summaryrefslogtreecommitdiffstats
path: root/src/evaluate.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-09-24 13:49:05 +0200
committerPatrick McHardy <kaber@trash.net>2014-09-24 13:49:05 +0200
commit30a7eb9eecba7d5f83d28c284948ed7448d28fc0 (patch)
tree90fce3244f1aac276c381c9d12d70865cd908057 /src/evaluate.c
parentd68824c96f2e8cee14b6a505c91fd379b9aa3088 (diff)
queue: clean up queue statement
- Rename keyword tokens to their actual keyword - Change the grammar to follow the standard schema for statements and arguments - Use actual expression for the queue numbers to support using normal range expressions, symbolic expression and so on. - restore comma seperation of flag keywords The result is that its possible to use standard ranges, prefix expressions, symbolic expressions etc for the queue number. We get checks for overflow, negative ranges and so on automatically. The comma seperation of flags is more similar to what we have for other flag values. It is still possible to use spaces, however this could be removed since we never had a release supporting that. Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r--src/evaluate.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index 34558fcb..284ee72a 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1180,6 +1180,19 @@ static int stmt_evaluate_ct(struct eval_ctx *ctx, struct stmt *stmt)
return 0;
}
+static int stmt_evaluate_queue(struct eval_ctx *ctx, struct stmt *stmt)
+{
+ if (stmt->queue.queue != NULL) {
+ expr_set_context(&ctx->ectx, &integer_type, 16);
+ if (expr_evaluate(ctx, &stmt->queue.queue) < 0)
+ return -1;
+ if (!expr_is_constant(stmt->queue.queue))
+ return expr_error(ctx->msgs, stmt->queue.queue,
+ "queue number is not constant");
+ }
+ return 0;
+}
+
static int stmt_evaluate_log(struct eval_ctx *ctx, struct stmt *stmt)
{
if (stmt->log.flags & STMT_LOG_LEVEL &&
@@ -1219,7 +1232,7 @@ static int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt)
case STMT_NAT:
return stmt_evaluate_nat(ctx, stmt);
case STMT_QUEUE:
- return 0;
+ return stmt_evaluate_queue(ctx, stmt);
case STMT_CT:
return stmt_evaluate_ct(ctx, stmt);
default: