diff options
author | Eric Jallot <ejallot@gmail.com> | 2019-11-04 21:23:59 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-11-06 12:38:24 +0100 |
commit | 91487a80551ea91714082da41aa49ba52dd6e9bb (patch) | |
tree | 7f9c00b47fe7b3221c9dc9d8ced8f894b8b2566b /src/parser_json.c | |
parent | f5953e519ea8ae4243f58015a1311a3639524648 (diff) |
src: flowtable: add support for delete command by handle
Also, display handle when listing with '-a'.
Signed-off-by: Eric Jallot <ejallot@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_json.c')
-rw-r--r-- | src/parser_json.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/parser_json.c b/src/parser_json.c index 3b86a0ae..031930e2 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -2964,20 +2964,30 @@ static struct cmd *json_parse_cmd_add_flowtable(struct json_ctx *ctx, json_t *devs; int prio; - if (json_unpack_err(ctx, root, "{s:s, s:s, s:s}", + if (json_unpack_err(ctx, root, "{s:s, s:s}", "family", &family, - "table", &h.table.name, - "name", &h.flowtable.name)) + "table", &h.table.name)) + return NULL; + + if (op != CMD_DELETE && + json_unpack_err(ctx, root, "{s:s}", "name", &h.flowtable.name)) { + return NULL; + } else if (op == CMD_DELETE && + json_unpack(root, "{s:s}", "name", &h.flowtable.name) && + json_unpack(root, "{s:I}", "handle", &h.handle.id)) { + json_error(ctx, "Either name or handle required to delete a flowtable."); return NULL; + } if (parse_family(family, &h.family)) { json_error(ctx, "Unknown family '%s'.", family); return NULL; } h.table.name = xstrdup(h.table.name); - h.flowtable.name = xstrdup(h.flowtable.name); + if (h.flowtable.name) + h.flowtable.name = xstrdup(h.flowtable.name); - if (op == CMD_DELETE) + if (op == CMD_DELETE || op == CMD_LIST) return cmd_alloc(op, cmd_obj, &h, int_loc, NULL); if (json_unpack_err(ctx, root, "{s:s, s:I, s:o}", |