diff options
Diffstat (limited to 'src/payload.c')
-rw-r--r-- | src/payload.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/src/payload.c b/src/payload.c index 140ca50a..5de3d320 100644 --- a/src/payload.c +++ b/src/payload.c @@ -407,7 +407,6 @@ static int payload_add_dependency(struct eval_ctx *ctx, const struct proto_hdr_template *tmpl; struct expr *dep, *left, *right; struct proto_ctx *pctx; - unsigned int stmt_len; struct stmt *stmt; int protocol; @@ -429,15 +428,9 @@ static int payload_add_dependency(struct eval_ctx *ctx, dep = relational_expr_alloc(&expr->location, OP_EQ, left, right); - stmt_len = ctx->stmt_len; - ctx->stmt_len = 0; - stmt = expr_stmt_alloc(&dep->location, dep); - if (stmt_evaluate(ctx, stmt) < 0) { - return expr_error(ctx->msgs, expr, - "dependency statement is invalid"); - } - ctx->stmt_len = stmt_len; + if (stmt_dependency_evaluate(ctx, stmt) < 0) + return -1; if (ctx->inner_desc) { if (tmpl->meta_key) @@ -547,7 +540,6 @@ int payload_gen_dependency(struct eval_ctx *ctx, const struct expr *expr, const struct hook_proto_desc *h; const struct proto_desc *desc; struct proto_ctx *pctx; - unsigned int stmt_len; struct stmt *stmt; uint16_t type; @@ -564,17 +556,11 @@ int payload_gen_dependency(struct eval_ctx *ctx, const struct expr *expr, "protocol specification is invalid " "for this family"); - stmt_len = ctx->stmt_len; - ctx->stmt_len = 0; - stmt = meta_stmt_meta_iiftype(&expr->location, type); - if (stmt_evaluate(ctx, stmt) < 0) { - return expr_error(ctx->msgs, expr, - "dependency statement is invalid"); - } - *res = stmt; + if (stmt_dependency_evaluate(ctx, stmt) < 0) + return -1; - ctx->stmt_len = stmt_len; + *res = stmt; return 0; } @@ -1442,9 +1428,8 @@ int payload_gen_icmp_dependency(struct eval_ctx *ctx, const struct expr *expr, pctx->th_dep.icmp.type = type; - if (stmt_evaluate(ctx, stmt) < 0) - return expr_error(ctx->msgs, expr, - "icmp dependency statement is invalid"); + if (stmt_dependency_evaluate(ctx, stmt) < 0) + return -1; done: *res = stmt; return 0; |