Commit | Line | Data |
---|---|---|
5b1158e9 JK |
1 | #ifndef _NF_NAT_H |
2 | #define _NF_NAT_H | |
3 | #include <linux/netfilter_ipv4.h> | |
cbc9f2f4 | 4 | #include <linux/netfilter/nf_nat.h> |
5b1158e9 JK |
5 | #include <net/netfilter/nf_conntrack_tuple.h> |
6 | ||
fd2c3ef7 | 7 | enum nf_nat_manip_type { |
cbc9f2f4 PM |
8 | NF_NAT_MANIP_SRC, |
9 | NF_NAT_MANIP_DST | |
5b1158e9 JK |
10 | }; |
11 | ||
12 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ | |
6e23ae2a PM |
13 | #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \ |
14 | (hooknum) != NF_INET_LOCAL_IN) | |
5b1158e9 | 15 | |
5b1158e9 JK |
16 | /* NAT sequence number modifications */ |
17 | struct nf_nat_seq { | |
18 | /* position of the last TCP sequence number modification (if any) */ | |
19 | u_int32_t correction_pos; | |
20 | ||
21 | /* sequence number offset before and after last modification */ | |
22 | int16_t offset_before, offset_after; | |
23 | }; | |
24 | ||
5b1158e9 | 25 | #include <linux/list.h> |
4ba88779 | 26 | #include <linux/netfilter/nf_conntrack_pptp.h> |
2d59e5ca | 27 | #include <net/netfilter/nf_conntrack_extend.h> |
5b1158e9 | 28 | |
4ba88779 | 29 | /* per conntrack: nat application helper private data */ |
fd2c3ef7 | 30 | union nf_conntrack_nat_help { |
4ba88779 | 31 | /* insert nat helper private data here */ |
03c0e5bb | 32 | #if defined(CONFIG_NF_NAT_PPTP) || defined(CONFIG_NF_NAT_PPTP_MODULE) |
4ba88779 | 33 | struct nf_nat_pptp nat_pptp_info; |
03c0e5bb | 34 | #endif |
4ba88779 YK |
35 | }; |
36 | ||
b6b84d4a YK |
37 | struct nf_conn; |
38 | ||
39 | /* The structure embedded in the conntrack structure. */ | |
fd2c3ef7 | 40 | struct nf_conn_nat { |
53aba597 | 41 | struct hlist_node bysource; |
b6b84d4a YK |
42 | struct nf_nat_seq seq[IP_CT_DIR_MAX]; |
43 | struct nf_conn *ct; | |
4ba88779 YK |
44 | union nf_conntrack_nat_help help; |
45 | #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ | |
46 | defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) | |
47 | int masq_index; | |
48 | #endif | |
49 | }; | |
50 | ||
5b1158e9 JK |
51 | /* Set up the info structure to map into this range. */ |
52 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, | |
cbc9f2f4 | 53 | const struct nf_nat_ipv4_range *range, |
cc01dcbd | 54 | enum nf_nat_manip_type maniptype); |
5b1158e9 JK |
55 | |
56 | /* Is this tuple already taken? (not by us)*/ | |
57 | extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, | |
58 | const struct nf_conn *ignored_conntrack); | |
59 | ||
2d59e5ca YK |
60 | static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct) |
61 | { | |
e0e76c83 | 62 | #if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE) |
2d59e5ca | 63 | return nf_ct_ext_find(ct, NF_CT_EXT_NAT); |
e0e76c83 CG |
64 | #else |
65 | return NULL; | |
66 | #endif | |
2d59e5ca YK |
67 | } |
68 | ||
5b1158e9 | 69 | #endif |