Fix DNAT port remapping rules by not emitting 0.0.0.0 in --to-destination
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 21 Mar 2013 14:17:47 +0000 (15:17 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 21 Mar 2013 14:17:47 +0000 (15:17 +0100)
redirects.c

index 43ef65b..4e4f5b2 100644 (file)
@@ -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)
        {