From 60356ac1dd1c49a236d7e4d880c20d62edbd92fc Mon Sep 17 00:00:00 2001 From: amurai Date: Sun, 24 May 1998 03:03:10 +0000 Subject: Primary verison of NetBIOS over TCP/IP. Now you can connect Windows DOMAIN as DOMAIN user through NAT function. See also RFC1002 for futher detail of SMB structure. Submitted by: Atsushi Murai --- lib/libalias/alias.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'lib/libalias/alias.c') diff --git a/lib/libalias/alias.c b/lib/libalias/alias.c index 8ae038b..4c15c5e 100644 --- a/lib/libalias/alias.c +++ b/lib/libalias/alias.c @@ -93,6 +93,9 @@ #include "alias_local.h" #include "alias.h" +#define NETBIOS_NS_PORT_NUMBER 137 +#define NETBIOS_DGM_PORT_NUMBER 138 +#define FTP_CONTROL_PORT_NUMBER 21 #define FTP_CONTROL_PORT_NUMBER 21 #define IRC_CONTROL_PORT_NUMBER_1 6667 #define IRC_CONTROL_PORT_NUMBER_2 6668 @@ -318,12 +321,12 @@ IcmpAliasIn2(struct ip *pip) link = FindUdpTcpIn(ip->ip_dst, ip->ip_src, tc->th_dport, tc->th_sport, IPPROTO_TCP); - else if (ip->ip_p == IPPROTO_ICMP) { + else if (ip->ip_p == IPPROTO_ICMP) if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP) link = FindIcmpIn(ip->ip_dst, ip->ip_src, ic2->icmp_id); else link = NULL; - } else + else link = NULL; if (link != NULL) @@ -605,6 +608,21 @@ UdpAliasIn(struct ip *pip) alias_port = ud->uh_dport; ud->uh_dport = GetOriginalPort(link); +/* If NETBIOS Datagram, It should be alias address in UDP Data, too */ + if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER + || ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER ) + { + AliasHandleUdpNbt(pip, link, &original_address, ud->uh_dport); + } else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER + || ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER ) + { + AliasHandleUdpNbtNS(pip, link, + &alias_address, + &alias_port, + &original_address, + &ud->uh_dport ); + } + /* If UDP checksum is not zero, then adjust since destination port */ /* is being unaliased and destination port is being altered. */ if (ud->uh_sum != 0) @@ -650,6 +668,21 @@ UdpAliasOut(struct ip *pip) alias_address = GetAliasAddress(link); alias_port = GetAliasPort(link); +/* If NETBIOS Datagram, It should be alias address in UDP Data, too */ + if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER + || ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER ) + { + AliasHandleUdpNbt(pip, link, &alias_address, alias_port); + } else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER + || ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER ) + { + AliasHandleUdpNbtNS(pip, link, + &pip->ip_src, + &ud->uh_sport, + &alias_address, + &alias_port); + } + /* If UDP checksum is not zero, adjust since source port is */ /* being aliased and source address is being altered */ if (ud->uh_sum != 0) @@ -668,7 +701,7 @@ UdpAliasOut(struct ip *pip) ADJUST_CHECKSUM(accumulate, ud->uh_sum) } -/* Put alias port in TCP header */ +/* Put alias port in UDP header */ ud->uh_sport = alias_port; /* Change source address */ -- cgit v1.1