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