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