mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
Move BroFile to zeek namespace, rename to File
This commit is contained in:
parent
bfab224d7c
commit
910aa77d95
29 changed files with 135 additions and 115 deletions
|
@ -1 +1 @@
|
|||
Subproject commit ddcb00d15cab84f1b1d0e82dffa764f278e0c69c
|
||||
Subproject commit 462ac3bd3a7ae0d30378e36ca2fe771c53a0a23e
|
|
@ -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;
|
||||
|
|
|
@ -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<std::string>;
|
||||
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;
|
||||
|
|
52
src/File.cc
52
src/File.cc
|
@ -31,7 +31,9 @@
|
|||
#include "Desc.h"
|
||||
#include "Var.h"
|
||||
|
||||
std::list<std::pair<std::string, BroFile*>> BroFile::open_files;
|
||||
namespace zeek {
|
||||
|
||||
std::list<std::pair<std::string, File*>> 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<zeek::Val>(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<BroFile>(name, "w");
|
||||
return zeek::make_intrusive<File>(name, "w");
|
||||
}
|
||||
|
||||
} // namespace zeek
|
||||
|
|
42
src/File.h
42
src/File.h
|
@ -16,25 +16,23 @@
|
|||
#include "IntrusivePtr.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace zeek {
|
||||
class Type;
|
||||
using TypePtr = zeek::IntrusivePtr<zeek::Type>;
|
||||
}
|
||||
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<BroFile>;
|
||||
namespace zeek {
|
||||
class Type;
|
||||
using TypePtr = zeek::IntrusivePtr<zeek::Type>;
|
||||
|
||||
class BroFile final : public zeek::Obj {
|
||||
class File;
|
||||
using FilePtr = zeek::IntrusivePtr<File>;
|
||||
|
||||
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<std::pair<std::string, BroFile*>> open_files;
|
||||
static std::list<std::pair<std::string, File*>> 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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
13
src/Stats.h
13
src/Stats.h
|
@ -9,7 +9,8 @@
|
|||
#include <sys/resource.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -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<ValPtr> 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<ValPtr> 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 "-".
|
||||
|
|
|
@ -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);
|
||||
|
|
23
src/Val.h
23
src/Val.h
|
@ -28,7 +28,7 @@
|
|||
namespace zeek {
|
||||
template<typename T> class PDict;
|
||||
class String;
|
||||
};
|
||||
}
|
||||
template<typename T> using PDict [[deprecated("Remove in v4.1. Use zeek::PDict instead.")]] = zeek::PDict<T>;
|
||||
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<File>;
|
||||
}
|
||||
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<Func>;
|
||||
using BroFilePtr = zeek::IntrusivePtr<BroFile>;
|
||||
using FilePtr = zeek::IntrusivePtr<File>;
|
||||
|
||||
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<TableEntryVal>* table_val;
|
||||
std::vector<ValPtr>* 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<TableEntryVal>*, table_val, AsTable)
|
||||
CONST_ACCESSOR(zeek::TYPE_RECORD, std::vector<ValPtr>*, 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<ValPtr>*, 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<ValPtr>*, vector_val, AsVector)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -16,17 +16,19 @@
|
|||
#include "../Timer.h"
|
||||
#include "../IntrusivePtr.h"
|
||||
|
||||
class BroFile;
|
||||
using BroFilePtr = zeek::IntrusivePtr<BroFile>;
|
||||
|
||||
class Connection;
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(Rule, zeek::detail);
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(IP_Hdr, zeek);
|
||||
|
||||
namespace zeek {
|
||||
using RecordValPtr = zeek::IntrusivePtr<RecordVal>;
|
||||
class File;
|
||||
using FilePtr = zeek::IntrusivePtr<File>;
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -59,7 +59,7 @@ 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];
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<<gap %" PRIu64">>\n", upper_seq - start_seq)) )
|
||||
return;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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::Val>(zeek::make_intrusive<BroFile>(stderr, "-", "w"));
|
||||
return zeek::make_intrusive<zeek::Val>(zeek::make_intrusive<zeek::File>(stderr, "-", "w"));
|
||||
%}
|
||||
|
|
|
@ -119,7 +119,7 @@ struct val_converter {
|
|||
return zeek::make_intrusive<zeek::StringVal>(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<zeek::Val>(std::move(file));
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -4438,9 +4438,9 @@ function open%(f: string%): file
|
|||
const char* file = f->CheckString();
|
||||
|
||||
if ( streq(file, "-") )
|
||||
return zeek::make_intrusive<zeek::Val>(zeek::make_intrusive<BroFile>(stdout, "-", "w"));
|
||||
return zeek::make_intrusive<zeek::Val>(zeek::make_intrusive<zeek::File>(stdout, "-", "w"));
|
||||
else
|
||||
return zeek::make_intrusive<zeek::Val>(zeek::make_intrusive<BroFile>(file, "w"));
|
||||
return zeek::make_intrusive<zeek::Val>(zeek::make_intrusive<zeek::File>(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::Val>(zeek::make_intrusive<BroFile>(f->CheckString(), "a"));
|
||||
return zeek::make_intrusive<zeek::Val>(zeek::make_intrusive<zeek::File>(f->CheckString(), "a"));
|
||||
%}
|
||||
|
||||
## Closes an open file and flushes any buffered content.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue