netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nftables: add additional --numeric level
@ 2013-08-15 23:24 Phil Oester
  2013-08-22 11:48 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Oester @ 2013-08-15 23:24 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

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

Signed-off-by: Phil Oester <kernel@linuxace.com>


[-- Attachment #2: patch-nftables-numeric --]
[-- Type: text/plain, Size: 1563 bytes --]

diff --git a/include/nftables.h b/include/nftables.h
index ec21d37..12f3c49 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -8,6 +8,7 @@
 enum numeric_level {
 	NUMERIC_NONE,
 	NUMERIC_ADDR,
+	NUMERIC_PORT,
 	NUMERIC_ALL,
 };
 
diff --git a/src/datatype.c b/src/datatype.c
index 55368ee..243760d 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -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);
diff --git a/src/main.c b/src/main.c
index 48d4e03..1a40b9e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nftables: add additional --numeric level
  2013-08-15 23:24 [PATCH] nftables: add additional --numeric level Phil Oester
@ 2013-08-22 11:48 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2013-08-22 11:48 UTC (permalink / raw)
  To: Phil Oester; +Cc: netfilter-devel

On Thu, Aug 15, 2013 at 04:24:11PM -0700, Phil Oester wrote:
> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-22 11:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-15 23:24 [PATCH] nftables: add additional --numeric level Phil Oester
2013-08-22 11:48 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).