1 packaging/utils/nattpatch 2.4
2 Index: linux-2.4.35.4/include/net/sock.h
3 ===================================================================
4 --- linux-2.4.35.4.orig/include/net/sock.h 2007-12-15 05:19:41.462783867 +0100
5 +++ linux-2.4.35.4/include/net/sock.h 2007-12-15 05:19:53.815487806 +0100
12 +#define UDP_OPT_IN_SOCK 1
19 * This structure really needs to be cleaned up.
20 * Most of it is for TCP, and not used by any of
22 #if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE)
23 struct spx_opt af_spx;
24 #endif /* CONFIG_SPX */
26 + struct udp_opt af_udp;
31 Index: linux-2.4.35.4/net/Config.in
32 ===================================================================
33 --- linux-2.4.35.4.orig/net/Config.in 2007-12-15 05:19:41.470784323 +0100
34 +++ linux-2.4.35.4/net/Config.in 2007-12-15 05:19:53.819488035 +0100
36 dep_tristate 'Packet Generator (USE WITH CAUTION)' CONFIG_NET_PKTGEN $CONFIG_PROC_FS
39 +bool 'IPSEC NAT-Traversal' CONFIG_IPSEC_NAT_TRAVERSAL
42 Index: linux-2.4.35.4/net/ipv4/udp.c
43 ===================================================================
44 --- linux-2.4.35.4.orig/net/ipv4/udp.c 2007-12-15 05:19:41.482785007 +0100
45 +++ linux-2.4.35.4/net/ipv4/udp.c 2007-12-15 05:19:53.823488264 +0100
48 static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
50 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
51 + struct udp_opt *tp = &(sk->tp_pinfo.af_udp);
54 * Charge it to the socket, dropping if the queue is full.
60 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
61 + if (tp->esp_in_udp) {
63 + * Set skb->sk and xmit packet to ipsec_rcv.
65 + * If ret != 0, ipsec_rcv refused the packet (not ESPinUDP),
66 + * restore skb->sk and fall back to sock_queue_rcv_skb
68 + struct inet_protocol *esp = NULL;
70 +#if defined(CONFIG_KLIPS) && !defined(CONFIG_KLIPS_MODULE)
71 + /* optomize only when we know it is statically linked */
72 + extern struct inet_protocol esp_protocol;
73 + esp = &esp_protocol;
75 + for (esp = (struct inet_protocol *)inet_protos[IPPROTO_ESP & (MAX_INET_PROTOS - 1)];
76 + (esp) && (esp->protocol != IPPROTO_ESP);
80 + if (esp && esp->handler) {
81 + struct sock *sav_sk = skb->sk;
83 + if (esp->handler(skb) == 0) {
85 + /*not sure we might count ESPinUDP as UDP...*/
86 + UDP_INC_STATS_BH(UdpInDatagrams);
94 if (sock_queue_rcv_skb(sk,skb)<0) {
95 UDP_INC_STATS_BH(UdpInErrors);
96 IP_INC_STATS_BH(IpInDiscards);
97 @@ -1100,13 +1137,49 @@
101 +static int udp_setsockopt(struct sock *sk, int level, int optname,
102 + char *optval, int optlen)
104 + struct udp_opt *tp = &(sk->tp_pinfo.af_udp);
108 + if (level != SOL_UDP)
109 + return ip_setsockopt(sk, level, optname, optval, optlen);
111 + if(optlen<sizeof(int))
114 + if (get_user(val, (int *)optval))
120 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
121 +#ifndef UDP_ESPINUDP
122 +#define UDP_ESPINUDP 100
125 + tp->esp_in_udp = val;
129 + err = -ENOPROTOOPT;
137 struct proto udp_prot = {
140 connect: udp_connect,
141 disconnect: udp_disconnect,
143 - setsockopt: ip_setsockopt,
144 + setsockopt: udp_setsockopt,
145 getsockopt: ip_getsockopt,
146 sendmsg: udp_sendmsg,
147 recvmsg: udp_recvmsg,