Linux 2.6.21.1
[linux/fpc-iii.git] / net / ipv4 / xfrm4_state.c
blob93e2c061cddaf3b71a7c6e3c0bae0a22f1b45d76
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>
15 static struct xfrm_state_afinfo xfrm4_state_afinfo;
17 static int xfrm4_init_flags(struct xfrm_state *x)
19 if (ipv4_config.no_pmtu_disc)
20 x->props.flags |= XFRM_STATE_NOPMTUDISC;
21 return 0;
24 static void
25 __xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl,
26 struct xfrm_tmpl *tmpl,
27 xfrm_address_t *daddr, xfrm_address_t *saddr)
29 x->sel.daddr.a4 = fl->fl4_dst;
30 x->sel.saddr.a4 = fl->fl4_src;
31 x->sel.dport = xfrm_flowi_dport(fl);
32 x->sel.dport_mask = htons(0xffff);
33 x->sel.sport = xfrm_flowi_sport(fl);
34 x->sel.sport_mask = htons(0xffff);
35 x->sel.prefixlen_d = 32;
36 x->sel.prefixlen_s = 32;
37 x->sel.proto = fl->proto;
38 x->sel.ifindex = fl->oif;
39 x->id = tmpl->id;
40 if (x->id.daddr.a4 == 0)
41 x->id.daddr.a4 = daddr->a4;
42 x->props.saddr = tmpl->saddr;
43 if (x->props.saddr.a4 == 0)
44 x->props.saddr.a4 = saddr->a4;
45 x->props.mode = tmpl->mode;
46 x->props.reqid = tmpl->reqid;
47 x->props.family = AF_INET;
50 static struct xfrm_state_afinfo xfrm4_state_afinfo = {
51 .family = AF_INET,
52 .init_flags = xfrm4_init_flags,
53 .init_tempsel = __xfrm4_init_tempsel,
54 .output = xfrm4_output,
57 void __init xfrm4_state_init(void)
59 xfrm_state_register_afinfo(&xfrm4_state_afinfo);
62 #if 0
63 void __exit xfrm4_state_fini(void)
65 xfrm_state_unregister_afinfo(&xfrm4_state_afinfo);
67 #endif /* 0 */