diff options
author | Florian Westphal <fw@strlen.de> | 2018-08-29 11:37:41 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-08-29 23:55:02 +0200 |
commit | cd11fe1224af5dba5a04aaadf68ad5ca982177f5 (patch) | |
tree | e19bb8695f399fe7be4750fe4e992f274310c05d /src/json.c | |
parent | bb594473acd532aee6a268a6b27fd529ac71d4b5 (diff) |
src: tproxy: add json support
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -1297,6 +1297,32 @@ json_t *connlimit_stmt_json(const struct stmt *stmt, struct output_ctx *octx) return json_pack("{s:o}", "ct count", root); } +json_t *tproxy_stmt_json(const struct stmt *stmt, struct output_ctx *octx) +{ + json_t *root = json_object(); + + if (stmt->tproxy.addr) { + int family; + json_t *tmp; + + family = stmt->tproxy.table_family; + if (family == NFPROTO_INET) + family = stmt->tproxy.family; + + tmp = json_string(family2str(family)); + json_object_set_new(root, "family", tmp); + + tmp = expr_print_json(stmt->tproxy.addr, octx); + json_object_set_new(root, "addr", tmp); + } + + if (stmt->tproxy.port) + json_object_set_new(root, "port", + expr_print_json(stmt->tproxy.port, octx)); + + return json_pack("{s:o}", "tproxy", root); +} + static json_t *table_print_json_full(struct netlink_ctx *ctx, struct table *table) { |