3 #include <linux/netfilter_ipv4.h>
4 #include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
6 #define IP_NAT_MAPPING_TYPE_MAX_NAMELEN 16
14 #ifndef CONFIG_IP_NF_NAT_LOCAL
15 /* SRC manip occurs only on POST_ROUTING */
16 #define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING)
18 /* SRC manip occurs POST_ROUTING or LOCAL_IN */
19 #define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN)
22 #define IP_NAT_RANGE_MAP_IPS 1
23 #define IP_NAT_RANGE_PROTO_SPECIFIED 2
24 /* Used internally by get_unique_tuple(). */
25 #define IP_NAT_RANGE_FULL 4
27 /* NAT sequence number modifications */
29 /* position of the last TCP sequence number
30 * modification (if any) */
31 u_int32_t correction_pos;
32 /* sequence number offset before and after last modification */
33 int32_t offset_before, offset_after;
36 /* Single range specification. */
39 /* Set to OR of flags above. */
42 /* Inclusive: network order. */
43 u_int32_t min_ip, max_ip;
45 /* Inclusive: network order */
46 union ip_conntrack_manip_proto min, max;
49 /* A range consists of an array of 1 or more ip_nat_range */
50 struct ip_nat_multi_range
52 unsigned int rangesize;
55 struct ip_nat_range range[1];
58 /* Worst case: local-out manip + 1 post-routing, and reverse dirn. */
59 #define IP_NAT_MAX_MANIPS (2*3)
61 struct ip_nat_info_manip
66 /* Which hook the manipulation happens on. */
69 /* The manipulation type. */
72 /* Manipulations to occur at each conntrack in this dirn. */
73 struct ip_conntrack_manip manip;
77 #include <linux/list.h>
78 #include <linux/netfilter_ipv4/lockhelp.h>
80 /* Protects NAT hash tables, and NAT-private part of conntracks. */
81 DECLARE_RWLOCK_EXTERN(ip_nat_lock);
83 /* Hashes for by-source and IP/protocol. */
86 struct list_head list;
88 /* conntrack we're embedded in: NULL if not in hash. */
89 struct ip_conntrack *conntrack;
92 /* The structure embedded in the conntrack structure. */
95 /* Set to zero when conntrack created: bitmask of maniptypes */
98 unsigned int num_manips;
100 /* Manipulations to be done on this conntrack. */
101 struct ip_nat_info_manip manips[IP_NAT_MAX_MANIPS];
103 struct ip_nat_hash bysource, byipsproto;
105 /* Helper (NULL if none). */
106 struct ip_nat_helper *helper;
108 struct ip_nat_seq seq[IP_CT_DIR_MAX];
111 /* Set up the info structure to map into this range. */
112 extern unsigned int ip_nat_setup_info(struct ip_conntrack *conntrack,
113 const struct ip_nat_multi_range *mr,
114 unsigned int hooknum);
116 /* Is this tuple already taken? (not by us)*/
117 extern int ip_nat_used_tuple(const struct ip_conntrack_tuple *tuple,
118 const struct ip_conntrack *ignored_conntrack);
120 /* Calculate relative checksum. */
121 extern u_int16_t ip_nat_cheat_check(u_int32_t oldvalinv,
124 #endif /*__KERNEL__*/