From: Jo-Philipp Wich Date: Thu, 21 Mar 2013 14:17:47 +0000 (+0100) Subject: Fix DNAT port remapping rules by not emitting 0.0.0.0 in --to-destination X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cb80885eeb7d45b56651c22a7bec2bfe6a646add;p=oweals%2Ffirewall3.git Fix DNAT port remapping rules by not emitting 0.0.0.0 in --to-destination --- diff --git a/redirects.c b/redirects.c index 43ef65b..4e4f5b2 100644 --- a/redirects.c +++ b/redirects.c @@ -263,17 +263,18 @@ static void print_snat_dnat(enum fw3_flag target, struct fw3_address *addr, struct fw3_port *port) { - const char *t; char s[sizeof("255.255.255.255 ")]; if (target == FW3_FLAG_DNAT) - t = "DNAT --to-destination"; + fw3_pr(" -j DNAT --to-destination "); else - t = "SNAT --to-source"; + fw3_pr(" -j SNAT --to-source "); - inet_ntop(AF_INET, &addr->address.v4, s, sizeof(s)); - - fw3_pr(" -j %s %s", t, s); + if (addr && addr->set) + { + inet_ntop(AF_INET, &addr->address.v4, s, sizeof(s)); + fw3_pr(s); + } if (port && port->set) {