]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: prefix/order - ipaddr/ipmask to ascii output
authorJan Engelhardt <jengelh@medozas.de>
Fri, 30 Jan 2009 02:55:09 +0000 (03:55 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Fri, 30 Jan 2009 02:55:09 +0000 (03:55 +0100)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
12 files changed:
extensions/libipt_DNAT.c
extensions/libipt_NETMAP.c
extensions/libipt_SAME.c
extensions/libipt_SNAT.c
extensions/libipt_policy.c
extensions/libxt_TPROXY.c
extensions/libxt_conntrack.c
extensions/libxt_iprange.c
include/xtables.h.in
ip6tables.c
iptables.c
xtables.c

index e884b03eb49317fc0081c9ef37349bb7c4e32e70..42695bb453848f061cc5dcf132921599bed37e24 100644 (file)
@@ -195,10 +195,10 @@ static void print_range(const struct ip_nat_range *r)
                struct in_addr a;
 
                a.s_addr = r->min_ip;
-               printf("%s", ipaddr_to_numeric(&a));
+               printf("%s", xtables_ipaddr_to_numeric(&a));
                if (r->max_ip != r->min_ip) {
                        a.s_addr = r->max_ip;
-                       printf("-%s", ipaddr_to_numeric(&a));
+                       printf("-%s", xtables_ipaddr_to_numeric(&a));
                }
        }
        if (r->flags & IP_NAT_RANGE_PROTO_SPECIFIED) {
index d8f34ccdb418382166c74cbd1112a4e0590ebbaf..33f48c93798a86f31b31418f7c634d9e2600cbcd 100644 (file)
@@ -148,11 +148,11 @@ static void NETMAP_print(const void *ip, const struct xt_entry_target *target,
        int bits;
 
        a.s_addr = r->min_ip;
-       printf("%s", ipaddr_to_numeric(&a));
+       printf("%s", xtables_ipaddr_to_numeric(&a));
        a.s_addr = ~(r->min_ip ^ r->max_ip);
        bits = netmask2bits(a.s_addr);
        if (bits < 0)
-               printf("/%s", ipaddr_to_numeric(&a));
+               printf("/%s", xtables_ipaddr_to_numeric(&a));
        else
                printf("/%d", bits);
 }
index 6cb09afcae2441abe97ed67c8b322f23140fbe09..1ca38ff8fdc4cea01e794ffde926bfc144b4af18 100644 (file)
@@ -151,13 +151,13 @@ static void SAME_print(const void *ip, const struct xt_entry_target *target,
 
                a.s_addr = r->min_ip;
 
-               printf("%s", ipaddr_to_numeric(&a));
+               printf("%s", xtables_ipaddr_to_numeric(&a));
                a.s_addr = r->max_ip;
                
                if (r->min_ip == r->max_ip)
                        printf(" ");
                else
-                       printf("-%s ", ipaddr_to_numeric(&a));
+                       printf("-%s ", xtables_ipaddr_to_numeric(&a));
                if (r->flags & IP_NAT_RANGE_PROTO_RANDOM) 
                        random_selection = 1;
        }
@@ -181,13 +181,13 @@ static void SAME_save(const void *ip, const struct xt_entry_target *target)
                struct in_addr a;
 
                a.s_addr = r->min_ip;
-               printf("--to %s", ipaddr_to_numeric(&a));
+               printf("--to %s", xtables_ipaddr_to_numeric(&a));
                a.s_addr = r->max_ip;
 
                if (r->min_ip == r->max_ip)
                        printf(" ");
                else
-                       printf("-%s ", ipaddr_to_numeric(&a));
+                       printf("-%s ", xtables_ipaddr_to_numeric(&a));
                if (r->flags & IP_NAT_RANGE_PROTO_RANDOM) 
                        random_selection = 1;
        }
index 8c28c0eedee6858a0fca499fd59b23c4c1b6ef59..2afcbb1ee58aa973d29077b7563286d87a602d44 100644 (file)
@@ -196,10 +196,10 @@ static void print_range(const struct ip_nat_range *r)
                struct in_addr a;
 
                a.s_addr = r->min_ip;
-               printf("%s", ipaddr_to_numeric(&a));
+               printf("%s", xtables_ipaddr_to_numeric(&a));
                if (r->max_ip != r->min_ip) {
                        a.s_addr = r->max_ip;
-                       printf("-%s", ipaddr_to_numeric(&a));
+                       printf("-%s", xtables_ipaddr_to_numeric(&a));
                }
        }
        if (r->flags & IP_NAT_RANGE_PROTO_SPECIFIED) {
index 9c701820247ac588ae5e93fc77bdf62d3a69ce6a..6b044d875f6a163a474def3edf73068163ab9f31 100644 (file)
@@ -352,14 +352,14 @@ static void print_entry(char *prefix, const struct ipt_policy_elem *e,
        if (e->match.daddr) {
                PRINT_INVERT(e->invert.daddr);
                printf("%stunnel-dst %s%s ", prefix,
-                      ipaddr_to_numeric((const void *)&e->daddr),
-                      ipmask_to_numeric((const void *)&e->dmask));
+                      xtables_ipaddr_to_numeric((const void *)&e->daddr),
+                      xtables_ipmask_to_numeric((const void *)&e->dmask));
        }
        if (e->match.saddr) {
                PRINT_INVERT(e->invert.saddr);
                printf("%stunnel-src %s%s ", prefix,
-                      ipaddr_to_numeric((const void *)&e->saddr),
-                      ipmask_to_numeric((const void *)&e->smask));
+                      xtables_ipaddr_to_numeric((const void *)&e->saddr),
+                      xtables_ipmask_to_numeric((const void *)&e->smask));
        }
 }
 
index d0933aef5117b77fcc9d1458d4a874fd08627dec..2398c84943275f59ba9f4f0bce33b63ddc2d8506 100644 (file)
@@ -114,7 +114,7 @@ static void tproxy_tg_print(const void *ip, const struct xt_entry_target *target
 {
        const struct xt_tproxy_target_info *info = (const void *)target->data;
        printf("TPROXY redirect %s:%u mark 0x%x/0x%x",
-              ipaddr_to_numeric((const struct in_addr *)&info->laddr),
+              xtables_ipaddr_to_numeric((const struct in_addr *)&info->laddr),
               ntohs(info->lport), (unsigned int)info->mark_value,
               (unsigned int)info->mark_mask);
 }
@@ -125,7 +125,7 @@ static void tproxy_tg_save(const void *ip, const struct xt_entry_target *target)
 
        printf("--on-port %u ", ntohs(info->lport));
        printf("--on-ip %s ",
-              ipaddr_to_numeric((const struct in_addr *)&info->laddr));
+              xtables_ipaddr_to_numeric((const struct in_addr *)&info->laddr));
        printf("--tproxy-mark 0x%x/0x%x ",
               (unsigned int)info->mark_value, (unsigned int)info->mark_mask);
 }
index facd0fc280b515174f1f8dc5204cf18c6a444cee..ffa279cac3511f84a0ae07abf66377c445e95cff 100644 (file)
@@ -761,9 +761,9 @@ conntrack_dump_addr(const union nf_inet_addr *addr,
                        return;
                }
                if (numeric)
-                       printf("%s ", ipaddr_to_numeric(&addr->in));
+                       printf("%s ", xtables_ipaddr_to_numeric(&addr->in));
                else
-                       printf("%s ", ipaddr_to_anyname(&addr->in));
+                       printf("%s ", xtables_ipaddr_to_anyname(&addr->in));
        } else if (family == NFPROTO_IPV6) {
                if (!numeric && addr->ip6[0] == 0 && addr->ip6[1] == 0 &&
                    addr->ip6[2] == 0 && addr->ip6[3] == 0) {
@@ -771,9 +771,9 @@ conntrack_dump_addr(const union nf_inet_addr *addr,
                        return;
                }
                if (numeric)
-                       printf("%s ", ip6addr_to_numeric(&addr->in6));
+                       printf("%s ", xtables_ip6addr_to_numeric(&addr->in6));
                else
-                       printf("%s ", ip6addr_to_anyname(&addr->in6));
+                       printf("%s ", xtables_ip6addr_to_anyname(&addr->in6));
        }
 }
 
@@ -789,10 +789,10 @@ print_addr(struct in_addr *addr, struct in_addr *mask, int inv, int numeric)
                printf("%s ", "anywhere");
        else {
                if (numeric)
-                       sprintf(buf, "%s", ipaddr_to_numeric(addr));
+                       strcpy(buf, xtables_ipaddr_to_numeric(addr));
                else
-                       sprintf(buf, "%s", ipaddr_to_anyname(addr));
-               strcat(buf, ipmask_to_numeric(mask));
+                       strcpy(buf, xtables_ipaddr_to_anyname(addr));
+               strcat(buf, xtables_ipmask_to_numeric(mask));
                printf("%s ", buf);
        }
 }
index 0fe2b4f040a6dd6b9c03f8084a9256fdff16c494..9fdc70a6ffdaeeaf96f0c5786701cca6c1e02863 100644 (file)
@@ -250,15 +250,15 @@ iprange_mt4_print(const void *ip, const struct xt_entry_match *match,
                 * ipaddr_to_numeric() uses a static buffer, so cannot
                 * combine the printf() calls.
                 */
-               printf("%s", ipaddr_to_numeric(&info->src_min.in));
-               printf("-%s ", ipaddr_to_numeric(&info->src_max.in));
+               printf("%s", xtables_ipaddr_to_numeric(&info->src_min.in));
+               printf("-%s ", xtables_ipaddr_to_numeric(&info->src_max.in));
        }
        if (info->flags & IPRANGE_DST) {
                printf("destination IP range ");
                if (info->flags & IPRANGE_DST_INV)
                        printf("! ");
-               printf("%s", ipaddr_to_numeric(&info->dst_min.in));
-               printf("-%s ", ipaddr_to_numeric(&info->dst_max.in));
+               printf("%s", xtables_ipaddr_to_numeric(&info->dst_min.in));
+               printf("-%s ", xtables_ipaddr_to_numeric(&info->dst_max.in));
        }
 }
 
@@ -276,15 +276,15 @@ iprange_mt6_print(const void *ip, const struct xt_entry_match *match,
                 * ipaddr_to_numeric() uses a static buffer, so cannot
                 * combine the printf() calls.
                 */
-               printf("%s", ip6addr_to_numeric(&info->src_min.in6));
-               printf("-%s ", ip6addr_to_numeric(&info->src_max.in6));
+               printf("%s", xtables_ip6addr_to_numeric(&info->src_min.in6));
+               printf("-%s ", xtables_ip6addr_to_numeric(&info->src_max.in6));
        }
        if (info->flags & IPRANGE_DST) {
                printf("destination IP range ");
                if (info->flags & IPRANGE_DST_INV)
                        printf("! ");
-               printf("%s", ip6addr_to_numeric(&info->dst_min.in6));
-               printf("-%s ", ip6addr_to_numeric(&info->dst_max.in6));
+               printf("%s", xtables_ip6addr_to_numeric(&info->dst_min.in6));
+               printf("-%s ", xtables_ip6addr_to_numeric(&info->dst_max.in6));
        }
 }
 
@@ -315,14 +315,14 @@ static void iprange_mt4_save(const void *ip, const struct xt_entry_match *match)
        if (info->flags & IPRANGE_SRC) {
                if (info->flags & IPRANGE_SRC_INV)
                        printf("! ");
-               printf("--src-range %s", ipaddr_to_numeric(&info->src_min.in));
-               printf("-%s ", ipaddr_to_numeric(&info->src_max.in));
+               printf("--src-range %s", xtables_ipaddr_to_numeric(&info->src_min.in));
+               printf("-%s ", xtables_ipaddr_to_numeric(&info->src_max.in));
        }
        if (info->flags & IPRANGE_DST) {
                if (info->flags & IPRANGE_DST_INV)
                        printf("! ");
-               printf("--dst-range %s", ipaddr_to_numeric(&info->dst_min.in));
-               printf("-%s ", ipaddr_to_numeric(&info->dst_max.in));
+               printf("--dst-range %s", xtables_ipaddr_to_numeric(&info->dst_min.in));
+               printf("-%s ", xtables_ipaddr_to_numeric(&info->dst_max.in));
        }
 }
 
@@ -333,14 +333,14 @@ static void iprange_mt6_save(const void *ip, const struct xt_entry_match *match)
        if (info->flags & IPRANGE_SRC) {
                if (info->flags & IPRANGE_SRC_INV)
                        printf("! ");
-               printf("--src-range %s", ip6addr_to_numeric(&info->src_min.in6));
-               printf("-%s ", ip6addr_to_numeric(&info->src_max.in6));
+               printf("--src-range %s", xtables_ip6addr_to_numeric(&info->src_min.in6));
+               printf("-%s ", xtables_ip6addr_to_numeric(&info->src_max.in6));
        }
        if (info->flags & IPRANGE_DST) {
                if (info->flags & IPRANGE_DST_INV)
                        printf("! ");
-               printf("--dst-range %s", ip6addr_to_numeric(&info->dst_min.in6));
-               printf("-%s ", ip6addr_to_numeric(&info->dst_max.in6));
+               printf("--dst-range %s", xtables_ip6addr_to_numeric(&info->dst_min.in6));
+               printf("-%s ", xtables_ip6addr_to_numeric(&info->dst_max.in6));
        }
 }
 
index e5737cb80f3789e2c3ce789816250d891febafe2..3099de8f97cd8dca75025e5e937b8922ac94bab1 100644 (file)
@@ -207,18 +207,18 @@ void exit_error(enum xtables_exittype, const char *, ...)
        __attribute__((noreturn, format(printf,2,3)));
 extern void xtables_param_act(unsigned int, const char *, ...);
 
-extern const char *ipaddr_to_numeric(const struct in_addr *);
-extern const char *ipaddr_to_anyname(const struct in_addr *);
-extern const char *ipmask_to_numeric(const struct in_addr *);
+extern const char *xtables_ipaddr_to_numeric(const struct in_addr *);
+extern const char *xtables_ipaddr_to_anyname(const struct in_addr *);
+extern const char *xtables_ipmask_to_numeric(const struct in_addr *);
 extern struct in_addr *numeric_to_ipaddr(const char *);
 extern struct in_addr *numeric_to_ipmask(const char *);
 extern void ipparse_hostnetworkmask(const char *, struct in_addr **,
        struct in_addr *, unsigned int *);
 
 extern struct in6_addr *numeric_to_ip6addr(const char *);
-extern const char *ip6addr_to_numeric(const struct in6_addr *);
-extern const char *ip6addr_to_anyname(const struct in6_addr *);
-extern const char *ip6mask_to_numeric(const struct in6_addr *);
+extern const char *xtables_ip6addr_to_numeric(const struct in6_addr *);
+extern const char *xtables_ip6addr_to_anyname(const struct in6_addr *);
+extern const char *xtables_ip6mask_to_numeric(const struct in6_addr *);
 extern void ip6parse_hostnetworkmask(const char *, struct in6_addr **,
        struct in6_addr *, unsigned int *);
 
index cbacd89955118c2baea00b214ba80ab6671ae03a..f741c521fa88e29d7b275013b8630c1672e75d2a 100644 (file)
@@ -809,10 +809,10 @@ print_firewall(const struct ip6t_entry *fw,
                printf(FMT("%-19s ","%s "), "anywhere");
        else {
                if (format & FMT_NUMERIC)
-                       sprintf(buf, "%s", ip6addr_to_numeric(&fw->ipv6.src));
+                       strcpy(buf, xtables_ip6addr_to_numeric(&fw->ipv6.src));
                else
-                       sprintf(buf, "%s", ip6addr_to_anyname(&fw->ipv6.src));
-               strcat(buf, ip6mask_to_numeric(&fw->ipv6.smsk));
+                       strcpy(buf, xtables_ip6addr_to_anyname(&fw->ipv6.src));
+               strcat(buf, xtables_ip6mask_to_numeric(&fw->ipv6.smsk));
                printf(FMT("%-19s ","%s "), buf);
        }
 
@@ -822,10 +822,10 @@ print_firewall(const struct ip6t_entry *fw,
                printf(FMT("%-19s ","-> %s"), "anywhere");
        else {
                if (format & FMT_NUMERIC)
-                       sprintf(buf, "%s", ip6addr_to_numeric(&fw->ipv6.dst));
+                       strcpy(buf, xtables_ip6addr_to_numeric(&fw->ipv6.dst));
                else
-                       sprintf(buf, "%s", ip6addr_to_anyname(&fw->ipv6.dst));
-               strcat(buf, ip6mask_to_numeric(&fw->ipv6.dmsk));
+                       strcpy(buf, xtables_ip6addr_to_anyname(&fw->ipv6.dst));
+               strcat(buf, xtables_ip6mask_to_numeric(&fw->ipv6.dmsk));
                printf(FMT("%-19s ","-> %s"), buf);
        }
 
index 9adc20938255a3492d73bccf46d9e325d5331b66..d3906fc9a3b684f7738617ae3d4ad0f0c4009cf0 100644 (file)
@@ -803,10 +803,10 @@ print_firewall(const struct ipt_entry *fw,
                printf(FMT("%-19s ","%s "), "anywhere");
        else {
                if (format & FMT_NUMERIC)
-                       sprintf(buf, "%s", ipaddr_to_numeric(&fw->ip.src));
+                       strcpy(buf, xtables_ipaddr_to_numeric(&fw->ip.src));
                else
-                       sprintf(buf, "%s", ipaddr_to_anyname(&fw->ip.src));
-               strcat(buf, ipmask_to_numeric(&fw->ip.smsk));
+                       strcpy(buf, xtables_ipaddr_to_anyname(&fw->ip.src));
+               strcat(buf, xtables_ipmask_to_numeric(&fw->ip.smsk));
                printf(FMT("%-19s ","%s "), buf);
        }
 
@@ -815,10 +815,10 @@ print_firewall(const struct ipt_entry *fw,
                printf(FMT("%-19s ","-> %s"), "anywhere");
        else {
                if (format & FMT_NUMERIC)
-                       sprintf(buf, "%s", ipaddr_to_numeric(&fw->ip.dst));
+                       strcpy(buf, xtables_ipaddr_to_numeric(&fw->ip.dst));
                else
-                       sprintf(buf, "%s", ipaddr_to_anyname(&fw->ip.dst));
-               strcat(buf, ipmask_to_numeric(&fw->ip.dmsk));
+                       strcpy(buf, xtables_ipaddr_to_anyname(&fw->ip.dst));
+               strcat(buf, xtables_ipmask_to_numeric(&fw->ip.dmsk));
                printf(FMT("%-19s ","-> %s"), buf);
        }
 
index 3ffefa2207ac208c817941a1e09f7333d01c8f16..07275f6e6cf374edb63bb4c134601d1b8149dc5f 100644 (file)
--- a/xtables.c
+++ b/xtables.c
@@ -748,7 +748,7 @@ void xtables_param_act(unsigned int status, const char *p1, ...)
        va_end(args);
 }
 
-const char *ipaddr_to_numeric(const struct in_addr *addrp)
+const char *xtables_ipaddr_to_numeric(const struct in_addr *addrp)
 {
        static char buf[20];
        const unsigned char *bytep = (const void *)&addrp->s_addr;
@@ -778,7 +778,7 @@ static const char *ipaddr_to_network(const struct in_addr *addr)
        return NULL;
 }
 
-const char *ipaddr_to_anyname(const struct in_addr *addr)
+const char *xtables_ipaddr_to_anyname(const struct in_addr *addr)
 {
        const char *name;
 
@@ -786,10 +786,10 @@ const char *ipaddr_to_anyname(const struct in_addr *addr)
            (name = ipaddr_to_network(addr)) != NULL)
                return name;
 
-       return ipaddr_to_numeric(addr);
+       return xtables_ipaddr_to_numeric(addr);
 }
 
-const char *ipmask_to_numeric(const struct in_addr *mask)
+const char *xtables_ipmask_to_numeric(const struct in_addr *mask)
 {
        static char buf[20];
        uint32_t maskaddr, bits;
@@ -809,7 +809,7 @@ const char *ipmask_to_numeric(const struct in_addr *mask)
                sprintf(buf, "/%d", i);
        else
                /* mask was not a decent combination of 1's and 0's */
-               sprintf(buf, "/%s", ipaddr_to_numeric(mask));
+               sprintf(buf, "/%s", xtables_ipaddr_to_numeric(mask));
 
        return buf;
 }
@@ -987,7 +987,7 @@ void ipparse_hostnetworkmask(const char *name, struct in_addr **addrpp,
        }
 }
 
-const char *ip6addr_to_numeric(const struct in6_addr *addrp)
+const char *xtables_ip6addr_to_numeric(const struct in6_addr *addrp)
 {
        /* 0000:0000:0000:0000:0000:000.000.000.000
         * 0000:0000:0000:0000:0000:0000:0000:0000 */
@@ -1020,14 +1020,14 @@ static const char *ip6addr_to_host(const struct in6_addr *addr)
        return hostname;
 }
 
-const char *ip6addr_to_anyname(const struct in6_addr *addr)
+const char *xtables_ip6addr_to_anyname(const struct in6_addr *addr)
 {
        const char *name;
 
        if ((name = ip6addr_to_host(addr)) != NULL)
                return name;
 
-       return ip6addr_to_numeric(addr);
+       return xtables_ip6addr_to_numeric(addr);
 }
 
 static int ip6addr_prefix_length(const struct in6_addr *k)
@@ -1054,14 +1054,14 @@ static int ip6addr_prefix_length(const struct in6_addr *k)
        return bits;
 }
 
-const char *ip6mask_to_numeric(const struct in6_addr *addrp)
+const char *xtables_ip6mask_to_numeric(const struct in6_addr *addrp)
 {
        static char buf[50+2];
        int l = ip6addr_prefix_length(addrp);
 
        if (l == -1) {
                strcpy(buf, "/");
-               strcat(buf, ip6addr_to_numeric(addrp));
+               strcat(buf, xtables_ip6addr_to_numeric(addrp));
                return buf;
        }
        sprintf(buf, "/%d", l);