From 0dbced3615ffdbb212ba4f791475a7c65a525309 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 16 Jan 2014 16:54:18 +0000 Subject: parser: use symbolic expressions for parsing keywords as protocol values For "meta protocol" and the "meta nfproto" expressions, we need to be able to parse "ip", "ip6", "vlan" and "arp" as protocol values. Since the interpretation depends on the LHS of the relaltional expression, we need to use symbolic expressions instead of constants to defer parsing to the evaluation phase. Signed-off-by: Patrick McHardy --- src/parser.y | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/parser.y b/src/parser.y index 05fe8bcb..fd631368 100644 --- a/src/parser.y +++ b/src/parser.y @@ -1485,10 +1485,9 @@ vlan_hdr_expr : VLAN vlan_hdr_field } | VLAN { - uint16_t data = ETH_P_8021Q; - $$ = constant_expr_alloc(&@$, ðertype_type, - BYTEORDER_HOST_ENDIAN, - sizeof(data) * BITS_PER_BYTE, &data); + $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE, + current_scope(state), + "vlan"); } ; @@ -1504,10 +1503,9 @@ arp_hdr_expr : ARP arp_hdr_field } | ARP { - uint16_t data = ETH_P_ARP; - $$ = constant_expr_alloc(&@$, ðertype_type, - BYTEORDER_HOST_ENDIAN, - sizeof(data) * BITS_PER_BYTE, &data); + $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE, + current_scope(state), + "arp"); } ; @@ -1524,10 +1522,9 @@ ip_hdr_expr : IP ip_hdr_field } | IP { - uint16_t data = ETH_P_IP; - $$ = constant_expr_alloc(&@$, ðertype_type, - BYTEORDER_HOST_ENDIAN, - sizeof(data) * BITS_PER_BYTE, &data); + $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE, + current_scope(state), + "ip"); } ; @@ -1572,10 +1569,9 @@ ip6_hdr_expr : IP6 ip6_hdr_field } | IP6 { - uint16_t data = ETH_P_IPV6; - $$ = constant_expr_alloc(&@$, ðertype_type, - BYTEORDER_HOST_ENDIAN, - sizeof(data) * BITS_PER_BYTE, &data); + $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE, + current_scope(state), + "ip6"); } ; -- cgit v1.2.3