Skip to contentSkip to conversation

nftables: add additional --numeric level

PATCH Applied Phil Oester 2 participants 2 messages Aug 15, 2013 – Aug 22, 2013 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nftables: add additional --numeric level

Personally, I like seeing ports and IPs numerically, but prefer protocols to be shown by name. As such, add a third --numeric level which will show protocols by number, splitting them out from ports.

-n/--numeric When specified once, show network addresses numerically.
When specified twice, also show Internet services, user IDs and group IDs numerically.
When specified thrice, also show protocols numerically.

Phil

include/nftables.h +1 -0
index ec21d37..12f3c49 100644
@@ -8,6 +8,7 @@
 enum numeric_level {
 	NUMERIC_NONE,
 	NUMERIC_ADDR,
+	NUMERIC_PORT,
 	NUMERIC_ALL,
 };
 
src/datatype.c +1 -1
index 55368ee..243760d 100644
@@ -487,7 +487,7 @@ static void inet_service_type_print(const struct expr *expr)
 	sin.sin_port = mpz_get_be16(expr->value);
 	err = getnameinfo((struct sockaddr *)&sin, sizeof(sin), NULL, 0,
 			  buf, sizeof(buf),
-			  numeric_output < NUMERIC_ALL ? 0 : NI_NUMERICSERV);
+			  numeric_output < NUMERIC_PORT ? 0 : NI_NUMERICSERV);
 	if (err != 0) {
 		getnameinfo((struct sockaddr *)&sin, sizeof(sin), NULL,
 			    0, buf, sizeof(buf), NI_NUMERICSERV);
src/main.c +3 -2
index 48d4e03..1a40b9e 100644
@@ -104,8 +104,9 @@ static void show_help(const char *name)
 "  -i/--interactive		Read input from interactive CLI\n"
 "\n"
 "  -n/--numeric			When specified once, show network addresses numerically.\n"
-"  				When specified twice, also show Internet protocols,\n"
-"				Internet services, user IDs and group IDs numerically.\n"
+"  				When specified twice, also show Internet services,\n"
+"				user IDs and group IDs numerically.\n"
+"				When specified thrice, also show protocols numerically.\n"
 "  -a/--handle			Output rule handle.\n"
 "  -I/--includepath <directory>	Add <directory> to the paths searched for include files.\n"
 #ifdef DEBUG
maintainer Applied
#1 lore raw
Quoted 8 lines · Phil Oester

Personally, I like seeing ports and IPs numerically, but prefer protocols to be shown by name. As such, add a third --numeric level which will show protocols by number, splitting them out from ports.

-n/--numeric When specified once, show network addresses numerically.
When specified twice, also show Internet services, user IDs and group IDs numerically.
When specified thrice, also show protocols numerically.

Applied, thanks Phil.