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