summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2015-12-28 10:51:43 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-01-03 20:53:37 +0100
commit22c66b3af76c2bc2c720013ffa0100aae7c97cbe (patch)
treecf35a403f9e80d4cbdb734f84d0b18c8c99c5c02
parenta3e60492a684be09374d0649735da42bdadc6b48 (diff)
parser: add redirect constant to rhs_expr rule
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>
-rw-r--r--include/datatype.h1
-rw-r--r--src/parser_bison.y7
-rw-r--r--src/proto.c2
3 files changed, 9 insertions, 1 deletions
diff --git a/include/datatype.h b/include/datatype.h
index 07fedce8..91ca2dd1 100644
--- a/include/datatype.h
+++ b/include/datatype.h
@@ -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;
diff --git a/src/parser_bison.y b/src/parser_bison.y
index be1c7403..d42bd2f8 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -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; }
diff --git a/src/proto.c b/src/proto.c
index 3282271f..65ee158f 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -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",