177ab9cffSMartin Josefsson /* 277ab9cffSMartin Josefsson * connection tracking expectations. 377ab9cffSMartin Josefsson */ 477ab9cffSMartin Josefsson 577ab9cffSMartin Josefsson #ifndef _NF_CONNTRACK_EXPECT_H 677ab9cffSMartin Josefsson #define _NF_CONNTRACK_EXPECT_H 777ab9cffSMartin Josefsson #include <net/netfilter/nf_conntrack.h> 877ab9cffSMartin Josefsson 9a71c0855SPatrick McHardy extern struct hlist_head *nf_ct_expect_hash; 10a71c0855SPatrick McHardy extern unsigned int nf_ct_expect_hsize; 11f264a7dfSPatrick McHardy extern unsigned int nf_ct_expect_max; 1277ab9cffSMartin Josefsson 1377ab9cffSMartin Josefsson struct nf_conntrack_expect 1477ab9cffSMartin Josefsson { 15b560580aSPatrick McHardy /* Conntrack expectation list member */ 16b560580aSPatrick McHardy struct hlist_node lnode; 1777ab9cffSMartin Josefsson 18a71c0855SPatrick McHardy /* Hash member */ 19a71c0855SPatrick McHardy struct hlist_node hnode; 20a71c0855SPatrick McHardy 2177ab9cffSMartin Josefsson /* We expect this tuple, with the following mask */ 22d4156e8cSPatrick McHardy struct nf_conntrack_tuple tuple; 23d4156e8cSPatrick McHardy struct nf_conntrack_tuple_mask mask; 2477ab9cffSMartin Josefsson 2577ab9cffSMartin Josefsson /* Function to call after setup and insertion */ 2677ab9cffSMartin Josefsson void (*expectfn)(struct nf_conn *new, 2777ab9cffSMartin Josefsson struct nf_conntrack_expect *this); 2877ab9cffSMartin Josefsson 299457d851SPatrick McHardy /* Helper to assign to new connection */ 309457d851SPatrick McHardy struct nf_conntrack_helper *helper; 319457d851SPatrick McHardy 3277ab9cffSMartin Josefsson /* The conntrack of the master connection */ 3377ab9cffSMartin Josefsson struct nf_conn *master; 3477ab9cffSMartin Josefsson 3577ab9cffSMartin Josefsson /* Timer function; deletes the expectation. */ 3677ab9cffSMartin Josefsson struct timer_list timeout; 3777ab9cffSMartin Josefsson 3877ab9cffSMartin Josefsson /* Usage count. */ 3977ab9cffSMartin Josefsson atomic_t use; 4077ab9cffSMartin Josefsson 4177ab9cffSMartin Josefsson /* Flags */ 4277ab9cffSMartin Josefsson unsigned int flags; 4377ab9cffSMartin Josefsson 4477ab9cffSMartin Josefsson #ifdef CONFIG_NF_NAT_NEEDED 45f587de0eSPatrick McHardy __be32 saved_ip; 4677ab9cffSMartin Josefsson /* This is the original per-proto part, used to map the 4777ab9cffSMartin Josefsson * expected connection the way the recipient expects. */ 485b1158e9SJozsef Kadlecsik union nf_conntrack_man_proto saved_proto; 4977ab9cffSMartin Josefsson /* Direction relative to the master connection. */ 5077ab9cffSMartin Josefsson enum ip_conntrack_dir dir; 5177ab9cffSMartin Josefsson #endif 527d0742daSPatrick McHardy 537d0742daSPatrick McHardy struct rcu_head rcu; 5477ab9cffSMartin Josefsson }; 5577ab9cffSMartin Josefsson 5677ab9cffSMartin Josefsson #define NF_CT_EXPECT_PERMANENT 0x1 5777ab9cffSMartin Josefsson 58e9c1b084SPatrick McHardy int nf_conntrack_expect_init(void); 59e9c1b084SPatrick McHardy void nf_conntrack_expect_fini(void); 6077ab9cffSMartin Josefsson 6177ab9cffSMartin Josefsson struct nf_conntrack_expect * 626823645dSPatrick McHardy __nf_ct_expect_find(const struct nf_conntrack_tuple *tuple); 6377ab9cffSMartin Josefsson 6477ab9cffSMartin Josefsson struct nf_conntrack_expect * 656823645dSPatrick McHardy nf_ct_expect_find_get(const struct nf_conntrack_tuple *tuple); 6677ab9cffSMartin Josefsson 6777ab9cffSMartin Josefsson struct nf_conntrack_expect * 686823645dSPatrick McHardy nf_ct_find_expectation(const struct nf_conntrack_tuple *tuple); 6977ab9cffSMartin Josefsson 7077ab9cffSMartin Josefsson void nf_ct_unlink_expect(struct nf_conntrack_expect *exp); 7177ab9cffSMartin Josefsson void nf_ct_remove_expectations(struct nf_conn *ct); 726823645dSPatrick McHardy void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); 7377ab9cffSMartin Josefsson 7477ab9cffSMartin Josefsson /* Allocate space for an expectation: this is mandatory before calling 756823645dSPatrick McHardy nf_ct_expect_related. You will have to call put afterwards. */ 766823645dSPatrick McHardy struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me); 776823645dSPatrick McHardy void nf_ct_expect_init(struct nf_conntrack_expect *, int, 78643a2c15SJan Engelhardt union nf_inet_addr *, 79643a2c15SJan Engelhardt union nf_inet_addr *, 80d6a9b650SPatrick McHardy u_int8_t, __be16 *, __be16 *); 816823645dSPatrick McHardy void nf_ct_expect_put(struct nf_conntrack_expect *exp); 826823645dSPatrick McHardy int nf_ct_expect_related(struct nf_conntrack_expect *expect); 8377ab9cffSMartin Josefsson 8477ab9cffSMartin Josefsson #endif /*_NF_CONNTRACK_EXPECT_H*/ 8577ab9cffSMartin Josefsson 86