]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expression: Show the base which pre-defined constants are displayed
authorElise Lennion <elise.lennion@gmail.com>
Mon, 19 Dec 2016 22:11:04 +0000 (19:11 -0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 20 Dec 2016 19:23:33 +0000 (20:23 +0100)
so the user know how we express it.

The base was added to all symbol tables, which are associated with
datatype->sym_tbl, so they are displayed in the right base.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/ct.c
src/datatype.c
src/expression.c
src/exthdr.c
src/fib.c
src/meta.c
src/proto.c

index e5327539e935a56c47e6aa7296fb21a902f2f980..d0792890a9741c889e0d980526df8fbfd9cf6570 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -33,6 +33,7 @@
 #define CONNLABEL_CONF DEFAULT_INCLUDE_PATH "/connlabel.conf"
 
 static const struct symbol_table ct_state_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("invalid",       NF_CT_STATE_INVALID_BIT),
                SYMBOL("new",           NF_CT_STATE_BIT(IP_CT_NEW)),
@@ -54,6 +55,7 @@ static const struct datatype ct_state_type = {
 };
 
 static const struct symbol_table ct_dir_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("original",      IP_CT_DIR_ORIGINAL),
                SYMBOL("reply",         IP_CT_DIR_REPLY),
@@ -75,6 +77,7 @@ static const struct symbol_table ct_status_tbl = {
        /*
         * There are more, but most of them don't make sense for filtering.
         */
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("expected",      IPS_EXPECTED),
                SYMBOL("seen-reply",    IPS_SEEN_REPLY),
index ec0b12013677dab60687db7811aa41597e5f7026..f5f4f3adc3054dce2384ba7fadebc182317d5a55 100644 (file)
@@ -267,6 +267,7 @@ const struct datatype verdict_type = {
 };
 
 static const struct symbol_table nfproto_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("ipv4",          NFPROTO_IPV4),
                SYMBOL("ipv6",          NFPROTO_IPV6),
@@ -726,6 +727,7 @@ const struct datatype mark_type = {
 };
 
 static const struct symbol_table icmp_code_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("net-unreachable",       ICMP_NET_UNREACH),
                SYMBOL("host-unreachable",      ICMP_HOST_UNREACH),
@@ -749,6 +751,7 @@ const struct datatype icmp_code_type = {
 };
 
 static const struct symbol_table icmpv6_code_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("no-route",              ICMPV6_NOROUTE),
                SYMBOL("admin-prohibited",      ICMPV6_ADM_PROHIBITED),
@@ -771,6 +774,7 @@ const struct datatype icmpv6_code_type = {
 };
 
 static const struct symbol_table icmpx_code_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("port-unreachable",      NFT_REJECT_ICMPX_PORT_UNREACH),
                SYMBOL("admin-prohibited",      NFT_REJECT_ICMPX_ADMIN_PROHIBITED),
index 2aada77d6694a8f01f9695765e6299ecceb8879b..b7403c7009cd0c1e3f46f98b6126026cea0cef43 100644 (file)
@@ -114,7 +114,11 @@ void expr_describe(const struct expr *expr)
        printf("\n");
 
        if (expr->dtype->sym_tbl != NULL) {
-               printf("\npre-defined symbolic constants:\n");
+               printf("\npre-defined symbolic constants ");
+               if (expr->dtype->sym_tbl->base == BASE_DECIMAL)
+                       printf("(in decimal):\n");
+               else
+                       printf("(in hexadecimal):\n");
                symbol_table_print(expr->dtype->sym_tbl, expr->dtype,
                                   expr->byteorder);
        }
index f392cffe35ca8b0071242da7ba53e98d187dfe0c..c641d4a398ad235c3a37ab3d6e569b6bf13d0a3b 100644 (file)
@@ -249,6 +249,7 @@ const struct exthdr_desc exthdr_dst = {
        HDR_TEMPLATE(__name, __dtype, struct ip6_mh, __member)
 
 static const struct symbol_table mh_type_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("binding-refresh-request",       IP6_MH_TYPE_BRR),
                SYMBOL("home-test-init",                IP6_MH_TYPE_HOTI),
index 346cce322da261b73da9965ee6756587eaea126c..c65677c811abce374cb8176e9b9ef71f8ef2b8c2 100644 (file)
--- a/src/fib.c
+++ b/src/fib.c
@@ -27,6 +27,7 @@ static const char *fib_result[NFT_FIB_RESULT_MAX + 1] = {
 };
 
 static const struct symbol_table addrtype_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("unspec",        RTN_UNSPEC),
                SYMBOL("unicast",       RTN_UNICAST),
index 574fc5000c91f47d1182cd232143f2cfe25f4997..cb7c1368e0874efaded65220621cffc8a81d83b8 100644 (file)
@@ -198,6 +198,7 @@ const struct datatype ifindex_type = {
 };
 
 static const struct symbol_table arphrd_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("ether",         ARPHRD_ETHER),
                SYMBOL("ppp",           ARPHRD_PPP),
@@ -326,6 +327,7 @@ static const struct datatype gid_type = {
 };
 
 static const struct symbol_table pkttype_type_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("host", PACKET_HOST),
                SYMBOL("unicast", PACKET_HOST), /* backwards compat */
index 8930bed65891227fa8cf1ebd23b0ac67c6a2d932..fb965304e59d9ccf21d6013e59efb42819a1ab8e 100644 (file)
@@ -303,6 +303,7 @@ const struct proto_desc proto_comp = {
 #include <netinet/ip_icmp.h>
 
 static const struct symbol_table icmp_type_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("echo-reply",                    ICMP_ECHOREPLY),
                SYMBOL("destination-unreachable",       ICMP_DEST_UNREACH),
@@ -391,6 +392,7 @@ const struct proto_desc proto_udplite = {
 #include <netinet/tcp.h>
 
 static const struct symbol_table tcp_flag_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("fin",   TCP_FLAG_FIN),
                SYMBOL("syn",   TCP_FLAG_SYN),
@@ -449,6 +451,7 @@ const struct proto_desc proto_tcp = {
  */
 
 static const struct symbol_table dccp_pkttype_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("request",       DCCP_PKT_REQUEST),
                SYMBOL("response",      DCCP_PKT_RESPONSE),
@@ -514,6 +517,7 @@ const struct proto_desc proto_sctp = {
 #include <netinet/ip.h>
 
 static const struct symbol_table dscp_type_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("cs0",   0x00),
                SYMBOL("cs1",   0x08),
@@ -553,6 +557,7 @@ static const struct datatype dscp_type = {
 };
 
 static const struct symbol_table ecn_type_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("not-ect",       0x00),
                SYMBOL("ect1",          0x01),
@@ -628,6 +633,7 @@ const struct proto_desc proto_ip = {
 #include <netinet/icmp6.h>
 
 static const struct symbol_table icmp6_type_tbl = {
+       .base           = BASE_DECIMAL,
        .symbols        = {
                SYMBOL("destination-unreachable",       ICMP6_DST_UNREACH),
                SYMBOL("packet-too-big",                ICMP6_PACKET_TOO_BIG),
@@ -778,6 +784,7 @@ const struct proto_desc proto_inet_service = {
 #include <net/if_arp.h>
 
 static const struct symbol_table arpop_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("request",       __constant_htons(ARPOP_REQUEST)),
                SYMBOL("reply",         __constant_htons(ARPOP_REPLY)),
@@ -866,6 +873,7 @@ const struct datatype etheraddr_type = {
 };
 
 static const struct symbol_table ethertype_tbl = {
+       .base           = BASE_HEXADECIMAL,
        .symbols        = {
                SYMBOL("ip",            __constant_htons(ETH_P_IP)),
                SYMBOL("arp",           __constant_htons(ETH_P_ARP)),