Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6-block.git] / include / net / netfilter / nf_conntrack_expect.h
CommitLineData
77ab9cff
MJ
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
a71c0855 9extern unsigned int nf_ct_expect_hsize;
f264a7df 10extern unsigned int nf_ct_expect_max;
77ab9cff 11
fd2c3ef7 12struct nf_conntrack_expect {
b560580a
PM
13 /* Conntrack expectation list member */
14 struct hlist_node lnode;
77ab9cff 15
a71c0855
PM
16 /* Hash member */
17 struct hlist_node hnode;
18
77ab9cff 19 /* We expect this tuple, with the following mask */
d4156e8c
PM
20 struct nf_conntrack_tuple tuple;
21 struct nf_conntrack_tuple_mask mask;
77ab9cff
MJ
22
23 /* Function to call after setup and insertion */
24 void (*expectfn)(struct nf_conn *new,
25 struct nf_conntrack_expect *this);
26
9457d851
PM
27 /* Helper to assign to new connection */
28 struct nf_conntrack_helper *helper;
29
77ab9cff
MJ
30 /* The conntrack of the master connection */
31 struct nf_conn *master;
32
33 /* Timer function; deletes the expectation. */
34 struct timer_list timeout;
35
36 /* Usage count. */
37 atomic_t use;
38
77ab9cff
MJ
39 /* Flags */
40 unsigned int flags;
41
6002f266
PM
42 /* Expectation class */
43 unsigned int class;
44
77ab9cff 45#ifdef CONFIG_NF_NAT_NEEDED
c7232c99 46 union nf_inet_addr saved_addr;
77ab9cff
MJ
47 /* This is the original per-proto part, used to map the
48 * expected connection the way the recipient expects. */
5b1158e9 49 union nf_conntrack_man_proto saved_proto;
77ab9cff
MJ
50 /* Direction relative to the master connection. */
51 enum ip_conntrack_dir dir;
52#endif
7d0742da
PM
53
54 struct rcu_head rcu;
77ab9cff
MJ
55};
56
9b03f38d
AD
57static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
58{
857b409a 59 return nf_ct_net(exp->master);
9b03f38d
AD
60}
61
3a8fc53a
PNA
62#define NF_CT_EXP_POLICY_NAME_LEN 16
63
fd2c3ef7 64struct nf_conntrack_expect_policy {
6002f266
PM
65 unsigned int max_expected;
66 unsigned int timeout;
3a8fc53a 67 char name[NF_CT_EXP_POLICY_NAME_LEN];
6002f266
PM
68};
69
70#define NF_CT_EXPECT_CLASS_DEFAULT 0
71
83b4dbe1
G
72int nf_conntrack_expect_pernet_init(struct net *net);
73void nf_conntrack_expect_pernet_fini(struct net *net);
74
75int nf_conntrack_expect_init(void);
76void nf_conntrack_expect_fini(void);
77ab9cff
MJ
77
78struct nf_conntrack_expect *
5d0aa2cc
PM
79__nf_ct_expect_find(struct net *net, u16 zone,
80 const struct nf_conntrack_tuple *tuple);
77ab9cff
MJ
81
82struct nf_conntrack_expect *
5d0aa2cc
PM
83nf_ct_expect_find_get(struct net *net, u16 zone,
84 const struct nf_conntrack_tuple *tuple);
77ab9cff
MJ
85
86struct nf_conntrack_expect *
5d0aa2cc
PM
87nf_ct_find_expectation(struct net *net, u16 zone,
88 const struct nf_conntrack_tuple *tuple);
77ab9cff 89
ebbf41df 90void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,
ec464e5d 91 u32 portid, int report);
ebbf41df
PNA
92static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp)
93{
94 nf_ct_unlink_expect_report(exp, 0, 0);
95}
96
77ab9cff 97void nf_ct_remove_expectations(struct nf_conn *ct);
6823645d 98void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
77ab9cff
MJ
99
100/* Allocate space for an expectation: this is mandatory before calling
6823645d
PM
101 nf_ct_expect_related. You will have to call put afterwards. */
102struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me);
76108cea 103void nf_ct_expect_init(struct nf_conntrack_expect *, unsigned int, u_int8_t,
1d9d7522
PM
104 const union nf_inet_addr *,
105 const union nf_inet_addr *,
106 u_int8_t, const __be16 *, const __be16 *);
6823645d 107void nf_ct_expect_put(struct nf_conntrack_expect *exp);
19abb7b0 108int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
ec464e5d 109 u32 portid, int report);
83731671
PNA
110static inline int nf_ct_expect_related(struct nf_conntrack_expect *expect)
111{
112 return nf_ct_expect_related_report(expect, 0, 0);
113}
77ab9cff
MJ
114
115#endif /*_NF_CONNTRACK_EXPECT_H*/
116