summaryrefslogtreecommitdiffstats
path: root/src/evaluate.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2018-08-24 09:52:17 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-08-24 09:52:17 +0200
commit0e90798e98121abab274434ec60f0b873f510021 (patch)
treeea0785039aafd7129fa7e39e6df0778cd0a9fcf7 /src/evaluate.c
parent03302da063b032e531d8c748d698f03667658645 (diff)
src: simplify map statement
Instead of using the map expression, store dynamic key and data separately since they need special handling than constant maps. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r--src/evaluate.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index 3f15b322..9bc67d8f 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -2714,8 +2714,31 @@ static int stmt_evaluate_set(struct eval_ctx *ctx, struct stmt *stmt)
static int stmt_evaluate_map(struct eval_ctx *ctx, struct stmt *stmt)
{
- if (expr_evaluate(ctx, &stmt->map.map->map) < 0)
+ expr_set_context(&ctx->ectx, NULL, 0);
+ if (expr_evaluate(ctx, &stmt->map.set) < 0)
return -1;
+ if (stmt->map.set->ops->type != EXPR_SET_REF)
+ return expr_error(ctx->msgs, stmt->map.set,
+ "Expression does not refer to a set");
+
+ if (stmt_evaluate_arg(ctx, stmt,
+ stmt->map.set->set->key->dtype,
+ stmt->map.set->set->key->len,
+ stmt->map.set->set->key->byteorder,
+ &stmt->map.key) < 0)
+ return -1;
+ if (expr_is_constant(stmt->map.key))
+ return expr_error(ctx->msgs, stmt->map.key,
+ "Key expression can not be constant");
+ if (stmt->map.key->comment != NULL)
+ return expr_error(ctx->msgs, stmt->map.key,
+ "Key expression comments are not supported");
+ if (expr_is_constant(stmt->map.data))
+ return expr_error(ctx->msgs, stmt->map.data,
+ "Data expression can not be constant");
+ if (stmt->map.data->comment != NULL)
+ return expr_error(ctx->msgs, stmt->map.data,
+ "Data expression comments are not supported");
return 0;
}