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 /* The structure embedded in the conntrack structure. */
86 /* Set to zero when conntrack created: bitmask of maniptypes */
87 u_int16_t initialized
;
91 /* Manipulations to be done on this conntrack. */
92 struct ip_nat_info_manip manips
[IP_NAT_MAX_MANIPS
];
94 struct list_head bysource
, byipsproto
;
96 /* Helper (NULL if none). */
97 struct ip_nat_helper
*helper
;
99 struct ip_nat_seq seq
[IP_CT_DIR_MAX
];
102 /* Set up the info structure to map into this range. */
103 extern unsigned int ip_nat_setup_info(struct ip_conntrack
*conntrack
,
104 const struct ip_nat_multi_range
*mr
,
105 unsigned int hooknum
);
107 /* Is this tuple already taken? (not by us)*/
108 extern int ip_nat_used_tuple(const struct ip_conntrack_tuple
*tuple
,
109 const struct ip_conntrack
*ignored_conntrack
);
111 /* Calculate relative checksum. */
112 extern u_int16_t
ip_nat_cheat_check(u_int32_t oldvalinv
,
115 #endif /*__KERNEL__*/