netfilter: nf_conntrack: make sequence number adjustments usuable without NAT
[linux-2.6/btrfs-unstable.git] / include / net / netfilter / nf_nat.h
blob59a1924200536b9fc5847998b7129c8aefeb7060
1 #ifndef _NF_NAT_H
2 #define _NF_NAT_H
3 #include <linux/netfilter_ipv4.h>
4 #include <linux/netfilter/nf_nat.h>
5 #include <net/netfilter/nf_conntrack_tuple.h>
7 enum nf_nat_manip_type {
8 NF_NAT_MANIP_SRC,
9 NF_NAT_MANIP_DST
12 /* SRC manip occurs POST_ROUTING or LOCAL_IN */
13 #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \
14 (hooknum) != NF_INET_LOCAL_IN)
16 #include <linux/list.h>
17 #include <linux/netfilter/nf_conntrack_pptp.h>
18 #include <net/netfilter/nf_conntrack_extend.h>
20 /* per conntrack: nat application helper private data */
21 union nf_conntrack_nat_help {
22 /* insert nat helper private data here */
23 #if defined(CONFIG_NF_NAT_PPTP) || defined(CONFIG_NF_NAT_PPTP_MODULE)
24 struct nf_nat_pptp nat_pptp_info;
25 #endif
28 struct nf_conn;
30 /* The structure embedded in the conntrack structure. */
31 struct nf_conn_nat {
32 struct hlist_node bysource;
33 struct nf_conn *ct;
34 union nf_conntrack_nat_help help;
35 #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
36 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) || \
37 defined(CONFIG_IP6_NF_TARGET_MASQUERADE) || \
38 defined(CONFIG_IP6_NF_TARGET_MASQUERADE_MODULE)
39 int masq_index;
40 #endif
43 /* Set up the info structure to map into this range. */
44 extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
45 const struct nf_nat_range *range,
46 enum nf_nat_manip_type maniptype);
48 /* Is this tuple already taken? (not by us)*/
49 extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
50 const struct nf_conn *ignored_conntrack);
52 static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
54 #if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
55 return nf_ct_ext_find(ct, NF_CT_EXT_NAT);
56 #else
57 return NULL;
58 #endif
61 static inline bool nf_nat_oif_changed(unsigned int hooknum,
62 enum ip_conntrack_info ctinfo,
63 struct nf_conn_nat *nat,
64 const struct net_device *out)
66 #if IS_ENABLED(CONFIG_IP_NF_TARGET_MASQUERADE) || \
67 IS_ENABLED(CONFIG_IP6_NF_TARGET_MASQUERADE)
68 return nat->masq_index && hooknum == NF_INET_POST_ROUTING &&
69 CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL &&
70 nat->masq_index != out->ifindex;
71 #else
72 return false;
73 #endif
76 #endif