Commit | Line | Data |
---|---|---|
9fb9cbb1 YK |
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> | |
77ab9cff | 16 | #include <net/netfilter/nf_conntrack_l3proto.h> |
605dcad6 | 17 | #include <net/netfilter/nf_conntrack_l4proto.h> |
f6180121 | 18 | #include <net/netfilter/nf_conntrack_ecache.h> |
9fb9cbb1 YK |
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. */ | |
4e77be46 JP |
23 | unsigned int nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, |
24 | struct sk_buff *skb); | |
25 | ||
26 | int nf_conntrack_init_net(struct net *net); | |
27 | void nf_conntrack_cleanup_net(struct net *net); | |
28 | void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list); | |
29 | ||
30 | int nf_conntrack_proto_pernet_init(struct net *net); | |
31 | void nf_conntrack_proto_pernet_fini(struct net *net); | |
32 | ||
33 | int nf_conntrack_proto_init(void); | |
34 | void nf_conntrack_proto_fini(void); | |
35 | ||
36 | int nf_conntrack_init_start(void); | |
37 | void nf_conntrack_cleanup_start(void); | |
38 | ||
39 | void nf_conntrack_init_end(void); | |
40 | void nf_conntrack_cleanup_end(void); | |
41 | ||
42 | bool nf_ct_get_tuple(const struct sk_buff *skb, unsigned int nhoff, | |
43 | unsigned int dataoff, u_int16_t l3num, u_int8_t protonum, | |
44 | struct nf_conntrack_tuple *tuple, | |
45 | const struct nf_conntrack_l3proto *l3proto, | |
46 | const struct nf_conntrack_l4proto *l4proto); | |
47 | ||
48 | bool nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, | |
49 | const struct nf_conntrack_tuple *orig, | |
50 | const struct nf_conntrack_l3proto *l3proto, | |
51 | const struct nf_conntrack_l4proto *l4proto); | |
9fb9cbb1 YK |
52 | |
53 | /* Find a connection corresponding to a tuple. */ | |
4e77be46 | 54 | struct nf_conntrack_tuple_hash * |
5d0aa2cc PM |
55 | nf_conntrack_find_get(struct net *net, u16 zone, |
56 | const struct nf_conntrack_tuple *tuple); | |
9fb9cbb1 | 57 | |
4e77be46 | 58 | int __nf_conntrack_confirm(struct sk_buff *skb); |
9fb9cbb1 YK |
59 | |
60 | /* Confirm a connection: returns NF_DROP if packet must be dropped. */ | |
3db05fea | 61 | static inline int nf_conntrack_confirm(struct sk_buff *skb) |
9fb9cbb1 | 62 | { |
3db05fea | 63 | struct nf_conn *ct = (struct nf_conn *)skb->nfct; |
9fb9cbb1 YK |
64 | int ret = NF_ACCEPT; |
65 | ||
5bfddbd4 | 66 | if (ct && !nf_ct_is_untracked(ct)) { |
fc350777 | 67 | if (!nf_ct_is_confirmed(ct)) |
3db05fea | 68 | ret = __nf_conntrack_confirm(skb); |
b1e93a68 PNA |
69 | if (likely(ret == NF_ACCEPT)) |
70 | nf_ct_deliver_cached_events(ct); | |
9fb9cbb1 YK |
71 | } |
72 | return ret; | |
73 | } | |
74 | ||
824f1fbe | 75 | void |
77ab9cff | 76 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, |
32948588 JE |
77 | const struct nf_conntrack_l3proto *l3proto, |
78 | const struct nf_conntrack_l4proto *proto); | |
77ab9cff | 79 | |
93bb0ceb JDB |
80 | #ifdef CONFIG_LOCKDEP |
81 | # define CONNTRACK_LOCKS 8 | |
82 | #else | |
83 | # define CONNTRACK_LOCKS 1024 | |
84 | #endif | |
85 | extern spinlock_t nf_conntrack_locks[CONNTRACK_LOCKS]; | |
7e5d03bb | 86 | |
ca7433df JDB |
87 | extern spinlock_t nf_conntrack_expect_lock; |
88 | ||
9fb9cbb1 | 89 | #endif /* _NF_CONNTRACK_CORE_H */ |