mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Remove 'using namespace std' from SerialTypes.h
This unfortunately cuases a ton of flow-down changes because a lot of other code was depending on that definition existing. This has a fairly large chance to break builds of external plugins, considering how many internal ones it broke.
This commit is contained in:
parent
a525f9532e
commit
d53c1454c0
119 changed files with 402 additions and 383 deletions
|
@ -56,7 +56,7 @@ int bi_ffs(uint32_t value)
|
||||||
|
|
||||||
ipaddr32_t AnonymizeIPAddr::Anonymize(ipaddr32_t addr)
|
ipaddr32_t AnonymizeIPAddr::Anonymize(ipaddr32_t addr)
|
||||||
{
|
{
|
||||||
map<ipaddr32_t, ipaddr32_t>::iterator p = mapping.find(addr);
|
std::map<ipaddr32_t, ipaddr32_t>::iterator p = mapping.find(addr);
|
||||||
if ( p != mapping.end() )
|
if ( p != mapping.end() )
|
||||||
return p->second;
|
return p->second;
|
||||||
else
|
else
|
||||||
|
|
|
@ -106,7 +106,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const
|
||||||
ODesc dd;
|
ODesc dd;
|
||||||
dd.SetQuotes(true);
|
dd.SetQuotes(true);
|
||||||
expr->Describe(&dd);
|
expr->Describe(&dd);
|
||||||
string s = dd.Description();
|
std::string s = dd.Description();
|
||||||
add_long_expr_string(d, s, shorten);
|
add_long_expr_string(d, s, shorten);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const
|
||||||
{
|
{
|
||||||
ODesc dd;
|
ODesc dd;
|
||||||
expr->Eval(nullptr)->Describe(&dd);
|
expr->Eval(nullptr)->Describe(&dd);
|
||||||
string s = dd.Description();
|
std::string s = dd.Description();
|
||||||
|
|
||||||
for ( size_t i = 0; i < s.size(); ++i )
|
for ( size_t i = 0; i < s.size(); ++i )
|
||||||
if ( s[i] == '\n' )
|
if ( s[i] == '\n' )
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
int Base64Converter::default_base64_table[256];
|
int Base64Converter::default_base64_table[256];
|
||||||
const string Base64Converter::default_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
const std::string Base64Converter::default_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, char** pbuf)
|
void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, char** pbuf)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, cha
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int* Base64Converter::InitBase64Table(const string& alphabet)
|
int* Base64Converter::InitBase64Table(const std::string& alphabet)
|
||||||
{
|
{
|
||||||
assert(alphabet.size() == 64);
|
assert(alphabet.size() == 64);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ int* Base64Converter::InitBase64Table(const string& alphabet)
|
||||||
return base64_table;
|
return base64_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
Base64Converter::Base64Converter(Connection* arg_conn, const string& arg_alphabet)
|
Base64Converter::Base64Converter(Connection* arg_conn, const std::string& arg_alphabet)
|
||||||
{
|
{
|
||||||
if ( arg_alphabet.size() > 0 )
|
if ( arg_alphabet.size() > 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ BroString::BroString(const char* str) : BroString()
|
||||||
Set(str);
|
Set(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
BroString::BroString(const string &str) : BroString()
|
BroString::BroString(const std::string &str) : BroString()
|
||||||
{
|
{
|
||||||
Set(str);
|
Set(str);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ void BroString::Set(const char* str)
|
||||||
use_free_to_delete = false;
|
use_free_to_delete = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BroString::Set(const string& str)
|
void BroString::Set(const std::string& str)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ char* BroString::Render(int format, int* len) const
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& BroString::Render(ostream &os, int format) const
|
std::ostream& BroString::Render(std::ostream &os, int format) const
|
||||||
{
|
{
|
||||||
char* tmp = Render(format);
|
char* tmp = Render(format);
|
||||||
os << tmp;
|
os << tmp;
|
||||||
|
@ -242,7 +242,7 @@ ostream& BroString::Render(ostream &os, int format) const
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& BroString::Read(istream &is, int format)
|
std::istream& BroString::Read(std::istream &is, int format)
|
||||||
{
|
{
|
||||||
if ( (format & BroString::ESC_SER) )
|
if ( (format & BroString::ESC_SER) )
|
||||||
{
|
{
|
||||||
|
@ -260,7 +260,7 @@ istream& BroString::Read(istream &is, int format)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string str;
|
std::string str;
|
||||||
is >> str;
|
is >> str;
|
||||||
Set(str);
|
Set(str);
|
||||||
}
|
}
|
||||||
|
@ -376,7 +376,7 @@ BroString::Vec* BroString::VecFromPolicy(VectorVal* vec)
|
||||||
|
|
||||||
char* BroString::VecToString(const Vec* vec)
|
char* BroString::VecToString(const Vec* vec)
|
||||||
{
|
{
|
||||||
string result("[");
|
std::string result("[");
|
||||||
|
|
||||||
for ( BroString::VecCIt it = vec->begin(); it != vec->end(); ++it )
|
for ( BroString::VecCIt it = vec->begin(); it != vec->end(); ++it )
|
||||||
{
|
{
|
||||||
|
@ -396,7 +396,7 @@ bool BroStringLenCmp::operator()(BroString * const& bst1,
|
||||||
(bst1->Len() > bst2->Len());
|
(bst1->Len() > bst2->Len());
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& operator<<(ostream& os, const BroString& bs)
|
std::ostream& operator<<(std::ostream& os, const BroString& bs)
|
||||||
{
|
{
|
||||||
char* tmp = bs.Render(BroString::EXPANDED_STRING);
|
char* tmp = bs.Render(BroString::EXPANDED_STRING);
|
||||||
os << tmp;
|
os << tmp;
|
||||||
|
@ -414,7 +414,7 @@ int Bstr_eq(const BroString* s1, const BroString* s2)
|
||||||
|
|
||||||
int Bstr_cmp(const BroString* s1, const BroString* s2)
|
int Bstr_cmp(const BroString* s1, const BroString* s2)
|
||||||
{
|
{
|
||||||
int n = min(s1->Len(), s2->Len());
|
int n = std::min(s1->Len(), s2->Len());
|
||||||
int cmp = memcmp(s1->Bytes(), s2->Bytes(), n);
|
int cmp = memcmp(s1->Bytes(), s2->Bytes(), n);
|
||||||
|
|
||||||
if ( cmp || s1->Len() == s2->Len() )
|
if ( cmp || s1->Len() == s2->Len() )
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
Brofiler::Brofiler()
|
Brofiler::Brofiler()
|
||||||
: ignoring(0), delim('\t')
|
: ignoring(0), delim('\t')
|
||||||
{
|
{
|
||||||
|
|
|
@ -906,7 +906,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
|
||||||
RecordType* rt = t->AsRecordType();
|
RecordType* rt = t->AsRecordType();
|
||||||
int num_fields = rt->NumFields();
|
int num_fields = rt->NumFields();
|
||||||
|
|
||||||
vector<Val*> values;
|
std::vector<Val*> values;
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < num_fields; ++i )
|
for ( i = 0; i < num_fields; ++i )
|
||||||
{
|
{
|
||||||
|
|
|
@ -369,7 +369,7 @@ protected:
|
||||||
static uint64_t total_connections;
|
static uint64_t total_connections;
|
||||||
static uint64_t current_connections;
|
static uint64_t current_connections;
|
||||||
|
|
||||||
string history;
|
std::string history;
|
||||||
uint32_t hist_seen;
|
uint32_t hist_seen;
|
||||||
|
|
||||||
analyzer::TransportLayerAnalyzer* root_analyzer;
|
analyzer::TransportLayerAnalyzer* root_analyzer;
|
||||||
|
|
|
@ -50,6 +50,7 @@ extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||||
#include "nb_dns.h"
|
#include "nb_dns.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class DNS_Mgr_Request {
|
class DNS_Mgr_Request {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -60,8 +60,8 @@ public:
|
||||||
bool Save();
|
bool Save();
|
||||||
|
|
||||||
const char* LookupAddrInCache(const IPAddr& addr);
|
const char* LookupAddrInCache(const IPAddr& addr);
|
||||||
IntrusivePtr<TableVal> LookupNameInCache(const string& name);
|
IntrusivePtr<TableVal> LookupNameInCache(const std::string& name);
|
||||||
const char* LookupTextInCache(const string& name);
|
const char* LookupTextInCache(const std::string& name);
|
||||||
|
|
||||||
// Support for async lookups.
|
// Support for async lookups.
|
||||||
class LookupCallback {
|
class LookupCallback {
|
||||||
|
@ -75,8 +75,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void AsyncLookupAddr(const IPAddr& host, LookupCallback* callback);
|
void AsyncLookupAddr(const IPAddr& host, LookupCallback* callback);
|
||||||
void AsyncLookupName(const string& name, LookupCallback* callback);
|
void AsyncLookupName(const std::string& name, LookupCallback* callback);
|
||||||
void AsyncLookupNameText(const string& name, LookupCallback* callback);
|
void AsyncLookupNameText(const std::string& name, LookupCallback* callback);
|
||||||
|
|
||||||
struct Stats {
|
struct Stats {
|
||||||
unsigned long requests; // These count only async requests.
|
unsigned long requests; // These count only async requests.
|
||||||
|
@ -108,9 +108,9 @@ protected:
|
||||||
IntrusivePtr<ListVal> AddrListDelta(ListVal* al1, ListVal* al2);
|
IntrusivePtr<ListVal> AddrListDelta(ListVal* al1, ListVal* al2);
|
||||||
void DumpAddrList(FILE* f, ListVal* al);
|
void DumpAddrList(FILE* f, ListVal* al);
|
||||||
|
|
||||||
typedef map<string, pair<DNS_Mapping*, DNS_Mapping*> > HostMap;
|
typedef std::map<std::string, std::pair<DNS_Mapping*, DNS_Mapping*> > HostMap;
|
||||||
typedef map<IPAddr, DNS_Mapping*> AddrMap;
|
typedef std::map<IPAddr, DNS_Mapping*> AddrMap;
|
||||||
typedef map<string, DNS_Mapping*> TextMap;
|
typedef std::map<std::string, DNS_Mapping*> TextMap;
|
||||||
void LoadCache(FILE* f);
|
void LoadCache(FILE* f);
|
||||||
void Save(FILE* f, const AddrMap& m);
|
void Save(FILE* f, const AddrMap& m);
|
||||||
void Save(FILE* f, const HostMap& m);
|
void Save(FILE* f, const HostMap& m);
|
||||||
|
@ -159,14 +159,14 @@ protected:
|
||||||
|
|
||||||
RecordType* dm_rec;
|
RecordType* dm_rec;
|
||||||
|
|
||||||
typedef list<LookupCallback*> CallbackList;
|
typedef std::list<LookupCallback*> CallbackList;
|
||||||
|
|
||||||
struct AsyncRequest {
|
struct AsyncRequest {
|
||||||
double time;
|
double time;
|
||||||
bool is_txt;
|
bool is_txt;
|
||||||
bool processed;
|
bool processed;
|
||||||
IPAddr host;
|
IPAddr host;
|
||||||
string name;
|
std::string name;
|
||||||
CallbackList callbacks;
|
CallbackList callbacks;
|
||||||
|
|
||||||
AsyncRequest() : time(0.0), is_txt(false), processed(false) { }
|
AsyncRequest() : time(0.0), is_txt(false), processed(false) { }
|
||||||
|
@ -211,16 +211,16 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef map<IPAddr, AsyncRequest*> AsyncRequestAddrMap;
|
typedef std::map<IPAddr, AsyncRequest*> AsyncRequestAddrMap;
|
||||||
AsyncRequestAddrMap asyncs_addrs;
|
AsyncRequestAddrMap asyncs_addrs;
|
||||||
|
|
||||||
typedef map<string, AsyncRequest*> AsyncRequestNameMap;
|
typedef std::map<std::string, AsyncRequest*> AsyncRequestNameMap;
|
||||||
AsyncRequestNameMap asyncs_names;
|
AsyncRequestNameMap asyncs_names;
|
||||||
|
|
||||||
typedef map<string, AsyncRequest*> AsyncRequestTextMap;
|
typedef std::map<std::string, AsyncRequest*> AsyncRequestTextMap;
|
||||||
AsyncRequestTextMap asyncs_texts;
|
AsyncRequestTextMap asyncs_texts;
|
||||||
|
|
||||||
typedef list<AsyncRequest*> QueuedList;
|
typedef std::list<AsyncRequest*> QueuedList;
|
||||||
QueuedList asyncs_queued;
|
QueuedList asyncs_queued;
|
||||||
|
|
||||||
struct AsyncRequestCompare {
|
struct AsyncRequestCompare {
|
||||||
|
@ -230,7 +230,7 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef priority_queue<AsyncRequest*, std::vector<AsyncRequest*>, AsyncRequestCompare> TimeoutQueue;
|
typedef std::priority_queue<AsyncRequest*, std::vector<AsyncRequest*>, AsyncRequestCompare> TimeoutQueue;
|
||||||
TimeoutQueue asyncs_timeouts;
|
TimeoutQueue asyncs_timeouts;
|
||||||
|
|
||||||
int asyncs_pending;
|
int asyncs_pending;
|
||||||
|
|
|
@ -90,7 +90,7 @@ void DbgBreakpoint::AddToGlobalMap()
|
||||||
|
|
||||||
void DbgBreakpoint::RemoveFromGlobalMap()
|
void DbgBreakpoint::RemoveFromGlobalMap()
|
||||||
{
|
{
|
||||||
pair<BPMapType::iterator, BPMapType::iterator> p;
|
std::pair<BPMapType::iterator, BPMapType::iterator> p;
|
||||||
p = g_debugger_state.breakpoint_map.equal_range(at_stmt);
|
p = g_debugger_state.breakpoint_map.equal_range(at_stmt);
|
||||||
|
|
||||||
for ( BPMapType::iterator i = p.first; i != p.second; )
|
for ( BPMapType::iterator i = p.first; i != p.second; )
|
||||||
|
@ -120,7 +120,7 @@ void DbgBreakpoint::RemoveFromStmt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DbgBreakpoint::SetLocation(ParseLocationRec plr, string_view loc_str)
|
bool DbgBreakpoint::SetLocation(ParseLocationRec plr, std::string_view loc_str)
|
||||||
{
|
{
|
||||||
if ( plr.type == plrUnknown )
|
if ( plr.type == plrUnknown )
|
||||||
{
|
{
|
||||||
|
@ -224,7 +224,7 @@ bool DbgBreakpoint::Reset()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DbgBreakpoint::SetCondition(const string& new_condition)
|
bool DbgBreakpoint::SetCondition(const std::string& new_condition)
|
||||||
{
|
{
|
||||||
condition = new_condition;
|
condition = new_condition;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "Val.h"
|
#include "Val.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Helper routines
|
// Helper routines
|
||||||
//
|
//
|
||||||
|
|
|
@ -165,7 +165,7 @@ void DebugLogger::Log(DebugStream stream, const char* fmt, ...)
|
||||||
|
|
||||||
void DebugLogger::Log(const plugin::Plugin& plugin, const char* fmt, ...)
|
void DebugLogger::Log(const plugin::Plugin& plugin, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
string tok = string("plugin-") + plugin.Name();
|
std::string tok = std::string("plugin-") + plugin.Name();
|
||||||
tok = strreplace(tok, "::", "-");
|
tok = strreplace(tok, "::", "-");
|
||||||
|
|
||||||
if ( enabled_streams.find(tok) == enabled_streams.end() )
|
if ( enabled_streams.find(tok) == enabled_streams.end() )
|
||||||
|
|
|
@ -251,7 +251,7 @@ size_t ODesc::StartsWithEscapeSequence(const char* start, const char* end)
|
||||||
|
|
||||||
for ( it = escape_sequences.begin(); it != escape_sequences.end(); ++it )
|
for ( it = escape_sequences.begin(); it != escape_sequences.end(); ++it )
|
||||||
{
|
{
|
||||||
const string& esc_str = *it;
|
const std::string& esc_str = *it;
|
||||||
size_t esc_len = esc_str.length();
|
size_t esc_len = esc_str.length();
|
||||||
|
|
||||||
if ( start + esc_len > end )
|
if ( start + esc_len > end )
|
||||||
|
@ -264,9 +264,9 @@ size_t ODesc::StartsWithEscapeSequence(const char* start, const char* end)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<const char*, size_t> ODesc::FirstEscapeLoc(const char* bytes, size_t n)
|
std::pair<const char*, size_t> ODesc::FirstEscapeLoc(const char* bytes, size_t n)
|
||||||
{
|
{
|
||||||
typedef pair<const char*, size_t> escape_pos;
|
typedef std::pair<const char*, size_t> escape_pos;
|
||||||
|
|
||||||
if ( IsBinary() )
|
if ( IsBinary() )
|
||||||
return escape_pos(0, 0);
|
return escape_pos(0, 0);
|
||||||
|
@ -327,7 +327,7 @@ void ODesc::AddBytes(const void* bytes, unsigned int n)
|
||||||
|
|
||||||
while ( s < e )
|
while ( s < e )
|
||||||
{
|
{
|
||||||
pair<const char*, size_t> p = FirstEscapeLoc(s, e - s);
|
std::pair<const char*, size_t> p = FirstEscapeLoc(s, e - s);
|
||||||
|
|
||||||
if ( p.first )
|
if ( p.first )
|
||||||
{
|
{
|
||||||
|
|
|
@ -161,7 +161,7 @@ Val* Discarder::BuildData(const u_char* data, int hdrlen, int len, int caplen)
|
||||||
caplen -= hdrlen;
|
caplen -= hdrlen;
|
||||||
data += hdrlen;
|
data += hdrlen;
|
||||||
|
|
||||||
len = max(min(min(len, caplen), discarder_maxlen), 0);
|
len = std::max(std::min(std::min(len, caplen), discarder_maxlen), 0);
|
||||||
|
|
||||||
return new StringVal(new BroString(data, len, true));
|
return new StringVal(new BroString(data, len, true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ void EventHandler::Call(const zeek::Args& vl, bool no_remote)
|
||||||
auto opt_data = bro_broker::val_to_data(vl[i].get());
|
auto opt_data = bro_broker::val_to_data(vl[i].get());
|
||||||
|
|
||||||
if ( opt_data )
|
if ( opt_data )
|
||||||
xs.emplace_back(move(*opt_data));
|
xs.emplace_back(std::move(*opt_data));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valid_args = false;
|
valid_args = false;
|
||||||
|
|
|
@ -8,10 +8,10 @@ EventRegistry::~EventRegistry() noexcept = default;
|
||||||
|
|
||||||
void EventRegistry::Register(EventHandlerPtr handler)
|
void EventRegistry::Register(EventHandlerPtr handler)
|
||||||
{
|
{
|
||||||
handlers[string(handler->Name())] = std::unique_ptr<EventHandler>(handler.Ptr());
|
handlers[std::string(handler->Name())] = std::unique_ptr<EventHandler>(handler.Ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler* EventRegistry::Lookup(const string& name)
|
EventHandler* EventRegistry::Lookup(const std::string& name)
|
||||||
{
|
{
|
||||||
auto it = handlers.find(name);
|
auto it = handlers.find(name);
|
||||||
if ( it != handlers.end() )
|
if ( it != handlers.end() )
|
||||||
|
@ -86,7 +86,7 @@ void EventRegistry::PrintDebug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventRegistry::SetErrorHandler(const string& name)
|
void EventRegistry::SetErrorHandler(const std::string& name)
|
||||||
{
|
{
|
||||||
EventHandler* eh = Lookup(name);
|
EventHandler* eh = Lookup(name);
|
||||||
|
|
||||||
|
|
|
@ -709,7 +709,7 @@ IntrusivePtr<Val> BinaryExpr::StringFold(Val* v1, Val* v2) const
|
||||||
case EXPR_ADD:
|
case EXPR_ADD:
|
||||||
case EXPR_ADD_TO:
|
case EXPR_ADD_TO:
|
||||||
{
|
{
|
||||||
vector<const BroString*> strings;
|
std::vector<const BroString*> strings;
|
||||||
strings.push_back(s1);
|
strings.push_back(s1);
|
||||||
strings.push_back(s2);
|
strings.push_back(s2);
|
||||||
|
|
||||||
|
@ -3602,7 +3602,7 @@ RecordCoerceExpr::RecordCoerceExpr(IntrusivePtr<Expr> arg_op,
|
||||||
if ( ! is_arithmetic_promotable(sup_t_i, sub_t_i) &&
|
if ( ! is_arithmetic_promotable(sup_t_i, sub_t_i) &&
|
||||||
! is_record_promotable(sup_t_i, sub_t_i) )
|
! is_record_promotable(sup_t_i, sub_t_i) )
|
||||||
{
|
{
|
||||||
string error_msg = fmt(
|
std::string error_msg = fmt(
|
||||||
"type clash for field \"%s\"", sub_r->FieldName(i));
|
"type clash for field \"%s\"", sub_r->FieldName(i));
|
||||||
Error(error_msg.c_str(), sub_t_i);
|
Error(error_msg.c_str(), sub_t_i);
|
||||||
SetError();
|
SetError();
|
||||||
|
@ -3622,7 +3622,7 @@ RecordCoerceExpr::RecordCoerceExpr(IntrusivePtr<Expr> arg_op,
|
||||||
{
|
{
|
||||||
if ( ! t_r->FieldDecl(i)->FindAttr(ATTR_OPTIONAL) )
|
if ( ! t_r->FieldDecl(i)->FindAttr(ATTR_OPTIONAL) )
|
||||||
{
|
{
|
||||||
string error_msg = fmt(
|
std::string error_msg = fmt(
|
||||||
"non-optional field \"%s\" missing", t_r->FieldName(i));
|
"non-optional field \"%s\" missing", t_r->FieldName(i));
|
||||||
Error(error_msg.c_str());
|
Error(error_msg.c_str());
|
||||||
SetError();
|
SetError();
|
||||||
|
@ -4832,7 +4832,7 @@ RecordAssignExpr::RecordAssignExpr(const IntrusivePtr<Expr>& record,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string s = "No such field '";
|
std::string s = "No such field '";
|
||||||
s += field_name;
|
s += field_name;
|
||||||
s += "'";
|
s += "'";
|
||||||
init_list->SetError(s.c_str());
|
init_list->SetError(s.c_str());
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "Val.h"
|
#include "Val.h"
|
||||||
#include "ID.h"
|
#include "ID.h"
|
||||||
|
|
||||||
vector<Frame*> g_frame_stack;
|
std::vector<Frame*> g_frame_stack;
|
||||||
|
|
||||||
Frame::Frame(int arg_size, const BroFunc* func, const zeek::Args* fn_args)
|
Frame::Frame(int arg_size, const BroFunc* func, const zeek::Args* fn_args)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,10 +56,10 @@
|
||||||
|
|
||||||
extern RETSIGTYPE sig_handler(int signo);
|
extern RETSIGTYPE sig_handler(int signo);
|
||||||
|
|
||||||
vector<CallInfo> call_stack;
|
std::vector<CallInfo> call_stack;
|
||||||
bool did_builtin_init = false;
|
bool did_builtin_init = false;
|
||||||
|
|
||||||
vector<Func*> Func::unique_ids;
|
std::vector<Func*> Func::unique_ids;
|
||||||
static const std::pair<bool, Val*> empty_hook_result(false, NULL);
|
static const std::pair<bool, Val*> empty_hook_result(false, NULL);
|
||||||
|
|
||||||
std::string render_call_stack()
|
std::string render_call_stack()
|
||||||
|
|
10
src/ID.cc
10
src/ID.cc
|
@ -45,7 +45,7 @@ ID::~ID()
|
||||||
Unref(val);
|
Unref(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
string ID::ModuleName() const
|
std::string ID::ModuleName() const
|
||||||
{
|
{
|
||||||
return extract_module_name(name);
|
return extract_module_name(name);
|
||||||
}
|
}
|
||||||
|
@ -214,9 +214,9 @@ void ID::MakeDeprecated(IntrusivePtr<Expr> deprecation)
|
||||||
AddAttrs(make_intrusive<Attributes>(attr, IntrusivePtr{NewRef{}, Type()}, false, IsGlobal()));
|
AddAttrs(make_intrusive<Attributes>(attr, IntrusivePtr{NewRef{}, Type()}, false, IsGlobal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
string ID::GetDeprecationWarning() const
|
std::string ID::GetDeprecationWarning() const
|
||||||
{
|
{
|
||||||
string result;
|
std::string result;
|
||||||
Attr* depr_attr = FindAttr(ATTR_DEPRECATED);
|
Attr* depr_attr = FindAttr(ATTR_DEPRECATED);
|
||||||
if ( depr_attr )
|
if ( depr_attr )
|
||||||
{
|
{
|
||||||
|
@ -541,12 +541,12 @@ void ID::AddOptionHandler(IntrusivePtr<Func> callback, int priority)
|
||||||
option_handlers.emplace(priority, std::move(callback));
|
option_handlers.emplace(priority, std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Func*> ID::GetOptionHandlers() const
|
std::vector<Func*> ID::GetOptionHandlers() const
|
||||||
{
|
{
|
||||||
// multimap is sorted
|
// multimap is sorted
|
||||||
// It might be worth caching this if we expect it to be called
|
// It might be worth caching this if we expect it to be called
|
||||||
// a lot...
|
// a lot...
|
||||||
vector<Func*> v;
|
std::vector<Func*> v;
|
||||||
for ( auto& element : option_handlers )
|
for ( auto& element : option_handlers )
|
||||||
v.push_back(element.second.get());
|
v.push_back(element.second.get());
|
||||||
return v;
|
return v;
|
||||||
|
|
|
@ -153,7 +153,7 @@ void IPAddr::Init(const char* s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string IPAddr::AsString() const
|
std::string IPAddr::AsString() const
|
||||||
{
|
{
|
||||||
if ( GetFamily() == IPv4 )
|
if ( GetFamily() == IPv4 )
|
||||||
{
|
{
|
||||||
|
@ -175,7 +175,7 @@ string IPAddr::AsString() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string IPAddr::AsHexString() const
|
std::string IPAddr::AsHexString() const
|
||||||
{
|
{
|
||||||
char buf[33];
|
char buf[33];
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ string IPAddr::AsHexString() const
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
string IPAddr::PtrName() const
|
std::string IPAddr::PtrName() const
|
||||||
{
|
{
|
||||||
if ( GetFamily() == IPv4 )
|
if ( GetFamily() == IPv4 )
|
||||||
{
|
{
|
||||||
|
@ -212,7 +212,7 @@ string IPAddr::PtrName() const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static const char hex_digit[] = "0123456789abcdef";
|
static const char hex_digit[] = "0123456789abcdef";
|
||||||
string ptr_name("ip6.arpa");
|
std::string ptr_name("ip6.arpa");
|
||||||
uint32_t* p = (uint32_t*) in6.s6_addr;
|
uint32_t* p = (uint32_t*) in6.s6_addr;
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < 4; ++i )
|
for ( unsigned int i = 0; i < 4; ++i )
|
||||||
|
@ -290,7 +290,7 @@ IPPrefix::IPPrefix(const IPAddr& addr, uint8_t length, bool len_is_v6_relative)
|
||||||
prefix.Mask(this->length);
|
prefix.Mask(this->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
string IPPrefix::AsString() const
|
std::string IPPrefix::AsString() const
|
||||||
{
|
{
|
||||||
char l[16];
|
char l[16];
|
||||||
|
|
||||||
|
@ -317,10 +317,10 @@ HashKey* IPPrefix::GetHashKey() const
|
||||||
|
|
||||||
bool IPPrefix::ConvertString(const char* text, IPPrefix* result)
|
bool IPPrefix::ConvertString(const char* text, IPPrefix* result)
|
||||||
{
|
{
|
||||||
string s(text);
|
std::string s(text);
|
||||||
size_t slash_loc = s.find('/');
|
size_t slash_loc = s.find('/');
|
||||||
|
|
||||||
if ( slash_loc == string::npos )
|
if ( slash_loc == std::string::npos )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto ip_str = s.substr(0, slash_loc);
|
auto ip_str = s.substr(0, slash_loc);
|
||||||
|
|
|
@ -65,7 +65,7 @@ iosource::PktSrc* current_pktsrc = nullptr;
|
||||||
iosource::IOSource* current_iosrc = nullptr;
|
iosource::IOSource* current_iosrc = nullptr;
|
||||||
|
|
||||||
std::list<ScannedFile> files_scanned;
|
std::list<ScannedFile> files_scanned;
|
||||||
std::vector<string> sig_files;
|
std::vector<std::string> sig_files;
|
||||||
|
|
||||||
RETSIGTYPE watchdog(int /* signo */)
|
RETSIGTYPE watchdog(int /* signo */)
|
||||||
{
|
{
|
||||||
|
|
|
@ -777,7 +777,7 @@ bool BloomFilterVal::Empty() const
|
||||||
return bloom_filter->Empty();
|
return bloom_filter->Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
string BloomFilterVal::InternalState() const
|
std::string BloomFilterVal::InternalState() const
|
||||||
{
|
{
|
||||||
return bloom_filter->InternalState();
|
return bloom_filter->InternalState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,9 @@ void* PrefixTable::Insert(const Val* value, void* data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list<tuple<IPPrefix,void*>> PrefixTable::FindAll(const IPAddr& addr, int width) const
|
std::list<std::tuple<IPPrefix,void*>> PrefixTable::FindAll(const IPAddr& addr, int width) const
|
||||||
{
|
{
|
||||||
std::list<tuple<IPPrefix,void*>> out;
|
std::list<std::tuple<IPPrefix,void*>> out;
|
||||||
prefix_t* prefix = MakePrefix(addr, width);
|
prefix_t* prefix = MakePrefix(addr, width);
|
||||||
|
|
||||||
int elems = 0;
|
int elems = 0;
|
||||||
|
@ -81,7 +81,7 @@ list<tuple<IPPrefix,void*>> PrefixTable::FindAll(const IPAddr& addr, int width)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<tuple<IPPrefix,void*>> PrefixTable::FindAll(const SubNetVal* value) const
|
std::list<std::tuple<IPPrefix,void*>> PrefixTable::FindAll(const SubNetVal* value) const
|
||||||
{
|
{
|
||||||
return FindAll(value->AsSubNet().Prefix(), value->AsSubNet().LengthIPv6());
|
return FindAll(value->AsSubNet().Prefix(), value->AsSubNet().LengthIPv6());
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,13 +195,13 @@ bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Specific_RE_Matcher::LookupDef(const string& def)
|
std::string Specific_RE_Matcher::LookupDef(const std::string& def)
|
||||||
{
|
{
|
||||||
const auto& iter = defs.find(def);
|
const auto& iter = defs.find(def);
|
||||||
if ( iter != defs.end() )
|
if ( iter != defs.end() )
|
||||||
return iter->second;
|
return iter->second;
|
||||||
|
|
||||||
return string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Specific_RE_Matcher::MatchAll(const char* s)
|
bool Specific_RE_Matcher::MatchAll(const char* s)
|
||||||
|
|
|
@ -78,7 +78,7 @@ void Reporter::InitOptions()
|
||||||
while ( (v = wl_table->NextEntry(k, c)) )
|
while ( (v = wl_table->NextEntry(k, c)) )
|
||||||
{
|
{
|
||||||
auto index = wl_val->RecoverIndex(k);
|
auto index = wl_val->RecoverIndex(k);
|
||||||
string key = index->Index(0)->AsString()->CheckString();
|
std::string key = index->Index(0)->AsString()->CheckString();
|
||||||
weird_sampling_whitelist.emplace(move(key));
|
weird_sampling_whitelist.emplace(move(key));
|
||||||
delete k;
|
delete k;
|
||||||
}
|
}
|
||||||
|
@ -384,11 +384,11 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
|
||||||
char* buffer = tmp;
|
char* buffer = tmp;
|
||||||
char* alloced = 0;
|
char* alloced = 0;
|
||||||
|
|
||||||
string loc_str;
|
std::string loc_str;
|
||||||
|
|
||||||
if ( location )
|
if ( location )
|
||||||
{
|
{
|
||||||
string loc_file = "";
|
std::string loc_file = "";
|
||||||
int loc_line = 0;
|
int loc_line = 0;
|
||||||
|
|
||||||
if ( locations.size() )
|
if ( locations.size() )
|
||||||
|
@ -427,7 +427,7 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
|
||||||
loc_str = filename;
|
loc_str = filename;
|
||||||
char tmp[32];
|
char tmp[32];
|
||||||
snprintf(tmp, 32, "%d", line_number);
|
snprintf(tmp, 32, "%d", line_number);
|
||||||
loc_str += string(", line ") + string(tmp);
|
loc_str += std::string(", line ") + std::string(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,21 +514,21 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
|
||||||
|
|
||||||
if ( out )
|
if ( out )
|
||||||
{
|
{
|
||||||
string s = "";
|
std::string s = "";
|
||||||
|
|
||||||
if ( bro_start_network_time != 0.0 )
|
if ( bro_start_network_time != 0.0 )
|
||||||
{
|
{
|
||||||
char tmp[32];
|
char tmp[32];
|
||||||
snprintf(tmp, 32, "%.6f", network_time);
|
snprintf(tmp, 32, "%.6f", network_time);
|
||||||
s += string(tmp) + " ";
|
s += std::string(tmp) + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( prefix && *prefix )
|
if ( prefix && *prefix )
|
||||||
{
|
{
|
||||||
if ( loc_str != "" )
|
if ( loc_str != "" )
|
||||||
s += string(prefix) + " in " + loc_str + ": ";
|
s += std::string(prefix) + " in " + loc_str + ": ";
|
||||||
else
|
else
|
||||||
s += string(prefix) + ": ";
|
s += std::string(prefix) + ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
#include "module_util.h"
|
#include "module_util.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
// FIXME: Things that are not fully implemented/working yet:
|
// FIXME: Things that are not fully implemented/working yet:
|
||||||
//
|
//
|
||||||
// - "ip-options" always evaluates to false
|
// - "ip-options" always evaluates to false
|
||||||
|
|
|
@ -121,9 +121,9 @@ IntrusivePtr<ID> lookup_ID(const char* name, const char* curr_module,
|
||||||
bool no_global, bool same_module_only,
|
bool no_global, bool same_module_only,
|
||||||
bool check_export)
|
bool check_export)
|
||||||
{
|
{
|
||||||
string fullname = make_full_var_name(curr_module, name);
|
std::string fullname = make_full_var_name(curr_module, name);
|
||||||
|
|
||||||
string ID_module = extract_module_name(fullname.c_str());
|
std::string ID_module = extract_module_name(fullname.c_str());
|
||||||
bool need_export = check_export && (ID_module != GLOBAL_MODULE_NAME &&
|
bool need_export = check_export && (ID_module != GLOBAL_MODULE_NAME &&
|
||||||
ID_module != curr_module);
|
ID_module != curr_module);
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ IntrusivePtr<ID> lookup_ID(const char* name, const char* curr_module,
|
||||||
if ( ! no_global && (strcmp(GLOBAL_MODULE_NAME, curr_module) == 0 ||
|
if ( ! no_global && (strcmp(GLOBAL_MODULE_NAME, curr_module) == 0 ||
|
||||||
! same_module_only) )
|
! same_module_only) )
|
||||||
{
|
{
|
||||||
string globalname = make_full_var_name(GLOBAL_MODULE_NAME, name);
|
std::string globalname = make_full_var_name(GLOBAL_MODULE_NAME, name);
|
||||||
ID* id = global_scope()->Lookup(globalname);
|
ID* id = global_scope()->Lookup(globalname);
|
||||||
if ( id )
|
if ( id )
|
||||||
return {NewRef{}, id};
|
return {NewRef{}, id};
|
||||||
|
@ -168,7 +168,7 @@ IntrusivePtr<ID> install_ID(const char* name, const char* module_name,
|
||||||
else
|
else
|
||||||
scope = SCOPE_FUNCTION;
|
scope = SCOPE_FUNCTION;
|
||||||
|
|
||||||
string full_name = make_full_var_name(module_name, name);
|
std::string full_name = make_full_var_name(module_name, name);
|
||||||
|
|
||||||
auto id = make_intrusive<ID>(full_name.data(), scope, is_export);
|
auto id = make_intrusive<ID>(full_name.data(), scope, is_export);
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ bool BinarySerializationFormat::Read(char** str, int* len, const char* tag)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinarySerializationFormat::Read(string* v, const char* tag)
|
bool BinarySerializationFormat::Read(std::string* v, const char* tag)
|
||||||
{
|
{
|
||||||
char* buffer;
|
char* buffer;
|
||||||
int len;
|
int len;
|
||||||
|
@ -227,7 +227,7 @@ bool BinarySerializationFormat::Read(string* v, const char* tag)
|
||||||
if ( ! Read(&buffer, &len, tag) )
|
if ( ! Read(&buffer, &len, tag) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*v = string(buffer, len);
|
*v = std::string(buffer, len);
|
||||||
|
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
return true;
|
return true;
|
||||||
|
@ -362,7 +362,7 @@ bool BinarySerializationFormat::Write(const char* s, const char* tag)
|
||||||
return Write(s, strlen(s), tag);
|
return Write(s, strlen(s), tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinarySerializationFormat::Write(const string& s, const char* tag)
|
bool BinarySerializationFormat::Write(const std::string& s, const char* tag)
|
||||||
{
|
{
|
||||||
return Write(s.data(), s.size(), tag);
|
return Write(s.data(), s.size(), tag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1196,7 +1196,7 @@ Connection* NetSessions::LookupConn(const ConnectionMap& conns, const ConnIDKey&
|
||||||
bool NetSessions::IsLikelyServerPort(uint32_t port, TransportProto proto) const
|
bool NetSessions::IsLikelyServerPort(uint32_t port, TransportProto proto) const
|
||||||
{
|
{
|
||||||
// We keep a cached in-core version of the table to speed up the lookup.
|
// We keep a cached in-core version of the table to speed up the lookup.
|
||||||
static set<bro_uint_t> port_cache;
|
static std::set<bro_uint_t> port_cache;
|
||||||
static bool have_cache = false;
|
static bool have_cache = false;
|
||||||
|
|
||||||
if ( ! have_cache )
|
if ( ! have_cache )
|
||||||
|
|
|
@ -221,9 +221,9 @@ protected:
|
||||||
|
|
||||||
SessionStats stats;
|
SessionStats stats;
|
||||||
|
|
||||||
typedef pair<IPAddr, IPAddr> IPPair;
|
using IPPair = std::pair<IPAddr, IPAddr>;
|
||||||
typedef pair<EncapsulatingConn, double> TunnelActivity;
|
using TunnelActivity = std::pair<EncapsulatingConn, double>;
|
||||||
typedef std::map<IPPair, TunnelActivity> IPTunnelMap;
|
using IPTunnelMap = std::map<IPPair, TunnelActivity>;
|
||||||
IPTunnelMap ip_tunnels;
|
IPTunnelMap ip_tunnels;
|
||||||
|
|
||||||
analyzer::arp::ARP_Analyzer* arp_analyzer;
|
analyzer::arp::ARP_Analyzer* arp_analyzer;
|
||||||
|
|
|
@ -143,7 +143,7 @@ BroSubstring::Vec* BroSubstring::VecFromPolicy(VectorVal* vec)
|
||||||
|
|
||||||
char* BroSubstring::VecToString(Vec* vec)
|
char* BroSubstring::VecToString(Vec* vec)
|
||||||
{
|
{
|
||||||
string result("[");
|
std::string result("[");
|
||||||
|
|
||||||
for ( BroSubstring::VecIt it = vec->begin(); it != vec->end(); ++it )
|
for ( BroSubstring::VecIt it = vec->begin(); it != vec->end(); ++it )
|
||||||
{
|
{
|
||||||
|
@ -276,7 +276,7 @@ private:
|
||||||
static void sw_collect_single(BroSubstring::Vec* result, SWNodeMatrix& matrix,
|
static void sw_collect_single(BroSubstring::Vec* result, SWNodeMatrix& matrix,
|
||||||
SWNode* node, SWParams& params)
|
SWNode* node, SWParams& params)
|
||||||
{
|
{
|
||||||
string substring("");
|
std::string substring("");
|
||||||
int row = 0, col = 0;
|
int row = 0, col = 0;
|
||||||
|
|
||||||
while ( node )
|
while ( node )
|
||||||
|
@ -340,7 +340,7 @@ static void sw_collect_single(BroSubstring::Vec* result, SWNodeMatrix& matrix,
|
||||||
static void sw_collect_multiple(BroSubstring::Vec* result,
|
static void sw_collect_multiple(BroSubstring::Vec* result,
|
||||||
SWNodeMatrix& matrix, SWParams& params)
|
SWNodeMatrix& matrix, SWParams& params)
|
||||||
{
|
{
|
||||||
vector<BroSubstring::Vec*> als;
|
std::vector<BroSubstring::Vec*> als;
|
||||||
|
|
||||||
for ( int i = matrix.GetHeight() - 1; i > 0; --i )
|
for ( int i = matrix.GetHeight() - 1; i > 0; --i )
|
||||||
{
|
{
|
||||||
|
@ -354,7 +354,7 @@ static void sw_collect_multiple(BroSubstring::Vec* result,
|
||||||
BroSubstring::Vec* new_al = new BroSubstring::Vec();
|
BroSubstring::Vec* new_al = new BroSubstring::Vec();
|
||||||
sw_collect_single(new_al, matrix, node, params);
|
sw_collect_single(new_al, matrix, node, params);
|
||||||
|
|
||||||
for ( vector<BroSubstring::Vec*>::iterator it = als.begin();
|
for ( std::vector<BroSubstring::Vec*>::iterator it = als.begin();
|
||||||
it != als.end(); ++it )
|
it != als.end(); ++it )
|
||||||
{
|
{
|
||||||
BroSubstring::Vec* old_al = *it;
|
BroSubstring::Vec* old_al = *it;
|
||||||
|
@ -393,7 +393,7 @@ end_loop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( vector<BroSubstring::Vec*>::iterator it = als.begin();
|
for ( std::vector<BroSubstring::Vec*>::iterator it = als.begin();
|
||||||
it != als.end(); ++it )
|
it != als.end(); ++it )
|
||||||
{
|
{
|
||||||
BroSubstring::Vec* al = *it;
|
BroSubstring::Vec* al = *it;
|
||||||
|
@ -506,7 +506,7 @@ BroSubstring::Vec* smith_waterman(const BroString* s1, const BroString* s2,
|
||||||
if ( current->swn_byte_assigned )
|
if ( current->swn_byte_assigned )
|
||||||
current->swn_score = score_tl;
|
current->swn_score = score_tl;
|
||||||
else
|
else
|
||||||
current->swn_score = max(max(score_t, score_l), score_tl);
|
current->swn_score = std::max(std::max(score_t, score_l), score_tl);
|
||||||
|
|
||||||
// Establish predecessor chain according to neighbor
|
// Establish predecessor chain according to neighbor
|
||||||
// with best score.
|
// with best score.
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
BroType::TypeAliasMap BroType::type_aliases;
|
BroType::TypeAliasMap BroType::type_aliases;
|
||||||
|
|
||||||
// Note: This function must be thread-safe.
|
// Note: This function must be thread-safe.
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
|
|
||||||
#include "threading/formatters/JSON.h"
|
#include "threading/formatters/JSON.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
Val::Val(Func* f)
|
Val::Val(Func* f)
|
||||||
: val(f), type(f->FType()->Ref())
|
: val(f), type(f->FType()->Ref())
|
||||||
{
|
{
|
||||||
|
|
|
@ -272,8 +272,8 @@ extern IntrusivePtr<Expr> add_and_assign_local(IntrusivePtr<ID> id,
|
||||||
|
|
||||||
void add_type(ID* id, IntrusivePtr<BroType> t, attr_list* attr)
|
void add_type(ID* id, IntrusivePtr<BroType> t, attr_list* attr)
|
||||||
{
|
{
|
||||||
string new_type_name = id->Name();
|
std::string new_type_name = id->Name();
|
||||||
string old_type_name = t->GetName();
|
std::string old_type_name = t->GetName();
|
||||||
IntrusivePtr<BroType> tnew;
|
IntrusivePtr<BroType> tnew;
|
||||||
|
|
||||||
if ( (t->Tag() == TYPE_RECORD || t->Tag() == TYPE_ENUM) &&
|
if ( (t->Tag() == TYPE_RECORD || t->Tag() == TYPE_ENUM) &&
|
||||||
|
@ -427,7 +427,7 @@ public:
|
||||||
TraversalCode PostExpr(const Expr*) override;
|
TraversalCode PostExpr(const Expr*) override;
|
||||||
|
|
||||||
std::vector<Scope*> scopes;
|
std::vector<Scope*> scopes;
|
||||||
vector<const NameExpr*> outer_id_references;
|
std::vector<const NameExpr*> outer_id_references;
|
||||||
};
|
};
|
||||||
|
|
||||||
TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
||||||
|
|
|
@ -108,8 +108,8 @@ void Manager::DumpDebug()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
DBG_LOG(DBG_ANALYZER, "Available analyzers after zeek_init():");
|
DBG_LOG(DBG_ANALYZER, "Available analyzers after zeek_init():");
|
||||||
list<Component*> all_analyzers = GetComponents();
|
std::list<Component*> all_analyzers = GetComponents();
|
||||||
for ( list<Component*>::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i )
|
for ( std::list<Component*>::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i )
|
||||||
DBG_LOG(DBG_ANALYZER, " %s (%s)", (*i)->Name().c_str(),
|
DBG_LOG(DBG_ANALYZER, " %s (%s)", (*i)->Name().c_str(),
|
||||||
IsEnabled((*i)->Tag()) ? "enabled" : "disabled");
|
IsEnabled((*i)->Tag()) ? "enabled" : "disabled");
|
||||||
|
|
||||||
|
@ -118,20 +118,20 @@ void Manager::DumpDebug()
|
||||||
|
|
||||||
for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_tcp.begin(); i != analyzers_by_port_tcp.end(); i++ )
|
for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_tcp.begin(); i != analyzers_by_port_tcp.end(); i++ )
|
||||||
{
|
{
|
||||||
string s;
|
std::string s;
|
||||||
|
|
||||||
for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ )
|
for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ )
|
||||||
s += string(GetComponentName(*j)) + " ";
|
s += std::string(GetComponentName(*j)) + " ";
|
||||||
|
|
||||||
DBG_LOG(DBG_ANALYZER, " %d/tcp: %s", i->first, s.c_str());
|
DBG_LOG(DBG_ANALYZER, " %d/tcp: %s", i->first, s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_udp.begin(); i != analyzers_by_port_udp.end(); i++ )
|
for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_udp.begin(); i != analyzers_by_port_udp.end(); i++ )
|
||||||
{
|
{
|
||||||
string s;
|
std::string s;
|
||||||
|
|
||||||
for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ )
|
for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ )
|
||||||
s += string(GetComponentName(*j)) + " ";
|
s += std::string(GetComponentName(*j)) + " ";
|
||||||
|
|
||||||
DBG_LOG(DBG_ANALYZER, " %d/udp: %s", i->first, s.c_str());
|
DBG_LOG(DBG_ANALYZER, " %d/udp: %s", i->first, s.c_str());
|
||||||
}
|
}
|
||||||
|
@ -199,8 +199,8 @@ void Manager::DisableAllAnalyzers()
|
||||||
{
|
{
|
||||||
DBG_LOG(DBG_ANALYZER, "Disabling all analyzers");
|
DBG_LOG(DBG_ANALYZER, "Disabling all analyzers");
|
||||||
|
|
||||||
list<Component*> all_analyzers = GetComponents();
|
std::list<Component*> all_analyzers = GetComponents();
|
||||||
for ( list<Component*>::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i )
|
for ( std::list<Component*>::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i )
|
||||||
(*i)->SetEnabled(false);
|
(*i)->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,8 +342,9 @@ public:
|
||||||
{ return vxlan_ports; }
|
{ return vxlan_ports; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef set<Tag> tag_set;
|
|
||||||
typedef map<uint32_t, tag_set*> analyzer_map_by_port;
|
using tag_set = std::set<Tag>;
|
||||||
|
using analyzer_map_by_port = std::map<uint32_t, tag_set*>;
|
||||||
|
|
||||||
tag_set* LookupPort(PortVal* val, bool add_if_not_found);
|
tag_set* LookupPort(PortVal* val, bool add_if_not_found);
|
||||||
tag_set* LookupPort(TransportProto proto, uint32_t port, bool add_if_not_found);
|
tag_set* LookupPort(TransportProto proto, uint32_t port, bool add_if_not_found);
|
||||||
|
@ -387,10 +388,10 @@ private:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::multimap<ConnIndex, ScheduledAnalyzer*> conns_map;
|
using conns_map = std::multimap<ConnIndex, ScheduledAnalyzer*>;
|
||||||
typedef std::priority_queue<ScheduledAnalyzer*,
|
using conns_queue = std::priority_queue<ScheduledAnalyzer*,
|
||||||
vector<ScheduledAnalyzer*>,
|
std::vector<ScheduledAnalyzer*>,
|
||||||
ScheduledAnalyzer::Comparator> conns_queue;
|
ScheduledAnalyzer::Comparator>;
|
||||||
|
|
||||||
conns_map conns;
|
conns_map conns;
|
||||||
conns_queue conns_by_timeout;
|
conns_queue conns_by_timeout;
|
||||||
|
|
|
@ -745,7 +745,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void)
|
||||||
if ( benc_str_have < benc_str_len )
|
if ( benc_str_have < benc_str_len )
|
||||||
{
|
{
|
||||||
unsigned int seek =
|
unsigned int seek =
|
||||||
min(len, benc_str_len - benc_str_have);
|
std::min(len, benc_str_len - benc_str_have);
|
||||||
benc_str_have += seek;
|
benc_str_have += seek;
|
||||||
|
|
||||||
if ( benc_raw_type != BENC_TYPE_NONE )
|
if ( benc_raw_type != BENC_TYPE_NONE )
|
||||||
|
|
|
@ -106,8 +106,8 @@ protected:
|
||||||
TableVal* res_val_peers;
|
TableVal* res_val_peers;
|
||||||
TableVal* res_val_benc;
|
TableVal* res_val_benc;
|
||||||
|
|
||||||
vector<char> benc_stack;
|
std::vector<char> benc_stack;
|
||||||
vector<unsigned int> benc_count;
|
std::vector<unsigned int> benc_count;
|
||||||
enum btt_benc_states benc_state;
|
enum btt_benc_states benc_state;
|
||||||
|
|
||||||
char* benc_raw;
|
char* benc_raw;
|
||||||
|
|
|
@ -21,7 +21,7 @@ void File_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
|
||||||
{
|
{
|
||||||
tcp::TCP_ApplicationAnalyzer::DeliverStream(len, data, orig);
|
tcp::TCP_ApplicationAnalyzer::DeliverStream(len, data, orig);
|
||||||
|
|
||||||
int n = min(len, BUFFER_SIZE - buffer_len);
|
int n = std::min(len, BUFFER_SIZE - buffer_len);
|
||||||
|
|
||||||
if ( n )
|
if ( n )
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ void File_Analyzer::Identify()
|
||||||
RuleMatcher::MIME_Matches matches;
|
RuleMatcher::MIME_Matches matches;
|
||||||
file_mgr->DetectMIME(reinterpret_cast<const u_char*>(buffer), buffer_len,
|
file_mgr->DetectMIME(reinterpret_cast<const u_char*>(buffer), buffer_len,
|
||||||
&matches);
|
&matches);
|
||||||
string match = matches.empty() ? "<unknown>"
|
std::string match = matches.empty() ? "<unknown>"
|
||||||
: *(matches.begin()->second.begin());
|
: *(matches.begin()->second.begin());
|
||||||
|
|
||||||
if ( file_transferred )
|
if ( file_transferred )
|
||||||
|
|
|
@ -27,8 +27,8 @@ protected:
|
||||||
static const int BUFFER_SIZE = 1024;
|
static const int BUFFER_SIZE = 1024;
|
||||||
char buffer[BUFFER_SIZE];
|
char buffer[BUFFER_SIZE];
|
||||||
int buffer_len;
|
int buffer_len;
|
||||||
string file_id_orig;
|
std::string file_id_orig;
|
||||||
string file_id_resp;
|
std::string file_id_resp;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IRC_Data : public File_Analyzer {
|
class IRC_Data : public File_Analyzer {
|
||||||
|
|
|
@ -107,7 +107,7 @@ void FTP_Analyzer::DeliverStream(int length, const u_char* data, bool orig)
|
||||||
|
|
||||||
if ( strncmp((const char*) cmd_str->Bytes(),
|
if ( strncmp((const char*) cmd_str->Bytes(),
|
||||||
"AUTH", cmd_len) == 0 )
|
"AUTH", cmd_len) == 0 )
|
||||||
auth_requested = string(line, end_of_line - line);
|
auth_requested = std::string(line, end_of_line - line);
|
||||||
|
|
||||||
if ( rule_matcher )
|
if ( rule_matcher )
|
||||||
Conn()->Match(Rule::FTP, (const u_char *) cmd,
|
Conn()->Match(Rule::FTP, (const u_char *) cmd,
|
||||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
||||||
login::NVT_Analyzer* nvt_orig;
|
login::NVT_Analyzer* nvt_orig;
|
||||||
login::NVT_Analyzer* nvt_resp;
|
login::NVT_Analyzer* nvt_resp;
|
||||||
uint32_t pending_reply; // code associated with multi-line reply, or 0
|
uint32_t pending_reply; // code associated with multi-line reply, or 0
|
||||||
string auth_requested; // AUTH method requested
|
std::string auth_requested; // AUTH method requested
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -86,7 +86,7 @@ static Val* parse_eftp(const char* line)
|
||||||
good = 0;
|
good = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
string s(line, nptr-line); // extract IP address
|
std::string s(line, nptr-line); // extract IP address
|
||||||
IPAddr tmp(s);
|
IPAddr tmp(s);
|
||||||
// on error, "tmp" will have all 128 bits zero
|
// on error, "tmp" will have all 128 bits zero
|
||||||
if ( tmp == addr )
|
if ( tmp == addr )
|
||||||
|
|
|
@ -112,9 +112,9 @@ bool Gnutella_Analyzer::NextLine(const u_char* data, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Gnutella_Analyzer::IsHTTP(string header)
|
bool Gnutella_Analyzer::IsHTTP(std::string header)
|
||||||
{
|
{
|
||||||
if ( header.find(" HTTP/1.") == string::npos )
|
if ( header.find(" HTTP/1.") == std::string::npos )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( gnutella_http_notify )
|
if ( gnutella_http_notify )
|
||||||
|
@ -139,7 +139,7 @@ bool Gnutella_Analyzer::IsHTTP(string header)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Gnutella_Analyzer::GnutellaOK(string header)
|
bool Gnutella_Analyzer::GnutellaOK(std::string header)
|
||||||
{
|
{
|
||||||
if ( strncmp("GNUTELLA", header.data(), 8) )
|
if ( strncmp("GNUTELLA", header.data(), 8) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -223,7 +223,7 @@ void Gnutella_Analyzer::SendEvents(GnutellaMsgState* p, bool is_orig)
|
||||||
IntrusivePtr{AdoptRef{}, val_mgr->GetCount(p->msg_len)},
|
IntrusivePtr{AdoptRef{}, val_mgr->GetCount(p->msg_len)},
|
||||||
make_intrusive<StringVal>(p->payload),
|
make_intrusive<StringVal>(p->payload),
|
||||||
IntrusivePtr{AdoptRef{}, val_mgr->GetCount(p->payload_len)},
|
IntrusivePtr{AdoptRef{}, val_mgr->GetCount(p->payload_len)},
|
||||||
IntrusivePtr{AdoptRef{}, val_mgr->GetBool((p->payload_len < min(p->msg_len, (unsigned int)GNUTELLA_MAX_PAYLOAD)))},
|
IntrusivePtr{AdoptRef{}, val_mgr->GetBool((p->payload_len < std::min(p->msg_len, (unsigned int)GNUTELLA_MAX_PAYLOAD)))},
|
||||||
IntrusivePtr{AdoptRef{}, val_mgr->GetBool((p->payload_left == 0))}
|
IntrusivePtr{AdoptRef{}, val_mgr->GetBool((p->payload_left == 0))}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@ class GnutellaMsgState {
|
||||||
public:
|
public:
|
||||||
GnutellaMsgState ();
|
GnutellaMsgState ();
|
||||||
|
|
||||||
string buffer;
|
std::string buffer;
|
||||||
int current_offset;
|
int current_offset;
|
||||||
int got_CR;
|
int got_CR;
|
||||||
string headers;
|
std::string headers;
|
||||||
char msg[GNUTELLA_MSG_SIZE];
|
char msg[GNUTELLA_MSG_SIZE];
|
||||||
u_char msg_hops;
|
u_char msg_hops;
|
||||||
unsigned int msg_len;
|
unsigned int msg_len;
|
||||||
|
@ -47,8 +47,8 @@ public:
|
||||||
private:
|
private:
|
||||||
bool NextLine(const u_char* data, int len);
|
bool NextLine(const u_char* data, int len);
|
||||||
|
|
||||||
bool GnutellaOK(string header);
|
bool GnutellaOK(std::string header);
|
||||||
bool IsHTTP(string header);
|
bool IsHTTP(std::string header);
|
||||||
|
|
||||||
bool Established() const { return state == (ORIG_OK | RESP_OK); }
|
bool Established() const { return state == (ORIG_OK | RESP_OK); }
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data,
|
||||||
// caplen > len.
|
// caplen > len.
|
||||||
if ( packet_contents )
|
if ( packet_contents )
|
||||||
// Subtract off the common part of ICMP header.
|
// Subtract off the common part of ICMP header.
|
||||||
PacketContents(data + 8, min(len, caplen) - 8);
|
PacketContents(data + 8, std::min(len, caplen) - 8);
|
||||||
|
|
||||||
const struct icmp* icmpp = (const struct icmp*) data;
|
const struct icmp* icmpp = (const struct icmp*) data;
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ void ICMP_Analyzer::ICMP_Sent(const struct icmp* icmpp, int len, int caplen,
|
||||||
|
|
||||||
if ( icmp_sent_payload )
|
if ( icmp_sent_payload )
|
||||||
{
|
{
|
||||||
BroString* payload = new BroString(data, min(len, caplen), false);
|
BroString* payload = new BroString(data, std::min(len, caplen), false);
|
||||||
|
|
||||||
EnqueueConnEvent(icmp_sent_payload,
|
EnqueueConnEvent(icmp_sent_payload,
|
||||||
IntrusivePtr{AdoptRef{}, BuildConnVal()},
|
IntrusivePtr{AdoptRef{}, BuildConnVal()},
|
||||||
|
@ -841,7 +841,7 @@ VectorVal* ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data)
|
||||||
|
|
||||||
if ( set_payload_field )
|
if ( set_payload_field )
|
||||||
{
|
{
|
||||||
BroString* payload = new BroString(data, min((int)length, caplen), false);
|
BroString* payload = new BroString(data, std::min((int)length, caplen), false);
|
||||||
rv->Assign(6, make_intrusive<StringVal>(payload));
|
rv->Assign(6, make_intrusive<StringVal>(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "events.bif.h"
|
#include "events.bif.h"
|
||||||
|
|
||||||
using namespace analyzer::irc;
|
using namespace analyzer::irc;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
IRC_Analyzer::IRC_Analyzer(Connection* conn)
|
IRC_Analyzer::IRC_Analyzer(Connection* conn)
|
||||||
: tcp::TCP_ApplicationAnalyzer("IRC", conn)
|
: tcp::TCP_ApplicationAnalyzer("IRC", conn)
|
||||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void StartTLS();
|
void StartTLS();
|
||||||
|
|
||||||
inline void SkipLeadingWhitespace(string& str);
|
inline void SkipLeadingWhitespace(std::string& str);
|
||||||
|
|
||||||
/** \brief counts number of invalid IRC messages */
|
/** \brief counts number of invalid IRC messages */
|
||||||
int invalid_msg_count;
|
int invalid_msg_count;
|
||||||
|
@ -62,7 +62,7 @@ private:
|
||||||
* \param split character which separates the words
|
* \param split character which separates the words
|
||||||
* \return vector containing words
|
* \return vector containing words
|
||||||
*/
|
*/
|
||||||
vector<string> SplitWords(const string& input, char split);
|
std::vector<std::string> SplitWords(const std::string& input, char split);
|
||||||
|
|
||||||
tcp::ContentLine_Analyzer* cl_orig;
|
tcp::ContentLine_Analyzer* cl_orig;
|
||||||
tcp::ContentLine_Analyzer* cl_resp;
|
tcp::ContentLine_Analyzer* cl_resp;
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ void MIME_Entity::DataOctets(int len, const char* data)
|
||||||
if ( data_buf_offset < 0 && ! GetDataBuffer() )
|
if ( data_buf_offset < 0 && ! GetDataBuffer() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int n = min(data_buf_length - data_buf_offset, len);
|
int n = std::min(data_buf_length - data_buf_offset, len);
|
||||||
memcpy(data_buf_data + data_buf_offset, data, n);
|
memcpy(data_buf_data + data_buf_offset, data, n);
|
||||||
data += n;
|
data += n;
|
||||||
data_buf_offset += n;
|
data_buf_offset += n;
|
||||||
|
|
|
@ -86,7 +86,7 @@ void POP3_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
|
||||||
ProcessReply(len, (char*) terminated_string.Bytes());
|
ProcessReply(len, (char*) terminated_string.Bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
static string trim_whitespace(const char* in)
|
static std::string trim_whitespace(const char* in)
|
||||||
{
|
{
|
||||||
int n = strlen(in);
|
int n = strlen(in);
|
||||||
char* out = new char[n + 1];
|
char* out = new char[n + 1];
|
||||||
|
@ -121,7 +121,7 @@ static string trim_whitespace(const char* in)
|
||||||
|
|
||||||
*out_p = 0;
|
*out_p = 0;
|
||||||
|
|
||||||
string rval(out);
|
std::string rval(out);
|
||||||
delete [] out;
|
delete [] out;
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line)
|
||||||
// Some clients pipeline their commands (i.e., keep sending
|
// Some clients pipeline their commands (i.e., keep sending
|
||||||
// without waiting for a server's responses). Therefore we
|
// without waiting for a server's responses). Therefore we
|
||||||
// keep a list of pending commands.
|
// keep a list of pending commands.
|
||||||
cmds.push_back(string(line));
|
cmds.push_back(std::string(line));
|
||||||
|
|
||||||
if ( cmds.size() == 1 )
|
if ( cmds.size() == 1 )
|
||||||
// Not waiting for another server response,
|
// Not waiting for another server response,
|
||||||
|
@ -241,7 +241,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static string commands[] = {
|
static std::string commands[] = {
|
||||||
"OK", "ERR", "USER", "PASS", "APOP", "AUTH",
|
"OK", "ERR", "USER", "PASS", "APOP", "AUTH",
|
||||||
"STAT", "LIST", "RETR", "DELE", "RSET", "NOOP", "LAST", "QUIT",
|
"STAT", "LIST", "RETR", "DELE", "RSET", "NOOP", "LAST", "QUIT",
|
||||||
"TOP", "CAPA", "UIDL", "STLS", "XSENDER",
|
"TOP", "CAPA", "UIDL", "STLS", "XSENDER",
|
||||||
|
@ -258,8 +258,8 @@ void POP3_Analyzer::ProcessClientCmd()
|
||||||
if ( ! cmds.size() )
|
if ( ! cmds.size() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string str = trim_whitespace(cmds.front().c_str());
|
std::string str = trim_whitespace(cmds.front().c_str());
|
||||||
vector<string> tokens = TokenizeLine(str, ' ');
|
std::vector<std::string> tokens = TokenizeLine(str, ' ');
|
||||||
|
|
||||||
int cmd_code = -1;
|
int cmd_code = -1;
|
||||||
const char* cmd = "";
|
const char* cmd = "";
|
||||||
|
@ -593,7 +593,7 @@ void POP3_Analyzer::FinishClientCmd()
|
||||||
void POP3_Analyzer::ProcessReply(int length, const char* line)
|
void POP3_Analyzer::ProcessReply(int length, const char* line)
|
||||||
{
|
{
|
||||||
const char* end_of_line = line + length;
|
const char* end_of_line = line + length;
|
||||||
string str = trim_whitespace(line);
|
std::string str = trim_whitespace(line);
|
||||||
|
|
||||||
if ( multiLine == true )
|
if ( multiLine == true )
|
||||||
{
|
{
|
||||||
|
@ -631,7 +631,7 @@ void POP3_Analyzer::ProcessReply(int length, const char* line)
|
||||||
int cmd_code = -1;
|
int cmd_code = -1;
|
||||||
const char* cmd = "";
|
const char* cmd = "";
|
||||||
|
|
||||||
vector<string> tokens = TokenizeLine(str, ' ');
|
std::vector<std::string> tokens = TokenizeLine(str, ' ');
|
||||||
if ( tokens.size() > 0 )
|
if ( tokens.size() > 0 )
|
||||||
cmd_code = ParseCmd(tokens[0]);
|
cmd_code = ParseCmd(tokens[0]);
|
||||||
|
|
||||||
|
@ -863,7 +863,7 @@ void POP3_Analyzer::ProcessData(int length, const char* line)
|
||||||
mail->Deliver(length, line, true);
|
mail->Deliver(length, line, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int POP3_Analyzer::ParseCmd(string cmd)
|
int POP3_Analyzer::ParseCmd(std::string cmd)
|
||||||
{
|
{
|
||||||
if ( cmd.size() == 0 )
|
if ( cmd.size() == 0 )
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -884,18 +884,18 @@ int POP3_Analyzer::ParseCmd(string cmd)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> POP3_Analyzer::TokenizeLine(const string& input, char split)
|
std::vector<std::string> POP3_Analyzer::TokenizeLine(const std::string& input, char split)
|
||||||
{
|
{
|
||||||
vector<string> tokens;
|
std::vector<std::string> tokens;
|
||||||
|
|
||||||
if ( input.size() < 1 )
|
if ( input.size() < 1 )
|
||||||
return tokens;
|
return tokens;
|
||||||
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
unsigned int splitPos = 0;
|
unsigned int splitPos = 0;
|
||||||
string token = "";
|
std::string token = "";
|
||||||
|
|
||||||
if ( input.find(split, 0) == string::npos )
|
if ( input.find(split, 0) == std::string::npos )
|
||||||
{
|
{
|
||||||
tokens.push_back(input);
|
tokens.push_back(input);
|
||||||
return tokens;
|
return tokens;
|
||||||
|
|
|
@ -86,8 +86,8 @@ protected:
|
||||||
int lastRequiredCommand;
|
int lastRequiredCommand;
|
||||||
int authLines;
|
int authLines;
|
||||||
|
|
||||||
string user;
|
std::string user;
|
||||||
string password;
|
std::string password;
|
||||||
|
|
||||||
void ProcessRequest(int length, const char* line);
|
void ProcessRequest(int length, const char* line);
|
||||||
void ProcessReply(int length, const char* line);
|
void ProcessReply(int length, const char* line);
|
||||||
|
@ -99,14 +99,14 @@ protected:
|
||||||
void EndData();
|
void EndData();
|
||||||
void StartTLS();
|
void StartTLS();
|
||||||
|
|
||||||
vector<string> TokenizeLine(const string& input, char split);
|
std::vector<std::string> TokenizeLine(const std::string& input, char split);
|
||||||
int ParseCmd(string cmd);
|
int ParseCmd(std::string cmd);
|
||||||
void AuthSuccessfull();
|
void AuthSuccessfull();
|
||||||
void POP3Event(EventHandlerPtr event, bool is_orig,
|
void POP3Event(EventHandlerPtr event, bool is_orig,
|
||||||
const char* arg1 = 0, const char* arg2 = 0);
|
const char* arg1 = 0, const char* arg2 = 0);
|
||||||
|
|
||||||
mime::MIME_Mail* mail;
|
mime::MIME_Mail* mail;
|
||||||
list<string> cmds;
|
std::list<std::string> cmds;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool tls;
|
bool tls;
|
||||||
|
|
|
@ -309,8 +309,8 @@ StringVal* NFS_Interp::nfs3_file_data(const u_char*& buf, int& n, uint64_t offse
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Ok, so we want to return some data
|
// Ok, so we want to return some data
|
||||||
data_n = min(data_n, size);
|
data_n = std::min(data_n, size);
|
||||||
data_n = min(data_n, int(BifConst::NFS3::return_data_max));
|
data_n = std::min(data_n, int(BifConst::NFS3::return_data_max));
|
||||||
|
|
||||||
if ( data && data_n > 0 )
|
if ( data && data_n > 0 )
|
||||||
return new StringVal(new BroString(data, data_n, false));
|
return new StringVal(new BroString(data, data_n, false));
|
||||||
|
|
|
@ -394,14 +394,14 @@ bool RPC_Reasm_Buffer::ConsumeChunk(const u_char*& data, int& len)
|
||||||
// How many bytes do we want to process with this call? Either the
|
// How many bytes do we want to process with this call? Either the
|
||||||
// all of the bytes available or the number of bytes that we are
|
// all of the bytes available or the number of bytes that we are
|
||||||
// still missing.
|
// still missing.
|
||||||
int64_t to_process = min(int64_t(len), (expected-processed));
|
int64_t to_process = std::min(int64_t(len), (expected-processed));
|
||||||
|
|
||||||
if ( fill < maxsize )
|
if ( fill < maxsize )
|
||||||
{
|
{
|
||||||
// We haven't yet filled the buffer. How many bytes to copy
|
// We haven't yet filled the buffer. How many bytes to copy
|
||||||
// into the buff. Either all of the bytes we want to process
|
// into the buff. Either all of the bytes we want to process
|
||||||
// or the number of bytes until we reach maxsize.
|
// or the number of bytes until we reach maxsize.
|
||||||
int64_t to_copy = min( to_process, (maxsize-fill) );
|
int64_t to_copy = std::min( to_process, (maxsize-fill) );
|
||||||
if ( to_copy )
|
if ( to_copy )
|
||||||
memcpy(buf+fill, data, to_copy);
|
memcpy(buf+fill, data, to_copy);
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ void RPC_Analyzer::DeliverPacket(int len, const u_char* data, bool orig,
|
||||||
uint64_t seq, const IP_Hdr* ip, int caplen)
|
uint64_t seq, const IP_Hdr* ip, int caplen)
|
||||||
{
|
{
|
||||||
tcp::TCP_ApplicationAnalyzer::DeliverPacket(len, data, orig, seq, ip, caplen);
|
tcp::TCP_ApplicationAnalyzer::DeliverPacket(len, data, orig, seq, ip, caplen);
|
||||||
len = min(len, caplen);
|
len = std::min(len, caplen);
|
||||||
|
|
||||||
if ( orig )
|
if ( orig )
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
||||||
int last_replied_cmd;
|
int last_replied_cmd;
|
||||||
int first_cmd; // first un-replied SMTP cmd, or -1
|
int first_cmd; // first un-replied SMTP cmd, or -1
|
||||||
int pending_reply; // code assoc. w/ multi-line reply, or 0
|
int pending_reply; // code assoc. w/ multi-line reply, or 0
|
||||||
list<int> pending_cmd_q; // to support pipelining
|
std::list<int> pending_cmd_q; // to support pipelining
|
||||||
bool skip_data; // whether to skip message body
|
bool skip_data; // whether to skip message body
|
||||||
BroString* line_after_gap; // last line before the first reply
|
BroString* line_after_gap; // last line before the first reply
|
||||||
// after a gap
|
// after a gap
|
||||||
|
|
|
@ -145,7 +145,7 @@ void ContentLine_Analyzer::DoDeliver(int len, const u_char* data)
|
||||||
|
|
||||||
if ( plain_delivery_length > 0 )
|
if ( plain_delivery_length > 0 )
|
||||||
{
|
{
|
||||||
int deliver_plain = min(plain_delivery_length, (int64_t)len);
|
int deliver_plain = std::min(plain_delivery_length, (int64_t)len);
|
||||||
|
|
||||||
last_char = 0; // clear last_char
|
last_char = 0; // clear last_char
|
||||||
plain_delivery_length -= deliver_plain;
|
plain_delivery_length -= deliver_plain;
|
||||||
|
|
|
@ -794,7 +794,7 @@ void TCP_Analyzer::GeneratePacketEvent(
|
||||||
IntrusivePtr{AdoptRef{}, val_mgr->GetCount(len)},
|
IntrusivePtr{AdoptRef{}, val_mgr->GetCount(len)},
|
||||||
// We need the min() here because Ethernet padding can lead to
|
// We need the min() here because Ethernet padding can lead to
|
||||||
// caplen > len.
|
// caplen > len.
|
||||||
make_intrusive<StringVal>(min(caplen, len), (const char*) data)
|
make_intrusive<StringVal>(std::min(caplen, len), (const char*) data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ void TCP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
|
||||||
// We need the min() here because Ethernet frame padding can lead to
|
// We need the min() here because Ethernet frame padding can lead to
|
||||||
// caplen > len.
|
// caplen > len.
|
||||||
if ( packet_contents )
|
if ( packet_contents )
|
||||||
PacketContents(data, min(len, caplen));
|
PacketContents(data, std::min(len, caplen));
|
||||||
|
|
||||||
TCP_Endpoint* endpoint = is_orig ? orig : resp;
|
TCP_Endpoint* endpoint = is_orig ? orig : resp;
|
||||||
TCP_Endpoint* peer = endpoint->peer;
|
TCP_Endpoint* peer = endpoint->peer;
|
||||||
|
@ -1906,7 +1906,7 @@ void TCP_ApplicationAnalyzer::DeliverPacket(int len, const u_char* data,
|
||||||
Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen);
|
Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen);
|
||||||
DBG_LOG(DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]",
|
DBG_LOG(DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]",
|
||||||
len, is_orig ? "T" : "F", seq, ip, caplen,
|
len, is_orig ? "T" : "F", seq, ip, caplen,
|
||||||
fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : "");
|
fmt_bytes((const char*) data, std::min(40, len)), len > 40 ? "..." : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCP_ApplicationAnalyzer::SetEnv(bool /* is_orig */, char* name, char* val)
|
void TCP_ApplicationAnalyzer::SetEnv(bool /* is_orig */, char* name, char* val)
|
||||||
|
|
|
@ -169,7 +169,7 @@ private:
|
||||||
TCP_Endpoint* orig;
|
TCP_Endpoint* orig;
|
||||||
TCP_Endpoint* resp;
|
TCP_Endpoint* resp;
|
||||||
|
|
||||||
typedef list<analyzer::Analyzer*> analyzer_list;
|
using analyzer_list = std::list<analyzer::Analyzer*>;
|
||||||
analyzer_list packet_children;
|
analyzer_list packet_children;
|
||||||
|
|
||||||
unsigned int first_packet_seen: 2;
|
unsigned int first_packet_seen: 2;
|
||||||
|
|
|
@ -14,13 +14,13 @@ public:
|
||||||
bool URG() const { return flags & TH_URG; }
|
bool URG() const { return flags & TH_URG; }
|
||||||
bool PUSH() const { return flags & TH_PUSH; }
|
bool PUSH() const { return flags & TH_PUSH; }
|
||||||
|
|
||||||
string AsString() const;
|
std::string AsString() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
u_char flags;
|
u_char flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline string TCP_Flags::AsString() const
|
inline std::string TCP_Flags::AsString() const
|
||||||
{
|
{
|
||||||
char tcp_flags[10];
|
char tcp_flags[10];
|
||||||
char* p = tcp_flags;
|
char* p = tcp_flags;
|
||||||
|
|
|
@ -58,7 +58,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
|
||||||
// We need the min() here because Ethernet frame padding can lead to
|
// We need the min() here because Ethernet frame padding can lead to
|
||||||
// caplen > len.
|
// caplen > len.
|
||||||
if ( packet_contents )
|
if ( packet_contents )
|
||||||
PacketContents(data, min(len, caplen) - sizeof(struct udphdr));
|
PacketContents(data, std::min(len, caplen) - sizeof(struct udphdr));
|
||||||
|
|
||||||
int chksum = up->uh_sum;
|
int chksum = up->uh_sum;
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ public:
|
||||||
* See the Broker::SendFlags record type.
|
* See the Broker::SendFlags record type.
|
||||||
* @return true if the message is sent successfully.
|
* @return true if the message is sent successfully.
|
||||||
*/
|
*/
|
||||||
bool PublishLogWrite(EnumVal* stream, EnumVal* writer, string path, int num_vals,
|
bool PublishLogWrite(EnumVal* stream, EnumVal* writer, std::string path, int num_vals,
|
||||||
const threading::Value* const * vals);
|
const threading::Value* const * vals);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,7 +52,7 @@ class StoreQueryCallback {
|
||||||
public:
|
public:
|
||||||
StoreQueryCallback(trigger::Trigger* arg_trigger, const CallExpr* arg_call,
|
StoreQueryCallback(trigger::Trigger* arg_trigger, const CallExpr* arg_call,
|
||||||
broker::store store)
|
broker::store store)
|
||||||
: trigger(arg_trigger), call(arg_call), store(move(store))
|
: trigger(arg_trigger), call(arg_call), store(std::move(store))
|
||||||
{
|
{
|
||||||
Ref(trigger);
|
Ref(trigger);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ void File::StaticInit()
|
||||||
meta_inferred_idx = Idx("inferred", fa_metadata_type);
|
meta_inferred_idx = Idx("inferred", fa_metadata_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
File::File(const string& file_id, const string& source_name, Connection* conn,
|
File::File(const std::string& file_id, const std::string& source_name, Connection* conn,
|
||||||
analyzer::Tag tag, bool is_orig)
|
analyzer::Tag tag, bool is_orig)
|
||||||
: id(file_id), val(0), file_reassembler(0), stream_offset(0),
|
: id(file_id), val(0), file_reassembler(0), stream_offset(0),
|
||||||
reassembly_max_buffer(0), did_metadata_inference(false),
|
reassembly_max_buffer(0), did_metadata_inference(false),
|
||||||
|
@ -174,7 +174,7 @@ double File::LookupFieldDefaultInterval(int idx) const
|
||||||
return v->AsInterval();
|
return v->AsInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
int File::Idx(const string& field, const RecordType* type)
|
int File::Idx(const std::string& field, const RecordType* type)
|
||||||
{
|
{
|
||||||
int rval = type->FieldOffset(field.c_str());
|
int rval = type->FieldOffset(field.c_str());
|
||||||
|
|
||||||
|
@ -185,14 +185,14 @@ int File::Idx(const string& field, const RecordType* type)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
string File::GetSource() const
|
std::string File::GetSource() const
|
||||||
{
|
{
|
||||||
Val* v = val->Lookup(source_idx);
|
Val* v = val->Lookup(source_idx);
|
||||||
|
|
||||||
return v ? v->AsString()->CheckString() : string();
|
return v ? v->AsString()->CheckString() : std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::SetSource(const string& source)
|
void File::SetSource(const std::string& source)
|
||||||
{
|
{
|
||||||
val->Assign(source_idx, make_intrusive<StringVal>(source.c_str()));
|
val->Assign(source_idx, make_intrusive<StringVal>(source.c_str()));
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ void File::SetReassemblyBuffer(uint64_t max)
|
||||||
reassembly_max_buffer = max;
|
reassembly_max_buffer = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::SetMime(const string& mime_type)
|
bool File::SetMime(const std::string& mime_type)
|
||||||
{
|
{
|
||||||
if ( mime_type.empty() || bof_buffer.size != 0 || did_metadata_inference )
|
if ( mime_type.empty() || bof_buffer.size != 0 || did_metadata_inference )
|
||||||
return false;
|
return false;
|
||||||
|
@ -329,7 +329,7 @@ void File::InferMetadata()
|
||||||
RuleMatcher::MIME_Matches matches;
|
RuleMatcher::MIME_Matches matches;
|
||||||
const u_char* data = bof_buffer_val->AsString()->Bytes();
|
const u_char* data = bof_buffer_val->AsString()->Bytes();
|
||||||
uint64_t len = bof_buffer_val->AsString()->Len();
|
uint64_t len = bof_buffer_val->AsString()->Len();
|
||||||
len = min(len, LookupFieldDefaultCount(bof_buffer_size_idx));
|
len = std::min(len, LookupFieldDefaultCount(bof_buffer_size_idx));
|
||||||
file_mgr->DetectMIME(data, len, &matches);
|
file_mgr->DetectMIME(data, len, &matches);
|
||||||
|
|
||||||
auto meta = make_intrusive<RecordVal>(fa_metadata_type);
|
auto meta = make_intrusive<RecordVal>(fa_metadata_type);
|
||||||
|
@ -383,7 +383,7 @@ void File::DeliverStream(const u_char* data, uint64_t len)
|
||||||
"[%s] %" PRIu64 " stream bytes in at offset %" PRIu64 "; %s [%s%s]",
|
"[%s] %" PRIu64 " stream bytes in at offset %" PRIu64 "; %s [%s%s]",
|
||||||
id.c_str(), len, stream_offset,
|
id.c_str(), len, stream_offset,
|
||||||
IsComplete() ? "complete" : "incomplete",
|
IsComplete() ? "complete" : "incomplete",
|
||||||
fmt_bytes((const char*) data, min((uint64_t)40, len)),
|
fmt_bytes((const char*) data, std::min((uint64_t)40, len)),
|
||||||
len > 40 ? "..." : "");
|
len > 40 ? "..." : "");
|
||||||
|
|
||||||
file_analysis::Analyzer* a = 0;
|
file_analysis::Analyzer* a = 0;
|
||||||
|
@ -487,7 +487,7 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset)
|
||||||
"[%s] %" PRIu64 " chunk bytes in at offset %" PRIu64 "; %s [%s%s]",
|
"[%s] %" PRIu64 " chunk bytes in at offset %" PRIu64 "; %s [%s%s]",
|
||||||
id.c_str(), len, offset,
|
id.c_str(), len, offset,
|
||||||
IsComplete() ? "complete" : "incomplete",
|
IsComplete() ? "complete" : "incomplete",
|
||||||
fmt_bytes((const char*) data, min((uint64_t)40, len)),
|
fmt_bytes((const char*) data, std::min((uint64_t)40, len)),
|
||||||
len > 40 ? "..." : "");
|
len > 40 ? "..." : "");
|
||||||
|
|
||||||
file_analysis::Analyzer* a = 0;
|
file_analysis::Analyzer* a = 0;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
using namespace file_analysis;
|
using namespace file_analysis;
|
||||||
|
|
||||||
FileTimer::FileTimer(double t, const string& id, double interval)
|
FileTimer::FileTimer(double t, const std::string& id, double interval)
|
||||||
: Timer(t + interval, TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id)
|
: Timer(t + interval, TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id)
|
||||||
{
|
{
|
||||||
DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s",
|
DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s",
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
|
|
||||||
using namespace file_analysis;
|
using namespace file_analysis;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
TableVal* Manager::disabled = 0;
|
TableVal* Manager::disabled = 0;
|
||||||
TableType* Manager::tag_set_type = 0;
|
TableType* Manager::tag_set_type = 0;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
using namespace file_analysis;
|
using namespace file_analysis;
|
||||||
|
|
||||||
Extract::Extract(RecordVal* args, File* file, const string& arg_filename,
|
Extract::Extract(RecordVal* args, File* file, const std::string& arg_filename,
|
||||||
uint64_t arg_limit)
|
uint64_t arg_limit)
|
||||||
: file_analysis::Analyzer(file_mgr->GetComponentTag("EXTRACT"), args, file),
|
: file_analysis::Analyzer(file_mgr->GetComponentTag("EXTRACT"), args, file),
|
||||||
filename(arg_filename), limit(arg_limit), depth(0)
|
filename(arg_filename), limit(arg_limit), depth(0)
|
||||||
|
|
|
@ -66,11 +66,11 @@ protected:
|
||||||
* to which the contents of the file will be extracted/written.
|
* to which the contents of the file will be extracted/written.
|
||||||
* @param arg_limit the maximum allowed file size.
|
* @param arg_limit the maximum allowed file size.
|
||||||
*/
|
*/
|
||||||
Extract(RecordVal* args, File* file, const string& arg_filename,
|
Extract(RecordVal* args, File* file, const std::string& arg_filename,
|
||||||
uint64_t arg_limit);
|
uint64_t arg_limit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string filename;
|
std::string filename;
|
||||||
int fd;
|
int fd;
|
||||||
uint64_t limit;
|
uint64_t limit;
|
||||||
uint64_t depth;
|
uint64_t depth;
|
||||||
|
|
|
@ -703,7 +703,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa
|
||||||
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
|
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
|
||||||
assert(mdctx);
|
assert(mdctx);
|
||||||
|
|
||||||
string errstr;
|
std::string errstr;
|
||||||
int success = 0;
|
int success = 0;
|
||||||
|
|
||||||
const EVP_MD* hash = hash_to_evp(hash_algorithm);
|
const EVP_MD* hash = hash_to_evp(hash_algorithm);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../threading/SerialTypes.h"
|
#include "../threading/SerialTypes.h"
|
||||||
|
|
||||||
using namespace input;
|
using namespace input;
|
||||||
|
using namespace std;
|
||||||
using threading::Value;
|
using threading::Value;
|
||||||
using threading::Field;
|
using threading::Field;
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "EventHandler.h"
|
#include "EventHandler.h"
|
||||||
#include "plugin/ComponentManager.h"
|
#include "plugin/ComponentManager.h"
|
||||||
#include "threading/SerialTypes.h"
|
#include "threading/SerialTypes.h"
|
||||||
#include "Tag.h"
|
#include "Tag.h"
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
class RecordVal;
|
class RecordVal;
|
||||||
|
|
||||||
namespace input {
|
namespace input {
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
* This method corresponds directly to the internal BiF defined in
|
* This method corresponds directly to the internal BiF defined in
|
||||||
* input.bif, which just forwards here.
|
* input.bif, which just forwards here.
|
||||||
*/
|
*/
|
||||||
bool ForceUpdate(const string &id);
|
bool ForceUpdate(const std::string &id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an existing input stream.
|
* Deletes an existing input stream.
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
* This method corresponds directly to the internal BiF defined in
|
* This method corresponds directly to the internal BiF defined in
|
||||||
* input.bif, which just forwards here.
|
* input.bif, which just forwards here.
|
||||||
*/
|
*/
|
||||||
bool RemoveStream(const string &id);
|
bool RemoveStream(const std::string &id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals the manager to shutdown at Bro's termination.
|
* Signals the manager to shutdown at Bro's termination.
|
||||||
|
@ -145,7 +145,7 @@ protected:
|
||||||
// Allows readers to directly send Bro events. The num_vals and vals
|
// Allows readers to directly send Bro events. The num_vals and vals
|
||||||
// must be the same the named event expects. Takes ownership of
|
// must be the same the named event expects. Takes ownership of
|
||||||
// threading::Value fields.
|
// threading::Value fields.
|
||||||
bool SendEvent(ReaderFrontend* reader, const string& name, const int num_vals, threading::Value* *vals) const;
|
bool SendEvent(ReaderFrontend* reader, const std::string& name, const int num_vals, threading::Value* *vals) const;
|
||||||
|
|
||||||
// Instantiates a new ReaderBackend of the given type (note that
|
// Instantiates a new ReaderBackend of the given type (note that
|
||||||
// doing so creates a new thread!).
|
// doing so creates a new thread!).
|
||||||
|
@ -205,11 +205,11 @@ private:
|
||||||
// Check if a record is made up of compatible types and return a list
|
// Check if a record is made up of compatible types and return a list
|
||||||
// of all fields that are in the record in order. Recursively unrolls
|
// of all fields that are in the record in order. Recursively unrolls
|
||||||
// records
|
// records
|
||||||
bool UnrollRecordType(vector<threading::Field*> *fields, const RecordType *rec, const string& nameprepend, bool allow_file_func) const;
|
bool UnrollRecordType(std::vector<threading::Field*> *fields, const RecordType *rec, const std::string& nameprepend, bool allow_file_func) const;
|
||||||
|
|
||||||
// Send events
|
// Send events
|
||||||
void SendEvent(EventHandlerPtr ev, const int numvals, ...) const;
|
void SendEvent(EventHandlerPtr ev, const int numvals, ...) const;
|
||||||
void SendEvent(EventHandlerPtr ev, list<Val*> events) const;
|
void SendEvent(EventHandlerPtr ev, std::list<Val*> events) const;
|
||||||
|
|
||||||
// Implementation of SendEndOfData (send end_of_data event).
|
// Implementation of SendEndOfData (send end_of_data event).
|
||||||
void SendEndOfData(const Stream *i);
|
void SendEndOfData(const Stream *i);
|
||||||
|
@ -257,12 +257,12 @@ private:
|
||||||
void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, ...) const __attribute__((format(printf, 5, 6)));
|
void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, ...) const __attribute__((format(printf, 5, 6)));
|
||||||
void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, va_list ap) const __attribute__((format(printf, 5, 0)));
|
void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, va_list ap) const __attribute__((format(printf, 5, 0)));
|
||||||
|
|
||||||
Stream* FindStream(const string &name) const;
|
Stream* FindStream(const std::string &name) const;
|
||||||
Stream* FindStream(ReaderFrontend* reader) const;
|
Stream* FindStream(ReaderFrontend* reader) const;
|
||||||
|
|
||||||
enum StreamType { TABLE_STREAM, EVENT_STREAM, ANALYSIS_STREAM };
|
enum StreamType { TABLE_STREAM, EVENT_STREAM, ANALYSIS_STREAM };
|
||||||
|
|
||||||
map<ReaderFrontend*, Stream*> readers;
|
std::map<ReaderFrontend*, Stream*> readers;
|
||||||
|
|
||||||
EventHandlerPtr end_of_data;
|
EventHandlerPtr end_of_data;
|
||||||
};
|
};
|
||||||
|
@ -271,4 +271,3 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
extern input::Manager* input_mgr;
|
extern input::Manager* input_mgr;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
using namespace input::reader;
|
using namespace input::reader;
|
||||||
using namespace threading;
|
using namespace threading;
|
||||||
|
using namespace std;
|
||||||
using threading::Value;
|
using threading::Value;
|
||||||
using threading::Field;
|
using threading::Field;
|
||||||
|
|
||||||
|
@ -468,4 +469,3 @@ bool Ascii::DoHeartbeat(double network_time, double current_time)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,15 @@ namespace input { namespace reader {
|
||||||
|
|
||||||
// Description for input field mapping.
|
// Description for input field mapping.
|
||||||
struct FieldMapping {
|
struct FieldMapping {
|
||||||
string name;
|
std::string name;
|
||||||
TypeTag type;
|
TypeTag type;
|
||||||
TypeTag subtype; // internal type for sets and vectors
|
TypeTag subtype; // internal type for sets and vectors
|
||||||
int position;
|
int position;
|
||||||
int secondary_position; // for ports: pos of the second field
|
int secondary_position; // for ports: pos of the second field
|
||||||
bool present;
|
bool present;
|
||||||
|
|
||||||
FieldMapping(const string& arg_name, const TypeTag& arg_type, int arg_position);
|
FieldMapping(const std::string& arg_name, const TypeTag& arg_type, int arg_position);
|
||||||
FieldMapping(const string& arg_name, const TypeTag& arg_type, const TypeTag& arg_subtype, int arg_position);
|
FieldMapping(const std::string& arg_name, const TypeTag& arg_type, const TypeTag& arg_subtype, int arg_position);
|
||||||
FieldMapping(const FieldMapping& arg);
|
FieldMapping(const FieldMapping& arg);
|
||||||
FieldMapping() { position = -1; secondary_position = -1; }
|
FieldMapping() { position = -1; secondary_position = -1; }
|
||||||
|
|
||||||
|
@ -54,32 +54,32 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ReadHeader(bool useCached);
|
bool ReadHeader(bool useCached);
|
||||||
bool GetLine(string& str);
|
bool GetLine(std::string& str);
|
||||||
bool OpenFile();
|
bool OpenFile();
|
||||||
|
|
||||||
ifstream file;
|
std::ifstream file;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
|
|
||||||
// The name using which we actually load the file -- compared
|
// The name using which we actually load the file -- compared
|
||||||
// to the input source name, this one may have a path_prefix
|
// to the input source name, this one may have a path_prefix
|
||||||
// attached to it.
|
// attached to it.
|
||||||
string fname;
|
std::string fname;
|
||||||
|
|
||||||
// map columns in the file to columns to send back to the manager
|
// map columns in the file to columns to send back to the manager
|
||||||
vector<FieldMapping> columnMap;
|
std::vector<FieldMapping> columnMap;
|
||||||
|
|
||||||
// keep a copy of the headerline to determine field locations when stream descriptions change
|
// keep a copy of the headerline to determine field locations when stream descriptions change
|
||||||
string headerline;
|
std::string headerline;
|
||||||
|
|
||||||
// options set from the script-level.
|
// options set from the script-level.
|
||||||
string separator;
|
std::string separator;
|
||||||
string set_separator;
|
std::string set_separator;
|
||||||
string empty_field;
|
std::string empty_field;
|
||||||
string unset_field;
|
std::string unset_field;
|
||||||
bool fail_on_invalid_lines;
|
bool fail_on_invalid_lines;
|
||||||
bool fail_on_file_problem;
|
bool fail_on_file_problem;
|
||||||
string path_prefix;
|
std::string path_prefix;
|
||||||
|
|
||||||
std::unique_ptr<threading::formatter::Formatter> formatter;
|
std::unique_ptr<threading::formatter::Formatter> formatter;
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,9 +55,9 @@ bool Benchmark::DoInit(const ReaderInfo& info, int num_fields, const Field* cons
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Benchmark::RandomString(const int len)
|
std::string Benchmark::RandomString(const int len)
|
||||||
{
|
{
|
||||||
string s(len, ' ');
|
std::string s(len, ' ');
|
||||||
|
|
||||||
static const char values[] =
|
static const char values[] =
|
||||||
"0123456789!@#$%^&*()-_=+{}[]\\|"
|
"0123456789!@#$%^&*()-_=+{}[]\\|"
|
||||||
|
@ -135,7 +135,7 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
|
||||||
|
|
||||||
case TYPE_STRING:
|
case TYPE_STRING:
|
||||||
{
|
{
|
||||||
string rnd = RandomString(10);
|
std::string rnd = RandomString(10);
|
||||||
val->val.string_val.data = copy_string(rnd.c_str());
|
val->val.string_val.data = copy_string(rnd.c_str());
|
||||||
val->val.string_val.length = rnd.size();
|
val->val.string_val.length = rnd.size();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,7 +25,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double CurrTime();
|
double CurrTime();
|
||||||
string RandomString(const int len);
|
std::string RandomString(const int len);
|
||||||
threading::Value* EntryToVal(TypeTag Type, TypeTag subtype);
|
threading::Value* EntryToVal(TypeTag Type, TypeTag subtype);
|
||||||
|
|
||||||
int num_lines;
|
int num_lines;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "threading/SerialTypes.h"
|
#include "threading/SerialTypes.h"
|
||||||
|
|
||||||
using namespace input::reader;
|
using namespace input::reader;
|
||||||
|
using namespace std;
|
||||||
using threading::Value;
|
using threading::Value;
|
||||||
using threading::Field;
|
using threading::Field;
|
||||||
|
|
||||||
|
|
|
@ -30,18 +30,18 @@ protected:
|
||||||
private:
|
private:
|
||||||
bool OpenInput();
|
bool OpenInput();
|
||||||
bool CloseInput();
|
bool CloseInput();
|
||||||
streamsize GetChunk(char** chunk);
|
std::streamsize GetChunk(char** chunk);
|
||||||
int UpdateModificationTime();
|
int UpdateModificationTime();
|
||||||
|
|
||||||
string fname;
|
std::string fname;
|
||||||
ifstream* in;
|
std::ifstream* in;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
bool firstrun;
|
bool firstrun;
|
||||||
|
|
||||||
// options set from the script-level.
|
// options set from the script-level.
|
||||||
static streamsize chunk_size;
|
static std::streamsize chunk_size;
|
||||||
string path_prefix;
|
std::string path_prefix;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool Config::DoInit(const ReaderInfo& info, int num_fields, const Field* const*
|
||||||
BifConst::InputConfig::empty_field->Len());
|
BifConst::InputConfig::empty_field->Len());
|
||||||
|
|
||||||
formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
|
formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
|
||||||
formatter = unique_ptr<threading::formatter::Formatter>(new formatter::Ascii(this, sep_info));
|
formatter = std::unique_ptr<threading::formatter::Formatter>(new formatter::Ascii(this, sep_info));
|
||||||
|
|
||||||
return DoUpdate();
|
return DoUpdate();
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ bool Config::OpenFile()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::GetLine(string& str)
|
bool Config::GetLine(std::string& str)
|
||||||
{
|
{
|
||||||
while ( getline(file, str) )
|
while ( getline(file, str) )
|
||||||
{
|
{
|
||||||
|
@ -170,7 +170,7 @@ bool Config::DoUpdate()
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
string line;
|
std::string line;
|
||||||
file.sync();
|
file.sync();
|
||||||
|
|
||||||
// keep a list of options to remove because they were no longer in the input file.
|
// keep a list of options to remove because they were no longer in the input file.
|
||||||
|
@ -197,8 +197,8 @@ bool Config::DoUpdate()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string key = line.substr(match[1].rm_so, match[1].rm_eo - match[1].rm_so);
|
std::string key = line.substr(match[1].rm_so, match[1].rm_eo - match[1].rm_so);
|
||||||
string value;
|
std::string value;
|
||||||
if ( match[2].rm_so > 0 )
|
if ( match[2].rm_so > 0 )
|
||||||
value = line.substr(match[2].rm_so, match[2].rm_eo - match[2].rm_so);
|
value = line.substr(match[2].rm_so, match[2].rm_eo - match[2].rm_so);
|
||||||
|
|
||||||
|
@ -308,4 +308,3 @@ bool Config::DoHeartbeat(double network_time, double current_time)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,17 @@ protected:
|
||||||
bool DoHeartbeat(double network_time, double current_time) override;
|
bool DoHeartbeat(double network_time, double current_time) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool GetLine(string& str);
|
bool GetLine(std::string& str);
|
||||||
bool OpenFile();
|
bool OpenFile();
|
||||||
|
|
||||||
ifstream file;
|
std::ifstream file;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
|
|
||||||
bool fail_on_file_problem;
|
bool fail_on_file_problem;
|
||||||
|
|
||||||
string set_separator;
|
std::string set_separator;
|
||||||
string empty_field;
|
std::string empty_field;
|
||||||
|
|
||||||
std::unique_ptr<threading::formatter::Formatter> formatter;
|
std::unique_ptr<threading::formatter::Formatter> formatter;
|
||||||
std::unordered_map<std::string, std::tuple<TypeTag, TypeTag>> option_types;
|
std::unordered_map<std::string, std::tuple<TypeTag, TypeTag>> option_types;
|
||||||
|
|
|
@ -348,7 +348,7 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie
|
||||||
int want_fields = 1;
|
int want_fields = 1;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
string source = string(info.source);
|
std::string source = std::string(info.source);
|
||||||
char last = info.source[source.length() - 1];
|
char last = info.source[source.length() - 1];
|
||||||
if ( last == '|' )
|
if ( last == '|' )
|
||||||
{
|
{
|
||||||
|
@ -379,7 +379,7 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie
|
||||||
it = info.config.find("offset"); // we want to seek to a given offset inside the file
|
it = info.config.find("offset"); // we want to seek to a given offset inside the file
|
||||||
if ( it != info.config.end() && ! execute && (Info().mode == MODE_STREAM || Info().mode == MODE_MANUAL) )
|
if ( it != info.config.end() && ! execute && (Info().mode == MODE_STREAM || Info().mode == MODE_MANUAL) )
|
||||||
{
|
{
|
||||||
string offset_s = it->second;
|
std::string offset_s = it->second;
|
||||||
offset = strtoll(offset_s.c_str(), 0, 10);
|
offset = strtoll(offset_s.c_str(), 0, 10);
|
||||||
}
|
}
|
||||||
else if ( it != info.config.end() )
|
else if ( it != info.config.end() )
|
||||||
|
@ -585,7 +585,7 @@ bool Raw::DoUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string line;
|
std::string line;
|
||||||
assert ( (NumFields() == 1 && !use_stderr) || (NumFields() == 2 && use_stderr));
|
assert ( (NumFields() == 1 && !use_stderr) || (NumFields() == 2 && use_stderr));
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ private:
|
||||||
bool Execute();
|
bool Execute();
|
||||||
void WriteToStdin();
|
void WriteToStdin();
|
||||||
|
|
||||||
string fname; // Source with a potential "|" removed.
|
std::string fname; // Source with a potential "|" removed.
|
||||||
std::unique_ptr<FILE, int(*)(FILE*)> file;
|
std::unique_ptr<FILE, int(*)(FILE*)> file;
|
||||||
std::unique_ptr<FILE, int(*)(FILE*)> stderrfile;
|
std::unique_ptr<FILE, int(*)(FILE*)> stderrfile;
|
||||||
bool execute;
|
bool execute;
|
||||||
|
@ -54,7 +54,7 @@ private:
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
|
|
||||||
// options set from the script-level.
|
// options set from the script-level.
|
||||||
string separator;
|
std::string separator;
|
||||||
unsigned int sep_length; // length of the separator
|
unsigned int sep_length; // length of the separator
|
||||||
|
|
||||||
int bufpos;
|
int bufpos;
|
||||||
|
@ -65,7 +65,7 @@ private:
|
||||||
int stdout_fileno;
|
int stdout_fileno;
|
||||||
int stderr_fileno;
|
int stderr_fileno;
|
||||||
|
|
||||||
string stdin_string;
|
std::string stdin_string;
|
||||||
uint64_t stdin_towrite;
|
uint64_t stdin_towrite;
|
||||||
|
|
||||||
bool use_stderr;
|
bool use_stderr;
|
||||||
|
|
|
@ -38,7 +38,7 @@ SQLite::SQLite(ReaderFrontend *frontend)
|
||||||
BifConst::InputSQLite::empty_field->Len()
|
BifConst::InputSQLite::empty_field->Len()
|
||||||
);
|
);
|
||||||
|
|
||||||
io = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo(string(), set_separator, unset_field, empty_field));
|
io = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo(std::string(), set_separator, unset_field, empty_field));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLite::~SQLite()
|
SQLite::~SQLite()
|
||||||
|
@ -90,10 +90,10 @@ bool SQLite::DoInit(const ReaderInfo& info, int arg_num_fields, const threading:
|
||||||
|
|
||||||
started = false;
|
started = false;
|
||||||
|
|
||||||
string fullpath(info.source);
|
std::string fullpath(info.source);
|
||||||
fullpath.append(".sqlite");
|
fullpath.append(".sqlite");
|
||||||
|
|
||||||
string query;
|
std::string query;
|
||||||
ReaderInfo::config_map::const_iterator it = info.config.find("query");
|
ReaderInfo::config_map::const_iterator it = info.config.find("query");
|
||||||
if ( it == info.config.end() )
|
if ( it == info.config.end() )
|
||||||
{
|
{
|
||||||
|
@ -199,7 +199,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
Error("Port protocol definition did not contain text");
|
Error("Port protocol definition did not contain text");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string s(text, sqlite3_column_bytes(st, subpos));
|
std::string s(text, sqlite3_column_bytes(st, subpos));
|
||||||
val->val.port_val.proto = io->ParseProto(s);
|
val->val.port_val.proto = io->ParseProto(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,10 +209,10 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
case TYPE_SUBNET:
|
case TYPE_SUBNET:
|
||||||
{
|
{
|
||||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||||
string s(text, sqlite3_column_bytes(st, pos));
|
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||||
int pos = s.find('/');
|
int pos = s.find('/');
|
||||||
int width = atoi(s.substr(pos+1).c_str());
|
int width = atoi(s.substr(pos+1).c_str());
|
||||||
string addr = s.substr(0, pos);
|
std::string addr = s.substr(0, pos);
|
||||||
|
|
||||||
val->val.subnet_val.prefix = io->ParseAddr(addr);
|
val->val.subnet_val.prefix = io->ParseAddr(addr);
|
||||||
val->val.subnet_val.length = width;
|
val->val.subnet_val.length = width;
|
||||||
|
@ -222,7 +222,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
case TYPE_ADDR:
|
case TYPE_ADDR:
|
||||||
{
|
{
|
||||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||||
string s(text, sqlite3_column_bytes(st, pos));
|
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||||
val->val.addr_val = io->ParseAddr(s);
|
val->val.addr_val = io->ParseAddr(s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
case TYPE_VECTOR:
|
case TYPE_VECTOR:
|
||||||
{
|
{
|
||||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||||
string s(text, sqlite3_column_bytes(st, pos));
|
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||||
delete val;
|
delete val;
|
||||||
val = io->ParseValue(s, "", field->type, field->subtype);
|
val = io->ParseValue(s, "", field->type, field->subtype);
|
||||||
break;
|
break;
|
||||||
|
@ -342,4 +342,3 @@ bool SQLite::DoUpdate()
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,14 @@ private:
|
||||||
unsigned int num_fields;
|
unsigned int num_fields;
|
||||||
int mode;
|
int mode;
|
||||||
bool started;
|
bool started;
|
||||||
string query;
|
std::string query;
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
sqlite3_stmt *st;
|
sqlite3_stmt *st;
|
||||||
threading::formatter::Ascii* io;
|
threading::formatter::Ascii* io;
|
||||||
|
|
||||||
string set_separator;
|
std::string set_separator;
|
||||||
string unset_field;
|
std::string unset_field;
|
||||||
string empty_field;
|
std::string empty_field;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ const std::vector<std::string>& PktSrcComponent::Prefixes() const
|
||||||
return prefixes;
|
return prefixes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PktSrcComponent::HandlesPrefix(const string& prefix) const
|
bool PktSrcComponent::HandlesPrefix(const std::string& prefix) const
|
||||||
{
|
{
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
i != prefixes.end(); i++ )
|
i != prefixes.end(); i++ )
|
||||||
|
@ -69,7 +69,7 @@ void PktSrcComponent::DoDescribe(ODesc* d) const
|
||||||
{
|
{
|
||||||
iosource::Component::DoDescribe(d);
|
iosource::Component::DoDescribe(d);
|
||||||
|
|
||||||
string prefs;
|
std::string prefs;
|
||||||
|
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
i != prefixes.end(); i++ )
|
i != prefixes.end(); i++ )
|
||||||
|
@ -128,7 +128,7 @@ const std::vector<std::string>& PktDumperComponent::Prefixes() const
|
||||||
return prefixes;
|
return prefixes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PktDumperComponent::HandlesPrefix(const string& prefix) const
|
bool PktDumperComponent::HandlesPrefix(const std::string& prefix) const
|
||||||
{
|
{
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
i != prefixes.end(); i++ )
|
i != prefixes.end(); i++ )
|
||||||
|
@ -144,7 +144,7 @@ void PktDumperComponent::DoDescribe(ODesc* d) const
|
||||||
{
|
{
|
||||||
plugin::Component::DoDescribe(d);
|
plugin::Component::DoDescribe(d);
|
||||||
|
|
||||||
string prefs;
|
std::string prefs;
|
||||||
|
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
i != prefixes.end(); i++ )
|
i != prefixes.end(); i++ )
|
||||||
|
|
|
@ -364,7 +364,7 @@ PktSrc* Manager::OpenPktSrc(const std::string& path, bool is_live)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PktDumper* Manager::OpenPktDumper(const string& path, bool append)
|
PktDumper* Manager::OpenPktDumper(const std::string& path, bool append)
|
||||||
{
|
{
|
||||||
std::pair<std::string, std::string> t = split_prefix(path);
|
std::pair<std::string, std::string> t = split_prefix(path);
|
||||||
std::string prefix = t.first;
|
std::string prefix = t.first;
|
||||||
|
|
|
@ -273,10 +273,10 @@ bool PktSrc::PrecompileBPFFilter(int index, const std::string& filter)
|
||||||
|
|
||||||
if ( ! code->Compile(BifConst::Pcap::snaplen, LinkType(), filter.c_str(), Netmask(), errbuf, sizeof(errbuf)) )
|
if ( ! code->Compile(BifConst::Pcap::snaplen, LinkType(), filter.c_str(), Netmask(), errbuf, sizeof(errbuf)) )
|
||||||
{
|
{
|
||||||
string msg = fmt("cannot compile BPF filter \"%s\"", filter.c_str());
|
std::string msg = fmt("cannot compile BPF filter \"%s\"", filter.c_str());
|
||||||
|
|
||||||
if ( *errbuf )
|
if ( *errbuf )
|
||||||
msg += ": " + string(errbuf);
|
msg += ": " + std::string(errbuf);
|
||||||
|
|
||||||
Error(msg);
|
Error(msg);
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ void PcapSource::Statistics(Stats* s)
|
||||||
|
|
||||||
void PcapSource::PcapError(const char* where)
|
void PcapSource::PcapError(const char* where)
|
||||||
{
|
{
|
||||||
string location;
|
std::string location;
|
||||||
|
|
||||||
if ( where )
|
if ( where )
|
||||||
location = fmt(" (%s)", where);
|
location = fmt(" (%s)", where);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <broker/endpoint_info.hh>
|
#include <broker/endpoint_info.hh>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace logging;
|
using namespace logging;
|
||||||
|
|
||||||
struct Manager::Filter {
|
struct Manager::Filter {
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
* This methods corresponds directly to the internal BiF defined in
|
* This methods corresponds directly to the internal BiF defined in
|
||||||
* logging.bif, which just forwards here.
|
* logging.bif, which just forwards here.
|
||||||
*/
|
*/
|
||||||
bool RemoveFilter(EnumVal* id, const string& name);
|
bool RemoveFilter(EnumVal* id, const std::string& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a record to a log stream.
|
* Write a record to a log stream.
|
||||||
|
@ -165,7 +165,7 @@ public:
|
||||||
* @param vals An array of log values to write, of size num_fields.
|
* @param vals An array of log values to write, of size num_fields.
|
||||||
* The method takes ownership of the array.
|
* The method takes ownership of the array.
|
||||||
*/
|
*/
|
||||||
bool WriteFromRemote(EnumVal* stream, EnumVal* writer, const string& path,
|
bool WriteFromRemote(EnumVal* stream, EnumVal* writer, const std::string& path,
|
||||||
int num_fields, threading::Value** vals);
|
int num_fields, threading::Value** vals);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -241,7 +241,7 @@ protected:
|
||||||
// Takes ownership of fields and info.
|
// Takes ownership of fields and info.
|
||||||
WriterFrontend* CreateWriter(EnumVal* id, EnumVal* writer, WriterBackend::WriterInfo* info,
|
WriterFrontend* CreateWriter(EnumVal* id, EnumVal* writer, WriterBackend::WriterInfo* info,
|
||||||
int num_fields, const threading::Field* const* fields,
|
int num_fields, const threading::Field* const* fields,
|
||||||
bool local, bool remote, bool from_remote, const string& instantiating_filter="");
|
bool local, bool remote, bool from_remote, const std::string& instantiating_filter="");
|
||||||
|
|
||||||
// Signals that a file has been rotated.
|
// Signals that a file has been rotated.
|
||||||
bool FinishedRotation(WriterFrontend* writer, const char* new_name, const char* old_name,
|
bool FinishedRotation(WriterFrontend* writer, const char* new_name, const char* old_name,
|
||||||
|
@ -256,7 +256,7 @@ private:
|
||||||
struct WriterInfo;
|
struct WriterInfo;
|
||||||
|
|
||||||
bool TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
bool TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
||||||
TableVal* include, TableVal* exclude, const string& path, const list<int>& indices);
|
TableVal* include, TableVal* exclude, const std::string& path, const std::list<int>& indices);
|
||||||
|
|
||||||
threading::Value** RecordToFilterVals(Stream* stream, Filter* filter,
|
threading::Value** RecordToFilterVals(Stream* stream, Filter* filter,
|
||||||
RecordVal* columns);
|
RecordVal* columns);
|
||||||
|
@ -270,7 +270,7 @@ private:
|
||||||
bool CompareFields(const Filter* filter, const WriterFrontend* writer);
|
bool CompareFields(const Filter* filter, const WriterFrontend* writer);
|
||||||
bool CheckFilterWriterConflict(const WriterInfo* winfo, const Filter* filter);
|
bool CheckFilterWriterConflict(const WriterInfo* winfo, const Filter* filter);
|
||||||
|
|
||||||
vector<Stream *> streams; // Indexed by stream enum.
|
std::vector<Stream *> streams; // Indexed by stream enum.
|
||||||
int rotations_pending; // Number of rotations not yet finished.
|
int rotations_pending; // Number of rotations not yet finished.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "Ascii.h"
|
#include "Ascii.h"
|
||||||
#include "ascii.bif.h"
|
#include "ascii.bif.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace logging::writer;
|
using namespace logging::writer;
|
||||||
using namespace threading;
|
using namespace threading;
|
||||||
using threading::Value;
|
using threading::Value;
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
explicit Ascii(WriterFrontend* frontend);
|
explicit Ascii(WriterFrontend* frontend);
|
||||||
~Ascii() override;
|
~Ascii() override;
|
||||||
|
|
||||||
static string LogExt();
|
static std::string LogExt();
|
||||||
|
|
||||||
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
||||||
{ return new Ascii(frontend); }
|
{ return new Ascii(frontend); }
|
||||||
|
@ -35,11 +35,11 @@ protected:
|
||||||
bool DoHeartbeat(double network_time, double current_time) override;
|
bool DoHeartbeat(double network_time, double current_time) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool IsSpecial(const string &path) { return path.find("/dev/") == 0; }
|
bool IsSpecial(const std::string &path) { return path.find("/dev/") == 0; }
|
||||||
bool WriteHeader(const string& path);
|
bool WriteHeader(const std::string& path);
|
||||||
bool WriteHeaderField(const string& key, const string& value);
|
bool WriteHeaderField(const std::string& key, const std::string& value);
|
||||||
void CloseFile(double t);
|
void CloseFile(double t);
|
||||||
string Timestamp(double t); // Uses current time if t is zero.
|
std::string Timestamp(double t); // Uses current time if t is zero.
|
||||||
void InitConfigOptions();
|
void InitConfigOptions();
|
||||||
bool InitFilterOptions();
|
bool InitFilterOptions();
|
||||||
bool InitFormatter();
|
bool InitFormatter();
|
||||||
|
@ -48,7 +48,7 @@ private:
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
gzFile gzfile;
|
gzFile gzfile;
|
||||||
string fname;
|
std::string fname;
|
||||||
ODesc desc;
|
ODesc desc;
|
||||||
bool ascii_done;
|
bool ascii_done;
|
||||||
|
|
||||||
|
@ -57,17 +57,17 @@ private:
|
||||||
bool include_meta;
|
bool include_meta;
|
||||||
bool tsv;
|
bool tsv;
|
||||||
|
|
||||||
string separator;
|
std::string separator;
|
||||||
string set_separator;
|
std::string set_separator;
|
||||||
string empty_field;
|
std::string empty_field;
|
||||||
string unset_field;
|
std::string unset_field;
|
||||||
string meta_prefix;
|
std::string meta_prefix;
|
||||||
|
|
||||||
int gzip_level; // level > 0 enables gzip compression
|
int gzip_level; // level > 0 enables gzip compression
|
||||||
string gzip_file_extension;
|
std::string gzip_file_extension;
|
||||||
bool use_json;
|
bool use_json;
|
||||||
bool enable_utf_8;
|
bool enable_utf_8;
|
||||||
string json_timestamps;
|
std::string json_timestamps;
|
||||||
|
|
||||||
threading::formatter::Formatter* formatter;
|
threading::formatter::Formatter* formatter;
|
||||||
bool init_options;
|
bool init_options;
|
||||||
|
@ -75,4 +75,3 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,14 @@ bool None::DoInit(const WriterInfo& info, int num_fields,
|
||||||
|
|
||||||
// Output the config sorted by keys.
|
// Output the config sorted by keys.
|
||||||
|
|
||||||
std::vector<std::pair<string, string> > keys;
|
std::vector<std::pair<std::string, std::string> > keys;
|
||||||
|
|
||||||
for ( WriterInfo::config_map::const_iterator i = info.config.begin(); i != info.config.end(); i++ )
|
for ( WriterInfo::config_map::const_iterator i = info.config.begin(); i != info.config.end(); i++ )
|
||||||
keys.push_back(std::make_pair(i->first, i->second));
|
keys.push_back(std::make_pair(i->first, i->second));
|
||||||
|
|
||||||
std::sort(keys.begin(), keys.end());
|
std::sort(keys.begin(), keys.end());
|
||||||
|
|
||||||
for ( std::vector<std::pair<string,string> >::const_iterator i = keys.begin(); i != keys.end(); i++ )
|
for ( std::vector<std::pair<std::string, std::string> >::const_iterator i = keys.begin(); i != keys.end(); i++ )
|
||||||
std::cout << " config[" << (*i).first << "] = " << (*i).second << std::endl;
|
std::cout << " config[" << (*i).first << "] = " << (*i).second << std::endl;
|
||||||
|
|
||||||
for ( int i = 0; i < num_fields; i++ )
|
for ( int i = 0; i < num_fields; i++ )
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "SQLite.h"
|
#include "SQLite.h"
|
||||||
#include "sqlite.bif.h"
|
#include "sqlite.bif.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace logging;
|
using namespace logging;
|
||||||
using namespace writer;
|
using namespace writer;
|
||||||
using threading::Value;
|
using threading::Value;
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
bool checkError(int code);
|
bool checkError(int code);
|
||||||
|
|
||||||
int AddParams(threading::Value* val, int pos);
|
int AddParams(threading::Value* val, int pos);
|
||||||
string GetTableType(int, int);
|
std::string GetTableType(int, int);
|
||||||
|
|
||||||
const threading::Field* const * fields; // raw mapping
|
const threading::Field* const * fields; // raw mapping
|
||||||
unsigned int num_fields;
|
unsigned int num_fields;
|
||||||
|
@ -45,9 +45,9 @@ private:
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
sqlite3_stmt *st;
|
sqlite3_stmt *st;
|
||||||
|
|
||||||
string set_separator;
|
std::string set_separator;
|
||||||
string unset_field;
|
std::string unset_field;
|
||||||
string empty_field;
|
std::string empty_field;
|
||||||
|
|
||||||
threading::formatter::Ascii* io;
|
threading::formatter::Ascii* io;
|
||||||
};
|
};
|
||||||
|
|
|
@ -137,8 +137,8 @@ const char* fmt_conn_id(const IPAddr& src_addr, uint32_t src_port,
|
||||||
static char buffer[512];
|
static char buffer[512];
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "%s:%d > %s:%d",
|
snprintf(buffer, sizeof(buffer), "%s:%d > %s:%d",
|
||||||
string(src_addr).c_str(), src_port,
|
std::string(src_addr).c_str(), src_port,
|
||||||
string(dst_addr).c_str(), dst_port);
|
std::string(dst_addr).c_str(), dst_port);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ extern int brolex();
|
||||||
* Part of the module facility: while parsing, keep track of which
|
* Part of the module facility: while parsing, keep track of which
|
||||||
* module to put things in.
|
* module to put things in.
|
||||||
*/
|
*/
|
||||||
string current_module = GLOBAL_MODULE_NAME;
|
std::string current_module = GLOBAL_MODULE_NAME;
|
||||||
bool is_export = false; // true if in an export {} block
|
bool is_export = false; // true if in an export {} block
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -196,7 +196,7 @@ static attr_list* copy_attr_list(attr_list* al)
|
||||||
|
|
||||||
static void extend_record(ID* id, type_decl_list* fields, attr_list* attrs)
|
static void extend_record(ID* id, type_decl_list* fields, attr_list* attrs)
|
||||||
{
|
{
|
||||||
set<BroType*> types = BroType::GetAliases(id->Name());
|
std::set<BroType*> types = BroType::GetAliases(id->Name());
|
||||||
|
|
||||||
if ( types.empty() )
|
if ( types.empty() )
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ static void extend_record(ID* id, type_decl_list* fields, attr_list* attrs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( set<BroType*>::const_iterator it = types.begin(); it != types.end(); )
|
for ( std::set<BroType*>::const_iterator it = types.begin(); it != types.end(); )
|
||||||
{
|
{
|
||||||
RecordType* add_to = (*it)->AsRecordType();
|
RecordType* add_to = (*it)->AsRecordType();
|
||||||
const char* error = 0;
|
const char* error = 0;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
* @param local_id The local part of the ID of the new enum type
|
* @param local_id The local part of the ID of the new enum type
|
||||||
* (e.g., "Tag").
|
* (e.g., "Tag").
|
||||||
*/
|
*/
|
||||||
ComponentManager(const string& module, const string& local_id);
|
ComponentManager(const std::string& module, const std::string& local_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The script-layer module in which the component's "Tag" ID lives.
|
* @return The script-layer module in which the component's "Tag" ID lives.
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @return A list of all registered components.
|
* @return A list of all registered components.
|
||||||
*/
|
*/
|
||||||
list<C*> GetComponents() const;
|
std::list<C*> GetComponents() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The enum type associated with the script-layer "Tag".
|
* @return The enum type associated with the script-layer "Tag".
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
* @return The component's tag, or a tag representing an error if
|
* @return The component's tag, or a tag representing an error if
|
||||||
* no such component assoicated with the name exists.
|
* no such component assoicated with the name exists.
|
||||||
*/
|
*/
|
||||||
T GetComponentTag(const string& name) const;
|
T GetComponentTag(const std::string& name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a component tag from its enum value.
|
* Get a component tag from its enum value.
|
||||||
|
@ -97,14 +97,14 @@ public:
|
||||||
* value will be a concatenation of this prefix and the component's
|
* value will be a concatenation of this prefix and the component's
|
||||||
* canonical name.
|
* canonical name.
|
||||||
*/
|
*/
|
||||||
void RegisterComponent(C* component, const string& prefix = "");
|
void RegisterComponent(C* component, const std::string& prefix = "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The canonical name of a component.
|
* @param name The canonical name of a component.
|
||||||
* @return The component associated with the name or a null pointer if no
|
* @return The component associated with the name or a null pointer if no
|
||||||
* such component exists.
|
* such component exists.
|
||||||
*/
|
*/
|
||||||
C* Lookup(const string& name) const;
|
C* Lookup(const std::string& name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name A component tag.
|
* @param name A component tag.
|
||||||
|
@ -121,15 +121,15 @@ public:
|
||||||
C* Lookup(EnumVal* val) const;
|
C* Lookup(EnumVal* val) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string module; /**< Script layer module in which component tags live. */
|
std::string module; /**< Script layer module in which component tags live. */
|
||||||
IntrusivePtr<EnumType> tag_enum_type; /**< Enum type of component tags. */
|
IntrusivePtr<EnumType> tag_enum_type; /**< Enum type of component tags. */
|
||||||
map<string, C*> components_by_name;
|
std::map<std::string, C*> components_by_name;
|
||||||
map<T, C*> components_by_tag;
|
std::map<T, C*> components_by_tag;
|
||||||
map<int, C*> components_by_val;
|
std::map<int, C*> components_by_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
ComponentManager<T, C>::ComponentManager(const string& arg_module, const string& local_id)
|
ComponentManager<T, C>::ComponentManager(const std::string& arg_module, const std::string& local_id)
|
||||||
: module(arg_module),
|
: module(arg_module),
|
||||||
tag_enum_type(make_intrusive<EnumType>(module + "::" + local_id))
|
tag_enum_type(make_intrusive<EnumType>(module + "::" + local_id))
|
||||||
{
|
{
|
||||||
|
@ -145,10 +145,10 @@ const std::string& ComponentManager<T, C>::GetModule() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
list<C*> ComponentManager<T, C>::GetComponents() const
|
std::list<C*> ComponentManager<T, C>::GetComponents() const
|
||||||
{
|
{
|
||||||
list<C*> rval;
|
std::list<C*> rval;
|
||||||
typename map<T, C*>::const_iterator i;
|
typename std::map<T, C*>::const_iterator i;
|
||||||
|
|
||||||
for ( i = components_by_tag.begin(); i != components_by_tag.end(); ++i )
|
for ( i = components_by_tag.begin(); i != components_by_tag.end(); ++i )
|
||||||
rval.push_back(i->second);
|
rval.push_back(i->second);
|
||||||
|
@ -187,7 +187,7 @@ const std::string& ComponentManager<T, C>::GetComponentName(Val* val) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
T ComponentManager<T, C>::GetComponentTag(const string& name) const
|
T ComponentManager<T, C>::GetComponentTag(const std::string& name) const
|
||||||
{
|
{
|
||||||
C* c = Lookup(name);
|
C* c = Lookup(name);
|
||||||
return c ? c->Tag() : T();
|
return c ? c->Tag() : T();
|
||||||
|
@ -201,9 +201,9 @@ T ComponentManager<T, C>::GetComponentTag(Val* v) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
C* ComponentManager<T, C>::Lookup(const string& name) const
|
C* ComponentManager<T, C>::Lookup(const std::string& name) const
|
||||||
{
|
{
|
||||||
typename map<string, C*>::const_iterator i =
|
typename std::map<std::string, C*>::const_iterator i =
|
||||||
components_by_name.find(to_upper(name));
|
components_by_name.find(to_upper(name));
|
||||||
return i != components_by_name.end() ? i->second : 0;
|
return i != components_by_name.end() ? i->second : 0;
|
||||||
}
|
}
|
||||||
|
@ -211,21 +211,21 @@ C* ComponentManager<T, C>::Lookup(const string& name) const
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
C* ComponentManager<T, C>::Lookup(const T& tag) const
|
C* ComponentManager<T, C>::Lookup(const T& tag) const
|
||||||
{
|
{
|
||||||
typename map<T, C*>::const_iterator i = components_by_tag.find(tag);
|
typename std::map<T, C*>::const_iterator i = components_by_tag.find(tag);
|
||||||
return i != components_by_tag.end() ? i->second : 0;
|
return i != components_by_tag.end() ? i->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
C* ComponentManager<T, C>::Lookup(EnumVal* val) const
|
C* ComponentManager<T, C>::Lookup(EnumVal* val) const
|
||||||
{
|
{
|
||||||
typename map<int, C*>::const_iterator i =
|
typename std::map<int, C*>::const_iterator i =
|
||||||
components_by_val.find(val->InternalInt());
|
components_by_val.find(val->InternalInt());
|
||||||
return i != components_by_val.end() ? i->second : 0;
|
return i != components_by_val.end() ? i->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
void ComponentManager<T, C>::RegisterComponent(C* component,
|
void ComponentManager<T, C>::RegisterComponent(C* component,
|
||||||
const string& prefix)
|
const std::string& prefix)
|
||||||
{
|
{
|
||||||
std::string cname = component->CanonicalName();
|
std::string cname = component->CanonicalName();
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ void ComponentManager<T, C>::RegisterComponent(C* component,
|
||||||
component->Tag().AsEnumVal()->InternalInt(), component));
|
component->Tag().AsEnumVal()->InternalInt(), component));
|
||||||
|
|
||||||
// Install an identfier for enum value
|
// Install an identfier for enum value
|
||||||
string id = fmt("%s%s", prefix.c_str(), cname.c_str());
|
std::string id = fmt("%s%s", prefix.c_str(), cname.c_str());
|
||||||
tag_enum_type->AddName(module, id.c_str(),
|
tag_enum_type->AddName(module, id.c_str(),
|
||||||
component->Tag().AsEnumVal()->InternalInt(), true,
|
component->Tag().AsEnumVal()->InternalInt(), true,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
#include "../input.h"
|
#include "../input.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace plugin;
|
using namespace plugin;
|
||||||
|
|
||||||
Plugin* Manager::current_plugin = 0;
|
Plugin* Manager::current_plugin = 0;
|
||||||
|
|
|
@ -238,7 +238,7 @@ public:
|
||||||
* if a plugin took over the file but had trouble loading it; and -1 if
|
* if a plugin took over the file but had trouble loading it; and -1 if
|
||||||
* no plugin was interested in the file at all.
|
* no plugin was interested in the file at all.
|
||||||
*/
|
*/
|
||||||
virtual int HookLoadFile(const Plugin::LoadType type, const string& file, const string& resolved);
|
virtual int HookLoadFile(const Plugin::LoadType type, const std::string& file, const std::string& resolved);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook that filters calls to a script function/event/hook.
|
* Hook that filters calls to a script function/event/hook.
|
||||||
|
|
|
@ -254,7 +254,7 @@ CountingBloomFilter* CountingBloomFilter::Clone() const
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
string CountingBloomFilter::InternalState() const
|
std::string CountingBloomFilter::InternalState() const
|
||||||
{
|
{
|
||||||
return fmt("%" PRIu64, cells->Hash());
|
return fmt("%" PRIu64, cells->Hash());
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ bool CardinalityCounter::Merge(CardinalityCounter* c)
|
||||||
if ( m != c->GetM() )
|
if ( m != c->GetM() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const vector<uint8_t>& temp = c->GetBuckets();
|
const std::vector<uint8_t>& temp = c->GetBuckets();
|
||||||
|
|
||||||
V = 0;
|
V = 0;
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ bool CardinalityCounter::Merge(CardinalityCounter* c)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<uint8_t> &CardinalityCounter::GetBuckets() const
|
const std::vector<uint8_t> &CardinalityCounter::GetBuckets() const
|
||||||
{
|
{
|
||||||
return buckets;
|
return buckets;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue