summaryrefslogtreecommitdiffstats
path: root/src/expr/exthdr.c
diff options
context:
space:
mode:
authorÁlvaro Neira Ayuso <alvaroneay@gmail.com>2013-06-27 21:56:18 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-06-29 11:56:05 +0200
commit4a684c2ee4cdff2c5c6bfa06d93b58cb4e868bf6 (patch)
tree6216e645631bba685f1c17e0cce851d0c1c6c517 /src/expr/exthdr.c
parentcaf4ac2e95a358f5b6ee64c4cc6c6c96a0bff24b (diff)
src: support JSON format in chain, rule and expressions
While at it, order possible switch cases of _snprintf. Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr/exthdr.c')
-rw-r--r--src/expr/exthdr.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c
index a31f079..b4b9c13 100644
--- a/src/expr/exthdr.c
+++ b/src/expr/exthdr.c
@@ -325,6 +325,10 @@ nft_rule_expr_exthdr_snprintf(char *buf, size_t len, uint32_t type,
struct nft_expr_exthdr *exthdr = (struct nft_expr_exthdr *)e->data;
switch(type) {
+ case NFT_RULE_O_DEFAULT:
+ return snprintf(buf, len, "dreg=%u type=%u offset=%u len=%u ",
+ exthdr->dreg, exthdr->type,
+ exthdr->offset, exthdr->len);
case NFT_RULE_O_XML:
return snprintf(buf, len, "<dreg>%u</dreg>"
"<exthdr_type>%s</exthdr_type>"
@@ -333,11 +337,13 @@ nft_rule_expr_exthdr_snprintf(char *buf, size_t len, uint32_t type,
exthdr->dreg,
exthdr_type2str(exthdr->type),
exthdr->offset, exthdr->len);
-
- case NFT_RULE_O_DEFAULT:
- return snprintf(buf, len, "dreg=%u type=%u offset=%u len=%u ",
- exthdr->dreg, exthdr->type,
- exthdr->offset, exthdr->len);
+ case NFT_RULE_O_JSON:
+ return snprintf(buf, len, "\"dreg\" : %u, "
+ "\"exthdr_type\" : \"%s\", \"offset\" : %u, "
+ "\"len\" : %u",
+ exthdr->dreg,
+ exthdr_type2str(exthdr->type),
+ exthdr->offset, exthdr->len);
default:
break;
}