dfilter: Clean up scanner code

Clean up some issues flagged by a linter.

Remove hyphen from pattern names and remove an unused start condition.
This commit is contained in:
João Valverde 2022-12-24 11:19:08 +00:00
parent d9a09aa622
commit b9a5009cb2
1 changed files with 10 additions and 11 deletions

View File

@ -121,25 +121,24 @@ MacAddress {hex2}:{hex2}:{hex2}:{hex2}:{hex2}:{hex2}|{hex2}-{hex2}-{hex2}-{hex2}
hex4 [[:xdigit:]]{4}
QuadMacAddress {hex4}\.{hex4}\.{hex4}
dec-octet [0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]
IPv4address {dec-octet}\.{dec-octet}\.{dec-octet}\.{dec-octet}
DecOctet [0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]
IPv4address {DecOctet}\.{DecOctet}\.{DecOctet}\.{DecOctet}
h16 [0-9A-Fa-f]{1,4}
ls32 {h16}:{h16}|{IPv4address}
IPv6address ({h16}:){6}{ls32}|::({h16}:){5}{ls32}|({h16})?::({h16}:){4}{ls32}|(({h16}:){0,1}{h16})?::({h16}:){3}{ls32}|(({h16}:){0,2}{h16})?::({h16}:){2}{ls32}|(({h16}:){0,3}{h16})?::{h16}:{ls32}|(({h16}:){0,4}{h16})?::{ls32}|(({h16}:){0,5}{h16})?::{h16}|(({h16}:){0,6}{h16})?::
v4-cidr-prefix \/[[:digit:]]{1,2}
v6-cidr-prefix \/[[:digit:]]{1,3}
V4CidrPrefix \/[[:digit:]]{1,2}
V6CidrPrefix \/[[:digit:]]{1,3}
colon-bytes {hex2}(:{hex2})+
dot-bytes {hex2}(\.{hex2})+
hyphen-bytes {hex2}(-{hex2})+
ColonBytes {hex2}(:{hex2})+
DotBytes {hex2}(\.{hex2})+
HyphenBytes {hex2}(-{hex2})+
%x RANGE
%x LAYER
%x DQUOTE
%x SQUOTE
%x REFERENCE
%%
@ -423,19 +422,19 @@ hyphen-bytes {hex2}(-{hex2})+
return set_lval_simple(yyextra, TOKEN_UNPARSED, yytext, STTYPE_UNINITIALIZED);
}
{IPv4address}{v4-cidr-prefix}? {
{IPv4address}{V4CidrPrefix}? {
/* IPv4 with or without prefix. */
update_location(yyextra, yytext);
return set_lval_simple(yyextra, TOKEN_UNPARSED, yytext, STTYPE_UNINITIALIZED);
}
{IPv6address}{v6-cidr-prefix}? {
{IPv6address}{V6CidrPrefix}? {
/* IPv6 with or without prefix. */
update_location(yyextra, yytext);
return set_lval_simple(yyextra, TOKEN_UNPARSED, yytext, STTYPE_UNINITIALIZED);
}
:?({colon-bytes}|{dot-bytes}|{hyphen-bytes}) {
:?({ColonBytes}|{DotBytes}|{HyphenBytes}) {
/* Bytes. */
update_location(yyextra, yytext);
if (yytext[0] == ':')