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.
6 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
7 * - generalize L3 protocol dependent part.
9 * Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h
12 #ifndef _NF_CONNTRACK_CORE_H
13 #define _NF_CONNTRACK_CORE_H
15 #include <linux/netfilter.h>
16 #include <net/netfilter/nf_conntrack_l3proto.h>
17 #include <net/netfilter/nf_conntrack_l4proto.h>
18 #include <net/netfilter/nf_conntrack_ecache.h>
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. */
23 unsigned int nf_conntrack_in(struct net
*net
, u_int8_t pf
, unsigned int hooknum
,
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
);
30 int nf_conntrack_proto_pernet_init(struct net
*net
);
31 void nf_conntrack_proto_pernet_fini(struct net
*net
);
33 int nf_conntrack_proto_init(void);
34 void nf_conntrack_proto_fini(void);
36 int nf_conntrack_init_start(void);
37 void nf_conntrack_cleanup_start(void);
39 void nf_conntrack_init_end(void);
40 void nf_conntrack_cleanup_end(void);
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
,
45 struct nf_conntrack_tuple
*tuple
,
46 const struct nf_conntrack_l3proto
*l3proto
,
47 const struct nf_conntrack_l4proto
*l4proto
);
49 bool nf_ct_invert_tuple(struct nf_conntrack_tuple
*inverse
,
50 const struct nf_conntrack_tuple
*orig
,
51 const struct nf_conntrack_l3proto
*l3proto
,
52 const struct nf_conntrack_l4proto
*l4proto
);
54 void nf_conntrack_get_ht(struct hlist_nulls_head
**hash
, unsigned int *hsize
);
56 /* Find a connection corresponding to a tuple. */
57 struct nf_conntrack_tuple_hash
*
58 nf_conntrack_find_get(struct net
*net
,
59 const struct nf_conntrack_zone
*zone
,
60 const struct nf_conntrack_tuple
*tuple
);
62 int __nf_conntrack_confirm(struct sk_buff
*skb
);
64 /* Confirm a connection: returns NF_DROP if packet must be dropped. */
65 static inline int nf_conntrack_confirm(struct sk_buff
*skb
)
67 struct nf_conn
*ct
= (struct nf_conn
*)skb
->nfct
;
70 if (ct
&& !nf_ct_is_untracked(ct
)) {
71 if (!nf_ct_is_confirmed(ct
))
72 ret
= __nf_conntrack_confirm(skb
);
73 if (likely(ret
== NF_ACCEPT
))
74 nf_ct_deliver_cached_events(ct
);
80 print_tuple(struct seq_file
*s
, const struct nf_conntrack_tuple
*tuple
,
81 const struct nf_conntrack_l3proto
*l3proto
,
82 const struct nf_conntrack_l4proto
*proto
);
84 #define CONNTRACK_LOCKS 1024
86 extern struct hlist_nulls_head
*nf_conntrack_hash
;
87 extern spinlock_t nf_conntrack_locks
[CONNTRACK_LOCKS
];
88 void nf_conntrack_lock(spinlock_t
*lock
);
90 extern spinlock_t nf_conntrack_expect_lock
;
92 #endif /* _NF_CONNTRACK_CORE_H */