Merge remote-tracking branches 'spi/topic/octeon', 'spi/topic/omap2-mcspi', 'spi...
[deliverable/linux.git] / include / net / netfilter / nf_conntrack_expect.h
1 /*
2 * connection tracking expectations.
3 */
4
5 #ifndef _NF_CONNTRACK_EXPECT_H
6 #define _NF_CONNTRACK_EXPECT_H
7
8 #include <net/netfilter/nf_conntrack.h>
9 #include <net/netfilter/nf_conntrack_zones.h>
10
11 extern unsigned int nf_ct_expect_hsize;
12 extern unsigned int nf_ct_expect_max;
13
14 struct nf_conntrack_expect {
15 /* Conntrack expectation list member */
16 struct hlist_node lnode;
17
18 /* Hash member */
19 struct hlist_node hnode;
20
21 /* We expect this tuple, with the following mask */
22 struct nf_conntrack_tuple tuple;
23 struct nf_conntrack_tuple_mask mask;
24
25 /* Function to call after setup and insertion */
26 void (*expectfn)(struct nf_conn *new,
27 struct nf_conntrack_expect *this);
28
29 /* Helper to assign to new connection */
30 struct nf_conntrack_helper *helper;
31
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
41 /* Flags */
42 unsigned int flags;
43
44 /* Expectation class */
45 unsigned int class;
46
47 #ifdef CONFIG_NF_NAT_NEEDED
48 union nf_inet_addr saved_addr;
49 /* This is the original per-proto part, used to map the
50 * expected connection the way the recipient expects. */
51 union nf_conntrack_man_proto saved_proto;
52 /* Direction relative to the master connection. */
53 enum ip_conntrack_dir dir;
54 #endif
55
56 struct rcu_head rcu;
57 };
58
59 static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
60 {
61 return nf_ct_net(exp->master);
62 }
63
64 #define NF_CT_EXP_POLICY_NAME_LEN 16
65
66 struct nf_conntrack_expect_policy {
67 unsigned int max_expected;
68 unsigned int timeout;
69 char name[NF_CT_EXP_POLICY_NAME_LEN];
70 };
71
72 #define NF_CT_EXPECT_CLASS_DEFAULT 0
73
74 int nf_conntrack_expect_pernet_init(struct net *net);
75 void nf_conntrack_expect_pernet_fini(struct net *net);
76
77 int nf_conntrack_expect_init(void);
78 void nf_conntrack_expect_fini(void);
79
80 struct nf_conntrack_expect *
81 __nf_ct_expect_find(struct net *net,
82 const struct nf_conntrack_zone *zone,
83 const struct nf_conntrack_tuple *tuple);
84
85 struct nf_conntrack_expect *
86 nf_ct_expect_find_get(struct net *net,
87 const struct nf_conntrack_zone *zone,
88 const struct nf_conntrack_tuple *tuple);
89
90 struct nf_conntrack_expect *
91 nf_ct_find_expectation(struct net *net,
92 const struct nf_conntrack_zone *zone,
93 const struct nf_conntrack_tuple *tuple);
94
95 void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,
96 u32 portid, int report);
97 static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp)
98 {
99 nf_ct_unlink_expect_report(exp, 0, 0);
100 }
101
102 void nf_ct_remove_expectations(struct nf_conn *ct);
103 void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
104
105 /* Allocate space for an expectation: this is mandatory before calling
106 nf_ct_expect_related. You will have to call put afterwards. */
107 struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me);
108 void nf_ct_expect_init(struct nf_conntrack_expect *, unsigned int, u_int8_t,
109 const union nf_inet_addr *,
110 const union nf_inet_addr *,
111 u_int8_t, const __be16 *, const __be16 *);
112 void nf_ct_expect_put(struct nf_conntrack_expect *exp);
113 int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
114 u32 portid, int report);
115 static inline int nf_ct_expect_related(struct nf_conntrack_expect *expect)
116 {
117 return nf_ct_expect_related_report(expect, 0, 0);
118 }
119
120 #endif /*_NF_CONNTRACK_EXPECT_H*/
121
This page took 0.034911 seconds and 5 git commands to generate.