2 * connection tracking expectations.
5 #ifndef _NF_CONNTRACK_EXPECT_H
6 #define _NF_CONNTRACK_EXPECT_H
8 #include <linux/refcount.h>
10 #include <net/netfilter/nf_conntrack.h>
11 #include <net/netfilter/nf_conntrack_zones.h>
13 extern unsigned int nf_ct_expect_hsize
;
14 extern unsigned int nf_ct_expect_max
;
15 extern struct hlist_head
*nf_ct_expect_hash
;
17 struct nf_conntrack_expect
{
18 /* Conntrack expectation list member */
19 struct hlist_node lnode
;
22 struct hlist_node hnode
;
24 /* We expect this tuple, with the following mask */
25 struct nf_conntrack_tuple tuple
;
26 struct nf_conntrack_tuple_mask mask
;
28 /* Function to call after setup and insertion */
29 void (*expectfn
)(struct nf_conn
*new,
30 struct nf_conntrack_expect
*this);
32 /* Helper to assign to new connection */
33 struct nf_conntrack_helper
*helper
;
35 /* The conntrack of the master connection */
36 struct nf_conn
*master
;
38 /* Timer function; deletes the expectation. */
39 struct timer_list timeout
;
47 /* Expectation class */
50 #ifdef CONFIG_NF_NAT_NEEDED
51 union nf_inet_addr saved_addr
;
52 /* This is the original per-proto part, used to map the
53 * expected connection the way the recipient expects. */
54 union nf_conntrack_man_proto saved_proto
;
55 /* Direction relative to the master connection. */
56 enum ip_conntrack_dir dir
;
62 static inline struct net
*nf_ct_exp_net(struct nf_conntrack_expect
*exp
)
64 return nf_ct_net(exp
->master
);
67 #define NF_CT_EXP_POLICY_NAME_LEN 16
69 struct nf_conntrack_expect_policy
{
70 unsigned int max_expected
;
72 char name
[NF_CT_EXP_POLICY_NAME_LEN
];
75 #define NF_CT_EXPECT_CLASS_DEFAULT 0
76 #define NF_CT_EXPECT_MAX_CNT 255
78 int nf_conntrack_expect_pernet_init(struct net
*net
);
79 void nf_conntrack_expect_pernet_fini(struct net
*net
);
81 int nf_conntrack_expect_init(void);
82 void nf_conntrack_expect_fini(void);
84 struct nf_conntrack_expect
*
85 __nf_ct_expect_find(struct net
*net
,
86 const struct nf_conntrack_zone
*zone
,
87 const struct nf_conntrack_tuple
*tuple
);
89 struct nf_conntrack_expect
*
90 nf_ct_expect_find_get(struct net
*net
,
91 const struct nf_conntrack_zone
*zone
,
92 const struct nf_conntrack_tuple
*tuple
);
94 struct nf_conntrack_expect
*
95 nf_ct_find_expectation(struct net
*net
,
96 const struct nf_conntrack_zone
*zone
,
97 const struct nf_conntrack_tuple
*tuple
);
99 void nf_ct_unlink_expect_report(struct nf_conntrack_expect
*exp
,
100 u32 portid
, int report
);
101 static inline void nf_ct_unlink_expect(struct nf_conntrack_expect
*exp
)
103 nf_ct_unlink_expect_report(exp
, 0, 0);
106 void nf_ct_remove_expectations(struct nf_conn
*ct
);
107 void nf_ct_unexpect_related(struct nf_conntrack_expect
*exp
);
109 /* Allocate space for an expectation: this is mandatory before calling
110 nf_ct_expect_related. You will have to call put afterwards. */
111 struct nf_conntrack_expect
*nf_ct_expect_alloc(struct nf_conn
*me
);
112 void nf_ct_expect_init(struct nf_conntrack_expect
*, unsigned int, u_int8_t
,
113 const union nf_inet_addr
*,
114 const union nf_inet_addr
*,
115 u_int8_t
, const __be16
*, const __be16
*);
116 void nf_ct_expect_put(struct nf_conntrack_expect
*exp
);
117 int nf_ct_expect_related_report(struct nf_conntrack_expect
*expect
,
118 u32 portid
, int report
);
119 static inline int nf_ct_expect_related(struct nf_conntrack_expect
*expect
)
121 return nf_ct_expect_related_report(expect
, 0, 0);
124 #endif /*_NF_CONNTRACK_EXPECT_H*/