From: Denis Ovsienko Date: Fri, 21 Mar 2025 12:11:59 +0000 (+0000) Subject: Make pcap_compile() error messages more uniform and consistent. X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/5f8382bb9c6ffbceae33efd05a58a92a32307b00 Make pcap_compile() error messages more uniform and consistent. In the grammar say "qualifier" rather than "modifier" to match the prose in pcap-filter(7) better (this reduces the terminology inconsistency described in GitHub bug report #125), also spell IPv4/IPv6 for clarity. --- diff --git a/CHANGES b/CHANGES index 83d7dd15..d0def799 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group The Riverbed AirPcap Product has reached End of Availability (EOA) as of December 31, 2017 Mind netmap support in pcap_lib_version(). + Make pcap_compile() error messages more uniform and consistent. Link-layer types: Add LINKTYPE_ETW/DLT_ETW. Add LINKTYPE_NETANALYZER_NG/DLT_NETANALYZER_NG (pull request diff --git a/grammar.y.in b/grammar.y.in index 4df43396..b312fca2 100644 --- a/grammar.y.in +++ b/grammar.y.in @@ -454,16 +454,16 @@ nid: ID { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$. /* Check whether HID/NUM is being used when appropriate */ $$.q = $0.q; if ($$.q.addr == Q_PORT) { - bpf_set_error(cstate, "'port' modifier applied to IP address and prefix length"); + bpf_set_error(cstate, "'port' qualifier applied to IPv4 address and prefix length"); YYABORT; } else if ($$.q.addr == Q_PORTRANGE) { - bpf_set_error(cstate, "'portrange' modifier applied to IP address and prefix length"); + bpf_set_error(cstate, "'portrange' qualifier applied to IPv4 address and prefix length"); YYABORT; } else if ($$.q.addr == Q_PROTO) { - bpf_set_error(cstate, "'proto' modifier applied to IP address and prefix length"); + bpf_set_error(cstate, "'proto' qualifier applied to IPv4 address and prefix length"); YYABORT; } else if ($$.q.addr == Q_PROTOCHAIN) { - bpf_set_error(cstate, "'protochain' modifier applied to IP address and prefix length"); + bpf_set_error(cstate, "'protochain' qualifier applied to IPv4 address and prefix length"); YYABORT; } CHECK_PTR_VAL(($$.b = gen_mcode(cstate, $1, NULL, $3, $$.q))); @@ -473,16 +473,16 @@ nid: ID { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$. /* Check whether HID mask HID is being used when appropriate */ $$.q = $0.q; if ($$.q.addr == Q_PORT) { - bpf_set_error(cstate, "'port' modifier applied to IP address and netmask"); + bpf_set_error(cstate, "'port' qualifier applied to IPv4 address and netmask"); YYABORT; } else if ($$.q.addr == Q_PORTRANGE) { - bpf_set_error(cstate, "'portrange' modifier applied to IP address and netmask"); + bpf_set_error(cstate, "'portrange' qualifier applied to IPv4 address and netmask"); YYABORT; } else if ($$.q.addr == Q_PROTO) { - bpf_set_error(cstate, "'proto' modifier applied to IP address and netmask"); + bpf_set_error(cstate, "'proto' qualifier applied to IPv4 address and netmask"); YYABORT; } else if ($$.q.addr == Q_PROTOCHAIN) { - bpf_set_error(cstate, "'protochain' modifier applied to IP address and netmask"); + bpf_set_error(cstate, "'protochain' qualifier applied to IPv4 address and netmask"); YYABORT; } CHECK_PTR_VAL(($$.b = gen_mcode(cstate, $1, $3, 0, $$.q))); @@ -492,16 +492,16 @@ nid: ID { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$. /* Check whether HID is being used when appropriate */ $$.q = $0.q; if ($$.q.addr == Q_PORT) { - bpf_set_error(cstate, "'port' modifier applied to IP address"); + bpf_set_error(cstate, "'port' qualifier applied to IPv4 address"); YYABORT; } else if ($$.q.addr == Q_PORTRANGE) { - bpf_set_error(cstate, "'portrange' modifier applied to IP address"); + bpf_set_error(cstate, "'portrange' qualifier applied to IPv4 address"); YYABORT; } else if ($$.q.addr == Q_PROTO) { - bpf_set_error(cstate, "'proto' modifier applied to IP address"); + bpf_set_error(cstate, "'proto' qualifier applied to IPv4 address"); YYABORT; } else if ($$.q.addr == Q_PROTOCHAIN) { - bpf_set_error(cstate, "'protochain' modifier applied to IP address"); + bpf_set_error(cstate, "'protochain' qualifier applied to IPv4 address"); YYABORT; } CHECK_PTR_VAL(($$.b = gen_ncode(cstate, $1, 0, $$.q))); @@ -512,16 +512,16 @@ nid: ID { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$. /* Check whether HID6/NUM is being used when appropriate */ $$.q = $0.q; if ($$.q.addr == Q_PORT) { - bpf_set_error(cstate, "'port' modifier applied to IP address and prefix length"); + bpf_set_error(cstate, "'port' qualifier applied to IPv6 address and prefix length"); YYABORT; } else if ($$.q.addr == Q_PORTRANGE) { - bpf_set_error(cstate, "'portrange' modifier applied to IP address and prefix length"); + bpf_set_error(cstate, "'portrange' qualifier applied to IPv6 address and prefix length"); YYABORT; } else if ($$.q.addr == Q_PROTO) { - bpf_set_error(cstate, "'proto' modifier applied to IP address and prefix length "); + bpf_set_error(cstate, "'proto' qualifier applied to IPv6 address and prefix length "); YYABORT; } else if ($$.q.addr == Q_PROTOCHAIN) { - bpf_set_error(cstate, "'protochain' modifier applied to IP address and prefix length"); + bpf_set_error(cstate, "'protochain' qualifier applied to IPv6 address and prefix length"); YYABORT; } CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, $3, $$.q))); @@ -537,16 +537,16 @@ nid: ID { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$. /* Check whether HID6 is being used when appropriate */ $$.q = $0.q; if ($$.q.addr == Q_PORT) { - bpf_set_error(cstate, "'port' modifier applied to IP address"); + bpf_set_error(cstate, "'port' qualifier applied to IPv6 address"); YYABORT; } else if ($$.q.addr == Q_PORTRANGE) { - bpf_set_error(cstate, "'portrange' modifier applied to IP address"); + bpf_set_error(cstate, "'portrange' qualifier applied to IPv6 address"); YYABORT; } else if ($$.q.addr == Q_PROTO) { - bpf_set_error(cstate, "'proto' modifier applied to 'ip6addr/prefixlen"); + bpf_set_error(cstate, "'proto' qualifier applied to 'ip6addr/prefixlen"); YYABORT; } else if ($$.q.addr == Q_PROTOCHAIN) { - bpf_set_error(cstate, "'protochain' modifier applied to IP address"); + bpf_set_error(cstate, "'protochain' qualifier applied to IPv6 address"); YYABORT; } CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, 128, $$.q))); diff --git a/testprogs/TESTrun b/testprogs/TESTrun index b94a5799..73301806 100755 --- a/testprogs/TESTrun +++ b/testprogs/TESTrun @@ -11445,7 +11445,7 @@ my @reject_tests = ( name => 'proto_1_2_3_4', DLT => 'RAW', expr => 'proto 1.2.3.4', - errstr => '\'proto\' modifier applied to IP address', + errstr => '\'proto\' qualifier applied to IPv4 address', }, # In the tests below the hostname normally should not matter because the # lookup would be made not in the IPv4/IPv6 space, or not at all. Still