btrfs: drop unused parameter from extent_map_tree_init
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / ipv4 / xfrm4_state.c
blob1717c64628d1c5c4625ca7b25a2b02422b52c61b
1 /*
2 * xfrm4_state.c
4 * Changes:
5 * YOSHIFUJI Hideaki @USAGI
6 * Split up af-specific portion
8 */
10 #include <net/ip.h>
11 #include <net/xfrm.h>
12 #include <linux/pfkeyv2.h>
13 #include <linux/ipsec.h>
14 #include <linux/netfilter_ipv4.h>
16 static int xfrm4_init_flags(struct xfrm_state *x)
18 if (ipv4_config.no_pmtu_disc)
19 x->props.flags |= XFRM_STATE_NOPMTUDISC;
20 return 0;
23 static void
24 __xfrm4_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl)
26 const struct flowi4 *fl4 = &fl->u.ip4;
28 sel->daddr.a4 = fl4->daddr;
29 sel->saddr.a4 = fl4->saddr;
30 sel->dport = xfrm_flowi_dport(fl, &fl4->uli);
31 sel->dport_mask = htons(0xffff);
32 sel->sport = xfrm_flowi_sport(fl, &fl4->uli);
33 sel->sport_mask = htons(0xffff);
34 sel->family = AF_INET;
35 sel->prefixlen_d = 32;
36 sel->prefixlen_s = 32;
37 sel->proto = fl4->flowi4_proto;
38 sel->ifindex = fl4->flowi4_oif;
41 static void
42 xfrm4_init_temprop(struct xfrm_state *x, const struct xfrm_tmpl *tmpl,
43 const xfrm_address_t *daddr, const xfrm_address_t *saddr)
45 x->id = tmpl->id;
46 if (x->id.daddr.a4 == 0)
47 x->id.daddr.a4 = daddr->a4;
48 x->props.saddr = tmpl->saddr;
49 if (x->props.saddr.a4 == 0)
50 x->props.saddr.a4 = saddr->a4;
51 x->props.mode = tmpl->mode;
52 x->props.reqid = tmpl->reqid;
53 x->props.family = AF_INET;
56 int xfrm4_extract_header(struct sk_buff *skb)
58 struct iphdr *iph = ip_hdr(skb);
60 XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph);
61 XFRM_MODE_SKB_CB(skb)->id = iph->id;
62 XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off;
63 XFRM_MODE_SKB_CB(skb)->tos = iph->tos;
64 XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl;
65 XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph);
66 memset(XFRM_MODE_SKB_CB(skb)->flow_lbl, 0,
67 sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl));
69 return 0;
72 static struct xfrm_state_afinfo xfrm4_state_afinfo = {
73 .family = AF_INET,
74 .proto = IPPROTO_IPIP,
75 .eth_proto = htons(ETH_P_IP),
76 .owner = THIS_MODULE,
77 .init_flags = xfrm4_init_flags,
78 .init_tempsel = __xfrm4_init_tempsel,
79 .init_temprop = xfrm4_init_temprop,
80 .output = xfrm4_output,
81 .extract_input = xfrm4_extract_input,
82 .extract_output = xfrm4_extract_output,
83 .transport_finish = xfrm4_transport_finish,
86 void __init xfrm4_state_init(void)
88 xfrm_state_register_afinfo(&xfrm4_state_afinfo);
91 #if 0
92 void __exit xfrm4_state_fini(void)
94 xfrm_state_unregister_afinfo(&xfrm4_state_afinfo);
96 #endif /* 0 */