1 #ifndef __LINUX_NETFILTER_H
2 #define __LINUX_NETFILTER_H
10 #include <linux/wait.h>
11 #include <linux/list.h>
13 #ifdef CONFIG_NETFILTER
14 static inline int NF_DROP_GETERR(
int verdict)
22 return a1->
all[0] == a2->
all[0] &&
23 a1->
all[1] == a2->
all[1] &&
24 a1->
all[2] == a2->
all[2] &&
32 result->
all[0] = a1->
all[0] & mask->
all[0];
33 result->
all[1] = a1->
all[1] & mask->
all[1];
34 result->
all[2] = a1->
all[2] & mask->
all[2];
35 result->
all[3] = a1->
all[3] & mask->
all[3];
41 #define NF_MAX_HOOKS 8
45 typedef unsigned int nf_hookfn(
unsigned int hooknum,
63 struct nf_sockopt_ops {
73 int (*compat_set)(
struct sock *
sk,
int optval,
80 int (*compat_get)(
struct sock *
sk,
int optval,
100 #if defined(CONFIG_JUMP_LABEL)
103 static inline bool nf_hooks_active(
u_int8_t pf,
unsigned int hook)
105 if (__builtin_constant_p(pf) &&
106 __builtin_constant_p(hook))
107 return static_key_false(&nf_hooks_needed[pf][hook]);
109 return !list_empty(&nf_hooks[pf][hook]);
112 static inline bool nf_hooks_active(
u_int8_t pf,
unsigned int hook)
114 return !list_empty(&nf_hooks[pf][hook]);
120 int (*okfn)(
struct sk_buff *),
int thresh);
129 static inline int nf_hook_thresh(
u_int8_t pf,
unsigned int hook,
133 int (*okfn)(
struct sk_buff *),
int thresh)
135 if (nf_hooks_active(pf, hook))
136 return nf_hook_slow(pf, hook, skb, indev, outdev, okfn, thresh);
140 static inline int nf_hook(
u_int8_t pf,
unsigned int hook,
struct sk_buff *skb,
144 return nf_hook_thresh(pf, hook, skb, indev, outdev, okfn,
INT_MIN);
165 NF_HOOK_THRESH(
uint8_t pf,
unsigned int hook,
struct sk_buff *skb,
167 int (*okfn)(
struct sk_buff *),
int thresh)
169 int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh);
183 ((ret = nf_hook_thresh(pf, hook, skb, in, out, okfn,
INT_MIN)) == 1))
193 return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn,
INT_MIN);
202 int compat_nf_setsockopt(
struct sock *
sk,
u_int8_t pf,
int optval,
203 char __user *
opt,
unsigned int len);
204 int compat_nf_getsockopt(
struct sock *
sk,
u_int8_t pf,
int optval,
205 char __user *
opt,
int *len);
222 unsigned int dataoff,
226 struct flowi *
fl,
bool strict);
235 static inline const struct nf_afinfo *nf_get_afinfo(
unsigned short family)
241 nf_checksum(
struct sk_buff *skb,
unsigned int hook,
unsigned int dataoff,
244 const struct nf_afinfo *afinfo;
248 afinfo = nf_get_afinfo(family);
250 csum = afinfo->checksum(skb, hook, dataoff, protocol);
256 nf_checksum_partial(
struct sk_buff *skb,
unsigned int hook,
257 unsigned int dataoff,
unsigned int len,
258 u_int8_t protocol,
unsigned short family)
260 const struct nf_afinfo *afinfo;
264 afinfo = nf_get_afinfo(family);
266 csum = afinfo->checksum_partial(skb, hook, dataoff, len,
276 extern void (*nf_nat_decode_session_hook)(
struct sk_buff *,
struct flowi *);
281 #ifdef CONFIG_NF_NAT_NEEDED
292 #ifdef CONFIG_PROC_FS
298 #define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
299 #define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb)
300 static inline int nf_hook_thresh(
u_int8_t pf,
unsigned int hook,
304 int (*okfn)(
struct sk_buff *),
int thresh)
308 static inline int nf_hook(
u_int8_t pf,
unsigned int hook,
struct sk_buff *skb,
321 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
324 extern void (*nf_ct_destroy)(
struct nf_conntrack *)
__rcu;
334 extern struct nfq_ct_hook
__rcu *nfq_ct_hook;
336 struct nfq_ct_nat_hook {
338 u32 ctinfo,
int off);
340 extern struct nfq_ct_nat_hook
__rcu *nfq_ct_nat_hook;
342 static inline void nf_ct_attach(
struct sk_buff *
new,
struct sk_buff *skb) {}