Blame view

include/linux/netfilter.h 11.3 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  #ifndef __LINUX_NETFILTER_H
  #define __LINUX_NETFILTER_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
  #include <linux/init.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
5
6
  #include <linux/skbuff.h>
  #include <linux/net.h>
  #include <linux/if.h>
2e3075a2c   Jan Engelhardt   [NETFILTER]: Exte...
7
8
  #include <linux/in.h>
  #include <linux/in6.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
10
  #include <linux/wait.h>
  #include <linux/list.h>
d1c85c2eb   Zhouyi Zhou   netfilter: HAVE_J...
11
  #include <linux/static_key.h>
a263653ed   Pablo Neira Ayuso   netfilter: don't ...
12
  #include <linux/netfilter_defs.h>
085db2c04   Eric W. Biederman   netfilter: Per ne...
13
14
  #include <linux/netdevice.h>
  #include <net/net_namespace.h>
a263653ed   Pablo Neira Ayuso   netfilter: don't ...
15

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
  #ifdef CONFIG_NETFILTER
f615df76e   Florian Westphal   netfilter: reduce...
17
18
19
20
  static inline int NF_DROP_GETERR(int verdict)
  {
  	return -(verdict >> NF_VERDICT_QBITS);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21

b8beedd25   Patrick McHardy   [NETFILTER]: Add ...
22
23
24
25
26
27
28
29
  static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1,
  				   const union nf_inet_addr *a2)
  {
  	return a1->all[0] == a2->all[0] &&
  	       a1->all[1] == a2->all[1] &&
  	       a1->all[2] == a2->all[2] &&
  	       a1->all[3] == a2->all[3];
  }
efdedd542   Denys Fedoryshchenko   netfilter: xt_rec...
30
31
32
33
34
35
36
37
38
  static inline void nf_inet_addr_mask(const union nf_inet_addr *a1,
  				     union nf_inet_addr *result,
  				     const union nf_inet_addr *mask)
  {
  	result->all[0] = a1->all[0] & mask->all[0];
  	result->all[1] = a1->all[1] & mask->all[1];
  	result->all[2] = a1->all[2] & mask->all[2];
  	result->all[3] = a1->all[3] & mask->all[3];
  }
a0f4ecf34   Joe Perches   netfilter: Remove...
39
  int netfilter_init(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
  struct sk_buff;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42

795aa6ef6   Patrick McHardy   netfilter: pass h...
43
  struct nf_hook_ops;
cfdfab314   David S. Miller   netfilter: Create...
44

1c984f8a5   David Miller   netfilter: Add so...
45
  struct sock;
cfdfab314   David S. Miller   netfilter: Create...
46
47
48
49
50
51
  struct nf_hook_state {
  	unsigned int hook;
  	int thresh;
  	u_int8_t pf;
  	struct net_device *in;
  	struct net_device *out;
1c984f8a5   David Miller   netfilter: Add so...
52
  	struct sock *sk;
f71914834   Pablo Neira   netfilter: add ho...
53
  	struct list_head *hook_list;
7026b1ddb   David Miller   netfilter: Pass s...
54
  	int (*okfn)(struct sock *, struct sk_buff *);
cfdfab314   David S. Miller   netfilter: Create...
55
  };
107a9f4dc   David Miller   netfilter: Add nf...
56
  static inline void nf_hook_state_init(struct nf_hook_state *p,
f71914834   Pablo Neira   netfilter: add ho...
57
  				      struct list_head *hook_list,
107a9f4dc   David Miller   netfilter: Add nf...
58
59
60
61
  				      unsigned int hook,
  				      int thresh, u_int8_t pf,
  				      struct net_device *indev,
  				      struct net_device *outdev,
1c984f8a5   David Miller   netfilter: Add so...
62
  				      struct sock *sk,
7026b1ddb   David Miller   netfilter: Pass s...
63
  				      int (*okfn)(struct sock *, struct sk_buff *))
107a9f4dc   David Miller   netfilter: Add nf...
64
65
66
67
68
69
  {
  	p->hook = hook;
  	p->thresh = thresh;
  	p->pf = pf;
  	p->in = indev;
  	p->out = outdev;
1c984f8a5   David Miller   netfilter: Add so...
70
  	p->sk = sk;
f71914834   Pablo Neira   netfilter: add ho...
71
  	p->hook_list = hook_list;
107a9f4dc   David Miller   netfilter: Add nf...
72
73
  	p->okfn = okfn;
  }
795aa6ef6   Patrick McHardy   netfilter: pass h...
74
  typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
3db05fea5   Herbert Xu   [NETFILTER]: Repl...
75
  			       struct sk_buff *skb,
238e54c9c   David S. Miller   netfilter: Make n...
76
  			       const struct nf_hook_state *state);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77

d94d9fee9   Eric Dumazet   net: cleanup incl...
78
  struct nf_hook_ops {
87d5c18ce   Pablo Neira   netfilter: cleanu...
79
  	struct list_head 	list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80
81
  
  	/* User fills in from here down. */
87d5c18ce   Pablo Neira   netfilter: cleanu...
82
  	nf_hookfn		*hook;
e687ad60a   Pablo Neira   netfilter: add ne...
83
  	struct net_device	*dev;
87d5c18ce   Pablo Neira   netfilter: cleanu...
84
85
86
87
  	struct module		*owner;
  	void			*priv;
  	u_int8_t		pf;
  	unsigned int		hooknum;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
88
  	/* Hooks are ordered in ascending priority. */
87d5c18ce   Pablo Neira   netfilter: cleanu...
89
  	int			priority;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90
  };
d94d9fee9   Eric Dumazet   net: cleanup incl...
91
  struct nf_sockopt_ops {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
92
  	struct list_head list;
76108cea0   Jan Engelhardt   netfilter: Use un...
93
  	u_int8_t pf;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94
95
96
97
98
  
  	/* Non-inclusive ranges: use 0/0/NULL to never get called. */
  	int set_optmin;
  	int set_optmax;
  	int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
99
  #ifdef CONFIG_COMPAT
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
100
101
  	int (*compat_set)(struct sock *sk, int optval,
  			void __user *user, unsigned int len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
102
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
103
104
105
  	int get_optmin;
  	int get_optmax;
  	int (*get)(struct sock *sk, int optval, void __user *user, int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
106
  #ifdef CONFIG_COMPAT
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
107
108
  	int (*compat_get)(struct sock *sk, int optval,
  			void __user *user, int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
109
  #endif
16fcec35e   Neil Horman   [NETFILTER]: Fix/...
110
111
  	/* Use the module struct to lock set/get code in place */
  	struct module *owner;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
  /* Function to register/unregister hook points. */
085db2c04   Eric W. Biederman   netfilter: Per ne...
114
115
116
117
118
119
  int nf_register_net_hook(struct net *net, const struct nf_hook_ops *ops);
  void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *ops);
  int nf_register_net_hooks(struct net *net, const struct nf_hook_ops *reg,
  			  unsigned int n);
  void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg,
  			     unsigned int n);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
121
  int nf_register_hook(struct nf_hook_ops *reg);
  void nf_unregister_hook(struct nf_hook_ops *reg);
972d1cb14   Patrick McHardy   [NETFILTER]: Add ...
122
123
  int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n);
  void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
125
126
127
128
  
  /* Functions to register get/setsockopt ranges (non-inclusive).  You
     need to check permissions yourself! */
  int nf_register_sockopt(struct nf_sockopt_ops *reg);
  void nf_unregister_sockopt(struct nf_sockopt_ops *reg);
d1c85c2eb   Zhouyi Zhou   netfilter: HAVE_J...
129
  #ifdef HAVE_JUMP_LABEL
c5905afb0   Ingo Molnar   static keys: Intr...
130
  extern struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
d1c85c2eb   Zhouyi Zhou   netfilter: HAVE_J...
131

b8d0aad0c   Pablo Neira   netfilter: add nf...
132
133
  static inline bool nf_hook_list_active(struct list_head *nf_hook_list,
  				       u_int8_t pf, unsigned int hook)
a2d7ec58a   Eric Dumazet   netfilter: use ju...
134
135
136
  {
  	if (__builtin_constant_p(pf) &&
  	    __builtin_constant_p(hook))
c5905afb0   Ingo Molnar   static keys: Intr...
137
  		return static_key_false(&nf_hooks_needed[pf][hook]);
a2d7ec58a   Eric Dumazet   netfilter: use ju...
138

b8d0aad0c   Pablo Neira   netfilter: add nf...
139
  	return !list_empty(nf_hook_list);
a2d7ec58a   Eric Dumazet   netfilter: use ju...
140
141
  }
  #else
b8d0aad0c   Pablo Neira   netfilter: add nf...
142
143
  static inline bool nf_hook_list_active(struct list_head *nf_hook_list,
  				       u_int8_t pf, unsigned int hook)
a2d7ec58a   Eric Dumazet   netfilter: use ju...
144
  {
b8d0aad0c   Pablo Neira   netfilter: add nf...
145
  	return !list_empty(nf_hook_list);
a2d7ec58a   Eric Dumazet   netfilter: use ju...
146
147
  }
  #endif
cfdfab314   David S. Miller   netfilter: Create...
148
  int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state);
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
149
150
151
  
  /**
   *	nf_hook_thresh - call a netfilter hook
b8d0aad0c   Pablo Neira   netfilter: add nf...
152
   *
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
153
154
155
156
   *	Returns 1 if the hook has allowed the packet to pass.  The function
   *	okfn must be invoked by the caller in this case.  Any other return
   *	value indicates the packet has been consumed by the hook.
   */
76108cea0   Jan Engelhardt   netfilter: Use un...
157
  static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
7026b1ddb   David Miller   netfilter: Pass s...
158
  				 struct sock *sk,
3db05fea5   Herbert Xu   [NETFILTER]: Repl...
159
  				 struct sk_buff *skb,
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
160
161
  				 struct net_device *indev,
  				 struct net_device *outdev,
7026b1ddb   David Miller   netfilter: Pass s...
162
163
  				 int (*okfn)(struct sock *, struct sk_buff *),
  				 int thresh)
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
164
  {
085db2c04   Eric W. Biederman   netfilter: Per ne...
165
166
  	struct net *net = dev_net(indev ? indev : outdev);
  	struct list_head *nf_hook_list = &net->nf.hooks[pf][hook];
70aa99660   Eric W. Biederman   netfilter: kill n...
167
168
  
  	if (nf_hook_list_active(nf_hook_list, pf, hook)) {
107a9f4dc   David Miller   netfilter: Add nf...
169
  		struct nf_hook_state state;
cfdfab314   David S. Miller   netfilter: Create...
170

70aa99660   Eric W. Biederman   netfilter: kill n...
171
  		nf_hook_state_init(&state, nf_hook_list, hook, thresh,
f71914834   Pablo Neira   netfilter: add ho...
172
  				   pf, indev, outdev, sk, okfn);
cfdfab314   David S. Miller   netfilter: Create...
173
174
  		return nf_hook_slow(skb, &state);
  	}
a2d7ec58a   Eric Dumazet   netfilter: use ju...
175
  	return 1;
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
176
  }
7026b1ddb   David Miller   netfilter: Pass s...
177
178
179
180
  static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
  			  struct sk_buff *skb, struct net_device *indev,
  			  struct net_device *outdev,
  			  int (*okfn)(struct sock *, struct sk_buff *))
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
181
  {
7026b1ddb   David Miller   netfilter: Pass s...
182
  	return nf_hook_thresh(pf, hook, sk, skb, indev, outdev, okfn, INT_MIN);
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
183
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
                     
  /* Activate hook; either okfn or kfree_skb called, unless a hook
     returns NF_STOLEN (in which case, it's up to the hook to deal with
     the consequences).
  
     Returns -ERRNO if packet dropped.  Zero means queued, stolen or
     accepted.
  */
  
  /* RR:
     > I don't want nf_hook to return anything because people might forget
     > about async and trust the return value to mean "packet was ok".
  
     AK:
     Just document it clearly, then you can expect some sense from kernel
     coders :)
  */
2249065f4   Jan Engelhardt   netfilter: get ri...
201
  static inline int
7026b1ddb   David Miller   netfilter: Pass s...
202
203
204
205
  NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sock *sk,
  	       struct sk_buff *skb, struct net_device *in,
  	       struct net_device *out,
  	       int (*okfn)(struct sock *, struct sk_buff *), int thresh)
2249065f4   Jan Engelhardt   netfilter: get ri...
206
  {
7026b1ddb   David Miller   netfilter: Pass s...
207
  	int ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, thresh);
2249065f4   Jan Engelhardt   netfilter: get ri...
208
  	if (ret == 1)
7026b1ddb   David Miller   netfilter: Pass s...
209
  		ret = okfn(sk, skb);
2249065f4   Jan Engelhardt   netfilter: get ri...
210
211
  	return ret;
  }
48d5cad87   Patrick McHardy   [XFRM]: Fix SNAT-...
212

2249065f4   Jan Engelhardt   netfilter: get ri...
213
  static inline int
7026b1ddb   David Miller   netfilter: Pass s...
214
215
216
  NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sock *sk,
  	     struct sk_buff *skb, struct net_device *in, struct net_device *out,
  	     int (*okfn)(struct sock *, struct sk_buff *), bool cond)
2249065f4   Jan Engelhardt   netfilter: get ri...
217
  {
4bac6b180   Patrick McHardy   netfilter: restor...
218
219
220
  	int ret;
  
  	if (!cond ||
7026b1ddb   David Miller   netfilter: Pass s...
221
222
  	    ((ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, INT_MIN)) == 1))
  		ret = okfn(sk, skb);
2249065f4   Jan Engelhardt   netfilter: get ri...
223
224
  	return ret;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
225

2249065f4   Jan Engelhardt   netfilter: get ri...
226
  static inline int
7026b1ddb   David Miller   netfilter: Pass s...
227
  NF_HOOK(uint8_t pf, unsigned int hook, struct sock *sk, struct sk_buff *skb,
2249065f4   Jan Engelhardt   netfilter: get ri...
228
  	struct net_device *in, struct net_device *out,
7026b1ddb   David Miller   netfilter: Pass s...
229
  	int (*okfn)(struct sock *, struct sk_buff *))
2249065f4   Jan Engelhardt   netfilter: get ri...
230
  {
7026b1ddb   David Miller   netfilter: Pass s...
231
  	return NF_HOOK_THRESH(pf, hook, sk, skb, in, out, okfn, INT_MIN);
2249065f4   Jan Engelhardt   netfilter: get ri...
232
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
233
234
  
  /* Call setsockopt() */
76108cea0   Jan Engelhardt   netfilter: Use un...
235
  int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
b7058842c   David S. Miller   net: Make setsock...
236
  		  unsigned int len);
76108cea0   Jan Engelhardt   netfilter: Use un...
237
  int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
238
  		  int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
239
  #ifdef CONFIG_COMPAT
76108cea0   Jan Engelhardt   netfilter: Use un...
240
  int compat_nf_setsockopt(struct sock *sk, u_int8_t pf, int optval,
b7058842c   David S. Miller   net: Make setsock...
241
  		char __user *opt, unsigned int len);
76108cea0   Jan Engelhardt   netfilter: Use un...
242
  int compat_nf_getsockopt(struct sock *sk, u_int8_t pf, int optval,
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
243
  		char __user *opt, int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
244
  #endif
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
245

089af26c7   Harald Welte   [NETFILTER]: Rena...
246
247
248
  /* Call this before modifying an existing packet: ensures it is
     modifiable and linear to the point you care about (writable_len).
     Returns true or false. */
a0f4ecf34   Joe Perches   netfilter: Remove...
249
  int skb_make_writable(struct sk_buff *skb, unsigned int writable_len);
089af26c7   Harald Welte   [NETFILTER]: Rena...
250

1841a4c7a   Patrick McHardy   [NETFILTER]: nf_c...
251
  struct flowi;
02f014d88   Patrick McHardy   [NETFILTER]: nf_q...
252
  struct nf_queue_entry;
c01cd429f   Patrick McHardy   [NETFILTER]: nf_q...
253

bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
254
255
  struct nf_afinfo {
  	unsigned short	family;
b51655b95   Al Viro   [NET]: Annotate _...
256
  	__sum16		(*checksum)(struct sk_buff *skb, unsigned int hook,
422c346fa   Patrick McHardy   [NETFILTER]: Add ...
257
  				    unsigned int dataoff, u_int8_t protocol);
d63a65073   Patrick McHardy   [NETFILTER]: Add ...
258
259
260
261
262
  	__sum16		(*checksum_partial)(struct sk_buff *skb,
  					    unsigned int hook,
  					    unsigned int dataoff,
  					    unsigned int len,
  					    u_int8_t protocol);
31ad3dd64   Florian Westphal   netfilter: af_inf...
263
  	int		(*route)(struct net *net, struct dst_entry **dst,
0fae2e774   Florian Westphal   netfilter: af_inf...
264
  				 struct flowi *fl, bool strict);
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
265
  	void		(*saveroute)(const struct sk_buff *skb,
02f014d88   Patrick McHardy   [NETFILTER]: nf_q...
266
  				     struct nf_queue_entry *entry);
3db05fea5   Herbert Xu   [NETFILTER]: Repl...
267
  	int		(*reroute)(struct sk_buff *skb,
02f014d88   Patrick McHardy   [NETFILTER]: nf_q...
268
  				   const struct nf_queue_entry *entry);
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
269
  	int		route_key_size;
2cc7d5730   Harald Welte   [NETFILTER]: Move...
270
  };
0e60ebe04   Eric Dumazet   netfilter: add __...
271
  extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
1e796fda0   Patrick McHardy   [NETFILTER]: cons...
272
  static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
273
274
275
  {
  	return rcu_dereference(nf_afinfo[family]);
  }
2cc7d5730   Harald Welte   [NETFILTER]: Move...
276

b51655b95   Al Viro   [NET]: Annotate _...
277
  static inline __sum16
422c346fa   Patrick McHardy   [NETFILTER]: Add ...
278
279
280
  nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
  	    u_int8_t protocol, unsigned short family)
  {
1e796fda0   Patrick McHardy   [NETFILTER]: cons...
281
  	const struct nf_afinfo *afinfo;
b51655b95   Al Viro   [NET]: Annotate _...
282
  	__sum16 csum = 0;
422c346fa   Patrick McHardy   [NETFILTER]: Add ...
283
284
285
286
287
288
289
290
  
  	rcu_read_lock();
  	afinfo = nf_get_afinfo(family);
  	if (afinfo)
  		csum = afinfo->checksum(skb, hook, dataoff, protocol);
  	rcu_read_unlock();
  	return csum;
  }
d63a65073   Patrick McHardy   [NETFILTER]: Add ...
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
  static inline __sum16
  nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
  		    unsigned int dataoff, unsigned int len,
  		    u_int8_t protocol, unsigned short family)
  {
  	const struct nf_afinfo *afinfo;
  	__sum16 csum = 0;
  
  	rcu_read_lock();
  	afinfo = nf_get_afinfo(family);
  	if (afinfo)
  		csum = afinfo->checksum_partial(skb, hook, dataoff, len,
  						protocol);
  	rcu_read_unlock();
  	return csum;
  }
a0f4ecf34   Joe Perches   netfilter: Remove...
307
308
  int nf_register_afinfo(const struct nf_afinfo *afinfo);
  void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
309

eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
310
  #include <net/flow.h>
c7232c997   Patrick McHardy   netfilter: add pr...
311
  extern void (*nf_nat_decode_session_hook)(struct sk_buff *, struct flowi *);
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
312
313
  
  static inline void
76108cea0   Jan Engelhardt   netfilter: Use un...
314
  nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
315
  {
051578ccb   Patrick McHardy   [NETFILTER]: nf_n...
316
  #ifdef CONFIG_NF_NAT_NEEDED
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
317
  	void (*decodefn)(struct sk_buff *, struct flowi *);
c7232c997   Patrick McHardy   netfilter: add pr...
318
319
320
321
322
  	rcu_read_lock();
  	decodefn = rcu_dereference(nf_nat_decode_session_hook);
  	if (decodefn)
  		decodefn(skb, fl);
  	rcu_read_unlock();
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
323
324
  #endif
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
325
  #else /* !CONFIG_NETFILTER */
7026b1ddb   David Miller   netfilter: Pass s...
326
327
  #define NF_HOOK(pf, hook, sk, skb, indev, outdev, okfn) (okfn)(sk, skb)
  #define NF_HOOK_COND(pf, hook, sk, skb, indev, outdev, okfn, cond) (okfn)(sk, skb)
76108cea0   Jan Engelhardt   netfilter: Use un...
328
  static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
7026b1ddb   David Miller   netfilter: Pass s...
329
  				 struct sock *sk,
3db05fea5   Herbert Xu   [NETFILTER]: Repl...
330
  				 struct sk_buff *skb,
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
331
332
  				 struct net_device *indev,
  				 struct net_device *outdev,
7026b1ddb   David Miller   netfilter: Pass s...
333
  				 int (*okfn)(struct sock *sk, struct sk_buff *), int thresh)
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
334
  {
7026b1ddb   David Miller   netfilter: Pass s...
335
  	return okfn(sk, skb);
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
336
  }
7026b1ddb   David Miller   netfilter: Pass s...
337
338
339
340
  static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
  			  struct sk_buff *skb, struct net_device *indev,
  			  struct net_device *outdev,
  			  int (*okfn)(struct sock *, struct sk_buff *))
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
341
  {
9c92d3486   Patrick McHardy   [NETFILTER]: Don'...
342
  	return 1;
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
343
  }
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
344
  struct flowi;
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
345
  static inline void
76108cea0   Jan Engelhardt   netfilter: Use un...
346
347
348
  nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
  {
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
349
  #endif /*CONFIG_NETFILTER*/
5f79e0f91   Yasuyuki Kozakai   [NETFILTER]: nf_c...
350
  #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
312a0c16c   Patrick McHardy   netfilter: nf_con...
351
  extern void (*ip_ct_attach)(struct sk_buff *, const struct sk_buff *) __rcu;
a0f4ecf34   Joe Perches   netfilter: Remove...
352
  void nf_ct_attach(struct sk_buff *, const struct sk_buff *);
0e60ebe04   Eric Dumazet   netfilter: add __...
353
  extern void (*nf_ct_destroy)(struct nf_conntrack *) __rcu;
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
354
355
  
  struct nf_conn;
41d73ec05   Patrick McHardy   netfilter: nf_con...
356
  enum ip_conntrack_info;
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
357
358
359
360
361
362
  struct nlattr;
  
  struct nfq_ct_hook {
  	size_t (*build_size)(const struct nf_conn *ct);
  	int (*build)(struct sk_buff *skb, struct nf_conn *ct);
  	int (*parse)(const struct nlattr *attr, struct nf_conn *ct);
bd0779370   Pablo Neira Ayuso   netfilter: nfnetl...
363
364
  	int (*attach_expect)(const struct nlattr *attr, struct nf_conn *ct,
  			     u32 portid, u32 report);
8c88f87cb   Pablo Neira Ayuso   netfilter: nfnetl...
365
  	void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
41d73ec05   Patrick McHardy   netfilter: nf_con...
366
  			   enum ip_conntrack_info ctinfo, s32 off);
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
367
  };
41d73ec05   Patrick McHardy   netfilter: nf_con...
368
  extern struct nfq_ct_hook __rcu *nfq_ct_hook;
5f79e0f91   Yasuyuki Kozakai   [NETFILTER]: nf_c...
369
370
371
  #else
  static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
372
  #endif /*__LINUX_NETFILTER_H*/