]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: add -p to print layer 4 protocol numerically
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 29 Oct 2018 20:43:25 +0000 (21:43 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 30 Oct 2018 09:29:53 +0000 (10:29 +0100)
We keep printing layer 4 protocols as literals since we do not use
/etc/protocols. Add -p option to print layer 4 protocols numerically.

Acked-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
doc/nft.txt
src/main.c

index 8e18d9085a0d8a7d02a628849a716cd1741f7cb5..cff04a6ae099f4e8a12111558057b15b6c373720 100644 (file)
@@ -9,7 +9,7 @@ nft - Administration tool of the nftables framework for packet filtering and cla
 SYNOPSIS
 --------
 [verse]
-*nft* [ *-nNscaeS* ] [ *-I* 'directory' ] [ *-f* 'filename' | *-i* | 'cmd' ...]
+*nft* [ *-nNscaeSupy* ] [ *-I* 'directory' ] [ *-f* 'filename' | *-i* | 'cmd' ...]
 *nft* *-h*
 *nft* *-v*
 
@@ -53,6 +53,10 @@ For a full summary of options, run *nft --help*.
 *--guid**::
        Translate numeric UID/GID to names as defined by /etc/passwd and /etc/group.
 
+*-p*::
+*--numeric-protocol**::
+       Display layer 4 protocol numerically.
+
 *-y*::
 *--numeric-priority**::
        Display base chain priority numerically.
index 1f01a6c0b528c6b34fb2250df8737638547a2734..9a50f30f850b2ecfaf0fff76e5431647a0713079 100644 (file)
@@ -41,9 +41,10 @@ enum opt_vals {
        OPT_ECHO                = 'e',
        OPT_GUID                = 'u',
        OPT_NUMERIC_PRIO        = 'y',
+       OPT_NUMERIC_PROTO       = 'p',
        OPT_INVALID             = '?',
 };
-#define OPTSTRING      "hvcf:iI:jvnsNaeSupy"
+#define OPTSTRING      "hvcf:iI:jvnsNaeSupyp"
 
 static const struct option options[] = {
        {
@@ -137,6 +138,7 @@ static void show_help(const char *name)
 "  -u, --guid                  Print UID/GID as defined in /etc/passwd and /etc/group.\n"
 "  -N                          Translate IP addresses to names.\n"
 "  -S, --service                       Translate ports to service names as described in /etc/services.\n"
+"  -p, --numeric-protocol      Print layer 4 protocols numerically.\n"
 "  -y, --numeric-priority      Print chain priority numerically.\n"
 "  -a, --handle                        Output rule handle.\n"
 "  -e, --echo                  Echo what has been added, inserted or replaced.\n"
@@ -283,6 +285,9 @@ int main(int argc, char * const *argv)
                case OPT_NUMERIC_PRIO:
                        output_flags |= NFT_CTX_OUTPUT_NUMERIC_PRIO;
                        break;
+               case OPT_NUMERIC_PROTO:
+                       output_flags |= NFT_CTX_OUTPUT_NUMERIC_PROTO;
+                       break;
                case OPT_INVALID:
                        exit(EXIT_FAILURE);
                }