Restore reporting messages for pcap filter issues

This commit is contained in:
Tim Wojtulewicz 2022-10-13 13:41:59 -05:00
parent 5e4db6d0c4
commit 81357853ed
3 changed files with 62 additions and 11 deletions

View file

@ -279,22 +279,33 @@ function install(): bool
return F;
local ts = current_time();
if ( ! Pcap::precompile_pcap_filter(DefaultPcapFilter, tmp_filter) )
{
NOTICE([$note=Compile_Failure,
$msg=fmt("Compiling packet filter failed"),
$sub=tmp_filter]);
local state = Pcap::get_filter_state(DefaultPcapFilter);
local error_string : string;
if ( state == Pcap::fatal )
{
NOTICE([$note=Compile_Failure,
$msg=fmt("Compiling packet filter failed"),
$sub=tmp_filter]);
local error_string = fmt("Bad pcap filter '%s': %s", tmp_filter, Pcap::get_filter_state_string(DefaultPcapFilter));
error_string = fmt("Bad pcap filter '%s': %s", tmp_filter,
Pcap::get_filter_state_string(DefaultPcapFilter));
local pkt_src_error : string = Pcap::error();
if ( pkt_src_error != "no error" )
error_string = pkt_src_error;
if ( network_time() == 0.0 )
Reporter::fatal(error_string);
else
Reporter::warning(error_string);
}
else if ( state == Pcap::warning )
{
error_string = fmt("Warning while compiling pcap filter '%s': %s",
tmp_filter,
Pcap::get_filter_state_string(DefaultPcapFilter));
if ( network_time() == 0.0 )
Reporter::fatal(error_string);
else
Reporter::warning(error_string);
}
}
local diff = current_time()-ts;
if ( diff > max_filter_compile_time )