1 /* xfrm4_tunnel.c: Generic IP tunnel transformer.
3 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
6 #include <linux/skbuff.h>
7 #include <linux/module.h>
8 #include <linux/mutex.h>
11 #include <net/protocol.h>
13 static int ipip_output(struct xfrm_state *x, struct sk_buff *skb)
18 iph->tot_len = htons(skb->len);
24 static int ipip_xfrm_rcv(struct xfrm_state *x, struct sk_buff *skb)
29 static int ipip_init_state(struct xfrm_state *x)
37 x->props.header_len = sizeof(struct iphdr);
42 static void ipip_destroy(struct xfrm_state *x)
46 static struct xfrm_type ipip_type = {
47 .description = "IPIP",
49 .proto = IPPROTO_IPIP,
50 .init_state = ipip_init_state,
51 .destructor = ipip_destroy,
52 .input = ipip_xfrm_rcv,
56 static int xfrm_tunnel_err(struct sk_buff *skb, u32 info)
61 static struct xfrm_tunnel xfrm_tunnel_handler = {
63 .err_handler = xfrm_tunnel_err,
67 static int __init ipip_init(void)
69 if (xfrm_register_type(&ipip_type, AF_INET) < 0) {
70 printk(KERN_INFO "ipip init: can't add xfrm type\n");
73 if (xfrm4_tunnel_register(&xfrm_tunnel_handler)) {
74 printk(KERN_INFO "ipip init: can't add xfrm handler\n");
75 xfrm_unregister_type(&ipip_type, AF_INET);
81 static void __exit ipip_fini(void)
83 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler))
84 printk(KERN_INFO "ipip close: can't remove xfrm handler\n");
85 if (xfrm_unregister_type(&ipip_type, AF_INET) < 0)
86 printk(KERN_INFO "ipip close: can't remove xfrm type\n");
89 module_init(ipip_init);
90 module_exit(ipip_fini);
91 MODULE_LICENSE("GPL");