initial commit with v2.6.9
[linux-2.6.9-moxart.git] / include / linux / netfilter_ipv4 / ip_nat.h
blobc4a3622604b75f5b1aac2e26f438bb636837f4a9
1 #ifndef _IP_NAT_H
2 #define _IP_NAT_H
3 #include <linux/netfilter_ipv4.h>
4 #include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
6 #define IP_NAT_MAPPING_TYPE_MAX_NAMELEN 16
8 enum ip_nat_manip_type
10 IP_NAT_MANIP_SRC,
11 IP_NAT_MANIP_DST
14 #ifndef CONFIG_IP_NF_NAT_LOCAL
15 /* SRC manip occurs only on POST_ROUTING */
16 #define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING)
17 #else
18 /* SRC manip occurs POST_ROUTING or LOCAL_IN */
19 #define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN)
20 #endif
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 */
28 struct ip_nat_seq {
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. */
37 struct ip_nat_range
39 /* Set to OR of flags above. */
40 unsigned int flags;
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;
54 /* hangs off end. */
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
63 /* The direction. */
64 u_int8_t direction;
66 /* Which hook the manipulation happens on. */
67 u_int8_t hooknum;
69 /* The manipulation type. */
70 u_int8_t maniptype;
72 /* Manipulations to occur at each conntrack in this dirn. */
73 struct ip_conntrack_manip manip;
76 #ifdef __KERNEL__
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. */
84 struct ip_nat_info
86 /* Set to zero when conntrack created: bitmask of maniptypes */
87 u_int16_t initialized;
89 u_int16_t num_manips;
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,
113 u_int32_t newval,
114 u_int16_t oldcheck);
115 #endif /*__KERNEL__*/
116 #endif