Linux Audio

Check our new training course

Loading...
Note: File does not exist in v4.10.11.
 1#include <linux/kernel.h>
 2#include <linux/netfilter.h>
 3#include <linux/netfilter_ipv4.h>
 4#include <linux/netfilter_ipv6.h>
 5#include <net/netfilter/nf_queue.h>
 6
 7__sum16 nf_checksum(struct sk_buff *skb, unsigned int hook,
 8		    unsigned int dataoff, u_int8_t protocol,
 9		    unsigned short family)
10{
11	const struct nf_ipv6_ops *v6ops;
12	__sum16 csum = 0;
13
14	switch (family) {
15	case AF_INET:
16		csum = nf_ip_checksum(skb, hook, dataoff, protocol);
17		break;
18	case AF_INET6:
19		v6ops = rcu_dereference(nf_ipv6_ops);
20		if (v6ops)
21			csum = v6ops->checksum(skb, hook, dataoff, protocol);
22		break;
23	}
24
25	return csum;
26}
27EXPORT_SYMBOL_GPL(nf_checksum);
28
29__sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
30			    unsigned int dataoff, unsigned int len,
31			    u_int8_t protocol, unsigned short family)
32{
33	const struct nf_ipv6_ops *v6ops;
34	__sum16 csum = 0;
35
36	switch (family) {
37	case AF_INET:
38		csum = nf_ip_checksum_partial(skb, hook, dataoff, len,
39					      protocol);
40		break;
41	case AF_INET6:
42		v6ops = rcu_dereference(nf_ipv6_ops);
43		if (v6ops)
44			csum = v6ops->checksum_partial(skb, hook, dataoff, len,
45						       protocol);
46		break;
47	}
48
49	return csum;
50}
51EXPORT_SYMBOL_GPL(nf_checksum_partial);
52
53int nf_route(struct net *net, struct dst_entry **dst, struct flowi *fl,
54	     bool strict, unsigned short family)
55{
56	const struct nf_ipv6_ops *v6ops;
57	int ret = 0;
58
59	switch (family) {
60	case AF_INET:
61		ret = nf_ip_route(net, dst, fl, strict);
62		break;
63	case AF_INET6:
64		v6ops = rcu_dereference(nf_ipv6_ops);
65		if (v6ops)
66			ret = v6ops->route(net, dst, fl, strict);
67		break;
68	}
69
70	return ret;
71}
72EXPORT_SYMBOL_GPL(nf_route);
73
74int nf_reroute(struct sk_buff *skb, struct nf_queue_entry *entry)
75{
76	const struct nf_ipv6_ops *v6ops;
77	int ret = 0;
78
79	switch (entry->state.pf) {
80	case AF_INET:
81		ret = nf_ip_reroute(skb, entry);
82		break;
83	case AF_INET6:
84		v6ops = rcu_dereference(nf_ipv6_ops);
85		if (v6ops)
86			ret = v6ops->reroute(skb, entry);
87		break;
88	}
89	return ret;
90}