expression: Show the base which pre-defined constants are displayed
PATCH 1/1 expression: Show the base which pre-defined constants are displayed
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 <[email protected]>
--- src/ct.c | 3 +++ src/datatype.c | 4 ++++ src/expression.c | 6 +++++- src/exthdr.c | 1 + src/fib.c | 1 + src/meta.c | 2 ++ src/proto.c | 8 ++++++++ 7 files changed, 24 insertions(+), 1 deletion(-)
src/ct.c +3 -0
@@ -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),
src/datatype.c +4 -0
@@ -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 ),
src/expression.c +5 -1
@@ -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); }
src/exthdr.c +1 -0
@@ -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 ),
src/fib.c +1 -0
@@ -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 ),
src/meta.c +2 -0
@@ -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 */
src/proto.c +8 -0
@@ -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 )),
Signature · 1 line
2.7.4
Quoted 4 lines · Elise Lennion
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.
Applied, thanks Elise.