summaryrefslogtreecommitdiffstats
path: root/src/evaluate.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-01-08 13:02:15 +0000
committerPatrick McHardy <kaber@trash.net>2014-01-08 13:02:15 +0000
commit8f86606efe82489945db1706bd1d1a4d524afcad (patch)
tree5a7b5febee4c8190a067b3d1af38fcd5f9172c74 /src/evaluate.c
parentbc3656ad1e5b5812f916e9c9356785c06ce90936 (diff)
nftables: generic procotol contexts
Currently the context of higher layer protocols is specific to payload expressions with some special cases for meta IIFTYPE expressions. This approach has a few shortcomings, concretely there are more expression types which define upper layer protocols like the ct expression and two upcoming new types for the meta expression. Replace the payload context by a generic protocol context to deal with this. This patch just splits off the requires parts from the payload expression without any functional changes, the following patches will add further functionality for other expressions. Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r--src/evaluate.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index d4f83396..112fc944 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -269,7 +269,7 @@ static int expr_evaluate_primary(struct eval_ctx *ctx, struct expr **expr)
static int expr_evaluate_payload(struct eval_ctx *ctx, struct expr **expr)
{
struct expr *payload = *expr;
- enum payload_bases base = payload->payload.base;
+ enum proto_bases base = payload->payload.base;
struct stmt *nstmt;
struct expr *nexpr;
@@ -916,15 +916,15 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)
left->dtype->desc,
right->dtype->desc);
/*
- * Update payload context for payload and meta iiftype equality
- * expressions.
+ * Update protocol context for payload and meta iiftype
+ * equality expressions.
*/
switch (left->ops->type) {
case EXPR_PAYLOAD:
- payload_ctx_update(&ctx->pctx, rel);
+ payload_expr_pctx_update(&ctx->pctx, rel);
break;
case EXPR_META:
- payload_ctx_update_meta(&ctx->pctx, rel);
+ meta_expr_pctx_update(&ctx->pctx, rel);
break;
case EXPR_CONCAT:
return 0;
@@ -1117,7 +1117,7 @@ static int stmt_evaluate_reject(struct eval_ctx *ctx, struct stmt *stmt)
static int stmt_evaluate_nat(struct eval_ctx *ctx, struct stmt *stmt)
{
- struct payload_ctx *pctx = &ctx->pctx;
+ struct proto_ctx *pctx = &ctx->pctx;
int err;
if (stmt->nat.addr != NULL) {
@@ -1133,7 +1133,7 @@ static int stmt_evaluate_nat(struct eval_ctx *ctx, struct stmt *stmt)
}
if (stmt->nat.proto != NULL) {
- if (pctx->protocol[PAYLOAD_BASE_TRANSPORT_HDR].desc == NULL)
+ if (pctx->protocol[PROTO_BASE_TRANSPORT_HDR].desc == NULL)
return stmt_binary_error(ctx, stmt->nat.proto, stmt,
"transport protocol mapping is only "
"valid after transport protocol match");
@@ -1232,7 +1232,7 @@ static int rule_evaluate(struct eval_ctx *ctx, struct rule *rule)
struct stmt *stmt, *tstmt = NULL;
struct error_record *erec;
- payload_ctx_init(&ctx->pctx, rule->handle.family);
+ proto_ctx_init(&ctx->pctx, rule->handle.family);
memset(&ctx->ectx, 0, sizeof(ctx->ectx));
list_for_each_entry(stmt, &rule->stmts, list) {