Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / include / net / netfilter / nf_nat.h
blob0346b0070864c34c3bf4eaa89ca16a708ad72b88
1 #ifndef _NF_NAT_H
2 #define _NF_NAT_H
3 #include <linux/netfilter_ipv4.h>
4 #include <net/netfilter/nf_conntrack_tuple.h>
6 #define NF_NAT_MAPPING_TYPE_MAX_NAMELEN 16
8 enum nf_nat_manip_type {
9 IP_NAT_MANIP_SRC,
10 IP_NAT_MANIP_DST
13 /* SRC manip occurs POST_ROUTING or LOCAL_IN */
14 #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \
15 (hooknum) != NF_INET_LOCAL_IN)
17 #define IP_NAT_RANGE_MAP_IPS 1
18 #define IP_NAT_RANGE_PROTO_SPECIFIED 2
19 #define IP_NAT_RANGE_PROTO_RANDOM 4
20 #define IP_NAT_RANGE_PERSISTENT 8
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;
27 /* sequence number offset before and after last modification */
28 int16_t offset_before, offset_after;
31 /* Single range specification. */
32 struct nf_nat_range {
33 /* Set to OR of flags above. */
34 unsigned int flags;
36 /* Inclusive: network order. */
37 __be32 min_ip, max_ip;
39 /* Inclusive: network order */
40 union nf_conntrack_man_proto min, max;
43 /* For backwards compat: don't use in modern code. */
44 struct nf_nat_multi_range_compat {
45 unsigned int rangesize; /* Must be 1. */
47 /* hangs off end. */
48 struct nf_nat_range range[1];
51 #include <linux/list.h>
52 #include <linux/netfilter/nf_conntrack_pptp.h>
53 #include <net/netfilter/nf_conntrack_extend.h>
55 /* per conntrack: nat application helper private data */
56 union nf_conntrack_nat_help {
57 /* insert nat helper private data here */
58 #if defined(CONFIG_NF_NAT_PPTP) || defined(CONFIG_NF_NAT_PPTP_MODULE)
59 struct nf_nat_pptp nat_pptp_info;
60 #endif
63 struct nf_conn;
65 /* The structure embedded in the conntrack structure. */
66 struct nf_conn_nat {
67 struct hlist_node bysource;
68 struct nf_nat_seq seq[IP_CT_DIR_MAX];
69 struct nf_conn *ct;
70 union nf_conntrack_nat_help help;
71 #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
72 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE)
73 int masq_index;
74 #endif
77 /* Set up the info structure to map into this range. */
78 extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
79 const struct nf_nat_range *range,
80 enum nf_nat_manip_type maniptype);
82 /* Is this tuple already taken? (not by us)*/
83 extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
84 const struct nf_conn *ignored_conntrack);
86 static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
88 #if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
89 return nf_ct_ext_find(ct, NF_CT_EXT_NAT);
90 #else
91 return NULL;
92 #endif
95 #endif