diff --git a/src/Conn.cc b/src/Conn.cc index c536ae06b4..9d82057edc 100644 --- a/src/Conn.cc +++ b/src/Conn.cc @@ -627,7 +627,7 @@ unsigned int Connection::MemoryAllocationConnVal() const return conn_val ? conn_val->MemoryAllocation() : 0; } -void Connection::Describe(ODesc* d) const +void Connection::Describe(zeek::ODesc* d) const { d->Add(start_time); d->Add("("); @@ -674,7 +674,7 @@ void Connection::Describe(ODesc* d) const d->NL(); } -void Connection::IDString(ODesc* d) const +void Connection::IDString(zeek::ODesc* d) const { d->Add(orig_addr); d->AddRaw(":", 1); diff --git a/src/Conn.h b/src/Conn.h index 1bac3598e8..1943700596 100644 --- a/src/Conn.h +++ b/src/Conn.h @@ -261,8 +261,8 @@ public: return true; } - void Describe(ODesc* d) const override; - void IDString(ODesc* d) const; + void Describe(zeek::ODesc* d) const override; + void IDString(zeek::ODesc* d) const; // Statistics. diff --git a/src/Desc.cc b/src/Desc.cc index aab5913cd1..773f99940a 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -16,6 +16,8 @@ #define DEFAULT_SIZE 128 #define SLOP 10 +namespace zeek { + ODesc::ODesc(desc_type t, zeek::File* arg_f) { type = t; @@ -424,3 +426,5 @@ bool ODesc::FindType(const zeek::Type* type) return false; } + +} // namespace zeek diff --git a/src/Desc.h b/src/Desc.h index 95d34d1928..7a33a02ba6 100644 --- a/src/Desc.h +++ b/src/Desc.h @@ -11,17 +11,6 @@ #include // for u_char -typedef enum { - DESC_READABLE, - DESC_PORTABLE, - DESC_BINARY, -} desc_type; - -typedef enum { - STANDARD_STYLE, - RAW_STYLE, -} desc_style; - namespace zeek { class File; } using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File; @@ -31,6 +20,19 @@ ZEEK_FORWARD_DECLARE_NAMESPACED(IPPrefix, zeek); namespace zeek { class Type; } using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type; +namespace zeek { + +enum desc_type { + DESC_READABLE, + DESC_PORTABLE, + DESC_BINARY, +}; + +enum desc_style { + STANDARD_STYLE, + RAW_STYLE, +}; + class ODesc { public: explicit ODesc(desc_type t=DESC_READABLE, zeek::File* f=nullptr); @@ -210,3 +212,15 @@ protected: std::set encountered_types; }; + +} // namespace zeek + +using ODesc [[deprecated("Remove in v4.1. Use zeek::ODesc.")]] = zeek::ODesc; +using desc_type [[deprecated("Remove in v4.1. Use zeek::desc_type.")]] = zeek::desc_type; +constexpr auto DESC_READABLE [[deprecated("Remove in v4.1. Use zeek::DESC_READABLE.")]] = zeek::DESC_READABLE; +constexpr auto DESC_PORTABLE [[deprecated("Remove in v4.1. Use zeek::DESC_PORTABLE.")]] = zeek::DESC_PORTABLE; +constexpr auto DESC_BINARY [[deprecated("Remove in v4.1. Use zeek::DESC_BINARY.")]] = zeek::DESC_BINARY; + +using desc_style [[deprecated("Remove in v4.1. Use zeek::desc_style.")]] = zeek::desc_style; +constexpr auto STANDARD_STYLE [[deprecated("Remove in v4.1. Use zeek::STANDARD_STYLE.")]] = zeek::STANDARD_STYLE; +constexpr auto RAW_STYLE [[deprecated("Remove in v4.1. Use zeek::RAW_STYLE.")]] = zeek::RAW_STYLE; diff --git a/src/Obj.cc b/src/Obj.cc index 77358a5b3d..4c7f367992 100644 --- a/src/Obj.cc +++ b/src/Obj.cc @@ -16,7 +16,7 @@ namespace detail { Location start_location("", 0, 0, 0, 0); Location end_location("", 0, 0, 0, 0); -void Location::Describe(ODesc* d) const +void Location::Describe(zeek::ODesc* d) const { if ( filename ) { @@ -65,7 +65,7 @@ Obj::~Obj() void Obj::Warn(const char* msg, const Obj* obj2, bool pinpoint_only, const detail::Location* expr_location) const { - ODesc d; + zeek::ODesc d; DoMsg(&d, msg, obj2, pinpoint_only, expr_location); zeek::reporter->Warning("%s", d.Description()); zeek::reporter->PopLocation(); @@ -76,7 +76,7 @@ void Obj::Error(const char* msg, const Obj* obj2, bool pinpoint_only, const deta if ( suppress_errors ) return; - ODesc d; + zeek::ODesc d; DoMsg(&d, msg, obj2, pinpoint_only, expr_location); zeek::reporter->Error("%s", d.Description()); zeek::reporter->PopLocation(); @@ -93,7 +93,7 @@ void Obj::BadTag(const char* msg, const char* t1, const char* t2) const else snprintf(out, sizeof(out), "%s", msg); - ODesc d; + zeek::ODesc d; DoMsg(&d, out); zeek::reporter->FatalErrorWithCore("%s", d.Description()); zeek::reporter->PopLocation(); @@ -101,7 +101,7 @@ void Obj::BadTag(const char* msg, const char* t1, const char* t2) const void Obj::Internal(const char* msg) const { - ODesc d; + zeek::ODesc d; DoMsg(&d, msg); auto rcs = zeek::render_call_stack(); @@ -115,13 +115,13 @@ void Obj::Internal(const char* msg) const void Obj::InternalWarning(const char* msg) const { - ODesc d; + zeek::ODesc d; DoMsg(&d, msg); zeek::reporter->InternalWarning("%s", d.Description()); zeek::reporter->PopLocation(); } -void Obj::AddLocation(ODesc* d) const +void Obj::AddLocation(zeek::ODesc* d) const { if ( ! location ) { @@ -162,8 +162,8 @@ void Obj::UpdateLocationEndInfo(const detail::Location& end) location->last_column = end.last_column; } -void Obj::DoMsg(ODesc* d, const char s1[], const Obj* obj2, - bool pinpoint_only, const detail::Location* expr_location) const +void Obj::DoMsg(zeek::ODesc* d, const char s1[], const Obj* obj2, + bool pinpoint_only, const detail::Location* expr_location) const { d->SetShort(); @@ -180,7 +180,7 @@ void Obj::DoMsg(ODesc* d, const char s1[], const Obj* obj2, zeek::reporter->PushLocation(GetLocationInfo(), loc2); } -void Obj::PinPoint(ODesc* d, const Obj* obj2, bool pinpoint_only) const +void Obj::PinPoint(zeek::ODesc* d, const Obj* obj2, bool pinpoint_only) const { d->Add(" ("); Describe(d); @@ -196,7 +196,7 @@ void Obj::PinPoint(ODesc* d, const Obj* obj2, bool pinpoint_only) const void Obj::Print() const { static zeek::File fstderr(stderr); - ODesc d(DESC_READABLE, &fstderr); + zeek::ODesc d(DESC_READABLE, &fstderr); Describe(&d); d.Add("\n"); } diff --git a/src/Obj.h b/src/Obj.h index 9072366527..08466540f9 100644 --- a/src/Obj.h +++ b/src/Obj.h @@ -2,9 +2,11 @@ #pragma once +#include "zeek-config.h" + #include -class ODesc; +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); namespace zeek { namespace detail { @@ -19,7 +21,7 @@ public: Location() = default; - void Describe(ODesc* d) const; + void Describe(zeek::ODesc* d) const; bool operator==(const Location& l) const; bool operator!=(const Location& l) const @@ -103,9 +105,9 @@ public: [[noreturn]] void Internal(const char* msg) const; void InternalWarning(const char* msg) const; - virtual void Describe(ODesc* d) const { /* FIXME: Add code */ }; + virtual void Describe(zeek::ODesc* d) const { /* FIXME: Add code */ }; - void AddLocation(ODesc* d) const; + void AddLocation(zeek::ODesc* d) const; // Get location info for debugging. const detail::Location* GetLocationInfo() const @@ -142,10 +144,10 @@ protected: private: friend class SuppressErrors; - void DoMsg(ODesc* d, const char s1[], const Obj* obj2 = nullptr, - bool pinpoint_only = false, const detail::Location* expr_location = nullptr) const; - void PinPoint(ODesc* d, const Obj* obj2 = nullptr, - bool pinpoint_only = false) const; + void DoMsg(zeek::ODesc* d, const char s1[], const Obj* obj2 = nullptr, + bool pinpoint_only = false, const detail::Location* expr_location = nullptr) const; + void PinPoint(zeek::ODesc* d, const Obj* obj2 = nullptr, + bool pinpoint_only = false) const; friend inline void Ref(Obj* o); friend inline void Unref(Obj* o); diff --git a/src/Reassem.cc b/src/Reassem.cc index 658c6fe395..35b9053403 100644 --- a/src/Reassem.cc +++ b/src/Reassem.cc @@ -369,7 +369,7 @@ uint64_t Reassembler::TotalSize() const return block_list.DataSize() + old_block_list.DataSize(); } -void Reassembler::Describe(ODesc* d) const +void Reassembler::Describe(zeek::ODesc* d) const { d->Add("reassembler"); } @@ -384,4 +384,3 @@ uint64_t Reassembler::MemoryAllocation(ReassemblerType rtype) { return Reassembler::sizes[rtype]; } - diff --git a/src/Reassem.h b/src/Reassem.h index 3ca1bfc414..d46cbc7679 100644 --- a/src/Reassem.h +++ b/src/Reassem.h @@ -279,7 +279,7 @@ public: uint64_t TotalSize() const; // number of bytes buffered up - void Describe(ODesc* d) const override; + void Describe(zeek::ODesc* d) const override; // Sum over all data buffered in some reassembler. static uint64_t TotalMemoryAllocation() { return total_size; } diff --git a/src/Timer.h b/src/Timer.h index 2eeb38e7f6..02be6f379d 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -7,7 +7,7 @@ #include -class ODesc; +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); namespace zeek::detail { diff --git a/src/Trigger.h b/src/Trigger.h index 549341440a..19ead2909e 100644 --- a/src/Trigger.h +++ b/src/Trigger.h @@ -10,8 +10,7 @@ #include "util.h" #include "IntrusivePtr.h" -class ODesc; - +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); diff --git a/src/analyzer/protocol/arp/ARP.cc b/src/analyzer/protocol/arp/ARP.cc index 181c0fd7b1..9f0c9be579 100644 --- a/src/analyzer/protocol/arp/ARP.cc +++ b/src/analyzer/protocol/arp/ARP.cc @@ -180,7 +180,7 @@ void ARP_Analyzer::NextPacket(double t, const zeek::Packet* pkt) } } -void ARP_Analyzer::Describe(ODesc* d) const +void ARP_Analyzer::Describe(zeek::ODesc* d) const { d->Add(""); d->NL(); diff --git a/src/analyzer/protocol/arp/ARP.h b/src/analyzer/protocol/arp/ARP.h index 37f8d01f30..3f85f69d30 100644 --- a/src/analyzer/protocol/arp/ARP.h +++ b/src/analyzer/protocol/arp/ARP.h @@ -39,7 +39,7 @@ public: void NextPacket(double t, const zeek::Packet* pkt); - void Describe(ODesc* d) const override; + void Describe(zeek::ODesc* d) const override; void RREvent(zeek::EventHandlerPtr e, const u_char* src, const u_char* dst, const char* spa, const char* sha, const char* tpa, const char* tha); diff --git a/src/analyzer/protocol/icmp/ICMP.cc b/src/analyzer/protocol/icmp/ICMP.cc index b37f3712f6..c1527c90b6 100644 --- a/src/analyzer/protocol/icmp/ICMP.cc +++ b/src/analyzer/protocol/icmp/ICMP.cc @@ -452,7 +452,7 @@ bool ICMP_Analyzer::IsReuse(double /* t */, const u_char* /* pkt */) return false; } -void ICMP_Analyzer::Describe(ODesc* d) const +void ICMP_Analyzer::Describe(zeek::ODesc* d) const { d->Add(Conn()->StartTime()); d->Add("("); diff --git a/src/analyzer/protocol/icmp/ICMP.h b/src/analyzer/protocol/icmp/ICMP.h index 96a5a43bc7..327b5ace75 100644 --- a/src/analyzer/protocol/icmp/ICMP.h +++ b/src/analyzer/protocol/icmp/ICMP.h @@ -52,7 +52,7 @@ protected: void RouterSolicit(double t, const struct icmp* icmpp, int len, int caplen, const u_char*& data, const zeek::IP_Hdr* ip_hdr); - void Describe(ODesc* d) const; + void Describe(zeek::ODesc* d) const; zeek::RecordValPtr BuildICMPVal(const struct icmp* icmpp, int len, int icmpv6, const zeek::IP_Hdr* ip_hdr); diff --git a/src/analyzer/protocol/krb/krb-padata.pac b/src/analyzer/protocol/krb/krb-padata.pac index 78f811638a..15f1c185a1 100644 --- a/src/analyzer/protocol/krb/krb-padata.pac +++ b/src/analyzer/protocol/krb/krb-padata.pac @@ -62,14 +62,14 @@ zeek::VectorValPtr proc_padata(const KRB_PA_Data_Sequence* data, const BroAnalyz { const bytestring& cert = element->pa_data_element()->pa_pk_as_req()->cert(); - ODesc common; + zeek::ODesc common; common.AddRaw("Analyzer::ANALYZER_KRB"); common.Add(bro_analyzer->Conn()->StartTime()); // Request means is_orig=T common.AddRaw("T", 1); bro_analyzer->Conn()->IDString(&common); - ODesc file_handle; + zeek::ODesc file_handle; file_handle.Add(common.Description()); file_handle.Add(0); @@ -86,14 +86,14 @@ zeek::VectorValPtr proc_padata(const KRB_PA_Data_Sequence* data, const BroAnalyz { const bytestring& cert = element->pa_data_element()->pa_pk_as_rep()->cert(); - ODesc common; + zeek::ODesc common; common.AddRaw("Analyzer::ANALYZER_KRB"); common.Add(bro_analyzer->Conn()->StartTime()); // Response means is_orig=F common.AddRaw("F", 1); bro_analyzer->Conn()->IDString(&common); - ODesc file_handle; + zeek::ODesc file_handle; file_handle.Add(common.Description()); file_handle.Add(1); diff --git a/src/analyzer/protocol/rdp/rdp-analyzer.pac b/src/analyzer/protocol/rdp/rdp-analyzer.pac index db267cd66d..039196a7c4 100644 --- a/src/analyzer/protocol/rdp/rdp-analyzer.pac +++ b/src/analyzer/protocol/rdp/rdp-analyzer.pac @@ -208,7 +208,7 @@ refine flow RDP_Flow += { %{ const bytestring& cert = ${x509.cert}; - ODesc file_handle; + zeek::ODesc file_handle; file_handle.AddRaw("Analyzer::ANALYZER_RDP"); file_handle.Add(connection()->bro_analyzer()->Conn()->StartTime()); connection()->bro_analyzer()->Conn()->IDString(&file_handle); diff --git a/src/analyzer/protocol/ssl/proc-certificate.pac b/src/analyzer/protocol/ssl/proc-certificate.pac index 2a99c124b6..fd725ee4dc 100644 --- a/src/analyzer/protocol/ssl/proc-certificate.pac +++ b/src/analyzer/protocol/ssl/proc-certificate.pac @@ -3,7 +3,7 @@ if ( certificates->size() == 0 ) return true; - ODesc common; + zeek::ODesc common; common.AddRaw("Analyzer::ANALYZER_SSL"); common.Add(bro_analyzer()->Conn()->StartTime()); common.AddRaw(is_orig ? "T" : "F", 1); @@ -22,7 +22,7 @@ continue; } - ODesc file_handle; + zeek::ODesc file_handle; file_handle.Add(common.Description()); file_handle.Add(i); diff --git a/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac b/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac index 2106e3bcc2..9194994709 100644 --- a/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac +++ b/src/analyzer/protocol/ssl/tls-handshake-analyzer.pac @@ -295,7 +295,7 @@ refine connection Handshake_Conn += { function proc_certificate_status(rec : HandshakeRecord, status_type: uint8, response: bytestring) : bool %{ - ODesc common; + zeek::ODesc common; common.AddRaw("Analyzer::ANALYZER_SSL"); common.Add(bro_analyzer()->Conn()->StartTime()); common.AddRaw("F"); @@ -303,7 +303,7 @@ refine connection Handshake_Conn += { if ( status_type == 1 && response.length() > 0 ) // ocsp { - ODesc file_handle; + zeek::ODesc file_handle; file_handle.Add(common.Description()); file_handle.Add("ocsp"); diff --git a/src/broker/Data.cc b/src/broker/Data.cc index ffa101e7da..997da46a8b 100644 --- a/src/broker/Data.cc +++ b/src/broker/Data.cc @@ -1130,7 +1130,7 @@ broker::data& bro_broker::opaque_field_to_data(zeek::RecordVal* v, zeek::detail: return static_cast(d.get())->data; } -void bro_broker::DataVal::ValDescribe(ODesc* d) const +void bro_broker::DataVal::ValDescribe(zeek::ODesc* d) const { d->Add("broker::data{"); d->Add(broker::to_string(data)); diff --git a/src/broker/Data.h b/src/broker/Data.h index ef6571ee97..cbd136d35e 100644 --- a/src/broker/Data.h +++ b/src/broker/Data.h @@ -5,7 +5,7 @@ #include "Frame.h" #include "Expr.h" -class ODesc; +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); namespace threading { struct Value; @@ -104,7 +104,7 @@ public: : OpaqueVal(bro_broker::opaque_of_data_type), data(std::move(arg_data)) {} - void ValDescribe(ODesc* d) const override; + void ValDescribe(zeek::ODesc* d) const override; zeek::ValPtr castTo(zeek::Type* t); bool canCastTo(zeek::Type* t) const; diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index 3b16052485..358028d82c 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -1276,7 +1276,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc) if ( ! log_mgr->CreateWriterForRemoteLog(stream_id->AsEnumVal(), writer_id->AsEnumVal(), writer_info.release(), num_fields, fields) ) { - ODesc d; + zeek::ODesc d; stream_id->Describe(&d); zeek::reporter->Warning("failed to create remote log stream for %s locally", d.Description()); } diff --git a/src/broker/Store.cc b/src/broker/Store.cc index f2cbaf71f6..90a18c3c0d 100644 --- a/src/broker/Store.cc +++ b/src/broker/Store.cc @@ -24,7 +24,7 @@ zeek::EnumValPtr query_status(bool success) return rval; } -void StoreHandleVal::ValDescribe(ODesc* d) const +void StoreHandleVal::ValDescribe(zeek::ODesc* d) const { //using BifEnum::Broker::BackendType; d->Add("broker::store::"); diff --git a/src/broker/Store.h b/src/broker/Store.h index f699c4abba..fb98627080 100644 --- a/src/broker/Store.h +++ b/src/broker/Store.h @@ -117,7 +117,7 @@ public: : zeek::OpaqueVal(bro_broker::opaque_of_store_handle), store{s}, proxy{store}, store_pid{store.frontend_id()} { } - void ValDescribe(ODesc* d) const override; + void ValDescribe(zeek::ODesc* d) const override; broker::store store; broker::store::proxy proxy; diff --git a/src/file_analysis/Component.cc b/src/file_analysis/Component.cc index 1372a8eedf..eb26589760 100644 --- a/src/file_analysis/Component.cc +++ b/src/file_analysis/Component.cc @@ -34,7 +34,7 @@ Component::~Component() { } -void Component::DoDescribe(ODesc* d) const +void Component::DoDescribe(zeek::ODesc* d) const { if ( factory ) { diff --git a/src/file_analysis/Component.h b/src/file_analysis/Component.h index 07621ce5b2..769ea4e34f 100644 --- a/src/file_analysis/Component.h +++ b/src/file_analysis/Component.h @@ -80,7 +80,7 @@ protected: /** * Overriden from plugin::Component. */ - void DoDescribe(ODesc* d) const override; + void DoDescribe(zeek::ODesc* d) const override; private: friend class file_analysis::Manager; diff --git a/src/input/Component.cc b/src/input/Component.cc index db6a127b2f..1a227bd033 100644 --- a/src/input/Component.cc +++ b/src/input/Component.cc @@ -24,7 +24,7 @@ Component::~Component() { } -void Component::DoDescribe(ODesc* d) const +void Component::DoDescribe(zeek::ODesc* d) const { d->Add("Input::READER_"); d->Add(CanonicalName()); diff --git a/src/input/Component.h b/src/input/Component.h index b9aaa8ec76..39e904d9ef 100644 --- a/src/input/Component.h +++ b/src/input/Component.h @@ -54,7 +54,7 @@ protected: /** * Overriden from plugin::Component. */ - void DoDescribe(ODesc* d) const override; + void DoDescribe(zeek::ODesc* d) const override; private: factory_callback factory; diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 337eefcc1e..3ebdea6b8c 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -364,8 +364,8 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) { if ( ! same_type(args[i + 2], fields->GetFieldType(i) ) ) { - ODesc desc1; - ODesc desc2; + zeek::ODesc desc1; + zeek::ODesc desc2; args[i + 2]->Describe(&desc1); fields->GetFieldType(i)->Describe(&desc2); @@ -390,8 +390,8 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval) if ( ! same_type(args[2], fields ) ) { - ODesc desc1; - ODesc desc2; + zeek::ODesc desc1; + zeek::ODesc desc2; args[2]->Describe(&desc1); fields->Describe(&desc2); zeek::reporter->Error("Input stream %s: Incompatible type '%s':%s for event, which needs type '%s':%s\n", @@ -495,8 +495,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( ! same_type(idx->GetFieldType(j), tl[j]) ) { - ODesc desc1; - ODesc desc2; + zeek::ODesc desc1; + zeek::ODesc desc2; idx->GetFieldType(j)->Describe(&desc1); tl[j]->Describe(&desc2); @@ -535,8 +535,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( ! same_type(table_yield, compare_type) ) { - ODesc desc1; - ODesc desc2; + zeek::ODesc desc1; + zeek::ODesc desc2; compare_type->Describe(&desc1); table_yield->Describe(&desc2); zeek::reporter->Error("Input stream %s: Table type does not match value type. Need type '%s', got '%s'", @@ -596,8 +596,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) if ( ! same_type(args[2], idx) ) { - ODesc desc1; - ODesc desc2; + zeek::ODesc desc1; + zeek::ODesc desc2; idx->Describe(&desc1); args[2]->Describe(&desc2); zeek::reporter->Error("Input stream %s: Table event's index attributes do not match. Need '%s', got '%s'", @@ -610,8 +610,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) { if ( want_record->InternalInt() == 1 && val && ! same_type(args[3], val) ) { - ODesc desc1; - ODesc desc2; + zeek::ODesc desc1; + zeek::ODesc desc2; val->Describe(&desc1); args[3]->Describe(&desc2); zeek::reporter->Error("Input stream %s: Table event's value attributes do not match. Need '%s', got '%s'", @@ -621,8 +621,8 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval) else if ( want_record->InternalInt() == 0 && val && !same_type(args[3], val->GetFieldType(0) ) ) { - ODesc desc1; - ODesc desc2; + zeek::ODesc desc1; + zeek::ODesc desc2; val->GetFieldType(0)->Describe(&desc1); args[3]->Describe(&desc2); zeek::reporter->Error("Input stream %s: Table event's value attribute does not match. Need '%s', got '%s'", diff --git a/src/iosource/Component.cc b/src/iosource/Component.cc index efcf13a4bc..b7ad278e68 100644 --- a/src/iosource/Component.cc +++ b/src/iosource/Component.cc @@ -65,7 +65,7 @@ PktSrcComponent::factory_callback PktSrcComponent::Factory() const return factory; } -void PktSrcComponent::DoDescribe(ODesc* d) const +void PktSrcComponent::DoDescribe(zeek::ODesc* d) const { iosource::Component::DoDescribe(d); @@ -140,7 +140,7 @@ bool PktDumperComponent::HandlesPrefix(const std::string& prefix) const return false; } -void PktDumperComponent::DoDescribe(ODesc* d) const +void PktDumperComponent::DoDescribe(zeek::ODesc* d) const { zeek::plugin::Component::DoDescribe(d); diff --git a/src/iosource/Component.h b/src/iosource/Component.h index d9e887ae3a..0916709b28 100644 --- a/src/iosource/Component.h +++ b/src/iosource/Component.h @@ -113,7 +113,7 @@ public: * Generates a human-readable description of the component. This goes * into the output of \c "bro -NN". */ - void DoDescribe(ODesc* d) const override; + void DoDescribe(zeek::ODesc* d) const override; private: std::vector prefixes; @@ -160,7 +160,7 @@ public: * Generates a human-readable description of the component. This goes * into the output of \c "bro -NN". */ - void DoDescribe(ODesc* d) const override; + void DoDescribe(zeek::ODesc* d) const override; private: std::vector prefixes; diff --git a/src/iosource/Packet.h b/src/iosource/Packet.h index 7a8cc73ecf..f0c30f9b08 100644 --- a/src/iosource/Packet.h +++ b/src/iosource/Packet.h @@ -14,7 +14,7 @@ typedef struct bpf_timeval pkt_timeval; typedef struct timeval pkt_timeval; #endif -class ODesc; +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(RecordVal, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(IP_Hdr, zeek); diff --git a/src/logging/Component.cc b/src/logging/Component.cc index b100ce2583..d3f5807307 100644 --- a/src/logging/Component.cc +++ b/src/logging/Component.cc @@ -23,7 +23,7 @@ Component::~Component() { } -void Component::DoDescribe(ODesc* d) const +void Component::DoDescribe(zeek::ODesc* d) const { d->Add("Log::WRITER_"); d->Add(CanonicalName()); diff --git a/src/logging/Component.h b/src/logging/Component.h index 600f6a8438..8a98f9afa1 100644 --- a/src/logging/Component.h +++ b/src/logging/Component.h @@ -54,7 +54,7 @@ protected: /** * Overriden from plugin::Component. */ - void DoDescribe(ODesc* d) const override; + void DoDescribe(zeek::ODesc* d) const override; private: factory_callback factory; diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index de3b14b605..9a4cb4b20a 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -638,7 +638,7 @@ bool Manager::AddFilter(zeek::EnumVal* id, zeek::RecordVal* fval) stream->filters.push_back(filter); #ifdef DEBUG - ODesc desc; + zeek::ODesc desc; writer->Describe(&desc); DBG_LOG(zeek::DBG_LOGGING, "Created new filter '%s' for stream '%s'", @@ -1002,7 +1002,7 @@ threading::Value* Manager::ValToLogVal(zeek::Val* val, zeek::Type* ty) case zeek::TYPE_FUNC: { - ODesc d; + zeek::ODesc d; const zeek::Func* f = val->AsFunc(); f->Describe(&d); const char* s = d.Description(); @@ -1252,7 +1252,7 @@ bool Manager::WriteFromRemote(zeek::EnumVal* id, zeek::EnumVal* writer, const st { // Don't know this stream. #ifdef DEBUG - ODesc desc; + zeek::ODesc desc; id->Describe(&desc); DBG_LOG(zeek::DBG_LOGGING, "unknown stream %s in Manager::Write()", desc.Description()); @@ -1274,7 +1274,7 @@ bool Manager::WriteFromRemote(zeek::EnumVal* id, zeek::EnumVal* writer, const st { // Don't know this writer. #ifdef DEBUG - ODesc desc; + zeek::ODesc desc; id->Describe(&desc); DBG_LOG(zeek::DBG_LOGGING, "unknown writer %s in Manager::Write()", desc.Description()); diff --git a/src/logging/writers/ascii/Ascii.cc b/src/logging/writers/ascii/Ascii.cc index bd38d3e520..6a3256daba 100644 --- a/src/logging/writers/ascii/Ascii.cc +++ b/src/logging/writers/ascii/Ascii.cc @@ -240,7 +240,7 @@ void Ascii::InitConfigOptions() zeek::BifConst::LogAscii::meta_prefix->Len() ); - ODesc tsfmt; + zeek::ODesc tsfmt; zeek::BifConst::LogAscii::json_timestamps->Describe(&tsfmt); json_timestamps.assign( (const char*) tsfmt.Bytes(), diff --git a/src/logging/writers/ascii/Ascii.h b/src/logging/writers/ascii/Ascii.h index ada5463533..5f3ba6663b 100644 --- a/src/logging/writers/ascii/Ascii.h +++ b/src/logging/writers/ascii/Ascii.h @@ -55,7 +55,7 @@ private: int fd; gzFile gzfile; std::string fname; - ODesc desc; + zeek::ODesc desc; bool ascii_done; // Options set from the script-level. diff --git a/src/logging/writers/sqlite/SQLite.cc b/src/logging/writers/sqlite/SQLite.cc index c1fa94e4c7..092cb77e11 100644 --- a/src/logging/writers/sqlite/SQLite.cc +++ b/src/logging/writers/sqlite/SQLite.cc @@ -286,7 +286,7 @@ int SQLite::AddParams(Value* val, int pos) case zeek::TYPE_TABLE: { - ODesc desc; + zeek::ODesc desc; desc.Clear(); desc.EnableEscaping(); desc.AddEscapeSequence(set_separator); @@ -308,7 +308,7 @@ int SQLite::AddParams(Value* val, int pos) case zeek::TYPE_VECTOR: { - ODesc desc; + zeek::ODesc desc; desc.Clear(); desc.EnableEscaping(); desc.AddEscapeSequence(set_separator); diff --git a/src/parse.y b/src/parse.y index 099e923140..0eeba01ca8 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1400,7 +1400,7 @@ attr: zeek::make_intrusive(zeek::IntrusivePtr{zeek::AdoptRef{}, $3})); else { - ODesc d; + zeek::ODesc d; $3->Describe(&d); Unref($3); zeek::reporter->Error("'&deprecated=%s' must use a string literal", @@ -1895,7 +1895,7 @@ opt_deprecated: $$ = new zeek::detail::ConstExpr({zeek::AdoptRef{}, $3}); else { - ODesc d; + zeek::ODesc d; $3->Describe(&d); zeek::reporter->Error("'&deprecated=%s' must use a string literal", d.Description()); diff --git a/src/plugin/Component.cc b/src/plugin/Component.cc index caccfb0ba1..7a7ef38f5e 100644 --- a/src/plugin/Component.cc +++ b/src/plugin/Component.cc @@ -28,7 +28,7 @@ component::Type Component::Type() const return type; } -void Component::Describe(ODesc* d) const +void Component::Describe(zeek::ODesc* d) const { d->Add(" "); d->Add("["); diff --git a/src/plugin/Component.h b/src/plugin/Component.h index fe9c3ba2c3..695be4bbda 100644 --- a/src/plugin/Component.h +++ b/src/plugin/Component.h @@ -2,9 +2,10 @@ #pragma once +#include "zeek-config.h" #include -class ODesc; +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); namespace zeek::plugin { @@ -82,7 +83,7 @@ public: * * @param d The description object to use. */ - void Describe(ODesc* d) const; + void Describe(zeek::ODesc* d) const; protected: /** @@ -92,7 +93,7 @@ protected: * * @param d The description object to use. */ - virtual void DoDescribe(ODesc* d) const { } + virtual void DoDescribe(zeek::ODesc* d) const { } private: // Disable. diff --git a/src/plugin/Plugin.cc b/src/plugin/Plugin.cc index c79a38bac8..30dafeb078 100644 --- a/src/plugin/Plugin.cc +++ b/src/plugin/Plugin.cc @@ -69,7 +69,7 @@ BifItem::~BifItem() { } -void HookArgument::Describe(ODesc* d) const +void HookArgument::Describe(zeek::ODesc* d) const { switch ( type ) { case BOOL: @@ -462,7 +462,7 @@ void Plugin::InitializeComponents() (*i)->Initialize(); } -void Plugin::Describe(ODesc* d) const +void Plugin::Describe(zeek::ODesc* d) const { d->Add(config.name); diff --git a/src/plugin/Plugin.h b/src/plugin/Plugin.h index f49cd6534d..84d1d276b8 100644 --- a/src/plugin/Plugin.h +++ b/src/plugin/Plugin.h @@ -16,8 +16,7 @@ #define BRO_PLUGIN_BRO_VERSION BRO_VERSION_FUNCTION -class ODesc; - +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Event, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail); @@ -360,7 +359,7 @@ public: * * @param d Description object to use for rendering. */ - void Describe(ODesc* d) const; + void Describe(zeek::ODesc* d) const; private: Type type; @@ -491,7 +490,7 @@ public: * is disabled, the rendering will include a list of all components * and BiF items. */ - void Describe(ODesc* d) const; + void Describe(zeek::ODesc* d) const; /** * Registers an individual BiF that the plugin defines. The diff --git a/src/threading/Formatter.h b/src/threading/Formatter.h index e31cf56f4b..dc834ccd81 100644 --- a/src/threading/Formatter.h +++ b/src/threading/Formatter.h @@ -51,8 +51,8 @@ public: * @return Returns true on success, false on error. Errors must also * be flagged via the thread. */ - virtual bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields, - threading::Value** vals) const = 0; + virtual bool Describe(zeek::ODesc* desc, int num_fields, const threading::Field* const * fields, + threading::Value** vals) const = 0; /** * Convert a single threading value into an implementation-specific @@ -67,7 +67,7 @@ public: * @return Returns true on success, false on error. Errors are also * flagged via the thread. */ - virtual bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const = 0; + virtual bool Describe(zeek::ODesc* desc, threading::Value* val, const std::string& name = "") const = 0; /** * Convert an implementation-specific textual representation of a diff --git a/src/threading/formatters/Ascii.cc b/src/threading/formatters/Ascii.cc index 5e84bc67ac..eb234b05fe 100644 --- a/src/threading/formatters/Ascii.cc +++ b/src/threading/formatters/Ascii.cc @@ -15,7 +15,7 @@ using namespace threading::formatter; // If the value we'd write out would match exactly the a reserved string, we // escape the first character so that the output won't be ambigious. If this // function returns true, it has added an escaped version of data to desc. -static inline bool escapeReservedContent(ODesc* desc, const string& reserved, const char* data, int size) +static inline bool escapeReservedContent(zeek::ODesc* desc, const string& reserved, const char* data, int size) { if ( size != (int)reserved.size() || memcmp(data, reserved.data(), size) != 0 ) return false; @@ -56,7 +56,7 @@ Ascii::~Ascii() { } -bool Ascii::Describe(ODesc* desc, int num_fields, const threading::Field* const * fields, +bool Ascii::Describe(zeek::ODesc* desc, int num_fields, const threading::Field* const * fields, threading::Value** vals) const { for ( int i = 0; i < num_fields; i++ ) @@ -71,7 +71,7 @@ bool Ascii::Describe(ODesc* desc, int num_fields, const threading::Field* const return true; } -bool Ascii::Describe(ODesc* desc, threading::Value* val, const string& name) const +bool Ascii::Describe(zeek::ODesc* desc, threading::Value* val, const string& name) const { if ( ! val->present ) { diff --git a/src/threading/formatters/Ascii.h b/src/threading/formatters/Ascii.h index aeaaef279f..b010e29b90 100644 --- a/src/threading/formatters/Ascii.h +++ b/src/threading/formatters/Ascii.h @@ -47,8 +47,8 @@ public: Ascii(threading::MsgThread* t, const SeparatorInfo& info); virtual ~Ascii(); - virtual bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const; - virtual bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields, + virtual bool Describe(zeek::ODesc* desc, threading::Value* val, const std::string& name = "") const; + virtual bool Describe(zeek::ODesc* desc, int num_fields, const threading::Field* const * fields, threading::Value** vals) const; virtual threading::Value* ParseValue(const std::string& s, const std::string& name, zeek::TypeTag type, zeek::TypeTag subtype = zeek::TYPE_ERROR) const; diff --git a/src/threading/formatters/JSON.cc b/src/threading/formatters/JSON.cc index f7ee529829..77677d828f 100644 --- a/src/threading/formatters/JSON.cc +++ b/src/threading/formatters/JSON.cc @@ -35,7 +35,7 @@ JSON::~JSON() { } -bool JSON::Describe(ODesc* desc, int num_fields, const Field* const * fields, +bool JSON::Describe(zeek::ODesc* desc, int num_fields, const Field* const * fields, Value** vals) const { rapidjson::StringBuffer buffer; @@ -55,7 +55,7 @@ bool JSON::Describe(ODesc* desc, int num_fields, const Field* const * fields, return true; } -bool JSON::Describe(ODesc* desc, Value* val, const std::string& name) const +bool JSON::Describe(zeek::ODesc* desc, Value* val, const std::string& name) const { if ( desc->IsBinary() ) { diff --git a/src/threading/formatters/JSON.h b/src/threading/formatters/JSON.h index 66ab88c39e..a02d8367c6 100644 --- a/src/threading/formatters/JSON.h +++ b/src/threading/formatters/JSON.h @@ -25,10 +25,11 @@ public: JSON(threading::MsgThread* t, TimeFormat tf); ~JSON() override; - bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const override; - bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields, - threading::Value** vals) const override; - threading::Value* ParseValue(const std::string& s, const std::string& name, zeek::TypeTag type, zeek::TypeTag subtype = zeek::TYPE_ERROR) const override; + bool Describe(zeek::ODesc* desc, threading::Value* val, const std::string& name = "") const override; + bool Describe(zeek::ODesc* desc, int num_fields, const threading::Field* const * fields, + threading::Value** vals) const override; + threading::Value* ParseValue(const std::string& s, const std::string& name, zeek::TypeTag type, + zeek::TypeTag subtype = zeek::TYPE_ERROR) const override; class NullDoubleWriter : public rapidjson::Writer { public: diff --git a/src/util.cc b/src/util.cc index 3fafe41d66..7ddcd6b833 100644 --- a/src/util.cc +++ b/src/util.cc @@ -210,14 +210,14 @@ TEST_CASE("util get_escaped_string") { SUBCASE("returned ODesc") { - ODesc* d = get_escaped_string(nullptr, "a bcd\n", 6, false); + zeek::ODesc* d = get_escaped_string(nullptr, "a bcd\n", 6, false); CHECK(strcmp(d->Description(), "a\\x20bcd\\x0a") == 0); delete d; } SUBCASE("provided ODesc") { - ODesc d2; + zeek::ODesc d2; get_escaped_string(&d2, "ab\\e", 4, true); CHECK(strcmp(d2.Description(), "\\x61\\x62\\\\\\x65") == 0); } @@ -244,11 +244,11 @@ TEST_CASE("util get_escaped_string") * ASCII. * @return A ODesc object containing a list of escaped hex values of the form * \x##, which may be newly allocated if \a d was a null pointer. */ -ODesc* get_escaped_string(ODesc* d, const char* str, size_t len, - bool escape_all) +zeek::ODesc* get_escaped_string(zeek::ODesc* d, const char* str, size_t len, + bool escape_all) { if ( ! d ) - d = new ODesc(); + d = new zeek::ODesc(); for ( size_t i = 0; i < len; ++i ) { @@ -275,7 +275,7 @@ ODesc* get_escaped_string(ODesc* d, const char* str, size_t len, std::string get_escaped_string(const char* str, size_t len, bool escape_all) { - ODesc d; + zeek::ODesc d; return get_escaped_string(&d, str, len, escape_all)->Description(); } diff --git a/src/util.h b/src/util.h index 97c6041c28..5d18591ef0 100644 --- a/src/util.h +++ b/src/util.h @@ -125,10 +125,10 @@ inline void bytetohex(unsigned char byte, char* hex_out) std::string get_unescaped_string(const std::string& str); -class ODesc; +ZEEK_FORWARD_DECLARE_NAMESPACED(ODesc, zeek); -ODesc* get_escaped_string(ODesc* d, const char* str, size_t len, - bool escape_all); +zeek::ODesc* get_escaped_string(zeek::ODesc* d, const char* str, size_t len, + bool escape_all); std::string get_escaped_string(const char* str, size_t len, bool escape_all); inline std::string get_escaped_string(const std::string& str, bool escape_all) diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 61f772c17a..11c9f05c98 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -183,7 +183,7 @@ bool show_plugins(int level) return false; } - ODesc d; + zeek::ODesc d; if ( level == 1 ) d.SetShort(); @@ -785,7 +785,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, if ( ! id ) zeek::reporter->FatalError("No such ID: %s\n", options.identifier_to_print->data()); - ODesc desc; + zeek::ODesc desc; desc.SetQuotes(true); desc.SetIncludeStats(true); id->DescribeExtended(&desc); diff --git a/src/zeek.bif b/src/zeek.bif index 9901f6f378..0b804e3271 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -66,7 +66,7 @@ static int check_fmt_type(zeek::TypeTag t, zeek::TypeTag ok[]) return 0; } -static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d) +static void do_fmt(const char*& fmt, zeek::Val* v, zeek::ODesc* d) { zeek::TypeTag t = v->GetType()->Tag(); zeek::InternalTypeTag it = v->GetType()->InternalType(); @@ -126,8 +126,8 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d) char fmt_buf[512]; char out_buf[512]; - ODesc s; - s.SetStyle(RAW_STYLE); + zeek::ODesc s; + s.SetStyle(zeek::RAW_STYLE); if ( precision >= 0 && *fmt != 'e' && *fmt != 'f' && *fmt != 'g' ) zeek::emit_builtin_error("precision specified for non-floating point"); @@ -268,7 +268,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d) ++fmt; } -static int next_fmt(const char*& fmt, const zeek::Args* args, ODesc* d, int& n) +static int next_fmt(const char*& fmt, const zeek::Args* args, zeek::ODesc* d, int& n) { const char* fp = fmt; @@ -872,7 +872,7 @@ function paraglob_equals%(p_one: opaque of paraglob, p_two: opaque of paraglob%) ## .. zeek:see:: hrw_weight function fnv1a32%(input: any%): count %{ - ODesc desc(DESC_BINARY); + zeek::ODesc desc(DESC_BINARY); input->Describe(&desc); auto bytes = desc.Bytes(); @@ -1561,7 +1561,7 @@ function order%(v: any, ...%) : index_vec ## Returns: A string concatentation of all arguments. function cat%(...%): string %{ - ODesc d; + zeek::ODesc d; d.SetStyle(RAW_STYLE); for ( const auto& a : @ARG@ ) @@ -1588,7 +1588,7 @@ function cat%(...%): string ## .. zeek:see:: cat string_cat function cat_sep%(sep: string, def: string, ...%): string %{ - ODesc d; + zeek::ODesc d; d.SetStyle(RAW_STYLE); int pre_size = 0; @@ -1664,7 +1664,7 @@ function fmt%(...%): string // checks that. const char* fmt = fmt_v->AsString()->CheckString(); - ODesc d; + zeek::ODesc d; d.SetStyle(RAW_STYLE); int n = 0; @@ -1699,7 +1699,7 @@ function fmt%(...%): string ## .. zeek:see:: fmt cat cat_sep string_cat to_json function print_raw%(...%): bool %{ - ODesc d(DESC_READABLE); + zeek::ODesc d(DESC_READABLE); d.SetStyle(RAW_STYLE); describe_vals(@ARG@, &d, 0); printf("%.*s", d.Len(), d.Description()); @@ -1840,7 +1840,7 @@ function record_type_to_vector%(rt: string%): string_vec ## Returns: The type name of *t*. function type_name%(t: any%): string %{ - ODesc d; + zeek::ODesc d; t->GetType()->Describe(&d); String* s = new String(1, d.TakeBytes(), d.Len()); diff --git a/src/zeekygen/IdentifierInfo.cc b/src/zeekygen/IdentifierInfo.cc index 46ee45dbe3..114068f8e8 100644 --- a/src/zeekygen/IdentifierInfo.cc +++ b/src/zeekygen/IdentifierInfo.cc @@ -100,7 +100,7 @@ string IdentifierInfo::GetDeclaringScriptForField(const string& field) const string IdentifierInfo::DoReStructuredText(bool roles_only) const { - ODesc d; + zeek::ODesc d; d.SetIndentSpaces(3); d.SetQuotes(true); id->DescribeReST(&d, roles_only); diff --git a/src/zeekygen/ScriptInfo.cc b/src/zeekygen/ScriptInfo.cc index 166e0607f1..b12f5b769a 100644 --- a/src/zeekygen/ScriptInfo.cc +++ b/src/zeekygen/ScriptInfo.cc @@ -46,7 +46,7 @@ static vector summary_comment(const vector& cmnts) return rval; } -static void add_summary_rows(const ODesc& id_desc, const vector& cmnts, +static void add_summary_rows(const zeek::ODesc& id_desc, const vector& cmnts, ReStructuredTextTable* table) { vector row; @@ -83,7 +83,7 @@ static string make_summary(const string& heading, char underline, char border, it != id_list.end(); ++it ) { auto* id = (*it)->GetID(); - ODesc d; + zeek::ODesc d; d.SetQuotes(true); id->DescribeReSTShort(&d); add_summary_rows(d, summary_comment((*it)->GetComments()), &table); @@ -106,7 +106,7 @@ static string make_redef_summary(const string& heading, char underline, ++it ) { auto* id = (*it)->GetID(); - ODesc d; + zeek::ODesc d; d.SetQuotes(true); id->DescribeReSTShort(&d);