1 packaging/utils/nattpatch 2.4
2 --- linux/include/net/sock.h 2002/02/06 15:25:10 1.1
3 +++ linux/include/net/sock.h 2002/05/22 12:14:56
10 +#define UDP_OPT_IN_SOCK 1
17 * This structure really needs to be cleaned up.
18 * Most of it is for TCP, and not used by any of
20 #if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE)
21 struct spx_opt af_spx;
22 #endif /* CONFIG_SPX */
24 + struct udp_opt af_udp;
29 --- linux/net/Config.in.orig Fri Feb 9 14:34:13 2001
30 +++ linux/net/Config.in Thu Feb 22 19:40:08 2001
34 +bool 'IPSEC NAT-Traversal' CONFIG_IPSEC_NAT_TRAVERSAL
37 --- linux/net/ipv4/udp.c.1 Wed Jan 28 15:57:05 2004
38 +++ linux/net/ipv4/udp.c Wed Jan 28 15:58:56 2004
41 static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
43 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
44 + struct udp_opt *tp = &(sk->tp_pinfo.af_udp);
47 * Charge it to the socket, dropping if the queue is full.
53 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
54 + if (tp->esp_in_udp) {
56 + * Set skb->sk and xmit packet to ipsec_rcv.
58 + * If ret != 0, ipsec_rcv refused the packet (not ESPinUDP),
59 + * restore skb->sk and fall back to sock_queue_rcv_skb
61 + struct inet_protocol *esp = NULL;
63 +#if defined(CONFIG_KLIPS) && !defined(CONFIG_KLIPS_MODULE)
64 + /* optomize only when we know it is statically linked */
65 + extern struct inet_protocol esp_protocol;
66 + esp = &esp_protocol;
68 + for (esp = (struct inet_protocol *)inet_protos[IPPROTO_ESP & (MAX_INET_PROTOS - 1)];
69 + (esp) && (esp->protocol != IPPROTO_ESP);
73 + if (esp && esp->handler) {
74 + struct sock *sav_sk = skb->sk;
76 + if (esp->handler(skb) == 0) {
78 + /*not sure we might count ESPinUDP as UDP...*/
79 + UDP_INC_STATS_BH(UdpInDatagrams);
87 if (sock_queue_rcv_skb(sk,skb)<0) {
88 UDP_INC_STATS_BH(UdpInErrors);
89 IP_INC_STATS_BH(IpInDiscards);
90 @@ -1027,13 +1064,49 @@
94 +static int udp_setsockopt(struct sock *sk, int level, int optname,
95 + char *optval, int optlen)
97 + struct udp_opt *tp = &(sk->tp_pinfo.af_udp);
101 + if (level != SOL_UDP)
102 + return ip_setsockopt(sk, level, optname, optval, optlen);
104 + if(optlen<sizeof(int))
107 + if (get_user(val, (int *)optval))
113 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
114 +#ifndef UDP_ESPINUDP
115 +#define UDP_ESPINUDP 100
118 + tp->esp_in_udp = val;
122 + err = -ENOPROTOOPT;
130 struct proto udp_prot = {
133 connect: udp_connect,
134 disconnect: udp_disconnect,
136 - setsockopt: ip_setsockopt,
137 + setsockopt: udp_setsockopt,
138 getsockopt: ip_getsockopt,
139 sendmsg: udp_sendmsg,
140 recvmsg: udp_recvmsg,