Type and variable usage cleanup in Net.h

This commit is contained in:
Tim Wojtulewicz 2019-10-29 16:21:28 -07:00
parent fa9a568e8f
commit eee2abf729
2 changed files with 28 additions and 29 deletions

View file

@ -42,11 +42,11 @@ extern "C" {
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
}
iosource::PktDumper* pkt_dumper = 0;
iosource::PktDumper* pkt_dumper = nullptr;
int reading_live = 0;
int reading_traces = 0;
int have_pending_timers = 0;
bool reading_live = false;
bool reading_traces = false;
bool have_pending_timers = false;
double pseudo_realtime = 0.0;
double network_time = 0.0; // time according to last packet timestamp
// (or current time)
@ -57,11 +57,11 @@ double last_watchdog_proc_time = 0.0; // value of above during last watchdog
bool terminating = false; // whether we're done reading and finishing up
bool is_parsing = false;
const Packet *current_pkt = 0;
const Packet *current_pkt = nullptr;
int current_dispatched = 0;
double current_timestamp = 0.0;
iosource::PktSrc* current_pktsrc = 0;
iosource::IOSource* current_iosrc = 0;
iosource::PktSrc* current_pktsrc = nullptr;
iosource::IOSource* current_iosrc = nullptr;
std::list<ScannedFile> files_scanned;
std::vector<string> sig_files;
@ -153,7 +153,7 @@ void net_init(const std::string& interface,
if ( ! pcap_input_file.empty() )
{
reading_live = pseudo_realtime > 0.0;
reading_traces = 1;
reading_traces = true;
iosource::PktSrc* ps = iosource_mgr->OpenPktSrc(pcap_input_file, false);
assert(ps);
@ -164,8 +164,8 @@ void net_init(const std::string& interface,
}
else if ( ! interface.empty() )
{
reading_live = 1;
reading_traces = 0;
reading_live = true;
reading_traces = false;
iosource::PktSrc* ps = iosource_mgr->OpenPktSrc(interface, true);
assert(ps);
@ -176,11 +176,11 @@ void net_init(const std::string& interface,
}
else
// have_pending_timers = 1, possibly. We don't set
// have_pending_timers = true, possibly. We don't set
// that here, though, because at this point we don't know
// whether the user's zeek_init() event will indeed set
// a timer.
reading_traces = reading_live = 0;
reading_traces = reading_live = false;
if ( pcap_output_file )
{
@ -192,11 +192,10 @@ void net_init(const std::string& interface,
reporter->FatalError("problem opening dump file %s (%s)",
writefile, pkt_dumper->ErrorMsg());
ID* id = global_scope()->Lookup("trace_output_file");
if ( ! id )
reporter->Error("trace_output_file not defined in bro.init");
else
if ( ID* id = global_scope()->Lookup("trace_output_file") )
id->SetVal(new StringVal(writefile));
else
reporter->Error("trace_output_file not defined in bro.init");
}
init_ip_addr_anonymizers();
@ -239,7 +238,7 @@ void net_packet_dispatch(double t, const Packet* pkt, iosource::PktSrc* src_ps)
expire_timers(src_ps);
SegmentProfiler* sp = 0;
SegmentProfiler* sp = nullptr;
if ( load_sample )
{
@ -266,13 +265,13 @@ void net_packet_dispatch(double t, const Packet* pkt, iosource::PktSrc* src_ps)
{
delete sp;
delete sample_logger;
sample_logger = 0;
sample_logger = nullptr;
}
processing_start_time = 0.0; // = "we're not processing now"
current_dispatched = 0;
current_iosrc = 0;
current_pktsrc = 0;
current_iosrc = nullptr;
current_pktsrc = nullptr;
}
void net_run()
@ -299,20 +298,20 @@ void net_run()
loop_counter = 0;
}
#endif
current_iosrc = src;
current_iosrc = nullptr;
auto communication_enabled = broker_mgr->Active();
if ( src )
src->Process(); // which will call net_packet_dispatch()
else if ( reading_live && ! pseudo_realtime)
{ // live but no source is currently active
double ct = current_time();
{
// live but no source is currently active
if ( ! net_is_processing_suspended() )
{
// Take advantage of the lull to get up to
// date on timers and events.
net_update_time(ct);
net_update_time(current_time());
expire_timers();
usleep(1); // Just yield.
}
@ -353,7 +352,7 @@ void net_run()
processing_start_time = 0.0; // = "we're not processing now"
current_dispatched = 0;
current_iosrc = 0;
current_iosrc = nullptr;
if ( signal_val == SIGTERM || signal_val == SIGINT )
// We received a signal while processing the
@ -376,7 +375,7 @@ void net_run()
if ( ! have_active_packet_source )
// Can turn off pseudo realtime now
pseudo_realtime = 0;
pseudo_realtime = 0.0;
}
}