1 /* 2 * Linux NET3: IP/IP protocol decoder. 3 * 4 * Authors: 5 * Sam Lantinga (slouken@cs.ucdavis.edu) 02/01/95 6 * 7 * Fixes: 8 * Alan Cox : Merged and made usable non modular (its so tiny its silly as 9 * a module taking up 2 pages). 10 * Alan Cox : Fixed bug with 1.3.18 and IPIP not working (now needs to set skb->h.iph) 11 * to keep ip_forward happy. 12 * Alan Cox : More fixes for 1.3.21, and firewall fix. Maybe this will work soon 8). 13 * Kai Schulte : Fixed #defines for IP_FIREWALL->FIREWALL 14 * 15 * This program is free software; you can redistribute it and/or 16 * modify it under the terms of the GNU General Public License 17 * as published by the Free Software Foundation; either version 18 * 2 of the License, or (at your option) any later version. 19 * 20 */ 21
22 #include <linux/module.h>
23
24 #include <linux/config.h>
25 #include <linux/types.h>
26 #include <linux/sched.h>
27 #include <linux/kernel.h>
28 #include <linux/skbuff.h>
29 #include <linux/netdevice.h>
30 #include <linux/in.h>
31 #include <linux/tcp.h>
32 #include <linux/udp.h>
33 #include <linux/firewall.h>
34 #include <linux/config.h> /* For CONFIG_FIREWALL */ 35
36 #include <net/datalink.h>
37 #include <net/sock.h>
38 #include <net/ip.h>
39 #include <net/icmp.h>
40 #include <net/protocol.h>
41 #include <net/ipip.h>
42
43 /* 44 * The IPIP protocol driver. 45 * 46 * On entry here 47 * skb->data is the original IP header 48 * skb->ip_hdr points to the initial IP header. 49 * skb->h.raw points at the new header. 50 */ 51
52 intipip_rcv(structsk_buff *skb, structdevice *dev, structoptions *opt,
/* */ 53 __u32daddr, unsignedshortlen, __u32saddr,
54 intredo, structinet_protocol *protocol)
55 { 56 #ifdefCONFIG_FIREWALL 57 interr;
58 #endif 59 /* Don't unlink in the middle of a turnaround */ 60 MOD_INC_USE_COUNT;
61 #ifdefTUNNEL_DEBUG 62 printk("ipip_rcv: got a packet!\n");
63 #endif 64 /* 65 * Discard the original IP header 66 */ 67
68 skb_pull(skb, ((structiphdr *)skb->data)->ihl<<2);
69
70 /* 71 * Adjust pointers 72 */ 73
74 skb->h.iph=(structiphdr *)skb->data;
75 skb->ip_hdr=(structiphdr *)skb->data;
76 memset(skb->proto_priv, 0, sizeof(structoptions));
77
78 /* 79 * If you want to add LZ compressed IP or things like that here, 80 * and in drivers/net/tunnel.c are the places to add. 81 */ 82
83 /* skb=lzw_uncompress(skb); */ 84
85 /* 86 * Feed it to the IP layer. 87 */ 88 ip_rcv(skb, dev, NULL);
89
90 MOD_DEC_USE_COUNT;
91 return(0);
92 } 93
94 #ifdefMODULE 95
96 staticstructinet_protocolipip_protocol = { 97 ipip_rcv, /* IPIP handler */ 98 #if 0
99 NULL, /* Will be UDP fraglist handler */ 100 #endif 101 NULL, /* TUNNEL error control */ 102 0, /* next */ 103 IPPROTO_IPIP, /* protocol ID */ 104 0, /* copy */ 105 NULL, /* data */ 106 "IPIP" /* name */ 107 };
108
109
110 /* 111 * And now the modules code and kernel interface. 112 */ 113
114 intinit_module( void)
/* */ 115 { 116 inet_add_protocol(&ipip_protocol);
117 return 0;
118 } 119
120 voidcleanup_module( void)
/* */ 121 { 122 if ( inet_del_protocol(&ipip_protocol) < 0 )
123 printk("ipip close: can't remove protocol\n");
124 } 125
126 #endif