acpi: fix integer as NULL pointer warning
[linux-2.6/openmoko-kernel/knife-kernel.git] / net / ipv4 / xfrm4_state.c
blob07735ed280d720f32ac7269c5099c1e840d866d7
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 struct xfrm_state_afinfo xfrm4_state_afinfo;
18 static int xfrm4_init_flags(struct xfrm_state *x)
20 if (ipv4_config.no_pmtu_disc)
21 x->props.flags |= XFRM_STATE_NOPMTUDISC;
22 return 0;
25 static void
26 __xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl,
27 struct xfrm_tmpl *tmpl,
28 xfrm_address_t *daddr, xfrm_address_t *saddr)
30 x->sel.daddr.a4 = fl->fl4_dst;
31 x->sel.saddr.a4 = fl->fl4_src;
32 x->sel.dport = xfrm_flowi_dport(fl);
33 x->sel.dport_mask = htons(0xffff);
34 x->sel.sport = xfrm_flowi_sport(fl);
35 x->sel.sport_mask = htons(0xffff);
36 x->sel.prefixlen_d = 32;
37 x->sel.prefixlen_s = 32;
38 x->sel.proto = fl->proto;
39 x->sel.ifindex = fl->oif;
40 x->id = tmpl->id;
41 if (x->id.daddr.a4 == 0)
42 x->id.daddr.a4 = daddr->a4;
43 x->props.saddr = tmpl->saddr;
44 if (x->props.saddr.a4 == 0)
45 x->props.saddr.a4 = saddr->a4;
46 x->props.mode = tmpl->mode;
47 x->props.reqid = tmpl->reqid;
48 x->props.family = AF_INET;
51 int xfrm4_extract_header(struct sk_buff *skb)
53 struct iphdr *iph = ip_hdr(skb);
55 XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph);
56 XFRM_MODE_SKB_CB(skb)->id = iph->id;
57 XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off;
58 XFRM_MODE_SKB_CB(skb)->tos = iph->tos;
59 XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl;
60 XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph);
61 memset(XFRM_MODE_SKB_CB(skb)->flow_lbl, 0,
62 sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl));
64 return 0;
67 static struct xfrm_state_afinfo xfrm4_state_afinfo = {
68 .family = AF_INET,
69 .proto = IPPROTO_IPIP,
70 .eth_proto = htons(ETH_P_IP),
71 .owner = THIS_MODULE,
72 .init_flags = xfrm4_init_flags,
73 .init_tempsel = __xfrm4_init_tempsel,
74 .output = xfrm4_output,
75 .extract_input = xfrm4_extract_input,
76 .extract_output = xfrm4_extract_output,
77 .transport_finish = xfrm4_transport_finish,
80 void __init xfrm4_state_init(void)
82 xfrm_state_register_afinfo(&xfrm4_state_afinfo);
85 #if 0
86 void __exit xfrm4_state_fini(void)
88 xfrm_state_unregister_afinfo(&xfrm4_state_afinfo);
90 #endif /* 0 */