diff options
author | Phil Sutter <phil@nwl.cc> | 2018-07-19 18:32:05 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-07-19 23:11:03 +0200 |
commit | f3b772c10b782196060fe39ca6da142ba75e43d9 (patch) | |
tree | af2af6d6dd327d65f4301d6402a33e6fc36090b1 /iptables/nft-shared.c | |
parent | fa1681f170e2b8d80d9ef9d4564797f0f5969fd0 (diff) |
xtables: introduce save_chain callback
In preparation for ebtables-save implementation, introduce a callback
for convenient per-family formatting of chains in save output.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/nft-shared.c')
-rw-r--r-- | iptables/nft-shared.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c index 60b539c8..66db7ed1 100644 --- a/iptables/nft-shared.c +++ b/iptables/nft-shared.c @@ -16,6 +16,7 @@ #include <stdbool.h> #include <netdb.h> #include <errno.h> +#include <inttypes.h> #include <xtables.h> @@ -802,6 +803,16 @@ void save_counters(const void *data) (unsigned long long)cs->counters.bcnt); } +void nft_ipv46_save_chain(const struct nftnl_chain *c, const char *policy) +{ + const char *chain = nftnl_chain_get_str(c, NFTNL_CHAIN_NAME); + uint64_t pkts = nftnl_chain_get_u64(c, NFTNL_CHAIN_PACKETS); + uint64_t bytes = nftnl_chain_get_u64(c, NFTNL_CHAIN_BYTES); + + printf(":%s %s [%"PRIu64":%"PRIu64"]\n", + chain, policy ?: "-", pkts, bytes); +} + void save_matches_and_target(struct xtables_rule_match *m, struct xtables_target *target, const char *jumpto, uint8_t flags, const void *fw) |