NFT_CTX_OUTPUT_ECHO = (1 << 5),
NFT_CTX_OUTPUT_GUID = (1 << 6),
NFT_CTX_OUTPUT_NUMERIC_PROTO = (1 << 7),
+ NFT_CTX_OUTPUT_NUMERIC_PRIO = (1 << 8),
};
----
The *nft_ctx_output_set_flags*() function sets the output flags setting in 'ctx' to the value of 'val'.
NFT_CTX_OUTPUT_NUMERIC_PROTO::
Display layer 4 protocol numerically.
+NFT_CTX_OUTPUT_NUMERIC_PRIO::
+ Display base chain priority numerically.
=== nft_ctx_output_get_numeric() and nft_ctx_output_set_numeric()
These functions allow control over value representation in library output.
OPT_HANDLE_OUTPUT = 'a',
OPT_ECHO = 'e',
OPT_GUID = 'u',
+ OPT_NUMERIC_PRIO = 'y',
OPT_INVALID = '?',
};
-
-#define OPTSTRING "hvcf:iI:jvnsNaeSu"
+#define OPTSTRING "hvcf:iI:jvnsNaeSupy"
static const struct option options[] = {
{
.name = "guid",
.val = OPT_GUID,
},
+ {
+ .name = "numeric-priority",
+ .val = OPT_NUMERIC_PRIO,
+ },
{
.name = NULL
}
" -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"
+" -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"
" -I, --includepath <directory> Add <directory> to the paths searched for include files. Default is: %s\n"
case OPT_GUID:
output_flags |= NFT_CTX_OUTPUT_GUID;
break;
+ case OPT_NUMERIC_PRIO:
+ output_flags |= NFT_CTX_OUTPUT_NUMERIC_PRIO;
+ break;
case OPT_INVALID:
exit(EXIT_FAILURE);
}
return NF_IP_PRI_LAST;
}
-static const char *prio2str(char *buf, size_t bufsize, int family, int hook,
- int prio, int numeric)
+static const char *prio2str(const struct output_ctx *octx,
+ char *buf, size_t bufsize, int family, int hook,
+ int prio)
{
const struct prio_tag *prio_arr;
const char *std_prio_str;
arr_size = array_size(std_prios);
}
- if (numeric != NFT_NUMERIC_ALL) {
+ if (!nft_output_numeric_prio(octx)) {
for (i = 0; i < arr_size; ++i) {
std_prio = prio_arr[i].val;
std_prio_str = prio_arr[i].str;
if (chain->dev != NULL)
nft_print(octx, " device %s", chain->dev);
nft_print(octx, " priority %s; policy %s;\n",
- prio2str(priobuf, sizeof(priobuf),
+ prio2str(octx, priobuf, sizeof(priobuf),
chain->handle.family, chain->hooknum,
- chain->priority.num, octx->numeric),
+ chain->priority.num),
chain_policy2str(chain->policy));
}
}
if (chain->flags & CHAIN_F_BASECHAIN) {
nft_print(octx, " { type %s hook %s priority %s; policy %s; }",
chain->type, chain->hookstr,
- prio2str(priobuf, sizeof(priobuf),
+ prio2str(octx, priobuf, sizeof(priobuf),
chain->handle.family, chain->hooknum,
- chain->priority.num, octx->numeric),
+ chain->priority.num),
chain_policy2str(chain->policy));
}
if (nft_output_handle(octx))
nft_print(octx, "%s%shook %s priority %s%s",
opts->tab, opts->tab,
hooknum2str(NFPROTO_NETDEV, flowtable->hooknum),
- prio2str(priobuf, sizeof(priobuf), NFPROTO_NETDEV,
- flowtable->hooknum, flowtable->priority.num,
- octx->numeric),
+ prio2str(octx, priobuf, sizeof(priobuf), NFPROTO_NETDEV,
+ flowtable->hooknum, flowtable->priority.num),
opts->stmt_separator);
nft_print(octx, "%s%sdevices = { ", opts->tab, opts->tab);