diff options
author | Phil Sutter <phil@nwl.cc> | 2018-08-29 16:23:27 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-08-30 12:19:36 +0200 |
commit | 90d4ee087171e75d5313359ad6b6f1341e51ddc5 (patch) | |
tree | 59572c39aa334813b9b090fa46a57fedf9ff5aac /src/json.c | |
parent | 8f6e1c37e3e74e1fd490a0de5360ff1467c521cd (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/json.c')
-rw-r--r-- | src/json.c | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -385,19 +385,10 @@ json_t *binop_expr_json(const struct expr *expr, struct output_ctx *octx) json_t *relational_expr_json(const struct expr *expr, struct output_ctx *octx) { - json_t *tmp; - - tmp = json_pack("{s:o, s:o}", - "left", expr_print_json(expr->left, octx), - "right", expr_print_json(expr->right, octx)); - /* XXX: check taken from binop_expr_print() - * if right is range, op is OP_EQ which in turn crashes nft if fed with it */ - if (expr_op_symbols[expr->op] && - (expr->op != OP_EQ || must_print_eq_op(expr))) - json_object_set_new(tmp, "op", - json_string(expr_op_symbols[expr->op])); - - return json_pack("{s:o}", "match", tmp); + return json_pack("{s:{s:s, s:o, s:o}}", "match", + "op", expr_op_symbols[expr->op] ? : "in", + "left", expr_print_json(expr->left, octx), + "right", expr_print_json(expr->right, octx)); } json_t *range_expr_json(const struct expr *expr, struct output_ctx *octx) |