From b07fbc17e9994ab739ffd14ae1d9df38c22fdfea Mon Sep 17 00:00:00 2001 From: Joe Marcus Clarke Date: Tue, 23 Sep 2003 07:41:55 +0000 Subject: Add Cisco Skinny Station protocol support to libalias, natd, and ppp. Skinny is the protocol used by Cisco IP phones to talk to Cisco Call Managers. With this code, one can use a Cisco IP phone behind a FreeBSD NAT gateway. Currently, having the Call Manager behind the NAT gateway is not supported. More information on enabling Skinny support in libalias, natd, and ppp can be found in those applications' manpages. PR: 55843 Reviewed by: ru Approved by: ru MFC after: 30 days --- lib/libalias/Makefile | 2 +- lib/libalias/alias.c | 6 ++++++ lib/libalias/alias.h | 1 + lib/libalias/alias_db.c | 8 ++++++++ lib/libalias/alias_local.h | 4 ++++ lib/libalias/libalias.3 | 10 ++++++++++ 6 files changed, 30 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libalias/Makefile b/lib/libalias/Makefile index bf26f05268f0..f262be1a88fe 100644 --- a/lib/libalias/Makefile +++ b/lib/libalias/Makefile @@ -5,7 +5,7 @@ SHLIBDIR?= /lib SHLIB_MAJOR= 4 MAN= libalias.3 SRCS= alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \ - alias_nbt.c alias_pptp.c alias_proxy.c alias_smedia.c \ + alias_nbt.c alias_pptp.c alias_proxy.c alias_skinny.c alias_smedia.c \ alias_util.c INCS= alias.h diff --git a/lib/libalias/alias.c b/lib/libalias/alias.c index 54839ffb6a4d..cf93a74c79bb 100644 --- a/lib/libalias/alias.c +++ b/lib/libalias/alias.c @@ -917,6 +917,9 @@ TcpAliasIn(struct ip *pip) if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER || ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER) AliasHandlePptpIn(pip, link); + else if (skinnyPort != 0 && (ntohs(tc->th_dport) == skinnyPort + || ntohs(tc->th_sport) == skinnyPort)) + AliasHandleSkinny(pip, link); alias_address = GetAliasAddress(link); original_address = GetOriginalAddress(link); @@ -1098,6 +1101,9 @@ TcpAliasOut(struct ip *pip, int maxpacketsize) else if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER || ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER) AliasHandlePptpOut(pip, link); + else if (skinnyPort != 0 && (ntohs(tc->th_sport) == skinnyPort + || ntohs(tc->th_dport) == skinnyPort)) + AliasHandleSkinny(pip, link); /* Adjust TCP checksum since source port is being aliased */ /* and source address is being altered */ diff --git a/lib/libalias/alias.h b/lib/libalias/alias.h index eb35bf76d20c..b0c75c90a4d2 100644 --- a/lib/libalias/alias.h +++ b/lib/libalias/alias.h @@ -45,6 +45,7 @@ void PacketAliasInit(void); void PacketAliasSetAddress(struct in_addr _addr); void PacketAliasSetFWBase(unsigned int _base, unsigned int _num); +void PacketAliasSetSkinnyPort(unsigned int _port); unsigned int PacketAliasSetMode(unsigned int _flags, unsigned int _mask); void PacketAliasUninit(void); diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c index ec250702af9e..e53e94d64b51 100644 --- a/lib/libalias/alias_db.c +++ b/lib/libalias/alias_db.c @@ -398,6 +398,9 @@ static int fireWallFD = -1; /* File descriptor to be able to */ /* flag. */ #endif +unsigned int skinnyPort = 0; /* TCP port used by the Skinny */ + /* protocol. */ + @@ -2948,3 +2951,8 @@ PacketAliasSetFWBase(unsigned int base, unsigned int num) { fireWallNumNums = num; #endif } + +void +PacketAliasSetSkinnyPort(unsigned int port) { + skinnyPort = port; +} diff --git a/lib/libalias/alias_local.h b/lib/libalias/alias_local.h index 4428d2aa1941..d207f9f73b5d 100644 --- a/lib/libalias/alias_local.h +++ b/lib/libalias/alias_local.h @@ -74,6 +74,7 @@ /* Globals */ extern int packetAliasMode; +extern unsigned int skinnyPort; /* Prototypes */ @@ -212,6 +213,9 @@ int AliasHandleUdpNbtNS(struct ip *_pip, struct alias_link *_link, void AliasHandleCUSeeMeOut(struct ip *_pip, struct alias_link *_link); void AliasHandleCUSeeMeIn(struct ip *_pip, struct in_addr _original_addr); +/* Skinny routines */ +void AliasHandleSkinny(struct ip *_pip, struct alias_link *_link); + /* Transparent proxy routines */ int ProxyCheck(struct ip *_pip, struct in_addr *_proxy_server_addr, u_short *_proxy_server_port); diff --git a/lib/libalias/libalias.3 b/lib/libalias/libalias.3 index a75cd2b02947..e5ef09eb03ac 100644 --- a/lib/libalias/libalias.3 +++ b/lib/libalias/libalias.3 @@ -265,6 +265,16 @@ Set firewall range allocated for punching firewall holes (with the flag). The range will be cleared for all rules on initialization. .Ed +.Pp +.Ft void +.Fn PacketAliasSkinnyPort "unsigned int port" +.Bd -ragged -offset indent +Set the TCP port used by the Skinny Station protocol. +Skinny is used by Cisco IP phones to communicate with +Cisco Call Managers to set up voice over IP calls. +If this is not set, Skinny aliasing will not be done. +The typical port used by Skinny is 2000. +.Ed .Sh PACKET HANDLING The packet handling functions are used to modify incoming (remote to local) and outgoing (local to remote) packets. -- cgit v1.3