aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/netfilter/nf_nat_proto_common.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-04-14 05:15:47 -0400
committerPatrick McHardy <kaber@trash.net>2008-04-14 05:15:47 -0400
commit535b57c7c1524125444aa1b874332f6ff1608ef5 (patch)
treec127d9bce1b29158343447967c50edd51e357890 /net/ipv4/netfilter/nf_nat_proto_common.c
parent5abd363f738dcd048ee790fb9b84d0768a8a407f (diff)
[NETFILTER]: nf_nat: move NAT ctnetlink helpers to nf_nat_proto_common
Move to nf_nat_proto_common and rename to nf_nat_proto_... since they're also used by protocols that don't have port numbers. Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/ipv4/netfilter/nf_nat_proto_common.c')
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_common.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c
index 871ab0eb325..ef4dc398892 100644
--- a/net/ipv4/netfilter/nf_nat_proto_common.c
+++ b/net/ipv4/netfilter/nf_nat_proto_common.c
@@ -88,3 +88,41 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
88 return 0; 88 return 0;
89} 89}
90EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple); 90EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple);
91
92#if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
93int nf_nat_proto_range_to_nlattr(struct sk_buff *skb,
94 const struct nf_nat_range *range)
95{
96 NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MIN, range->min.all);
97 NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MAX, range->max.all);
98 return 0;
99
100nla_put_failure:
101 return -1;
102}
103EXPORT_SYMBOL_GPL(nf_nat_proto_nlattr_to_range);
104
105int nf_nat_proto_nlattr_to_range(struct nlattr *tb[],
106 struct nf_nat_range *range)
107{
108 int ret = 0;
109
110 /* we have to return whether we actually parsed something or not */
111
112 if (tb[CTA_PROTONAT_PORT_MIN]) {
113 ret = 1;
114 range->min.all = nla_get_be16(tb[CTA_PROTONAT_PORT_MIN]);
115 }
116
117 if (!tb[CTA_PROTONAT_PORT_MAX]) {
118 if (ret)
119 range->max.all = range->min.all;
120 } else {
121 ret = 1;
122 range->max.all = nla_get_be16(tb[CTA_PROTONAT_PORT_MAX]);
123 }
124
125 return ret;
126}
127EXPORT_SYMBOL_GPL(nf_nat_proto_range_to_nlattr);
128#endif