blob: 47c28dd07896054d081f91dce55cfcdb55ef0710 [file] [log] [blame]
Martin Josefsson77ab9cf2006-11-29 02:34:58 +01001/*
2 * connection tracking expectations.
3 */
4
5#ifndef _NF_CONNTRACK_EXPECT_H
6#define _NF_CONNTRACK_EXPECT_H
7#include <net/netfilter/nf_conntrack.h>
8
Patrick McHardya71c0852007-07-07 22:33:47 -07009extern struct hlist_head *nf_ct_expect_hash;
10extern unsigned int nf_ct_expect_hsize;
Patrick McHardyf264a7d2007-07-07 22:36:24 -070011extern unsigned int nf_ct_expect_max;
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010012
13struct nf_conntrack_expect
14{
Patrick McHardyb5605802007-07-07 22:35:56 -070015 /* Conntrack expectation list member */
16 struct hlist_node lnode;
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010017
Patrick McHardya71c0852007-07-07 22:33:47 -070018 /* Hash member */
19 struct hlist_node hnode;
20
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010021 /* We expect this tuple, with the following mask */
Patrick McHardyd4156e82007-07-07 22:31:32 -070022 struct nf_conntrack_tuple tuple;
23 struct nf_conntrack_tuple_mask mask;
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010024
25 /* Function to call after setup and insertion */
26 void (*expectfn)(struct nf_conn *new,
27 struct nf_conntrack_expect *this);
28
Patrick McHardy9457d852006-12-02 22:05:25 -080029 /* Helper to assign to new connection */
30 struct nf_conntrack_helper *helper;
31
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010032 /* The conntrack of the master connection */
33 struct nf_conn *master;
34
35 /* Timer function; deletes the expectation. */
36 struct timer_list timeout;
37
38 /* Usage count. */
39 atomic_t use;
40
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010041 /* Flags */
42 unsigned int flags;
43
44#ifdef CONFIG_NF_NAT_NEEDED
Patrick McHardyf587de02006-12-02 22:08:46 -080045 __be32 saved_ip;
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010046 /* This is the original per-proto part, used to map the
47 * expected connection the way the recipient expects. */
Jozsef Kadlecsik5b1158e2006-12-02 22:07:13 -080048 union nf_conntrack_man_proto saved_proto;
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010049 /* Direction relative to the master connection. */
50 enum ip_conntrack_dir dir;
51#endif
Patrick McHardy7d0742d2008-01-31 04:38:19 -080052
53 struct rcu_head rcu;
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010054};
55
Patrick McHardy359b9ab2008-03-25 20:08:37 -070056#define NF_CT_EXPECT_PERMANENT 0x1
57#define NF_CT_EXPECT_INACTIVE 0x2
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010058
Patrick McHardye9c1b082007-07-07 22:32:53 -070059int nf_conntrack_expect_init(void);
60void nf_conntrack_expect_fini(void);
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010061
62struct nf_conntrack_expect *
Patrick McHardy68236452007-07-07 22:30:49 -070063__nf_ct_expect_find(const struct nf_conntrack_tuple *tuple);
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010064
65struct nf_conntrack_expect *
Patrick McHardy68236452007-07-07 22:30:49 -070066nf_ct_expect_find_get(const struct nf_conntrack_tuple *tuple);
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010067
68struct nf_conntrack_expect *
Patrick McHardy68236452007-07-07 22:30:49 -070069nf_ct_find_expectation(const struct nf_conntrack_tuple *tuple);
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010070
71void nf_ct_unlink_expect(struct nf_conntrack_expect *exp);
72void nf_ct_remove_expectations(struct nf_conn *ct);
Patrick McHardy68236452007-07-07 22:30:49 -070073void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010074
75/* Allocate space for an expectation: this is mandatory before calling
Patrick McHardy68236452007-07-07 22:30:49 -070076 nf_ct_expect_related. You will have to call put afterwards. */
77struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me);
78void nf_ct_expect_init(struct nf_conntrack_expect *, int,
Patrick McHardy1d9d7522008-03-25 20:07:58 -070079 const union nf_inet_addr *,
80 const union nf_inet_addr *,
81 u_int8_t, const __be16 *, const __be16 *);
Patrick McHardy68236452007-07-07 22:30:49 -070082void nf_ct_expect_put(struct nf_conntrack_expect *exp);
83int nf_ct_expect_related(struct nf_conntrack_expect *expect);
Martin Josefsson77ab9cf2006-11-29 02:34:58 +010084
85#endif /*_NF_CONNTRACK_EXPECT_H*/
86