summaryrefslogtreecommitdiffstats
path: root/src/parser_json.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2018-08-29 16:23:27 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-08-30 12:19:36 +0200
commit90d4ee087171e75d5313359ad6b6f1341e51ddc5 (patch)
tree59572c39aa334813b9b090fa46a57fedf9ff5aac /src/parser_json.c
parent8f6e1c37e3e74e1fd490a0de5360ff1467c521cd (diff)
JSON: Make match op mandatory, introduce 'in' operator
This special operator is required for cases where missing operator does not lead to same results as equal operator, i.e. with bitmasks on RHS. 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.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/parser_json.c b/src/parser_json.c
index 2f7e0a3e..6870434e 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1363,24 +1363,24 @@ static struct stmt *json_parse_match_stmt(struct json_ctx *ctx,
const char *opstr = NULL;
enum ops op;
- if (json_unpack_err(ctx, value, "{s:o, s:o}",
+ if (json_unpack_err(ctx, value, "{s:o, s:o, s:s}",
"left", &jleft,
- "right", &jright))
+ "right", &jright,
+ "op", &opstr))
return NULL;
- json_unpack(value, "{s:s}", "op", &opstr);
- if (opstr) {
- for (op = OP_INVALID; op < __OP_MAX; op++) {
- if (expr_op_symbols[op] &&
- !strcmp(opstr, expr_op_symbols[op]))
- break;
- }
- if (op == __OP_MAX) {
+ for (op = OP_INVALID; op < __OP_MAX; op++) {
+ if (expr_op_symbols[op] &&
+ !strcmp(opstr, expr_op_symbols[op]))
+ break;
+ }
+ if (op == __OP_MAX) {
+ if (!strcmp(opstr, "in")) {
+ op = OP_IMPLICIT;
+ } else {
json_error(ctx, "Unknown relational op '%s'.", opstr);
return NULL;
}
- } else {
- op = OP_IMPLICIT;
}
left = json_parse_expr(ctx, jleft);