summaryrefslogtreecommitdiffstats
path: root/extensions/libip6t_SNPT.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@inai.de>2013-01-24 09:37:55 +0000
committerPablo Neira Ayuso <pablo@netfilter.org>2013-01-28 12:32:03 +0100
commit2fda8fcef0f3c321fb03953b8ecc424a2bad4476 (patch)
tree1df63a3ed72be55e0ce821a41b8f711f3091da12 /extensions/libip6t_SNPT.c
parentff338552d318b49e07662fd7648fdb11e3c42bc9 (diff)
extensions: S/DNPT: add missing save function
Jean-Michel DILLY reports that `ip6tables -S` exits with Target `DNPT' is missing save function when a DNPT rule is invoked. Fix this omission. References: http://marc.info/?l=netfilter&m=135904831220440&w=2 Signed-off-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'extensions/libip6t_SNPT.c')
-rw-r--r--extensions/libip6t_SNPT.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/extensions/libip6t_SNPT.c b/extensions/libip6t_SNPT.c
index 26a86c56..7ed80b20 100644
--- a/extensions/libip6t_SNPT.c
+++ b/extensions/libip6t_SNPT.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <string.h>
#include <xtables.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
#include <linux/netfilter_ipv6/ip6t_NPT.h>
@@ -53,6 +54,23 @@ static void SNPT_print(const void *ip, const struct xt_entry_target *target,
npt->dst_pfx_len);
}
+static void SNPT_save(const void *ip, const struct xt_entry_target *target)
+{
+ static const struct in6_addr zero_addr;
+ const struct ip6t_npt_tginfo *info = (const void *)target->data;
+
+ if (memcmp(&info->src_pfx.in6, &zero_addr, sizeof(zero_addr)) != 0 ||
+ info->src_pfx_len != 0)
+ printf("--src-pfx %s/%u ",
+ xtables_ip6addr_to_numeric(&info->src_pfx.in6),
+ info->src_pfx_len);
+ if (memcmp(&info->dst_pfx.in6, &zero_addr, sizeof(zero_addr)) != 0 ||
+ info->dst_pfx_len != 0)
+ printf("--dst-pfx %s/%u ",
+ xtables_ip6addr_to_numeric(&info->dst_pfx.in6),
+ info->dst_pfx_len);
+}
+
static struct xtables_target snpt_tg_reg = {
.name = "SNPT",
.version = XTABLES_VERSION,
@@ -62,6 +80,7 @@ static struct xtables_target snpt_tg_reg = {
.help = SNPT_help,
.x6_parse = SNPT_parse,
.print = SNPT_print,
+ .save = SNPT_save,
.x6_options = SNPT_options,
};