From 4a684c2ee4cdff2c5c6bfa06d93b58cb4e868bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Neira=20Ayuso?= Date: Thu, 27 Jun 2013 21:56:18 +0200 Subject: src: support JSON format in chain, rule and expressions While at it, order possible switch cases of _snprintf. Signed-off-by: Alvaro Neira Ayuso Signed-off-by: Pablo Neira Ayuso --- src/expr/counter.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/expr/counter.c') diff --git a/src/expr/counter.c b/src/expr/counter.c index 77054e2..62bd143 100644 --- a/src/expr/counter.c +++ b/src/expr/counter.c @@ -194,11 +194,14 @@ nft_rule_expr_counter_snprintf(char *buf, size_t len, uint32_t type, struct nft_expr_counter *ctr = (struct nft_expr_counter *)e->data; switch(type) { + case NFT_RULE_O_DEFAULT: + return snprintf(buf, len, "pkts=%lu bytes=%lu ", + ctr->pkts, ctr->bytes); case NFT_RULE_O_XML: return snprintf(buf, len, "%lu%lu", ctr->pkts, ctr->bytes); - case NFT_RULE_O_DEFAULT: - return snprintf(buf, len, "pkts=%lu bytes=%lu ", + case NFT_RULE_O_JSON: + return snprintf(buf, len, "\"pkts\" : %lu, \"bytes\" : %lu", ctr->pkts, ctr->bytes); default: break; -- cgit v1.2.3