From: Patrick McHardy Date: Thu, 16 Jan 2014 16:54:18 +0000 (+0000) Subject: parser: use symbolic expressions for parsing keywords as protocol values X-Git-Tag: v0.2~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dbced3;p=thirdparty%2Fnftables.git 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 --- 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"); } ;