summaryrefslogtreecommitdiffstats
path: root/src/parser_json.c
diff options
context:
space:
mode:
authorFernando Fernandez Mancera <ffmancera@riseup.net>2019-05-24 15:06:47 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-05-24 21:29:54 +0200
commitf1e8a129ee428419a0d5a45a2f410e8e4008d109 (patch)
tree7216ec99ab5873ca6706c766a04b4d0209efef90 /src/parser_json.c
parent4b0f2a712b5792d2842d89fe68d4230e0eb05c7e (diff)
src: Introduce chain_expr in jump and goto statements
Introduce expressions as a chain in jump and goto statements. This is going to be used to support variables as a chain in the following patches. Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_json.c')
-rw-r--r--src/parser_json.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/parser_json.c b/src/parser_json.c
index 1b3e0862..80f17d85 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1068,10 +1068,16 @@ static struct expr *json_parse_verdict_expr(struct json_ctx *ctx,
{ NF_ACCEPT, "accept", false },
{ NF_DROP, "drop", false },
};
+ struct expr *chain_expr = NULL;
const char *chain = NULL;
unsigned int i;
json_unpack(root, "{s:s}", "target", &chain);
+ if (!chain)
+ chain_expr = constant_expr_alloc(int_loc, &string_type,
+ BYTEORDER_HOST_ENDIAN,
+ NFT_CHAIN_MAXNAMELEN *
+ BITS_PER_BYTE, chain);
for (i = 0; i < array_size(verdict_tbl); i++) {
if (strcmp(type, verdict_tbl[i].name))
@@ -1082,8 +1088,7 @@ static struct expr *json_parse_verdict_expr(struct json_ctx *ctx,
return NULL;
return verdict_expr_alloc(int_loc,
- verdict_tbl[i].verdict,
- chain ? xstrdup(chain) : NULL);
+ verdict_tbl[i].verdict, chain_expr);
}
json_error(ctx, "Unknown verdict '%s'.", type);
return NULL;