Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 1 | /* |
| 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 McHardy | a71c085 | 2007-07-07 22:33:47 -0700 | [diff] [blame] | 9 | extern struct hlist_head *nf_ct_expect_hash; |
| 10 | extern unsigned int nf_ct_expect_hsize; |
Patrick McHardy | f264a7d | 2007-07-07 22:36:24 -0700 | [diff] [blame] | 11 | extern unsigned int nf_ct_expect_max; |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 12 | |
| 13 | struct nf_conntrack_expect |
| 14 | { |
Patrick McHardy | b560580 | 2007-07-07 22:35:56 -0700 | [diff] [blame] | 15 | /* Conntrack expectation list member */ |
| 16 | struct hlist_node lnode; |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 17 | |
Patrick McHardy | a71c085 | 2007-07-07 22:33:47 -0700 | [diff] [blame] | 18 | /* Hash member */ |
| 19 | struct hlist_node hnode; |
| 20 | |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 21 | /* We expect this tuple, with the following mask */ |
Patrick McHardy | d4156e8 | 2007-07-07 22:31:32 -0700 | [diff] [blame] | 22 | struct nf_conntrack_tuple tuple; |
| 23 | struct nf_conntrack_tuple_mask mask; |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 24 | |
| 25 | /* Function to call after setup and insertion */ |
| 26 | void (*expectfn)(struct nf_conn *new, |
| 27 | struct nf_conntrack_expect *this); |
| 28 | |
Patrick McHardy | 9457d85 | 2006-12-02 22:05:25 -0800 | [diff] [blame] | 29 | /* Helper to assign to new connection */ |
| 30 | struct nf_conntrack_helper *helper; |
| 31 | |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 32 | /* 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 Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 41 | /* Flags */ |
| 42 | unsigned int flags; |
| 43 | |
| 44 | #ifdef CONFIG_NF_NAT_NEEDED |
Patrick McHardy | f587de0 | 2006-12-02 22:08:46 -0800 | [diff] [blame] | 45 | __be32 saved_ip; |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 46 | /* This is the original per-proto part, used to map the |
| 47 | * expected connection the way the recipient expects. */ |
Jozsef Kadlecsik | 5b1158e | 2006-12-02 22:07:13 -0800 | [diff] [blame] | 48 | union nf_conntrack_man_proto saved_proto; |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 49 | /* Direction relative to the master connection. */ |
| 50 | enum ip_conntrack_dir dir; |
| 51 | #endif |
Patrick McHardy | 7d0742d | 2008-01-31 04:38:19 -0800 | [diff] [blame] | 52 | |
| 53 | struct rcu_head rcu; |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 54 | }; |
| 55 | |
Patrick McHardy | 359b9ab | 2008-03-25 20:08:37 -0700 | [diff] [blame^] | 56 | #define NF_CT_EXPECT_PERMANENT 0x1 |
| 57 | #define NF_CT_EXPECT_INACTIVE 0x2 |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 58 | |
Patrick McHardy | e9c1b08 | 2007-07-07 22:32:53 -0700 | [diff] [blame] | 59 | int nf_conntrack_expect_init(void); |
| 60 | void nf_conntrack_expect_fini(void); |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 61 | |
| 62 | struct nf_conntrack_expect * |
Patrick McHardy | 6823645 | 2007-07-07 22:30:49 -0700 | [diff] [blame] | 63 | __nf_ct_expect_find(const struct nf_conntrack_tuple *tuple); |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 64 | |
| 65 | struct nf_conntrack_expect * |
Patrick McHardy | 6823645 | 2007-07-07 22:30:49 -0700 | [diff] [blame] | 66 | nf_ct_expect_find_get(const struct nf_conntrack_tuple *tuple); |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 67 | |
| 68 | struct nf_conntrack_expect * |
Patrick McHardy | 6823645 | 2007-07-07 22:30:49 -0700 | [diff] [blame] | 69 | nf_ct_find_expectation(const struct nf_conntrack_tuple *tuple); |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 70 | |
| 71 | void nf_ct_unlink_expect(struct nf_conntrack_expect *exp); |
| 72 | void nf_ct_remove_expectations(struct nf_conn *ct); |
Patrick McHardy | 6823645 | 2007-07-07 22:30:49 -0700 | [diff] [blame] | 73 | void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 74 | |
| 75 | /* Allocate space for an expectation: this is mandatory before calling |
Patrick McHardy | 6823645 | 2007-07-07 22:30:49 -0700 | [diff] [blame] | 76 | nf_ct_expect_related. You will have to call put afterwards. */ |
| 77 | struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me); |
| 78 | void nf_ct_expect_init(struct nf_conntrack_expect *, int, |
Patrick McHardy | 1d9d752 | 2008-03-25 20:07:58 -0700 | [diff] [blame] | 79 | const union nf_inet_addr *, |
| 80 | const union nf_inet_addr *, |
| 81 | u_int8_t, const __be16 *, const __be16 *); |
Patrick McHardy | 6823645 | 2007-07-07 22:30:49 -0700 | [diff] [blame] | 82 | void nf_ct_expect_put(struct nf_conntrack_expect *exp); |
| 83 | int nf_ct_expect_related(struct nf_conntrack_expect *expect); |
Martin Josefsson | 77ab9cf | 2006-11-29 02:34:58 +0100 | [diff] [blame] | 84 | |
| 85 | #endif /*_NF_CONNTRACK_EXPECT_H*/ |
| 86 | |