Move Reporter to zeek namespace

This commit is contained in:
Tim Wojtulewicz 2020-07-20 10:57:36 -07:00
parent 7cedd94ee7
commit bfab224d7c
132 changed files with 1010 additions and 987 deletions

View file

@ -75,7 +75,7 @@ ipaddr32_t AnonymizeIPAddr::Anonymize(ipaddr32_t addr)
// Keep the specified prefix unchanged. // Keep the specified prefix unchanged.
bool AnonymizeIPAddr::PreservePrefix(ipaddr32_t /* input */, int /* num_bits */) bool AnonymizeIPAddr::PreservePrefix(ipaddr32_t /* input */, int /* num_bits */)
{ {
reporter->InternalError("prefix preserving is not supported for the anonymizer"); zeek::reporter->InternalError("prefix preserving is not supported for the anonymizer");
return false; return false;
} }
@ -172,7 +172,7 @@ bool AnonymizeIPAddr_A50::PreservePrefix(ipaddr32_t input, int num_bits)
if ( ! before_anonymization ) if ( ! before_anonymization )
{ {
reporter->Error("prefix perservation specified after anonymization begun"); zeek::reporter->Error("prefix perservation specified after anonymization begun");
return false; return false;
} }
@ -219,7 +219,7 @@ AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::new_node_block()
int block_size = 1024; int block_size = 1024;
Node* block = new Node[block_size]; Node* block = new Node[block_size];
if ( ! block ) if ( ! block )
reporter->InternalError("out of memory!"); zeek::reporter->InternalError("out of memory!");
blocks.push_back(block); blocks.push_back(block);
@ -271,7 +271,7 @@ ipaddr32_t AnonymizeIPAddr_A50::make_output(ipaddr32_t old_output, int swivel) c
AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::make_peer(ipaddr32_t a, Node* n) AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::make_peer(ipaddr32_t a, Node* n)
{ {
if ( a == 0 || a == 0xFFFFFFFFU ) if ( a == 0 || a == 0xFFFFFFFFU )
reporter->InternalError("0.0.0.0 and 255.255.255.255 should never get into the tree"); zeek::reporter->InternalError("0.0.0.0 and 255.255.255.255 should never get into the tree");
// Become a peer. // Become a peer.
// Algorithm: create two nodes, the two peers. Leave orig node as // Algorithm: create two nodes, the two peers. Leave orig node as
@ -354,7 +354,7 @@ AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::find_node(ipaddr32_t a)
} }
} }
reporter->InternalError("out of memory!"); zeek::reporter->InternalError("out of memory!");
return nullptr; return nullptr;
} }
@ -421,14 +421,14 @@ ipaddr32_t zeek::detail::anonymize_ip(ipaddr32_t ip, enum ip_addr_anonymization_
new_ip = ip; new_ip = ip;
else if ( ! ip_anonymizer[method] ) else if ( ! ip_anonymizer[method] )
reporter->InternalError("IP anonymizer not initialized"); zeek::reporter->InternalError("IP anonymizer not initialized");
else else
new_ip = ip_anonymizer[method]->Anonymize(ip); new_ip = ip_anonymizer[method]->Anonymize(ip);
} }
else else
reporter->InternalError("invalid IP anonymization method"); zeek::reporter->InternalError("invalid IP anonymization method");
#ifdef LOG_ANONYMIZATION_MAPPING #ifdef LOG_ANONYMIZATION_MAPPING
log_anonymization_mapping(ip, new_ip); log_anonymization_mapping(ip, new_ip);

View file

@ -15,10 +15,10 @@ void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, cha
char *buf; char *buf;
if ( ! pbuf ) if ( ! pbuf )
reporter->InternalError("nil pointer to encoding result buffer"); zeek::reporter->InternalError("nil pointer to encoding result buffer");
if ( *pbuf && (*pblen % 4 != 0) ) if ( *pbuf && (*pblen % 4 != 0) )
reporter->InternalError("Base64 encode buffer not a multiple of 4"); zeek::reporter->InternalError("Base64 encode buffer not a multiple of 4");
if ( *pbuf ) if ( *pbuf )
{ {
@ -121,7 +121,7 @@ int Base64Converter::Decode(int len, const char* data, int* pblen, char** pbuf)
base64_table = InitBase64Table(alphabet); base64_table = InitBase64Table(alphabet);
if ( ! pbuf ) if ( ! pbuf )
reporter->InternalError("nil pointer to decoding result buffer"); zeek::reporter->InternalError("nil pointer to decoding result buffer");
if ( *pbuf ) if ( *pbuf )
{ {
@ -225,14 +225,14 @@ void Base64Converter::IllegalEncoding(const char* msg)
if ( conn ) if ( conn )
conn->Weird("base64_illegal_encoding", msg); conn->Weird("base64_illegal_encoding", msg);
else else
reporter->Error("%s", msg); zeek::reporter->Error("%s", msg);
} }
zeek::String* decode_base64(const zeek::String* s, const zeek::String* a, Connection* conn) zeek::String* decode_base64(const zeek::String* s, const zeek::String* a, Connection* conn)
{ {
if ( a && a->Len() != 0 && a->Len() != 64 ) if ( a && a->Len() != 0 && a->Len() != 64 )
{ {
reporter->Error("base64 decoding alphabet is not 64 characters: %s", zeek::reporter->Error("base64 decoding alphabet is not 64 characters: %s",
a->CheckString()); a->CheckString());
return nullptr; return nullptr;
} }
@ -266,7 +266,7 @@ zeek::String* encode_base64(const zeek::String* s, const zeek::String* a, Connec
{ {
if ( a && a->Len() != 0 && a->Len() != 64 ) if ( a && a->Len() != 0 && a->Len() != 64 )
{ {
reporter->Error("base64 alphabet is not 64 characters: %s", zeek::reporter->Error("base64 alphabet is not 64 characters: %s",
a->CheckString()); a->CheckString());
return nullptr; return nullptr;
} }

View file

@ -98,7 +98,7 @@ bool Brofiler::WriteStats()
if ( ! ensure_intermediate_dirs(dirname.result.data()) ) if ( ! ensure_intermediate_dirs(dirname.result.data()) )
{ {
reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf); zeek::reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf);
return false; return false;
} }
@ -113,7 +113,7 @@ bool Brofiler::WriteStats()
if ( fd == -1 ) if ( fd == -1 )
{ {
reporter->Error("Failed to generate unique file name from ZEEK_PROFILER_FILE: %s", bf); zeek::reporter->Error("Failed to generate unique file name from ZEEK_PROFILER_FILE: %s", bf);
return false; return false;
} }
f = fdopen(fd, "w"); f = fdopen(fd, "w");
@ -125,7 +125,7 @@ bool Brofiler::WriteStats()
if ( ! f ) if ( ! f )
{ {
reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf); zeek::reporter->Error("Failed to open ZEEK_PROFILER_FILE destination '%s' for writing", bf);
return false; return false;
} }

View file

@ -305,7 +305,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
default: default:
{ {
reporter->InternalError("bad index type in CompositeHash::SingleValHash"); zeek::reporter->InternalError("bad index type in CompositeHash::SingleValHash");
return nullptr; return nullptr;
} }
} }
@ -435,7 +435,7 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const zeek::Val* v,
return std::make_unique<HashKey>(false, key, n); return std::make_unique<HashKey>(false, key, n);
} }
reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash"); zeek::reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash");
return nullptr; return nullptr;
case zeek::TYPE_INTERNAL_STRING: case zeek::TYPE_INTERNAL_STRING:
@ -445,7 +445,7 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const zeek::Val* v,
return nullptr; return nullptr;
default: default:
reporter->InternalError("bad internal type in CompositeHash::ComputeSingletonHash"); zeek::reporter->InternalError("bad internal type in CompositeHash::ComputeSingletonHash");
return nullptr; return nullptr;
} }
} }
@ -599,7 +599,7 @@ int CompositeHash::SingleTypeKeySize(zeek::Type* bt, const zeek::Val* v,
default: default:
{ {
reporter->InternalError("bad index type in CompositeHash::CompositeHash"); zeek::reporter->InternalError("bad index type in CompositeHash::CompositeHash");
return 0; return 0;
} }
} }
@ -725,7 +725,7 @@ zeek::ListValPtr CompositeHash::RecoverVals(const HashKey& k) const
} }
if ( kp != k_end ) if ( kp != k_end )
reporter->InternalError("under-ran key in CompositeHash::DescribeKey %zd", k_end - kp); zeek::reporter->InternalError("under-ran key in CompositeHash::DescribeKey %zd", k_end - kp);
return l; return l;
} }
@ -737,7 +737,7 @@ const char* CompositeHash::RecoverOneVal(
{ {
// k->Size() == 0 for a single empty string. // k->Size() == 0 for a single empty string.
if ( kp0 >= k_end && k.Size() > 0 ) if ( kp0 >= k_end && k.Size() > 0 )
reporter->InternalError("over-ran key in CompositeHash::RecoverVals"); zeek::reporter->InternalError("over-ran key in CompositeHash::RecoverVals");
zeek::TypeTag tag = t->Tag(); zeek::TypeTag tag = t->Tag();
zeek::InternalTypeTag it = t->InternalType(); zeek::InternalTypeTag it = t->InternalType();
@ -769,7 +769,7 @@ const char* CompositeHash::RecoverOneVal(
*pval = zeek::val_mgr->Int(*kp); *pval = zeek::val_mgr->Int(*kp);
else else
{ {
reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); zeek::reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()");
*pval = nullptr; *pval = nullptr;
} }
} }
@ -791,7 +791,7 @@ const char* CompositeHash::RecoverOneVal(
break; break;
default: default:
reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()"); zeek::reporter->InternalError("bad internal unsigned int in CompositeHash::RecoverOneVal()");
*pval = nullptr; *pval = nullptr;
break; break;
} }
@ -825,7 +825,7 @@ const char* CompositeHash::RecoverOneVal(
break; break;
default: default:
reporter->InternalError("bad internal address in CompositeHash::RecoverOneVal()"); zeek::reporter->InternalError("bad internal address in CompositeHash::RecoverOneVal()");
*pval = nullptr; *pval = nullptr;
break; break;
} }
@ -852,22 +852,22 @@ const char* CompositeHash::RecoverOneVal(
const auto& f = zeek::Func::GetFuncPtrByID(*kp); const auto& f = zeek::Func::GetFuncPtrByID(*kp);
if ( ! f ) if ( ! f )
reporter->InternalError("failed to look up unique function id %" PRIu32 " in CompositeHash::RecoverOneVal()", *kp); zeek::reporter->InternalError("failed to look up unique function id %" PRIu32 " in CompositeHash::RecoverOneVal()", *kp);
*pval = zeek::make_intrusive<zeek::Val>(f); *pval = zeek::make_intrusive<zeek::Val>(f);
const auto& pvt = (*pval)->GetType(); const auto& pvt = (*pval)->GetType();
if ( ! pvt ) if ( ! pvt )
reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()"); zeek::reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()");
else if ( t->Tag() != zeek::TYPE_FUNC && ! same_type(pvt, t) ) else if ( t->Tag() != zeek::TYPE_FUNC && ! same_type(pvt, t) )
// ### Maybe fix later, but may be fundamentally // ### Maybe fix later, but may be fundamentally
// un-checkable --US // un-checkable --US
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); zeek::reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
// ### A crude approximation for now. // ### A crude approximation for now.
else if ( t->Tag() == zeek::TYPE_FUNC && pvt->Tag() != zeek::TYPE_FUNC ) else if ( t->Tag() == zeek::TYPE_FUNC && pvt->Tag() != zeek::TYPE_FUNC )
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()"); zeek::reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
} }
break; break;
@ -891,7 +891,7 @@ const char* CompositeHash::RecoverOneVal(
} }
if ( ! re->Compile() ) if ( ! re->Compile() )
reporter->InternalError("failed compiling table/set key pattern: %s", zeek::reporter->InternalError("failed compiling table/set key pattern: %s",
re->PatternText()); re->PatternText());
*pval = zeek::make_intrusive<zeek::PatternVal>(re); *pval = zeek::make_intrusive<zeek::PatternVal>(re);
@ -921,7 +921,7 @@ const char* CompositeHash::RecoverOneVal(
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch) // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch)
if ( ! (v || optional) ) if ( ! (v || optional) )
{ {
reporter->InternalError("didn't recover expected number of fields from HashKey"); zeek::reporter->InternalError("didn't recover expected number of fields from HashKey");
pval = nullptr; pval = nullptr;
break; break;
} }
@ -1023,7 +1023,7 @@ const char* CompositeHash::RecoverOneVal(
default: default:
{ {
reporter->InternalError("bad index type in CompositeHash::DescribeKey"); zeek::reporter->InternalError("bad index type in CompositeHash::DescribeKey");
} }
} }
} }

View file

@ -33,7 +33,7 @@ void ConnectionTimer::Init(Connection* arg_conn, timer_func arg_timer,
ConnectionTimer::~ConnectionTimer() ConnectionTimer::~ConnectionTimer()
{ {
if ( conn->RefCnt() < 1 ) if ( conn->RefCnt() < 1 )
reporter->InternalError("reference count inconsistency in ~ConnectionTimer"); zeek::reporter->InternalError("reference count inconsistency in ~ConnectionTimer");
conn->RemoveTimer(this); conn->RemoveTimer(this);
Unref(conn); Unref(conn);
@ -51,7 +51,7 @@ void ConnectionTimer::Dispatch(double t, bool is_expire)
(conn->*timer)(t); (conn->*timer)(t);
if ( conn->RefCnt() < 1 ) if ( conn->RefCnt() < 1 )
reporter->InternalError("reference count inconsistency in ConnectionTimer::Dispatch"); zeek::reporter->InternalError("reference count inconsistency in ConnectionTimer::Dispatch");
} }
uint64_t Connection::total_connections = 0; uint64_t Connection::total_connections = 0;
@ -125,7 +125,7 @@ Connection::Connection(NetSessions* s, const zeek::detail::ConnIDKey& k, double
Connection::~Connection() Connection::~Connection()
{ {
if ( ! finished ) if ( ! finished )
reporter->InternalError("Done() not called before destruction of Connection"); zeek::reporter->InternalError("Done() not called before destruction of Connection");
CancelTimers(); CancelTimers();
@ -535,7 +535,7 @@ void Connection::EnqueueEvent(EventHandlerPtr f, zeek::analyzer::Analyzer* a,
void Connection::Weird(const char* name, const char* addl) void Connection::Weird(const char* name, const char* addl)
{ {
weird = 1; weird = 1;
reporter->Weird(this, name, addl ? addl : ""); zeek::reporter->Weird(this, name, addl ? addl : "");
} }
void Connection::AddTimer(timer_func timer, double t, bool do_expire, void Connection::AddTimer(timer_func timer, double t, bool do_expire,
@ -648,13 +648,13 @@ void Connection::Describe(ODesc* d) const
case TRANSPORT_UNKNOWN: case TRANSPORT_UNKNOWN:
d->Add("unknown"); d->Add("unknown");
reporter->InternalWarning( zeek::reporter->InternalWarning(
"unknown transport in Connction::Describe()"); "unknown transport in Connction::Describe()");
break; break;
default: default:
reporter->InternalError( zeek::reporter->InternalError(
"unhandled transport type in Connection::Describe"); "unhandled transport type in Connection::Describe");
} }

View file

@ -440,11 +440,11 @@ void DNS_Mgr::InitSource()
if ( nb_dns ) if ( nb_dns )
{ {
if ( ! iosource_mgr->RegisterFd(nb_dns_fd(nb_dns), this) ) if ( ! iosource_mgr->RegisterFd(nb_dns_fd(nb_dns), this) )
reporter->FatalError("Failed to register nb_dns file descriptor with iosource_mgr"); zeek::reporter->FatalError("Failed to register nb_dns file descriptor with iosource_mgr");
} }
else else
{ {
reporter->Warning("problem initializing NB-DNS: %s", err); zeek::reporter->Warning("problem initializing NB-DNS: %s", err);
} }
did_init = true; did_init = true;
@ -508,7 +508,7 @@ zeek::TableValPtr DNS_Mgr::LookupHost(const char* name)
if ( (d4 && d4->Failed()) || (d6 && d6->Failed()) ) if ( (d4 && d4->Failed()) || (d6 && d6->Failed()) )
{ {
reporter->Warning("no such host: %s", name); zeek::reporter->Warning("no such host: %s", name);
return empty_addr_set(); return empty_addr_set();
} }
else if ( d4 && d6 ) else if ( d4 && d6 )
@ -529,7 +529,7 @@ zeek::TableValPtr DNS_Mgr::LookupHost(const char* name)
return empty_addr_set(); return empty_addr_set();
case DNS_FORCE: case DNS_FORCE:
reporter->FatalError("can't find DNS entry for %s in cache", name); zeek::reporter->FatalError("can't find DNS entry for %s in cache", name);
return nullptr; return nullptr;
case DNS_DEFAULT: case DNS_DEFAULT:
@ -539,7 +539,7 @@ zeek::TableValPtr DNS_Mgr::LookupHost(const char* name)
return LookupHost(name); return LookupHost(name);
default: default:
reporter->InternalError("bad mode in DNS_Mgr::LookupHost"); zeek::reporter->InternalError("bad mode in DNS_Mgr::LookupHost");
return nullptr; return nullptr;
} }
} }
@ -560,7 +560,7 @@ zeek::ValPtr DNS_Mgr::LookupAddr(const zeek::IPAddr& addr)
else else
{ {
string s(addr); string s(addr);
reporter->Warning("can't resolve IP address: %s", s.c_str()); zeek::reporter->Warning("can't resolve IP address: %s", s.c_str());
return zeek::make_intrusive<zeek::StringVal>(s.c_str()); return zeek::make_intrusive<zeek::StringVal>(s.c_str());
} }
} }
@ -573,7 +573,7 @@ zeek::ValPtr DNS_Mgr::LookupAddr(const zeek::IPAddr& addr)
return zeek::make_intrusive<zeek::StringVal>("<none>"); return zeek::make_intrusive<zeek::StringVal>("<none>");
case DNS_FORCE: case DNS_FORCE:
reporter->FatalError("can't find DNS entry for %s in cache", zeek::reporter->FatalError("can't find DNS entry for %s in cache",
addr.AsString().c_str()); addr.AsString().c_str());
return nullptr; return nullptr;
@ -583,7 +583,7 @@ zeek::ValPtr DNS_Mgr::LookupAddr(const zeek::IPAddr& addr)
return LookupAddr(addr); return LookupAddr(addr);
default: default:
reporter->InternalError("bad mode in DNS_Mgr::LookupAddr"); zeek::reporter->InternalError("bad mode in DNS_Mgr::LookupAddr");
return nullptr; return nullptr;
} }
} }
@ -644,7 +644,7 @@ void DNS_Mgr::Resolve()
struct nb_dns_result r; struct nb_dns_result r;
status = nb_dns_activity(nb_dns, &r, err); status = nb_dns_activity(nb_dns, &r, err);
if ( status < 0 ) if ( status < 0 )
reporter->Warning( zeek::reporter->Warning(
"NB-DNS error in DNS_Mgr::WaitForReplies (%s)", "NB-DNS error in DNS_Mgr::WaitForReplies (%s)",
err); err);
else if ( status > 0 ) else if ( status > 0 )
@ -861,7 +861,7 @@ void DNS_Mgr::CompareMappings(DNS_Mapping* prev_dm, DNS_Mapping* new_dm)
if ( ! prev_a || ! new_a ) if ( ! prev_a || ! new_a )
{ {
reporter->InternalWarning("confused in DNS_Mgr::CompareMappings"); zeek::reporter->InternalWarning("confused in DNS_Mgr::CompareMappings");
return; return;
} }
@ -932,7 +932,7 @@ void DNS_Mgr::LoadCache(FILE* f)
} }
if ( ! m->NoMapping() ) if ( ! m->NoMapping() )
reporter->FatalError("DNS cache corrupted"); zeek::reporter->FatalError("DNS cache corrupted");
delete m; delete m;
fclose(f); fclose(f);
@ -1167,7 +1167,7 @@ static bool DoRequest(nb_dns_info* nb_dns, DNS_Mgr_Request* dr)
// dr stored in nb_dns cookie and deleted later when results available. // dr stored in nb_dns cookie and deleted later when results available.
return true; return true;
reporter->Warning("can't issue DNS request"); zeek::reporter->Warning("can't issue DNS request");
delete dr; delete dr;
return false; return false;
} }
@ -1376,7 +1376,7 @@ void DNS_Mgr::Process()
int status = nb_dns_activity(nb_dns, &r, err); int status = nb_dns_activity(nb_dns, &r, err);
if ( status < 0 ) if ( status < 0 )
reporter->Warning("NB-DNS error in DNS_Mgr::Process (%s)", err); zeek::reporter->Warning("NB-DNS error in DNS_Mgr::Process (%s)", err);
else if ( status > 0 ) else if ( status > 0 )
{ {
@ -1416,7 +1416,7 @@ int DNS_Mgr::AnswerAvailable(int timeout)
int fd = nb_dns_fd(nb_dns); int fd = nb_dns_fd(nb_dns);
if ( fd < 0 ) if ( fd < 0 )
{ {
reporter->Warning("nb_dns_fd() failed in DNS_Mgr::WaitForReplies"); zeek::reporter->Warning("nb_dns_fd() failed in DNS_Mgr::WaitForReplies");
return -1; return -1;
} }
@ -1434,14 +1434,14 @@ int DNS_Mgr::AnswerAvailable(int timeout)
if ( status < 0 ) if ( status < 0 )
{ {
if ( errno != EINTR ) if ( errno != EINTR )
reporter->Warning("problem with DNS select"); zeek::reporter->Warning("problem with DNS select");
return -1; return -1;
} }
if ( status > 1 ) if ( status > 1 )
{ {
reporter->Warning("strange return from DNS select"); zeek::reporter->Warning("strange return from DNS select");
return -1; return -1;
} }

View file

@ -219,7 +219,7 @@ bool DbgBreakpoint::Reset()
break; break;
} }
reporter->InternalError("DbgBreakpoint::Reset function incomplete."); zeek::reporter->InternalError("DbgBreakpoint::Reset function incomplete.");
// Cannot be reached. // Cannot be reached.
return false; return false;
@ -312,7 +312,7 @@ BreakCode DbgBreakpoint::ShouldBreak(zeek::detail::Stmt* s)
assert(false); assert(false);
default: default:
reporter->InternalError("Invalid breakpoint type in DbgBreakpoint::ShouldBreak"); zeek::reporter->InternalError("Invalid breakpoint type in DbgBreakpoint::ShouldBreak");
} }
// If we got here, that means that the breakpoint could hit, // If we got here, that means that the breakpoint could hit,
@ -329,7 +329,7 @@ BreakCode DbgBreakpoint::ShouldBreak(zeek::detail::Stmt* s)
BreakCode DbgBreakpoint::ShouldBreak(double t) BreakCode DbgBreakpoint::ShouldBreak(double t)
{ {
if ( kind != BP_TIME ) if ( kind != BP_TIME )
reporter->InternalError("Calling ShouldBreak(time) on a non-time breakpoint"); zeek::reporter->InternalError("Calling ShouldBreak(time) on a non-time breakpoint");
if ( t < at_time ) if ( t < at_time )
return BC_NO_HIT; return BC_NO_HIT;
@ -370,7 +370,7 @@ void DbgBreakpoint::PrintHitMsg()
assert(false); assert(false);
default: default:
reporter->InternalError("Missed a case in DbgBreakpoint::PrintHitMsg\n"); zeek::reporter->InternalError("Missed a case in DbgBreakpoint::PrintHitMsg\n");
} }
} }

View file

@ -9,10 +9,10 @@
// Support classes // Support classes
zeek::detail::DbgWatch::DbgWatch(zeek::Obj* var_to_watch) zeek::detail::DbgWatch::DbgWatch(zeek::Obj* var_to_watch)
{ {
reporter->InternalError("DbgWatch unimplemented"); zeek::reporter->InternalError("DbgWatch unimplemented");
} }
zeek::detail::DbgWatch::DbgWatch(zeek::detail::Expr* expr_to_watch) zeek::detail::DbgWatch::DbgWatch(zeek::detail::Expr* expr_to_watch)
{ {
reporter->InternalError("DbgWatch unimplemented"); zeek::reporter->InternalError("DbgWatch unimplemented");
} }

View file

@ -91,7 +91,7 @@ DebuggerState::~DebuggerState()
bool StmtLocMapping::StartsAfter(const StmtLocMapping* m2) bool StmtLocMapping::StartsAfter(const StmtLocMapping* m2)
{ {
if ( ! m2 ) if ( ! m2 )
reporter->InternalError("Assertion failed: m2 != 0"); zeek::reporter->InternalError("Assertion failed: m2 != 0");
return loc.first_line > m2->loc.first_line || return loc.first_line > m2->loc.first_line ||
(loc.first_line == m2->loc.first_line && (loc.first_line == m2->loc.first_line &&
@ -395,7 +395,7 @@ vector<ParseLocationRec> parse_location_string(const string& s)
{ {
auto iter = g_dbgfilemaps.find(loc_filename); auto iter = g_dbgfilemaps.find(loc_filename);
if ( iter == g_dbgfilemaps.end() ) if ( iter == g_dbgfilemaps.end() )
reporter->InternalError("Policy file %s should have been loaded\n", zeek::reporter->InternalError("Policy file %s should have been loaded\n",
loc_filename.data()); loc_filename.data());
if ( plr.line > how_many_lines_in(loc_filename.data()) ) if ( plr.line > how_many_lines_in(loc_filename.data()) )
@ -637,7 +637,7 @@ int dbg_execute_command(const char* cmd)
#endif #endif
if ( int(cmd_code) >= num_debug_cmds() ) if ( int(cmd_code) >= num_debug_cmds() )
reporter->InternalError("Assertion failed: int(cmd_code) < num_debug_cmds()"); zeek::reporter->InternalError("Assertion failed: int(cmd_code) < num_debug_cmds()");
// Dispatch to the op-specific handler (with args). // Dispatch to the op-specific handler (with args).
int retcode = dbg_dispatch_cmd(cmd_code, arguments); int retcode = dbg_dispatch_cmd(cmd_code, arguments);
@ -646,7 +646,7 @@ int dbg_execute_command(const char* cmd)
const DebugCmdInfo* info = get_debug_cmd_info(cmd_code); const DebugCmdInfo* info = get_debug_cmd_info(cmd_code);
if ( ! info ) if ( ! info )
reporter->InternalError("Assertion failed: info"); zeek::reporter->InternalError("Assertion failed: info");
if ( ! info ) if ( ! info )
return -2; // ### yuck, why -2? return -2; // ### yuck, why -2?
@ -803,7 +803,7 @@ int dbg_handle_debug_input()
const zeek::detail::Stmt* stmt = curr_frame->GetNextStmt(); const zeek::detail::Stmt* stmt = curr_frame->GetNextStmt();
if ( ! stmt ) if ( ! stmt )
reporter->InternalError("Assertion failed: stmt != 0"); zeek::reporter->InternalError("Assertion failed: stmt != 0");
const zeek::detail::Location loc = *stmt->GetLocationInfo(); const zeek::detail::Location loc = *stmt->GetLocationInfo();
@ -909,7 +909,7 @@ bool pre_execute_stmt(zeek::detail::Stmt* stmt, zeek::detail::Frame* f)
p = g_debugger_state.breakpoint_map.equal_range(stmt); p = g_debugger_state.breakpoint_map.equal_range(stmt);
if ( p.first == p.second ) if ( p.first == p.second )
reporter->InternalError("Breakpoint count nonzero, but no matching breakpoints"); zeek::reporter->InternalError("Breakpoint count nonzero, but no matching breakpoints");
for ( BPMapType::iterator i = p.first; i != p.second; ++i ) for ( BPMapType::iterator i = p.first; i != p.second; ++i )
{ {
@ -966,11 +966,11 @@ zeek::ValPtr dbg_eval_expr(const char* expr)
(g_frame_stack.size() - 1) - g_debugger_state.curr_frame_idx; (g_frame_stack.size() - 1) - g_debugger_state.curr_frame_idx;
if ( ! (frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()) ) if ( ! (frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()) )
reporter->InternalError("Assertion failed: frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()"); zeek::reporter->InternalError("Assertion failed: frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()");
zeek::detail::Frame* frame = g_frame_stack[frame_idx]; zeek::detail::Frame* frame = g_frame_stack[frame_idx];
if ( ! (frame) ) if ( ! (frame) )
reporter->InternalError("Assertion failed: frame"); zeek::reporter->InternalError("Assertion failed: frame");
const zeek::detail::ScriptFunc* func = frame->GetFunction(); const zeek::detail::ScriptFunc* func = frame->GetFunction();
if ( func ) if ( func )

View file

@ -206,7 +206,7 @@ static int dbg_backtrace_internal(int start, int end)
if ( start < 0 || end < 0 || if ( start < 0 || end < 0 ||
(unsigned) start >= g_frame_stack.size() || (unsigned) start >= g_frame_stack.size() ||
(unsigned) end >= g_frame_stack.size() ) (unsigned) end >= g_frame_stack.size() )
reporter->InternalError("Invalid stack frame index in DbgBacktraceInternal\n"); zeek::reporter->InternalError("Invalid stack frame index in DbgBacktraceInternal\n");
if ( start < end ) if ( start < end )
{ {
@ -337,7 +337,7 @@ int dbg_cmd_frame(DebugCmd cmd, const vector<string>& args)
// for 'list', 'break', etc. // for 'list', 'break', etc.
const zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); const zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
if ( ! stmt ) if ( ! stmt )
reporter->InternalError("Assertion failed: %s", "stmt != 0"); zeek::reporter->InternalError("Assertion failed: %s", "stmt != 0");
const zeek::detail::Location loc = *stmt->GetLocationInfo(); const zeek::detail::Location loc = *stmt->GetLocationInfo();
g_debugger_state.last_loc = loc; g_debugger_state.last_loc = loc;
@ -377,7 +377,7 @@ int dbg_cmd_break(DebugCmd cmd, const vector<string>& args)
zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
if ( ! stmt ) if ( ! stmt )
reporter->InternalError("Assertion failed: %s", "stmt != 0"); zeek::reporter->InternalError("Assertion failed: %s", "stmt != 0");
DbgBreakpoint* bp = new DbgBreakpoint(); DbgBreakpoint* bp = new DbgBreakpoint();
bp->SetID(g_debugger_state.NextBPID()); bp->SetID(g_debugger_state.NextBPID());
@ -540,7 +540,7 @@ int dbg_cmd_break_set_state(DebugCmd cmd, const vector<string>& args)
break; break;
default: default:
reporter->InternalError("Invalid command in DbgCmdBreakSetState\n"); zeek::reporter->InternalError("Invalid command in DbgCmdBreakSetState\n");
} }
} }

View file

@ -45,8 +45,8 @@ void DebugLogger::OpenDebugLog(const char* filename)
if ( ! file ) if ( ! file )
{ {
// The reporter may not be initialized here yet. // The reporter may not be initialized here yet.
if ( reporter ) if ( zeek::reporter )
reporter->FatalError("can't open '%s' for debugging output", filename); zeek::reporter->FatalError("can't open '%s' for debugging output", filename);
else else
{ {
fprintf(stderr, "can't open '%s' for debugging output\n", filename); fprintf(stderr, "can't open '%s' for debugging output\n", filename);
@ -132,7 +132,7 @@ void DebugLogger::EnableStreams(const char* s)
} }
} }
reporter->FatalError("unknown debug stream '%s', try -B help.\n", tok); zeek::reporter->FatalError("unknown debug stream '%s', try -B help.\n", tok);
next: next:
tok = strtok(0, ","); tok = strtok(0, ",");

View file

@ -75,7 +75,7 @@ void ODesc::PushIndent()
void ODesc::PopIndent() void ODesc::PopIndent()
{ {
if ( --indent_level < 0 ) if ( --indent_level < 0 )
reporter->InternalError("ODesc::PopIndent underflow"); zeek::reporter->InternalError("ODesc::PopIndent underflow");
NL(); NL();
} }
@ -83,7 +83,7 @@ void ODesc::PopIndent()
void ODesc::PopIndentNoNL() void ODesc::PopIndentNoNL()
{ {
if ( --indent_level < 0 ) if ( --indent_level < 0 )
reporter->InternalError("ODesc::PopIndent underflow"); zeek::reporter->InternalError("ODesc::PopIndent underflow");
} }
void ODesc::Add(const char* s, int do_indent) void ODesc::Add(const char* s, int do_indent)
@ -358,7 +358,7 @@ void ODesc::AddBytesRaw(const void* bytes, unsigned int n)
if ( ! write_failed ) if ( ! write_failed )
// Most likely it's a "disk full" so report // Most likely it's a "disk full" so report
// subsequent failures only once. // subsequent failures only once.
reporter->Error("error writing to %s: %s", f->Name(), strerror(errno)); zeek::reporter->Error("error writing to %s: %s", f->Name(), strerror(errno));
write_failed = true; write_failed = true;
return; return;

View file

@ -650,7 +650,7 @@ void Dictionary::StartChangeSize(int new_size)
return; return;
if ( tbl2 ) if ( tbl2 )
reporter->InternalError("Dictionary::StartChangeSize() tbl2 not NULL"); zeek::reporter->InternalError("Dictionary::StartChangeSize() tbl2 not NULL");
Init2(new_size); Init2(new_size);
@ -697,7 +697,7 @@ void Dictionary::FinishChangeSize()
{ {
// Cheap safety check. // Cheap safety check.
if ( num_entries != 0 ) if ( num_entries != 0 )
reporter->InternalError( zeek::reporter->InternalError(
"Dictionary::FinishChangeSize: num_entries is %d\n", "Dictionary::FinishChangeSize: num_entries is %d\n",
num_entries); num_entries);

View file

@ -46,7 +46,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen)
discard_packet = check_ip->Invoke(&args)->AsBool(); discard_packet = check_ip->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( zeek::InterpreterException& e )
{ {
discard_packet = false; discard_packet = false;
} }
@ -101,7 +101,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen)
discard_packet = check_tcp->Invoke(&args)->AsBool(); discard_packet = check_tcp->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( zeek::InterpreterException& e )
{ {
discard_packet = false; discard_packet = false;
} }
@ -125,7 +125,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen)
discard_packet = check_udp->Invoke(&args)->AsBool(); discard_packet = check_udp->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( zeek::InterpreterException& e )
{ {
discard_packet = false; discard_packet = false;
} }
@ -145,7 +145,7 @@ bool Discarder::NextPacket(const zeek::IP_Hdr* ip, int len, int caplen)
discard_packet = check_icmp->Invoke(&args)->AsBool(); discard_packet = check_icmp->Invoke(&args)->AsBool();
} }
catch ( InterpreterException& e ) catch ( zeek::InterpreterException& e )
{ {
discard_packet = false; discard_packet = false;
} }

View file

@ -52,14 +52,14 @@ void Event::Dispatch(bool no_remote)
no_remote = true; no_remote = true;
if ( handler->ErrorHandler() ) if ( handler->ErrorHandler() )
reporter->BeginErrorHandler(); zeek::reporter->BeginErrorHandler();
try try
{ {
handler->Call(&args, no_remote); handler->Call(&args, no_remote);
} }
catch ( InterpreterException& e ) catch ( zeek::InterpreterException& e )
{ {
// Already reported. // Already reported.
} }
@ -69,7 +69,7 @@ void Event::Dispatch(bool no_remote)
Unref(obj); Unref(obj);
if ( handler->ErrorHandler() ) if ( handler->ErrorHandler() )
reporter->EndErrorHandler(); zeek::reporter->EndErrorHandler();
} }
EventMgr::EventMgr() EventMgr::EventMgr()
@ -242,5 +242,5 @@ void EventMgr::InitPostScript()
{ {
iosource_mgr->Register(this, true, false); iosource_mgr->Register(this, true, false);
if ( ! iosource_mgr->RegisterFd(queue_flare.FD(), this) ) if ( ! iosource_mgr->RegisterFd(queue_flare.FD(), this) )
reporter->FatalError("Failed to register event manager FD with iosource_mgr"); zeek::reporter->FatalError("Failed to register event manager FD with iosource_mgr");
} }

View file

@ -78,7 +78,7 @@ void EventHandler::Call(zeek::Args* vl, bool no_remote)
{ {
valid_args = false; valid_args = false;
auto_publish.clear(); auto_publish.clear();
reporter->Error("failed auto-remote event '%s', disabled", Name()); zeek::reporter->Error("failed auto-remote event '%s', disabled", Name());
break; break;
} }
} }

View file

@ -117,6 +117,6 @@ void EventRegistry::SetErrorHandler(std::string_view name)
return; return;
} }
reporter->InternalWarning("unknown event handler '%s' in SetErrorHandler()", zeek::reporter->InternalWarning("unknown event handler '%s' in SetErrorHandler()",
std::string(name).c_str()); std::string(name).c_str());
} }

View file

@ -244,7 +244,7 @@ void Expr::ExprError(const char msg[])
void Expr::RuntimeError(const std::string& msg) const void Expr::RuntimeError(const std::string& msg) const
{ {
reporter->ExprRuntimeError(this, "%s", msg.data()); zeek::reporter->ExprRuntimeError(this, "%s", msg.data());
} }
void Expr::RuntimeErrorWithCallStack(const std::string& msg) const void Expr::RuntimeErrorWithCallStack(const std::string& msg) const
@ -252,13 +252,13 @@ void Expr::RuntimeErrorWithCallStack(const std::string& msg) const
auto rcs = render_call_stack(); auto rcs = render_call_stack();
if ( rcs.empty() ) if ( rcs.empty() )
reporter->ExprRuntimeError(this, "%s", msg.data()); zeek::reporter->ExprRuntimeError(this, "%s", msg.data());
else else
{ {
ODesc d; ODesc d;
d.SetShort(); d.SetShort();
Describe(&d); Describe(&d);
reporter->RuntimeError(GetLocationInfo(), "%s, expression: %s, call stack: %s", zeek::reporter->RuntimeError(GetLocationInfo(), "%s, expression: %s, call stack: %s",
msg.data(), d.Description(), rcs.data()); msg.data(), d.Description(), rcs.data());
} }
} }
@ -803,7 +803,7 @@ ValPtr BinaryExpr::SetFold(Val* v1, Val* v2) const
auto rval = v1->Clone(); auto rval = v1->Clone();
if ( ! tv2->AddTo(rval.get(), false, false) ) if ( ! tv2->AddTo(rval.get(), false, false) )
reporter->InternalError("set union failed to type check"); zeek::reporter->InternalError("set union failed to type check");
return rval; return rval;
} }
@ -813,7 +813,7 @@ ValPtr BinaryExpr::SetFold(Val* v1, Val* v2) const
auto rval = v1->Clone(); auto rval = v1->Clone();
if ( ! tv2->RemoveFrom(rval.get()) ) if ( ! tv2->RemoveFrom(rval.get()) )
reporter->InternalError("set difference failed to type check"); zeek::reporter->InternalError("set difference failed to type check");
return rval; return rval;
} }
@ -837,7 +837,7 @@ ValPtr BinaryExpr::SetFold(Val* v1, Val* v2) const
case EXPR_GE: case EXPR_GE:
case EXPR_GT: case EXPR_GT:
// These should't happen due to canonicalization. // These should't happen due to canonicalization.
reporter->InternalError("confusion over canonicalization in set comparison"); zeek::reporter->InternalError("confusion over canonicalization in set comparison");
break; break;
default: default:
@ -916,7 +916,7 @@ void BinaryExpr::PromoteOps(TypeTag t)
bt2 = op2->GetType()->AsVectorType()->Yield()->Tag(); bt2 = op2->GetType()->AsVectorType()->Yield()->Tag();
if ( (is_vec1 || is_vec2) && ! (is_vec1 && is_vec2) ) if ( (is_vec1 || is_vec2) && ! (is_vec1 && is_vec2) )
reporter->Warning("mixing vector and scalar operands is deprecated"); zeek::reporter->Warning("mixing vector and scalar operands is deprecated");
if ( bt1 != t ) if ( bt1 != t )
op1 = zeek::make_intrusive<ArithCoerceExpr>(op1, t); op1 = zeek::make_intrusive<ArithCoerceExpr>(op1, t);
@ -973,7 +973,7 @@ IncrExpr::IncrExpr(BroExprTag arg_tag, ExprPtr arg_op)
ExprError("vector elements must be integral for increment operator"); ExprError("vector elements must be integral for increment operator");
else else
{ {
reporter->Warning("increment/decrement operations for vectors deprecated"); zeek::reporter->Warning("increment/decrement operations for vectors deprecated");
SetType(t); SetType(t);
} }
} }
@ -1541,7 +1541,7 @@ BoolExpr::BoolExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
if ( is_vector(op1) || is_vector(op2) ) if ( is_vector(op1) || is_vector(op2) )
{ {
if ( ! (is_vector(op1) && is_vector(op2)) ) if ( ! (is_vector(op1) && is_vector(op2)) )
reporter->Warning("mixing vector and scalar operands is deprecated"); zeek::reporter->Warning("mixing vector and scalar operands is deprecated");
SetType(zeek::make_intrusive<zeek::VectorType>(base_type(zeek::TYPE_BOOL))); SetType(zeek::make_intrusive<zeek::VectorType>(base_type(zeek::TYPE_BOOL)));
} }
else else
@ -2224,12 +2224,12 @@ bool AssignExpr::TypeCheck(const AttributesPtr& attrs)
attr_copy = std::make_unique<std::vector<AttrPtr>>(a); attr_copy = std::make_unique<std::vector<AttrPtr>>(a);
} }
int errors_before = reporter->Errors(); int errors_before = zeek::reporter->Errors();
op2 = zeek::make_intrusive<SetConstructorExpr>( op2 = zeek::make_intrusive<SetConstructorExpr>(
IntrusivePtr{zeek::NewRef{}, ctor_list}, IntrusivePtr{zeek::NewRef{}, ctor_list},
std::move(attr_copy), std::move(attr_copy),
op1->GetType()); op1->GetType());
int errors_after = reporter->Errors(); int errors_after = zeek::reporter->Errors();
if ( errors_after > errors_before ) if ( errors_after > errors_before )
{ {
@ -2898,7 +2898,7 @@ FieldExpr::FieldExpr(ExprPtr arg_op, const char* arg_field_name)
td = rt->FieldDecl(field); td = rt->FieldDecl(field);
if ( rt->IsFieldDeprecated(field) ) if ( rt->IsFieldDeprecated(field) )
reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, false).c_str()); zeek::reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, false).c_str());
} }
} }
} }
@ -2984,7 +2984,7 @@ HasFieldExpr::HasFieldExpr(ExprPtr arg_op, const char* arg_field_name)
if ( field < 0 ) if ( field < 0 )
ExprError("no such field in record"); ExprError("no such field in record");
else if ( rt->IsFieldDeprecated(field) ) else if ( rt->IsFieldDeprecated(field) )
reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, true).c_str()); zeek::reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, true).c_str());
SetType(base_type(zeek::TYPE_BOOL)); SetType(base_type(zeek::TYPE_BOOL));
} }
@ -3451,7 +3451,7 @@ void FieldAssignExpr::EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f
int idx = rt->FieldOffset(field_name.c_str()); int idx = rt->FieldOffset(field_name.c_str());
if ( idx < 0 ) if ( idx < 0 )
reporter->InternalError("Missing record field: %s", zeek::reporter->InternalError("Missing record field: %s",
field_name.c_str()); field_name.c_str());
rec->Assign(idx, std::move(v)); rec->Assign(idx, std::move(v));
@ -3657,7 +3657,7 @@ RecordCoerceExpr::RecordCoerceExpr(ExprPtr arg_op, zeek::RecordTypePtr r)
} }
} }
else if ( t_r->IsFieldDeprecated(i) ) else if ( t_r->IsFieldDeprecated(i) )
reporter->Warning("%s", t_r->GetFieldDeprecationWarning(i, false).c_str()); zeek::reporter->Warning("%s", t_r->GetFieldDeprecationWarning(i, false).c_str());
} }
} }
} }

View file

@ -38,7 +38,7 @@ static void maximize_num_fds()
{ {
struct rlimit rl; struct rlimit rl;
if ( getrlimit(RLIMIT_NOFILE, &rl) < 0 ) if ( getrlimit(RLIMIT_NOFILE, &rl) < 0 )
reporter->FatalError("maximize_num_fds(): getrlimit failed"); zeek::reporter->FatalError("maximize_num_fds(): getrlimit failed");
if ( rl.rlim_max == RLIM_INFINITY ) if ( rl.rlim_max == RLIM_INFINITY )
{ {
@ -50,7 +50,7 @@ static void maximize_num_fds()
rl.rlim_cur = rl.rlim_max; rl.rlim_cur = rl.rlim_max;
if ( setrlimit(RLIMIT_NOFILE, &rl) < 0 ) if ( setrlimit(RLIMIT_NOFILE, &rl) < 0 )
reporter->FatalError("maximize_num_fds(): setrlimit failed"); zeek::reporter->FatalError("maximize_num_fds(): setrlimit failed");
} }
BroFile::BroFile(FILE* arg_f) BroFile::BroFile(FILE* arg_f)
@ -92,7 +92,7 @@ BroFile::BroFile(const char* arg_name, const char* arg_access)
else if ( ! Open() ) else if ( ! Open() )
{ {
reporter->Error("cannot open %s: %s", name, strerror(errno)); zeek::reporter->Error("cannot open %s: %s", name, strerror(errno));
is_open = false; is_open = false;
} }
} }
@ -189,7 +189,7 @@ FILE* BroFile::Seek(long new_position)
return nullptr; return nullptr;
if ( fseek(f, new_position, SEEK_SET) < 0 ) if ( fseek(f, new_position, SEEK_SET) < 0 )
reporter->Error("seek failed"); zeek::reporter->Error("seek failed");
return f; return f;
} }
@ -200,7 +200,7 @@ void BroFile::SetBuf(bool arg_buffered)
return; return;
if ( setvbuf(f, NULL, arg_buffered ? _IOFBF : _IOLBF, 0) != 0 ) if ( setvbuf(f, NULL, arg_buffered ? _IOFBF : _IOLBF, 0) != 0 )
reporter->Error("setvbuf failed"); zeek::reporter->Error("setvbuf failed");
buffered = arg_buffered; buffered = arg_buffered;
} }
@ -339,7 +339,7 @@ double BroFile::Size()
struct stat s; struct stat s;
if ( fstat(fileno(f), &s) < 0 ) if ( fstat(fileno(f), &s) < 0 )
{ {
reporter->Error("can't stat fd for %s: %s", name, strerror(errno)); zeek::reporter->Error("can't stat fd for %s: %s", name, strerror(errno));
return 0; return 0;
} }

View file

@ -21,8 +21,8 @@ Flare::Flare()
char buf[256]; char buf[256];
bro_strerror_r(errno, buf, sizeof(buf)); bro_strerror_r(errno, buf, sizeof(buf));
if ( reporter ) if ( zeek::reporter )
reporter->FatalErrorWithCore("unexpected pipe %s failure: %s", which, buf); zeek::reporter->FatalErrorWithCore("unexpected pipe %s failure: %s", which, buf);
else else
{ {
fprintf(stderr, "unexpected pipe %s failure: %s", which, buf); fprintf(stderr, "unexpected pipe %s failure: %s", which, buf);

View file

@ -23,7 +23,7 @@ void FragTimer::Dispatch(double t, bool /* is_expire */)
if ( f ) if ( f )
f->Expire(t); f->Expire(t);
else else
reporter->InternalWarning("fragment timer dispatched w/o reassembler"); zeek::reporter->InternalWarning("fragment timer dispatched w/o reassembler");
} }
FragReassembler::FragReassembler(NetSessions* arg_s, FragReassembler::FragReassembler(NetSessions* arg_s,
@ -173,8 +173,8 @@ void FragReassembler::Weird(const char* name) const
else else
{ {
reporter->InternalWarning("Unexpected IP version in FragReassembler"); zeek::reporter->InternalWarning("Unexpected IP version in FragReassembler");
reporter->Weird(name); zeek::reporter->Weird(name);
} }
} }
@ -274,7 +274,7 @@ void FragReassembler::BlockInserted(DataBlockMap::const_iterator /* it */)
if ( b.upper > n ) if ( b.upper > n )
{ {
reporter->InternalWarning("bad fragment reassembly"); zeek::reporter->InternalWarning("bad fragment reassembly");
DeleteTimer(); DeleteTimer();
Expire(network_time); Expire(network_time);
delete [] pkt_start; delete [] pkt_start;
@ -308,7 +308,7 @@ void FragReassembler::BlockInserted(DataBlockMap::const_iterator /* it */)
else else
{ {
reporter->InternalWarning("bad IP version in fragment reassembly: %d", zeek::reporter->InternalWarning("bad IP version in fragment reassembly: %d",
version); version);
delete [] pkt_start; delete [] pkt_start;
} }

View file

@ -245,7 +245,7 @@ Frame* Frame::SelectiveClone(const id_list& selection, ScriptFunc* func) const
} }
if ( ! frame[id->Offset()].val ) if ( ! frame[id->Offset()].val )
reporter->InternalError("Attempted to clone an id ('%s') with no associated value.", id->Name()); zeek::reporter->InternalError("Attempted to clone an id ('%s') with no associated value.", id->Name());
CloneNonFuncElement(id->Offset(), func, other); CloneNonFuncElement(id->Offset(), func, other);
} }
@ -308,7 +308,7 @@ broker::expected<broker::data> Frame::Serialize(const Frame* target, const id_li
if ( them.length() ) if ( them.length() )
{ {
if ( ! target->closure ) if ( ! target->closure )
reporter->InternalError("Attempting to serialize values from a frame that does not exist."); zeek::reporter->InternalError("Attempting to serialize values from a frame that does not exist.");
rval.emplace_back(std::string("ClosureFrame")); rval.emplace_back(std::string("ClosureFrame"));
@ -502,7 +502,7 @@ void Frame::AddKnownOffsets(const id_list& ids)
void Frame::CaptureClosure(Frame* c, id_list arg_outer_ids) void Frame::CaptureClosure(Frame* c, id_list arg_outer_ids)
{ {
if ( closure || outer_ids.length() ) if ( closure || outer_ids.length() )
reporter->InternalError("Attempted to override a closure."); zeek::reporter->InternalError("Attempted to override a closure.");
outer_ids = std::move(arg_outer_ids); outer_ids = std::move(arg_outer_ids);

View file

@ -242,7 +242,7 @@ void Func::CheckPluginResult(bool handled, const zeek::ValPtr& hook_result,
if ( ! handled ) if ( ! handled )
{ {
if ( hook_result ) if ( hook_result )
reporter->InternalError("plugin set processed flag to false but actually returned a value"); zeek::reporter->InternalError("plugin set processed flag to false but actually returned a value");
// The plugin result hasn't been processed yet (read: fall // The plugin result hasn't been processed yet (read: fall
// into ::Call method). // into ::Call method).
@ -252,14 +252,14 @@ void Func::CheckPluginResult(bool handled, const zeek::ValPtr& hook_result,
switch ( flavor ) { switch ( flavor ) {
case zeek::FUNC_FLAVOR_EVENT: case zeek::FUNC_FLAVOR_EVENT:
if ( hook_result ) if ( hook_result )
reporter->InternalError("plugin returned non-void result for event %s", zeek::reporter->InternalError("plugin returned non-void result for event %s",
this->Name()); this->Name());
break; break;
case zeek::FUNC_FLAVOR_HOOK: case zeek::FUNC_FLAVOR_HOOK:
if ( hook_result->GetType()->Tag() != zeek::TYPE_BOOL ) if ( hook_result->GetType()->Tag() != zeek::TYPE_BOOL )
reporter->InternalError("plugin returned non-bool for hook %s", zeek::reporter->InternalError("plugin returned non-bool for hook %s",
this->Name()); this->Name());
break; break;
@ -271,13 +271,13 @@ void Func::CheckPluginResult(bool handled, const zeek::ValPtr& hook_result,
if ( (! yt) || yt->Tag() == zeek::TYPE_VOID ) if ( (! yt) || yt->Tag() == zeek::TYPE_VOID )
{ {
if ( hook_result ) if ( hook_result )
reporter->InternalError("plugin returned non-void result for void method %s", zeek::reporter->InternalError("plugin returned non-void result for void method %s",
this->Name()); this->Name());
} }
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != zeek::TYPE_ANY ) else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != zeek::TYPE_ANY )
{ {
reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s", zeek::reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s",
hook_result->GetType()->Tag(), yt->Tag(), this->Name()); hook_result->GetType()->Tag(), yt->Tag(), this->Name());
} }
@ -453,7 +453,7 @@ zeek::ValPtr ScriptFunc::Invoke(zeek::Args* args, zeek::detail::Frame* parent) c
(flow != FLOW_RETURN /* we fell off the end */ || (flow != FLOW_RETURN /* we fell off the end */ ||
! result /* explicit return with no result */) && ! result /* explicit return with no result */) &&
! f->HasDelayed() ) ! f->HasDelayed() )
reporter->Warning("non-void function returning without a value: %s", zeek::reporter->Warning("non-void function returning without a value: %s",
Name()); Name());
if ( result && g_trace_state.DoTrace() ) if ( result && g_trace_state.DoTrace() )
@ -523,7 +523,7 @@ bool ScriptFunc::StrengthenClosureReference(zeek::detail::Frame* f)
void ScriptFunc::SetClosureFrame(zeek::detail::Frame* f) void ScriptFunc::SetClosureFrame(zeek::detail::Frame* f)
{ {
if ( closure ) if ( closure )
reporter->InternalError("Tried to override closure for ScriptFunc %s.", zeek::reporter->InternalError("Tried to override closure for ScriptFunc %s.",
Name()); Name());
// Have to use weak references initially because otherwise Ref'ing the // Have to use weak references initially because otherwise Ref'ing the
@ -618,9 +618,9 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name,
const auto& id = zeek::detail::lookup_ID(Name(), GLOBAL_MODULE_NAME, false); const auto& id = zeek::detail::lookup_ID(Name(), GLOBAL_MODULE_NAME, false);
if ( ! id ) if ( ! id )
reporter->InternalError("built-in function %s missing", Name()); zeek::reporter->InternalError("built-in function %s missing", Name());
if ( id->HasVal() ) if ( id->HasVal() )
reporter->InternalError("built-in function %s multiply defined", Name()); zeek::reporter->InternalError("built-in function %s multiply defined", Name());
type = id->GetType<zeek::FuncType>(); type = id->GetType<zeek::FuncType>();
id->SetVal(zeek::make_intrusive<zeek::Val>(zeek::IntrusivePtr{zeek::NewRef{}, this})); id->SetVal(zeek::make_intrusive<zeek::Val>(zeek::IntrusivePtr{zeek::NewRef{}, this}));
@ -800,11 +800,11 @@ static void emit_builtin_error_common(const char* msg, Obj* arg, bool unwind)
{ {
ODesc d; ODesc d;
arg->Describe(&d); arg->Describe(&d);
reporter->ExprRuntimeError(ce, "%s (%s), during call:", msg, zeek::reporter->ExprRuntimeError(ce, "%s (%s), during call:", msg,
d.Description()); d.Description());
} }
else else
reporter->ExprRuntimeError(ce, "%s", msg); zeek::reporter->ExprRuntimeError(ce, "%s", msg);
} }
else else
ce->Error(msg, arg); ce->Error(msg, arg);
@ -814,16 +814,16 @@ static void emit_builtin_error_common(const char* msg, Obj* arg, bool unwind)
if ( arg ) if ( arg )
{ {
if ( unwind ) if ( unwind )
reporter->RuntimeError(arg->GetLocationInfo(), "%s", msg); zeek::reporter->RuntimeError(arg->GetLocationInfo(), "%s", msg);
else else
arg->Error(msg); arg->Error(msg);
} }
else else
{ {
if ( unwind ) if ( unwind )
reporter->RuntimeError(nullptr, "%s", msg); zeek::reporter->RuntimeError(nullptr, "%s", msg);
else else
reporter->Error("%s", msg); zeek::reporter->Error("%s", msg);
} }
} }
}; };

View file

@ -83,7 +83,7 @@ void init_hash_function()
{ {
// Make sure we have already called init_random_seed(). // Make sure we have already called init_random_seed().
if ( ! KeyedHash::IsInitialized() ) if ( ! KeyedHash::IsInitialized() )
reporter->InternalError("Zeek's hash functions aren't fully initialized"); zeek::reporter->InternalError("Zeek's hash functions aren't fully initialized");
} }
HashKey::HashKey(bro_int_t i) HashKey::HashKey(bro_int_t i)

View file

@ -42,7 +42,7 @@ const zeek::TypePtr& zeek::id::find_type(std::string_view name)
auto id = zeek::detail::global_scope()->Find(name); auto id = zeek::detail::global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find type named: %s", zeek::reporter->InternalError("Failed to find type named: %s",
std::string(name).data()); std::string(name).data());
return id->GetType(); return id->GetType();
@ -53,7 +53,7 @@ const zeek::ValPtr& zeek::id::find_val(std::string_view name)
auto id = zeek::detail::global_scope()->Find(name); auto id = zeek::detail::global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find variable named: %s", zeek::reporter->InternalError("Failed to find variable named: %s",
std::string(name).data()); std::string(name).data());
return id->GetVal(); return id->GetVal();
@ -64,11 +64,11 @@ const zeek::ValPtr& zeek::id::find_const(std::string_view name)
auto id = zeek::detail::global_scope()->Find(name); auto id = zeek::detail::global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find variable named: %s", zeek::reporter->InternalError("Failed to find variable named: %s",
std::string(name).data()); std::string(name).data());
if ( ! id->IsConst() ) if ( ! id->IsConst() )
reporter->InternalError("Variable is not 'const', but expected to be: %s", zeek::reporter->InternalError("Variable is not 'const', but expected to be: %s",
std::string(name).data()); std::string(name).data());
return id->GetVal(); return id->GetVal();
@ -82,7 +82,7 @@ zeek::FuncPtr zeek::id::find_func(std::string_view name)
return nullptr; return nullptr;
if ( ! IsFunc(v->GetType()->Tag()) ) if ( ! IsFunc(v->GetType()->Tag()) )
reporter->InternalError("Expected variable '%s' to be a function", zeek::reporter->InternalError("Expected variable '%s' to be a function",
std::string(name).data()); std::string(name).data());
return v->AsFuncPtr(); return v->AsFuncPtr();

View file

@ -284,7 +284,7 @@ zeek::RecordValPtr IPv6_Hdr::ToVal(zeek::VectorValPtr chain) const
} }
default: default:
reporter->Weird("unknown_mobility_type", fmt("%d", mob->ip6mob_type)); zeek::reporter->Weird("unknown_mobility_type", fmt("%d", mob->ip6mob_type));
break; break;
} }
@ -494,7 +494,7 @@ void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, int total_len,
if ( total_len < (int)sizeof(struct ip6_hdr) ) if ( total_len < (int)sizeof(struct ip6_hdr) )
{ {
reporter->InternalWarning("truncated IP header in IPv6_HdrChain::Init"); zeek::reporter->InternalWarning("truncated IP header in IPv6_HdrChain::Init");
return; return;
} }
@ -552,7 +552,7 @@ bool IPv6_Hdr_Chain::IsFragment() const
{ {
if ( chain.empty() ) if ( chain.empty() )
{ {
reporter->InternalWarning("empty IPv6 header chain"); zeek::reporter->InternalWarning("empty IPv6 header chain");
return false; return false;
} }
@ -567,7 +567,7 @@ IPAddr IPv6_Hdr_Chain::SrcAddr() const
#endif #endif
if ( chain.empty() ) if ( chain.empty() )
{ {
reporter->InternalWarning("empty IPv6 header chain"); zeek::reporter->InternalWarning("empty IPv6 header chain");
return IPAddr(); return IPAddr();
} }
@ -581,7 +581,7 @@ IPAddr IPv6_Hdr_Chain::DstAddr() const
if ( chain.empty() ) if ( chain.empty() )
{ {
reporter->InternalWarning("empty IPv6 header chain"); zeek::reporter->InternalWarning("empty IPv6 header chain");
return IPAddr(); return IPAddr();
} }
@ -593,7 +593,7 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t le
if ( finalDst ) if ( finalDst )
{ {
// RFC 2460 section 4.1 says Routing should occur at most once. // RFC 2460 section 4.1 says Routing should occur at most once.
reporter->Weird(SrcAddr(), DstAddr(), "multiple_routing_headers"); zeek::reporter->Weird(SrcAddr(), DstAddr(), "multiple_routing_headers");
return; return;
} }
@ -608,11 +608,11 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t le
if ( r->ip6r_len % 2 == 0 ) if ( r->ip6r_len % 2 == 0 )
finalDst = new IPAddr(*addr); finalDst = new IPAddr(*addr);
else else
reporter->Weird(SrcAddr(), DstAddr(), "odd_routing0_len"); zeek::reporter->Weird(SrcAddr(), DstAddr(), "odd_routing0_len");
} }
// Always raise a weird since this type is deprecated. // Always raise a weird since this type is deprecated.
reporter->Weird(SrcAddr(), DstAddr(), "routing0_hdr"); zeek::reporter->Weird(SrcAddr(), DstAddr(), "routing0_hdr");
} }
break; break;
@ -624,14 +624,14 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t le
if ( r->ip6r_len == 2 ) if ( r->ip6r_len == 2 )
finalDst = new IPAddr(*addr); finalDst = new IPAddr(*addr);
else else
reporter->Weird(SrcAddr(), DstAddr(), "bad_routing2_len"); zeek::reporter->Weird(SrcAddr(), DstAddr(), "bad_routing2_len");
} }
} }
break; break;
#endif #endif
default: default:
reporter->Weird(SrcAddr(), DstAddr(), "unknown_routing_type", zeek::reporter->Weird(SrcAddr(), DstAddr(), "unknown_routing_type",
fmt("%d", r->ip6r_type)); fmt("%d", r->ip6r_type));
break; break;
} }
@ -652,11 +652,11 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
{ {
if ( opt->ip6o_len == 16 ) if ( opt->ip6o_len == 16 )
if ( homeAddr ) if ( homeAddr )
reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts"); zeek::reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts");
else else
homeAddr = new IPAddr(*((const in6_addr*)(data + 2))); homeAddr = new IPAddr(*((const in6_addr*)(data + 2)));
else else
reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len"); zeek::reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len");
} }
break; break;
@ -722,7 +722,7 @@ zeek::VectorValPtr IPv6_Hdr_Chain::ToVal() const
break; break;
#endif #endif
default: default:
reporter->InternalWarning("IPv6_Hdr_Chain bad header %d", type); zeek::reporter->InternalWarning("IPv6_Hdr_Chain bad header %d", type);
continue; continue;
} }
@ -768,7 +768,7 @@ IPv6_Hdr_Chain* IPv6_Hdr_Chain::Copy(const ip6_hdr* new_hdr) const
if ( chain.empty() ) if ( chain.empty() )
{ {
reporter->InternalWarning("empty IPv6 header chain"); zeek::reporter->InternalWarning("empty IPv6 header chain");
delete rval; delete rval;
return nullptr; return nullptr;
} }

View file

@ -74,7 +74,7 @@ void IPAddr::Mask(int top_bits_to_keep)
{ {
if ( top_bits_to_keep < 0 || top_bits_to_keep > 128 ) if ( top_bits_to_keep < 0 || top_bits_to_keep > 128 )
{ {
reporter->Error("Bad IPAddr::Mask value %d", top_bits_to_keep); zeek::reporter->Error("Bad IPAddr::Mask value %d", top_bits_to_keep);
return; return;
} }
@ -98,7 +98,7 @@ void IPAddr::ReverseMask(int top_bits_to_chop)
{ {
if ( top_bits_to_chop < 0 || top_bits_to_chop > 128 ) if ( top_bits_to_chop < 0 || top_bits_to_chop > 128 )
{ {
reporter->Error("Bad IPAddr::ReverseMask value %d", top_bits_to_chop); zeek::reporter->Error("Bad IPAddr::ReverseMask value %d", top_bits_to_chop);
return; return;
} }
@ -153,7 +153,7 @@ void IPAddr::Init(const char* s)
{ {
if ( ! ConvertString(s, &in6) ) if ( ! ConvertString(s, &in6) )
{ {
reporter->Error("Bad IP address: %s", s); zeek::reporter->Error("Bad IP address: %s", s);
memset(in6.s6_addr, 0, sizeof(in6.s6_addr)); memset(in6.s6_addr, 0, sizeof(in6.s6_addr));
} }
} }
@ -239,7 +239,7 @@ IPPrefix::IPPrefix(const in4_addr& in4, uint8_t length)
{ {
if ( length > 32 ) if ( length > 32 )
{ {
reporter->Error("Bad in4_addr IPPrefix length : %d", length); zeek::reporter->Error("Bad in4_addr IPPrefix length : %d", length);
this->length = 0; this->length = 0;
} }
@ -251,7 +251,7 @@ IPPrefix::IPPrefix(const in6_addr& in6, uint8_t length)
{ {
if ( length > 128 ) if ( length > 128 )
{ {
reporter->Error("Bad in6_addr IPPrefix length : %d", length); zeek::reporter->Error("Bad in6_addr IPPrefix length : %d", length);
this->length = 0; this->length = 0;
} }
@ -288,7 +288,7 @@ IPPrefix::IPPrefix(const IPAddr& addr, uint8_t length, bool len_is_v6_relative)
else else
{ {
auto vstr = prefix.GetFamily() == IPv4 ? "v4" : "v6"; auto vstr = prefix.GetFamily() == IPv4 ? "v4" : "v6";
reporter->Error("Bad IPAddr(%s) IPPrefix length : %d", vstr, length); zeek::reporter->Error("Bad IPAddr(%s) IPPrefix length : %d", vstr, length);
this->length = 0; this->length = 0;
} }

View file

@ -114,7 +114,7 @@ RETSIGTYPE watchdog(int /* signo */)
pkt_dumper = iosource_mgr->OpenPktDumper("watchdog-pkt.pcap", false); pkt_dumper = iosource_mgr->OpenPktDumper("watchdog-pkt.pcap", false);
if ( ! pkt_dumper || pkt_dumper->IsError() ) if ( ! pkt_dumper || pkt_dumper->IsError() )
{ {
reporter->Error("watchdog: can't open watchdog-pkt.pcap for writing"); zeek::reporter->Error("watchdog: can't open watchdog-pkt.pcap for writing");
pkt_dumper = nullptr; pkt_dumper = nullptr;
} }
} }
@ -127,7 +127,7 @@ RETSIGTYPE watchdog(int /* signo */)
net_get_final_stats(); net_get_final_stats();
net_finish(0); net_finish(0);
reporter->FatalErrorWithCore( zeek::reporter->FatalErrorWithCore(
"**watchdog timer expired, t = %d.%06d, start = %d.%06d, dispatched = %d", "**watchdog timer expired, t = %d.%06d, start = %d.%06d, dispatched = %d",
int_ct, frac_ct, int_pst, frac_pst, int_ct, frac_ct, int_pst, frac_pst,
current_dispatched); current_dispatched);
@ -160,7 +160,7 @@ void net_init(const std::optional<std::string>& interface,
assert(ps); assert(ps);
if ( ! ps->IsOpen() ) if ( ! ps->IsOpen() )
reporter->FatalError("problem with trace file %s (%s)", zeek::reporter->FatalError("problem with trace file %s (%s)",
pcap_input_file->c_str(), ps->ErrorMsg()); pcap_input_file->c_str(), ps->ErrorMsg());
} }
else if ( interface ) else if ( interface )
@ -172,7 +172,7 @@ void net_init(const std::optional<std::string>& interface,
assert(ps); assert(ps);
if ( ! ps->IsOpen() ) if ( ! ps->IsOpen() )
reporter->FatalError("problem with interface %s (%s)", zeek::reporter->FatalError("problem with interface %s (%s)",
interface->c_str(), ps->ErrorMsg()); interface->c_str(), ps->ErrorMsg());
} }
@ -190,13 +190,13 @@ void net_init(const std::optional<std::string>& interface,
assert(pkt_dumper); assert(pkt_dumper);
if ( ! pkt_dumper->IsOpen() ) if ( ! pkt_dumper->IsOpen() )
reporter->FatalError("problem opening dump file %s (%s)", zeek::reporter->FatalError("problem opening dump file %s (%s)",
writefile, pkt_dumper->ErrorMsg()); writefile, pkt_dumper->ErrorMsg());
if ( const auto& id = zeek::detail::global_scope()->Find("trace_output_file") ) if ( const auto& id = zeek::detail::global_scope()->Find("trace_output_file") )
id->SetVal(zeek::make_intrusive<zeek::StringVal>(writefile)); id->SetVal(zeek::make_intrusive<zeek::StringVal>(writefile));
else else
reporter->Error("trace_output_file not defined in bro.init"); zeek::reporter->Error("trace_output_file not defined in bro.init");
} }
zeek::detail::init_ip_addr_anonymizers(); zeek::detail::init_ip_addr_anonymizers();
@ -373,7 +373,7 @@ void net_get_final_stats()
iosource::PktSrc::Stats s; iosource::PktSrc::Stats s;
ps->Statistics(&s); ps->Statistics(&s);
double dropped_pct = s.dropped > 0.0 ? ((double)s.dropped / ((double)s.received + (double)s.dropped)) * 100.0 : 0.0; double dropped_pct = s.dropped > 0.0 ? ((double)s.dropped / ((double)s.received + (double)s.dropped)) * 100.0 : 0.0;
reporter->Info("%" PRIu64 " packets received on interface %s, %" PRIu64 " (%.2f%%) dropped", zeek::reporter->Info("%" PRIu64 " packets received on interface %s, %" PRIu64 " (%.2f%%) dropped",
s.received, ps->Path().c_str(), s.dropped, dropped_pct); s.received, ps->Path().c_str(), s.dropped, dropped_pct);
} }
} }
@ -418,7 +418,7 @@ int _processing_suspended = 0;
void net_suspend_processing() void net_suspend_processing()
{ {
if ( _processing_suspended == 0 ) if ( _processing_suspended == 0 )
reporter->Info("processing suspended"); zeek::reporter->Info("processing suspended");
++_processing_suspended; ++_processing_suspended;
} }
@ -427,7 +427,7 @@ void net_continue_processing()
{ {
if ( _processing_suspended == 1 ) if ( _processing_suspended == 1 )
{ {
reporter->Info("processing continued"); zeek::reporter->Info("processing continued");
if ( iosource::PktSrc* ps = iosource_mgr->GetPktSrc() ) if ( iosource::PktSrc* ps = iosource_mgr->GetPktSrc() )
ps->ContinueAfterSuspend(); ps->ContinueAfterSuspend();
} }

View file

@ -67,8 +67,8 @@ void Obj::Warn(const char* msg, const Obj* obj2, bool pinpoint_only, const detai
{ {
ODesc d; ODesc d;
DoMsg(&d, msg, obj2, pinpoint_only, expr_location); DoMsg(&d, msg, obj2, pinpoint_only, expr_location);
reporter->Warning("%s", d.Description()); zeek::reporter->Warning("%s", d.Description());
reporter->PopLocation(); zeek::reporter->PopLocation();
} }
void Obj::Error(const char* msg, const Obj* obj2, bool pinpoint_only, const detail::Location* expr_location) const void Obj::Error(const char* msg, const Obj* obj2, bool pinpoint_only, const detail::Location* expr_location) const
@ -78,8 +78,8 @@ void Obj::Error(const char* msg, const Obj* obj2, bool pinpoint_only, const deta
ODesc d; ODesc d;
DoMsg(&d, msg, obj2, pinpoint_only, expr_location); DoMsg(&d, msg, obj2, pinpoint_only, expr_location);
reporter->Error("%s", d.Description()); zeek::reporter->Error("%s", d.Description());
reporter->PopLocation(); zeek::reporter->PopLocation();
} }
void Obj::BadTag(const char* msg, const char* t1, const char* t2) const void Obj::BadTag(const char* msg, const char* t1, const char* t2) const
@ -95,8 +95,8 @@ void Obj::BadTag(const char* msg, const char* t1, const char* t2) const
ODesc d; ODesc d;
DoMsg(&d, out); DoMsg(&d, out);
reporter->FatalErrorWithCore("%s", d.Description()); zeek::reporter->FatalErrorWithCore("%s", d.Description());
reporter->PopLocation(); zeek::reporter->PopLocation();
} }
void Obj::Internal(const char* msg) const void Obj::Internal(const char* msg) const
@ -106,19 +106,19 @@ void Obj::Internal(const char* msg) const
auto rcs = zeek::render_call_stack(); auto rcs = zeek::render_call_stack();
if ( rcs.empty() ) if ( rcs.empty() )
reporter->InternalError("%s", d.Description()); zeek::reporter->InternalError("%s", d.Description());
else else
reporter->InternalError("%s, call stack: %s", d.Description(), rcs.data()); zeek::reporter->InternalError("%s, call stack: %s", d.Description(), rcs.data());
reporter->PopLocation(); zeek::reporter->PopLocation();
} }
void Obj::InternalWarning(const char* msg) const void Obj::InternalWarning(const char* msg) const
{ {
ODesc d; ODesc d;
DoMsg(&d, msg); DoMsg(&d, msg);
reporter->InternalWarning("%s", d.Description()); zeek::reporter->InternalWarning("%s", d.Description());
reporter->PopLocation(); zeek::reporter->PopLocation();
} }
void Obj::AddLocation(ODesc* d) const void Obj::AddLocation(ODesc* d) const
@ -177,7 +177,7 @@ void Obj::DoMsg(ODesc* d, const char s1[], const Obj* obj2,
else if ( expr_location ) else if ( expr_location )
loc2 = expr_location; loc2 = expr_location;
reporter->PushLocation(GetLocationInfo(), loc2); zeek::reporter->PushLocation(GetLocationInfo(), loc2);
} }
void Obj::PinPoint(ODesc* d, const Obj* obj2, bool pinpoint_only) const void Obj::PinPoint(ODesc* d, const Obj* obj2, bool pinpoint_only) const
@ -203,7 +203,7 @@ void Obj::Print() const
void bad_ref(int type) void bad_ref(int type)
{ {
reporter->InternalError("bad reference count [%d]", type); zeek::reporter->InternalError("bad reference count [%d]", type);
abort(); abort();
} }

View file

@ -54,7 +54,7 @@ const std::string& OpaqueMgr::TypeID(const OpaqueVal* v) const
auto x = _types.find(v->OpaqueName()); auto x = _types.find(v->OpaqueName());
if ( x == _types.end() ) if ( x == _types.end() )
reporter->InternalError("OpaqueMgr::TypeID: opaque type %s not registered", zeek::reporter->InternalError("OpaqueMgr::TypeID: opaque type %s not registered",
v->OpaqueName()); v->OpaqueName());
return x->first; return x->first;
@ -774,13 +774,13 @@ BloomFilterValPtr BloomFilterVal::Merge(const BloomFilterVal* x,
y->Type() && y->Type() &&
! same_type(x->Type(), y->Type()) ) ! same_type(x->Type(), y->Type()) )
{ {
reporter->Error("cannot merge Bloom filters with different types"); zeek::reporter->Error("cannot merge Bloom filters with different types");
return nullptr; return nullptr;
} }
if ( typeid(*x->bloom_filter) != typeid(*y->bloom_filter) ) if ( typeid(*x->bloom_filter) != typeid(*y->bloom_filter) )
{ {
reporter->Error("cannot merge different Bloom filter types"); zeek::reporter->Error("cannot merge different Bloom filter types");
return nullptr; return nullptr;
} }
@ -789,7 +789,7 @@ BloomFilterValPtr BloomFilterVal::Merge(const BloomFilterVal* x,
if ( ! copy->Merge(y->bloom_filter) ) if ( ! copy->Merge(y->bloom_filter) )
{ {
delete copy; delete copy;
reporter->Error("failed to merge Bloom filter"); zeek::reporter->Error("failed to merge Bloom filter");
return nullptr; return nullptr;
} }
@ -797,7 +797,7 @@ BloomFilterValPtr BloomFilterVal::Merge(const BloomFilterVal* x,
if ( x->Type() && ! merged->Typify(x->Type()) ) if ( x->Type() && ! merged->Typify(x->Type()) )
{ {
reporter->Error("failed to set type on merged Bloom filter"); zeek::reporter->Error("failed to set type on merged Bloom filter");
return nullptr; return nullptr;
} }
@ -1008,12 +1008,12 @@ bool ParaglobVal::DoUnserialize(const broker::data& data)
} }
catch (const paraglob::underflow_error& e) catch (const paraglob::underflow_error& e)
{ {
reporter->Error("Paraglob underflow error -> %s", e.what()); zeek::reporter->Error("Paraglob underflow error -> %s", e.what());
return false; return false;
} }
catch (const paraglob::overflow_error& e) catch (const paraglob::overflow_error& e)
{ {
reporter->Error("Paraglob overflow error -> %s", e.what()); zeek::reporter->Error("Paraglob overflow error -> %s", e.what());
return false; return false;
} }
@ -1028,12 +1028,12 @@ ValPtr ParaglobVal::DoClone(CloneState* state)
} }
catch (const paraglob::underflow_error& e) catch (const paraglob::underflow_error& e)
{ {
reporter->Error("Paraglob underflow error while cloning -> %s", e.what()); zeek::reporter->Error("Paraglob underflow error while cloning -> %s", e.what());
return nullptr; return nullptr;
} }
catch (const paraglob::overflow_error& e) catch (const paraglob::overflow_error& e)
{ {
reporter->Error("Paraglob overflow error while cloning -> %s", e.what()); zeek::reporter->Error("Paraglob overflow error while cloning -> %s", e.what());
return nullptr; return nullptr;
} }
} }

View file

@ -12,7 +12,7 @@ PacketDumper::PacketDumper(pcap_dumper_t* arg_pkt_dump)
pkt_dump = arg_pkt_dump; pkt_dump = arg_pkt_dump;
if ( ! pkt_dump ) if ( ! pkt_dump )
reporter->InternalError("PacketDumper: nil dump file"); zeek::reporter->InternalError("PacketDumper: nil dump file");
} }
void PacketDumper::DumpPacket(const struct pcap_pkthdr* hdr, void PacketDumper::DumpPacket(const struct pcap_pkthdr* hdr,
@ -23,7 +23,7 @@ void PacketDumper::DumpPacket(const struct pcap_pkthdr* hdr,
struct pcap_pkthdr h = *hdr; struct pcap_pkthdr h = *hdr;
h.caplen = len; h.caplen = len;
if ( h.caplen > hdr->caplen ) if ( h.caplen > hdr->caplen )
reporter->InternalError("bad modified caplen"); zeek::reporter->InternalError("bad modified caplen");
pcap_dump((u_char*) pkt_dump, &h, pkt); pcap_dump((u_char*) pkt_dump, &h, pkt);
} }

View file

@ -14,8 +14,8 @@ static void pipe_fail(int eno)
char tmp[256]; char tmp[256];
bro_strerror_r(eno, tmp, sizeof(tmp)); bro_strerror_r(eno, tmp, sizeof(tmp));
if ( reporter ) if ( zeek::reporter )
reporter->FatalError("Pipe failure: %s", tmp); zeek::reporter->FatalError("Pipe failure: %s", tmp);
else else
fprintf(stderr, "Pipe failure: %s", tmp); fprintf(stderr, "Pipe failure: %s", tmp);
} }

View file

@ -32,7 +32,7 @@ static PolicyFileMap policy_files;
int how_many_lines_in(const char* policy_filename) int how_many_lines_in(const char* policy_filename)
{ {
if ( ! policy_filename ) if ( ! policy_filename )
reporter->InternalError("NULL value passed to how_many_lines_in\n"); zeek::reporter->InternalError("NULL value passed to how_many_lines_in\n");
FILE* throwaway = fopen(policy_filename, "r"); FILE* throwaway = fopen(policy_filename, "r");
if ( ! throwaway ) if ( ! throwaway )
@ -85,7 +85,7 @@ bool LoadPolicyFileText(const char* policy_filename)
{ {
char buf[256]; char buf[256];
bro_strerror_r(errno, buf, sizeof(buf)); bro_strerror_r(errno, buf, sizeof(buf));
reporter->Error("fstat failed on %s: %s", policy_filename, buf); zeek::reporter->Error("fstat failed on %s: %s", policy_filename, buf);
fclose(f); fclose(f);
return false; return false;
} }
@ -97,7 +97,7 @@ bool LoadPolicyFileText(const char* policy_filename)
// (probably fine with UTF-8) // (probably fine with UTF-8)
pf->filedata = new char[size+1]; pf->filedata = new char[size+1];
if ( fread(pf->filedata, size, 1, f) != 1 ) if ( fread(pf->filedata, size, 1, f) != 1 )
reporter->InternalError("Failed to fread() file data"); zeek::reporter->InternalError("Failed to fread() file data");
pf->filedata[size] = 0; pf->filedata[size] = 0;
fclose(f); fclose(f);

View file

@ -27,7 +27,7 @@ void* PrefixTable::Insert(const zeek::IPAddr& addr, int width, void* data)
if ( ! node ) if ( ! node )
{ {
reporter->InternalWarning("Cannot create node in patricia tree"); zeek::reporter->InternalWarning("Cannot create node in patricia tree");
return nullptr; return nullptr;
} }
@ -58,7 +58,7 @@ void* PrefixTable::Insert(const zeek::Val* value, void* data)
break; break;
default: default:
reporter->InternalWarning("Wrong index type for PrefixTable"); zeek::reporter->InternalWarning("Wrong index type for PrefixTable");
return nullptr; return nullptr;
} }
} }
@ -118,7 +118,7 @@ void* PrefixTable::Lookup(const zeek::Val* value, bool exact) const
break; break;
default: default:
reporter->InternalWarning("Wrong index type %d for PrefixTable", zeek::reporter->InternalWarning("Wrong index type %d for PrefixTable",
value->GetType()->Tag()); value->GetType()->Tag());
return nullptr; return nullptr;
} }
@ -157,7 +157,7 @@ void* PrefixTable::Remove(const zeek::Val* value)
break; break;
default: default:
reporter->InternalWarning("Wrong index type for PrefixTable"); zeek::reporter->InternalWarning("Wrong index type for PrefixTable");
return nullptr; return nullptr;
} }
} }

View file

@ -49,7 +49,7 @@ PQ_Element* PriorityQueue::Remove(PQ_Element* e)
PQ_Element* e2 = Remove(); PQ_Element* e2 = Remove();
if ( e != e2 ) if ( e != e2 )
reporter->InternalError("inconsistency in PriorityQueue::Remove"); zeek::reporter->InternalError("inconsistency in PriorityQueue::Remove");
return e2; return e2;
} }

View file

@ -135,7 +135,7 @@ bool Specific_RE_Matcher::Compile(bool lazy)
if ( parse_status ) if ( parse_status )
{ {
reporter->Error("error compiling pattern /%s/", pattern_text); zeek::reporter->Error("error compiling pattern /%s/", pattern_text);
Unref(nfa); Unref(nfa);
nfa = nullptr; nfa = nullptr;
return false; return false;
@ -157,7 +157,7 @@ bool Specific_RE_Matcher::Compile(bool lazy)
bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx) bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx)
{ {
if ( (size_t)set.length() != idx.size() ) if ( (size_t)set.length() != idx.size() )
reporter->InternalError("compileset: lengths of sets differ"); zeek::reporter->InternalError("compileset: lengths of sets differ");
rem = this; rem = this;
@ -171,7 +171,7 @@ bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx
if ( parse_status ) if ( parse_status )
{ {
reporter->Error("error compiling pattern /%s/", set[i]); zeek::reporter->Error("error compiling pattern /%s/", set[i]);
if ( set_nfa && set_nfa != nfa ) if ( set_nfa && set_nfa != nfa )
Unref(set_nfa); Unref(set_nfa);

View file

@ -30,7 +30,10 @@ int closelog();
} }
#endif #endif
Reporter* reporter = nullptr; zeek::Reporter* zeek::reporter = nullptr;
zeek::Reporter*& reporter = zeek::reporter;
namespace zeek {
Reporter::Reporter(bool arg_abort_on_scripting_errors) Reporter::Reporter(bool arg_abort_on_scripting_errors)
{ {
@ -253,7 +256,7 @@ public:
{} {}
void Dispatch(double t, bool is_expire) override void Dispatch(double t, bool is_expire) override
{ reporter->ResetNetWeird(weird_name); } { zeek::reporter->ResetNetWeird(weird_name); }
std::string weird_name; std::string weird_name;
}; };
@ -267,7 +270,7 @@ public:
{} {}
void Dispatch(double t, bool is_expire) override void Dispatch(double t, bool is_expire) override
{ reporter->ResetFlowWeird(endpoints.first, endpoints.second); } { zeek::reporter->ResetFlowWeird(endpoints.first, endpoints.second); }
IPPair endpoints; IPPair endpoints;
}; };
@ -282,7 +285,7 @@ public:
{} {}
void Dispatch(double t, bool is_expire) override void Dispatch(double t, bool is_expire) override
{ reporter->ResetExpiredConnWeird(conn_id); } { zeek::reporter->ResetExpiredConnWeird(conn_id); }
ConnTuple conn_id; ConnTuple conn_id;
}; };
@ -620,3 +623,5 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
if ( alloced ) if ( alloced )
free(alloced); free(alloced);
} }
} // namespace zeek

View file

@ -18,19 +18,18 @@
ZEEK_FORWARD_DECLARE_NAMESPACED(Analyzer, zeek, analyzer); ZEEK_FORWARD_DECLARE_NAMESPACED(Analyzer, zeek, analyzer);
namespace file_analysis { class File; } namespace file_analysis { class File; }
class Connection; class Connection;
class Reporter;
class EventHandlerPtr; class EventHandlerPtr;
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordVal, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(RecordVal, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(Location, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(IPAddr, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Reporter, zeek);
namespace zeek { namespace zeek {
template <class T> class IntrusivePtr; template <class T> class IntrusivePtr;
using RecordValPtr = zeek::IntrusivePtr<RecordVal>; using RecordValPtr = zeek::IntrusivePtr<RecordVal>;
using StringValPtr = zeek::IntrusivePtr<StringVal>; using StringValPtr = zeek::IntrusivePtr<StringVal>;
}
ZEEK_FORWARD_DECLARE_NAMESPACED(Location, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(IPAddr, zeek);
// One cannot raise this exception directly, go through the // One cannot raise this exception directly, go through the
// Reporter's methods instead. // Reporter's methods instead.
@ -47,8 +46,6 @@ protected:
InterpreterException() {} InterpreterException() {}
}; };
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
#define FMT_ATTR __attribute__((format(printf, 2, 3))) // sic! 1st is "this" I guess. #define FMT_ATTR __attribute__((format(printf, 2, 3))) // sic! 1st is "this" I guess.
class Reporter { class Reporter {
@ -304,3 +301,11 @@ private:
}; };
extern Reporter* reporter; extern Reporter* reporter;
} // namespace zeek
using Reporter [[deprecated("Remove in v4.1. Use zeek::Reporter.")]] = zeek::Reporter;
using ReporterException [[deprecated("Remove in v4.1. Use zeek::ReporterException.")]] = zeek::ReporterException;
using InterpreterException [[deprecated("Remove in v4.1. Use zeek::InterpreterException.")]] = zeek::InterpreterException;
extern zeek::Reporter*& reporter [[deprecated("Remove v4.1. Use zeek::reporter.")]];

View file

@ -54,7 +54,7 @@ RuleActionAnalyzer::RuleActionAnalyzer(const char* arg_analyzer)
analyzer = zeek::analyzer_mgr->GetComponentTag(arg.c_str()); analyzer = zeek::analyzer_mgr->GetComponentTag(arg.c_str());
if ( ! analyzer ) if ( ! analyzer )
reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str()); zeek::reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str());
if ( pos != string::npos ) if ( pos != string::npos )
{ {
@ -62,7 +62,7 @@ RuleActionAnalyzer::RuleActionAnalyzer(const char* arg_analyzer)
child_analyzer = zeek::analyzer_mgr->GetComponentTag(arg.c_str()); child_analyzer = zeek::analyzer_mgr->GetComponentTag(arg.c_str());
if ( ! child_analyzer ) if ( ! child_analyzer )
reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str()); zeek::reporter->Warning("unknown analyzer '%s' specified in rule", arg.c_str());
} }
else else
child_analyzer = zeek::analyzer::Tag(); child_analyzer = zeek::analyzer::Tag();

View file

@ -122,7 +122,7 @@ bool RuleConditionPayloadSize::DoMatch(Rule* rule, RuleEndpointState* state,
return payload_size >= val; return payload_size >= val;
default: default:
reporter->InternalError("unknown comparison type"); zeek::reporter->InternalError("unknown comparison type");
} }
// Should not be reached // Should not be reached
@ -162,7 +162,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state,
{ {
if ( ! id->HasVal() ) if ( ! id->HasVal() )
{ {
reporter->Error("undefined value"); zeek::reporter->Error("undefined value");
return false; return false;
} }

View file

@ -265,7 +265,7 @@ bool RuleMatcher::ReadFiles(const std::vector<std::string>& files)
if ( ! rules_in ) if ( ! rules_in )
{ {
reporter->Error("Can't open signature file %s", f.data()); zeek::reporter->Error("Can't open signature file %s", f.data());
return false; return false;
} }
@ -482,7 +482,7 @@ static inline uint32_t getval(const u_char* data, int size)
return ntohl(*(uint32_t*) data); return ntohl(*(uint32_t*) data);
default: default:
reporter->InternalError("illegal HdrTest size"); zeek::reporter->InternalError("illegal HdrTest size");
} }
// Should not be reached. // Should not be reached.
@ -576,7 +576,7 @@ static inline bool compare(const maskedvalue_list& mvals, uint32_t v,
break; break;
default: default:
reporter->InternalError("unknown RuleHdrTest comparison type"); zeek::reporter->InternalError("unknown RuleHdrTest comparison type");
break; break;
} }
return false; return false;
@ -611,7 +611,7 @@ static inline bool compare(const vector<zeek::IPPrefix>& prefixes, const zeek::I
break; break;
default: default:
reporter->InternalError("unknown RuleHdrTest comparison type"); zeek::reporter->InternalError("unknown RuleHdrTest comparison type");
break; break;
} }
return false; return false;
@ -666,7 +666,7 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state,
if ( ! state ) if ( ! state )
{ {
reporter->Warning("RuleFileMagicState not initialized yet."); zeek::reporter->Warning("RuleFileMagicState not initialized yet.");
return rval; return rval;
} }
@ -831,7 +831,7 @@ RuleEndpointState* RuleMatcher::InitEndpoint(zeek::analyzer::Analyzer* analyzer,
break; break;
default: default:
reporter->InternalError("unknown RuleHdrTest protocol type"); zeek::reporter->InternalError("unknown RuleHdrTest protocol type");
break; break;
} }
@ -856,7 +856,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type,
{ {
if ( ! state ) if ( ! state )
{ {
reporter->Warning("RuleEndpointState not initialized yet."); zeek::reporter->Warning("RuleEndpointState not initialized yet.");
return; return;
} }

View file

@ -30,7 +30,7 @@ Scope::Scope(zeek::detail::IDPtr id,
if ( id_type->Tag() == zeek::TYPE_ERROR ) if ( id_type->Tag() == zeek::TYPE_ERROR )
return; return;
else if ( id_type->Tag() != zeek::TYPE_FUNC ) else if ( id_type->Tag() != zeek::TYPE_FUNC )
reporter->InternalError("bad scope id"); zeek::reporter->InternalError("bad scope id");
zeek::FuncType* ft = id->GetType()->AsFuncType(); zeek::FuncType* ft = id->GetType()->AsFuncType();
return_type = ft->Yield(); return_type = ft->Yield();
@ -138,7 +138,7 @@ const zeek::detail::IDPtr& lookup_ID(const char* name, const char* curr_module,
if ( id ) if ( id )
{ {
if ( need_export && ! id->IsExport() && ! in_debug ) if ( need_export && ! id->IsExport() && ! in_debug )
reporter->Error("identifier is not exported: %s", zeek::reporter->Error("identifier is not exported: %s",
fullname.c_str()); fullname.c_str());
return id; return id;
@ -159,7 +159,7 @@ zeek::detail::IDPtr install_ID(const char* name, const char* module_name,
bool is_global, bool is_export) bool is_global, bool is_export)
{ {
if ( scopes.empty() && ! is_global ) if ( scopes.empty() && ! is_global )
reporter->InternalError("local identifier in global scope"); zeek::reporter->InternalError("local identifier in global scope");
zeek::detail::IDScope scope; zeek::detail::IDScope scope;
if ( is_export || ! module_name || if ( is_export || ! module_name ||
@ -201,7 +201,7 @@ void push_scope(zeek::detail::IDPtr id,
ScopePtr pop_scope() ScopePtr pop_scope()
{ {
if ( scopes.empty() ) if ( scopes.empty() )
reporter->InternalError("scope underflow"); zeek::reporter->InternalError("scope underflow");
scopes.pop_back(); scopes.pop_back();
Scope* old_top = top_scope; Scope* old_top = top_scope;

View file

@ -65,7 +65,7 @@ bool SerializationFormat::ReadData(void* b, size_t count)
{ {
if ( input_pos + count > input_len ) if ( input_pos + count > input_len )
{ {
reporter->Error("data underflow during read in binary format"); zeek::reporter->Error("data underflow during read in binary format");
abort(); abort();
return false; return false;
} }
@ -207,7 +207,7 @@ bool BinarySerializationFormat::Read(char** str, int* len, const char* tag)
for ( int i = 0; i < l; i++ ) for ( int i = 0; i < l; i++ )
if ( ! s[i] ) if ( ! s[i] )
{ {
reporter->Error("binary Format: string contains null; replaced by '_'"); zeek::reporter->Error("binary Format: string contains null; replaced by '_'");
s[i] = '_'; s[i] = '_';
} }
} }

View file

@ -839,7 +839,7 @@ int NetSessions::ParseIPPacket(int caplen, const u_char* const pkt, int proto,
else else
{ {
reporter->InternalWarning("Bad IP protocol version in ParseIPPacket"); zeek::reporter->InternalWarning("Bad IP protocol version in ParseIPPacket");
return -1; return -1;
} }
@ -1024,21 +1024,21 @@ void NetSessions::Remove(Connection* c)
switch ( c->ConnTransport() ) { switch ( c->ConnTransport() ) {
case TRANSPORT_TCP: case TRANSPORT_TCP:
if ( tcp_conns.erase(key) == 0 ) if ( tcp_conns.erase(key) == 0 )
reporter->InternalWarning("connection missing"); zeek::reporter->InternalWarning("connection missing");
break; break;
case TRANSPORT_UDP: case TRANSPORT_UDP:
if ( udp_conns.erase(key) == 0 ) if ( udp_conns.erase(key) == 0 )
reporter->InternalWarning("connection missing"); zeek::reporter->InternalWarning("connection missing");
break; break;
case TRANSPORT_ICMP: case TRANSPORT_ICMP:
if ( icmp_conns.erase(key) == 0 ) if ( icmp_conns.erase(key) == 0 )
reporter->InternalWarning("connection missing"); zeek::reporter->InternalWarning("connection missing");
break; break;
case TRANSPORT_UNKNOWN: case TRANSPORT_UNKNOWN:
reporter->InternalWarning("unknown transport when removing connection"); zeek::reporter->InternalWarning("unknown transport when removing connection");
break; break;
} }
@ -1052,7 +1052,7 @@ void NetSessions::Remove(FragReassembler* f)
return; return;
if ( fragments.erase(f->Key()) == 0 ) if ( fragments.erase(f->Key()) == 0 )
reporter->InternalWarning("fragment reassembler not in dict"); zeek::reporter->InternalWarning("fragment reassembler not in dict");
Unref(f); Unref(f);
} }
@ -1086,7 +1086,7 @@ void NetSessions::Insert(Connection* c)
break; break;
default: default:
reporter->InternalWarning("unknown connection type"); zeek::reporter->InternalWarning("unknown connection type");
Unref(c); Unref(c);
return; return;
} }
@ -1185,7 +1185,7 @@ Connection* NetSessions::NewConn(const zeek::detail::ConnIDKey& k, double t, con
tproto = TRANSPORT_ICMP; tproto = TRANSPORT_ICMP;
break; break;
default: default:
reporter->InternalWarning("unknown transport protocol"); zeek::reporter->InternalWarning("unknown transport protocol");
return nullptr; return nullptr;
}; };
@ -1310,7 +1310,7 @@ void NetSessions::DumpPacket(const Packet *pkt, int len)
if ( len != 0 ) if ( len != 0 )
{ {
if ( (uint32_t)len > pkt->cap_len ) if ( (uint32_t)len > pkt->cap_len )
reporter->Warning("bad modified caplen"); zeek::reporter->Warning("bad modified caplen");
else else
const_cast<Packet *>(pkt)->cap_len = len; const_cast<Packet *>(pkt)->cap_len = len;
} }
@ -1325,19 +1325,19 @@ void NetSessions::Weird(const char* name, const Packet* pkt,
dump_this_packet = true; dump_this_packet = true;
if ( encap && encap->LastType() != BifEnum::Tunnel::NONE ) if ( encap && encap->LastType() != BifEnum::Tunnel::NONE )
reporter->Weird(fmt("%s_in_tunnel", name), addl); zeek::reporter->Weird(fmt("%s_in_tunnel", name), addl);
else else
reporter->Weird(name, addl); zeek::reporter->Weird(name, addl);
} }
void NetSessions::Weird(const char* name, const zeek::IP_Hdr* ip, void NetSessions::Weird(const char* name, const zeek::IP_Hdr* ip,
const EncapsulationStack* encap, const char* addl) const EncapsulationStack* encap, const char* addl)
{ {
if ( encap && encap->LastType() != BifEnum::Tunnel::NONE ) if ( encap && encap->LastType() != BifEnum::Tunnel::NONE )
reporter->Weird(ip->SrcAddr(), ip->DstAddr(), zeek::reporter->Weird(ip->SrcAddr(), ip->DstAddr(),
fmt("%s_in_tunnel", name), addl); fmt("%s_in_tunnel", name), addl);
else else
reporter->Weird(ip->SrcAddr(), ip->DstAddr(), name, addl); zeek::reporter->Weird(ip->SrcAddr(), ip->DstAddr(), name, addl);
} }
unsigned int NetSessions::ConnectionMemoryUsage() unsigned int NetSessions::ConnectionMemoryUsage()

View file

@ -174,7 +174,7 @@ bool SubstringCmp::operator()(const Substring* bst1,
if ( _index >= bst1->GetNumAlignments() || if ( _index >= bst1->GetNumAlignments() ||
_index >= bst2->GetNumAlignments() ) _index >= bst2->GetNumAlignments() )
{ {
reporter->Warning("SubstringCmp::operator(): invalid index for input strings.\n"); zeek::reporter->Warning("SubstringCmp::operator(): invalid index for input strings.\n");
return false; return false;
} }

View file

@ -120,7 +120,7 @@ void Stmt::DecrBPCount()
if ( breakpoint_count ) if ( breakpoint_count )
--breakpoint_count; --breakpoint_count;
else else
reporter->InternalError("breakpoint count decremented below 0"); zeek::reporter->InternalError("breakpoint count decremented below 0");
} }
void Stmt::AddTag(ODesc* d) const void Stmt::AddTag(ODesc* d) const
@ -279,7 +279,7 @@ ValPtr PrintStmt::DoExec(std::vector<ValPtr> vals,
} }
break; break;
default: default:
reporter->InternalError("unknown Log::PrintLogType value: %d", zeek::reporter->InternalError("unknown Log::PrintLogType value: %d",
print_log_type); print_log_type);
break; break;
} }
@ -745,9 +745,10 @@ bool SwitchStmt::AddCaseLabelValueMapping(const Val* v, int idx)
if ( ! hk ) if ( ! hk )
{ {
reporter->PushLocation(e->GetLocationInfo()); zeek::reporter->PushLocation(e->GetLocationInfo());
reporter->InternalError("switch expression type mismatch (%s/%s)", zeek::reporter->InternalError("switch expression type mismatch (%s/%s)",
type_name(v->GetType()->Tag()), type_name(e->GetType()->Tag())); type_name(v->GetType()->Tag()),
type_name(e->GetType()->Tag()));
} }
int* label_idx = case_label_value_map.Lookup(hk.get()); int* label_idx = case_label_value_map.Lookup(hk.get());
@ -785,9 +786,10 @@ std::pair<int, ID*> SwitchStmt::FindCaseLabelMatch(const Val* v) const
if ( ! hk ) if ( ! hk )
{ {
reporter->PushLocation(e->GetLocationInfo()); zeek::reporter->PushLocation(e->GetLocationInfo());
reporter->Error("switch expression type mismatch (%s/%s)", zeek::reporter->Error("switch expression type mismatch (%s/%s)",
type_name(v->GetType()->Tag()), type_name(e->GetType()->Tag())); type_name(v->GetType()->Tag()),
type_name(e->GetType()->Tag()));
return std::make_pair(-1, nullptr); return std::make_pair(-1, nullptr);
} }

View file

@ -128,7 +128,7 @@ void PQ_TimerMgr::Add(Timer* timer)
// multiple already-added timers are added, they'll still // multiple already-added timers are added, they'll still
// execute in sorted order. // execute in sorted order.
if ( ! q->Add(timer) ) if ( ! q->Add(timer) )
reporter->InternalError("out of memory"); zeek::reporter->InternalError("out of memory");
++current_timers[timer->Type()]; ++current_timers[timer->Type()];
} }
@ -174,7 +174,7 @@ int PQ_TimerMgr::DoAdvance(double new_t, int max_expire)
void PQ_TimerMgr::Remove(Timer* timer) void PQ_TimerMgr::Remove(Timer* timer)
{ {
if ( ! q->Remove(timer) ) if ( ! q->Remove(timer) )
reporter->InternalError("asked to remove a missing timer"); zeek::reporter->InternalError("asked to remove a missing timer");
--current_timers[timer->Type()]; --current_timers[timer->Type()];
delete timer; delete timer;

View file

@ -142,7 +142,7 @@ Trigger::Trigger(zeek::detail::Expr* arg_cond, zeek::detail::Stmt* arg_body,
Trigger* parent = frame->GetTrigger(); Trigger* parent = frame->GetTrigger();
if ( ! parent ) if ( ! parent )
{ {
reporter->Error("return trigger in context which does not allow delaying result"); zeek::reporter->Error("return trigger in context which does not allow delaying result");
Unref(this); Unref(this);
return; return;
} }

View file

@ -217,7 +217,7 @@ TypePtr Type::ShallowClone()
return zeek::make_intrusive<Type>(tag, base_type); return zeek::make_intrusive<Type>(tag, base_type);
default: default:
reporter->InternalError("cloning illegal base Type"); zeek::reporter->InternalError("cloning illegal base Type");
} }
return nullptr; return nullptr;
} }
@ -291,7 +291,7 @@ bool TypeList::AllMatch(const Type* t, bool is_init) const
void TypeList::Append(TypePtr t) void TypeList::Append(TypePtr t)
{ {
if ( pure_type && ! same_type(t, pure_type) ) if ( pure_type && ! same_type(t, pure_type) )
reporter->InternalError("pure type-list violation"); zeek::reporter->InternalError("pure type-list violation");
types_list.push_back(t.get()); types_list.push_back(t.get());
types.emplace_back(std::move(t)); types.emplace_back(std::move(t));
@ -591,7 +591,7 @@ string FuncType::FlavorString() const
return "hook"; return "hook";
default: default:
reporter->InternalError("Invalid function flavor"); zeek::reporter->InternalError("Invalid function flavor");
return "invalid_func_flavor"; return "invalid_func_flavor";
} }
} }
@ -1062,7 +1062,7 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const
if ( ! doc ) if ( ! doc )
{ {
reporter->InternalWarning("Failed to lookup record doc: %s", zeek::reporter->InternalWarning("Failed to lookup record doc: %s",
GetName().c_str()); GetName().c_str());
continue; continue;
} }
@ -1210,7 +1210,7 @@ TypePtr EnumType::ShallowClone()
EnumType::~EnumType() = default; EnumType::~EnumType() = default;
// Note, we use reporter->Error() here (not Error()) to include the current script // Note, we use zeek::reporter->Error() here (not Error()) to include the current script
// location in the error message, rather than the one where the type was // location in the error message, rather than the one where the type was
// originally defined. // originally defined.
void EnumType::AddName(const string& module_name, const char* name, bool is_export, zeek::detail::Expr* deprecation) void EnumType::AddName(const string& module_name, const char* name, bool is_export, zeek::detail::Expr* deprecation)
@ -1218,7 +1218,7 @@ void EnumType::AddName(const string& module_name, const char* name, bool is_expo
/* implicit, auto-increment */ /* implicit, auto-increment */
if ( counter < 0) if ( counter < 0)
{ {
reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); zeek::reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment");
SetError(); SetError();
return; return;
} }
@ -1231,7 +1231,7 @@ void EnumType::AddName(const string& module_name, const char* name, bro_int_t va
/* explicit value specified */ /* explicit value specified */
if ( counter > 0 ) if ( counter > 0 )
{ {
reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment"); zeek::reporter->Error("cannot mix explicit enumerator assignment and implicit auto-increment");
SetError(); SetError();
return; return;
} }
@ -1244,7 +1244,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
{ {
if ( Lookup(val) ) if ( Lookup(val) )
{ {
reporter->Error("enumerator value in enumerated type definition already exists"); zeek::reporter->Error("enumerator value in enumerated type definition already exists");
SetError(); SetError();
return; return;
} }
@ -1272,7 +1272,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
|| (id->HasVal() && val != id->GetVal()->AsEnum()) || (id->HasVal() && val != id->GetVal()->AsEnum())
|| (names.find(fullname) != names.end() && names[fullname] != val) ) || (names.find(fullname) != names.end() && names[fullname] != val) )
{ {
reporter->Error("identifier or enumerator value in enumerated type definition already exists"); zeek::reporter->Error("identifier or enumerator value in enumerated type definition already exists");
SetError(); SetError();
return; return;
} }
@ -1378,7 +1378,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
if ( ! doc ) if ( ! doc )
{ {
reporter->InternalWarning("Enum %s documentation lookup failure", zeek::reporter->InternalWarning("Enum %s documentation lookup failure",
it->second.c_str()); it->second.c_str());
continue; continue;
} }
@ -1664,7 +1664,7 @@ bool same_type(const Type& arg_t1, const Type& arg_t2,
} }
case TYPE_UNION: case TYPE_UNION:
reporter->Error("union type in same_type()"); zeek::reporter->Error("union type in same_type()");
} }
return false; return false;
} }
@ -1724,7 +1724,7 @@ const Type* flatten_type(const Type* t)
const auto& types = tl->GetTypes(); const auto& types = tl->GetTypes();
if ( types.size() == 0 ) if ( types.size() == 0 )
reporter->InternalError("empty type list in flatten_type"); zeek::reporter->InternalError("empty type list in flatten_type");
const auto& ft = types[0]; const auto& ft = types[0];
@ -1774,7 +1774,7 @@ bool is_assignable(TypeTag t)
return false; return false;
case TYPE_UNION: case TYPE_UNION:
reporter->Error("union type in is_assignable()"); zeek::reporter->Error("union type in is_assignable()");
} }
return false; return false;
@ -1803,7 +1803,7 @@ TypeTag max_type(TypeTag t1, TypeTag t2)
} }
else else
{ {
reporter->InternalError("non-arithmetic tags in max_type()"); zeek::reporter->InternalError("non-arithmetic tags in max_type()");
return TYPE_ERROR; return TYPE_ERROR;
} }
} }
@ -2039,11 +2039,11 @@ TypePtr merge_types(const TypePtr& arg_t1,
return zeek::make_intrusive<FileType>(merge_types(t1->Yield(), t2->Yield())); return zeek::make_intrusive<FileType>(merge_types(t1->Yield(), t2->Yield()));
case TYPE_UNION: case TYPE_UNION:
reporter->InternalError("union type in merge_types()"); zeek::reporter->InternalError("union type in merge_types()");
return nullptr; return nullptr;
default: default:
reporter->InternalError("bad type in merge_types()"); zeek::reporter->InternalError("bad type in merge_types()");
return nullptr; return nullptr;
} }
} }
@ -2055,7 +2055,7 @@ TypePtr merge_type_list(zeek::detail::ListExpr* elements)
if ( tl.size() < 1 ) if ( tl.size() < 1 )
{ {
reporter->Error("no type can be inferred for empty list"); zeek::reporter->Error("no type can be inferred for empty list");
return nullptr; return nullptr;
} }
@ -2068,7 +2068,7 @@ TypePtr merge_type_list(zeek::detail::ListExpr* elements)
t = merge_types(t, tl[i]); t = merge_types(t, tl[i]);
if ( ! t ) if ( ! t )
reporter->Error("inconsistent types in list"); zeek::reporter->Error("inconsistent types in list");
return t; return t;
} }

View file

@ -32,7 +32,7 @@ void UID::Set(bro_uint_t bits, const uint64_t* v, size_t n)
std::string UID::Base62(std::string prefix) const std::string UID::Base62(std::string prefix) const
{ {
if ( ! initialized ) if ( ! initialized )
reporter->InternalError("use of uninitialized UID"); zeek::reporter->InternalError("use of uninitialized UID");
char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation
for ( size_t i = 0; i < BRO_UID_LEN; ++i ) for ( size_t i = 0; i < BRO_UID_LEN; ++i )

View file

@ -27,7 +27,7 @@ static zeek::ValPtr init_val(zeek::detail::Expr* init,
{ {
return init->InitVal(t, std::move(aggr)); return init->InitVal(t, std::move(aggr));
} }
catch ( InterpreterException& e ) catch ( zeek::InterpreterException& e )
{ {
return nullptr; return nullptr;
} }
@ -541,11 +541,11 @@ void begin_func(zeek::detail::IDPtr id, const char* module_name,
if ( f->attrs && f->attrs->Find(zeek::detail::ATTR_DEFAULT) ) if ( f->attrs && f->attrs->Find(zeek::detail::ATTR_DEFAULT) )
{ {
reporter->PushLocation(args->GetLocationInfo()); zeek::reporter->PushLocation(args->GetLocationInfo());
reporter->Warning( zeek::reporter->Warning(
"&default on parameter '%s' has no effect (not a %s declaration)", "&default on parameter '%s' has no effect (not a %s declaration)",
args->FieldName(i), t->FlavorString().data()); args->FieldName(i), t->FlavorString().data());
reporter->PopLocation(); zeek::reporter->PopLocation();
} }
} }
} }
@ -597,7 +597,7 @@ void begin_func(zeek::detail::IDPtr id, const char* module_name,
break; break;
default: default:
reporter->InternalError("invalid function flavor"); zeek::reporter->InternalError("invalid function flavor");
break; break;
} }
} }
@ -836,7 +836,7 @@ zeek::ListVal* internal_list_val(const char* name)
} }
else else
reporter->InternalError("internal variable %s is not a list", name); zeek::reporter->InternalError("internal variable %s is not a list", name);
} }
return nullptr; return nullptr;

View file

@ -202,7 +202,7 @@ void ARP_Analyzer::BadARP(const struct arp_pkthdr* hdr, const char* msg)
void ARP_Analyzer::Corrupted(const char* msg) void ARP_Analyzer::Corrupted(const char* msg)
{ {
reporter->Weird(msg); zeek::reporter->Weird(msg);
} }
void ARP_Analyzer::RREvent(EventHandlerPtr e, void ARP_Analyzer::RREvent(EventHandlerPtr e,

View file

@ -120,7 +120,7 @@ zeek::ValPtr asn1_integer_to_val(const ASN1Encoding* i, zeek::TypeTag t)
case zeek::TYPE_COUNTER: case zeek::TYPE_COUNTER:
return zeek::val_mgr->Count(v); return zeek::val_mgr->Count(v);
default: default:
reporter->Error("bad asn1_integer_to_val tag: %s", zeek::type_name(t)); zeek::reporter->Error("bad asn1_integer_to_val tag: %s", zeek::type_name(t));
return zeek::val_mgr->Count(v); return zeek::val_mgr->Count(v);
} }
} }

View file

@ -20,7 +20,7 @@ flow AYIYA_Flow
if ( e && e->Depth() >= zeek::BifConst::Tunnel::max_depth ) if ( e && e->Depth() >= zeek::BifConst::Tunnel::max_depth )
{ {
reporter->Weird(c, "tunnel_depth"); zeek::reporter->Weird(c, "tunnel_depth");
return false; return false;
} }
@ -33,7 +33,7 @@ flow AYIYA_Flow
if ( ${pdu.next_header} != IPPROTO_IPV6 && if ( ${pdu.next_header} != IPPROTO_IPV6 &&
${pdu.next_header} != IPPROTO_IPV4 ) ${pdu.next_header} != IPPROTO_IPV4 )
{ {
reporter->Weird(c, "ayiya_tunnel_non_ip"); zeek::reporter->Weird(c, "ayiya_tunnel_non_ip");
return false; return false;
} }

View file

@ -178,10 +178,10 @@ void ConnSize_Analyzer::UpdateConnVal(zeek::RecordVal *conn_val)
int bytesidx = zeek::id::endpoint->FieldOffset("num_bytes_ip"); int bytesidx = zeek::id::endpoint->FieldOffset("num_bytes_ip");
if ( pktidx < 0 ) if ( pktidx < 0 )
reporter->InternalError("'endpoint' record missing 'num_pkts' field"); zeek::reporter->InternalError("'endpoint' record missing 'num_pkts' field");
if ( bytesidx < 0 ) if ( bytesidx < 0 )
reporter->InternalError("'endpoint' record missing 'num_bytes_ip' field"); zeek::reporter->InternalError("'endpoint' record missing 'num_bytes_ip' field");
orig_endp->Assign(pktidx, zeek::val_mgr->Count(orig_pkts)); orig_endp->Assign(pktidx, zeek::val_mgr->Count(orig_pkts));
orig_endp->Assign(bytesidx, zeek::val_mgr->Count(orig_bytes)); orig_endp->Assign(bytesidx, zeek::val_mgr->Count(orig_bytes));

View file

@ -11,7 +11,7 @@ static zeek::analyzer::Analyzer* GetConnsizeAnalyzer(zeek::Val* cid)
zeek::analyzer::Analyzer* a = c->FindAnalyzer("CONNSIZE"); zeek::analyzer::Analyzer* a = c->FindAnalyzer("CONNSIZE");
if ( ! a ) if ( ! a )
reporter->Error("connection does not have ConnSize analyzer"); zeek::reporter->Error("connection does not have ConnSize analyzer");
return a; return a;
} }

View file

@ -190,7 +190,7 @@ flow DCE_RPC_Flow(is_orig: bool) {
if ( it != fb.end() ) if ( it != fb.end() )
{ {
// We already had a first frag earlier. // We already had a first frag earlier.
reporter->Weird(connection()->bro_analyzer()->Conn(), zeek::reporter->Weird(connection()->bro_analyzer()->Conn(),
"multiple_first_fragments_in_dce_rpc_reassembly"); "multiple_first_fragments_in_dce_rpc_reassembly");
connection()->bro_analyzer()->SetSkip(true); connection()->bro_analyzer()->SetSkip(true);
return false; return false;
@ -212,14 +212,14 @@ flow DCE_RPC_Flow(is_orig: bool) {
if ( fb.size() > zeek::BifConst::DCE_RPC::max_cmd_reassembly ) if ( fb.size() > zeek::BifConst::DCE_RPC::max_cmd_reassembly )
{ {
reporter->Weird(connection()->bro_analyzer()->Conn(), zeek::reporter->Weird(connection()->bro_analyzer()->Conn(),
"too_many_dce_rpc_msgs_in_reassembly"); "too_many_dce_rpc_msgs_in_reassembly");
connection()->bro_analyzer()->SetSkip(true); connection()->bro_analyzer()->SetSkip(true);
} }
if ( flowbuf->data_length() > (int)zeek::BifConst::DCE_RPC::max_frag_data ) if ( flowbuf->data_length() > (int)zeek::BifConst::DCE_RPC::max_frag_data )
{ {
reporter->Weird(connection()->bro_analyzer()->Conn(), zeek::reporter->Weird(connection()->bro_analyzer()->Conn(),
"too_much_dce_rpc_fragment_data"); "too_much_dce_rpc_fragment_data");
connection()->bro_analyzer()->SetSkip(true); connection()->bro_analyzer()->SetSkip(true);
} }
@ -235,7 +235,7 @@ flow DCE_RPC_Flow(is_orig: bool) {
if ( flowbuf->data_length() > (int)zeek::BifConst::DCE_RPC::max_frag_data ) if ( flowbuf->data_length() > (int)zeek::BifConst::DCE_RPC::max_frag_data )
{ {
reporter->Weird(connection()->bro_analyzer()->Conn(), zeek::reporter->Weird(connection()->bro_analyzer()->Conn(),
"too_much_dce_rpc_fragment_data"); "too_much_dce_rpc_fragment_data");
connection()->bro_analyzer()->SetSkip(true); connection()->bro_analyzer()->SetSkip(true);
} }

View file

@ -235,13 +235,13 @@ int DNP3_Base::AddToBuffer(Endpoint* endp, int target_len, const u_char** data,
if ( *len < 0 ) if ( *len < 0 )
{ {
reporter->AnalyzerError(analyzer, "dnp3 negative input length: %d", *len); zeek::reporter->AnalyzerError(analyzer, "dnp3 negative input length: %d", *len);
return -1; return -1;
} }
if ( target_len < endp->buffer_len ) if ( target_len < endp->buffer_len )
{ {
reporter->AnalyzerError(analyzer, "dnp3 invalid target length: %d - %d", zeek::reporter->AnalyzerError(analyzer, "dnp3 invalid target length: %d - %d",
target_len, endp->buffer_len); target_len, endp->buffer_len);
return -1; return -1;
} }
@ -250,7 +250,7 @@ int DNP3_Base::AddToBuffer(Endpoint* endp, int target_len, const u_char** data,
if ( endp->buffer_len + to_copy > MAX_BUFFER_SIZE ) if ( endp->buffer_len + to_copy > MAX_BUFFER_SIZE )
{ {
reporter->AnalyzerError(analyzer, "dnp3 buffer length exceeded: %d + %d", zeek::reporter->AnalyzerError(analyzer, "dnp3 buffer length exceeded: %d + %d",
endp->buffer_len, to_copy); endp->buffer_len, to_copy);
return -1; return -1;
} }
@ -296,7 +296,7 @@ bool DNP3_Base::ParseAppLayer(Endpoint* endp)
if ( data + n >= endp->buffer + endp->buffer_len ) if ( data + n >= endp->buffer + endp->buffer_len )
{ {
reporter->AnalyzerError(analyzer, zeek::reporter->AnalyzerError(analyzer,
"dnp3 app layer parsing overflow %d - %d", "dnp3 app layer parsing overflow %d - %d",
endp->buffer_len, n); endp->buffer_len, n);
return false; return false;

View file

@ -654,7 +654,7 @@ flow GTPv1_Flow(is_orig: bool)
if ( e && e->Depth() >= zeek::BifConst::Tunnel::max_depth ) if ( e && e->Depth() >= zeek::BifConst::Tunnel::max_depth )
{ {
reporter->Weird(c, "tunnel_depth"); zeek::reporter->Weird(c, "tunnel_depth");
return false; return false;
} }

View file

@ -798,7 +798,7 @@ void HTTP_Message::SubmitEvent(int event_type, const char* detail)
break; break;
default: default:
reporter->AnalyzerError(MyHTTP_Analyzer(), zeek::reporter->AnalyzerError(MyHTTP_Analyzer(),
"unrecognized HTTP message event"); "unrecognized HTTP message event");
return; return;
} }
@ -1238,7 +1238,7 @@ int HTTP_Analyzer::HTTP_RequestLine(const char* line, const char* end_of_line)
if ( ! ParseRequest(rest, end_of_line) ) if ( ! ParseRequest(rest, end_of_line) )
{ {
reporter->AnalyzerError(this, "HTTP ParseRequest failed"); zeek::reporter->AnalyzerError(this, "HTTP ParseRequest failed");
return -1; return -1;
} }
@ -1251,11 +1251,11 @@ int HTTP_Analyzer::HTTP_RequestLine(const char* line, const char* end_of_line)
return 1; return 1;
bad_http_request_with_version: bad_http_request_with_version:
reporter->Weird(Conn(), "bad_HTTP_request_with_version"); zeek::reporter->Weird(Conn(), "bad_HTTP_request_with_version");
return 0; return 0;
error: error:
reporter->Weird(Conn(), "bad_HTTP_request"); zeek::reporter->Weird(Conn(), "bad_HTTP_request");
return 0; return 0;
} }

View file

@ -64,8 +64,8 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data,
break; break;
default: default:
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"unexpected IP proto in ICMP analyzer: %d", ip->NextProto()); this, "unexpected IP proto in ICMP analyzer: %d", ip->NextProto());
return; return;
} }
@ -104,8 +104,8 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data,
NextICMP6(current_timestamp, icmpp, len, caplen, data, ip); NextICMP6(current_timestamp, icmpp, len, caplen, data, ip);
else else
{ {
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"expected ICMP as IP packet's protocol, got %d", ip->NextProto()); this, "expected ICMP as IP packet's protocol, got %d", ip->NextProto());
return; return;
} }

View file

@ -33,7 +33,7 @@ refine connection IMAP_Conn += {
if ( is_orig && commands == "starttls" ) if ( is_orig && commands == "starttls" )
{ {
if ( !client_starttls_id.empty() ) if ( !client_starttls_id.empty() )
reporter->Weird(bro_analyzer()->Conn(), "IMAP: client sent duplicate StartTLS"); zeek::reporter->Weird(bro_analyzer()->Conn(), "IMAP: client sent duplicate StartTLS");
client_starttls_id = tags; client_starttls_id = tags;
} }
@ -48,7 +48,7 @@ refine connection IMAP_Conn += {
zeek::BifEvent::enqueue_imap_starttls(bro_analyzer(), bro_analyzer()->Conn()); zeek::BifEvent::enqueue_imap_starttls(bro_analyzer(), bro_analyzer()->Conn());
} }
else else
reporter->Weird(bro_analyzer()->Conn(), "IMAP: server refused StartTLS"); zeek::reporter->Weird(bro_analyzer()->Conn(), "IMAP: server refused StartTLS");
} }
return true; return true;

View file

@ -29,7 +29,7 @@ KRB_Analyzer::KRB_Analyzer(Connection* conn)
static void warn_krb(const char* msg, krb5_context ctx, krb5_error_code code) static void warn_krb(const char* msg, krb5_context ctx, krb5_error_code code)
{ {
auto err = krb5_get_error_message(ctx, code); auto err = krb5_get_error_message(ctx, code);
reporter->Warning("%s (%s)", msg, err); zeek::reporter->Warning("%s (%s)", msg, err);
krb5_free_error_message(ctx, err); krb5_free_error_message(ctx, err);
} }
@ -41,7 +41,7 @@ void KRB_Analyzer::Initialize_Krb()
const char* keytab_filename = zeek::BifConst::KRB::keytab->CheckString(); const char* keytab_filename = zeek::BifConst::KRB::keytab->CheckString();
if ( access(keytab_filename, R_OK) != 0 ) if ( access(keytab_filename, R_OK) != 0 )
{ {
reporter->Warning("KRB: Can't access keytab (%s)", keytab_filename); zeek::reporter->Warning("KRB: Can't access keytab (%s)", keytab_filename);
return; return;
} }
@ -99,14 +99,14 @@ zeek::StringValPtr KRB_Analyzer::GetAuthenticationInfo(const zeek::String* princ
int pos = principal->FindSubstring(&delim); int pos = principal->FindSubstring(&delim);
if ( pos == -1 ) if ( pos == -1 )
{ {
reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString()); zeek::reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString());
return nullptr; return nullptr;
} }
std::unique_ptr<zeek::String> service = unique_ptr<zeek::String>(principal->GetSubstring(0, pos)); std::unique_ptr<zeek::String> service = unique_ptr<zeek::String>(principal->GetSubstring(0, pos));
std::unique_ptr<zeek::String> hostname = unique_ptr<zeek::String>(principal->GetSubstring(pos + 1, -1)); std::unique_ptr<zeek::String> hostname = unique_ptr<zeek::String>(principal->GetSubstring(pos + 1, -1));
if ( !service || !hostname ) if ( !service || !hostname )
{ {
reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString()); zeek::reporter->Warning("KRB: Couldn't parse principal (%s)", principal->CheckString());
return nullptr; return nullptr;
} }
krb5_principal sprinc; krb5_principal sprinc;

View file

@ -129,8 +129,8 @@ void Login_Analyzer::NewLine(bool orig, char* line)
if ( state != LOGIN_STATE_CONFUSED ) if ( state != LOGIN_STATE_CONFUSED )
{ {
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"bad state in Login_Analyzer::NewLine"); this, "bad state in Login_Analyzer::NewLine");
return; return;
} }
@ -572,8 +572,8 @@ char* Login_Analyzer::PeekUserText()
{ {
if ( num_user_text <= 0 ) if ( num_user_text <= 0 )
{ {
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"underflow in Login_Analyzer::PeekUserText()"); this, "underflow in Login_Analyzer::PeekUserText()");
return nullptr; return nullptr;
} }

View file

@ -44,8 +44,8 @@ void TelnetOption::RecvOption(unsigned int type)
if ( ! peer ) if ( ! peer )
{ {
reporter->AnalyzerError(endp, zeek::reporter->AnalyzerError(
"option peer missing in TelnetOption::RecvOption"); endp, "option peer missing in TelnetOption::RecvOption");
return; return;
} }
@ -92,8 +92,8 @@ void TelnetOption::RecvOption(unsigned int type)
break; break;
default: default:
reporter->AnalyzerError(endp, zeek::reporter->AnalyzerError(
"bad option type in TelnetOption::RecvOption"); endp, "bad option type in TelnetOption::RecvOption");
return; return;
} }
} }
@ -175,8 +175,8 @@ void TelnetEncryptOption::RecvSubOption(u_char* data, int len)
if ( ! peer ) if ( ! peer )
{ {
reporter->AnalyzerError(endp, zeek::reporter->AnalyzerError(
"option peer missing in TelnetEncryptOption::RecvSubOption"); endp, "option peer missing in TelnetEncryptOption::RecvSubOption");
return; return;
} }
@ -215,8 +215,8 @@ void TelnetAuthenticateOption::RecvSubOption(u_char* data, int len)
if ( ! peer ) if ( ! peer )
{ {
reporter->AnalyzerError(endp, zeek::reporter->AnalyzerError(
"option peer missing in TelnetAuthenticateOption::RecvSubOption"); endp, "option peer missing in TelnetAuthenticateOption::RecvSubOption");
return; return;
} }

View file

@ -131,8 +131,8 @@ void Contents_Rsh_Analyzer::DoDeliver(int len, const u_char* data)
break; break;
default: default:
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"bad state in Contents_Rsh_Analyzer::DoDeliver"); this, "bad state in Contents_Rsh_Analyzer::DoDeliver");
break; break;
} }
} }
@ -205,7 +205,7 @@ void Rsh_Analyzer::ClientUserName(const char* s)
{ {
if ( client_name ) if ( client_name )
{ {
reporter->AnalyzerError(this, "multiple rsh client names"); zeek::reporter->AnalyzerError(this, "multiple rsh client names");
return; return;
} }
@ -216,7 +216,7 @@ void Rsh_Analyzer::ServerUserName(const char* s)
{ {
if ( username ) if ( username )
{ {
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(this,
"multiple rsh initial client names"); "multiple rsh initial client names");
return; return;
} }

View file

@ -194,8 +194,8 @@ void Contents_Rlogin_Analyzer::DoDeliver(int len, const u_char* data)
break; break;
default: default:
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"bad state in Contents_Rlogin_Analyzer::DoDeliver"); this, "bad state in Contents_Rlogin_Analyzer::DoDeliver");
break; break;
} }
} }
@ -227,7 +227,7 @@ void Rlogin_Analyzer::ClientUserName(const char* s)
{ {
if ( client_name ) if ( client_name )
{ {
reporter->AnalyzerError(this, "multiple rlogin client names"); zeek::reporter->AnalyzerError(this, "multiple rlogin client names");
return; return;
} }

View file

@ -586,7 +586,7 @@ void MIME_Entity::init()
MIME_Entity::~MIME_Entity() MIME_Entity::~MIME_Entity()
{ {
if ( ! end_of_data ) if ( ! end_of_data )
reporter->AnalyzerError(message ? message->GetAnalyzer() : nullptr, zeek::reporter->AnalyzerError(message ? message->GetAnalyzer() : nullptr,
"missing MIME_Entity::EndOfData() before ~MIME_Entity"); "missing MIME_Entity::EndOfData() before ~MIME_Entity");
delete current_header_line; delete current_header_line;
@ -973,7 +973,7 @@ int MIME_Entity::CheckBoundaryDelimiter(int len, const char* data)
{ {
if ( ! multipart_boundary ) if ( ! multipart_boundary )
{ {
reporter->Warning("boundary delimiter was not specified for a multipart message\n"); zeek::reporter->Warning("boundary delimiter was not specified for a multipart message\n");
DEBUG_MSG("headers of the MIME entity for debug:\n"); DEBUG_MSG("headers of the MIME entity for debug:\n");
DebugPrintHeaders(); DebugPrintHeaders();
return NOT_MULTIPART_BOUNDARY; return NOT_MULTIPART_BOUNDARY;
@ -1150,7 +1150,7 @@ void MIME_Entity::StartDecodeBase64()
{ {
if ( base64_decoder ) if ( base64_decoder )
{ {
reporter->InternalWarning("previous MIME Base64 decoder not released"); zeek::reporter->InternalWarning("previous MIME Base64 decoder not released");
delete base64_decoder; delete base64_decoder;
} }
@ -1158,7 +1158,7 @@ void MIME_Entity::StartDecodeBase64()
if ( ! analyzer ) if ( ! analyzer )
{ {
reporter->InternalWarning("no analyzer associated with MIME message"); zeek::reporter->InternalWarning("no analyzer associated with MIME message");
return; return;
} }
@ -1189,7 +1189,7 @@ bool MIME_Entity::GetDataBuffer()
int ret = message->RequestBuffer(&data_buf_length, &data_buf_data); int ret = message->RequestBuffer(&data_buf_length, &data_buf_data);
if ( ! ret || data_buf_length == 0 || data_buf_data == nullptr ) if ( ! ret || data_buf_length == 0 || data_buf_data == nullptr )
{ {
// reporter->InternalError("cannot get data buffer from MIME_Message", ""); // zeek::reporter->InternalError("cannot get data buffer from MIME_Message", "");
return false; return false;
} }
@ -1459,7 +1459,7 @@ void MIME_Mail::SubmitData(int len, const char* buf)
{ {
if ( buf != (char*) data_buffer->Bytes() + buffer_start ) if ( buf != (char*) data_buffer->Bytes() + buffer_start )
{ {
reporter->AnalyzerError(GetAnalyzer(), zeek::reporter->AnalyzerError(GetAnalyzer(),
"MIME buffer misalignment"); "MIME buffer misalignment");
return; return;
} }
@ -1554,7 +1554,7 @@ void MIME_Mail::SubmitEvent(int event_type, const char* detail)
break; break;
default: default:
reporter->AnalyzerError(GetAnalyzer(), zeek::reporter->AnalyzerError(GetAnalyzer(),
"unrecognized MIME_Mail event"); "unrecognized MIME_Mail event");
return; return;
} }

View file

@ -205,7 +205,7 @@ public:
virtual ~MIME_Message() virtual ~MIME_Message()
{ {
if ( ! finished ) if ( ! finished )
reporter->AnalyzerError(analyzer, zeek::reporter->AnalyzerError(analyzer,
"missing MIME_Message::Done() call"); "missing MIME_Message::Done() call");
} }

View file

@ -181,7 +181,7 @@ void PIA_UDP::ActivateAnalyzer(zeek::analyzer::Tag tag, const zeek::detail::Rule
void PIA_UDP::DeactivateAnalyzer(zeek::analyzer::Tag tag) void PIA_UDP::DeactivateAnalyzer(zeek::analyzer::Tag tag)
{ {
reporter->InternalError("PIA_UDP::Deact not implemented yet"); zeek::reporter->InternalError("PIA_UDP::Deact not implemented yet");
} }
//// TCP PIA //// TCP PIA
@ -420,7 +420,7 @@ void PIA_TCP::ActivateAnalyzer(zeek::analyzer::Tag tag, const zeek::detail::Rule
void PIA_TCP::DeactivateAnalyzer(zeek::analyzer::Tag tag) void PIA_TCP::DeactivateAnalyzer(zeek::analyzer::Tag tag)
{ {
reporter->InternalError("PIA_TCP::Deact not implemented yet"); zeek::reporter->InternalError("PIA_TCP::Deact not implemented yet");
} }
void PIA_TCP::ReplayStreamBuffer(zeek::analyzer::Analyzer* analyzer) void PIA_TCP::ReplayStreamBuffer(zeek::analyzer::Analyzer* analyzer)

View file

@ -213,8 +213,8 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line)
break; break;
default: default:
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"unexpected POP3 authorization state"); this, "unexpected POP3 authorization state");
delete decoded; delete decoded;
return; return;
} }
@ -572,7 +572,7 @@ void POP3_Analyzer::ProcessClientCmd()
break; break;
default: default:
reporter->AnalyzerError(this, "unknown POP3 command"); zeek::reporter->AnalyzerError(this, "unknown POP3 command");
return; return;
} }
} }
@ -845,7 +845,7 @@ void POP3_Analyzer::BeginData(bool orig)
void POP3_Analyzer::EndData() void POP3_Analyzer::EndData()
{ {
if ( ! mail ) if ( ! mail )
reporter->Warning("unmatched end of data"); zeek::reporter->Warning("unmatched end of data");
else else
{ {
mail->Done(); mail->Done();

View file

@ -60,7 +60,7 @@ void RDP_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
if ( ! AddChildAnalyzer(pia) ) if ( ! AddChildAnalyzer(pia) )
{ {
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(this,
"failed to add TCP child analyzer " "failed to add TCP child analyzer "
"to RDP analyzer: already exists"); "to RDP analyzer: already exists");
return; return;

View file

@ -308,7 +308,7 @@ int RPC_Interpreter::DeliverRPC(const u_char* buf, int n, int rpclen,
else if ( n < 0 ) else if ( n < 0 )
{ {
reporter->AnalyzerError(analyzer, "RPC underflow"); zeek::reporter->AnalyzerError(analyzer, "RPC underflow");
return 0; return 0;
} }
@ -513,8 +513,8 @@ bool Contents_RPC::CheckResync(int& len, const u_char*& data, bool orig)
if ( resync_toskip != 0 ) if ( resync_toskip != 0 )
{ {
// Should never happen. // Should never happen.
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"RPC resync: skipping over data failed"); this, "RPC resync: skipping over data failed");
return false; return false;
} }
@ -665,8 +665,8 @@ void Contents_RPC::DeliverStream(int len, const u_char* data, bool orig)
if ( ! dummy_p ) if ( ! dummy_p )
{ {
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"inconsistent RPC record marker extraction"); this, "inconsistent RPC record marker extraction");
return; return;
} }

View file

@ -175,13 +175,13 @@ refine connection SOCKS_Conn += {
function socks5_unsupported_authentication_method(auth_method: uint8): bool function socks5_unsupported_authentication_method(auth_method: uint8): bool
%{ %{
reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication_method", fmt("%d", auth_method)); zeek::reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication_method", fmt("%d", auth_method));
return true; return true;
%} %}
function socks5_unsupported_authentication_version(auth_method: uint8, version: uint8): bool function socks5_unsupported_authentication_version(auth_method: uint8, version: uint8): bool
%{ %{
reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication", fmt("method %d, version %d", auth_method, version)); zeek::reporter->Weird(bro_analyzer()->Conn(), "socks5_unsupported_authentication", fmt("method %d, version %d", auth_method, version));
return true; return true;
%} %}

View file

@ -18,7 +18,7 @@
if ( cert.length() <= 0 ) if ( cert.length() <= 0 )
{ {
reporter->Weird(bro_analyzer()->Conn(), "zero_length_certificate"); zeek::reporter->Weird(bro_analyzer()->Conn(), "zero_length_certificate");
continue; continue;
} }
@ -35,5 +35,3 @@
} }
return true; return true;
%} %}

View file

@ -323,7 +323,7 @@ refine connection Handshake_Conn += {
} }
else if ( response.length() == 0 ) else if ( response.length() == 0 )
{ {
reporter->Weird(bro_analyzer()->Conn(), "SSL_zero_length_stapled_OCSP_message"); zeek::reporter->Weird(bro_analyzer()->Conn(), "SSL_zero_length_stapled_OCSP_message");
} }
return true; return true;

View file

@ -111,8 +111,8 @@ void ContentLine_Analyzer::SetPlainDelivery(int64_t length)
{ {
if ( length < 0 ) if ( length < 0 )
{ {
reporter->AnalyzerError(this, zeek::reporter->AnalyzerError(
"negative length for plain delivery"); this, "negative length for plain delivery");
return; return;
} }

View file

@ -1624,7 +1624,7 @@ BroFilePtr TCP_Analyzer::GetContentsFile(unsigned int direction) const
break; break;
} }
reporter->Error("bad direction %u in TCP_Analyzer::GetContentsFile", zeek::reporter->Error("bad direction %u in TCP_Analyzer::GetContentsFile",
direction); direction);
return nullptr; return nullptr;
} }

View file

@ -234,7 +234,7 @@ bool TCP_Endpoint::DataSent(double t, uint64_t seq, int len, int caplen,
{ {
char buf[256]; char buf[256];
bro_strerror_r(errno, buf, sizeof(buf)); bro_strerror_r(errno, buf, sizeof(buf));
reporter->Error("TCP contents write failed: %s", buf); zeek::reporter->Error("TCP contents write failed: %s", buf);
if ( contents_file_write_failure ) if ( contents_file_write_failure )
tcp_analyzer->EnqueueConnEvent(contents_file_write_failure, tcp_analyzer->EnqueueConnEvent(contents_file_write_failure,

View file

@ -96,7 +96,7 @@ void TCP_Reassembler::SetContentsFile(BroFilePtr f)
{ {
if ( ! f->IsOpen() ) if ( ! f->IsOpen() )
{ {
reporter->Error("no such file \"%s\"", f->Name()); zeek::reporter->Error("no such file \"%s\"", f->Name());
return; return;
} }
@ -203,7 +203,7 @@ void TCP_Reassembler::Undelivered(uint64_t up_to_seq)
if ( up_to_seq <= last_reassem_seq ) if ( up_to_seq <= last_reassem_seq )
// This should never happen. (Reassembler::TrimToSeq has the only call // This should never happen. (Reassembler::TrimToSeq has the only call
// to this method and only if this condition is not true). // to this method and only if this condition is not true).
reporter->InternalError("Calling Undelivered for data that has already been delivered (or has already been marked as undelivered"); zeek::reporter->InternalError("Calling Undelivered for data that has already been delivered (or has already been marked as undelivered");
if ( zeek::BifConst::detect_filtered_trace && last_reassem_seq == 1 && if ( zeek::BifConst::detect_filtered_trace && last_reassem_seq == 1 &&
(endpoint->FIN_cnt > 0 || endpoint->RST_cnt > 0 || (endpoint->FIN_cnt > 0 || endpoint->RST_cnt > 0 ||
@ -353,7 +353,7 @@ void TCP_Reassembler::RecordBlock(const DataBlock& b, const BroFilePtr& f)
if ( f->Write((const char*) b.block, b.Size()) ) if ( f->Write((const char*) b.block, b.Size()) )
return; return;
reporter->Error("TCP_Reassembler contents write failed"); zeek::reporter->Error("TCP_Reassembler contents write failed");
if ( contents_file_write_failure ) if ( contents_file_write_failure )
tcp_analyzer->EnqueueConnEvent(contents_file_write_failure, tcp_analyzer->EnqueueConnEvent(contents_file_write_failure,
@ -368,7 +368,7 @@ void TCP_Reassembler::RecordGap(uint64_t start_seq, uint64_t upper_seq, const Br
if ( f->Write(fmt("\n<<gap %" PRIu64">>\n", upper_seq - start_seq)) ) if ( f->Write(fmt("\n<<gap %" PRIu64">>\n", upper_seq - start_seq)) )
return; return;
reporter->Error("TCP_Reassembler contents gap write failed"); zeek::reporter->Error("TCP_Reassembler contents gap write failed");
if ( contents_file_write_failure ) if ( contents_file_write_failure )
tcp_analyzer->EnqueueConnEvent(contents_file_write_failure, tcp_analyzer->EnqueueConnEvent(contents_file_write_failure,

View file

@ -33,7 +33,7 @@ public:
void Weird(const char* name, bool force = false) const void Weird(const char* name, bool force = false) const
{ {
if ( ProtocolConfirmed() || force ) if ( ProtocolConfirmed() || force )
reporter->Weird(Conn(), name); zeek::reporter->Weird(Conn(), name);
} }
/** /**

View file

@ -184,7 +184,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
request_len += ulen; request_len += ulen;
#ifdef DEBUG #ifdef DEBUG
if ( request_len < 0 ) if ( request_len < 0 )
reporter->Warning("wrapping around for UDP request length"); zeek::reporter->Warning("wrapping around for UDP request length");
#endif #endif
} }
@ -202,7 +202,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
reply_len += ulen; reply_len += ulen;
#ifdef DEBUG #ifdef DEBUG
if ( reply_len < 0 ) if ( reply_len < 0 )
reporter->Warning("wrapping around for UDP reply length"); zeek::reporter->Warning("wrapping around for UDP reply length");
#endif #endif
} }

View file

@ -50,7 +50,7 @@ void VXLAN_Analyzer::DeliverPacket(int len, const u_char* data, bool orig,
if ( estack && estack->Depth() >= zeek::BifConst::Tunnel::max_depth ) if ( estack && estack->Depth() >= zeek::BifConst::Tunnel::max_depth )
{ {
reporter->Weird(Conn(), "tunnel_depth"); zeek::reporter->Weird(Conn(), "tunnel_depth");
return; return;
} }

View file

@ -36,7 +36,7 @@ refine connection XMPP_Conn += {
zeek::BifEvent::enqueue_xmpp_starttls(bro_analyzer(), bro_analyzer()->Conn()); zeek::BifEvent::enqueue_xmpp_starttls(bro_analyzer(), bro_analyzer()->Conn());
} }
else if ( !is_orig && token == "proceed" ) else if ( !is_orig && token == "proceed" )
reporter->Weird(bro_analyzer()->Conn(), "XMPP: proceed without starttls"); zeek::reporter->Weird(bro_analyzer()->Conn(), "XMPP: proceed without starttls");
// printf("Processed: %d %s %s %s \n", is_orig, c_str(name), c_str(rest), token_no_ns.c_str()); // printf("Processed: %d %s %s %s \n", is_orig, c_str(name), c_str(rest), token_no_ns.c_str());
@ -48,4 +48,3 @@ refine connection XMPP_Conn += {
refine typeattr XMPP_TOKEN += &let { refine typeattr XMPP_TOKEN += &let {
proc: bool = $context.connection.proc_xmpp_token(is_orig, name, rest); proc: bool = $context.connection.proc_xmpp_token(is_orig, name, rest);
}; };

View file

@ -15,7 +15,7 @@ zeek::StringValPtr utf16_to_utf8_val(Connection* conn, const bytestring& utf16)
if ( utf8size > resultstring.max_size() ) if ( utf8size > resultstring.max_size() )
{ {
reporter->Weird(conn, "utf16_conversion_failed", "utf16 too long in utf16_to_utf8_val"); zeek::reporter->Weird(conn, "utf16_conversion_failed", "utf16 too long in utf16_to_utf8_val");
// If the conversion didn't go well, return the original data. // If the conversion didn't go well, return the original data.
return to_stringval(utf16); return to_stringval(utf16);
} }
@ -43,7 +43,7 @@ zeek::StringValPtr utf16_to_utf8_val(Connection* conn, const bytestring& utf16)
lenientConversion); lenientConversion);
if ( res != conversionOK ) if ( res != conversionOK )
{ {
reporter->Weird(conn, "utf16_conversion_failed", "utf16 conversion failed in utf16_to_utf8_val"); zeek::reporter->Weird(conn, "utf16_conversion_failed", "utf16 conversion failed in utf16_to_utf8_val");
// If the conversion didn't go well, return the original data. // If the conversion didn't go well, return the original data.
return to_stringval(utf16); return to_stringval(utf16);
} }

View file

@ -426,7 +426,7 @@ struct val_converter {
if ( ! re->Compile() ) if ( ! re->Compile() )
{ {
reporter->Error("failed compiling unserialized pattern: %s, %s", zeek::reporter->Error("failed compiling unserialized pattern: %s, %s",
exact_text->c_str(), anywhere_text->c_str()); exact_text->c_str(), anywhere_text->c_str());
delete re; delete re;
return nullptr; return nullptr;
@ -752,7 +752,7 @@ struct type_checker {
if ( ! compiled ) if ( ! compiled )
{ {
reporter->Error("failed compiling pattern: %s, %s", zeek::reporter->Error("failed compiling pattern: %s, %s",
exact_text->c_str(), anywhere_text->c_str()); exact_text->c_str(), anywhere_text->c_str());
return false; return false;
} }
@ -871,7 +871,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const zeek::Val* v)
} }
else else
{ {
reporter->InternalWarning("Closure with non-ScriptFunc"); zeek::reporter->InternalWarning("Closure with non-ScriptFunc");
return broker::ec::invalid_data; return broker::ec::invalid_data;
} }
} }
@ -995,14 +995,14 @@ broker::expected<broker::data> bro_broker::val_to_data(const zeek::Val* v)
auto c = v->AsOpaqueVal()->Serialize(); auto c = v->AsOpaqueVal()->Serialize();
if ( ! c ) if ( ! c )
{ {
reporter->Error("unsupported opaque type for serialization"); zeek::reporter->Error("unsupported opaque type for serialization");
break; break;
} }
return {c}; return {c};
} }
default: default:
reporter->Error("unsupported Broker::Data type: %s", zeek::reporter->Error("unsupported Broker::Data type: %s",
zeek::type_name(v->GetType()->Tag())); zeek::type_name(v->GetType()->Tag()));
break; break;
} }
@ -1018,7 +1018,7 @@ zeek::RecordValPtr bro_broker::make_data_val(zeek::Val* v)
if ( data ) if ( data )
rval->Assign(0, zeek::make_intrusive<DataVal>(move(*data))); rval->Assign(0, zeek::make_intrusive<DataVal>(move(*data)));
else else
reporter->Warning("did not get a value from val_to_data"); zeek::reporter->Warning("did not get a value from val_to_data");
return rval; return rval;
} }
@ -1122,7 +1122,7 @@ broker::data& bro_broker::opaque_field_to_data(zeek::RecordVal* v, zeek::detail:
const auto& d = v->GetField(0); const auto& d = v->GetField(0);
if ( ! d ) if ( ! d )
reporter->RuntimeError(f->GetCall()->GetLocationInfo(), zeek::reporter->RuntimeError(f->GetCall()->GetLocationInfo(),
"Broker::Data's opaque field is not set"); "Broker::Data's opaque field is not set");
// RuntimeError throws an exception which causes this line to never exceute. // RuntimeError throws an exception which causes this line to never exceute.

View file

@ -205,7 +205,7 @@ T& require_data_type(broker::data& d, zeek::TypeTag tag, zeek::detail::Frame* f)
{ {
auto ptr = caf::get_if<T>(&d); auto ptr = caf::get_if<T>(&d);
if ( ! ptr ) if ( ! ptr )
reporter->RuntimeError(f->GetCall()->GetLocationInfo(), zeek::reporter->RuntimeError(f->GetCall()->GetLocationInfo(),
"data is of type '%s' not of type '%s'", "data is of type '%s' not of type '%s'",
caf::visit(type_name_getter{tag}, d), caf::visit(type_name_getter{tag}, d),
zeek::type_name(tag)); zeek::type_name(tag));

View file

@ -33,7 +33,7 @@ static inline zeek::Val* get_option(const char* option)
const auto& id = zeek::detail::global_scope()->Find(option); const auto& id = zeek::detail::global_scope()->Find(option);
if ( ! (id && id->GetVal()) ) if ( ! (id && id->GetVal()) )
reporter->FatalError("Unknown Broker option %s", option); zeek::reporter->FatalError("Unknown Broker option %s", option);
return id->GetVal().get(); return id->GetVal().get();
} }
@ -72,12 +72,12 @@ int Manager::script_scope = 0;
struct scoped_reporter_location { struct scoped_reporter_location {
scoped_reporter_location(zeek::detail::Frame* frame) scoped_reporter_location(zeek::detail::Frame* frame)
{ {
reporter->PushLocation(frame->GetCall()->GetLocationInfo()); zeek::reporter->PushLocation(frame->GetCall()->GetLocationInfo());
} }
~scoped_reporter_location() ~scoped_reporter_location()
{ {
reporter->PopLocation(); zeek::reporter->PopLocation();
} }
}; };
@ -179,7 +179,7 @@ void Manager::InitPostScript()
else if ( streq(scheduler_policy, "stealing") ) else if ( streq(scheduler_policy, "stealing") )
config.set("scheduler.policy", caf::atom("stealing")); config.set("scheduler.policy", caf::atom("stealing"));
else else
reporter->FatalError("Invalid Broker::scheduler_policy: %s", scheduler_policy); zeek::reporter->FatalError("Invalid Broker::scheduler_policy: %s", scheduler_policy);
auto max_threads_env = zeekenv("ZEEK_BROKER_MAX_THREADS"); auto max_threads_env = zeekenv("ZEEK_BROKER_MAX_THREADS");
@ -211,9 +211,9 @@ void Manager::InitPostScript()
bstate = std::make_shared<BrokerState>(std::move(config), cqs); bstate = std::make_shared<BrokerState>(std::move(config), cqs);
if ( ! iosource_mgr->RegisterFd(bstate->subscriber.fd(), this) ) if ( ! iosource_mgr->RegisterFd(bstate->subscriber.fd(), this) )
reporter->FatalError("Failed to register broker subscriber with iosource_mgr"); zeek::reporter->FatalError("Failed to register broker subscriber with iosource_mgr");
if ( ! iosource_mgr->RegisterFd(bstate->status_subscriber.fd(), this) ) if ( ! iosource_mgr->RegisterFd(bstate->status_subscriber.fd(), this) )
reporter->FatalError("Failed to register broker status subscriber with iosource_mgr"); zeek::reporter->FatalError("Failed to register broker status subscriber with iosource_mgr");
bstate->subscriber.add_topic(broker::topics::store_events, true); bstate->subscriber.add_topic(broker::topics::store_events, true);
@ -507,7 +507,7 @@ bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer,
if ( ! stream_id ) if ( ! stream_id )
{ {
reporter->Error("Failed to remotely log: stream %d doesn't have name", zeek::reporter->Error("Failed to remotely log: stream %d doesn't have name",
stream->AsEnum()); stream->AsEnum());
return false; return false;
} }
@ -516,7 +516,7 @@ bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer,
if ( ! writer_id ) if ( ! writer_id )
{ {
reporter->Error("Failed to remotely log: writer %d doesn't have name", zeek::reporter->Error("Failed to remotely log: writer %d doesn't have name",
writer->AsEnum()); writer->AsEnum());
return false; return false;
} }
@ -563,7 +563,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri
if ( ! stream_id ) if ( ! stream_id )
{ {
reporter->Error("Failed to remotely log: stream %d doesn't have name", zeek::reporter->Error("Failed to remotely log: stream %d doesn't have name",
stream->AsEnum()); stream->AsEnum());
return false; return false;
} }
@ -572,7 +572,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri
if ( ! writer_id ) if ( ! writer_id )
{ {
reporter->Error("Failed to remotely log: writer %d doesn't have name", zeek::reporter->Error("Failed to remotely log: writer %d doesn't have name",
writer->AsEnum()); writer->AsEnum());
return false; return false;
} }
@ -587,7 +587,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri
if ( ! success ) if ( ! success )
{ {
reporter->Error("Failed to remotely log stream %s: num_fields serialization failed", stream_id); zeek::reporter->Error("Failed to remotely log stream %s: num_fields serialization failed", stream_id);
return false; return false;
} }
@ -595,7 +595,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri
{ {
if ( ! vals[i]->Write(&fmt) ) if ( ! vals[i]->Write(&fmt) )
{ {
reporter->Error("Failed to remotely log stream %s: field %d serialization failed", stream_id, i); zeek::reporter->Error("Failed to remotely log stream %s: field %d serialization failed", stream_id, i);
return false; return false;
} }
} }
@ -609,7 +609,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri
if ( ! v ) if ( ! v )
{ {
reporter->Error("Failed to remotely log: log_topic func did not return" zeek::reporter->Error("Failed to remotely log: log_topic func did not return"
" a value for stream %s at path %s", stream_id, " a value for stream %s at path %s", stream_id,
path.data()); path.data());
return false; return false;
@ -685,7 +685,7 @@ void Manager::Error(const char* format, ...)
if ( script_scope ) if ( script_scope )
zeek::emit_builtin_error(msg); zeek::emit_builtin_error(msg);
else else
reporter->Error("%s", msg); zeek::reporter->Error("%s", msg);
} }
bool Manager::AutoPublishEvent(string topic, zeek::Val* event) bool Manager::AutoPublishEvent(string topic, zeek::Val* event)
@ -872,7 +872,7 @@ void Manager::DispatchMessage(const broker::topic& topic, broker::data msg)
{ {
switch ( broker::zeek::Message::type(msg) ) { switch ( broker::zeek::Message::type(msg) ) {
case broker::zeek::Message::Type::Invalid: case broker::zeek::Message::Type::Invalid:
reporter->Warning("received invalid broker message: %s", zeek::reporter->Warning("received invalid broker message: %s",
broker::to_string(msg).data()); broker::to_string(msg).data());
break; break;
@ -898,7 +898,7 @@ void Manager::DispatchMessage(const broker::topic& topic, broker::data msg)
if ( ! batch.valid() ) if ( ! batch.valid() )
{ {
reporter->Warning("received invalid broker Batch: %s", zeek::reporter->Warning("received invalid broker Batch: %s",
broker::to_string(batch).data()); broker::to_string(batch).data());
return; return;
} }
@ -912,7 +912,7 @@ void Manager::DispatchMessage(const broker::topic& topic, broker::data msg)
default: default:
// We ignore unknown types so that we could add more in the // We ignore unknown types so that we could add more in the
// future if we had too. // future if we had too.
reporter->Warning("received unknown broker message: %s", zeek::reporter->Warning("received unknown broker message: %s",
broker::to_string(msg).data()); broker::to_string(msg).data());
break; break;
} }
@ -945,7 +945,7 @@ void Manager::Process()
continue; continue;
} }
reporter->InternalWarning("ignoring status_subscriber message with unexpected type"); zeek::reporter->InternalWarning("ignoring status_subscriber message with unexpected type");
} }
auto messages = bstate->subscriber.poll(); auto messages = bstate->subscriber.poll();
@ -974,7 +974,7 @@ void Manager::Process()
} }
catch ( std::runtime_error& e ) catch ( std::runtime_error& e )
{ {
reporter->Warning("ignoring invalid Broker message: %s", + e.what()); zeek::reporter->Warning("ignoring invalid Broker message: %s", + e.what());
continue; continue;
} }
} }
@ -1025,7 +1025,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table,
if ( table->GetType()->IsSet() && data.get_type() != broker::data::type::none ) if ( table->GetType()->IsSet() && data.get_type() != broker::data::type::none )
{ {
reporter->Error("ProcessStoreEvent %s got %s when expecting set", type, data.get_type_name()); zeek::reporter->Error("ProcessStoreEvent %s got %s when expecting set", type, data.get_type_name());
return; return;
} }
@ -1034,7 +1034,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table,
auto zeek_key = data_to_val(key, its[0].get()); auto zeek_key = data_to_val(key, its[0].get());
if ( ! zeek_key ) if ( ! zeek_key )
{ {
reporter->Error("ProcessStoreEvent %s: could not convert key \"%s\" for store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(key).c_str(), store_id.c_str()); zeek::reporter->Error("ProcessStoreEvent %s: could not convert key \"%s\" for store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(key).c_str(), store_id.c_str());
return; return;
} }
@ -1048,7 +1048,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table,
auto zeek_value = data_to_val(data, table->GetType()->Yield().get()); auto zeek_value = data_to_val(data, table->GetType()->Yield().get());
if ( ! zeek_value ) if ( ! zeek_value )
{ {
reporter->Error("ProcessStoreEvent %s: could not convert value \"%s\" for key \"%s\" in store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(data).c_str(), to_string(key).c_str(), store_id.c_str()); zeek::reporter->Error("ProcessStoreEvent %s: could not convert value \"%s\" for key \"%s\" in store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(data).c_str(), to_string(key).c_str(), store_id.c_str());
return; return;
} }
@ -1110,7 +1110,7 @@ void Manager::ProcessStoreEvent(broker::data msg)
auto zeek_key = data_to_val(key, its[0].get()); auto zeek_key = data_to_val(key, its[0].get());
if ( ! zeek_key ) if ( ! zeek_key )
{ {
reporter->Error("ProcessStoreEvent: could not convert key \"%s\" for store \"%s\" while receiving remote erase. This probably means the tables have different types on different nodes.", to_string(key).c_str(), insert.store_id().c_str()); zeek::reporter->Error("ProcessStoreEvent: could not convert key \"%s\" for store \"%s\" while receiving remote erase. This probably means the tables have different types on different nodes.", to_string(key).c_str(), insert.store_id().c_str());
return; return;
} }
@ -1134,7 +1134,7 @@ void Manager::ProcessStoreEvent(broker::data msg)
} }
else else
{ {
reporter->Error("ProcessStoreEvent: Unhandled event type"); zeek::reporter->Error("ProcessStoreEvent: Unhandled event type");
} }
} }
@ -1142,7 +1142,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
{ {
if ( ! ev.valid() ) if ( ! ev.valid() )
{ {
reporter->Warning("received invalid broker Event: %s", zeek::reporter->Warning("received invalid broker Event: %s",
broker::to_string(ev.as_data()).data()); broker::to_string(ev.as_data()).data());
return; return;
} }
@ -1177,7 +1177,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
if ( arg_types.size() != args.size() ) if ( arg_types.size() != args.size() )
{ {
reporter->Warning("got event message '%s' with invalid # of args," zeek::reporter->Warning("got event message '%s' with invalid # of args,"
" got %zd, expected %zu", name.data(), args.size(), " got %zd, expected %zu", name.data(), args.size(),
arg_types.size()); arg_types.size());
return; return;
@ -1198,7 +1198,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
{ {
auto expected_name = zeek::type_name(expected_type->Tag()); auto expected_name = zeek::type_name(expected_type->Tag());
reporter->Warning("failed to convert remote event '%s' arg #%lu," zeek::reporter->Warning("failed to convert remote event '%s' arg #%lu,"
" got %s, expected %s", " got %s, expected %s",
name.data(), i, got_type, name.data(), i, got_type,
expected_name); expected_name);
@ -1207,7 +1207,8 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
// possibly because of a mismatch between // possibly because of a mismatch between
// anonymous-function bodies. // anonymous-function bodies.
if ( strcmp(expected_name, "func") == 0 && strcmp("vector", got_type) == 0 ) if ( strcmp(expected_name, "func") == 0 && strcmp("vector", got_type) == 0 )
reporter->Warning("when sending functions the receiver must have access to a" zeek::reporter->Warning(
"when sending functions the receiver must have access to a"
" version of that function.\nFor anonymous functions, that function must have the same body."); " version of that function.\nFor anonymous functions, that function must have the same body.");
break; break;
@ -1223,7 +1224,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
DBG_LOG(DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str()); DBG_LOG(DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str());
if ( ! lc.valid() ) if ( ! lc.valid() )
{ {
reporter->Warning("received invalid broker LogCreate: %s", zeek::reporter->Warning("received invalid broker LogCreate: %s",
broker::to_string(lc).data()); broker::to_string(lc).data());
return false; return false;
} }
@ -1231,21 +1232,21 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
auto stream_id = data_to_val(std::move(lc.stream_id()), log_id_type); auto stream_id = data_to_val(std::move(lc.stream_id()), log_id_type);
if ( ! stream_id ) if ( ! stream_id )
{ {
reporter->Warning("failed to unpack remote log stream id"); zeek::reporter->Warning("failed to unpack remote log stream id");
return false; return false;
} }
auto writer_id = data_to_val(std::move(lc.writer_id()), writer_id_type); auto writer_id = data_to_val(std::move(lc.writer_id()), writer_id_type);
if ( ! writer_id ) if ( ! writer_id )
{ {
reporter->Warning("failed to unpack remote log writer id"); zeek::reporter->Warning("failed to unpack remote log writer id");
return false; return false;
} }
auto writer_info = std::unique_ptr<logging::WriterBackend::WriterInfo>(new logging::WriterBackend::WriterInfo); auto writer_info = std::unique_ptr<logging::WriterBackend::WriterInfo>(new logging::WriterBackend::WriterInfo);
if ( ! writer_info->FromBroker(std::move(lc.writer_info())) ) if ( ! writer_info->FromBroker(std::move(lc.writer_info())) )
{ {
reporter->Warning("failed to unpack remote log writer info"); zeek::reporter->Warning("failed to unpack remote log writer info");
return false; return false;
} }
@ -1254,7 +1255,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
if ( ! fields_data ) if ( ! fields_data )
{ {
reporter->Warning("failed to unpack remote log fields"); zeek::reporter->Warning("failed to unpack remote log fields");
return false; return false;
} }
@ -1267,7 +1268,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
fields[i] = field; fields[i] = field;
else else
{ {
reporter->Warning("failed to convert remote log field # %lu", i); zeek::reporter->Warning("failed to convert remote log field # %lu", i);
delete [] fields; delete [] fields;
return false; return false;
} }
@ -1277,7 +1278,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
{ {
ODesc d; ODesc d;
stream_id->Describe(&d); stream_id->Describe(&d);
reporter->Warning("failed to create remote log stream for %s locally", d.Description()); zeek::reporter->Warning("failed to create remote log stream for %s locally", d.Description());
} }
return true; return true;
@ -1289,7 +1290,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
if ( ! lw.valid() ) if ( ! lw.valid() )
{ {
reporter->Warning("received invalid broker LogWrite: %s", zeek::reporter->Warning("received invalid broker LogWrite: %s",
broker::to_string(lw).data()); broker::to_string(lw).data());
return false; return false;
} }
@ -1302,7 +1303,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
if ( ! stream_id ) if ( ! stream_id )
{ {
reporter->Warning("failed to unpack remote log stream id: %s", zeek::reporter->Warning("failed to unpack remote log stream id: %s",
stream_id_name.data()); stream_id_name.data());
return false; return false;
} }
@ -1311,7 +1312,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
auto writer_id = data_to_val(std::move(lw.writer_id()), writer_id_type); auto writer_id = data_to_val(std::move(lw.writer_id()), writer_id_type);
if ( ! writer_id ) if ( ! writer_id )
{ {
reporter->Warning("failed to unpack remote log writer id for stream: %s", stream_id_name.data()); zeek::reporter->Warning("failed to unpack remote log writer id for stream: %s", stream_id_name.data());
return false; return false;
} }
@ -1319,7 +1320,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
if ( ! path ) if ( ! path )
{ {
reporter->Warning("failed to unpack remote log values (bad path variant) for stream: %s", stream_id_name.data()); zeek::reporter->Warning("failed to unpack remote log values (bad path variant) for stream: %s", stream_id_name.data());
return false; return false;
} }
@ -1327,7 +1328,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
if ( ! serial_data ) if ( ! serial_data )
{ {
reporter->Warning("failed to unpack remote log values (bad serial_data variant) for stream: %s", stream_id_name.data()); zeek::reporter->Warning("failed to unpack remote log values (bad serial_data variant) for stream: %s", stream_id_name.data());
return false; return false;
} }
@ -1339,7 +1340,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
if ( ! success ) if ( ! success )
{ {
reporter->Warning("failed to unserialize remote log num fields for stream: %s", stream_id_name.data()); zeek::reporter->Warning("failed to unserialize remote log num fields for stream: %s", stream_id_name.data());
return false; return false;
} }
@ -1355,7 +1356,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
delete vals[j]; delete vals[j];
delete [] vals; delete [] vals;
reporter->Warning("failed to unserialize remote log field %d for stream: %s", i, stream_id_name.data()); zeek::reporter->Warning("failed to unserialize remote log field %d for stream: %s", i, stream_id_name.data());
return false; return false;
} }
@ -1373,7 +1374,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
if ( ! iu.valid() ) if ( ! iu.valid() )
{ {
reporter->Warning("received invalid broker IdentifierUpdate: %s", zeek::reporter->Warning("received invalid broker IdentifierUpdate: %s",
broker::to_string(iu).data()); broker::to_string(iu).data());
return false; return false;
} }
@ -1385,7 +1386,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
if ( ! id ) if ( ! id )
{ {
reporter->Warning("Received id-update request for unkown id: %s", zeek::reporter->Warning("Received id-update request for unkown id: %s",
id_name.c_str()); id_name.c_str());
return false; return false;
} }
@ -1394,7 +1395,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
if ( ! val ) if ( ! val )
{ {
reporter->Error("Failed to receive ID with unsupported type: %s (%s)", zeek::reporter->Error("Failed to receive ID with unsupported type: %s (%s)",
id_name.c_str(), zeek::type_name(id->GetType()->Tag())); id_name.c_str(), zeek::type_name(id->GetType()->Tag()));
return false; return false;
} }
@ -1433,7 +1434,7 @@ void Manager::ProcessStatus(broker::status stat)
break; break;
default: default:
reporter->Warning("Unhandled Broker status: %s", to_string(stat).data()); zeek::reporter->Warning("Unhandled Broker status: %s", to_string(stat).data());
break; break;
} }
@ -1489,7 +1490,7 @@ void Manager::ProcessError(broker::error err)
ec = static_cast<BifEnum::Broker::ErrorCode>(err.code()); ec = static_cast<BifEnum::Broker::ErrorCode>(err.code());
else else
{ {
reporter->Warning("Unknown Broker error code %u: mapped to unspecificed enum value ", err.code()); zeek::reporter->Warning("Unknown Broker error code %u: mapped to unspecificed enum value ", err.code());
ec = BifEnum::Broker::ErrorCode::UNSPECIFIED; ec = BifEnum::Broker::ErrorCode::UNSPECIFIED;
} }
@ -1515,7 +1516,7 @@ void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response re
if ( request == pending_queries.end() ) if ( request == pending_queries.end() )
{ {
reporter->Warning("unmatched response to query %" PRIu64 " on store %s", zeek::reporter->Warning("unmatched response to query %" PRIu64 " on store %s",
response.id, s->store.name().c_str()); response.id, s->store.name().c_str());
return; return;
} }
@ -1545,7 +1546,7 @@ void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response re
else if ( response.answer.error() == broker::ec::no_such_key ) else if ( response.answer.error() == broker::ec::no_such_key )
request->second->Result(query_result()); request->second->Result(query_result());
else else
reporter->InternalWarning("unknown store response status: %s", zeek::reporter->InternalWarning("unknown store response status: %s",
to_string(response.answer.error()).c_str()); to_string(response.answer.error()).c_str());
delete request->second; delete request->second;
@ -1634,7 +1635,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV
auto zeek_key = data_to_val(key, its[0].get()); auto zeek_key = data_to_val(key, its[0].get());
if ( ! zeek_key ) if ( ! zeek_key )
{ {
reporter->Error("Failed to convert key \"%s\" while importing broker store to table for store \"%s\". Aborting import.", to_string(key).c_str(), name.c_str()); zeek::reporter->Error("Failed to convert key \"%s\" while importing broker store to table for store \"%s\". Aborting import.", to_string(key).c_str(), name.c_str());
// just abort - this probably means the types are incompatible // just abort - this probably means the types are incompatible
table->EnableChangeNotifications(); table->EnableChangeNotifications();
return; return;
@ -1649,7 +1650,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV
auto value = handle->store.get(key); auto value = handle->store.get(key);
if ( ! value ) if ( ! value )
{ {
reporter->Error("Failed to load value for key %s while importing Broker store %s to table", to_string(key).c_str(), name.c_str()); zeek::reporter->Error("Failed to load value for key %s while importing Broker store %s to table", to_string(key).c_str(), name.c_str());
table->EnableChangeNotifications(); table->EnableChangeNotifications();
continue; continue;
} }
@ -1657,7 +1658,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV
auto zeek_value = data_to_val(*value, table->GetType()->Yield().get()); auto zeek_value = data_to_val(*value, table->GetType()->Yield().get());
if ( ! zeek_value ) if ( ! zeek_value )
{ {
reporter->Error("Could not convert %s to table value while trying to import Broker store %s. Aborting import.", to_string(value).c_str(), name.c_str()); zeek::reporter->Error("Could not convert %s to table value while trying to import Broker store %s. Aborting import.", to_string(value).c_str(), name.c_str());
table->EnableChangeNotifications(); table->EnableChangeNotifications();
return; return;
} }
@ -1760,7 +1761,7 @@ bool Manager::AddForwardedStore(const std::string& name, zeek::TableValPtr table
{ {
if ( forwarded_stores.find(name) != forwarded_stores.end() ) if ( forwarded_stores.find(name) != forwarded_stores.end() )
{ {
reporter->Error("same &broker_store %s specified for two different variables", name.c_str()); zeek::reporter->Error("same &broker_store %s specified for two different variables", name.c_str());
return false; return false;
} }

View file

@ -38,11 +38,11 @@ EVP_MD_CTX* hash_init(HashAlgorithm alg)
md = EVP_sha512(); md = EVP_sha512();
break; break;
default: default:
reporter->InternalError("Unknown hash algorithm passed to hash_init"); zeek::reporter->InternalError("Unknown hash algorithm passed to hash_init");
} }
if ( ! EVP_DigestInit_ex(c, md, NULL) ) if ( ! EVP_DigestInit_ex(c, md, NULL) )
reporter->InternalError("EVP_DigestInit failed"); zeek::reporter->InternalError("EVP_DigestInit failed");
return c; return c;
} }
@ -50,13 +50,13 @@ EVP_MD_CTX* hash_init(HashAlgorithm alg)
void hash_update(EVP_MD_CTX* c, const void* data, unsigned long len) void hash_update(EVP_MD_CTX* c, const void* data, unsigned long len)
{ {
if ( ! EVP_DigestUpdate(c, data, len) ) if ( ! EVP_DigestUpdate(c, data, len) )
reporter->InternalError("EVP_DigestUpdate failed"); zeek::reporter->InternalError("EVP_DigestUpdate failed");
} }
void hash_final(EVP_MD_CTX* c, u_char* md) void hash_final(EVP_MD_CTX* c, u_char* md)
{ {
if ( ! EVP_DigestFinal(c, md, NULL) ) if ( ! EVP_DigestFinal(c, md, NULL) )
reporter->InternalError("EVP_DigestFinal failed"); zeek::reporter->InternalError("EVP_DigestFinal failed");
EVP_MD_CTX_free(c); EVP_MD_CTX_free(c);
} }

View file

@ -162,7 +162,7 @@ std::unique_ptr<HashKey> AnalyzerSet::GetKey(const file_analysis::Tag& t,
auto key = analyzer_hash->MakeHashKey(*lv, true); auto key = analyzer_hash->MakeHashKey(*lv, true);
if ( ! key ) if ( ! key )
reporter->InternalError("AnalyzerArgs type mismatch"); zeek::reporter->InternalError("AnalyzerArgs type mismatch");
return key; return key;
} }
@ -174,7 +174,7 @@ file_analysis::Analyzer* AnalyzerSet::InstantiateAnalyzer(const Tag& tag,
if ( ! a ) if ( ! a )
{ {
reporter->Error("[%s] Failed file analyzer %s instantiation", zeek::reporter->Error("[%s] Failed file analyzer %s instantiation",
file->GetID().c_str(), file->GetID().c_str(),
file_mgr->GetComponentName(tag).c_str()); file_mgr->GetComponentName(tag).c_str());
return nullptr; return nullptr;

View file

@ -175,7 +175,7 @@ int File::Idx(const std::string& field, const zeek::RecordType* type)
int rval = type->FieldOffset(field.c_str()); int rval = type->FieldOffset(field.c_str());
if ( rval < 0 ) if ( rval < 0 )
reporter->InternalError("Unknown %s field: %s", type->GetName().c_str(), zeek::reporter->InternalError("Unknown %s field: %s", type->GetName().c_str(),
field.c_str()); field.c_str());
return rval; return rval;

View file

@ -465,7 +465,7 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag,
if ( ! c ) if ( ! c )
{ {
reporter->InternalWarning( zeek::reporter->InternalWarning(
"unknown file analyzer instantiation request: %s", "unknown file analyzer instantiation request: %s",
tag.AsString().c_str()); tag.AsString().c_str());
return nullptr; return nullptr;
@ -482,13 +482,13 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag,
a = c->factory(args.get(), f); a = c->factory(args.get(), f);
else else
{ {
reporter->InternalWarning("file analyzer %s cannot be instantiated " zeek::reporter->InternalWarning("file analyzer %s cannot be instantiated "
"dynamically", c->CanonicalName().c_str()); "dynamically", c->CanonicalName().c_str());
return nullptr; return nullptr;
} }
if ( ! a ) if ( ! a )
reporter->InternalError("file analyzer instantiation failed"); zeek::reporter->InternalError("file analyzer instantiation failed");
a->SetAnalyzerTag(tag); a->SetAnalyzerTag(tag);
@ -500,7 +500,7 @@ zeek::detail::RuleMatcher::MIME_Matches* Manager::DetectMIME(
zeek::detail::RuleMatcher::MIME_Matches* rval) const zeek::detail::RuleMatcher::MIME_Matches* rval) const
{ {
if ( ! magic_state ) if ( ! magic_state )
reporter->InternalError("file magic signature state not initialized"); zeek::reporter->InternalError("file magic signature state not initialized");
rval = zeek::detail::rule_matcher->Match(magic_state, data, len, rval); rval = zeek::detail::rule_matcher->Match(magic_state, data, len, rval);
zeek::detail::rule_matcher->ClearFileMagicState(magic_state); zeek::detail::rule_matcher->ClearFileMagicState(magic_state);

View file

@ -23,7 +23,7 @@ Extract::Extract(zeek::RecordValPtr args, File* file,
fd = 0; fd = 0;
char buf[128]; char buf[128];
bro_strerror_r(errno, buf, sizeof(buf)); bro_strerror_r(errno, buf, sizeof(buf));
reporter->Error("cannot open %s: %s", filename.c_str(), buf); zeek::reporter->Error("cannot open %s: %s", filename.c_str(), buf);
} }
} }
@ -39,7 +39,7 @@ static const zeek::ValPtr& get_extract_field_val(const zeek::RecordValPtr& args,
const auto& rval = args->GetField(name); const auto& rval = args->GetField(name);
if ( ! rval ) if ( ! rval )
reporter->Error("File extraction analyzer missing arg field: %s", name); zeek::reporter->Error("File extraction analyzer missing arg field: %s", name);
return rval; return rval;
} }

View file

@ -79,7 +79,7 @@ static bool ocsp_add_cert_id(const OCSP_CERTID* cert_id, zeek::Args* vl, BIO* bi
if ( ! res ) if ( ! res )
{ {
reporter->Weird("OpenSSL failed to get OCSP_CERTID info"); zeek::reporter->Weird("OpenSSL failed to get OCSP_CERTID info");
vl->emplace_back(zeek::val_mgr->EmptyString()); vl->emplace_back(zeek::val_mgr->EmptyString());
vl->emplace_back(zeek::val_mgr->EmptyString()); vl->emplace_back(zeek::val_mgr->EmptyString());
vl->emplace_back(zeek::val_mgr->EmptyString()); vl->emplace_back(zeek::val_mgr->EmptyString());
@ -154,7 +154,7 @@ bool file_analysis::OCSP::EndOfFile()
if (!req) if (!req)
{ {
reporter->Weird(GetFile(), "openssl_ocsp_request_parse_error"); zeek::reporter->Weird(GetFile(), "openssl_ocsp_request_parse_error");
return false; return false;
} }
@ -167,7 +167,7 @@ bool file_analysis::OCSP::EndOfFile()
if (!resp) if (!resp)
{ {
reporter->Weird(GetFile(), "openssl_ocsp_response_parse_error"); zeek::reporter->Weird(GetFile(), "openssl_ocsp_response_parse_error");
return false; return false;
} }
@ -506,7 +506,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp)
} }
else else
{ {
reporter->Weird("OpenSSL failed to get OCSP responder id"); zeek::reporter->Weird("OpenSSL failed to get OCSP responder id");
vl.emplace_back(zeek::val_mgr->EmptyString()); vl.emplace_back(zeek::val_mgr->EmptyString());
} }
@ -517,7 +517,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp)
produced_at = OCSP_resp_get0_produced_at(basic_resp); produced_at = OCSP_resp_get0_produced_at(basic_resp);
#endif #endif
vl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(produced_at, GetFile(), reporter))); vl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(produced_at, GetFile(), zeek::reporter)));
// responses // responses
@ -557,7 +557,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp)
const_cast<OCSP_CERTID*>(cert_id), const_cast<OCSP_CERTID*>(cert_id),
&status, &reason, &revoke_time, &status, &reason, &revoke_time,
&this_update, &next_update) ) &this_update, &next_update) )
reporter->Weird("OpenSSL failed to find status of OCSP response"); zeek::reporter->Weird("OpenSSL failed to find status of OCSP response");
const char* cert_status_str = OCSP_cert_status_str(status); const char* cert_status_str = OCSP_cert_status_str(status);
rvl.emplace_back(zeek::make_intrusive<zeek::StringVal>(strlen(cert_status_str), cert_status_str)); rvl.emplace_back(zeek::make_intrusive<zeek::StringVal>(strlen(cert_status_str), cert_status_str));
@ -565,7 +565,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp)
// revocation time and reason if revoked // revocation time and reason if revoked
if ( status == V_OCSP_CERTSTATUS_REVOKED ) if ( status == V_OCSP_CERTSTATUS_REVOKED )
{ {
rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(revoke_time, GetFile(), reporter))); rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(revoke_time, GetFile(), zeek::reporter)));
if ( reason != OCSP_REVOKED_STATUS_NOSTATUS ) if ( reason != OCSP_REVOKED_STATUS_NOSTATUS )
{ {
@ -582,12 +582,12 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp)
} }
if ( this_update ) if ( this_update )
rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(this_update, GetFile(), reporter))); rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(this_update, GetFile(), zeek::reporter)));
else else
rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(0.0)); rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(0.0));
if ( next_update ) if ( next_update )
rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(next_update, GetFile(), reporter))); rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(next_update, GetFile(), zeek::reporter)));
else else
rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(0.0)); rvl.emplace_back(zeek::make_intrusive<zeek::TimeVal>(0.0));
@ -638,7 +638,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp)
if (this_cert) if (this_cert)
certs_vector->Assign(i, zeek::make_intrusive<file_analysis::X509Val>(this_cert)); certs_vector->Assign(i, zeek::make_intrusive<file_analysis::X509Val>(this_cert));
else else
reporter->Weird("OpenSSL returned null certificate"); zeek::reporter->Weird("OpenSSL returned null certificate");
} }
} }

View file

@ -75,7 +75,7 @@ bool file_analysis::X509::EndOfFile()
::X509* ssl_cert = d2i_X509(NULL, &cert_char, cert_data.size()); ::X509* ssl_cert = d2i_X509(NULL, &cert_char, cert_data.size());
if ( ! ssl_cert ) if ( ! ssl_cert )
{ {
reporter->Weird(GetFile(), "x509_cert_parse_error"); zeek::reporter->Weird(GetFile(), "x509_cert_parse_error");
return false; return false;
} }
@ -160,8 +160,8 @@ zeek::RecordValPtr file_analysis::X509::ParseCertificate(X509Val* cert_val, File
pX509Cert->Assign(3, zeek::make_intrusive<zeek::StringVal>(len, buf)); pX509Cert->Assign(3, zeek::make_intrusive<zeek::StringVal>(len, buf));
BIO_free(bio); BIO_free(bio);
pX509Cert->Assign(5, zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(X509_get_notBefore(ssl_cert), f, reporter))); pX509Cert->Assign(5, zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(X509_get_notBefore(ssl_cert), f, zeek::reporter)));
pX509Cert->Assign(6, zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(X509_get_notAfter(ssl_cert), f, reporter))); pX509Cert->Assign(6, zeek::make_intrusive<zeek::TimeVal>(GetTimeFromAsn1(X509_get_notAfter(ssl_cert), f, zeek::reporter)));
// we only read 255 bytes because byte 256 is always 0. // we only read 255 bytes because byte 256 is always 0.
// if the string is longer than 255, that will be our null-termination, // if the string is longer than 255, that will be our null-termination,
@ -306,7 +306,7 @@ void file_analysis::X509::ParseBasicConstraints(X509_EXTENSION* ex)
} }
else else
reporter->Weird(GetFile(), "x509_invalid_basic_constraint"); zeek::reporter->Weird(GetFile(), "x509_invalid_basic_constraint");
} }
void file_analysis::X509::ParseExtensionsSpecific(X509_EXTENSION* ex, bool global, ASN1_OBJECT* ext_asn, const char* oid) void file_analysis::X509::ParseExtensionsSpecific(X509_EXTENSION* ex, bool global, ASN1_OBJECT* ext_asn, const char* oid)
@ -336,7 +336,7 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext)
GENERAL_NAMES *altname = (GENERAL_NAMES*)X509V3_EXT_d2i(ext); GENERAL_NAMES *altname = (GENERAL_NAMES*)X509V3_EXT_d2i(ext);
if ( ! altname ) if ( ! altname )
{ {
reporter->Weird(GetFile(), "x509_san_parse_error"); zeek::reporter->Weird(GetFile(), "x509_san_parse_error");
return; return;
} }
@ -356,7 +356,7 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext)
{ {
if ( ASN1_STRING_type(gen->d.ia5) != V_ASN1_IA5STRING ) if ( ASN1_STRING_type(gen->d.ia5) != V_ASN1_IA5STRING )
{ {
reporter->Weird(GetFile(), "x509_san_non_string"); zeek::reporter->Weird(GetFile(), "x509_san_non_string");
continue; continue;
} }
@ -407,14 +407,14 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext)
else else
{ {
reporter->Weird(GetFile(), "x509_san_ip_length", fmt("%d", gen->d.ip->length)); zeek::reporter->Weird(GetFile(), "x509_san_ip_length", fmt("%d", gen->d.ip->length));
continue; continue;
} }
} }
else else
{ {
// reporter->Error("Subject alternative name contained unsupported fields. fuid %s", GetFile()->GetID().c_str()); // zeek::reporter->Error("Subject alternative name contained unsupported fields. fuid %s", GetFile()->GetID().c_str());
// This happens quite often - just mark it // This happens quite often - just mark it
otherfields = true; otherfields = true;
continue; continue;
@ -524,7 +524,7 @@ unsigned int file_analysis::X509::KeyLength(EVP_PKEY *key)
return 0; // unknown public key type return 0; // unknown public key type
} }
reporter->InternalError("cannot be reached"); zeek::reporter->InternalError("cannot be reached");
} }
X509Val::X509Val(::X509* arg_certificate) : OpaqueVal(x509_opaque_type) X509Val::X509Val(::X509* arg_certificate) : OpaqueVal(x509_opaque_type)

View file

@ -25,12 +25,12 @@ X509Common::X509Common(const file_analysis::Tag& arg_tag,
static void EmitWeird(const char* name, File* file, const char* addl = "") static void EmitWeird(const char* name, File* file, const char* addl = "")
{ {
if ( file ) if ( file )
reporter->Weird(file, name, addl); zeek::reporter->Weird(file, name, addl);
else else
reporter->Weird(name); zeek::reporter->Weird(name);
} }
double X509Common::GetTimeFromAsn1(const ASN1_TIME* atime, File* f, Reporter* reporter) double X509Common::GetTimeFromAsn1(const ASN1_TIME* atime, File* f, zeek::Reporter* reporter)
{ {
time_t lResult = 0; time_t lResult = 0;
@ -205,7 +205,7 @@ void file_analysis::X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION*
ASN1_OCTET_STRING* inner = d2i_ASN1_OCTET_STRING(NULL, (const unsigned char**) &ext_val_copy, ext_val->length); ASN1_OCTET_STRING* inner = d2i_ASN1_OCTET_STRING(NULL, (const unsigned char**) &ext_val_copy, ext_val->length);
if ( !inner ) if ( !inner )
{ {
reporter->Error("X509::ParseSignedCertificateTimestamps could not parse inner octet string"); zeek::reporter->Error("X509::ParseSignedCertificateTimestamps could not parse inner octet string");
return; return;
} }
@ -219,7 +219,7 @@ void file_analysis::X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION*
catch( const binpac::Exception& e ) catch( const binpac::Exception& e )
{ {
// throw a warning or sth // throw a warning or sth
reporter->Error("X509::ParseSignedCertificateTimestamps could not parse SCT"); zeek::reporter->Error("X509::ParseSignedCertificateTimestamps could not parse SCT");
} }
ASN1_OCTET_STRING_free(inner); ASN1_OCTET_STRING_free(inner);
@ -325,7 +325,7 @@ zeek::StringValPtr file_analysis::X509Common::GetExtensionFromBIO(BIO* bio, File
{ {
// Just emit an error here and try to continue instead of aborting // Just emit an error here and try to continue instead of aborting
// because it's unclear the length value is very reliable. // because it's unclear the length value is very reliable.
reporter->Error("X509::GetExtensionFromBIO malloc(%d) failed", length); zeek::reporter->Error("X509::GetExtensionFromBIO malloc(%d) failed", length);
BIO_free_all(bio); BIO_free_all(bio);
return nullptr; return nullptr;
} }

View file

@ -11,8 +11,8 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
class EventHandlerPtr; class EventHandlerPtr;
class Reporter;
ZEEK_FORWARD_DECLARE_NAMESPACED(Reporter, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek);
namespace zeek { namespace zeek {
@ -42,7 +42,7 @@ public:
*/ */
static zeek::StringValPtr GetExtensionFromBIO(BIO* bio, File* f = nullptr); static zeek::StringValPtr GetExtensionFromBIO(BIO* bio, File* f = nullptr);
static double GetTimeFromAsn1(const ASN1_TIME* atime, File* f, Reporter* reporter); static double GetTimeFromAsn1(const ASN1_TIME* atime, File* f, zeek::Reporter* reporter);
protected: protected:
X509Common(const file_analysis::Tag& arg_tag, X509Common(const file_analysis::Tag& arg_tag,

View file

@ -225,7 +225,7 @@ function x509_ocsp_verify%(certs: x509_opaque_vector, ocsp_reply: string, root_c
zeek::VectorVal *certs_vec = certs->AsVectorVal(); zeek::VectorVal *certs_vec = certs->AsVectorVal();
if ( certs_vec->Size() < 1 ) if ( certs_vec->Size() < 1 )
{ {
reporter->Error("No certificates given in vector"); zeek::reporter->Error("No certificates given in vector");
return x509_result_record(-1, "no certificates"); return x509_result_record(-1, "no certificates");
} }
@ -511,7 +511,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
zeek::VectorVal *certs_vec = certs->AsVectorVal(); zeek::VectorVal *certs_vec = certs->AsVectorVal();
if ( ! certs_vec || certs_vec->Size() < 1 ) if ( ! certs_vec || certs_vec->Size() < 1 )
{ {
reporter->Error("No certificates given in vector"); zeek::reporter->Error("No certificates given in vector");
return x509_result_record(-1, "no certificates"); return x509_result_record(-1, "no certificates");
} }
@ -551,7 +551,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
if ( ! chain ) if ( ! chain )
{ {
reporter->Error("Encountered valid chain that could not be resolved"); zeek::reporter->Error("Encountered valid chain that could not be resolved");
sk_X509_pop_free(chain, X509_free); sk_X509_pop_free(chain, X509_free);
goto x509_verify_chainerror; goto x509_verify_chainerror;
} }
@ -568,7 +568,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
chainVector->Assign(i, zeek::make_intrusive<file_analysis::X509Val>(currcert)); chainVector->Assign(i, zeek::make_intrusive<file_analysis::X509Val>(currcert));
else else
{ {
reporter->InternalWarning("OpenSSL returned null certificate"); zeek::reporter->InternalWarning("OpenSSL returned null certificate");
sk_X509_pop_free(chain, X509_free); sk_X509_pop_free(chain, X509_free);
goto x509_verify_chainerror; goto x509_verify_chainerror;
} }
@ -623,7 +623,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa
bool precert = issuer_key_hash->Len() > 0; bool precert = issuer_key_hash->Len() > 0;
if ( precert && issuer_key_hash->Len() != 32) if ( precert && issuer_key_hash->Len() != 32)
{ {
reporter->Error("Invalid issuer_key_hash length"); zeek::reporter->Error("Invalid issuer_key_hash length");
return zeek::val_mgr->False(); return zeek::val_mgr->False();
} }
@ -647,7 +647,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa
int pos = X509_get_ext_by_NID(x, NID_ct_precert_scts, -1); int pos = X509_get_ext_by_NID(x, NID_ct_precert_scts, -1);
if ( pos < 0 ) if ( pos < 0 )
{ {
reporter->Error("NID_ct_precert_scts not found"); zeek::reporter->Error("NID_ct_precert_scts not found");
return zeek::val_mgr->False(); return zeek::val_mgr->False();
} }
#else #else
@ -751,7 +751,7 @@ sct_verify_err:
if (key) if (key)
EVP_PKEY_free(key); EVP_PKEY_free(key);
reporter->Error("%s", errstr.c_str()); zeek::reporter->Error("%s", errstr.c_str());
return zeek::val_mgr->False(); return zeek::val_mgr->False();
%} %}
@ -768,7 +768,7 @@ zeek::StringValPtr x509_entity_hash(file_analysis::X509Val *cert_handle, unsigne
if ( type > 2 ) if ( type > 2 )
{ {
reporter->InternalError("Unknown type in x509_entity_hash"); zeek::reporter->InternalError("Unknown type in x509_entity_hash");
return nullptr; return nullptr;
} }

View file

@ -204,7 +204,7 @@ ReaderBackend* Manager::CreateBackend(ReaderFrontend* frontend, zeek::EnumVal* t
if ( ! c ) if ( ! c )
{ {
reporter->Error("The reader that was requested was not found and could not be initialized."); zeek::reporter->Error("The reader that was requested was not found and could not be initialized.");
return nullptr; return nullptr;
} }
@ -222,7 +222,7 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description)
|| same_type(rtype, zeek::BifType::Record::Input::EventDescription, false) || same_type(rtype, zeek::BifType::Record::Input::EventDescription, false)
|| same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) ) ) || same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) ) )
{ {
reporter->Error("Stream description argument not of right type for new input stream"); zeek::reporter->Error("Stream description argument not of right type for new input stream");
return false; return false;
} }
@ -230,7 +230,7 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description)
if ( Stream *i = FindStream(name) ) if ( Stream *i = FindStream(name) )
{ {
reporter->Error("Trying create already existing input stream %s", zeek::reporter->Error("Trying create already existing input stream %s",
name.c_str()); name.c_str());
return false; return false;
} }
@ -263,7 +263,7 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description)
break; break;
default: default:
reporter->InternalWarning("unknown input reader mode"); zeek::reporter->InternalWarning("unknown input reader mode");
return false; return false;
} }
@ -308,7 +308,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
zeek::RecordType* rtype = fval->GetType()->AsRecordType(); zeek::RecordType* rtype = fval->GetType()->AsRecordType();
if ( ! same_type(rtype, zeek::BifType::Record::Input::EventDescription, false) ) if ( ! same_type(rtype, zeek::BifType::Record::Input::EventDescription, false) )
{ {
reporter->Error("EventDescription argument not of right type"); zeek::reporter->Error("EventDescription argument not of right type");
return false; return false;
} }
@ -328,7 +328,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT ) if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT )
{ {
reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str());
return false; return false;
} }
@ -336,19 +336,19 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
if ( args.size() < 2 ) if ( args.size() < 2 )
{ {
reporter->Error("Input stream %s: Event does not take enough arguments", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Event does not take enough arguments", stream_name.c_str());
return false; return false;
} }
if ( ! same_type(args[1], zeek::BifType::Enum::Input::Event, false) ) if ( ! same_type(args[1], zeek::BifType::Enum::Input::Event, false) )
{ {
reporter->Error("Input stream %s: Event's second attribute must be of type Input::Event", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Event's second attribute must be of type Input::Event", stream_name.c_str());
return false; return false;
} }
if ( ! same_type(args[0], zeek::BifType::Record::Input::EventDescription, false) ) if ( ! same_type(args[0], zeek::BifType::Record::Input::EventDescription, false) )
{ {
reporter->Error("Input stream %s: Event's first attribute must be of type Input::EventDescription", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Event's first attribute must be of type Input::EventDescription", stream_name.c_str());
return false; return false;
} }
@ -356,7 +356,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
{ {
if ( static_cast<int>(args.size()) != fields->NumFields() + 2 ) if ( static_cast<int>(args.size()) != fields->NumFields() + 2 )
{ {
reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str());
return false; return false;
} }
@ -369,7 +369,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
args[i + 2]->Describe(&desc1); args[i + 2]->Describe(&desc1);
fields->GetFieldType(i)->Describe(&desc2); fields->GetFieldType(i)->Describe(&desc2);
reporter->Error("Input stream %s: Incompatible type for event in field %d. Need type '%s':%s, got '%s':%s", zeek::reporter->Error("Input stream %s: Incompatible type for event in field %d. Need type '%s':%s, got '%s':%s",
stream_name.c_str(), i + 3, stream_name.c_str(), i + 3,
zeek::type_name(fields->GetFieldType(i)->Tag()), desc2.Description(), zeek::type_name(fields->GetFieldType(i)->Tag()), desc2.Description(),
zeek::type_name(args[i + 2]->Tag()), desc1.Description()); zeek::type_name(args[i + 2]->Tag()), desc1.Description());
@ -384,7 +384,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
{ {
if ( args.size() != 3 ) if ( args.size() != 3 )
{ {
reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Event has wrong number of arguments", stream_name.c_str());
return false; return false;
} }
@ -394,7 +394,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
ODesc desc2; ODesc desc2;
args[2]->Describe(&desc1); args[2]->Describe(&desc1);
fields->Describe(&desc2); fields->Describe(&desc2);
reporter->Error("Input stream %s: Incompatible type '%s':%s for event, which needs type '%s':%s\n", zeek::reporter->Error("Input stream %s: Incompatible type '%s':%s for event, which needs type '%s':%s\n",
stream_name.c_str(), stream_name.c_str(),
zeek::type_name(args[2]->Tag()), desc1.Description(), zeek::type_name(args[2]->Tag()), desc1.Description(),
zeek::type_name(fields->Tag()), desc2.Description()); zeek::type_name(fields->Tag()), desc2.Description());
@ -420,7 +420,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
if ( status ) if ( status )
{ {
reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str());
for ( auto& f : fieldsV ) delete f; for ( auto& f : fieldsV ) delete f;
return false; return false;
} }
@ -462,7 +462,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
zeek::RecordType* rtype = fval->GetType()->AsRecordType(); zeek::RecordType* rtype = fval->GetType()->AsRecordType();
if ( ! same_type(rtype, zeek::BifType::Record::Input::TableDescription, false) ) if ( ! same_type(rtype, zeek::BifType::Record::Input::TableDescription, false) )
{ {
reporter->Error("TableDescription argument not of right type"); zeek::reporter->Error("TableDescription argument not of right type");
return false; return false;
} }
@ -489,7 +489,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
{ {
if ( j >= num ) if ( j >= num )
{ {
reporter->Error("Input stream %s: Table type has more indexes than index definition", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Table type has more indexes than index definition", stream_name.c_str());
return false; return false;
} }
@ -500,7 +500,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
idx->GetFieldType(j)->Describe(&desc1); idx->GetFieldType(j)->Describe(&desc1);
tl[j]->Describe(&desc2); tl[j]->Describe(&desc2);
reporter->Error("Input stream %s: Table type does not match index type. Need type '%s':%s, got '%s':%s", stream_name.c_str(), zeek::reporter->Error("Input stream %s: Table type does not match index type. Need type '%s':%s, got '%s':%s",
stream_name.c_str(),
zeek::type_name(idx->GetFieldType(j)->Tag()), desc1.Description(), zeek::type_name(idx->GetFieldType(j)->Tag()), desc1.Description(),
zeek::type_name(tl[j]->Tag()), desc2.Description()); zeek::type_name(tl[j]->Tag()), desc2.Description());
@ -510,7 +511,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
if ( num != j ) if ( num != j )
{ {
reporter->Error("Input stream %s: Table has less elements than index definition", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Table has less elements than index definition", stream_name.c_str());
return false; return false;
} }
@ -521,7 +522,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
{ {
if ( destination_is_set ) if ( destination_is_set )
{ {
reporter->Error("Input stream %s: 'destination' field is a set, " zeek::reporter->Error("Input stream %s: 'destination' field is a set, "
"but the 'val' field was also specified " "but the 'val' field was also specified "
"(did you mean to use a table instead of a set?)", "(did you mean to use a table instead of a set?)",
stream_name.data()); stream_name.data());
@ -538,7 +539,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
ODesc desc2; ODesc desc2;
compare_type->Describe(&desc1); compare_type->Describe(&desc1);
table_yield->Describe(&desc2); table_yield->Describe(&desc2);
reporter->Error("Input stream %s: Table type does not match value type. Need type '%s', got '%s'", zeek::reporter->Error("Input stream %s: Table type does not match value type. Need type '%s', got '%s'",
stream_name.c_str(), desc1.Description(), desc2.Description()); stream_name.c_str(), desc1.Description(), desc2.Description());
return false; return false;
} }
@ -548,7 +549,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
{ {
if ( ! destination_is_set ) if ( ! destination_is_set )
{ {
reporter->Error("Input stream %s: 'destination' field is a table," zeek::reporter->Error("Input stream %s: 'destination' field is a table,"
" but 'val' field is not provided" " but 'val' field is not provided"
" (did you mean to use a set instead of a table?)", " (did you mean to use a set instead of a table?)",
stream_name.c_str()); stream_name.c_str());
@ -565,7 +566,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT ) if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT )
{ {
reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str());
return false; return false;
} }
@ -574,20 +575,22 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
if ( args.size() != required_arg_count ) if ( args.size() != required_arg_count )
{ {
reporter->Error("Input stream %s: Table event must take %zu arguments", zeek::reporter->Error("Input stream %s: Table event must take %zu arguments",
stream_name.c_str(), required_arg_count); stream_name.c_str(), required_arg_count);
return false; return false;
} }
if ( ! same_type(args[0], zeek::BifType::Record::Input::TableDescription, false) ) if ( ! same_type(args[0], zeek::BifType::Record::Input::TableDescription, false) )
{ {
reporter->Error("Input stream %s: Table event's first attribute must be of type Input::TableDescription", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Table event's first attribute must be of type Input::TableDescription",
stream_name.c_str());
return false; return false;
} }
if ( ! same_type(args[1], zeek::BifType::Enum::Input::Event, false) ) if ( ! same_type(args[1], zeek::BifType::Enum::Input::Event, false) )
{ {
reporter->Error("Input stream %s: Table event's second attribute must be of type Input::Event", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Table event's second attribute must be of type Input::Event",
stream_name.c_str());
return false; return false;
} }
@ -597,7 +600,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
ODesc desc2; ODesc desc2;
idx->Describe(&desc1); idx->Describe(&desc1);
args[2]->Describe(&desc2); args[2]->Describe(&desc2);
reporter->Error("Input stream %s: Table event's index attributes do not match. Need '%s', got '%s'", stream_name.c_str(), zeek::reporter->Error("Input stream %s: Table event's index attributes do not match. Need '%s', got '%s'",
stream_name.c_str(),
desc1.Description(), desc2.Description()); desc1.Description(), desc2.Description());
return false; return false;
} }
@ -610,7 +614,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
ODesc desc2; ODesc desc2;
val->Describe(&desc1); val->Describe(&desc1);
args[3]->Describe(&desc2); args[3]->Describe(&desc2);
reporter->Error("Input stream %s: Table event's value attributes do not match. Need '%s', got '%s'", zeek::reporter->Error("Input stream %s: Table event's value attributes do not match. Need '%s', got '%s'",
stream_name.c_str(), desc1.Description(), desc2.Description()); stream_name.c_str(), desc1.Description(), desc2.Description());
return false; return false;
} }
@ -621,13 +625,13 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
ODesc desc2; ODesc desc2;
val->GetFieldType(0)->Describe(&desc1); val->GetFieldType(0)->Describe(&desc1);
args[3]->Describe(&desc2); args[3]->Describe(&desc2);
reporter->Error("Input stream %s: Table event's value attribute does not match. Need '%s', got '%s'", zeek::reporter->Error("Input stream %s: Table event's value attribute does not match. Need '%s', got '%s'",
stream_name.c_str(), desc1.Description(), desc2.Description()); stream_name.c_str(), desc1.Description(), desc2.Description());
return false; return false;
} }
else if ( ! val ) else if ( ! val )
{ {
reporter->Error("Encountered a null value when creating a table stream"); zeek::reporter->Error("Encountered a null value when creating a table stream");
} }
} }
@ -653,7 +657,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
if ( (valfields > 1) && (want_record->InternalInt() != 1) ) if ( (valfields > 1) && (want_record->InternalInt() != 1) )
{ {
reporter->Error("Input stream %s: Stream does not want a record (want_record=F), but has more then one value field.", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Stream does not want a record (want_record=F), but has more then one value field.",
stream_name.c_str());
for ( auto& f : fieldsV ) delete f; for ( auto& f : fieldsV ) delete f;
return false; return false;
} }
@ -663,7 +668,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
if ( status ) if ( status )
{ {
reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Problem unrolling", stream_name.c_str());
for ( auto& f : fieldsV ) delete f; for ( auto& f : fieldsV ) delete f;
return false; return false;
} }
@ -717,7 +722,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const zeek::F
if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT ) if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT )
{ {
reporter->Error("Input stream %s: Error event is a function, not an event", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Error event is a function, not an event", stream_name.c_str());
return false; return false;
} }
@ -725,31 +730,35 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const zeek::F
if ( args.size() != 3 ) if ( args.size() != 3 )
{ {
reporter->Error("Input stream %s: Error event must take 3 arguments", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Error event must take 3 arguments", stream_name.c_str());
return false; return false;
} }
if ( table && ! same_type(args[0], zeek::BifType::Record::Input::TableDescription, false) ) if ( table && ! same_type(args[0], zeek::BifType::Record::Input::TableDescription, false) )
{ {
reporter->Error("Input stream %s: Error event's first attribute must be of type Input::TableDescription", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Error event's first attribute must be of type Input::TableDescription",
stream_name.c_str());
return false; return false;
} }
if ( ! table && ! same_type(args[0], zeek::BifType::Record::Input::EventDescription, false) ) if ( ! table && ! same_type(args[0], zeek::BifType::Record::Input::EventDescription, false) )
{ {
reporter->Error("Input stream %s: Error event's first attribute must be of type Input::EventDescription", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Error event's first attribute must be of type Input::EventDescription",
stream_name.c_str());
return false; return false;
} }
if ( args[1]->Tag() != zeek::TYPE_STRING ) if ( args[1]->Tag() != zeek::TYPE_STRING )
{ {
reporter->Error("Input stream %s: Error event's second attribute must be of type string", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Error event's second attribute must be of type string",
stream_name.c_str());
return false; return false;
} }
if ( ! same_type(args[2], zeek::BifType::Enum::Reporter::Level, false) ) if ( ! same_type(args[2], zeek::BifType::Enum::Reporter::Level, false) )
{ {
reporter->Error("Input stream %s: Error event's third attribute must be of type Reporter::Level", stream_name.c_str()); zeek::reporter->Error("Input stream %s: Error event's third attribute must be of type Reporter::Level",
stream_name.c_str());
return false; return false;
} }
@ -762,7 +771,7 @@ bool Manager::CreateAnalysisStream(zeek::RecordVal* fval)
if ( ! same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) ) if ( ! same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) )
{ {
reporter->Error("AnalysisDescription argument not of right type"); zeek::reporter->Error("AnalysisDescription argument not of right type");
return false; return false;
} }
@ -849,7 +858,7 @@ bool Manager::RemoveStream(Stream *i)
if ( i->removed ) if ( i->removed )
{ {
reporter->Warning("Stream %s is already queued for removal. Ignoring remove.", i->name.c_str()); zeek::reporter->Warning("Stream %s is already queued for removal. Ignoring remove.", i->name.c_str());
return true; return true;
} }
@ -881,7 +890,7 @@ bool Manager::RemoveStreamContinuation(ReaderFrontend* reader)
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->Error("Stream not found in RemoveStreamContinuation"); zeek::reporter->Error("Stream not found in RemoveStreamContinuation");
return false; return false;
} }
@ -915,12 +924,13 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const zeek::RecordType *r
rec->GetFieldType(i)->Tag() == zeek::TYPE_OPAQUE ) && rec->GetFieldType(i)->Tag() == zeek::TYPE_OPAQUE ) &&
rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) ) rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) )
{ {
reporter->Info("Encountered incompatible type \"%s\" in type definition for field \"%s\" in ReaderFrontend. Ignoring optional field.", zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str()); zeek::reporter->Info("Encountered incompatible type \"%s\" in type definition for field \"%s\" in ReaderFrontend. Ignoring optional field.",
zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str());
continue; continue;
} }
} }
reporter->Error("Incompatible type \"%s\" in type definition for for field \"%s\" in ReaderFrontend", zeek::reporter->Error("Incompatible type \"%s\" in type definition for for field \"%s\" in ReaderFrontend",
zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str()); zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str());
return false; return false;
} }
@ -931,7 +941,7 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const zeek::RecordType *r
if ( rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) ) if ( rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) )
{ {
reporter->Info("The input framework does not support optional record fields: \"%s\"", rec->FieldName(i)); zeek::reporter->Info("The input framework does not support optional record fields: \"%s\"", rec->FieldName(i));
return false; return false;
} }
@ -986,13 +996,13 @@ bool Manager::ForceUpdate(const string &name)
Stream *i = FindStream(name); Stream *i = FindStream(name);
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->Error("Stream %s not found", name.c_str()); zeek::reporter->Error("Stream %s not found", name.c_str());
return false; return false;
} }
if ( i->removed ) if ( i->removed )
{ {
reporter->Error("Stream %s is already queued for removal. Ignoring force update.", name.c_str()); zeek::reporter->Error("Stream %s is already queued for removal. Ignoring force update.", name.c_str());
return false; return false;
} }
@ -1070,7 +1080,7 @@ void Manager::SendEntry(ReaderFrontend* reader, Value* *vals)
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in SendEntry", zeek::reporter->InternalWarning("Unknown reader %s in SendEntry",
reader->Name()); reader->Name());
return; return;
} }
@ -1258,7 +1268,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
auto k = stream->tab->MakeHashKey(*idxval); auto k = stream->tab->MakeHashKey(*idxval);
if ( ! k ) if ( ! k )
reporter->InternalError("could not hash"); zeek::reporter->InternalError("could not hash");
InputHash* ih = new InputHash(); InputHash* ih = new InputHash();
ih->idxkey = new HashKey(k->Key(), k->Size(), k->Hash()); ih->idxkey = new HashKey(k->Key(), k->Size(), k->Hash());
@ -1310,7 +1320,7 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in EndCurrentSend", zeek::reporter->InternalWarning("Unknown reader %s in EndCurrentSend",
reader->Name()); reader->Name());
return; return;
} }
@ -1409,7 +1419,7 @@ void Manager::SendEndOfData(ReaderFrontend* reader)
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in SendEndOfData", zeek::reporter->InternalWarning("Unknown reader %s in SendEndOfData",
reader->Name()); reader->Name());
return; return;
} }
@ -1436,7 +1446,7 @@ void Manager::Put(ReaderFrontend* reader, Value* *vals)
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in Put", reader->Name()); zeek::reporter->InternalWarning("Unknown reader %s in Put", reader->Name());
return; return;
} }
@ -1664,7 +1674,7 @@ void Manager::Clear(ReaderFrontend* reader)
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in Clear", zeek::reporter->InternalWarning("Unknown reader %s in Clear",
reader->Name()); reader->Name());
return; return;
} }
@ -1686,7 +1696,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value* *vals)
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == nullptr ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in Delete", reader->Name()); zeek::reporter->InternalWarning("Unknown reader %s in Delete", reader->Name());
return false; return false;
} }
@ -1995,7 +2005,7 @@ int Manager::GetValueLength(const Value* val) const
} }
default: default:
reporter->InternalError("unsupported type %d for GetValueLength", val->type); zeek::reporter->InternalError("unsupported type %d for GetValueLength", val->type);
} }
return length; return length;
@ -2127,7 +2137,7 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
} }
default: default:
reporter->InternalError("unsupported type %d for CopyValue", val->type); zeek::reporter->InternalError("unsupported type %d for CopyValue", val->type);
return 0; return 0;
} }
@ -2189,7 +2199,7 @@ zeek::Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::Type* re
if ( request_type->Tag() != zeek::TYPE_ANY && request_type->Tag() != val->type ) if ( request_type->Tag() != zeek::TYPE_ANY && request_type->Tag() != val->type )
{ {
reporter->InternalError("Typetags don't match: %d vs %d in stream %s", request_type->Tag(), val->type, i->name.c_str()); zeek::reporter->InternalError("Typetags don't match: %d vs %d in stream %s", request_type->Tag(), val->type, i->name.c_str());
return nullptr; return nullptr;
} }
@ -2334,7 +2344,7 @@ zeek::Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::Type* re
} }
default: default:
reporter->InternalError("Unsupported type for input_read in stream %s", i->name.c_str()); zeek::reporter->InternalError("Unsupported type for input_read in stream %s", i->name.c_str());
} }
assert(false); assert(false);
@ -2381,7 +2391,7 @@ void Manager::Info(ReaderFrontend* reader, const char* msg) const
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( !i ) if ( !i )
{ {
reporter->Error("Stream not found in Info; lost message: %s", msg); zeek::reporter->Error("Stream not found in Info; lost message: %s", msg);
return; return;
} }
@ -2393,7 +2403,7 @@ void Manager::Warning(ReaderFrontend* reader, const char* msg) const
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( !i ) if ( !i )
{ {
reporter->Error("Stream not found in Warning; lost message: %s", msg); zeek::reporter->Error("Stream not found in Warning; lost message: %s", msg);
return; return;
} }
@ -2405,7 +2415,7 @@ void Manager::Error(ReaderFrontend* reader, const char* msg) const
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( !i ) if ( !i )
{ {
reporter->Error("Stream not found in Error; lost message: %s", msg); zeek::reporter->Error("Stream not found in Error; lost message: %s", msg);
return; return;
} }
@ -2451,7 +2461,7 @@ void Manager::ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, co
int n = vasprintf(&buf, fmt, ap); int n = vasprintf(&buf, fmt, ap);
if ( n < 0 || buf == nullptr ) if ( n < 0 || buf == nullptr )
{ {
reporter->InternalError("Could not format error message %s for stream %s", fmt, i->name.c_str()); zeek::reporter->InternalError("Could not format error message %s for stream %s", fmt, i->name.c_str());
return; return;
} }
@ -2474,7 +2484,7 @@ void Manager::ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, co
break; break;
default: default:
reporter->InternalError("Unknown error type while trying to report input error %s", fmt); zeek::reporter->InternalError("Unknown error type while trying to report input error %s", fmt);
__builtin_unreachable(); __builtin_unreachable();
} }
@ -2487,19 +2497,19 @@ void Manager::ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, co
switch (et) switch (et)
{ {
case ErrorType::INFO: case ErrorType::INFO:
reporter->Info("%s", buf); zeek::reporter->Info("%s", buf);
break; break;
case ErrorType::WARNING: case ErrorType::WARNING:
reporter->Warning("%s", buf); zeek::reporter->Warning("%s", buf);
break; break;
case ErrorType::ERROR: case ErrorType::ERROR:
reporter->Error("%s", buf); zeek::reporter->Error("%s", buf);
break; break;
default: default:
reporter->InternalError("Unknown error type while trying to report input error %s", fmt); zeek::reporter->InternalError("Unknown error type while trying to report input error %s", fmt);
} }
} }

View file

@ -69,7 +69,7 @@ void ReaderFrontend::Init(const int arg_num_fields,
return; return;
if ( initialized ) if ( initialized )
reporter->InternalError("reader initialize twice"); zeek::reporter->InternalError("reader initialize twice");
num_fields = arg_num_fields; num_fields = arg_num_fields;
fields = arg_fields; fields = arg_fields;
@ -85,7 +85,7 @@ void ReaderFrontend::Update()
if ( ! initialized ) if ( ! initialized )
{ {
reporter->Error("Tried to call update on uninitialized reader"); zeek::reporter->Error("Tried to call update on uninitialized reader");
return; return;
} }

Some files were not shown because too many files have changed in this diff Show more