Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_NETFILTER_H |
| 2 | #define __LINUX_NETFILTER_H |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | #include <linux/init.h> |
| 6 | #include <linux/types.h> |
| 7 | #include <linux/skbuff.h> |
| 8 | #include <linux/net.h> |
| 9 | #include <linux/if.h> |
| 10 | #include <linux/wait.h> |
| 11 | #include <linux/list.h> |
| 12 | #endif |
| 13 | #include <linux/compiler.h> |
| 14 | |
| 15 | /* Responses from hook functions. */ |
| 16 | #define NF_DROP 0 |
| 17 | #define NF_ACCEPT 1 |
| 18 | #define NF_STOLEN 2 |
| 19 | #define NF_QUEUE 3 |
| 20 | #define NF_REPEAT 4 |
| 21 | #define NF_STOP 5 |
| 22 | #define NF_MAX_VERDICT NF_STOP |
| 23 | |
Harald Welte | 0ab43f8 | 2005-08-09 19:43:44 -0700 | [diff] [blame] | 24 | /* we overload the higher bits for encoding auxiliary data such as the queue |
| 25 | * number. Not nice, but better than additional function arguments. */ |
| 26 | #define NF_VERDICT_MASK 0x0000ffff |
| 27 | #define NF_VERDICT_BITS 16 |
| 28 | |
| 29 | #define NF_VERDICT_QMASK 0xffff0000 |
| 30 | #define NF_VERDICT_QBITS 16 |
| 31 | |
Harald Welte | b766b30 | 2005-08-12 11:36:44 -0700 | [diff] [blame] | 32 | #define NF_QUEUE_NR(x) (((x << NF_VERDICT_QBITS) & NF_VERDICT_QMASK) | NF_QUEUE) |
Harald Welte | 0ab43f8 | 2005-08-09 19:43:44 -0700 | [diff] [blame] | 33 | |
Harald Welte | 6869c4d | 2005-08-09 19:24:19 -0700 | [diff] [blame] | 34 | /* only for userspace compatibility */ |
| 35 | #ifndef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | /* Generic cache responses from hook functions. |
| 37 | <= 0x2000 is used for protocol-flags. */ |
| 38 | #define NFC_UNKNOWN 0x4000 |
| 39 | #define NFC_ALTERED 0x8000 |
Harald Welte | 6869c4d | 2005-08-09 19:24:19 -0700 | [diff] [blame] | 40 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Patrick McHardy | 6e23ae2 | 2007-11-19 18:53:30 -0800 | [diff] [blame] | 42 | enum nf_inet_hooks { |
| 43 | NF_INET_PRE_ROUTING, |
| 44 | NF_INET_LOCAL_IN, |
| 45 | NF_INET_FORWARD, |
| 46 | NF_INET_LOCAL_OUT, |
| 47 | NF_INET_POST_ROUTING, |
| 48 | NF_INET_NUMHOOKS |
| 49 | }; |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #ifdef CONFIG_NETFILTER |
| 53 | |
| 54 | extern void netfilter_init(void); |
| 55 | |
| 56 | /* Largest hook number + 1 */ |
| 57 | #define NF_MAX_HOOKS 8 |
| 58 | |
| 59 | struct sk_buff; |
| 60 | struct net_device; |
| 61 | |
| 62 | typedef unsigned int nf_hookfn(unsigned int hooknum, |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 63 | struct sk_buff *skb, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | const struct net_device *in, |
| 65 | const struct net_device *out, |
| 66 | int (*okfn)(struct sk_buff *)); |
| 67 | |
| 68 | struct nf_hook_ops |
| 69 | { |
| 70 | struct list_head list; |
| 71 | |
| 72 | /* User fills in from here down. */ |
| 73 | nf_hookfn *hook; |
| 74 | struct module *owner; |
| 75 | int pf; |
| 76 | int hooknum; |
| 77 | /* Hooks are ordered in ascending priority. */ |
| 78 | int priority; |
| 79 | }; |
| 80 | |
| 81 | struct nf_sockopt_ops |
| 82 | { |
| 83 | struct list_head list; |
| 84 | |
| 85 | int pf; |
| 86 | |
| 87 | /* Non-inclusive ranges: use 0/0/NULL to never get called. */ |
| 88 | int set_optmin; |
| 89 | int set_optmax; |
| 90 | int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len); |
Dmitry Mishin | 3fdadf7 | 2006-03-20 22:45:21 -0800 | [diff] [blame] | 91 | int (*compat_set)(struct sock *sk, int optval, |
| 92 | void __user *user, unsigned int len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | int get_optmin; |
| 95 | int get_optmax; |
| 96 | int (*get)(struct sock *sk, int optval, void __user *user, int *len); |
Dmitry Mishin | 3fdadf7 | 2006-03-20 22:45:21 -0800 | [diff] [blame] | 97 | int (*compat_get)(struct sock *sk, int optval, |
| 98 | void __user *user, int *len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
Neil Horman | 16fcec3 | 2007-09-11 11:28:26 +0200 | [diff] [blame] | 100 | /* Use the module struct to lock set/get code in place */ |
| 101 | struct module *owner; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | /* Function to register/unregister hook points. */ |
| 105 | int nf_register_hook(struct nf_hook_ops *reg); |
| 106 | void nf_unregister_hook(struct nf_hook_ops *reg); |
Patrick McHardy | 972d1cb | 2006-04-06 14:09:12 -0700 | [diff] [blame] | 107 | int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n); |
| 108 | void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
| 110 | /* Functions to register get/setsockopt ranges (non-inclusive). You |
| 111 | need to check permissions yourself! */ |
| 112 | int nf_register_sockopt(struct nf_sockopt_ops *reg); |
| 113 | void nf_unregister_sockopt(struct nf_sockopt_ops *reg); |
| 114 | |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 115 | #ifdef CONFIG_SYSCTL |
| 116 | /* Sysctl registration */ |
| 117 | struct ctl_table_header *nf_register_sysctl_table(struct ctl_table *path, |
| 118 | struct ctl_table *table); |
| 119 | void nf_unregister_sysctl_table(struct ctl_table_header *header, |
| 120 | struct ctl_table *table); |
| 121 | extern struct ctl_table nf_net_netfilter_sysctl_path[]; |
| 122 | extern struct ctl_table nf_net_ipv4_netfilter_sysctl_path[]; |
| 123 | #endif /* CONFIG_SYSCTL */ |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS]; |
| 126 | |
Harald Welte | 608c8e4 | 2005-08-09 19:58:27 -0700 | [diff] [blame] | 127 | /* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will |
| 128 | * disappear once iptables is replaced with pkttables. Please DO NOT use them |
| 129 | * for any new code! */ |
| 130 | #define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */ |
| 131 | #define NF_LOG_TCPOPT 0x02 /* Log TCP options */ |
| 132 | #define NF_LOG_IPOPT 0x04 /* Log IP options */ |
| 133 | #define NF_LOG_UID 0x08 /* Log UID owning local socket */ |
| 134 | #define NF_LOG_MASK 0x0f |
| 135 | |
| 136 | #define NF_LOG_TYPE_LOG 0x01 |
| 137 | #define NF_LOG_TYPE_ULOG 0x02 |
| 138 | |
| 139 | struct nf_loginfo { |
| 140 | u_int8_t type; |
| 141 | union { |
| 142 | struct { |
| 143 | u_int32_t copy_len; |
| 144 | u_int16_t group; |
| 145 | u_int16_t qthreshold; |
| 146 | } ulog; |
| 147 | struct { |
| 148 | u_int8_t level; |
| 149 | u_int8_t logflags; |
| 150 | } log; |
| 151 | } u; |
| 152 | }; |
| 153 | |
| 154 | typedef void nf_logfn(unsigned int pf, |
| 155 | unsigned int hooknum, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | const struct sk_buff *skb, |
| 157 | const struct net_device *in, |
| 158 | const struct net_device *out, |
Harald Welte | 608c8e4 | 2005-08-09 19:58:27 -0700 | [diff] [blame] | 159 | const struct nf_loginfo *li, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | const char *prefix); |
| 161 | |
Harald Welte | 608c8e4 | 2005-08-09 19:58:27 -0700 | [diff] [blame] | 162 | struct nf_logger { |
| 163 | struct module *me; |
| 164 | nf_logfn *logfn; |
| 165 | char *name; |
| 166 | }; |
| 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | /* Function to register/unregister log function. */ |
Harald Welte | 608c8e4 | 2005-08-09 19:58:27 -0700 | [diff] [blame] | 169 | int nf_log_register(int pf, struct nf_logger *logger); |
Patrick McHardy | e92ad99 | 2007-02-12 11:11:55 -0800 | [diff] [blame] | 170 | void nf_log_unregister(struct nf_logger *logger); |
Patrick McHardy | 9dc6aa5 | 2007-02-12 11:11:24 -0800 | [diff] [blame] | 171 | void nf_log_unregister_pf(int pf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
| 173 | /* Calls the registered backend logging function */ |
| 174 | void nf_log_packet(int pf, |
| 175 | unsigned int hooknum, |
| 176 | const struct sk_buff *skb, |
| 177 | const struct net_device *in, |
| 178 | const struct net_device *out, |
Harald Welte | 608c8e4 | 2005-08-09 19:58:27 -0700 | [diff] [blame] | 179 | struct nf_loginfo *li, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | const char *fmt, ...); |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 181 | |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 182 | int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb, |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 183 | struct net_device *indev, struct net_device *outdev, |
| 184 | int (*okfn)(struct sk_buff *), int thresh); |
| 185 | |
| 186 | /** |
| 187 | * nf_hook_thresh - call a netfilter hook |
| 188 | * |
| 189 | * Returns 1 if the hook has allowed the packet to pass. The function |
| 190 | * okfn must be invoked by the caller in this case. Any other return |
| 191 | * value indicates the packet has been consumed by the hook. |
| 192 | */ |
| 193 | static inline int nf_hook_thresh(int pf, unsigned int hook, |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 194 | struct sk_buff *skb, |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 195 | struct net_device *indev, |
| 196 | struct net_device *outdev, |
Patrick McHardy | 48d5cad | 2006-02-15 15:10:22 -0800 | [diff] [blame] | 197 | int (*okfn)(struct sk_buff *), int thresh, |
| 198 | int cond) |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 199 | { |
Patrick McHardy | 48d5cad | 2006-02-15 15:10:22 -0800 | [diff] [blame] | 200 | if (!cond) |
| 201 | return 1; |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 202 | #ifndef CONFIG_NETFILTER_DEBUG |
| 203 | if (list_empty(&nf_hooks[pf][hook])) |
| 204 | return 1; |
| 205 | #endif |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 206 | return nf_hook_slow(pf, hook, skb, indev, outdev, okfn, thresh); |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 207 | } |
| 208 | |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 209 | static inline int nf_hook(int pf, unsigned int hook, struct sk_buff *skb, |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 210 | struct net_device *indev, struct net_device *outdev, |
| 211 | int (*okfn)(struct sk_buff *)) |
| 212 | { |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 213 | return nf_hook_thresh(pf, hook, skb, indev, outdev, okfn, INT_MIN, 1); |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 214 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
| 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 | |
| 233 | /* This is gross, but inline doesn't cut it for avoiding the function |
| 234 | call in fast path: gcc doesn't inline (needs value tracking?). --RR */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 236 | /* HX: It's slightly less gross now. */ |
| 237 | |
| 238 | #define NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, thresh) \ |
| 239 | ({int __ret; \ |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 240 | if ((__ret=nf_hook_thresh(pf, hook, (skb), indev, outdev, okfn, thresh, 1)) == 1)\ |
Patrick McHardy | 48d5cad | 2006-02-15 15:10:22 -0800 | [diff] [blame] | 241 | __ret = (okfn)(skb); \ |
| 242 | __ret;}) |
| 243 | |
| 244 | #define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) \ |
| 245 | ({int __ret; \ |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 246 | if ((__ret=nf_hook_thresh(pf, hook, (skb), indev, outdev, okfn, INT_MIN, cond)) == 1)\ |
Patrick McHardy | 16a6677 | 2006-01-06 23:01:48 -0800 | [diff] [blame] | 247 | __ret = (okfn)(skb); \ |
| 248 | __ret;}) |
| 249 | |
| 250 | #define NF_HOOK(pf, hook, skb, indev, outdev, okfn) \ |
| 251 | NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, INT_MIN) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | |
| 253 | /* Call setsockopt() */ |
| 254 | int nf_setsockopt(struct sock *sk, int pf, int optval, char __user *opt, |
| 255 | int len); |
| 256 | int nf_getsockopt(struct sock *sk, int pf, int optval, char __user *opt, |
| 257 | int *len); |
| 258 | |
Dmitry Mishin | 3fdadf7 | 2006-03-20 22:45:21 -0800 | [diff] [blame] | 259 | int compat_nf_setsockopt(struct sock *sk, int pf, int optval, |
| 260 | char __user *opt, int len); |
| 261 | int compat_nf_getsockopt(struct sock *sk, int pf, int optval, |
| 262 | char __user *opt, int *len); |
| 263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | /* FIXME: Before cache is ever used, this must be implemented for real. */ |
| 265 | extern void nf_invalidate_cache(int pf); |
| 266 | |
Harald Welte | 089af26 | 2005-08-09 19:37:23 -0700 | [diff] [blame] | 267 | /* Call this before modifying an existing packet: ensures it is |
| 268 | modifiable and linear to the point you care about (writable_len). |
| 269 | Returns true or false. */ |
Herbert Xu | 37d4187 | 2007-10-14 00:39:18 -0700 | [diff] [blame] | 270 | extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len); |
Harald Welte | 089af26 | 2005-08-09 19:37:23 -0700 | [diff] [blame] | 271 | |
Patrick McHardy | 1841a4c | 2007-12-05 01:22:05 -0800 | [diff] [blame] | 272 | struct flowi; |
Patrick McHardy | 02f014d | 2007-12-05 01:26:33 -0800 | [diff] [blame^] | 273 | struct nf_queue_entry; |
Patrick McHardy | c01cd42 | 2007-12-05 01:24:48 -0800 | [diff] [blame] | 274 | |
Patrick McHardy | bce8032 | 2006-04-06 14:18:09 -0700 | [diff] [blame] | 275 | struct nf_afinfo { |
| 276 | unsigned short family; |
Al Viro | b51655b | 2006-11-14 21:40:42 -0800 | [diff] [blame] | 277 | __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook, |
Patrick McHardy | 422c346 | 2006-04-06 14:18:43 -0700 | [diff] [blame] | 278 | unsigned int dataoff, u_int8_t protocol); |
Patrick McHardy | 1841a4c | 2007-12-05 01:22:05 -0800 | [diff] [blame] | 279 | int (*route)(struct dst_entry **dst, struct flowi *fl); |
Patrick McHardy | bce8032 | 2006-04-06 14:18:09 -0700 | [diff] [blame] | 280 | void (*saveroute)(const struct sk_buff *skb, |
Patrick McHardy | 02f014d | 2007-12-05 01:26:33 -0800 | [diff] [blame^] | 281 | struct nf_queue_entry *entry); |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 282 | int (*reroute)(struct sk_buff *skb, |
Patrick McHardy | 02f014d | 2007-12-05 01:26:33 -0800 | [diff] [blame^] | 283 | const struct nf_queue_entry *entry); |
Patrick McHardy | bce8032 | 2006-04-06 14:18:09 -0700 | [diff] [blame] | 284 | int route_key_size; |
Harald Welte | 2cc7d57 | 2005-08-09 19:42:34 -0700 | [diff] [blame] | 285 | }; |
| 286 | |
Patrick McHardy | bce8032 | 2006-04-06 14:18:09 -0700 | [diff] [blame] | 287 | extern struct nf_afinfo *nf_afinfo[]; |
| 288 | static inline struct nf_afinfo *nf_get_afinfo(unsigned short family) |
| 289 | { |
| 290 | return rcu_dereference(nf_afinfo[family]); |
| 291 | } |
Harald Welte | 2cc7d57 | 2005-08-09 19:42:34 -0700 | [diff] [blame] | 292 | |
Al Viro | b51655b | 2006-11-14 21:40:42 -0800 | [diff] [blame] | 293 | static inline __sum16 |
Patrick McHardy | 422c346 | 2006-04-06 14:18:43 -0700 | [diff] [blame] | 294 | nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, |
| 295 | u_int8_t protocol, unsigned short family) |
| 296 | { |
| 297 | struct nf_afinfo *afinfo; |
Al Viro | b51655b | 2006-11-14 21:40:42 -0800 | [diff] [blame] | 298 | __sum16 csum = 0; |
Patrick McHardy | 422c346 | 2006-04-06 14:18:43 -0700 | [diff] [blame] | 299 | |
| 300 | rcu_read_lock(); |
| 301 | afinfo = nf_get_afinfo(family); |
| 302 | if (afinfo) |
| 303 | csum = afinfo->checksum(skb, hook, dataoff, protocol); |
| 304 | rcu_read_unlock(); |
| 305 | return csum; |
| 306 | } |
| 307 | |
Patrick McHardy | bce8032 | 2006-04-06 14:18:09 -0700 | [diff] [blame] | 308 | extern int nf_register_afinfo(struct nf_afinfo *afinfo); |
| 309 | extern void nf_unregister_afinfo(struct nf_afinfo *afinfo); |
| 310 | |
Patrick McHardy | eb9c7eb | 2006-01-06 23:06:30 -0800 | [diff] [blame] | 311 | #include <net/flow.h> |
| 312 | extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *); |
| 313 | |
| 314 | static inline void |
| 315 | nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family) |
| 316 | { |
Jozsef Kadlecsik | 5b1158e | 2006-12-02 22:07:13 -0800 | [diff] [blame] | 317 | #if defined(CONFIG_IP_NF_NAT_NEEDED) || defined(CONFIG_NF_NAT_NEEDED) |
Patrick McHardy | eb9c7eb | 2006-01-06 23:06:30 -0800 | [diff] [blame] | 318 | void (*decodefn)(struct sk_buff *, struct flowi *); |
| 319 | |
| 320 | if (family == AF_INET && (decodefn = ip_nat_decode_session) != NULL) |
| 321 | decodefn(skb, fl); |
| 322 | #endif |
| 323 | } |
| 324 | |
Harald Welte | 608c8e4 | 2005-08-09 19:58:27 -0700 | [diff] [blame] | 325 | #ifdef CONFIG_PROC_FS |
| 326 | #include <linux/proc_fs.h> |
| 327 | extern struct proc_dir_entry *proc_net_netfilter; |
| 328 | #endif |
| 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | #else /* !CONFIG_NETFILTER */ |
| 331 | #define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb) |
Patrick McHardy | 48d5cad | 2006-02-15 15:10:22 -0800 | [diff] [blame] | 332 | #define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb) |
David S. Miller | f53b61d | 2006-01-07 12:50:27 -0800 | [diff] [blame] | 333 | static inline int nf_hook_thresh(int pf, unsigned int hook, |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 334 | struct sk_buff *skb, |
David S. Miller | f53b61d | 2006-01-07 12:50:27 -0800 | [diff] [blame] | 335 | struct net_device *indev, |
| 336 | struct net_device *outdev, |
Patrick McHardy | 48d5cad | 2006-02-15 15:10:22 -0800 | [diff] [blame] | 337 | int (*okfn)(struct sk_buff *), int thresh, |
| 338 | int cond) |
David S. Miller | f53b61d | 2006-01-07 12:50:27 -0800 | [diff] [blame] | 339 | { |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 340 | return okfn(skb); |
David S. Miller | f53b61d | 2006-01-07 12:50:27 -0800 | [diff] [blame] | 341 | } |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 342 | static inline int nf_hook(int pf, unsigned int hook, struct sk_buff *skb, |
David S. Miller | f53b61d | 2006-01-07 12:50:27 -0800 | [diff] [blame] | 343 | struct net_device *indev, struct net_device *outdev, |
| 344 | int (*okfn)(struct sk_buff *)) |
| 345 | { |
Patrick McHardy | 9c92d34 | 2006-02-15 15:18:19 -0800 | [diff] [blame] | 346 | return 1; |
David S. Miller | f53b61d | 2006-01-07 12:50:27 -0800 | [diff] [blame] | 347 | } |
David S. Miller | f53b61d | 2006-01-07 12:50:27 -0800 | [diff] [blame] | 348 | struct flowi; |
Patrick McHardy | eb9c7eb | 2006-01-06 23:06:30 -0800 | [diff] [blame] | 349 | static inline void |
| 350 | nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family) {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | #endif /*CONFIG_NETFILTER*/ |
| 352 | |
Yasuyuki Kozakai | 5f79e0f | 2007-03-23 11:17:07 -0700 | [diff] [blame] | 353 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
| 354 | extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *); |
| 355 | extern void nf_ct_attach(struct sk_buff *, struct sk_buff *); |
Yasuyuki Kozakai | de6e05c | 2007-03-23 11:17:27 -0700 | [diff] [blame] | 356 | extern void (*nf_ct_destroy)(struct nf_conntrack *); |
Yasuyuki Kozakai | 5f79e0f | 2007-03-23 11:17:07 -0700 | [diff] [blame] | 357 | #else |
| 358 | static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} |
| 359 | #endif |
| 360 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | #endif /*__KERNEL__*/ |
| 362 | #endif /*__LINUX_NETFILTER_H*/ |