2 * connection tracking expectations.
5 #ifndef _NF_CONNTRACK_EXPECT_H
6 #define _NF_CONNTRACK_EXPECT_H
8 #include <net/netfilter/nf_conntrack.h>
9 #include <net/netfilter/nf_conntrack_zones.h>
11 extern unsigned int nf_ct_expect_hsize
;
12 extern unsigned int nf_ct_expect_max
;
14 struct nf_conntrack_expect
{
15 /* Conntrack expectation list member */
16 struct hlist_node lnode
;
19 struct hlist_node hnode
;
21 /* We expect this tuple, with the following mask */
22 struct nf_conntrack_tuple tuple
;
23 struct nf_conntrack_tuple_mask mask
;
25 /* Function to call after setup and insertion */
26 void (*expectfn
)(struct nf_conn
*new,
27 struct nf_conntrack_expect
*this);
29 /* Helper to assign to new connection */
30 struct nf_conntrack_helper
*helper
;
32 /* The conntrack of the master connection */
33 struct nf_conn
*master
;
35 /* Timer function; deletes the expectation. */
36 struct timer_list timeout
;
44 /* Expectation class */
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
;
59 static inline struct net
*nf_ct_exp_net(struct nf_conntrack_expect
*exp
)
61 return nf_ct_net(exp
->master
);
64 #define NF_CT_EXP_POLICY_NAME_LEN 16
66 struct nf_conntrack_expect_policy
{
67 unsigned int max_expected
;
69 char name
[NF_CT_EXP_POLICY_NAME_LEN
];
72 #define NF_CT_EXPECT_CLASS_DEFAULT 0
74 int nf_conntrack_expect_pernet_init(struct net
*net
);
75 void nf_conntrack_expect_pernet_fini(struct net
*net
);
77 int nf_conntrack_expect_init(void);
78 void nf_conntrack_expect_fini(void);
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
);
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
);
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
);
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
)
99 nf_ct_unlink_expect_report(exp
, 0, 0);
102 void nf_ct_remove_expectations(struct nf_conn
*ct
);
103 void nf_ct_unexpect_related(struct nf_conntrack_expect
*exp
);
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
)
117 return nf_ct_expect_related_report(expect
, 0, 0);
120 #endif /*_NF_CONNTRACK_EXPECT_H*/