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 #else
48 #define MOD_INC_USE_COUNT
49 #define MOD_DEC_USE_COUNT
50 #endif
51
52
53
54
55
56
57
58
59
60
61
62 int ipip_rcv(struct sk_buff *skb, struct device *dev, struct options *opt,
63 __u32 daddr, unsigned short len, __u32 saddr,
64 int redo, struct inet_protocol *protocol)
65 {
66 #ifdef CONFIG_IP_FIREWALL
67 int err;
68 #endif
69
70 MOD_INC_USE_COUNT;
71 #ifdef TUNNEL_DEBUG
72 printk("ipip_rcv: got a packet!\n");
73 #endif
74
75
76
77
78 skb_pull(skb, ((struct iphdr *)skb->data)->ihl<<2);
79
80
81
82
83
84 skb->h.iph=(struct iphdr *)skb->data;
85 skb->ip_hdr=(struct iphdr *)skb->data;
86 memset(skb->proto_priv, 0, sizeof(struct options));
87 if (skb->ip_hdr->ihl > 5) {
88 if (ip_options_compile(NULL, skb))
89 return 0;
90 }
91
92 #ifdef CONFIG_IP_FIREWALL
93
94
95
96
97 if((err=ip_fw_chk(skb->ip_hdr,dev,ip_fw_blk_chain, ip_fw_blk_policy,0))<FW_ACCEPT)
98 {
99 if(err==FW_REJECT)
100 icmp_send(skb,ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0 , dev);
101 kfree_skb(skb, FREE_READ);
102 return 0;
103 }
104 #endif
105
106
107
108
109
110
111
112
113
114
115
116
117 if(ip_forward(skb, dev, 0, daddr))
118 kfree_skb(skb, FREE_READ);
119 MOD_DEC_USE_COUNT;
120 return(0);
121 }
122
123 #ifdef MODULE
124 static struct inet_protocol ipip_protocol = {
125 ipip_rcv,
126 NULL,
127 NULL,
128 0,
129 IPPROTO_IPIP,
130 0,
131 NULL,
132 "IPIP"
133 };
134
135
136
137
138
139
140 int init_module( void)
141 {
142 inet_add_protocol(&ipip_protocol);
143 return 0;
144 }
145
146 void cleanup_module( void)
147 {
148 if ( inet_del_protocol(&ipip_protocol) < 0 )
149 printk("ipip close: can't remove protocol\n");
150 }
151
152 #endif
153 #endif