diff options
author | Phil Sutter <phil@nwl.cc> | 2018-06-08 17:27:18 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-06-11 11:31:49 +0200 |
commit | f63b54623fcd1ab7d2f51928571c164409f00175 (patch) | |
tree | 49acf0abdbeb4552f66a720fb5ca76a8ce9930d2 /src/json.c | |
parent | 78f8d8127eac64abb14e1d4a4309b353ba03bdb6 (diff) |
JSON: Support latest enhancements of fwd statement
JSON equivalent of fwd statement was too primitive to support the added
address and family parameters, so make its value an object and accept
the device expression as value of a "dev" property in there. Then add
optional "addr" and "family" properties to it.
While being at it, add a testcase to make sure the extended syntax works
right.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1008,9 +1008,18 @@ json_t *limit_stmt_json(const struct stmt *stmt, struct output_ctx *octx) json_t *fwd_stmt_json(const struct stmt *stmt, struct output_ctx *octx) { - json_t *root; + json_t *root, *tmp; + + root = json_pack("{s:o}", "dev", expr_print_json(stmt->fwd.dev, octx)); + + if (stmt->fwd.addr) { + tmp = json_string(family2str(stmt->fwd.family)); + json_object_set_new(root, "family", tmp); + + tmp = expr_print_json(stmt->fwd.addr, octx); + json_object_set_new(root, "addr", tmp); + } - root = expr_print_json(stmt->fwd.dev, octx); return json_pack("{s:o}", "fwd", root); } |