This source file includes following definitions.
- ipip_rcv
- init_module
- cleanup_module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <linux/types.h>
22 #include <linux/sched.h>
23 #include <linux/kernel.h>
24 #include <linux/skbuff.h>
25 #include <linux/netdevice.h>
26 #include <linux/in.h>
27 #include <net/datalink.h>
28 #include <net/sock.h>
29 #include <net/ip.h>
30 #include <net/icmp.h>
31 #include <linux/tcp.h>
32 #include <linux/udp.h>
33 #include <net/protocol.h>
34 #include <net/ipip.h>
35 #include <linux/ip_fw.h>
36
37
38
39
40
41 #if ( defined(CONFIG_NET_IPIP) && defined(CONFIG_IP_FORWARD)) || defined(MODULE)
42 #ifdef MODULE
43 #include <linux/module.h>
44 #include <linux/version.h>
45
46 static char kernel_version[] = UTS_RELEASE;
47
48 #else
49 #define MOD_INC_USE_COUNT
50 #define MOD_DEC_USE_COUNT
51 #endif
52
53
54
55
56
57
58
59
60
61
62
63 int ipip_rcv(struct sk_buff *skb, struct device *dev, struct options *opt,
64 __u32 daddr, unsigned short len, __u32 saddr,
65 int redo, struct inet_protocol *protocol)
66 {
67 #ifdef CONFIG_IP_FIREWALL
68 int err;
69 #endif
70
71 MOD_INC_USE_COUNT;
72 #ifdef TUNNEL_DEBUG
73 printk("ipip_rcv: got a packet!\n");
74 #endif
75
76
77
78
79 skb_pull(skb, ((struct iphdr *)skb->data)->ihl<<2);
80
81
82
83
84
85 skb->h.iph=(struct iphdr *)skb->data;
86 skb->ip_hdr=(struct iphdr *)skb->data;
87
88 #ifdef CONFIG_IP_FIREWALL
89
90
91
92
93 if((err=ip_fw_chk(skb->ip_hdr,dev,ip_fw_blk_chain, ip_fw_blk_policy,0))<FW_ACCEPT)
94 {
95 if(err==FW_REJECT)
96 icmp_send(skb,ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0 , dev);
97 kfree_skb(skb, FREE_READ);
98 return 0;
99 }
100 #endif
101
102
103
104
105
106
107
108
109
110
111
112
113 if(ip_forward(skb, dev, 0, daddr, 0))
114 kfree_skb(skb, FREE_READ);
115 MOD_DEC_USE_COUNT;
116 return(0);
117 }
118
119 #ifdef MODULE
120 static struct inet_protocol ipip_protocol = {
121 ipip_rcv,
122 NULL,
123 NULL,
124 0,
125 IPPROTO_IPIP,
126 0,
127 NULL,
128 "IPIP"
129 };
130
131
132
133
134
135
136 int init_module( void)
137 {
138 inet_add_protocol(&ipip_protocol);
139 return 0;
140 }
141
142 void cleanup_module( void)
143 {
144 if ( inet_del_protocol(&ipip_protocol) < 0 )
145 printk("ipip close: can't remove protocol\n");
146 }
147
148 #endif
149 #endif