mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 03:58:20 +00:00
Type and variable usage cleanup in Net.h
This commit is contained in:
parent
fa9a568e8f
commit
eee2abf729
2 changed files with 28 additions and 29 deletions
51
src/Net.cc
51
src/Net.cc
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,19 +43,19 @@ inline bool net_is_processing_suspended()
|
|||
{ return _processing_suspended > 0; }
|
||||
|
||||
// Whether we're reading live traffic.
|
||||
extern int reading_live;
|
||||
extern bool reading_live;
|
||||
|
||||
// Same but for reading from traces instead. We have two separate
|
||||
// variables because it's possible that neither is true, and we're
|
||||
// instead just running timers (per the variable after this one).
|
||||
extern int reading_traces;
|
||||
extern bool reading_traces;
|
||||
|
||||
// True if we have timers scheduled for the future on which we need
|
||||
// to wait. "Need to wait" here means that we're running live (though
|
||||
// perhaps not reading_live, but just running in real-time) as opposed
|
||||
// to reading a trace (in which case we don't want to wait in real-time
|
||||
// on future timers).
|
||||
extern int have_pending_timers;
|
||||
extern bool have_pending_timers;
|
||||
|
||||
// If > 0, we are reading from traces but trying to mimic real-time behavior.
|
||||
// (In this case, both reading_traces and reading_live are true.) The value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue