[NETFILTER]: nf_conntrack: split out expectation handling
[sfrench/cifs-2.6.git] / include / net / netfilter / nf_conntrack_core.h
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>
16 #include <net/netfilter/nf_conntrack_l3proto.h>
17 #include <net/netfilter/nf_conntrack_protocol.h>
18
19 /* This header is used to share core functionality between the
20    standalone connection tracking module, and the compatibility layer's use
21    of connection tracking. */
22 extern unsigned int nf_conntrack_in(int pf,
23                                     unsigned int hooknum,
24                                     struct sk_buff **pskb);
25
26 extern int nf_conntrack_init(void);
27 extern void nf_conntrack_cleanup(void);
28
29 struct nf_conntrack_l3proto;
30 extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf);
31 /* Like above, but you already have conntrack read lock. */
32 extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto);
33
34 struct nf_conntrack_protocol;
35
36 extern int
37 nf_ct_get_tuple(const struct sk_buff *skb,
38                 unsigned int nhoff,
39                 unsigned int dataoff,
40                 u_int16_t l3num,
41                 u_int8_t protonum,
42                 struct nf_conntrack_tuple *tuple,
43                 const struct nf_conntrack_l3proto *l3proto,
44                 const struct nf_conntrack_protocol *protocol);
45
46 extern int
47 nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
48                    const struct nf_conntrack_tuple *orig,
49                    const struct nf_conntrack_l3proto *l3proto,
50                    const struct nf_conntrack_protocol *protocol);
51
52 /* Find a connection corresponding to a tuple. */
53 extern struct nf_conntrack_tuple_hash *
54 nf_conntrack_find_get(const struct nf_conntrack_tuple *tuple,
55                       const struct nf_conn *ignored_conntrack);
56
57 extern int __nf_conntrack_confirm(struct sk_buff **pskb);
58
59 /* Confirm a connection: returns NF_DROP if packet must be dropped. */
60 static inline int nf_conntrack_confirm(struct sk_buff **pskb)
61 {
62         struct nf_conn *ct = (struct nf_conn *)(*pskb)->nfct;
63         int ret = NF_ACCEPT;
64
65         if (ct) {
66                 if (!nf_ct_is_confirmed(ct))
67                         ret = __nf_conntrack_confirm(pskb);
68                 nf_ct_deliver_cached_events(ct);
69         }
70         return ret;
71 }
72
73 extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb);
74
75 int
76 print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
77             struct nf_conntrack_l3proto *l3proto,
78             struct nf_conntrack_protocol *proto);
79
80 extern struct list_head *nf_conntrack_hash;
81 extern struct list_head nf_conntrack_expect_list;
82 extern rwlock_t nf_conntrack_lock ;
83 #endif /* _NF_CONNTRACK_CORE_H */