]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expr: add expr_ops_by_type()
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 16 Dec 2019 12:42:21 +0000 (13:42 +0100)
committerFlorian Westphal <fw@strlen.de>
Mon, 16 Dec 2019 16:06:55 +0000 (17:06 +0100)
Fetch expression operation from the expression type.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
include/expression.h
src/expression.c

index 717b675503818dd29ddba518a2b11b9d15cd7cb8..d502fc2a861176495d88b7fdfe8dc991888f9c2b 100644 (file)
@@ -169,6 +169,7 @@ struct expr_ops {
 };
 
 const struct expr_ops *expr_ops(const struct expr *e);
+const struct expr_ops *expr_ops_by_type(enum expr_types etype);
 
 /**
  * enum expr_flags
index 6fa2f1dd9b1204fc374de84326dad885ec5cee4f..a7bbde7eec1ac43ae72920bdda0287a109083ad0 100644 (file)
@@ -1222,3 +1222,15 @@ const struct expr_ops *expr_ops(const struct expr *e)
 
        BUG("Unknown expression type %d\n", e->etype);
 }
+
+const struct expr_ops *expr_ops_by_type(enum expr_types etype)
+{
+       switch (etype) {
+       case EXPR_PAYLOAD:
+               return &payload_expr_ops;
+       default:
+               break;
+       }
+
+       BUG("Unknown expression type %d\n", etype);
+}