From ef399a3033aa860ea1653b9c4306c0e78777e981 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Tue, 29 May 2007 11:24:45 +0000 Subject: Add --random option to DNAT and REDIRECT targets and fix the manpage mess this option left behind. --- extensions/libipt_DNAT.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'extensions/libipt_DNAT.c') diff --git a/extensions/libipt_DNAT.c b/extensions/libipt_DNAT.c index 3cf839e6..b0def312 100644 --- a/extensions/libipt_DNAT.c +++ b/extensions/libipt_DNAT.c @@ -8,6 +8,9 @@ #include #include +#define IPT_DNAT_OPT_DEST 0x1 +#define IPT_DNAT_OPT_RANDOM 0x2 + /* Dest NAT data consists of a multi-range, indicating where to map to. */ struct ipt_natinfo @@ -24,12 +27,14 @@ help(void) "DNAT v%s options:\n" " --to-destination [-][:port-port]\n" " Address to map destination to.\n" -" (You can use this more than once)\n\n", +"[--random]\n" +"\n", IPTABLES_VERSION); } static struct option opts[] = { { "to-destination", 1, 0, '1' }, + { "random", 0, 0, '2' }, { 0 } }; @@ -163,9 +168,18 @@ parse(int c, char **argv, int invert, unsigned int *flags, "Multiple --to-destination not supported"); } *target = parse_to(optarg, portok, info); - *flags = 1; + /* WTF do we need this for?? */ + if (*flags & IPT_DNAT_OPT_RANDOM) + info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM; + *flags |= IPT_DNAT_OPT_DEST; return 1; + case '2': + if (*flags & IPT_DNAT_OPT_DEST) { + info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM; + *flags |= IPT_DNAT_OPT_RANDOM; + } else + *flags |= IPT_DNAT_OPT_RANDOM; default: return 0; } @@ -212,6 +226,8 @@ print(const struct ipt_ip *ip, for (i = 0; i < info->mr.rangesize; i++) { print_range(&info->mr.range[i]); printf(" "); + if (info->mr.range[i].flags & IP_NAT_RANGE_PROTO_RANDOM) + printf("random "); } } @@ -226,6 +242,8 @@ save(const struct ipt_ip *ip, const struct ipt_entry_target *target) printf("--to-destination "); print_range(&info->mr.range[i]); printf(" "); + if (info->mr.range[i].flags & IP_NAT_RANGE_PROTO_RANDOM) + printf("--random "); } } -- cgit v1.2.3