]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
extensions: make print (iptables -L) output the same as save (-S)
authorJan Engelhardt <jengelh@inai.de>
Thu, 30 May 2013 15:16:56 +0000 (17:16 +0200)
committerJan Engelhardt <jengelh@inai.de>
Thu, 30 May 2013 15:16:56 +0000 (17:16 +0200)
21 files changed:
doc/changelog.txt
extensions/libxt_CHAOS.c
extensions/libxt_DHCPMAC.c
extensions/libxt_DNETMAP.c
extensions/libxt_IPMARK.c
extensions/libxt_LOGMARK.c
extensions/libxt_RAWDNAT.c
extensions/libxt_RAWSNAT.c
extensions/libxt_TARPIT.c
extensions/libxt_condition.c
extensions/libxt_dhcpmac.c
extensions/libxt_fuzzy.c
extensions/libxt_geoip.c
extensions/libxt_gradm.c
extensions/libxt_iface.c
extensions/libxt_ipp2p.c
extensions/libxt_ipv4options.c
extensions/libxt_length2.c
extensions/libxt_lscan.c
extensions/libxt_psd.c
extensions/libxt_quota2.c

index 46aba4fb2e7ecc70c615b4bc89ae61661125d8b2..cbec097d308f30ca7eb16d7865d0487b2446844b 100644 (file)
@@ -5,6 +5,8 @@ Fixes:
 - xt_RAWNAT: ensure correct operation in the presence of IPv4 options
 - xt_geoip: do not throw a warnings when country database is size 0
 - xt_quota2: print "!" at the correct position during iptables-save
+Changes:
+- Make print (iptables -L) output the same as save (-S)
 
 
 v2.2 (2013-03-31)
index 17fb22c8e3cada3d7a1a4d6d29645fa6eb9d9578..1ed2c4f1db6634c4eaca0834c7a12f94f055b1d1 100644 (file)
@@ -64,21 +64,6 @@ static void chaos_tg_check(unsigned int flags)
                           "may be specified");
 }
 
-static void chaos_tg_print(const void *ip,
-    const struct xt_entry_target *target, int numeric)
-{
-       const struct xt_chaos_tginfo *info = (const void *)target->data;
-
-       switch (info->variant) {
-       case XTCHAOS_DELUDE:
-               printf(" DELUDE ");
-               break;
-       case XTCHAOS_TARPIT:
-               printf(" TARPIT ");
-               break;
-       }
-}
-
 static void chaos_tg_save(const void *ip, const struct xt_entry_target *target)
 {
        const struct xt_chaos_tginfo *info = (const void *)target->data;
@@ -93,6 +78,13 @@ static void chaos_tg_save(const void *ip, const struct xt_entry_target *target)
        }
 }
 
+static void chaos_tg_print(const void *ip,
+    const struct xt_entry_target *target, int numeric)
+{
+       printf(" -j CHAOS");
+       chaos_tg_save(ip, target);
+}
+
 static struct xtables_target chaos_tg_reg = {
        .version       = XTABLES_VERSION,
        .name          = "CHAOS",
index c81961d2753a418c820cafed39a09214b83f155c..e19fb3d8738d16d43d9d0bcbedd3daad7d98d889 100644 (file)
@@ -61,15 +61,6 @@ static void dhcpmac_tg_check(unsigned int flags)
                           "--set-mac parameter required");
 }
 
-static void dhcpmac_tg_print(const void *ip,
-    const struct xt_entry_target *target, int numeric)
-{
-       const struct dhcpmac_info *info = (void *)target->data;
-
-       printf(" DHCPMAC %s" DH_MAC_FMT "/%u ",
-              info->invert ? "!" : "", DH_MAC_HEX(info->addr), info->mask);
-}
-
 static void dhcpmac_tg_save(const void *ip,
     const struct xt_entry_target *target)
 {
@@ -81,6 +72,13 @@ static void dhcpmac_tg_save(const void *ip,
               DH_MAC_HEX(info->addr), info->mask);
 }
 
+static void dhcpmac_tg_print(const void *ip,
+    const struct xt_entry_target *target, int numeric)
+{
+       printf(" -j DHCPMAC");
+       dhcpmac_tg_save(ip, target);
+}
+
 static struct xtables_target dhcpmac_tg_reg = {
        .version       = XTABLES_VERSION,
        .name          = "DHCPMAC",
index 92c679b3f6e48a0a1d711af8e30bc588e73712fa..24a101c3d3c4c6e4be2d3c7b34443ba6dc0d77cb 100644 (file)
@@ -195,33 +195,6 @@ static void DNETMAP_print_addr(const void *ip,
                printf("/%d", bits);
 }
 
-static void DNETMAP_print(const void *ip, const struct xt_entry_target *target,
-                         int numeric)
-{
-       struct xt_DNETMAP_tginfo *tginfo = (void *)&target->data;
-       const __u8 *flags = &tginfo->flags;
-
-       printf(" prefix ");
-       if (*flags & XT_DNETMAP_PREFIX)
-               DNETMAP_print_addr(ip, target, numeric);
-       else
-               printf("any");
-
-       if (*flags & XT_DNETMAP_REUSE)
-               printf(" reuse");
-
-       if (*flags & XT_DNETMAP_STATIC)
-               printf(" static");
-
-       if (*flags & XT_DNETMAP_PERSISTENT)
-               printf(" persistent");
-
-       if (*flags & XT_DNETMAP_TTL)
-               printf(" ttl %i", tginfo->ttl);
-       else
-               printf(" ttl default");
-}
-
 static void DNETMAP_save(const void *ip, const struct xt_entry_target *target)
 {
        struct xt_DNETMAP_tginfo *tginfo = (void *)&target->data;
@@ -246,6 +219,13 @@ static void DNETMAP_save(const void *ip, const struct xt_entry_target *target)
                printf(" --ttl %i ", tginfo->ttl);
 }
 
+static void DNETMAP_print(const void *ip, const struct xt_entry_target *target,
+                         int numeric)
+{
+       printf(" -j DNETMAP");
+       DNETMAP_save(ip, target);
+}
+
 static struct xtables_target dnetmap_tg_reg = {
        .name          = MODULENAME,
        .version       = XTABLES_VERSION,
index 2432e0defc8798286ad3a772b07a6b4f773fe49c..f5d491fc3a6e63489ca617e1b7e645269b9c20ea 100644 (file)
@@ -112,25 +112,6 @@ static void ipmark_tg_check(unsigned int flags)
                           "IPMARK target: Parameter --addr is required");
 }
 
-static void
-ipmark_tg_print(const void *entry, const struct xt_entry_target *target,
-                int numeric)
-{
-       const struct xt_ipmark_tginfo *info = (const void *)target->data;
-
-       if (info->selector == XT_IPMARK_SRC)
-               printf(" IPMARK src ip ");
-       else
-               printf(" IPMARK dst ip ");
-
-       if (info->shift != 0)
-               printf(" shift %u ", (unsigned int)info->shift);
-       if (info->andmask != ~0U)
-               printf(" and 0x%x ", (unsigned int)info->andmask);
-       if (info->ormask != 0)
-               printf(" or 0x%x ", (unsigned int)info->ormask);
-}
-
 static void
 ipmark_tg_save(const void *entry, const struct xt_entry_target *target)
 {
@@ -149,6 +130,14 @@ ipmark_tg_save(const void *entry, const struct xt_entry_target *target)
                printf(" --or-mask 0x%x ", (unsigned int)info->ormask);
 }
 
+static void
+ipmark_tg_print(const void *entry, const struct xt_entry_target *target,
+                int numeric)
+{
+       printf(" -j IPMARK");
+       ipmark_tg_save(entry, target);
+}
+
 static struct xtables_target ipmark_tg_reg = {
        .version       = XTABLES_VERSION,
        .name          = "IPMARK",
index 955e1d87530352f9f8d47f35a1592af4577fad0d..1d8b6b31a1c5dc4d2ed94d4d988385349983ce00 100644 (file)
@@ -77,15 +77,6 @@ logmark_tg_parse(int c, char **argv, int invert, unsigned int *flags,
        return false;
 }
 
-static void
-logmark_tg_print(const void *ip, const struct xt_entry_target *target,
-                 int numeric)
-{
-       const struct xt_logmark_tginfo *info = (void *)target->data;
-
-       printf(" LOGMARK level %u prefix \"%s\" ", info->level, info->prefix);
-}
-
 static void
 logmark_tg_save(const void *ip, const struct xt_entry_target *target)
 {
@@ -97,6 +88,14 @@ logmark_tg_save(const void *ip, const struct xt_entry_target *target)
                printf(" --log-prefix \"%s\" ", info->prefix);
 }
 
+static void
+logmark_tg_print(const void *ip, const struct xt_entry_target *target,
+                 int numeric)
+{
+       printf(" -j LOGMARK");
+       logmark_tg_save(ip, target);
+}
+
 static struct xtables_target logmark_tg_reg = {
        .version       = XTABLES_VERSION,
        .name          = "LOGMARK",
index 243eef35c85302494ff1b9dbf254adf31b8bad5e..4285baed74fe1dcc27615f600439537d87882754 100644 (file)
@@ -104,51 +104,39 @@ static void rawdnat_tg_check(unsigned int flags)
 }
 
 static void
-rawdnat_tg4_print(const void *entry, const struct xt_entry_target *target,
-                  int numeric)
+rawdnat_tg4_save(const void *entry, const struct xt_entry_target *target)
 {
        const struct xt_rawnat_tginfo *info = (const void *)target->data;
 
-       if (!numeric && info->mask == 32)
-               printf(" to-destination %s ",
-                      xtables_ipaddr_to_anyname(&info->addr.in));
-       else
-               printf(" to-destination %s/%u ",
-                      xtables_ipaddr_to_numeric(&info->addr.in), info->mask);
+       printf(" --to-destination %s/%u ",
+              xtables_ipaddr_to_numeric(&info->addr.in),
+              info->mask);
 }
 
 static void
-rawdnat_tg6_print(const void *entry, const struct xt_entry_target *target,
+rawdnat_tg4_print(const void *entry, const struct xt_entry_target *target,
                   int numeric)
 {
-       const struct xt_rawnat_tginfo *info = (const void *)target->data;
-
-       if (!numeric && info->mask == 128)
-               printf(" to-destination %s ",
-                      xtables_ip6addr_to_anyname(&info->addr.in6));
-       else
-               printf(" to-destination %s/%u ",
-                      xtables_ip6addr_to_numeric(&info->addr.in6), info->mask);
+       printf(" -j RAWDNAT");
+       rawdnat_tg4_save(entry, target);
 }
 
 static void
-rawdnat_tg4_save(const void *entry, const struct xt_entry_target *target)
+rawdnat_tg6_save(const void *entry, const struct xt_entry_target *target)
 {
        const struct xt_rawnat_tginfo *info = (const void *)target->data;
 
        printf(" --to-destination %s/%u ",
-              xtables_ipaddr_to_numeric(&info->addr.in),
+              xtables_ip6addr_to_numeric(&info->addr.in6),
               info->mask);
 }
 
 static void
-rawdnat_tg6_save(const void *entry, const struct xt_entry_target *target)
+rawdnat_tg6_print(const void *entry, const struct xt_entry_target *target,
+                  int numeric)
 {
-       const struct xt_rawnat_tginfo *info = (const void *)target->data;
-
-       printf(" --to-destination %s/%u ",
-              xtables_ip6addr_to_numeric(&info->addr.in6),
-              info->mask);
+       printf(" -j RAWDNAT");
+       rawdnat_tg6_save(entry, target);
 }
 
 static struct xtables_target rawdnat_tg_reg[] = {
index efcd9f038798e00306fe40fce69dc030f908962b..1a64a97034cbaa4cc8ca2d248fbfad9505b6bece 100644 (file)
@@ -103,34 +103,6 @@ static void rawsnat_tg_check(unsigned int flags)
                        "\"--to-source\" is required.");
 }
 
-static void
-rawsnat_tg4_print(const void *entry, const struct xt_entry_target *target,
-                  int numeric)
-{
-       const struct xt_rawnat_tginfo *info = (const void *)target->data;
-
-       if (!numeric && info->mask == 32)
-               printf(" to-source %s ",
-                      xtables_ipaddr_to_anyname(&info->addr.in));
-       else
-               printf(" to-source %s/%u ",
-                      xtables_ipaddr_to_numeric(&info->addr.in), info->mask);
-}
-
-static void
-rawsnat_tg6_print(const void *entry, const struct xt_entry_target *target,
-                  int numeric)
-{
-       const struct xt_rawnat_tginfo *info = (const void *)target->data;
-
-       if (!numeric && info->mask == 128)
-               printf(" to-source %s ",
-                      xtables_ip6addr_to_anyname(&info->addr.in6));
-       else
-               printf(" to-source %s/%u ",
-                      xtables_ip6addr_to_numeric(&info->addr.in6), info->mask);
-}
-
 static void
 rawsnat_tg4_save(const void *entry, const struct xt_entry_target *target)
 {
@@ -151,6 +123,22 @@ rawsnat_tg6_save(const void *entry, const struct xt_entry_target *target)
               info->mask);
 }
 
+static void
+rawsnat_tg4_print(const void *entry, const struct xt_entry_target *target,
+                  int numeric)
+{
+       printf(" -j RAWSNAT");
+       rawsnat_tg4_save(entry, target);
+}
+
+static void
+rawsnat_tg6_print(const void *entry, const struct xt_entry_target *target,
+                  int numeric)
+{
+       printf(" -j RAWSNAT");
+       rawsnat_tg6_save(entry, target);
+}
+
 static struct xtables_target rawsnat_tg_reg[] = {
        {
                .version       = XTABLES_VERSION,
index 6b65b09c8061e21fc5a78302f28128468329eaf3..bd853690291a775359c625977dbe179d8fabd01e 100644 (file)
@@ -67,24 +67,6 @@ static void tarpit_tg_check(unsigned int flags)
                        "TARPIT: only one action can be used at a time");
 }
 
-static void tarpit_tg_print(const void *ip,
-    const struct xt_entry_target *target, int numeric)
-{
-       const struct xt_tarpit_tginfo *info = (void *)target->data;
-
-       switch (info->variant) {
-       case XTTARPIT_HONEYPOT:
-               printf(" honeypot mode ");
-               break;
-       case XTTARPIT_RESET:
-               printf(" reset mode ");
-               break;
-       default:
-               printf(" tarpit mode ");
-               break;
-       }
-}
-
 static void tarpit_tg_save(const void *ip,
     const struct xt_entry_target *target)
 {
@@ -103,6 +85,13 @@ static void tarpit_tg_save(const void *ip,
        }
 }
 
+static void tarpit_tg_print(const void *ip,
+    const struct xt_entry_target *target, int numeric)
+{
+       printf(" -j TARPIT");
+       tarpit_tg_save(ip, target);
+}
+
 static struct xtables_target tarpit_tg_reg = {
        .version       = XTABLES_VERSION,
        .name          = "TARPIT",
index 58dcc3da44d88cfc31da373d98648592deeaaa32..6e9ad29828c050a662b1a63e47980cac46dbec48 100644 (file)
@@ -62,20 +62,18 @@ static void condition_check(unsigned int flags)
                           "Condition match: must specify --condition");
 }
 
-static void condition_print(const void *ip, const struct xt_entry_match *match,
-                            int numeric)
+static void condition_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_condition_mtinfo *info = (const void *)match->data;
 
-       printf(" condition %s%s ", (info->invert) ? "!" : "", info->name);
+       printf("%s --condition \"%s\" ", info->invert ? " !" : "", info->name);
 }
 
-
-static void condition_save(const void *ip, const struct xt_entry_match *match)
+static void condition_print(const void *ip, const struct xt_entry_match *match,
+                            int numeric)
 {
-       const struct xt_condition_mtinfo *info = (const void *)match->data;
-
-       printf("%s --condition \"%s\" ", info->invert ? " !" : "", info->name);
+       printf(" -m condition");
+       condition_save(ip, match);
 }
 
 static struct xtables_match condition_mt_reg = {
index 6f35627e8226b05e620a1c0979349eca3e0d38d7..10138d6c86c1abeae5a6ea187674e1e20440a864 100644 (file)
@@ -62,15 +62,6 @@ static void dhcpmac_mt_check(unsigned int flags)
                           "--mac parameter required");
 }
 
-static void dhcpmac_mt_print(const void *ip,
-    const struct xt_entry_match *match, int numeric)
-{
-       const struct dhcpmac_info *info = (void *)match->data;
-
-       printf(" dhcpmac %s" DH_MAC_FMT "/%u ",
-              info->invert ? "!" : "", DH_MAC_HEX(info->addr), info->mask);
-}
-
 static void dhcpmac_mt_save(const void *ip,
     const struct xt_entry_match *match)
 {
@@ -82,6 +73,13 @@ static void dhcpmac_mt_save(const void *ip,
               DH_MAC_HEX(info->addr), info->mask);
 }
 
+static void dhcpmac_mt_print(const void *ip,
+    const struct xt_entry_match *match, int numeric)
+{
+       printf(" -m dhcpmac");
+       dhcpmac_mt_save(ip, match);
+}
+
 static struct xtables_match dhcpmac_mt_reg = {
        .version       = XTABLES_VERSION,
        .name          = "dhcpmac",
index 0a0dfcc1b914bc20a56e3eb46bbae55acb91261b..35a6e9288097fa03b467305db96e0c814a6e35c3 100644 (file)
@@ -83,15 +83,6 @@ static void fuzzy_mt_check(unsigned int flags)
 {
 }
 
-static void fuzzy_mt_print(const void *ip, const struct xt_entry_match *match,
-                           int numeric)
-{
-       const struct xt_fuzzy_mtinfo *info = (const void *)match->data;
-
-       printf(" fuzzy: lower limit = %u pps - upper limit = %u pps ",
-              info->minimum_rate, info->maximum_rate);
-}
-
 static void fuzzy_mt_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_fuzzy_mtinfo *info = (const void *)match->data;
@@ -100,6 +91,13 @@ static void fuzzy_mt_save(const void *ip, const struct xt_entry_match *match)
        printf(" --upper-limit %u ", info->maximum_rate);
 }
 
+static void fuzzy_mt_print(const void *ip, const struct xt_entry_match *match,
+                           int numeric)
+{
+       printf(" -m fuzzy");
+       fuzzy_mt_save(ip, match);
+}
+
 static struct xtables_match fuzzy_mt_reg = {
        .name          = "fuzzy",
        .revision      = 1,
index a25418143616b9636fdd19986d79ae41c15dfcd2..ecc78014a097bc352560bd62aa6a2066e34619f3 100644 (file)
@@ -251,31 +251,6 @@ geoip_final_check(unsigned int flags)
                        "geoip: missing arguments");
 }
 
-static void
-geoip_print(const void *ip, const struct xt_entry_match *match, int numeric)
-{
-       const struct xt_geoip_match_info *info = (void*)match->data;
-
-       u_int8_t i;
-
-       if (info->flags & XT_GEOIP_SRC)
-               printf(" Source ");
-       else
-               printf(" Destination ");
-
-       if (info->count > 1)
-               printf("countries: ");
-       else
-               printf("country: ");
-
-       if (info->flags & XT_GEOIP_INV)
-               printf("! ");
-
-       for (i = 0; i < info->count; i++)
-                printf("%s%c%c", i ? "," : "", COUNTRY(info->cc[i]));
-       printf(" ");
-}
-
 static void
 geoip_save(const void *ip, const struct xt_entry_match *match)
 {
@@ -295,6 +270,13 @@ geoip_save(const void *ip, const struct xt_entry_match *match)
        printf(" ");
 }
 
+static void
+geoip_print(const void *ip, const struct xt_entry_match *match, int numeric)
+{
+       printf(" -m geoip");
+       geoip_save(ip, match);
+}
+
 static struct xtables_match geoip_match[] = {
        {
                .family        = NFPROTO_IPV6,
index 5d1113df7bd55a7b50a2ee79e090283d19d4fd2b..85f24b8f818c1b0292d58d9150522d4536c3fd55 100644 (file)
@@ -57,17 +57,6 @@ static void gradm_mt_check(unsigned int flags)
 {
 }
 
-static void gradm_mt_print(const void *ip, const struct xt_entry_match *match,
-                           int numeric)
-{
-       const struct xt_gradm_mtinfo *info = (const void *)match->data;
-
-       if (info->invflags)
-               printf("gradm: disabled");
-       else
-               printf("gradm: enabled");
-}
-
 static void gradm_mt_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_gradm_mtinfo *info = (const void *)match->data;
@@ -78,6 +67,13 @@ static void gradm_mt_save(const void *ip, const struct xt_entry_match *match)
                printf(" --enabled ");
 }
 
+static void gradm_mt_print(const void *ip, const struct xt_entry_match *match,
+                           int numeric)
+{
+       printf(" -m gradm");
+       gradm_mt_save(ip, match);
+}
+
 static struct xtables_match gradm_mt_reg = {
        .family        = NFPROTO_UNSPEC,
        .name          = "gradm",
index b6e57a7ea0834ef3af01e37b797dcb9a618a52e2..c85df0c5bd9a8242d91263bcba7915f6ebbe29a4 100644 (file)
@@ -175,33 +175,6 @@ static void iface_mt_check(unsigned int flags)
                        "iface: You must specify at least one option");
 }
 
-static void iface_mt_print(const void *ip, const struct xt_entry_match *match,
-    int numeric)
-{
-       const struct xt_iface_mtinfo *info = (const void *)match->data;
-
-       printf(" iface: ");
-       if (info->flags & XT_IFACE_DEV_IN)
-               printf("(in)");
-       else if (info->flags & XT_IFACE_DEV_OUT)
-               printf("(out)");
-       else
-               printf("%s", info->ifname);
-       printf(" [state:");
-       iface_print_opt(info, XT_IFACE_UP,          "up");
-       iface_print_opt(info, XT_IFACE_BROADCAST,   "broadcast");
-       iface_print_opt(info, XT_IFACE_LOOPBACK,    "loopback");
-       iface_print_opt(info, XT_IFACE_POINTOPOINT, "pointopoint");
-       iface_print_opt(info, XT_IFACE_RUNNING,     "running");
-       iface_print_opt(info, XT_IFACE_NOARP,       "noarp");
-       iface_print_opt(info, XT_IFACE_PROMISC,     "promisc");
-       iface_print_opt(info, XT_IFACE_MULTICAST,   "multicast");
-       iface_print_opt(info, XT_IFACE_DYNAMIC,     "dynamic");
-       iface_print_opt(info, XT_IFACE_LOWER_UP,    "lower_up");
-       iface_print_opt(info, XT_IFACE_DORMANT,     "dormant");
-       printf("] ");
-}
-
 static void iface_mt_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_iface_mtinfo *info = (const void *)match->data;
@@ -226,6 +199,13 @@ static void iface_mt_save(const void *ip, const struct xt_entry_match *match)
        printf(" ");
 }
 
+static void iface_mt_print(const void *ip, const struct xt_entry_match *match,
+    int numeric)
+{
+       printf(" -m iface");
+       iface_mt_save(ip, match);
+}
+
 static struct xtables_match iface_mt_reg = {
        .version        = XTABLES_VERSION,
        .name           = "iface",
index 1d6835cab7f75cdd41808285171e55f1ee041a2c..74be4bee95ea82d1fddff2038a57dc15e3c0bd9e 100644 (file)
@@ -217,7 +217,7 @@ ipp2p_mt_print1(const void *entry, const struct xt_entry_match *match,
 static void ipp2p_mt_print(const void *entry,
     const struct xt_entry_match *match, int numeric)
 {
-       printf(" ipp2p ");
+       printf(" -m ipp2p ");
        ipp2p_mt_print1(entry, match, true);
 }
 
index 33d3592c9bb9d1d05e4fbaea01d918605b53f78e..696911db4e5bfdb4152119a25c89d72045a42bd1 100644 (file)
@@ -133,17 +133,6 @@ static void ipv4options_print_flags(const struct xt_ipv4options_mtinfo1 *info,
                }
 }
 
-static void ipv4options_mt_print(const void *ip,
-    const struct xt_entry_match *match, int numeric)
-{
-       const struct xt_ipv4options_mtinfo1 *info = (void *)match->data;
-
-       printf(" ipv4options %s ",
-              (info->flags & XT_V4OPTS_ANY) ? "any-of" : "all-of");
-       ipv4options_print_flags(info, numeric);
-       printf(" ");
-}
-
 static void ipv4options_mt_save(const void *ip,
     const struct xt_entry_match *match)
 {
@@ -158,6 +147,13 @@ static void ipv4options_mt_save(const void *ip,
        printf(" ");
 }
 
+static void ipv4options_mt_print(const void *ip,
+    const struct xt_entry_match *match, int numeric)
+{
+       printf(" -m ipv4options");
+       ipv4options_mt_save(ip, match);
+}
+
 static struct xtables_match ipv4options_mt_reg = {
        .version       = XTABLES_VERSION,
        .name          = "ipv4options",
index 5fbfe301b7556dd10040e032eb42dab7d627b818..37fe5df3ca60bad580a2b4c96d2b6d93d0091da4 100644 (file)
@@ -107,29 +107,6 @@ static void length_mt_check(unsigned int flags)
                        "--layer3. Consider specifying it explicitly.\n");
 }
 
-static void length_mt_print(const void *ip, const struct xt_entry_match *match,
-                            int numeric)
-{
-       const struct xt_length_mtinfo2 *info = (const void *)match->data;
-
-       if (info->flags & XT_LENGTH_LAYER3)
-               printf(" layer3 ");
-       else if (info->flags & XT_LENGTH_LAYER4)
-               printf(" layer4 ");
-       else if (info->flags & XT_LENGTH_LAYER5)
-               printf(" layer5 ");
-       else if (info->flags & XT_LENGTH_LAYER7)
-               printf(" layer7 ");
-       printf(" length ");
-       if (info->flags & XT_LENGTH_INVERT)
-               printf("! ");
-       if (info->min == info->max)
-               printf("%u ", (unsigned int)info->min);
-       else
-               printf("%u-%u ", (unsigned int)info->min,
-                      (unsigned int)info->max);
-}
-
 static void length_mt_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_length_mtinfo2 *info = (const void *)match->data;
@@ -152,6 +129,13 @@ static void length_mt_save(const void *ip, const struct xt_entry_match *match)
                       (unsigned int)info->max);
 }
 
+static void length_mt_print(const void *ip, const struct xt_entry_match *match,
+                            int numeric)
+{
+       printf(" -m length2");
+       length_mt_save(ip, match);
+}
+
 static struct xtables_match length2_mt_reg = {
        .version        = XTABLES_VERSION,
        .name           = "length2",
index efb196aa298fd05155b39e6c2e6e390478d8ff31..4d269f925e5dec5a0b7572417b32ea78798e4e7c 100644 (file)
@@ -64,30 +64,6 @@ static void lscan_mt_check(unsigned int flags)
 {
 }
 
-static void lscan_mt_print(const void *ip,
-    const struct xt_entry_match *match, int numeric)
-{
-       const struct xt_lscan_mtinfo *info = (const void *)(match->data);
-       const char *s = "";
-
-       printf(" lscan ");
-       if (info->match_stealth) {
-               printf("STEALTH");
-               s = ",";
-       }
-       if (info->match_syn) {
-               printf("%sSYNSCAN", s);
-               s = ",";
-       }
-       if (info->match_cn) {
-               printf("%sCNSCAN", s);
-               s = ",";
-       }
-       if (info->match_gr)
-               printf("%sGRSCAN", s);
-       printf(" ");
-}
-
 static void lscan_mt_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_lscan_mtinfo *info = (const void *)(match->data);
@@ -102,6 +78,13 @@ static void lscan_mt_save(const void *ip, const struct xt_entry_match *match)
                printf(" --grscan ");
 }
 
+static void lscan_mt_print(const void *ip,
+    const struct xt_entry_match *match, int numeric)
+{
+       printf(" -m lscan");
+       lscan_mt_save(ip, match);
+}
+
 static struct xtables_match lscan_mt_reg = {
        .version       = XTABLES_VERSION,
        .name          = "lscan",
index 3f88ac49abb0358d3b6603cc85296eebb3371938..05940e7187b9e58c22a085708824e72e593d2e0a 100644 (file)
@@ -117,18 +117,6 @@ static int psd_mt_parse(int c, char **argv, int invert, unsigned int *flags,
 /* Final check; nothing. */
 static void psd_mt_final_check(unsigned int flags) {}
 
-/* Prints out the targinfo. */
-static void psd_mt_print(const void *ip, const struct xt_entry_match *match, int numeric)
-{
-       const struct xt_psd_info *psdinfo = (const struct xt_psd_info *)match->data;
-       printf(" psd ");
-       printf("weight-threshold: %u ", psdinfo->weight_threshold);
-       printf("delay-threshold: %u ", psdinfo->delay_threshold);
-       printf("lo-ports-weight: %u ", psdinfo->lo_ports_weight);
-       printf("hi-ports-weight: %u ", psdinfo->hi_ports_weight);
-}
-
-/* Saves the union ipt_targinfo in parsable form to stdout. */
 static void psd_mt_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_psd_info *psdinfo = (const struct xt_psd_info *)match->data;
@@ -138,6 +126,12 @@ static void psd_mt_save(const void *ip, const struct xt_entry_match *match)
        printf("--psd-hi-ports-weight %u ", psdinfo->hi_ports_weight);
 }
 
+static void psd_mt_print(const void *ip, const struct xt_entry_match *match, int numeric)
+{
+       printf(" -m psd");
+       psd_mt_save(ip, match);
+}
+
 static struct xtables_match psd_mt_reg = {
        .name           = "psd",
        .version        = XTABLES_VERSION,
index 20c9581fc64f6f10a526336a3ef5aad2714d1fa1..f0cf3d47e3b425cbc65d6bc2ed74663e6aafebcf 100644 (file)
@@ -114,23 +114,8 @@ quota_mt2_save(const void *ip, const struct xt_entry_match *match)
 static void quota_mt2_print(const void *ip, const struct xt_entry_match *match,
                             int numeric)
 {
-       const struct xt_quota_mtinfo2 *q = (const void *)match->data;
-
-       if (q->flags & XT_QUOTA_INVERT)
-               printf(" !");
-       if (q->flags & XT_QUOTA_GROW)
-               printf(" counter");
-       else
-               printf(" quota");
-       if (*q->name != '\0')
-               printf(" %s:", q->name);
-       printf(" %llu ", (unsigned long long)q->quota);
-       if (q->flags & XT_QUOTA_PACKET)
-               printf("packets ");
-       else
-               printf("bytes ");
-       if (q->flags & XT_QUOTA_NO_CHANGE)
-               printf("(no-change mode) ");
+       printf(" -m quota");
+       quota_mt2_save(ip, match);
 }
 
 static struct xtables_match quota_mt2_reg = {