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
;
13 extern struct hlist_head
*nf_ct_expect_hash
;
15 struct nf_conntrack_expect
{
16 /* Conntrack expectation list member */
17 struct hlist_node lnode
;
20 struct hlist_node hnode
;
22 /* We expect this tuple, with the following mask */
23 struct nf_conntrack_tuple tuple
;
24 struct nf_conntrack_tuple_mask mask
;
26 /* Function to call after setup and insertion */
27 void (*expectfn
)(struct nf_conn
*new,
28 struct nf_conntrack_expect
*this);
30 /* Helper to assign to new connection */
31 struct nf_conntrack_helper
*helper
;
33 /* The conntrack of the master connection */
34 struct nf_conn
*master
;
36 /* Timer function; deletes the expectation. */
37 struct timer_list timeout
;
45 /* Expectation class */
48 #ifdef CONFIG_NF_NAT_NEEDED
49 union nf_inet_addr saved_addr
;
50 /* This is the original per-proto part, used to map the
51 * expected connection the way the recipient expects. */
52 union nf_conntrack_man_proto saved_proto
;
53 /* Direction relative to the master connection. */
54 enum ip_conntrack_dir dir
;
60 static inline struct net
*nf_ct_exp_net(struct nf_conntrack_expect
*exp
)
62 return nf_ct_net(exp
->master
);
65 #define NF_CT_EXP_POLICY_NAME_LEN 16
67 struct nf_conntrack_expect_policy
{
68 unsigned int max_expected
;
70 char name
[NF_CT_EXP_POLICY_NAME_LEN
];
73 #define NF_CT_EXPECT_CLASS_DEFAULT 0
75 int nf_conntrack_expect_pernet_init(struct net
*net
);
76 void nf_conntrack_expect_pernet_fini(struct net
*net
);
78 int nf_conntrack_expect_init(void);
79 void nf_conntrack_expect_fini(void);
81 struct nf_conntrack_expect
*
82 __nf_ct_expect_find(struct net
*net
,
83 const struct nf_conntrack_zone
*zone
,
84 const struct nf_conntrack_tuple
*tuple
);
86 struct nf_conntrack_expect
*
87 nf_ct_expect_find_get(struct net
*net
,
88 const struct nf_conntrack_zone
*zone
,
89 const struct nf_conntrack_tuple
*tuple
);
91 struct nf_conntrack_expect
*
92 nf_ct_find_expectation(struct net
*net
,
93 const struct nf_conntrack_zone
*zone
,
94 const struct nf_conntrack_tuple
*tuple
);
96 void nf_ct_unlink_expect_report(struct nf_conntrack_expect
*exp
,
97 u32 portid
, int report
);
98 static inline void nf_ct_unlink_expect(struct nf_conntrack_expect
*exp
)
100 nf_ct_unlink_expect_report(exp
, 0, 0);
103 void nf_ct_remove_expectations(struct nf_conn
*ct
);
104 void nf_ct_unexpect_related(struct nf_conntrack_expect
*exp
);
106 /* Allocate space for an expectation: this is mandatory before calling
107 nf_ct_expect_related. You will have to call put afterwards. */
108 struct nf_conntrack_expect
*nf_ct_expect_alloc(struct nf_conn
*me
);
109 void nf_ct_expect_init(struct nf_conntrack_expect
*, unsigned int, u_int8_t
,
110 const union nf_inet_addr
*,
111 const union nf_inet_addr
*,
112 u_int8_t
, const __be16
*, const __be16
*);
113 void nf_ct_expect_put(struct nf_conntrack_expect
*exp
);
114 int nf_ct_expect_related_report(struct nf_conntrack_expect
*expect
,
115 u32 portid
, int report
);
116 static inline int nf_ct_expect_related(struct nf_conntrack_expect
*expect
)
118 return nf_ct_expect_related_report(expect
, 0, 0);
121 #endif /*_NF_CONNTRACK_EXPECT_H*/