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 43ef65b377573fb2015a93c9467fe44c3a373924..4e4f5b215b12b92aebbf4a99c8dd4f4dd4a47356 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)
        {