diff options
author | Phil Sutter <phil@nwl.cc> | 2018-08-29 16:23:23 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-08-30 12:19:36 +0200 |
commit | 8125785d5c5d35ec275e508166091d5472748bc1 (patch) | |
tree | f95de547642eab67d12762a5297645e80ffa22c3 /src/parser_json.c | |
parent | 2a4a5a2c8ae21f2bcf7e81b5eafea91d799ee88a (diff) |
JSON: Review verdict statement and expression
Change jump and goto verdicts to become extensible by dedicating an
object for the target parameter.
While being at it, drop break and queue verdict expressions since they
don't seem to exist, no idea where I got those from in the first place.
For queue, there is a dedicated expression at least.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_json.c')
-rw-r--r-- | src/parser_json.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/parser_json.c b/src/parser_json.c index 88390432..dd21d428 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -1031,27 +1031,25 @@ static struct expr *json_parse_verdict_expr(struct json_ctx *ctx, bool chain; } verdict_tbl[] = { { NFT_CONTINUE, "continue", false }, - { NFT_BREAK, "break", false }, { NFT_JUMP, "jump", true }, { NFT_GOTO, "goto", true }, { NFT_RETURN, "return", false }, { NF_ACCEPT, "accept", false }, { NF_DROP, "drop", false }, - { NF_QUEUE, "queue", false }, }; const char *chain = NULL; unsigned int i; - json_unpack(root, "s", &chain); + json_unpack(root, "{s:s}", "target", &chain); for (i = 0; i < array_size(verdict_tbl); i++) { if (strcmp(type, verdict_tbl[i].name)) continue; - if (verdict_tbl[i].chain && !chain) { - json_error(ctx, "Verdict %s needs chain argument.", type); + if (verdict_tbl[i].chain && + json_unpack_err(ctx, root, "{s:s}", "target", &chain)) return NULL; - } + return verdict_expr_alloc(int_loc, verdict_tbl[i].verdict, chain); } |