Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This header is used to share core functionality between the |
| 3 | * standalone connection tracking module, and the compatibility layer's use |
| 4 | * of connection tracking. |
| 5 | * |
| 6 | * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> |
| 7 | * - generalize L3 protocol dependent part. |
| 8 | * |
| 9 | * Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h |
| 10 | */ |
| 11 | |
| 12 | #ifndef _NF_CONNTRACK_CORE_H |
| 13 | #define _NF_CONNTRACK_CORE_H |
| 14 | |
| 15 | #include <linux/netfilter.h> |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 16 | #include <net/netfilter/nf_conntrack_l3proto.h> |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 17 | #include <net/netfilter/nf_conntrack_l4proto.h> |
Martin Josefsson | f618012 | 2006-11-29 02:35:01 +0100 | [diff] [blame] | 18 | #include <net/netfilter/nf_conntrack_ecache.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 19 | |
| 20 | /* This header is used to share core functionality between the |
| 21 | standalone connection tracking module, and the compatibility layer's use |
| 22 | of connection tracking. */ |
Alexey Dobriyan | a702a65 | 2008-10-08 11:35:04 +0200 | [diff] [blame] | 23 | extern unsigned int nf_conntrack_in(struct net *net, |
| 24 | u_int8_t pf, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 25 | unsigned int hooknum, |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 26 | struct sk_buff *skb); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 27 | |
Alexey Dobriyan | dfdb8d7 | 2008-10-08 11:35:02 +0200 | [diff] [blame] | 28 | extern int nf_conntrack_init(struct net *net); |
| 29 | extern void nf_conntrack_cleanup(struct net *net); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 30 | |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 31 | extern int nf_conntrack_proto_init(void); |
| 32 | extern void nf_conntrack_proto_fini(void); |
| 33 | |
Jan Engelhardt | 5f2b4c9 | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 34 | extern bool |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 35 | nf_ct_get_tuple(const struct sk_buff *skb, |
| 36 | unsigned int nhoff, |
| 37 | unsigned int dataoff, |
| 38 | u_int16_t l3num, |
| 39 | u_int8_t protonum, |
| 40 | struct nf_conntrack_tuple *tuple, |
| 41 | const struct nf_conntrack_l3proto *l3proto, |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 42 | const struct nf_conntrack_l4proto *l4proto); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 43 | |
Jan Engelhardt | 5f2b4c9 | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 44 | extern bool |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 45 | nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, |
| 46 | const struct nf_conntrack_tuple *orig, |
| 47 | const struct nf_conntrack_l3proto *l3proto, |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 48 | const struct nf_conntrack_l4proto *l4proto); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 49 | |
| 50 | /* Find a connection corresponding to a tuple. */ |
| 51 | extern struct nf_conntrack_tuple_hash * |
Alexey Dobriyan | 400dad3 | 2008-10-08 11:35:03 +0200 | [diff] [blame] | 52 | nf_conntrack_find_get(struct net *net, const struct nf_conntrack_tuple *tuple); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 53 | |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 54 | extern int __nf_conntrack_confirm(struct sk_buff *skb); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 55 | |
| 56 | /* Confirm a connection: returns NF_DROP if packet must be dropped. */ |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 57 | static inline int nf_conntrack_confirm(struct sk_buff *skb) |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 58 | { |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 59 | struct nf_conn *ct = (struct nf_conn *)skb->nfct; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 60 | int ret = NF_ACCEPT; |
| 61 | |
Patrick McHardy | 5962fc6 | 2009-02-18 15:30:34 +0100 | [diff] [blame] | 62 | if (ct && ct != &nf_conntrack_untracked) { |
Patrick McHardy | ec68e97 | 2007-03-04 15:57:01 -0800 | [diff] [blame] | 63 | if (!nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 64 | ret = __nf_conntrack_confirm(skb); |
Pablo Neira Ayuso | b1e93a6 | 2009-03-16 15:06:42 +0100 | [diff] [blame] | 65 | if (likely(ret == NF_ACCEPT)) |
| 66 | nf_ct_deliver_cached_events(ct); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 67 | } |
| 68 | return ret; |
| 69 | } |
| 70 | |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 71 | int |
| 72 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, |
Jan Engelhardt | 3294858 | 2008-01-31 04:53:24 -0800 | [diff] [blame] | 73 | const struct nf_conntrack_l3proto *l3proto, |
| 74 | const struct nf_conntrack_l4proto *proto); |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 75 | |
Patrick McHardy | f8ba1af | 2008-01-31 04:38:58 -0800 | [diff] [blame] | 76 | extern spinlock_t nf_conntrack_lock ; |
Martin Josefsson | 7e5d03b | 2006-11-29 02:34:59 +0100 | [diff] [blame] | 77 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 78 | #endif /* _NF_CONNTRACK_CORE_H */ |