Move Conn and related types to zeek namespace

This commit is contained in:
Tim Wojtulewicz 2020-07-22 15:02:48 -07:00
parent 0355d13099
commit 7fefdd97af
147 changed files with 328 additions and 313 deletions

View file

@ -30,7 +30,7 @@ static zeek::TableValPtr empty_connection_table()
return zeek::make_intrusive<zeek::TableVal>(std::move(tbl_type));
}
static zeek::RecordValPtr get_conn_id_val(const Connection* conn)
static zeek::RecordValPtr get_conn_id_val(const zeek::Connection* conn)
{
auto v = zeek::make_intrusive<zeek::RecordVal>(zeek::id::conn_id);
v->Assign(0, zeek::make_intrusive<zeek::AddrVal>(conn->OrigAddr()));
@ -80,7 +80,7 @@ void File::StaticInit()
meta_inferred_idx = Idx("inferred", zeek::id::fa_metadata);
}
File::File(const std::string& file_id, const std::string& source_name, Connection* conn,
File::File(const std::string& file_id, const std::string& source_name, zeek::Connection* conn,
zeek::analyzer::Tag tag, bool is_orig)
: id(file_id), val(nullptr), file_reassembler(nullptr), stream_offset(0),
reassembly_max_buffer(0), did_metadata_inference(false),
@ -123,7 +123,7 @@ double File::GetLastActivityTime() const
return val->GetField(last_active_idx)->AsTime();
}
bool File::UpdateConnectionFields(Connection* conn, bool is_orig)
bool File::UpdateConnectionFields(zeek::Connection* conn, bool is_orig)
{
if ( ! conn )
return false;
@ -146,7 +146,7 @@ bool File::UpdateConnectionFields(Connection* conn, bool is_orig)
return true;
}
void File::RaiseFileOverNewConnection(Connection* conn, bool is_orig)
void File::RaiseFileOverNewConnection(zeek::Connection* conn, bool is_orig)
{
if ( conn && FileEventAvailable(file_over_new_connection) )
{

View file

@ -13,8 +13,7 @@
#include "ZeekArgs.h"
#include "WeirdState.h"
class Connection;
ZEEK_FORWARD_DECLARE_NAMESPACED(Connection, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(EventHandlerPtr, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordVal, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
@ -253,7 +252,7 @@ protected:
* of the connection to the responder. False indicates the other
* direction.
*/
File(const std::string& file_id, const std::string& source_name, Connection* conn = nullptr,
File(const std::string& file_id, const std::string& source_name, zeek::Connection* conn = nullptr,
zeek::analyzer::Tag tag = zeek::analyzer::Tag::Error, bool is_orig = false);
/**
@ -263,12 +262,12 @@ protected:
* @param is_orig true if the connection originator is sending the file.
* @return true if the connection was previously unknown.
*/
bool UpdateConnectionFields(Connection* conn, bool is_orig);
bool UpdateConnectionFields(zeek::Connection* conn, bool is_orig);
/**
* Raise the file_over_new_connection event with given arguments.
*/
void RaiseFileOverNewConnection(Connection* conn, bool is_orig);
void RaiseFileOverNewConnection(zeek::Connection* conn, bool is_orig);
/**
* Increment a byte count field of #val record by \a size.

View file

@ -5,7 +5,7 @@
namespace zeek { class File; }
using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File;
class Connection;
ZEEK_FORWARD_DECLARE_NAMESPACED(Connection, zeek);
namespace file_analysis {

View file

@ -91,7 +91,7 @@ void Manager::SetHandle(const string& handle)
}
string Manager::DataIn(const u_char* data, uint64_t len, uint64_t offset,
const zeek::analyzer::Tag& tag, Connection* conn, bool is_orig,
const zeek::analyzer::Tag& tag, zeek::Connection* conn, bool is_orig,
const string& precomputed_id, const string& mime_type)
{
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
@ -121,8 +121,8 @@ string Manager::DataIn(const u_char* data, uint64_t len, uint64_t offset,
}
string Manager::DataIn(const u_char* data, uint64_t len, const zeek::analyzer::Tag& tag,
Connection* conn, bool is_orig, const string& precomputed_id,
const string& mime_type)
zeek::Connection* conn, bool is_orig, const string& precomputed_id,
const string& mime_type)
{
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
// Sequential data input shouldn't be going over multiple conns, so don't
@ -161,13 +161,13 @@ void Manager::DataIn(const u_char* data, uint64_t len, const string& file_id,
RemoveFile(file->GetID());
}
void Manager::EndOfFile(const zeek::analyzer::Tag& tag, Connection* conn)
void Manager::EndOfFile(const zeek::analyzer::Tag& tag, zeek::Connection* conn)
{
EndOfFile(tag, conn, true);
EndOfFile(tag, conn, false);
}
void Manager::EndOfFile(const zeek::analyzer::Tag& tag, Connection* conn, bool is_orig)
void Manager::EndOfFile(const zeek::analyzer::Tag& tag, zeek::Connection* conn, bool is_orig)
{
// Don't need to create a file if we're just going to remove it right away.
RemoveFile(GetFileID(tag, conn, is_orig));
@ -179,7 +179,7 @@ void Manager::EndOfFile(const string& file_id)
}
string Manager::Gap(uint64_t offset, uint64_t len, const zeek::analyzer::Tag& tag,
Connection* conn, bool is_orig, const string& precomputed_id)
zeek::Connection* conn, bool is_orig, const string& precomputed_id)
{
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
File* file = GetFile(id, conn, tag, is_orig);
@ -191,7 +191,7 @@ string Manager::Gap(uint64_t offset, uint64_t len, const zeek::analyzer::Tag& ta
return id;
}
string Manager::SetSize(uint64_t size, const zeek::analyzer::Tag& tag, Connection* conn,
string Manager::SetSize(uint64_t size, const zeek::analyzer::Tag& tag, zeek::Connection* conn,
bool is_orig, const string& precomputed_id)
{
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
@ -303,7 +303,7 @@ bool Manager::RemoveAnalyzer(const string& file_id, const file_analysis::Tag& ta
return file->RemoveAnalyzer(tag, std::move(args));
}
File* Manager::GetFile(const string& file_id, Connection* conn,
File* Manager::GetFile(const string& file_id, zeek::Connection* conn,
const zeek::analyzer::Tag& tag, bool is_orig, bool update_conn,
const char* source_name)
{
@ -420,7 +420,7 @@ bool Manager::IsIgnored(const string& file_id)
return ignored.find(file_id) != ignored.end();
}
string Manager::GetFileID(const zeek::analyzer::Tag& tag, Connection* c, bool is_orig)
string Manager::GetFileID(const zeek::analyzer::Tag& tag, zeek::Connection* c, bool is_orig)
{
current_file_id.clear();

View file

@ -104,7 +104,7 @@ public:
* indicates the associate file is not going to be analyzed further.
*/
std::string DataIn(const u_char* data, uint64_t len, uint64_t offset,
const zeek::analyzer::Tag& tag, Connection* conn, bool is_orig,
const zeek::analyzer::Tag& tag, zeek::Connection* conn, bool is_orig,
const std::string& precomputed_file_id = "",
const std::string& mime_type = "");
@ -131,7 +131,7 @@ public:
* indicates the associated file is not going to be analyzed further.
*/
std::string DataIn(const u_char* data, uint64_t len, const zeek::analyzer::Tag& tag,
Connection* conn, bool is_orig,
zeek::Connection* conn, bool is_orig,
const std::string& precomputed_file_id = "",
const std::string& mime_type = "");
@ -153,7 +153,7 @@ public:
* @param tag network protocol over which the file data is transferred.
* @param conn network connection over which the file data is transferred.
*/
void EndOfFile(const zeek::analyzer::Tag& tag, Connection* conn);
void EndOfFile(const zeek::analyzer::Tag& tag, zeek::Connection* conn);
/**
* Signal the end of file data being transferred over a connection in
@ -161,7 +161,7 @@ public:
* @param tag network protocol over which the file data is transferred.
* @param conn network connection over which the file data is transferred.
*/
void EndOfFile(const zeek::analyzer::Tag& tag, Connection* conn, bool is_orig);
void EndOfFile(const zeek::analyzer::Tag& tag, zeek::Connection* conn, bool is_orig);
/**
* Signal the end of file data being transferred using the file identifier.
@ -186,7 +186,7 @@ public:
* indicates the associate file is not going to be analyzed further.
*/
std::string Gap(uint64_t offset, uint64_t len, const zeek::analyzer::Tag& tag,
Connection* conn, bool is_orig,
zeek::Connection* conn, bool is_orig,
const std::string& precomputed_file_id = "");
/**
@ -204,7 +204,7 @@ public:
* the \c get_file_handle script-layer event). An empty string
* indicates the associate file is not going to be analyzed further.
*/
std::string SetSize(uint64_t size, const zeek::analyzer::Tag& tag, Connection* conn,
std::string SetSize(uint64_t size, const zeek::analyzer::Tag& tag, zeek::Connection* conn,
bool is_orig, const std::string& precomputed_file_id = "");
/**
@ -369,7 +369,7 @@ protected:
* exist, the activity time is refreshed along with any
* connection-related fields.
*/
File* GetFile(const std::string& file_id, Connection* conn = nullptr,
File* GetFile(const std::string& file_id, zeek::Connection* conn = nullptr,
const zeek::analyzer::Tag& tag = zeek::analyzer::Tag::Error,
bool is_orig = false, bool update_conn = true,
const char* source_name = nullptr);
@ -401,7 +401,7 @@ protected:
* @return #current_file_id, which is a hash of a unique file handle string
* set by a \c get_file_handle event handler.
*/
std::string GetFileID(const zeek::analyzer::Tag& tag, Connection* c, bool is_orig);
std::string GetFileID(const zeek::analyzer::Tag& tag, zeek::Connection* c, bool is_orig);
/**
* Check if analysis is available for files transferred over a given