diff --git a/auxil/bifcl b/auxil/bifcl index ddcb00d15c..462ac3bd3a 160000 --- a/auxil/bifcl +++ b/auxil/bifcl @@ -1 +1 @@ -Subproject commit ddcb00d15cab84f1b1d0e82dffa764f278e0c69c +Subproject commit 462ac3bd3a7ae0d30378e36ca2fe771c53a0a23e diff --git a/src/Desc.cc b/src/Desc.cc index 32682ef736..aab5913cd1 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -16,7 +16,7 @@ #define DEFAULT_SIZE 128 #define SLOP 10 -ODesc::ODesc(desc_type t, BroFile* arg_f) +ODesc::ODesc(desc_type t, zeek::File* arg_f) { type = t; style = STANDARD_STYLE; diff --git a/src/Desc.h b/src/Desc.h index 10c09980a3..95d34d1928 100644 --- a/src/Desc.h +++ b/src/Desc.h @@ -22,7 +22,8 @@ typedef enum { RAW_STYLE, } desc_style; -class BroFile; +namespace zeek { class File; } +using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File; ZEEK_FORWARD_DECLARE_NAMESPACED(IPAddr, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(IPPrefix, zeek); @@ -32,7 +33,7 @@ using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek:: class ODesc { public: - explicit ODesc(desc_type t=DESC_READABLE, BroFile* f=nullptr); + explicit ODesc(desc_type t=DESC_READABLE, zeek::File* f=nullptr); ~ODesc(); @@ -201,7 +202,7 @@ protected: using escape_set = std::set; escape_set escape_sequences; // additional sequences of chars to escape - BroFile* f; // or the file we're using. + zeek::File* f; // or the file we're using. int indent_level; bool do_flush; diff --git a/src/File.cc b/src/File.cc index e5c3727373..aa7c54d818 100644 --- a/src/File.cc +++ b/src/File.cc @@ -31,7 +31,9 @@ #include "Desc.h" #include "Var.h" -std::list> BroFile::open_files; +namespace zeek { + +std::list> File::open_files; // Maximizes the number of open file descriptors. static void maximize_num_fds() @@ -53,7 +55,7 @@ static void maximize_num_fds() zeek::reporter->FatalError("maximize_num_fds(): setrlimit failed"); } -BroFile::BroFile(FILE* arg_f) +File::File(FILE* arg_f) { Init(); f = arg_f; @@ -62,7 +64,7 @@ BroFile::BroFile(FILE* arg_f) is_open = (f != nullptr); } -BroFile::BroFile(FILE* arg_f, const char* arg_name, const char* arg_access) +File::File(FILE* arg_f, const char* arg_name, const char* arg_access) { Init(); f = arg_f; @@ -72,7 +74,7 @@ BroFile::BroFile(FILE* arg_f, const char* arg_name, const char* arg_access) is_open = (f != nullptr); } -BroFile::BroFile(const char* arg_name, const char* arg_access) +File::File(const char* arg_name, const char* arg_access) { Init(); f = nullptr; @@ -97,7 +99,7 @@ BroFile::BroFile(const char* arg_name, const char* arg_access) } } -const char* BroFile::Name() const +const char* File::Name() const { if ( name ) return name; @@ -114,7 +116,7 @@ const char* BroFile::Name() const return nullptr; } -bool BroFile::Open(FILE* file, const char* mode) +bool File::Open(FILE* file, const char* mode) { static bool fds_maximized = false; open_time = network_time ? network_time : current_time(); @@ -152,7 +154,7 @@ bool BroFile::Open(FILE* file, const char* mode) return true; } -BroFile::~BroFile() +File::~File() { Close(); Unref(attrs); @@ -165,7 +167,7 @@ BroFile::~BroFile() #endif } -void BroFile::Init() +void File::Init() { open_time = 0; is_open = false; @@ -178,14 +180,14 @@ void BroFile::Init() #endif } -FILE* BroFile::File() +FILE* File::FileHandle() { return f; } -FILE* BroFile::Seek(long new_position) +FILE* File::Seek(long new_position) { - if ( ! File() ) + if ( ! FileHandle() ) return nullptr; if ( fseek(f, new_position, SEEK_SET) < 0 ) @@ -194,7 +196,7 @@ FILE* BroFile::Seek(long new_position) return f; } -void BroFile::SetBuf(bool arg_buffered) +void File::SetBuf(bool arg_buffered) { if ( ! f ) return; @@ -205,7 +207,7 @@ void BroFile::SetBuf(bool arg_buffered) buffered = arg_buffered; } -bool BroFile::Close() +bool File::Close() { if ( ! is_open ) return true; @@ -227,7 +229,7 @@ bool BroFile::Close() return true; } -void BroFile::Unlink() +void File::Unlink() { for ( auto it = open_files.begin(); it != open_files.end(); ++it) { @@ -239,7 +241,7 @@ void BroFile::Unlink() } } -void BroFile::Describe(ODesc* d) const +void File::Describe(ODesc* d) const { d->AddSP("file"); @@ -257,7 +259,7 @@ void BroFile::Describe(ODesc* d) const d->Add("(no type)"); } -void BroFile::SetAttrs(zeek::detail::Attributes* arg_attrs) +void File::SetAttrs(zeek::detail::Attributes* arg_attrs) { if ( ! arg_attrs ) return; @@ -269,7 +271,7 @@ void BroFile::SetAttrs(zeek::detail::Attributes* arg_attrs) EnableRawOutput(); } -zeek::RecordVal* BroFile::Rotate() +zeek::RecordVal* File::Rotate() { if ( ! is_open ) return nullptr; @@ -299,7 +301,7 @@ zeek::RecordVal* BroFile::Rotate() return info; } -void BroFile::CloseOpenFiles() +void File::CloseOpenFiles() { auto it = open_files.begin(); while ( it != open_files.end() ) @@ -309,7 +311,7 @@ void BroFile::CloseOpenFiles() } } -bool BroFile::Write(const char* data, int len) +bool File::Write(const char* data, int len) { if ( ! is_open ) return false; @@ -323,17 +325,17 @@ bool BroFile::Write(const char* data, int len) return true; } -void BroFile::RaiseOpenEvent() +void File::RaiseOpenEvent() { if ( ! ::file_opened ) return; - BroFilePtr bf{zeek::NewRef{}, this}; + FilePtr bf{zeek::NewRef{}, this}; Event* event = new ::Event(::file_opened, {zeek::make_intrusive(std::move(bf))}); mgr.Dispatch(event, true); } -double BroFile::Size() +double File::Size() { fflush(f); struct stat s; @@ -346,11 +348,13 @@ double BroFile::Size() return s.st_size; } -BroFilePtr BroFile::Get(const char* name) +FilePtr File::Get(const char* name) { for ( const auto &el : open_files ) if ( el.first == name ) return {zeek::NewRef{}, el.second}; - return zeek::make_intrusive(name, "w"); + return zeek::make_intrusive(name, "w"); } + +} // namespace zeek diff --git a/src/File.h b/src/File.h index 486b09d14e..6833414f88 100644 --- a/src/File.h +++ b/src/File.h @@ -16,25 +16,23 @@ #include "IntrusivePtr.h" #include "util.h" -namespace zeek { - class Type; - using TypePtr = zeek::IntrusivePtr; -} -using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type; - ZEEK_FORWARD_DECLARE_NAMESPACED(PrintStmt, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(RecordVal, zeek); -class BroFile; -using BroFilePtr = zeek::IntrusivePtr; +namespace zeek { +class Type; +using TypePtr = zeek::IntrusivePtr; -class BroFile final : public zeek::Obj { +class File; +using FilePtr = zeek::IntrusivePtr; + +class File final : public zeek::Obj { public: - explicit BroFile(FILE* arg_f); - BroFile(FILE* arg_f, const char* filename, const char* access); - BroFile(const char* filename, const char* access); - ~BroFile() override; + explicit File(FILE* arg_f); + File(FILE* arg_f, const char* filename, const char* access); + File(const char* filename, const char* access); + ~File() override; const char* Name() const; @@ -77,9 +75,9 @@ public: static void CloseOpenFiles(); // Get the file with the given name, opening it if it doesn't yet exist. - static BroFilePtr Get(const char* name); - [[deprecated("Remove in v4.1. Use BroFile::Get().")]] - static BroFile* GetFile(const char* name) + static FilePtr Get(const char* name); + [[deprecated("Remove in v4.1. Use File::Get().")]] + static File* GetFile(const char* name) { return Get(name).release(); } void EnableRawOutput() { raw_output = true; } @@ -89,7 +87,7 @@ protected: friend class zeek::detail::PrintStmt; - BroFile() { Init(); } + File() { Init(); } void Init(); /** @@ -105,7 +103,7 @@ protected: // (Protected because we do not want anyone to write directly // to the file, but the PrintStmt friend uses this to check whether // it's really stdout.) - FILE* File(); + FILE* FileHandle(); // Raises a file_opened event. void RaiseOpenEvent(); @@ -123,5 +121,11 @@ protected: static const int MIN_BUFFER_SIZE = 1024; private: - static std::list> open_files; + static std::list> open_files; }; + +} // namespace zeek + +using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type; +using BroFile [[deprecated("Remove in v4.1. Use zeek::File instead.")]] = zeek::File; +using BroFilePtr [[deprecated("Remove in v4.1. Use zeek::FilePtr instead.")]] = zeek::FilePtr; diff --git a/src/Obj.cc b/src/Obj.cc index dfff7a09a5..77358a5b3d 100644 --- a/src/Obj.cc +++ b/src/Obj.cc @@ -195,7 +195,7 @@ void Obj::PinPoint(ODesc* d, const Obj* obj2, bool pinpoint_only) const void Obj::Print() const { - static BroFile fstderr(stderr); + static zeek::File fstderr(stderr); ODesc d(DESC_READABLE, &fstderr); Describe(&d); d.Add("\n"); diff --git a/src/RuleMatcher.cc b/src/RuleMatcher.cc index 3d7ae4f45a..413b8bd8a1 100644 --- a/src/RuleMatcher.cc +++ b/src/RuleMatcher.cc @@ -1229,7 +1229,7 @@ void RuleMatcher::GetStats(Stats* stats, RuleHdrTest* hdr_test) GetStats(stats, h); } -void RuleMatcher::DumpStats(BroFile* f) +void RuleMatcher::DumpStats(zeek::File* f) { Stats stats; GetStats(&stats); @@ -1244,7 +1244,7 @@ void RuleMatcher::DumpStats(BroFile* f) DumpStateStats(f, root); } -void RuleMatcher::DumpStateStats(BroFile* f, RuleHdrTest* hdr_test) +void RuleMatcher::DumpStateStats(zeek::File* f, RuleHdrTest* hdr_test) { if ( ! hdr_test ) return; diff --git a/src/RuleMatcher.h b/src/RuleMatcher.h index ec7d2fb484..1a72ee3f21 100644 --- a/src/RuleMatcher.h +++ b/src/RuleMatcher.h @@ -27,9 +27,10 @@ extern FILE* rules_in; extern int rules_line_number; extern const char* current_rule_file; -class BroFile; class IntSet; +namespace zeek { class File; } +using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File; ZEEK_FORWARD_DECLARE_NAMESPACED(RE_Match_State, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Specific_RE_Matcher, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(RuleMatcher, zeek::detail); @@ -311,7 +312,7 @@ public: const RuleEndpointState* state) const; void GetStats(Stats* stats, RuleHdrTest* hdr_test = nullptr); - void DumpStats(BroFile* f); + void DumpStats(zeek::File* f); private: // Delete node and all children. @@ -354,7 +355,7 @@ private: void PrintTreeDebug(RuleHdrTest* node); - void DumpStateStats(BroFile* f, RuleHdrTest* hdr_test); + void DumpStateStats(zeek::File* f, RuleHdrTest* hdr_test); static bool AllRulePatternsMatched(const Rule* r, MatchPos matchpos, const AcceptingMatchSet& ams); diff --git a/src/Stats.cc b/src/Stats.cc index a7d76cd26e..21df9e1bdf 100644 --- a/src/Stats.cc +++ b/src/Stats.cc @@ -50,7 +50,7 @@ void ProfileTimer::Dispatch(double t, bool is_expire) } -ProfileLogger::ProfileLogger(BroFile* arg_file, double interval) +ProfileLogger::ProfileLogger(zeek::File* arg_file, double interval) : SegmentStatsReporter() { file = arg_file; @@ -408,7 +408,7 @@ void SegmentProfiler::Report() } PacketProfiler::PacketProfiler(unsigned int mode, double freq, - BroFile* arg_file) + zeek::File* arg_file) { update_mode = mode; update_freq = freq; diff --git a/src/Stats.h b/src/Stats.h index b9131d4d10..1c5254b09a 100644 --- a/src/Stats.h +++ b/src/Stats.h @@ -9,7 +9,8 @@ #include #include -class BroFile; +namespace zeek { class File; } +using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File; ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(TableVal, zeek); @@ -70,18 +71,18 @@ protected: class ProfileLogger final : public SegmentStatsReporter { public: - ProfileLogger(BroFile* file, double interval); + ProfileLogger(zeek::File* file, double interval); ~ProfileLogger() override; void Log(); - BroFile* File() { return file; } + zeek::File* File() { return file; } protected: void SegmentProfile(const char* name, const zeek::detail::Location* loc, double dtime, int dmem) override; private: - BroFile* file; + zeek::File* file; unsigned int log_count; }; @@ -120,7 +121,7 @@ extern uint64_t tot_gap_bytes; class PacketProfiler { public: - PacketProfiler(unsigned int mode, double freq, BroFile* arg_file); + PacketProfiler(unsigned int mode, double freq, zeek::File* arg_file); ~PacketProfiler(); static const unsigned int MODE_TIME = 1; @@ -130,7 +131,7 @@ public: void ProfilePkt(double t, unsigned int bytes); protected: - BroFile* file; + zeek::File* file; unsigned int update_mode; double update_freq; double last_Utime, last_Stime, last_Rtime; diff --git a/src/Stmt.cc b/src/Stmt.cc index 3329db256c..9c74c65edc 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -203,7 +203,7 @@ TraversalCode ExprListStmt::Traverse(TraversalCallback* cb) const HANDLE_TC_STMT_POST(tc); } -static BroFile* print_stdout = nullptr; +static zeek::File* print_stdout = nullptr; static EnumValPtr lookup_enum_val(const char* module_name, const char* name) { @@ -244,9 +244,9 @@ ValPtr PrintStmt::DoExec(std::vector vals, RegisterAccess(); if ( ! print_stdout ) - print_stdout = new BroFile(stdout); + print_stdout = new zeek::File(stdout); - BroFile* f = print_stdout; + zeek::File* f = print_stdout; int offset = 0; if ( vals.size() > 0 && (vals)[0]->GetType()->Tag() == TYPE_FILE ) @@ -270,7 +270,7 @@ ValPtr PrintStmt::DoExec(std::vector vals, return nullptr; } case BifEnum::Log::REDIRECT_STDOUT: - if ( f->File() == stdout ) + if ( f->FileHandle() == stdout ) { // Should catch even printing to a "manually opened" stdout file, // like "/dev/stdout" or "-". diff --git a/src/Val.cc b/src/Val.cc index 8ca9d4538f..c9a018919d 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -61,10 +61,10 @@ static const FileTypePtr& GetStringFileType() noexcept return string_file_type; } -Val::Val(BroFile* f) : Val({AdoptRef{}, f}) +Val::Val(zeek::File* f) : Val({AdoptRef{}, f}) {} -Val::Val(BroFilePtr f) +Val::Val(zeek::FilePtr f) : val(f.release()), type(GetStringFileType()) { assert(val.file_val->GetType()->Tag() == TYPE_STRING); diff --git a/src/Val.h b/src/Val.h index 67539052ad..a5ad870439 100644 --- a/src/Val.h +++ b/src/Val.h @@ -28,7 +28,7 @@ namespace zeek { template class PDict; class String; -}; +} template using PDict [[deprecated("Remove in v4.1. Use zeek::PDict instead.")]] = zeek::PDict; using BroString [[deprecated("Remove in v4.1. Use zeek::String instead.")]] = zeek::String; @@ -37,11 +37,16 @@ ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(IPAddr, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(IPPrefix, zeek); +namespace zeek { +class File; +using FilePtr = zeek::IntrusivePtr; +} +using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File; +using BroFilePtr [[deprecated("Remove in v4.1. Use zeek::FilePtr.")]] = zeek::FilePtr; namespace zeek::detail { class ScriptFunc; } using BroFunc [[deprecated("Remove in v4.1. Use zeek::detail::ScriptFunc instead.")]] = zeek::detail::ScriptFunc; -class BroFile; class PrefixTable; class StateAccess; ZEEK_FORWARD_DECLARE_NAMESPACED(RE_Matcher, zeek); @@ -54,7 +59,7 @@ extern double bro_start_network_time; namespace zeek { using FuncPtr = zeek::IntrusivePtr; -using BroFilePtr = zeek::IntrusivePtr; +using FilePtr = zeek::IntrusivePtr; class Val; class PortVal; @@ -99,7 +104,7 @@ union BroValUnion { String* string_val; zeek::Func* func_val; - BroFile* file_val; + File* file_val; RE_Matcher* re_val; zeek::PDict* table_val; std::vector* record_val; @@ -128,7 +133,7 @@ union BroValUnion { constexpr BroValUnion(zeek::Func* value) noexcept : func_val(value) {} - constexpr BroValUnion(BroFile* value) noexcept + constexpr BroValUnion(File* value) noexcept : file_val(value) {} constexpr BroValUnion(RE_Matcher* value) noexcept @@ -152,10 +157,10 @@ public: explicit Val(zeek::FuncPtr f); [[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]] - explicit Val(BroFile* f); + explicit Val(File* f); // Note, the file will be closed after this Val is destructed if there's // no other remaining references. - explicit Val(BroFilePtr f); + explicit Val(FilePtr f); // Extra arg to differentiate from protected version. Val(zeek::TypePtr t, bool type_type) @@ -241,7 +246,7 @@ public: CONST_ACCESSOR(zeek::TYPE_FUNC, zeek::Func*, func_val, AsFunc) CONST_ACCESSOR(zeek::TYPE_TABLE, zeek::PDict*, table_val, AsTable) CONST_ACCESSOR(zeek::TYPE_RECORD, std::vector*, record_val, AsRecord) - CONST_ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile) + CONST_ACCESSOR(zeek::TYPE_FILE, File*, file_val, AsFile) CONST_ACCESSOR(zeek::TYPE_PATTERN, RE_Matcher*, re_val, AsPattern) CONST_ACCESSOR(zeek::TYPE_VECTOR, std::vector*, vector_val, AsVector) @@ -275,7 +280,7 @@ public: // are protected to avoid external state changes. // ACCESSOR(zeek::TYPE_STRING, String*, string_val, AsString) ACCESSOR(zeek::TYPE_FUNC, zeek::Func*, func_val, AsFunc) - ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile) + ACCESSOR(zeek::TYPE_FILE, File*, file_val, AsFile) ACCESSOR(zeek::TYPE_PATTERN, RE_Matcher*, re_val, AsPattern) ACCESSOR(zeek::TYPE_VECTOR, std::vector*, vector_val, AsVector) diff --git a/src/analyzer/Analyzer.cc b/src/analyzer/Analyzer.cc index 1ca9dc2d16..78d8a944aa 100644 --- a/src/analyzer/Analyzer.cc +++ b/src/analyzer/Analyzer.cc @@ -926,12 +926,12 @@ void TransportLayerAnalyzer::Done() } void TransportLayerAnalyzer::SetContentsFile(unsigned int /* direction */, - BroFilePtr /* f */) + zeek::FilePtr /* f */) { reporter->Error("analyzer type does not support writing to a contents file"); } -BroFilePtr TransportLayerAnalyzer::GetContentsFile(unsigned int /* direction */) const +zeek::FilePtr TransportLayerAnalyzer::GetContentsFile(unsigned int /* direction */) const { reporter->Error("analyzer type does not support writing to a contents file"); return nullptr; diff --git a/src/analyzer/Analyzer.h b/src/analyzer/Analyzer.h index a9fc80ce87..3696504de5 100644 --- a/src/analyzer/Analyzer.h +++ b/src/analyzer/Analyzer.h @@ -16,17 +16,19 @@ #include "../Timer.h" #include "../IntrusivePtr.h" -class BroFile; -using BroFilePtr = zeek::IntrusivePtr; - class Connection; ZEEK_FORWARD_DECLARE_NAMESPACED(Rule, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(IP_Hdr, zeek); namespace zeek { using RecordValPtr = zeek::IntrusivePtr; +class File; +using FilePtr = zeek::IntrusivePtr; } +using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File; +using BroFilePtr [[deprecated("Remove in v4.1. Use zeek::FilePtr.")]] = zeek::FilePtr; + namespace analyzer { namespace tcp { class TCP_ApplicationAnalyzer; } namespace pia { class PIA; } @@ -919,7 +921,7 @@ public: * @param f The file to record to. * */ - virtual void SetContentsFile(unsigned int direction, BroFilePtr f); + virtual void SetContentsFile(unsigned int direction, zeek::FilePtr f); /** * Returns an associated contents file, if any. This must only be @@ -929,7 +931,7 @@ public: * @param direction One of the CONTENTS_* constants indicating which * direction the query is for. */ - virtual BroFilePtr GetContentsFile(unsigned int direction) const; + virtual zeek::FilePtr GetContentsFile(unsigned int direction) const; /** * Associates a PIA with this analyzer. A PIA takes the diff --git a/src/analyzer/protocol/tcp/Stats.cc b/src/analyzer/protocol/tcp/Stats.cc index 9dca450ab7..5ed6b8de23 100644 --- a/src/analyzer/protocol/tcp/Stats.cc +++ b/src/analyzer/protocol/tcp/Stats.cc @@ -38,7 +38,7 @@ unsigned int TCPStateStats::NumStatePartial() const return sum; } -void TCPStateStats::PrintStats(BroFile* file, const char* prefix) +void TCPStateStats::PrintStats(zeek::File* file, const char* prefix) { file->Write(prefix); file->Write(" Inact. Syn. SA Part. Est. Fin. Rst.\n"); diff --git a/src/analyzer/protocol/tcp/Stats.h b/src/analyzer/protocol/tcp/Stats.h index 3d118d7ac1..3e358d9d71 100644 --- a/src/analyzer/protocol/tcp/Stats.h +++ b/src/analyzer/protocol/tcp/Stats.h @@ -6,7 +6,7 @@ namespace analyzer { namespace tcp { // A TCPStateStats object tracks the distribution of TCP states for -// the currently active connections. +// the currently active connections. class TCPStateStats { public: TCPStateStats(); @@ -59,10 +59,10 @@ public: { return Cnt(TCP_ENDPOINT_INACTIVE); } unsigned int NumStatePartial() const; - void PrintStats(BroFile* file, const char* prefix); + void PrintStats(zeek::File* file, const char* prefix); private: unsigned int state_cnt[TCP_ENDPOINT_RESET+1][TCP_ENDPOINT_RESET+1]; }; -} } // namespace analyzer::* +} } // namespace analyzer::* diff --git a/src/analyzer/protocol/tcp/TCP.cc b/src/analyzer/protocol/tcp/TCP.cc index 5448e8ac92..2ae9c6baf4 100644 --- a/src/analyzer/protocol/tcp/TCP.cc +++ b/src/analyzer/protocol/tcp/TCP.cc @@ -1584,7 +1584,7 @@ void TCP_Analyzer::ConnDeleteTimer(double t) Conn()->DeleteTimer(t); } -void TCP_Analyzer::SetContentsFile(unsigned int direction, BroFilePtr f) +void TCP_Analyzer::SetContentsFile(unsigned int direction, zeek::FilePtr f) { if ( direction == CONTENTS_NONE ) { @@ -1601,7 +1601,7 @@ void TCP_Analyzer::SetContentsFile(unsigned int direction, BroFilePtr f) } } -BroFilePtr TCP_Analyzer::GetContentsFile(unsigned int direction) const +zeek::FilePtr TCP_Analyzer::GetContentsFile(unsigned int direction) const { switch ( direction ) { case CONTENTS_NONE: diff --git a/src/analyzer/protocol/tcp/TCP.h b/src/analyzer/protocol/tcp/TCP.h index 225da0c34e..982e18231b 100644 --- a/src/analyzer/protocol/tcp/TCP.h +++ b/src/analyzer/protocol/tcp/TCP.h @@ -60,8 +60,8 @@ public: // the test is whether it has any outstanding, un-acked data. bool DataPending(TCP_Endpoint* closing_endp); - void SetContentsFile(unsigned int direction, BroFilePtr f) override; - BroFilePtr GetContentsFile(unsigned int direction) const override; + void SetContentsFile(unsigned int direction, zeek::FilePtr f) override; + zeek::FilePtr GetContentsFile(unsigned int direction) const override; // From Analyzer.h void UpdateConnVal(zeek::RecordVal *conn_val) override; diff --git a/src/analyzer/protocol/tcp/TCP_Endpoint.cc b/src/analyzer/protocol/tcp/TCP_Endpoint.cc index 2c8e23d862..3f5f042330 100644 --- a/src/analyzer/protocol/tcp/TCP_Endpoint.cc +++ b/src/analyzer/protocol/tcp/TCP_Endpoint.cc @@ -254,7 +254,7 @@ void TCP_Endpoint::AckReceived(uint64_t seq) contents_processor->AckReceived(seq); } -void TCP_Endpoint::SetContentsFile(BroFilePtr f) +void TCP_Endpoint::SetContentsFile(zeek::FilePtr f) { contents_file = std::move(f); contents_start_seq = ToRelativeSeqSpace(last_seq, seq_wraps); diff --git a/src/analyzer/protocol/tcp/TCP_Endpoint.h b/src/analyzer/protocol/tcp/TCP_Endpoint.h index a9883d8e2d..bae3358717 100644 --- a/src/analyzer/protocol/tcp/TCP_Endpoint.h +++ b/src/analyzer/protocol/tcp/TCP_Endpoint.h @@ -188,8 +188,8 @@ public: void AckReceived(uint64_t seq); - void SetContentsFile(BroFilePtr f); - const BroFilePtr& GetContentsFile() const { return contents_file; } + void SetContentsFile(zeek::FilePtr f); + const zeek::FilePtr& GetContentsFile() const { return contents_file; } // Codes used for tracking history. For responders, we shift these // over by 16 bits in order to fit both originator and responder @@ -212,7 +212,7 @@ public: TCP_Endpoint* peer; TCP_Reassembler* contents_processor; TCP_Analyzer* tcp_analyzer; - BroFilePtr contents_file; + zeek::FilePtr contents_file; uint32_t checksum_base; double start_time, last_time; diff --git a/src/analyzer/protocol/tcp/TCP_Reassembler.cc b/src/analyzer/protocol/tcp/TCP_Reassembler.cc index 60fdf1f56e..7f43b64353 100644 --- a/src/analyzer/protocol/tcp/TCP_Reassembler.cc +++ b/src/analyzer/protocol/tcp/TCP_Reassembler.cc @@ -92,7 +92,7 @@ uint64_t TCP_Reassembler::NumUndeliveredBytes() const return last_block.upper - last_reassem_seq; } -void TCP_Reassembler::SetContentsFile(BroFilePtr f) +void TCP_Reassembler::SetContentsFile(zeek::FilePtr f) { if ( ! f->IsOpen() ) { @@ -317,7 +317,7 @@ void TCP_Reassembler::MatchUndelivered(uint64_t up_to_seq, bool use_last_upper) } } -void TCP_Reassembler::RecordToSeq(uint64_t start_seq, uint64_t stop_seq, const BroFilePtr& f) +void TCP_Reassembler::RecordToSeq(uint64_t start_seq, uint64_t stop_seq, const zeek::FilePtr& f) { auto it = block_list.Begin(); @@ -348,7 +348,7 @@ void TCP_Reassembler::RecordToSeq(uint64_t start_seq, uint64_t stop_seq, const B RecordGap(last_seq, stop_seq, f); } -void TCP_Reassembler::RecordBlock(const DataBlock& b, const BroFilePtr& f) +void TCP_Reassembler::RecordBlock(const DataBlock& b, const zeek::FilePtr& f) { if ( f->Write((const char*) b.block, b.Size()) ) return; @@ -363,7 +363,7 @@ void TCP_Reassembler::RecordBlock(const DataBlock& b, const BroFilePtr& f) ); } -void TCP_Reassembler::RecordGap(uint64_t start_seq, uint64_t upper_seq, const BroFilePtr& f) +void TCP_Reassembler::RecordGap(uint64_t start_seq, uint64_t upper_seq, const zeek::FilePtr& f) { if ( f->Write(fmt("\n<>\n", upper_seq - start_seq)) ) return; diff --git a/src/analyzer/protocol/tcp/TCP_Reassembler.h b/src/analyzer/protocol/tcp/TCP_Reassembler.h index 7906cff151..fb4ee93b52 100644 --- a/src/analyzer/protocol/tcp/TCP_Reassembler.h +++ b/src/analyzer/protocol/tcp/TCP_Reassembler.h @@ -48,8 +48,8 @@ public: // from waiting_on_hole above; and is computed in a different fashion). uint64_t NumUndeliveredBytes() const; - void SetContentsFile(BroFilePtr f); - const BroFilePtr& GetContentsFile() const { return record_contents_file; } + void SetContentsFile(zeek::FilePtr f); + const zeek::FilePtr& GetContentsFile() const { return record_contents_file; } void MatchUndelivered(uint64_t up_to_seq, bool use_last_upper); @@ -88,9 +88,9 @@ private: void Undelivered(uint64_t up_to_seq) override; void Gap(uint64_t seq, uint64_t len); - void RecordToSeq(uint64_t start_seq, uint64_t stop_seq, const BroFilePtr& f); - void RecordBlock(const DataBlock& b, const BroFilePtr& f); - void RecordGap(uint64_t start_seq, uint64_t upper_seq, const BroFilePtr& f); + void RecordToSeq(uint64_t start_seq, uint64_t stop_seq, const zeek::FilePtr& f); + void RecordBlock(const DataBlock& b, const zeek::FilePtr& f); + void RecordGap(uint64_t start_seq, uint64_t upper_seq, const zeek::FilePtr& f); void BlockInserted(DataBlockMap::const_iterator it) override; void Overlap(const u_char* b1, const u_char* b2, uint64_t n) override; @@ -107,7 +107,7 @@ private: bool in_delivery; analyzer::tcp::TCP_Flags flags; - BroFilePtr record_contents_file; // file on which to reassemble contents + zeek::FilePtr record_contents_file; // file on which to reassemble contents zeek::analyzer::Analyzer* dst_analyzer; TCP_Analyzer* tcp_analyzer; diff --git a/src/analyzer/protocol/tcp/functions.bif b/src/analyzer/protocol/tcp/functions.bif index fa2b535bf8..ad37055fb1 100644 --- a/src/analyzer/protocol/tcp/functions.bif +++ b/src/analyzer/protocol/tcp/functions.bif @@ -136,5 +136,5 @@ function get_contents_file%(cid: conn_id, direction: count%): file else zeek::emit_builtin_error("no contents file for given direction"); - return zeek::make_intrusive(zeek::make_intrusive(stderr, "-", "w")); + return zeek::make_intrusive(zeek::make_intrusive(stderr, "-", "w")); %} diff --git a/src/broker/Data.cc b/src/broker/Data.cc index eebb1073ff..61655fc09d 100644 --- a/src/broker/Data.cc +++ b/src/broker/Data.cc @@ -119,7 +119,7 @@ struct val_converter { return zeek::make_intrusive(a.size(), a.data()); case zeek::TYPE_FILE: { - auto file = BroFile::Get(a.data()); + auto file = zeek::File::Get(a.data()); if ( file ) return zeek::make_intrusive(std::move(file)); diff --git a/src/file_analysis/FileReassembler.h b/src/file_analysis/FileReassembler.h index cd17a1c9a4..55b53530e7 100644 --- a/src/file_analysis/FileReassembler.h +++ b/src/file_analysis/FileReassembler.h @@ -2,7 +2,9 @@ #include "Reassem.h" -class BroFile; +namespace zeek { class File; } +using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File; + class Connection; namespace file_analysis { diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 1c53fa97a3..0eba859407 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -993,7 +993,7 @@ threading::Value* Manager::ValToLogVal(zeek::Val* val, zeek::Type* ty) case zeek::TYPE_FILE: { - const BroFile* f = val->AsFile(); + const zeek::File* f = val->AsFile(); string s = f->Name(); lval->val.string_val.data = copy_string(s.c_str()); lval->val.string_val.length = s.size(); diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 50a78a5444..05b295f028 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -338,7 +338,7 @@ void zeek_terminate_loop(const char* reason) // Close files after net_delete(), because net_delete() // might write to connection content files. - BroFile::CloseOpenFiles(); + zeek::File::CloseOpenFiles(); delete zeek::detail::rule_matcher; @@ -891,7 +891,7 @@ int zeek::detail::cleanup(bool did_net_run) // Close files after net_delete(), because net_delete() // might write to connection content files. - BroFile::CloseOpenFiles(); + zeek::File::CloseOpenFiles(); delete rule_matcher; diff --git a/src/zeek.bif b/src/zeek.bif index dfde91e3ed..11603b26ca 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -4438,9 +4438,9 @@ function open%(f: string%): file const char* file = f->CheckString(); if ( streq(file, "-") ) - return zeek::make_intrusive(zeek::make_intrusive(stdout, "-", "w")); + return zeek::make_intrusive(zeek::make_intrusive(stdout, "-", "w")); else - return zeek::make_intrusive(zeek::make_intrusive(file, "w")); + return zeek::make_intrusive(zeek::make_intrusive(file, "w")); %} ## Opens a file for writing or appending. If a file with the same name already @@ -4455,7 +4455,7 @@ function open%(f: string%): file ## rmdir unlink rename function open_for_append%(f: string%): file %{ - return zeek::make_intrusive(zeek::make_intrusive(f->CheckString(), "a")); + return zeek::make_intrusive(zeek::make_intrusive(f->CheckString(), "a")); %} ## Closes an open file and flushes any buffered content.