diff -u --recursive --new-file linux-ipportfw/CREDITS linux-loose-udp/CREDITS --- linux-ipportfw/CREDITS Sun Nov 15 10:32:41 1998 +++ linux-loose-udp/CREDITS Mon Mar 22 09:36:48 1999 @@ -259,6 +259,7 @@ S: USA N: Juan Jose Ciarlante +W: http://juanjox.linuxhq.com E: jjciarla@raiz.uncu.edu.ar E: juanjo@irriga.uncu.edu.ar D: Network driver alias support @@ -794,6 +795,11 @@ E: lam836@cs.cuhk.hk D: Author of the dialog utility, foundation D: for Menuconfig's lxdialog. + +N: Glenn Lamb +E: mumford@netcom.com +P: 2048/0C8058F1 E3 0F DE CC 94 72 D1 1A 2D 2E A9 08 6B A0 CD 82 +D: Network driver alias support N: Volker Lendecke E: lendecke@namu01.Num.Math.Uni-Goettingen.de diff -u --recursive --new-file linux-ipportfw/Documentation/Configure.help linux-loose-udp/Documentation/Configure.help --- linux-ipportfw/Documentation/Configure.help Mon Mar 22 09:32:39 1999 +++ linux-loose-udp/Documentation/Configure.help Mon Mar 22 09:37:33 1999 @@ -1175,6 +1175,15 @@ rules (using the ipfwadm utility) and/or by doing an appropriate bind() system call. +IP: loose UDP port managing (EXPERIMENTAL) +CONFIG_IP_MASQ_LOOSE_UDP + This enables your Linux masquerading host to support peer-to-peer + UDP games such as Battlezone, Starcraft or Heavy Gear 2. Any UDP + peer-to-peer game that uses the technique outlined at + http://alumni.caltech.edu/~dank/peer-nat.html + should work behind a Masqerading host. Port forwarding may or may + not be necessary. + IP: masquerading CONFIG_IP_MASQUERADE If one of the computers on your local network for which your Linux diff -u --recursive --new-file linux-ipportfw/include/net/ip_masq.h linux-loose-udp/include/net/ip_masq.h --- linux-ipportfw/include/net/ip_masq.h Tue Dec 2 14:20:39 1997 +++ linux-loose-udp/include/net/ip_masq.h Mon Mar 22 09:38:51 1999 @@ -57,6 +57,10 @@ #define IP_MASQ_F_NO_REPLY 0x800 /* no reply yet from outside */ #define IP_MASQ_F_AFW_PORT 0x1000 +#ifdef CONFIG_IP_MASQ_LOOSE_UDP +# define IP_MASQ_F_DLOOSE 0x2000 /* loose dest binding */ +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ + #ifdef __KERNEL__ /* diff -u --recursive --new-file linux-ipportfw/net/ipv4/Config.in linux-loose-udp/net/ipv4/Config.in --- linux-ipportfw/net/ipv4/Config.in Mon Mar 22 09:32:39 1999 +++ linux-loose-udp/net/ipv4/Config.in Mon Mar 22 09:39:38 1999 @@ -22,6 +22,7 @@ fi if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then bool 'IP: transparent proxy support (EXPERIMENTAL)' CONFIG_IP_TRANSPARENT_PROXY + bool 'IP: loose UDP port managing (EXPERIMENTAL)' CONFIG_IP_MASQ_LOOSE_UDP fi bool 'IP: always defragment' CONFIG_IP_ALWAYS_DEFRAG fi diff -u --recursive --new-file linux-ipportfw/net/ipv4/ip_masq.c linux-loose-udp/net/ipv4/ip_masq.c --- linux-ipportfw/net/ipv4/ip_masq.c Mon Mar 22 09:32:39 1999 +++ linux-loose-udp/net/ipv4/ip_masq.c Mon Mar 22 09:52:33 1999 @@ -21,6 +21,8 @@ * Nigel Metheringham : ICMP in ICMP handling, tidy ups, bug fixes, made ICMP optional * Juan Jose Ciarlante : re-assign maddr if no packet received from outside * Steven Clarke : Added Port Forwarding + * Dan Kegel : behavior for UDP streams for 2.1.* + * Glenn Lamb : backported above to 2.0.36 * */ @@ -153,6 +155,19 @@ struct ip_fw_masq *ip_masq_expire = &ip_masq_dummy; +#ifdef CONFIG_IP_MASQ_LOOSE_UDP + +/* + * These flags enable non-strict d{addr,port} checks + * Given that both (in/out) lookup tables are hashed + * by m{addr,port} and s{addr,port} this is quite easy + */ + +#define MASQ_DADDR_PASS (IP_MASQ_F_NO_DADDR|IP_MASQ_F_DLOOSE) +#define MASQ_DPORT_PASS (IP_MASQ_F_NO_DPORT|IP_MASQ_F_DLOOSE) + +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ + #ifdef CONFIG_IP_MASQUERADE_IPAUTOFW /* * Auto-forwarding table @@ -414,6 +429,16 @@ hash = ip_masq_hash_key(protocol, d_addr, d_port); for(ms = ip_masq_m_tab[hash]; ms ; ms = ms->m_link) { + +#ifdef CONFIG_IP_MASQ_LOOSE_UDP + if (protocol==ms->protocol && + ((s_addr==ms->daddr || ms->flags & MASQ_DADDR_PASS) +#ifdef CONFIG_IP_MASQUERADE_IPAUTOFW + || (ms->dport==htons(1558)) +#endif /* CONFIG_IP_MASQUERADE_IPAUTOFW */ + ) && + (s_port==ms->dport || ms->flags & MASQ_DPORT_PASS)) { +#else /* CONFIG_IP_MASQ_LOOSE_UDP */ if (protocol==ms->protocol && ((s_addr==ms->daddr || ms->flags & IP_MASQ_F_NO_DADDR) #ifdef CONFIG_IP_MASQUERADE_IPAUTOFW @@ -422,6 +447,8 @@ ) && (s_port==ms->dport || ms->flags & IP_MASQ_F_NO_DPORT) && (d_addr==ms->maddr && d_port==ms->mport)) { +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ + #ifdef DEBUG_IP_MASQUERADE_VERBOSE printk("MASQ: look/in %d %08X:%04hX->%08X:%04hX OK\n", protocol, @@ -492,7 +519,13 @@ for(ms = ip_masq_s_tab[hash]; ms ; ms = ms->s_link) { if (protocol == ms->protocol && s_addr == ms->saddr && s_port == ms->sport && +#ifdef CONFIG_IP_MASQ_LOOSE_UDP + (d_addr == ms->daddr || ms->flags & MASQ_DADDR_PASS) && + (d_port == ms->dport || ms->flags & MASQ_DPORT_PASS)) { +#else d_addr == ms->daddr && d_port == ms->dport ) { +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ + #ifdef DEBUG_IP_MASQUERADE_VERBOSE printk("MASQ: lk/out1 %d %08X:%04hX->%08X:%04hX OK\n", protocol, @@ -666,7 +699,14 @@ ms->control = NULL; if (proto == IPPROTO_UDP && !matchport) - ms->flags |= IP_MASQ_F_NO_DADDR; +#ifdef CONFIG_IP_MASQ_LOOSE_UDP + /* + * Flag this tunnel as "dest loose" + */ + ms->flags |= IP_MASQ_F_DLOOSE; +#else + ms->flags |= IP_MASQ_F_NO_DADDR; +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ /* get masq address from rif */ ms->maddr = dev->pa_addr; @@ -881,6 +921,15 @@ printk("ip_fw_masquerade(): filled sport=%d\n", ntohs(ms->sport)); #endif +#ifdef CONFIG_IP_MASQ_LOOSE_UDP + if (ms->flags & IP_MASQ_F_DLOOSE) { + /* + * update dest loose values + */ + ms->dport = portptr[1]; + ms->daddr = iph->daddr; + } +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ } } @@ -1562,6 +1611,17 @@ * Set dport if not defined yet. */ +#ifdef CONFIG_IP_MASQ_LOOSE_UDP + /* + * Set daddr,dport if not yet defined + * and tunnel is not set up as "dest loose" + */ + if ( ms->flags & IP_MASQ_F_DLOOSE) { + ms->daddr = iph->saddr; + ms->dport = portptr[0]; + } else { +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ + if ( ms->flags & IP_MASQ_F_NO_DPORT && ms->protocol == IPPROTO_TCP ) { ms->flags &= ~IP_MASQ_F_NO_DPORT; ms->dport = portptr[0]; @@ -1578,6 +1638,9 @@ ntohs(ms->daddr)); #endif } +#ifdef CONFIG_IP_MASQ_LOOSE_UDP + } +#endif /* CONFIG_IP_MASQ_LOOSE_UDP */ iph->daddr = ms->saddr; portptr[1] = ms->sport;