Skip to contentSkip to conversation

parser: allow for string raw payload base

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 16, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 parser: allow for string raw payload base

Remove new 'ih' token, allow to represent the raw payload base with a string instead.

---
 src/parser_bison.y | 13 +++++++++++--
 src/scanner.l      |  1 -
 2 files changed, 11 insertions(+), 3 deletions(-)
src/parser_bison.y +11 -2
index eb89a58989e2..81d75ecb2fe8 100644
@@ -318,7 +318,6 @@ int nft_lex(void *, void *, void *);
 %token LL_HDR			"ll"
 %token NETWORK_HDR		"nh"
 %token TRANSPORT_HDR		"th"
-%token INNER_HDR		"ih"
 
 %token BRIDGE			"bridge"
 
@@ -5261,7 +5260,17 @@ payload_raw_expr	:	AT	payload_base_spec	COMMA	NUM	COMMA	NUM
 payload_base_spec	:	LL_HDR		{ $$ = PROTO_BASE_LL_HDR; }
 			|	NETWORK_HDR	{ $$ = PROTO_BASE_NETWORK_HDR; }
 			|	TRANSPORT_HDR	{ $$ = PROTO_BASE_TRANSPORT_HDR; }
-			|	INNER_HDR	{ $$ = PROTO_BASE_INNER_HDR; }
+			|	STRING
+			{
+				if (!strcmp($1, "ih")) {
+					$$ = PROTO_BASE_INNER_HDR;
+				} else {
+					erec_queue(error(&@1, "unknown raw payload base"), state->msgs);
+					xfree($1);
+					YYERROR;
+				}
+				xfree($1);
+			}
 			;
 
 eth_hdr_expr		:	ETHER	eth_hdr_field	close_scope_eth
src/scanner.l +0 -1
index 5d263f9dc8b1..6cc7778dd85e 100644
@@ -414,7 +414,6 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 "ll"			{ return LL_HDR; }
 "nh"			{ return NETWORK_HDR; }
 "th"			{ return TRANSPORT_HDR; }
-"ih"			{ return INNER_HDR; }
 
 "bridge"		{ return BRIDGE; }
 
Signature · 1 line
2.30.2