blob: dca19e61b30a0bc27fef7a39c0cd3df67d92790a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_NETFILTER_H
2#define __LINUX_NETFILTER_H
3
4#ifdef __KERNEL__
5#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <linux/skbuff.h>
7#include <linux/net.h>
8#include <linux/if.h>
Jan Engelhardt2e3075a2008-01-14 23:40:34 -08009#include <linux/in.h>
10#include <linux/in6.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/wait.h>
12#include <linux/list.h>
13#endif
Patrick McHardyc8942f12008-05-21 14:08:38 -070014#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/compiler.h>
David S. Millerbee95252011-05-26 16:40:37 -040016#include <linux/sysctl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18/* Responses from hook functions. */
19#define NF_DROP 0
20#define NF_ACCEPT 1
21#define NF_STOLEN 2
22#define NF_QUEUE 3
23#define NF_REPEAT 4
24#define NF_STOP 5
25#define NF_MAX_VERDICT NF_STOP
26
Harald Welte0ab43f82005-08-09 19:43:44 -070027/* we overload the higher bits for encoding auxiliary data such as the queue
Florian Westphalf615df72011-01-18 15:52:14 +010028 * number or errno values. Not nice, but better than additional function
29 * arguments. */
30#define NF_VERDICT_MASK 0x000000ff
Harald Welte0ab43f82005-08-09 19:43:44 -070031
Florian Westphalf615df72011-01-18 15:52:14 +010032/* extra verdict flags have mask 0x0000ff00 */
Florian Westphal94b27cc2011-01-18 16:08:30 +010033#define NF_VERDICT_FLAG_QUEUE_BYPASS 0x00008000
Florian Westphalf615df72011-01-18 15:52:14 +010034
35/* queue number (NF_QUEUE) or errno (NF_DROP) */
Harald Welte0ab43f82005-08-09 19:43:44 -070036#define NF_VERDICT_QMASK 0xffff0000
37#define NF_VERDICT_QBITS 16
38
Florian Westphalf615df72011-01-18 15:52:14 +010039#define NF_QUEUE_NR(x) ((((x) << 16) & NF_VERDICT_QMASK) | NF_QUEUE)
Harald Welte0ab43f82005-08-09 19:43:44 -070040
Florian Westphalf615df72011-01-18 15:52:14 +010041#define NF_DROP_ERR(x) (((-x) << 16) | NF_DROP)
Eric Parisda683652010-11-16 11:52:38 +000042
Harald Welte6869c4d2005-08-09 19:24:19 -070043/* only for userspace compatibility */
44#ifndef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -070045/* Generic cache responses from hook functions.
46 <= 0x2000 is used for protocol-flags. */
47#define NFC_UNKNOWN 0x4000
48#define NFC_ALTERED 0x8000
Florian Westphalf615df72011-01-18 15:52:14 +010049
50/* NF_VERDICT_BITS should be 8 now, but userspace might break if this changes */
51#define NF_VERDICT_BITS 16
Harald Welte6869c4d2005-08-09 19:24:19 -070052#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Patrick McHardy6e23ae22007-11-19 18:53:30 -080054enum nf_inet_hooks {
55 NF_INET_PRE_ROUTING,
56 NF_INET_LOCAL_IN,
57 NF_INET_FORWARD,
58 NF_INET_LOCAL_OUT,
59 NF_INET_POST_ROUTING,
60 NF_INET_NUMHOOKS
61};
62
Jan Engelhardt7e9c6ee2008-10-08 11:35:00 +020063enum {
64 NFPROTO_UNSPEC = 0,
65 NFPROTO_IPV4 = 2,
66 NFPROTO_ARP = 3,
67 NFPROTO_BRIDGE = 7,
68 NFPROTO_IPV6 = 10,
69 NFPROTO_DECNET = 12,
70 NFPROTO_NUMPROTO,
71};
72
Jan Engelhardt643a2c12007-12-17 22:43:50 -080073union nf_inet_addr {
Patrick McHardy7b33ed22008-02-19 17:20:33 -080074 __u32 all[4];
Jan Engelhardt643a2c12007-12-17 22:43:50 -080075 __be32 ip;
76 __be32 ip6[4];
Jan Engelhardt2e3075a2008-01-14 23:40:34 -080077 struct in_addr in;
78 struct in6_addr in6;
Jan Engelhardt643a2c12007-12-17 22:43:50 -080079};
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#ifdef CONFIG_NETFILTER
Florian Westphalf615df72011-01-18 15:52:14 +010083static inline int NF_DROP_GETERR(int verdict)
84{
85 return -(verdict >> NF_VERDICT_QBITS);
86}
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Patrick McHardyb8beedd2008-03-25 20:09:33 -070088static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1,
89 const union nf_inet_addr *a2)
90{
91 return a1->all[0] == a2->all[0] &&
92 a1->all[1] == a2->all[1] &&
93 a1->all[2] == a2->all[2] &&
94 a1->all[3] == a2->all[3];
95}
96
Denys Fedoryshchenkoefdedd52012-05-17 23:08:57 +030097static inline void nf_inet_addr_mask(const union nf_inet_addr *a1,
98 union nf_inet_addr *result,
99 const union nf_inet_addr *mask)
100{
101 result->all[0] = a1->all[0] & mask->all[0];
102 result->all[1] = a1->all[1] & mask->all[1];
103 result->all[2] = a1->all[2] & mask->all[2];
104 result->all[3] = a1->all[3] & mask->all[3];
105}
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern void netfilter_init(void);
108
109/* Largest hook number + 1 */
110#define NF_MAX_HOOKS 8
111
112struct sk_buff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114typedef unsigned int nf_hookfn(unsigned int hooknum,
Herbert Xu3db05fe2007-10-15 00:53:15 -0700115 struct sk_buff *skb,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 const struct net_device *in,
117 const struct net_device *out,
118 int (*okfn)(struct sk_buff *));
119
Eric Dumazetd94d9fe2009-11-04 09:50:58 -0800120struct nf_hook_ops {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 struct list_head list;
122
123 /* User fills in from here down. */
124 nf_hookfn *hook;
125 struct module *owner;
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200126 u_int8_t pf;
127 unsigned int hooknum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 /* Hooks are ordered in ascending priority. */
129 int priority;
130};
131
Eric Dumazetd94d9fe2009-11-04 09:50:58 -0800132struct nf_sockopt_ops {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 struct list_head list;
134
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200135 u_int8_t pf;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137 /* Non-inclusive ranges: use 0/0/NULL to never get called. */
138 int set_optmin;
139 int set_optmax;
140 int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);
Alexey Dobriyanc30f5402010-02-02 15:03:24 +0100141#ifdef CONFIG_COMPAT
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800142 int (*compat_set)(struct sock *sk, int optval,
143 void __user *user, unsigned int len);
Alexey Dobriyanc30f5402010-02-02 15:03:24 +0100144#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 int get_optmin;
146 int get_optmax;
147 int (*get)(struct sock *sk, int optval, void __user *user, int *len);
Alexey Dobriyanc30f5402010-02-02 15:03:24 +0100148#ifdef CONFIG_COMPAT
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800149 int (*compat_get)(struct sock *sk, int optval,
150 void __user *user, int *len);
Alexey Dobriyanc30f5402010-02-02 15:03:24 +0100151#endif
Neil Horman16fcec32007-09-11 11:28:26 +0200152 /* Use the module struct to lock set/get code in place */
153 struct module *owner;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154};
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156/* Function to register/unregister hook points. */
157int nf_register_hook(struct nf_hook_ops *reg);
158void nf_unregister_hook(struct nf_hook_ops *reg);
Patrick McHardy972d1cb2006-04-06 14:09:12 -0700159int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n);
160void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162/* Functions to register get/setsockopt ranges (non-inclusive). You
163 need to check permissions yourself! */
164int nf_register_sockopt(struct nf_sockopt_ops *reg);
165void nf_unregister_sockopt(struct nf_sockopt_ops *reg);
166
Jan Engelhardt7e9c6ee2008-10-08 11:35:00 +0200167extern struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
Eric Dumazeta2d7ec52011-11-18 17:32:46 +0000169#if defined(CONFIG_JUMP_LABEL)
Ingo Molnarc5905af2012-02-24 08:31:31 +0100170#include <linux/static_key.h>
171extern struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
Eric Dumazeta2d7ec52011-11-18 17:32:46 +0000172static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook)
173{
174 if (__builtin_constant_p(pf) &&
175 __builtin_constant_p(hook))
Ingo Molnarc5905af2012-02-24 08:31:31 +0100176 return static_key_false(&nf_hooks_needed[pf][hook]);
Eric Dumazeta2d7ec52011-11-18 17:32:46 +0000177
178 return !list_empty(&nf_hooks[pf][hook]);
179}
180#else
181static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook)
182{
183 return !list_empty(&nf_hooks[pf][hook]);
184}
185#endif
186
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200187int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
Patrick McHardy16a66772006-01-06 23:01:48 -0800188 struct net_device *indev, struct net_device *outdev,
189 int (*okfn)(struct sk_buff *), int thresh);
190
191/**
192 * nf_hook_thresh - call a netfilter hook
193 *
194 * Returns 1 if the hook has allowed the packet to pass. The function
195 * okfn must be invoked by the caller in this case. Any other return
196 * value indicates the packet has been consumed by the hook.
197 */
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200198static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
Herbert Xu3db05fe2007-10-15 00:53:15 -0700199 struct sk_buff *skb,
Patrick McHardy16a66772006-01-06 23:01:48 -0800200 struct net_device *indev,
201 struct net_device *outdev,
Jan Engelhardt23f37332009-06-05 17:31:46 +0200202 int (*okfn)(struct sk_buff *), int thresh)
Patrick McHardy16a66772006-01-06 23:01:48 -0800203{
Eric Dumazeta2d7ec52011-11-18 17:32:46 +0000204 if (nf_hooks_active(pf, hook))
205 return nf_hook_slow(pf, hook, skb, indev, outdev, okfn, thresh);
206 return 1;
Patrick McHardy16a66772006-01-06 23:01:48 -0800207}
208
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200209static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
Patrick McHardy16a66772006-01-06 23:01:48 -0800210 struct net_device *indev, struct net_device *outdev,
211 int (*okfn)(struct sk_buff *))
212{
Jan Engelhardt23f37332009-06-05 17:31:46 +0200213 return nf_hook_thresh(pf, hook, skb, indev, outdev, okfn, INT_MIN);
Patrick McHardy16a66772006-01-06 23:01:48 -0800214}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216/* Activate hook; either okfn or kfree_skb called, unless a hook
217 returns NF_STOLEN (in which case, it's up to the hook to deal with
218 the consequences).
219
220 Returns -ERRNO if packet dropped. Zero means queued, stolen or
221 accepted.
222*/
223
224/* RR:
225 > I don't want nf_hook to return anything because people might forget
226 > about async and trust the return value to mean "packet was ok".
227
228 AK:
229 Just document it clearly, then you can expect some sense from kernel
230 coders :)
231*/
232
Jan Engelhardt22490652009-06-13 04:13:26 +0200233static inline int
234NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sk_buff *skb,
235 struct net_device *in, struct net_device *out,
236 int (*okfn)(struct sk_buff *), int thresh)
237{
238 int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh);
239 if (ret == 1)
240 ret = okfn(skb);
241 return ret;
242}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
Jan Engelhardt22490652009-06-13 04:13:26 +0200244static inline int
245NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sk_buff *skb,
246 struct net_device *in, struct net_device *out,
247 int (*okfn)(struct sk_buff *), bool cond)
248{
Patrick McHardy4bac6b12010-02-19 08:03:28 +0100249 int ret;
250
251 if (!cond ||
Eric Parisac5aa2e2010-11-12 08:26:06 +0100252 ((ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, INT_MIN)) == 1))
Jan Engelhardt22490652009-06-13 04:13:26 +0200253 ret = okfn(skb);
254 return ret;
255}
Patrick McHardy16a66772006-01-06 23:01:48 -0800256
Jan Engelhardt22490652009-06-13 04:13:26 +0200257static inline int
258NF_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
259 struct net_device *in, struct net_device *out,
260 int (*okfn)(struct sk_buff *))
261{
262 return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn, INT_MIN);
263}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
265/* Call setsockopt() */
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200266int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
David S. Millerb7058842009-09-30 16:12:20 -0700267 unsigned int len);
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200268int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 int *len);
Alexey Dobriyanc30f5402010-02-02 15:03:24 +0100270#ifdef CONFIG_COMPAT
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200271int compat_nf_setsockopt(struct sock *sk, u_int8_t pf, int optval,
David S. Millerb7058842009-09-30 16:12:20 -0700272 char __user *opt, unsigned int len);
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200273int compat_nf_getsockopt(struct sock *sk, u_int8_t pf, int optval,
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800274 char __user *opt, int *len);
Alexey Dobriyanc30f5402010-02-02 15:03:24 +0100275#endif
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800276
Harald Welte089af262005-08-09 19:37:23 -0700277/* Call this before modifying an existing packet: ensures it is
278 modifiable and linear to the point you care about (writable_len).
279 Returns true or false. */
Herbert Xu37d41872007-10-14 00:39:18 -0700280extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len);
Harald Welte089af262005-08-09 19:37:23 -0700281
Patrick McHardy1841a4c2007-12-05 01:22:05 -0800282struct flowi;
Patrick McHardy02f014d2007-12-05 01:26:33 -0800283struct nf_queue_entry;
Patrick McHardyc01cd422007-12-05 01:24:48 -0800284
Patrick McHardybce80322006-04-06 14:18:09 -0700285struct nf_afinfo {
286 unsigned short family;
Al Virob51655b2006-11-14 21:40:42 -0800287 __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook,
Patrick McHardy422c3462006-04-06 14:18:43 -0700288 unsigned int dataoff, u_int8_t protocol);
Patrick McHardyd63a6502008-03-20 15:15:53 +0100289 __sum16 (*checksum_partial)(struct sk_buff *skb,
290 unsigned int hook,
291 unsigned int dataoff,
292 unsigned int len,
293 u_int8_t protocol);
Florian Westphal31ad3dd2011-04-04 16:56:29 +0200294 int (*route)(struct net *net, struct dst_entry **dst,
Florian Westphal0fae2e72011-04-04 17:00:54 +0200295 struct flowi *fl, bool strict);
Patrick McHardybce80322006-04-06 14:18:09 -0700296 void (*saveroute)(const struct sk_buff *skb,
Patrick McHardy02f014d2007-12-05 01:26:33 -0800297 struct nf_queue_entry *entry);
Herbert Xu3db05fe2007-10-15 00:53:15 -0700298 int (*reroute)(struct sk_buff *skb,
Patrick McHardy02f014d2007-12-05 01:26:33 -0800299 const struct nf_queue_entry *entry);
Patrick McHardybce80322006-04-06 14:18:09 -0700300 int route_key_size;
Harald Welte2cc7d572005-08-09 19:42:34 -0700301};
302
Eric Dumazet0e60ebe2010-11-15 18:17:21 +0100303extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
Patrick McHardy1e796fd2007-12-17 22:42:27 -0800304static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
Patrick McHardybce80322006-04-06 14:18:09 -0700305{
306 return rcu_dereference(nf_afinfo[family]);
307}
Harald Welte2cc7d572005-08-09 19:42:34 -0700308
Al Virob51655b2006-11-14 21:40:42 -0800309static inline __sum16
Patrick McHardy422c3462006-04-06 14:18:43 -0700310nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
311 u_int8_t protocol, unsigned short family)
312{
Patrick McHardy1e796fd2007-12-17 22:42:27 -0800313 const struct nf_afinfo *afinfo;
Al Virob51655b2006-11-14 21:40:42 -0800314 __sum16 csum = 0;
Patrick McHardy422c3462006-04-06 14:18:43 -0700315
316 rcu_read_lock();
317 afinfo = nf_get_afinfo(family);
318 if (afinfo)
319 csum = afinfo->checksum(skb, hook, dataoff, protocol);
320 rcu_read_unlock();
321 return csum;
322}
323
Patrick McHardyd63a6502008-03-20 15:15:53 +0100324static inline __sum16
325nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
326 unsigned int dataoff, unsigned int len,
327 u_int8_t protocol, unsigned short family)
328{
329 const struct nf_afinfo *afinfo;
330 __sum16 csum = 0;
331
332 rcu_read_lock();
333 afinfo = nf_get_afinfo(family);
334 if (afinfo)
335 csum = afinfo->checksum_partial(skb, hook, dataoff, len,
336 protocol);
337 rcu_read_unlock();
338 return csum;
339}
340
Patrick McHardy1e796fd2007-12-17 22:42:27 -0800341extern int nf_register_afinfo(const struct nf_afinfo *afinfo);
342extern void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
Patrick McHardybce80322006-04-06 14:18:09 -0700343
Patrick McHardyeb9c7eb2006-01-06 23:06:30 -0800344#include <net/flow.h>
345extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *);
346
347static inline void
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200348nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
Patrick McHardyeb9c7eb2006-01-06 23:06:30 -0800349{
Patrick McHardy051578c2007-12-17 22:42:51 -0800350#ifdef CONFIG_NF_NAT_NEEDED
Patrick McHardyeb9c7eb2006-01-06 23:06:30 -0800351 void (*decodefn)(struct sk_buff *, struct flowi *);
352
Patrick McHardy051578c2007-12-17 22:42:51 -0800353 if (family == AF_INET) {
354 rcu_read_lock();
355 decodefn = rcu_dereference(ip_nat_decode_session);
356 if (decodefn)
357 decodefn(skb, fl);
358 rcu_read_unlock();
359 }
Patrick McHardyeb9c7eb2006-01-06 23:06:30 -0800360#endif
361}
362
Harald Welte608c8e42005-08-09 19:58:27 -0700363#ifdef CONFIG_PROC_FS
364#include <linux/proc_fs.h>
365extern struct proc_dir_entry *proc_net_netfilter;
366#endif
367
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368#else /* !CONFIG_NETFILTER */
369#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
Patrick McHardy48d5cad2006-02-15 15:10:22 -0800370#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb)
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200371static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
Herbert Xu3db05fe2007-10-15 00:53:15 -0700372 struct sk_buff *skb,
David S. Millerf53b61d2006-01-07 12:50:27 -0800373 struct net_device *indev,
374 struct net_device *outdev,
Jan Engelhardt23f37332009-06-05 17:31:46 +0200375 int (*okfn)(struct sk_buff *), int thresh)
David S. Millerf53b61d2006-01-07 12:50:27 -0800376{
Herbert Xu3db05fe2007-10-15 00:53:15 -0700377 return okfn(skb);
David S. Millerf53b61d2006-01-07 12:50:27 -0800378}
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200379static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
David S. Millerf53b61d2006-01-07 12:50:27 -0800380 struct net_device *indev, struct net_device *outdev,
381 int (*okfn)(struct sk_buff *))
382{
Patrick McHardy9c92d342006-02-15 15:18:19 -0800383 return 1;
David S. Millerf53b61d2006-01-07 12:50:27 -0800384}
David S. Millerf53b61d2006-01-07 12:50:27 -0800385struct flowi;
Patrick McHardyeb9c7eb2006-01-06 23:06:30 -0800386static inline void
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200387nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
388{
389}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390#endif /*CONFIG_NETFILTER*/
391
Yasuyuki Kozakai5f79e0f2007-03-23 11:17:07 -0700392#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
Eric Dumazet0e60ebe2010-11-15 18:17:21 +0100393extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *) __rcu;
Yasuyuki Kozakai5f79e0f2007-03-23 11:17:07 -0700394extern void nf_ct_attach(struct sk_buff *, struct sk_buff *);
Eric Dumazet0e60ebe2010-11-15 18:17:21 +0100395extern void (*nf_ct_destroy)(struct nf_conntrack *) __rcu;
Pablo Neira Ayuso9cb01762012-06-07 12:13:39 +0200396
397struct nf_conn;
398struct nlattr;
399
400struct nfq_ct_hook {
401 size_t (*build_size)(const struct nf_conn *ct);
402 int (*build)(struct sk_buff *skb, struct nf_conn *ct);
403 int (*parse)(const struct nlattr *attr, struct nf_conn *ct);
Pablo Neira Ayuso8c88f872012-06-07 13:31:25 +0200404 void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
405 u32 ctinfo, int off);
Pablo Neira Ayuso9cb01762012-06-07 12:13:39 +0200406};
407extern struct nfq_ct_hook *nfq_ct_hook;
Yasuyuki Kozakai5f79e0f2007-03-23 11:17:07 -0700408#else
409static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
410#endif
411
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412#endif /*__KERNEL__*/
413#endif /*__LINUX_NETFILTER_H*/