[NET] IPV4: Fix whitespace errors.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / ipv4 / xfrm4_tunnel.c
CommitLineData
1da177e4
LT
1/* xfrm4_tunnel.c: Generic IP tunnel transformer.
2 *
3 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
4 */
5
6#include <linux/skbuff.h>
7#include <linux/module.h>
4a3e2f71 8#include <linux/mutex.h>
1da177e4
LT
9#include <net/xfrm.h>
10#include <net/ip.h>
11#include <net/protocol.h>
12
13static int ipip_output(struct xfrm_state *x, struct sk_buff *skb)
14{
15 struct iphdr *iph;
e905a9ed 16
1da177e4
LT
17 iph = skb->nh.iph;
18 iph->tot_len = htons(skb->len);
19 ip_send_check(iph);
20
21 return 0;
22}
23
e695633e 24static int ipip_xfrm_rcv(struct xfrm_state *x, struct sk_buff *skb)
1da177e4
LT
25{
26 return 0;
27}
28
72cb6962 29static int ipip_init_state(struct xfrm_state *x)
1da177e4 30{
7e49e6de 31 if (x->props.mode != XFRM_MODE_TUNNEL)
1da177e4
LT
32 return -EINVAL;
33
34 if (x->encap)
35 return -EINVAL;
36
37 x->props.header_len = sizeof(struct iphdr);
38
39 return 0;
40}
41
42static void ipip_destroy(struct xfrm_state *x)
43{
44}
45
46static struct xfrm_type ipip_type = {
47 .description = "IPIP",
48 .owner = THIS_MODULE,
49 .proto = IPPROTO_IPIP,
50 .init_state = ipip_init_state,
51 .destructor = ipip_destroy,
52 .input = ipip_xfrm_rcv,
53 .output = ipip_output
54};
55
d2acc347
HX
56static int xfrm_tunnel_err(struct sk_buff *skb, u32 info)
57{
58 return -ENOENT;
59}
60
61static struct xfrm_tunnel xfrm_tunnel_handler = {
62 .handler = xfrm4_rcv,
63 .err_handler = xfrm_tunnel_err,
64 .priority = 2,
1da177e4
LT
65};
66
67static int __init ipip_init(void)
68{
69 if (xfrm_register_type(&ipip_type, AF_INET) < 0) {
70 printk(KERN_INFO "ipip init: can't add xfrm type\n");
71 return -EAGAIN;
72 }
d2acc347
HX
73 if (xfrm4_tunnel_register(&xfrm_tunnel_handler)) {
74 printk(KERN_INFO "ipip init: can't add xfrm handler\n");
1da177e4
LT
75 xfrm_unregister_type(&ipip_type, AF_INET);
76 return -EAGAIN;
77 }
78 return 0;
79}
80
81static void __exit ipip_fini(void)
82{
d2acc347
HX
83 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler))
84 printk(KERN_INFO "ipip close: can't remove xfrm handler\n");
1da177e4
LT
85 if (xfrm_unregister_type(&ipip_type, AF_INET) < 0)
86 printk(KERN_INFO "ipip close: can't remove xfrm type\n");
87}
88
89module_init(ipip_init);
90module_exit(ipip_fini);
91MODULE_LICENSE("GPL");