diff options
author | Phil Sutter <phil@nwl.cc> | 2021-05-04 13:18:11 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-05-19 11:51:43 +0200 |
commit | fd81d3ec3ae8b8d1d54a708d63b2dab2c8508c90 (patch) | |
tree | 52bcd137ad801030b4421bd077112d0fd7cd09c2 /src | |
parent | 0925d7e214825628e7db4a86d5ebbad578ab0777 (diff) |
json: Simplify non-tcpopt exthdr printing a bit
This was just duplicate code apart from the object's name.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src')
-rw-r--r-- | src/json.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -711,21 +711,17 @@ json_t *exthdr_expr_json(const struct expr *expr, struct output_ctx *octx) return json_pack("{s:o}", "tcp option", root); } - if (expr->exthdr.op == NFT_EXTHDR_OP_IPV4) { - root = json_pack("{s:s}", "name", desc); - if (!is_exists) - json_object_set_new(root, "field", json_string(field)); - - return json_pack("{s:o}", "ip option", root); - } - - root = json_pack("{s:s}", - "name", desc); + root = json_pack("{s:s}", "name", desc); if (!is_exists) json_object_set_new(root, "field", json_string(field)); - return json_pack("{s:o}", "exthdr", root); + switch (expr->exthdr.op) { + case NFT_EXTHDR_OP_IPV4: + return json_pack("{s:o}", "ip option", root); + default: + return json_pack("{s:o}", "exthdr", root); + } } json_t *verdict_expr_json(const struct expr *expr, struct output_ctx *octx) |