]>
Commit | Line | Data |
---|---|---|
5b1158e9 JK |
1 | #ifndef _NF_NAT_H |
2 | #define _NF_NAT_H | |
3 | #include <linux/netfilter_ipv4.h> | |
4 | #include <net/netfilter/nf_conntrack_tuple.h> | |
5 | ||
6 | #define NF_NAT_MAPPING_TYPE_MAX_NAMELEN 16 | |
7 | ||
8 | enum nf_nat_manip_type | |
9 | { | |
10 | IP_NAT_MANIP_SRC, | |
11 | IP_NAT_MANIP_DST | |
12 | }; | |
13 | ||
14 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ | |
6e23ae2a PM |
15 | #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \ |
16 | (hooknum) != NF_INET_LOCAL_IN) | |
5b1158e9 JK |
17 | |
18 | #define IP_NAT_RANGE_MAP_IPS 1 | |
19 | #define IP_NAT_RANGE_PROTO_SPECIFIED 2 | |
41f4689a | 20 | #define IP_NAT_RANGE_PROTO_RANDOM 4 |
5b1158e9 JK |
21 | |
22 | /* NAT sequence number modifications */ | |
23 | struct nf_nat_seq { | |
24 | /* position of the last TCP sequence number modification (if any) */ | |
25 | u_int32_t correction_pos; | |
26 | ||
27 | /* sequence number offset before and after last modification */ | |
28 | int16_t offset_before, offset_after; | |
29 | }; | |
30 | ||
31 | /* Single range specification. */ | |
32 | struct nf_nat_range | |
33 | { | |
34 | /* Set to OR of flags above. */ | |
35 | unsigned int flags; | |
36 | ||
37 | /* Inclusive: network order. */ | |
38 | __be32 min_ip, max_ip; | |
39 | ||
40 | /* Inclusive: network order */ | |
41 | union nf_conntrack_man_proto min, max; | |
42 | }; | |
43 | ||
44 | /* For backwards compat: don't use in modern code. */ | |
45 | struct nf_nat_multi_range_compat | |
46 | { | |
47 | unsigned int rangesize; /* Must be 1. */ | |
48 | ||
49 | /* hangs off end. */ | |
50 | struct nf_nat_range range[1]; | |
51 | }; | |
52 | ||
53 | #ifdef __KERNEL__ | |
54 | #include <linux/list.h> | |
4ba88779 | 55 | #include <linux/netfilter/nf_conntrack_pptp.h> |
2d59e5ca | 56 | #include <net/netfilter/nf_conntrack_extend.h> |
5b1158e9 | 57 | |
4ba88779 YK |
58 | /* per conntrack: nat application helper private data */ |
59 | union nf_conntrack_nat_help | |
60 | { | |
61 | /* insert nat helper private data here */ | |
62 | struct nf_nat_pptp nat_pptp_info; | |
63 | }; | |
64 | ||
b6b84d4a YK |
65 | struct nf_conn; |
66 | ||
67 | /* The structure embedded in the conntrack structure. */ | |
4ba88779 YK |
68 | struct nf_conn_nat |
69 | { | |
53aba597 | 70 | struct hlist_node bysource; |
b6b84d4a YK |
71 | struct nf_nat_seq seq[IP_CT_DIR_MAX]; |
72 | struct nf_conn *ct; | |
4ba88779 YK |
73 | union nf_conntrack_nat_help help; |
74 | #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ | |
75 | defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) | |
76 | int masq_index; | |
77 | #endif | |
78 | }; | |
79 | ||
5b1158e9 JK |
80 | /* Set up the info structure to map into this range. */ |
81 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, | |
82 | const struct nf_nat_range *range, | |
83 | unsigned int hooknum); | |
84 | ||
85 | /* Is this tuple already taken? (not by us)*/ | |
86 | extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, | |
87 | const struct nf_conn *ignored_conntrack); | |
88 | ||
2d59e5ca YK |
89 | static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct) |
90 | { | |
91 | return nf_ct_ext_find(ct, NF_CT_EXT_NAT); | |
92 | } | |
93 | ||
5b1158e9 JK |
94 | #else /* !__KERNEL__: iptables wants this to compile. */ |
95 | #define nf_nat_multi_range nf_nat_multi_range_compat | |
96 | #endif /*__KERNEL__*/ | |
97 | #endif |