diff options
Diffstat (limited to 'src/expr/counter.c')
-rw-r--r-- | src/expr/counter.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/expr/counter.c b/src/expr/counter.c index f0d7617..d2da9bf 100644 --- a/src/expr/counter.c +++ b/src/expr/counter.c @@ -18,6 +18,7 @@ #include "internal.h" #include <libmnl/libmnl.h> #include <libnftables/expr.h> +#include <libnftables/rule.h> #include "expr_ops.h" struct nft_expr_counter { @@ -130,8 +131,17 @@ nft_rule_expr_counter_snprintf(char *buf, size_t len, uint32_t type, { struct nft_expr_counter *ctr = (struct nft_expr_counter *)e->data; - return snprintf(buf, len, "pkts=%lu bytes=%lu ", - ctr->pkts, ctr->bytes); + switch(type) { + case NFT_RULE_O_XML: + return snprintf(buf, len, "\t\t<pkts>%lu</pkts> <bytes>%lu</bytes> ", + ctr->pkts, ctr->bytes); + case NFT_RULE_O_DEFAULT: + return snprintf(buf, len, "pkts=%lu bytes=%lu ", + ctr->pkts, ctr->bytes); + default: + break; + } + return -1; } struct expr_ops expr_ops_counter = { |