]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables-save: output ! in position according to manpage
authorJan Engelhardt <jengelh@medozas.de>
Tue, 9 Dec 2008 14:06:20 +0000 (15:06 +0100)
committerPatrick McHardy <kaber@trash.net>
Tue, 9 Dec 2008 14:06:20 +0000 (15:06 +0100)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
16 files changed:
extensions/libip6t_ah.c
extensions/libip6t_dst.c
extensions/libip6t_frag.c
extensions/libip6t_hbh.c
extensions/libip6t_hl.c
extensions/libip6t_ipv6header.c
extensions/libip6t_rt.c
extensions/libipt_addrtype.c
extensions/libipt_ah.c
extensions/libxt_dscp.c
extensions/libxt_esp.c
extensions/libxt_length.c
extensions/libxt_multiport.c
extensions/libxt_pkttype.c
extensions/libxt_string.c
extensions/libxt_tcpmss.c

index 6a3e784162de4848a72e85509fce7a80a466f2cc..0bbd475418b44038946f74970b19693aff5efe70 100644 (file)
@@ -164,7 +164,7 @@ static void ah_save(const void *ip, const struct xt_entry_match *match)
 
        if (!(ahinfo->spis[0] == 0
            && ahinfo->spis[1] == 0xFFFFFFFF)) {
-               printf("--ahspi %s", 
+               printf("%s--ahspi ",
                        (ahinfo->invflags & IP6T_AH_INV_SPI) ? "! " : "");
                if (ahinfo->spis[0]
                    != ahinfo->spis[1])
@@ -177,7 +177,7 @@ static void ah_save(const void *ip, const struct xt_entry_match *match)
        }
 
        if (ahinfo->hdrlen != 0 || (ahinfo->invflags & IP6T_AH_INV_LEN) ) {
-               printf("--ahlen %s%u ", 
+               printf("%s--ahlen %u ", 
                        (ahinfo->invflags & IP6T_AH_INV_LEN) ? "! " : "", 
                        ahinfo->hdrlen);
        }
index 17e87808cfd5d0c5d4db9857070a00e9249bee00..215e2d95b9c8db379330c35f7e41dd83b88ebc6b 100644 (file)
@@ -207,7 +207,7 @@ static void dst_save(const void *ip, const struct xt_entry_match *match)
        const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data;
 
        if (optinfo->flags & IP6T_OPTS_LEN) {
-               printf("--dst-len %s%u ",
+               printf("%s--dst-len %u ",
                        (optinfo->invflags & IP6T_OPTS_INV_LEN) ? "! " : "", 
                        optinfo->hdrlen);
        }
index 1f8f801d42beeaf3900c9448fd746acf1eba5424..5ded1c652615bc3d747a17c6c5fc16e9ba00a82a 100644 (file)
@@ -200,7 +200,7 @@ static void frag_save(const void *ip, const struct xt_entry_match *match)
 
        if (!(fraginfo->ids[0] == 0
            && fraginfo->ids[1] == 0xFFFFFFFF)) {
-               printf("--fragid %s", 
+               printf("%s--fragid ", 
                        (fraginfo->invflags & IP6T_FRAG_INV_IDS) ? "! " : "");
                if (fraginfo->ids[0]
                    != fraginfo->ids[1])
@@ -213,7 +213,7 @@ static void frag_save(const void *ip, const struct xt_entry_match *match)
        }
 
        if (fraginfo->flags & IP6T_FRAG_LEN) {
-               printf("--fraglen %s%u ", 
+               printf("%s--fraglen %u ", 
                        (fraginfo->invflags & IP6T_FRAG_INV_LEN) ? "! " : "", 
                        fraginfo->hdrlen);
        }
index ce79af94cf0ae1227ec9f4bd1bf7658590cca4e5..419c2506a38706e31ab84dc73bf662feaa4753a5 100644 (file)
@@ -196,7 +196,7 @@ static void hbh_save(const void *ip, const struct xt_entry_match *match)
        const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data;
 
        if (optinfo->flags & IP6T_OPTS_LEN) {
-               printf("--hbh-len %s%u ",
+               printf("%s--hbh-len %u ",
                        (optinfo->invflags & IP6T_OPTS_INV_LEN) ? "! " : "", 
                        optinfo->hdrlen);
        }
index f683dc7375426b1d06b6a8a3a6194d9073580810..77275812880949fef62e523318521ffc599fea22 100644 (file)
@@ -104,16 +104,16 @@ static void hl_print(const void *ip, const struct xt_entry_match *match,
 
 static void hl_save(const void *ip, const struct xt_entry_match *match)
 {
-       static const char *op[] = {
-               [IP6T_HL_EQ] = "eq",
-               [IP6T_HL_NE] = "eq !",
-               [IP6T_HL_LT] = "lt",
-               [IP6T_HL_GT] = "gt" };
+       static const char *const op[] = {
+               [IP6T_HL_EQ] = "--hl-eq",
+               [IP6T_HL_NE] = "! --hl-eq",
+               [IP6T_HL_LT] = "--hl-lt",
+               [IP6T_HL_GT] = "--hl-gt" };
 
        const struct ip6t_hl_info *info =
                (struct ip6t_hl_info *) match->data;
 
-       printf("--hl-%s %u ", op[info->mode], info->hop_limit);
+       printf("%s %u ", op[info->mode], info->hop_limit);
 }
 
 static const struct option hl_opts[] = {
index e114451d78b315b1d0203a2fd88daa21a6508ed5..3006124418dd894a1fa4a23df05f69ed668ece3a 100644 (file)
@@ -271,8 +271,7 @@ static void ipv6header_save(const void *ip, const struct xt_entry_match *match)
 
        const struct ip6t_ipv6header_info *info = (const struct ip6t_ipv6header_info *)match->data;
 
-       printf("--header ");
-       printf("%s", info->invflags ? "!" : "");
+       printf("%s--header ", info->invflags ? "! " : "");
        print_header(info->matchflags);
        printf(" ");
        if (info->modeflag)
index c1f72af86e268447825563c9f9439ce07e2e5e20..9468da18de508c4258b62a846e0ea874c68d8fef 100644 (file)
@@ -291,14 +291,14 @@ static void rt_save(const void *ip, const struct xt_entry_match *match)
        const struct ip6t_rt *rtinfo = (struct ip6t_rt *)match->data;
 
        if (rtinfo->flags & IP6T_RT_TYP) {
-               printf("--rt-type %s%u ", 
+               printf("%s--rt-type %u ", 
                        (rtinfo->invflags & IP6T_RT_INV_TYP) ? "! " : "", 
                        rtinfo->rt_type);
        }
 
        if (!(rtinfo->segsleft[0] == 0
            && rtinfo->segsleft[1] == 0xFFFFFFFF)) {
-               printf("--rt-segsleft %s", 
+               printf("%s--rt-segsleft ",
                        (rtinfo->invflags & IP6T_RT_INV_SGS) ? "! " : "");
                if (rtinfo->segsleft[0]
                    != rtinfo->segsleft[1])
@@ -311,7 +311,7 @@ static void rt_save(const void *ip, const struct xt_entry_match *match)
        }
 
        if (rtinfo->flags & IP6T_RT_LEN) {
-               printf("--rt-len %s%u ", 
+               printf("%s--rt-len %u ",
                        (rtinfo->invflags & IP6T_RT_INV_LEN) ? "! " : "", 
                        rtinfo->hdrlen);
        }
index 3c83a0128511c323fec4f07e3bf92acfeb4f4229..dc43a3f57e54a1d26f27eacc3ea93f3a2ce15864 100644 (file)
@@ -266,15 +266,15 @@ static void addrtype_save_v0(const void *ip, const struct xt_entry_match *match)
                (struct ipt_addrtype_info *) match->data;
 
        if (info->source) {
-               printf("--src-type ");
                if (info->invert_source)
                        printf("! ");
+               printf("--src-type ");
                print_types(info->source);
        }
        if (info->dest) {
-               printf("--dst-type ");
                if (info->invert_dest)
                        printf("! ");
+               printf("--dst-type ");
                print_types(info->dest);
        }
 }
@@ -285,15 +285,15 @@ static void addrtype_save_v1(const void *ip, const struct xt_entry_match *match)
                (struct ipt_addrtype_info_v1 *) match->data;
 
        if (info->source) {
-               printf("--src-type ");
                if (info->flags & IPT_ADDRTYPE_INVERT_SOURCE)
                        printf("! ");
+               printf("--src-type ");
                print_types(info->source);
        }
        if (info->dest) {
-               printf("--dst-type ");
                if (info->flags & IPT_ADDRTYPE_INVERT_DEST)
                        printf("! ");
+               printf("--dst-type ");
                print_types(info->dest);
        }
        if (info->flags & IPT_ADDRTYPE_LIMIT_IFACE_IN) {
index 5084332a4bba543f6d4659c230902ab5b4baee97..fec87a74b947104391576abe3d1ea3266970edb6 100644 (file)
@@ -135,7 +135,7 @@ static void ah_save(const void *ip, const struct xt_entry_match *match)
 
        if (!(ahinfo->spis[0] == 0
            && ahinfo->spis[1] == 0xFFFFFFFF)) {
-               printf("--ahspi %s", 
+               printf("%s--ahspi ",
                        (ahinfo->invflags & IPT_AH_INV_SPI) ? "! " : "");
                if (ahinfo->spis[0]
                    != ahinfo->spis[1])
index 307d8009c8d46056bdeaaa3aed1264653780787b..eefb186b125b25b49f09ee53a502761a65ee84d7 100644 (file)
@@ -115,22 +115,12 @@ static void dscp_check(unsigned int flags)
                           "DSCP match: Parameter --dscp is required");
 }
 
-static void
-print_dscp(u_int8_t dscp, int invert, int numeric)
-{
-       if (invert)
-               printf("! ");
-
-       printf("0x%02x ", dscp);
-}
-
 static void
 dscp_print(const void *ip, const struct xt_entry_match *match, int numeric)
 {
        const struct xt_dscp_info *dinfo =
                (const struct xt_dscp_info *)match->data;
-       printf("DSCP match ");
-       print_dscp(dinfo->dscp, dinfo->invert, numeric);
+       printf("DSCP match %s0x%02x", dinfo->invert ? "!" : "", dinfo->dscp);
 }
 
 static void dscp_save(const void *ip, const struct xt_entry_match *match)
@@ -138,8 +128,7 @@ static void dscp_save(const void *ip, const struct xt_entry_match *match)
        const struct xt_dscp_info *dinfo =
                (const struct xt_dscp_info *)match->data;
 
-       printf("--dscp ");
-       print_dscp(dinfo->dscp, dinfo->invert, 1);
+       printf("%s--dscp 0x%02x ", dinfo->invert ? "! " : "", dinfo->dscp);
 }
 
 static struct xtables_match dscp_match = {
index 524449a2f2ae14fe43eb7b2d5c16d5e7484db84b..999733c318d701b727b0f55a7ca2e18ae40456ff 100644 (file)
@@ -134,7 +134,7 @@ static void esp_save(const void *ip, const struct xt_entry_match *match)
 
        if (!(espinfo->spis[0] == 0
            && espinfo->spis[1] == 0xFFFFFFFF)) {
-               printf("--espspi %s", 
+               printf("%s--espspi ",
                        (espinfo->invflags & XT_ESP_INV_SPI) ? "! " : "");
                if (espinfo->spis[0]
                    != espinfo->spis[1])
index c5c411e18a2b2ddbef87da083dbfe0c3472c49fc..98e816736857dd0d51b05473fd534ed0e0b7998b 100644 (file)
@@ -91,28 +91,26 @@ static void length_check(unsigned int flags)
 }
 
 static void
-print_length(struct xt_length_info *info)
+length_print(const void *ip, const struct xt_entry_match *match, int numeric)
 {
-       if (info->invert)
-               printf("! ");
-       
-       if (info->max == info->min)
+       const struct xt_length_info *info = (void *)match->data;
+
+       printf("length %s", info->invert ? "!" : "");
+       if (info->min == info->max)
                printf("%u ", info->min);
        else
                printf("%u:%u ", info->min, info->max);
 }
 
-static void
-length_print(const void *ip, const struct xt_entry_match *match, int numeric)
-{
-       printf("length ");
-       print_length((struct xt_length_info *)match->data);
-}
-
 static void length_save(const void *ip, const struct xt_entry_match *match)
 {
-       printf("--length ");
-       print_length((struct xt_length_info *)match->data);
+       const struct xt_length_info *info = (void *)match->data;
+
+       printf("%s--length ", info->invert ? "! " : "");
+       if (info->min == info->max)
+               printf("%u ", info->min);
+       else
+               printf("%u:%u ", info->min, info->max);
 }
 
 static struct xtables_match length_match = {
index 2552bbd8951826dfc4e06f1f66e6c519e1e3cc9d..dae6e3350a1d19a16df6739d875970b7a9b054d0 100644 (file)
@@ -464,6 +464,9 @@ static void __multiport_save_v1(const struct xt_entry_match *match,
                = (const struct xt_multiport_v1 *)match->data;
        unsigned int i;
 
+       if (multiinfo->invert)
+               printf("! ");
+
        switch (multiinfo->flags) {
        case XT_MULTIPORT_SOURCE:
                printf("--sports ");
@@ -478,9 +481,6 @@ static void __multiport_save_v1(const struct xt_entry_match *match,
                break;
        }
 
-       if (multiinfo->invert)
-               printf("! ");
-
        for (i=0; i < multiinfo->count; i++) {
                printf("%s", i ? "," : "");
                print_port(multiinfo->ports[i], proto, 1);
index 5e5e7ca7e1bc600e3178a622ced83aece57aacc0..ab2e2259097f909682ff4e6f86ef6b90bb8dfc3e 100644 (file)
@@ -140,7 +140,7 @@ static void pkttype_save(const void *ip, const struct xt_entry_match *match)
 {
        struct xt_pkttype_info *info = (struct xt_pkttype_info *)match->data;
        
-       printf("--pkt-type %s", info->invert?"! ":"");
+       printf("%s--pkt-type ", info->invert ? "! " : "");
        print_pkttype(info);
 }
 
index 5b3ebf668d8c06a4f3ca7d45d81d56e9c146c2a5..b440fc92a3930264c553303fd95d8940cc46628d 100644 (file)
@@ -332,10 +332,10 @@ static void string_save(const void *ip, const struct xt_entry_match *match)
                                    info->u.v1.flags & XT_STRING_FLAG_INVERT);
 
        if (is_hex_string(info->pattern, info->patlen)) {
-               printf("--hex-string %s", (invert) ? "! ": "");
+               printf("%s--hex-string ", (invert) ? "! ": "");
                print_hex_string(info->pattern, info->patlen);
        } else {
-               printf("--string %s", (invert) ? "! ": "");
+               printf("%s--string ", (invert) ? "! ": "");
                print_string(info->pattern, info->patlen);
        }
        printf("--algo %s ", info->algo);
index 14be9194e5f6c33163fea7a070bb6176806f7ae2..000d85a62a6eac94c34546c40ad97280a7bf2a79 100644 (file)
@@ -78,18 +78,6 @@ tcpmss_parse(int c, char **argv, int invert, unsigned int *flags,
        return 1;
 }
 
-static void
-print_tcpmss(u_int16_t mss_min, u_int16_t mss_max, int invert, int numeric)
-{
-       if (invert)
-               printf("! ");
-
-       if (mss_min == mss_max)
-               printf("%u ", mss_min);
-       else
-               printf("%u:%u ", mss_min, mss_max);
-}
-
 static void tcpmss_check(unsigned int flags)
 {
        if (!flags)
@@ -100,22 +88,24 @@ static void tcpmss_check(unsigned int flags)
 static void
 tcpmss_print(const void *ip, const struct xt_entry_match *match, int numeric)
 {
-       const struct xt_tcpmss_match_info *mssinfo =
-               (const struct xt_tcpmss_match_info *)match->data;
+       const struct xt_tcpmss_match_info *info = (void *)match->data;
 
-       printf("tcpmss match ");
-       print_tcpmss(mssinfo->mss_min, mssinfo->mss_max,
-                    mssinfo->invert, numeric);
+       printf("tcpmss match %s", info->invert ? "!" : "");
+       if (info->mss_min == info->mss_max)
+               printf("%u ", info->mss_min);
+       else
+               printf("%u:%u ", info->mss_min, info->mss_max);
 }
 
 static void tcpmss_save(const void *ip, const struct xt_entry_match *match)
 {
-       const struct xt_tcpmss_match_info *mssinfo =
-               (const struct xt_tcpmss_match_info *)match->data;
+       const struct xt_tcpmss_match_info *info = (void *)match->data;
 
-       printf("--mss ");
-       print_tcpmss(mssinfo->mss_min, mssinfo->mss_max,
-                    mssinfo->invert, 0);
+       printf("%s--mss ", info->invert ? "! " : "");
+       if (info->mss_min == info->mss_max)
+               printf("%u ", info->mss_min);
+       else
+               printf("%u:%u ", info->mss_min, info->mss_max);
 }
 
 static struct xtables_match tcpmss_match = {