]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser: add redirect constant to rhs_expr rule
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 28 Dec 2015 09:51:43 +0000 (10:51 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 3 Jan 2016 19:53:37 +0000 (20:53 +0100)
So we can use the 'redirect' reserve word as constant from the rhs
expression. Thus, we can use it as icmp type.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/datatype.h
src/parser_bison.y
src/proto.c

index 07fedce8f451f5407c0f3ceae71b77958af9bbb1..91ca2dd127bb7a21e3b355a5fbc99c60fb009ef2 100644 (file)
@@ -207,6 +207,7 @@ extern const struct datatype arphrd_type;
 extern const struct datatype inet_protocol_type;
 extern const struct datatype inet_service_type;
 extern const struct datatype mark_type;
+extern const struct datatype icmp_type_type;
 extern const struct datatype icmp_code_type;
 extern const struct datatype icmpv6_code_type;
 extern const struct datatype icmpx_code_type;
index be1c74030d06e67765dd157c173627fc972b5919..d42bd2f84a16141809a68e78fbbc75f0256aaec7 100644 (file)
@@ -2101,6 +2101,13 @@ primary_rhs_expr :       symbol_expr             { $$ = $1; }
                                                         BYTEORDER_HOST_ENDIAN,
                                                         sizeof(data) * BITS_PER_BYTE, &data);
                        }
+                       |       REDIRECT
+                       {
+                               uint8_t data = ICMP_REDIRECT;
+                               $$ = constant_expr_alloc(&@$, &icmp_type_type,
+                                                        BYTEORDER_HOST_ENDIAN,
+                                                        sizeof(data) * BITS_PER_BYTE, &data);
+                       }
                        ;
 
 relational_op          :       EQ              { $$ = OP_EQ; }
index 3282271fa41d8878c9e7e476f9ccefe353321540..65ee158f41a5af2a2258ab5d1173e20e47b2916e 100644 (file)
@@ -303,7 +303,7 @@ static const struct symbol_table icmp_type_tbl = {
        },
 };
 
-static const struct datatype icmp_type_type = {
+const struct datatype icmp_type_type = {
        .type           = TYPE_ICMP_TYPE,
        .name           = "icmp_type",
        .desc           = "ICMP type",