blob: 907d4f5ca5dc50f2384ad69730f8c5686e085cf1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _IP_CONNTRACK_CORE_H
2#define _IP_CONNTRACK_CORE_H
3#include <linux/netfilter.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Harald Welte080774a2005-08-09 19:32:58 -07005#define MAX_IP_CT_PROTO 256
6extern struct ip_conntrack_protocol *ip_ct_protos[MAX_IP_CT_PROTO];
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008/* This header is used to share core functionality between the
9 standalone connection tracking module, and the compatibility layer's use
10 of connection tracking. */
11extern unsigned int ip_conntrack_in(unsigned int hooknum,
12 struct sk_buff **pskb,
13 const struct net_device *in,
14 const struct net_device *out,
15 int (*okfn)(struct sk_buff *));
16
17extern int ip_conntrack_init(void);
18extern void ip_conntrack_cleanup(void);
19
20struct ip_conntrack_protocol;
21
22extern int
23ip_ct_get_tuple(const struct iphdr *iph,
24 const struct sk_buff *skb,
25 unsigned int dataoff,
26 struct ip_conntrack_tuple *tuple,
27 const struct ip_conntrack_protocol *protocol);
28
29extern int
30ip_ct_invert_tuple(struct ip_conntrack_tuple *inverse,
31 const struct ip_conntrack_tuple *orig,
32 const struct ip_conntrack_protocol *protocol);
33
34/* Find a connection corresponding to a tuple. */
35struct ip_conntrack_tuple_hash *
36ip_conntrack_find_get(const struct ip_conntrack_tuple *tuple,
37 const struct ip_conntrack *ignored_conntrack);
38
39extern int __ip_conntrack_confirm(struct sk_buff **pskb);
40
41/* Confirm a connection: returns NF_DROP if packet must be dropped. */
42static inline int ip_conntrack_confirm(struct sk_buff **pskb)
43{
Harald Welteac3247b2005-08-09 19:28:03 -070044 struct ip_conntrack *ct = (struct ip_conntrack *)(*pskb)->nfct;
45 int ret = NF_ACCEPT;
46
Patrick McHardya86888b2005-08-09 20:02:13 -070047 if (ct) {
48 if (!is_confirmed(ct))
49 ret = __ip_conntrack_confirm(pskb);
50 ip_ct_deliver_cached_events(ct);
51 }
Harald Welteac3247b2005-08-09 19:28:03 -070052 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
Pablo Neira Ayuso49719eb2005-09-06 15:10:46 -070055extern void ip_ct_unlink_expect(struct ip_conntrack_expect *exp);
Harald Welte080774a2005-08-09 19:32:58 -070056
Linus Torvalds1da177e2005-04-16 15:20:36 -070057extern struct list_head *ip_conntrack_hash;
58extern struct list_head ip_conntrack_expect_list;
Patrick McHardye45b1be2005-06-21 14:01:30 -070059extern rwlock_t ip_conntrack_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#endif /* _IP_CONNTRACK_CORE_H */
61