blob: 46eeea1e2733e5c2295d463c55afdf38995bd8bd [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
5/* This header is used to share core functionality between the
6 standalone connection tracking module, and the compatibility layer's use
7 of connection tracking. */
8extern unsigned int ip_conntrack_in(unsigned int hooknum,
9 struct sk_buff **pskb,
10 const struct net_device *in,
11 const struct net_device *out,
12 int (*okfn)(struct sk_buff *));
13
14extern int ip_conntrack_init(void);
15extern void ip_conntrack_cleanup(void);
16
17struct ip_conntrack_protocol;
18
19extern int
20ip_ct_get_tuple(const struct iphdr *iph,
21 const struct sk_buff *skb,
22 unsigned int dataoff,
23 struct ip_conntrack_tuple *tuple,
24 const struct ip_conntrack_protocol *protocol);
25
26extern int
27ip_ct_invert_tuple(struct ip_conntrack_tuple *inverse,
28 const struct ip_conntrack_tuple *orig,
29 const struct ip_conntrack_protocol *protocol);
30
31/* Find a connection corresponding to a tuple. */
32struct ip_conntrack_tuple_hash *
33ip_conntrack_find_get(const struct ip_conntrack_tuple *tuple,
34 const struct ip_conntrack *ignored_conntrack);
35
36extern int __ip_conntrack_confirm(struct sk_buff **pskb);
37
38/* Confirm a connection: returns NF_DROP if packet must be dropped. */
39static inline int ip_conntrack_confirm(struct sk_buff **pskb)
40{
Harald Welteac3247b2005-08-09 19:28:03 -070041 struct ip_conntrack *ct = (struct ip_conntrack *)(*pskb)->nfct;
42 int ret = NF_ACCEPT;
43
44 if (ct && !is_confirmed(ct))
45 ret = __ip_conntrack_confirm(pskb);
46 ip_conntrack_deliver_cached_events_for(ct);
47
48 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049}
50
Harald Welteac3247b2005-08-09 19:28:03 -070051#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
52struct ip_conntrack_ecache;
53extern void __ip_ct_deliver_cached_events(struct ip_conntrack_ecache *ec);
54#endif
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056extern struct list_head *ip_conntrack_hash;
57extern struct list_head ip_conntrack_expect_list;
Patrick McHardye45b1be2005-06-21 14:01:30 -070058extern rwlock_t ip_conntrack_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#endif /* _IP_CONNTRACK_CORE_H */
60