mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Move Type types to zeek namespace
This commit is contained in:
parent
4a1b39a2be
commit
ed13972924
120 changed files with 2094 additions and 1934 deletions
|
@ -1 +1 @@
|
|||
Subproject commit b1526de0d4b8639b51b79b712e83ea62597df1c0
|
||||
Subproject commit 519a0ed580c7826509239002a1e240eccb016013
|
|
@ -16,8 +16,8 @@ using id_list = PList<zeek::detail::ID>;
|
|||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||
using stmt_list = PList<zeek::detail::Stmt>;
|
||||
|
||||
class BroType;
|
||||
using type_list = PList<BroType>;
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
using type_list = PList<zeek::BroType>;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
|
||||
using attr_list = PList<zeek::detail::Attr>;
|
||||
|
|
194
src/CompHash.cc
194
src/CompHash.cc
|
@ -14,17 +14,17 @@
|
|||
#include "Func.h"
|
||||
#include "IPAddr.h"
|
||||
|
||||
CompositeHash::CompositeHash(IntrusivePtr<TypeList> composite_type)
|
||||
CompositeHash::CompositeHash(IntrusivePtr<zeek::TypeList> composite_type)
|
||||
: type(std::move(composite_type))
|
||||
{
|
||||
singleton_tag = TYPE_INTERNAL_ERROR;
|
||||
singleton_tag = zeek::TYPE_INTERNAL_ERROR;
|
||||
|
||||
// If the only element is a record, don't treat it as a
|
||||
// singleton, since it needs to be evaluated specially.
|
||||
|
||||
if ( type->Types().size() == 1 )
|
||||
{
|
||||
if ( type->Types()[0]->Tag() == TYPE_RECORD )
|
||||
if ( type->Types()[0]->Tag() == zeek::TYPE_RECORD )
|
||||
{
|
||||
is_complex_type = true;
|
||||
is_singleton = false;
|
||||
|
@ -71,10 +71,10 @@ CompositeHash::~CompositeHash()
|
|||
|
||||
// Computes the piece of the hash for Val*, returning the new kp.
|
||||
char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||
BroType* bt, Val* v, bool optional) const
|
||||
zeek::BroType* bt, Val* v, bool optional) const
|
||||
{
|
||||
char* kp1 = nullptr;
|
||||
InternalTypeTag t = bt->InternalType();
|
||||
zeek::InternalTypeTag t = bt->InternalType();
|
||||
|
||||
if ( optional )
|
||||
{
|
||||
|
@ -89,13 +89,13 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
|
||||
if ( type_check )
|
||||
{
|
||||
InternalTypeTag vt = v->GetType()->InternalType();
|
||||
zeek::InternalTypeTag vt = v->GetType()->InternalType();
|
||||
if ( vt != t )
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch ( t ) {
|
||||
case TYPE_INTERNAL_INT:
|
||||
case zeek::TYPE_INTERNAL_INT:
|
||||
{
|
||||
bro_int_t* kp = AlignAndPadType<bro_int_t>(kp0);
|
||||
*kp = v->ForceAsInt();
|
||||
|
@ -103,7 +103,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_UNSIGNED:
|
||||
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||
{
|
||||
bro_uint_t* kp = AlignAndPadType<bro_uint_t>(kp0);
|
||||
*kp = v->ForceAsUInt();
|
||||
|
@ -111,7 +111,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_ADDR:
|
||||
case zeek::TYPE_INTERNAL_ADDR:
|
||||
{
|
||||
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
||||
v->AsAddr().CopyIPv6(kp);
|
||||
|
@ -119,7 +119,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_SUBNET:
|
||||
case zeek::TYPE_INTERNAL_SUBNET:
|
||||
{
|
||||
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
||||
v->AsSubNet().Prefix().CopyIPv6(kp);
|
||||
|
@ -128,7 +128,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_DOUBLE:
|
||||
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||
{
|
||||
double* kp = AlignAndPadType<double>(kp0);
|
||||
*kp = v->InternalDouble();
|
||||
|
@ -136,11 +136,11 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_VOID:
|
||||
case TYPE_INTERNAL_OTHER:
|
||||
case zeek::TYPE_INTERNAL_VOID:
|
||||
case zeek::TYPE_INTERNAL_OTHER:
|
||||
{
|
||||
switch ( v->GetType()->Tag() ) {
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_FUNC:
|
||||
{
|
||||
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
||||
*kp = v->AsFunc()->GetUniqueFuncID();
|
||||
|
@ -148,7 +148,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_PATTERN:
|
||||
{
|
||||
const char* texts[2] = {
|
||||
v->AsPattern()->PatternText(),
|
||||
|
@ -172,11 +172,11 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_RECORD:
|
||||
case zeek::TYPE_RECORD:
|
||||
{
|
||||
char* kp = kp0;
|
||||
RecordVal* rv = v->AsRecordVal();
|
||||
RecordType* rt = bt->AsRecordType();
|
||||
zeek::RecordType* rt = bt->AsRecordType();
|
||||
int num_fields = rt->NumFields();
|
||||
|
||||
for ( int i = 0; i < num_fields; ++i )
|
||||
|
@ -199,7 +199,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
int* kp = AlignAndPadType<int>(kp0);
|
||||
TableVal* tv = v->AsTableVal();
|
||||
|
@ -208,7 +208,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
|
||||
auto tbl = tv->AsTable();
|
||||
auto it = tbl->InitForIteration();
|
||||
auto lv = make_intrusive<ListVal>(TYPE_ANY);
|
||||
auto lv = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||
|
||||
struct HashKeyComparer {
|
||||
bool operator()(const HashKey* a, const HashKey* b) const
|
||||
|
@ -258,11 +258,11 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
unsigned int* kp = AlignAndPadType<unsigned int>(kp0);
|
||||
VectorVal* vv = v->AsVectorVal();
|
||||
VectorType* vt = v->GetType()->AsVectorType();
|
||||
zeek::VectorType* vt = v->GetType()->AsVectorType();
|
||||
*kp = vv->Size();
|
||||
kp1 = reinterpret_cast<char*>(kp+1);
|
||||
for ( unsigned int i = 0; i < vv->Size(); ++i )
|
||||
|
@ -286,7 +286,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_LIST:
|
||||
case zeek::TYPE_LIST:
|
||||
{
|
||||
int* kp = AlignAndPadType<int>(kp0);
|
||||
ListVal* lv = v->AsListVal();
|
||||
|
@ -309,10 +309,10 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
}
|
||||
|
||||
break; // case TYPE_INTERNAL_VOID/OTHER
|
||||
break; // case zeek::TYPE_INTERNAL_VOID/OTHER
|
||||
}
|
||||
|
||||
case TYPE_INTERNAL_STRING:
|
||||
case zeek::TYPE_INTERNAL_STRING:
|
||||
{
|
||||
// Align to int for the length field.
|
||||
int* kp = AlignAndPadType<int>(kp0);
|
||||
|
@ -327,7 +327,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_ERROR:
|
||||
case zeek::TYPE_INTERNAL_ERROR:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -342,9 +342,9 @@ std::unique_ptr<HashKey> CompositeHash::MakeHashKey(const Val& argv, bool type_c
|
|||
if ( is_singleton )
|
||||
return ComputeSingletonHash(v, type_check);
|
||||
|
||||
if ( is_complex_type && v->GetType()->Tag() != TYPE_LIST )
|
||||
if ( is_complex_type && v->GetType()->Tag() != zeek::TYPE_LIST )
|
||||
{
|
||||
ListVal lv(TYPE_ANY);
|
||||
ListVal lv(zeek::TYPE_ANY);
|
||||
|
||||
// Cast away const to use ListVal - but since we
|
||||
// re-introduce const on the recursive call, it should
|
||||
|
@ -368,7 +368,7 @@ std::unique_ptr<HashKey> CompositeHash::MakeHashKey(const Val& argv, bool type_c
|
|||
|
||||
const auto& tl = type->Types();
|
||||
|
||||
if ( type_check && v->GetType()->Tag() != TYPE_LIST )
|
||||
if ( type_check && v->GetType()->Tag() != zeek::TYPE_LIST )
|
||||
return nullptr;
|
||||
|
||||
auto lv = v->AsListVal();
|
||||
|
@ -389,7 +389,7 @@ std::unique_ptr<HashKey> CompositeHash::MakeHashKey(const Val& argv, bool type_c
|
|||
|
||||
std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool type_check) const
|
||||
{
|
||||
if ( v->GetType()->Tag() == TYPE_LIST )
|
||||
if ( v->GetType()->Tag() == zeek::TYPE_LIST )
|
||||
{
|
||||
auto lv = v->AsListVal();
|
||||
|
||||
|
@ -403,25 +403,25 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool
|
|||
return nullptr;
|
||||
|
||||
switch ( singleton_tag ) {
|
||||
case TYPE_INTERNAL_INT:
|
||||
case TYPE_INTERNAL_UNSIGNED:
|
||||
case zeek::TYPE_INTERNAL_INT:
|
||||
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||
return std::make_unique<HashKey>(v->ForceAsInt());
|
||||
|
||||
case TYPE_INTERNAL_ADDR:
|
||||
case zeek::TYPE_INTERNAL_ADDR:
|
||||
return v->AsAddr().MakeHashKey();
|
||||
|
||||
case TYPE_INTERNAL_SUBNET:
|
||||
case zeek::TYPE_INTERNAL_SUBNET:
|
||||
return v->AsSubNet().MakeHashKey();
|
||||
|
||||
case TYPE_INTERNAL_DOUBLE:
|
||||
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||
return std::make_unique<HashKey>(v->InternalDouble());
|
||||
|
||||
case TYPE_INTERNAL_VOID:
|
||||
case TYPE_INTERNAL_OTHER:
|
||||
if ( v->GetType()->Tag() == TYPE_FUNC )
|
||||
case zeek::TYPE_INTERNAL_VOID:
|
||||
case zeek::TYPE_INTERNAL_OTHER:
|
||||
if ( v->GetType()->Tag() == zeek::TYPE_FUNC )
|
||||
return std::make_unique<HashKey>(v->AsFunc()->GetUniqueFuncID());
|
||||
|
||||
if ( v->GetType()->Tag() == TYPE_PATTERN )
|
||||
if ( v->GetType()->Tag() == zeek::TYPE_PATTERN )
|
||||
{
|
||||
const char* texts[2] = {
|
||||
v->AsPattern()->PatternText(),
|
||||
|
@ -437,10 +437,10 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool
|
|||
reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash");
|
||||
return nullptr;
|
||||
|
||||
case TYPE_INTERNAL_STRING:
|
||||
case zeek::TYPE_INTERNAL_STRING:
|
||||
return std::make_unique<HashKey>(v->AsString());
|
||||
|
||||
case TYPE_INTERNAL_ERROR:
|
||||
case zeek::TYPE_INTERNAL_ERROR:
|
||||
return nullptr;
|
||||
|
||||
default:
|
||||
|
@ -449,53 +449,53 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool
|
|||
}
|
||||
}
|
||||
|
||||
int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||
int CompositeHash::SingleTypeKeySize(zeek::BroType* bt, const Val* v,
|
||||
bool type_check, int sz, bool optional,
|
||||
bool calc_static_size) const
|
||||
{
|
||||
InternalTypeTag t = bt->InternalType();
|
||||
zeek::InternalTypeTag t = bt->InternalType();
|
||||
|
||||
if ( optional )
|
||||
sz = SizeAlign(sz, sizeof(char));
|
||||
|
||||
if ( type_check && v )
|
||||
{
|
||||
InternalTypeTag vt = v->GetType()->InternalType();
|
||||
zeek::InternalTypeTag vt = v->GetType()->InternalType();
|
||||
if ( vt != t )
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch ( t ) {
|
||||
case TYPE_INTERNAL_INT:
|
||||
case TYPE_INTERNAL_UNSIGNED:
|
||||
case zeek::TYPE_INTERNAL_INT:
|
||||
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||
sz = SizeAlign(sz, sizeof(bro_int_t));
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_ADDR:
|
||||
case zeek::TYPE_INTERNAL_ADDR:
|
||||
sz = SizeAlign(sz, sizeof(uint32_t));
|
||||
sz += sizeof(uint32_t) * 3; // to make a total of 4 words
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_SUBNET:
|
||||
case zeek::TYPE_INTERNAL_SUBNET:
|
||||
sz = SizeAlign(sz, sizeof(uint32_t));
|
||||
sz += sizeof(uint32_t) * 4; // to make a total of 5 words
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_DOUBLE:
|
||||
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||
sz = SizeAlign(sz, sizeof(double));
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_VOID:
|
||||
case TYPE_INTERNAL_OTHER:
|
||||
case zeek::TYPE_INTERNAL_VOID:
|
||||
case zeek::TYPE_INTERNAL_OTHER:
|
||||
{
|
||||
switch ( bt->Tag() ) {
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_FUNC:
|
||||
{
|
||||
sz = SizeAlign(sz, sizeof(uint32_t));
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_PATTERN:
|
||||
{
|
||||
if ( ! v )
|
||||
return (optional && ! calc_static_size) ? sz : 0;
|
||||
|
@ -506,10 +506,10 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_RECORD:
|
||||
case zeek::TYPE_RECORD:
|
||||
{
|
||||
const RecordVal* rv = v ? v->AsRecordVal() : nullptr;
|
||||
RecordType* rt = bt->AsRecordType();
|
||||
zeek::RecordType* rt = bt->AsRecordType();
|
||||
int num_fields = rt->NumFields();
|
||||
|
||||
for ( int i = 0; i < num_fields; ++i )
|
||||
|
@ -528,7 +528,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
if ( ! v )
|
||||
return (optional && ! calc_static_size) ? sz : 0;
|
||||
|
@ -557,7 +557,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
if ( ! v )
|
||||
return (optional && ! calc_static_size) ? sz : 0;
|
||||
|
@ -579,7 +579,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_LIST:
|
||||
case zeek::TYPE_LIST:
|
||||
{
|
||||
if ( ! v )
|
||||
return (optional && ! calc_static_size) ? sz : 0;
|
||||
|
@ -603,10 +603,10 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
}
|
||||
}
|
||||
|
||||
break; // case TYPE_INTERNAL_VOID/OTHER
|
||||
break; // case zeek::TYPE_INTERNAL_VOID/OTHER
|
||||
}
|
||||
|
||||
case TYPE_INTERNAL_STRING:
|
||||
case zeek::TYPE_INTERNAL_STRING:
|
||||
if ( ! v )
|
||||
return (optional && ! calc_static_size) ? sz : 0;
|
||||
|
||||
|
@ -615,7 +615,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
sz += v->AsString()->Len();
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_ERROR:
|
||||
case zeek::TYPE_INTERNAL_ERROR:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ int CompositeHash::ComputeKeySize(const Val* v, bool type_check, bool calc_stati
|
|||
|
||||
if ( v )
|
||||
{
|
||||
if ( type_check && v->GetType()->Tag() != TYPE_LIST )
|
||||
if ( type_check && v->GetType()->Tag() != zeek::TYPE_LIST )
|
||||
return 0;
|
||||
|
||||
auto lv = v->AsListVal();
|
||||
|
@ -710,7 +710,7 @@ int CompositeHash::SizeAlign(int offset, unsigned int size) const
|
|||
|
||||
IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
||||
{
|
||||
auto l = make_intrusive<ListVal>(TYPE_ANY);
|
||||
auto l = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||
const auto& tl = type->Types();
|
||||
const char* kp = (const char*) k.Key();
|
||||
const char* const k_end = kp + k.Size();
|
||||
|
@ -730,15 +730,15 @@ IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
|||
}
|
||||
|
||||
const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||
const char* const k_end, BroType* t,
|
||||
const char* const k_end, zeek::BroType* t,
|
||||
IntrusivePtr<Val>* pval, bool optional) const
|
||||
{
|
||||
// k->Size() == 0 for a single empty string.
|
||||
if ( kp0 >= k_end && k.Size() > 0 )
|
||||
reporter->InternalError("over-ran key in CompositeHash::RecoverVals");
|
||||
|
||||
TypeTag tag = t->Tag();
|
||||
InternalTypeTag it = t->InternalType();
|
||||
zeek::TypeTag tag = t->Tag();
|
||||
zeek::InternalTypeTag it = t->InternalType();
|
||||
const char* kp1 = nullptr;
|
||||
|
||||
if ( optional )
|
||||
|
@ -754,16 +754,16 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
|
||||
switch ( it ) {
|
||||
case TYPE_INTERNAL_INT:
|
||||
case zeek::TYPE_INTERNAL_INT:
|
||||
{
|
||||
const bro_int_t* const kp = AlignType<bro_int_t>(kp0);
|
||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||
|
||||
if ( tag == TYPE_ENUM )
|
||||
if ( tag == zeek::TYPE_ENUM )
|
||||
*pval = t->AsEnumType()->GetVal(*kp);
|
||||
else if ( tag == TYPE_BOOL )
|
||||
else if ( tag == zeek::TYPE_BOOL )
|
||||
*pval = val_mgr->Bool(*kp);
|
||||
else if ( tag == TYPE_INT )
|
||||
else if ( tag == zeek::TYPE_INT )
|
||||
*pval = val_mgr->Int(*kp);
|
||||
else
|
||||
{
|
||||
|
@ -773,18 +773,18 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_UNSIGNED:
|
||||
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||
{
|
||||
const bro_uint_t* const kp = AlignType<bro_uint_t>(kp0);
|
||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||
|
||||
switch ( tag ) {
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
*pval = val_mgr->Count(*kp);
|
||||
break;
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
*pval = val_mgr->Port(*kp);
|
||||
break;
|
||||
|
||||
|
@ -796,21 +796,21 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_DOUBLE:
|
||||
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||
{
|
||||
const double* const kp = AlignType<double>(kp0);
|
||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||
|
||||
if ( tag == TYPE_INTERVAL )
|
||||
if ( tag == zeek::TYPE_INTERVAL )
|
||||
*pval = make_intrusive<IntervalVal>(*kp, 1.0);
|
||||
else if ( tag == TYPE_TIME )
|
||||
else if ( tag == zeek::TYPE_TIME )
|
||||
*pval = make_intrusive<TimeVal>(*kp);
|
||||
else
|
||||
*pval = make_intrusive<DoubleVal>(*kp);
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_ADDR:
|
||||
case zeek::TYPE_INTERNAL_ADDR:
|
||||
{
|
||||
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
||||
kp1 = reinterpret_cast<const char*>(kp+4);
|
||||
|
@ -818,7 +818,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
IPAddr addr(IPv6, kp, IPAddr::Network);
|
||||
|
||||
switch ( tag ) {
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
*pval = make_intrusive<AddrVal>(addr);
|
||||
break;
|
||||
|
||||
|
@ -830,7 +830,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_SUBNET:
|
||||
case zeek::TYPE_INTERNAL_SUBNET:
|
||||
{
|
||||
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
||||
kp1 = reinterpret_cast<const char*>(kp+5);
|
||||
|
@ -838,11 +838,11 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_VOID:
|
||||
case TYPE_INTERNAL_OTHER:
|
||||
case zeek::TYPE_INTERNAL_VOID:
|
||||
case zeek::TYPE_INTERNAL_OTHER:
|
||||
{
|
||||
switch ( t->Tag() ) {
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_FUNC:
|
||||
{
|
||||
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||
|
@ -858,18 +858,18 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
if ( ! pvt )
|
||||
reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()");
|
||||
|
||||
else if ( t->Tag() != TYPE_FUNC && ! same_type(pvt, t) )
|
||||
else if ( t->Tag() != zeek::TYPE_FUNC && ! same_type(pvt, t) )
|
||||
// ### Maybe fix later, but may be fundamentally
|
||||
// un-checkable --US
|
||||
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
|
||||
|
||||
// ### A crude approximation for now.
|
||||
else if ( t->Tag() == TYPE_FUNC && pvt->Tag() != TYPE_FUNC )
|
||||
else if ( t->Tag() == zeek::TYPE_FUNC && pvt->Tag() != zeek::TYPE_FUNC )
|
||||
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_PATTERN:
|
||||
{
|
||||
RE_Matcher* re = nullptr;
|
||||
if ( is_singleton )
|
||||
|
@ -896,10 +896,10 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_RECORD:
|
||||
case zeek::TYPE_RECORD:
|
||||
{
|
||||
const char* kp = kp0;
|
||||
RecordType* rt = t->AsRecordType();
|
||||
zeek::RecordType* rt = t->AsRecordType();
|
||||
int num_fields = rt->NumFields();
|
||||
|
||||
std::vector<IntrusivePtr<Val>> values;
|
||||
|
@ -939,13 +939,13 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
int n;
|
||||
const int* const kp = AlignType<int>(kp0);
|
||||
n = *kp;
|
||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||
TableType* tt = t->AsTableType();
|
||||
zeek::TableType* tt = t->AsTableType();
|
||||
auto tv = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt});
|
||||
|
||||
for ( int i = 0; i < n; ++i )
|
||||
|
@ -968,13 +968,13 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
unsigned int n;
|
||||
const unsigned int* kp = AlignType<unsigned int>(kp0);
|
||||
n = *kp;
|
||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||
VectorType* vt = t->AsVectorType();
|
||||
zeek::VectorType* vt = t->AsVectorType();
|
||||
auto vv = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, vt});
|
||||
|
||||
for ( unsigned int i = 0; i < n; ++i )
|
||||
|
@ -998,19 +998,19 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_LIST:
|
||||
case zeek::TYPE_LIST:
|
||||
{
|
||||
int n;
|
||||
const int* const kp = AlignType<int>(kp0);
|
||||
n = *kp;
|
||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||
TypeList* tl = t->AsTypeList();
|
||||
auto lv = make_intrusive<ListVal>(TYPE_ANY);
|
||||
zeek::TypeList* tl = t->AsTypeList();
|
||||
auto lv = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||
|
||||
for ( int i = 0; i < n; ++i )
|
||||
{
|
||||
IntrusivePtr<Val> v;
|
||||
BroType* it = tl->Types()[i].get();
|
||||
zeek::BroType* it = tl->Types()[i].get();
|
||||
kp1 = RecoverOneVal(k, kp1, k_end, it, &v, false);
|
||||
lv->Append(std::move(v));
|
||||
}
|
||||
|
@ -1027,7 +1027,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_STRING:
|
||||
case zeek::TYPE_INTERNAL_STRING:
|
||||
{
|
||||
// There is a minor issue here -- the pointer does not have to
|
||||
// be aligned by int in the singleton case.
|
||||
|
@ -1050,7 +1050,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_INTERNAL_ERROR:
|
||||
case zeek::TYPE_INTERNAL_ERROR:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class HashKey;
|
|||
|
||||
class CompositeHash {
|
||||
public:
|
||||
explicit CompositeHash(IntrusivePtr<TypeList> composite_type);
|
||||
explicit CompositeHash(IntrusivePtr<zeek::TypeList> composite_type);
|
||||
~CompositeHash();
|
||||
|
||||
// Compute the hash corresponding to the given index val,
|
||||
|
@ -37,7 +37,7 @@ protected:
|
|||
|
||||
// Computes the piece of the hash for Val*, returning the new kp.
|
||||
// Used as a helper for ComputeHash in the non-singleton case.
|
||||
char* SingleValHash(bool type_check, char* kp, BroType* bt, Val* v,
|
||||
char* SingleValHash(bool type_check, char* kp, zeek::BroType* bt, Val* v,
|
||||
bool optional) const;
|
||||
|
||||
// Recovers just one Val of possibly many; called from RecoverVals.
|
||||
|
@ -46,7 +46,7 @@ protected:
|
|||
// upon errors, so there is no return value for invalid input.
|
||||
const char* RecoverOneVal(const HashKey& k,
|
||||
const char* kp, const char* const k_end,
|
||||
BroType* t, IntrusivePtr<Val>* pval, bool optional) const;
|
||||
zeek::BroType* t, IntrusivePtr<Val>* pval, bool optional) const;
|
||||
|
||||
// Rounds the given pointer up to the nearest multiple of the
|
||||
// given size, if not already a multiple.
|
||||
|
@ -85,11 +85,11 @@ protected:
|
|||
int ComputeKeySize(const Val* v, bool type_check,
|
||||
bool calc_static_size) const;
|
||||
|
||||
int SingleTypeKeySize(BroType*, const Val*,
|
||||
int SingleTypeKeySize(zeek::BroType*, const Val*,
|
||||
bool type_check, int sz, bool optional,
|
||||
bool calc_static_size) const;
|
||||
|
||||
IntrusivePtr<TypeList> type;
|
||||
IntrusivePtr<zeek::TypeList> type;
|
||||
char* key; // space for composite key
|
||||
int size;
|
||||
bool is_singleton; // if just one type in index
|
||||
|
@ -97,5 +97,5 @@ protected:
|
|||
// If one type, but not normal "singleton", e.g. record.
|
||||
bool is_complex_type;
|
||||
|
||||
InternalTypeTag singleton_tag;
|
||||
zeek::InternalTypeTag singleton_tag;
|
||||
};
|
||||
|
|
|
@ -175,10 +175,10 @@ void DNS_Mgr_mapping_delete_func(void* v)
|
|||
|
||||
static IntrusivePtr<TableVal> empty_addr_set()
|
||||
{
|
||||
auto addr_t = base_type(TYPE_ADDR);
|
||||
auto set_index = make_intrusive<TypeList>(addr_t);
|
||||
auto addr_t = zeek::base_type(zeek::TYPE_ADDR);
|
||||
auto set_index = make_intrusive<zeek::TypeList>(addr_t);
|
||||
set_index->Append(std::move(addr_t));
|
||||
auto s = make_intrusive<SetType>(std::move(set_index), nullptr);
|
||||
auto s = make_intrusive<zeek::SetType>(std::move(set_index), nullptr);
|
||||
return make_intrusive<TableVal>(std::move(s));
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ IntrusivePtr<ListVal> DNS_Mapping::Addrs()
|
|||
|
||||
if ( ! addrs_val )
|
||||
{
|
||||
auto addrs_val = make_intrusive<ListVal>(TYPE_ADDR);
|
||||
auto addrs_val = make_intrusive<ListVal>(zeek::TYPE_ADDR);
|
||||
|
||||
for ( int i = 0; i < num_addrs; ++i )
|
||||
addrs_val->Append(make_intrusive<AddrVal>(addrs[i]));
|
||||
|
@ -450,7 +450,7 @@ void DNS_Mgr::InitSource()
|
|||
|
||||
void DNS_Mgr::InitPostScript()
|
||||
{
|
||||
dm_rec = zeek::id::find_type<RecordType>("dns_mapping");
|
||||
dm_rec = zeek::id::find_type<zeek::RecordType>("dns_mapping");
|
||||
|
||||
// Registering will call Init()
|
||||
iosource_mgr->Register(this, true);
|
||||
|
@ -465,7 +465,7 @@ static IntrusivePtr<TableVal> fake_name_lookup_result(const char* name)
|
|||
{
|
||||
hash128_t hash;
|
||||
KeyedHash::StaticHash128(name, strlen(name), &hash);
|
||||
auto hv = make_intrusive<ListVal>(TYPE_ADDR);
|
||||
auto hv = make_intrusive<ListVal>(zeek::TYPE_ADDR);
|
||||
hv->Append(make_intrusive<AddrVal>(reinterpret_cast<const uint32_t*>(&hash)));
|
||||
return hv->ToSetVal();
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ void DNS_Mgr::CompareMappings(DNS_Mapping* prev_dm, DNS_Mapping* new_dm)
|
|||
|
||||
IntrusivePtr<ListVal> DNS_Mgr::AddrListDelta(ListVal* al1, ListVal* al2)
|
||||
{
|
||||
auto delta = make_intrusive<ListVal>(TYPE_ADDR);
|
||||
auto delta = make_intrusive<ListVal>(zeek::TYPE_ADDR);
|
||||
|
||||
for ( int i = 0; i < al1->Length(); ++i )
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "EventHandler.h"
|
||||
#include "iosource/IOSource.h"
|
||||
#include "IPAddr.h"
|
||||
#include "util.h"
|
||||
|
||||
template <class T> class IntrusivePtr;
|
||||
class Val;
|
||||
|
@ -18,9 +19,10 @@ class ListVal;
|
|||
class TableVal;
|
||||
class Func;
|
||||
class EventHandler;
|
||||
class RecordType;
|
||||
class DNS_Mgr_Request;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
|
||||
|
||||
typedef PList<DNS_Mgr_Request> DNS_mgr_request_list;
|
||||
|
||||
struct nb_dns_info;
|
||||
|
@ -149,7 +151,7 @@ protected:
|
|||
|
||||
bool did_init;
|
||||
|
||||
IntrusivePtr<RecordType> dm_rec;
|
||||
IntrusivePtr<zeek::RecordType> dm_rec;
|
||||
|
||||
typedef std::list<LookupCallback*> CallbackList;
|
||||
|
||||
|
|
|
@ -258,8 +258,8 @@ BreakCode DbgBreakpoint::HasHit()
|
|||
return bcHit;
|
||||
}
|
||||
|
||||
if ( ! IsIntegral(yes->GetType()->Tag()) &&
|
||||
! IsBool(yes->GetType()->Tag()) )
|
||||
if ( ! zeek::IsIntegral(yes->GetType()->Tag()) &&
|
||||
! zeek::IsBool(yes->GetType()->Tag()) )
|
||||
{
|
||||
PrintHitMsg();
|
||||
debug_msg("Breakpoint condition should return an integral type");
|
||||
|
|
|
@ -65,7 +65,7 @@ static void lookup_global_symbols_regex(const string& orig_regex, vector<zeek::d
|
|||
for ( const auto& sym : syms )
|
||||
{
|
||||
zeek::detail::ID* nextid = sym.second.get();
|
||||
if ( ! func_only || nextid->GetType()->Tag() == TYPE_FUNC )
|
||||
if ( ! func_only || nextid->GetType()->Tag() == zeek::TYPE_FUNC )
|
||||
if ( ! regexec (&re, nextid->Name(), 0, 0, 0) )
|
||||
matches.push_back(nextid);
|
||||
}
|
||||
|
|
|
@ -403,19 +403,19 @@ void ODesc::Clear()
|
|||
}
|
||||
}
|
||||
|
||||
bool ODesc::PushType(const BroType* type)
|
||||
bool ODesc::PushType(const zeek::BroType* type)
|
||||
{
|
||||
auto res = encountered_types.insert(type);
|
||||
return std::get<1>(res);
|
||||
}
|
||||
|
||||
bool ODesc::PopType(const BroType* type)
|
||||
bool ODesc::PopType(const zeek::BroType* type)
|
||||
{
|
||||
size_t res = encountered_types.erase(type);
|
||||
return (res == 1);
|
||||
}
|
||||
|
||||
bool ODesc::FindType(const BroType* type)
|
||||
bool ODesc::FindType(const zeek::BroType* type)
|
||||
{
|
||||
auto res = encountered_types.find(type);
|
||||
|
||||
|
|
10
src/Desc.h
10
src/Desc.h
|
@ -25,7 +25,7 @@ typedef enum {
|
|||
class BroFile;
|
||||
class IPAddr;
|
||||
class IPPrefix;
|
||||
class BroType;
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
|
||||
class ODesc {
|
||||
public:
|
||||
|
@ -146,9 +146,9 @@ public:
|
|||
|
||||
// Used to determine recursive types. Records push their types on here;
|
||||
// if the same type (by address) is re-encountered, processing aborts.
|
||||
bool PushType(const BroType* type);
|
||||
bool PopType(const BroType* type);
|
||||
bool FindType(const BroType* type);
|
||||
bool PushType(const zeek::BroType* type);
|
||||
bool PopType(const zeek::BroType* type);
|
||||
bool FindType(const zeek::BroType* type);
|
||||
|
||||
protected:
|
||||
void Indent();
|
||||
|
@ -204,5 +204,5 @@ protected:
|
|||
bool do_flush;
|
||||
bool include_stats;
|
||||
|
||||
std::set<const BroType*> encountered_types;
|
||||
std::set<const zeek::BroType*> encountered_types;
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ EventHandler::operator bool() const
|
|||
|| ! auto_publish.empty());
|
||||
}
|
||||
|
||||
const IntrusivePtr<FuncType>& EventHandler::GetType(bool check_export)
|
||||
const IntrusivePtr<zeek::FuncType>& EventHandler::GetType(bool check_export)
|
||||
{
|
||||
if ( type )
|
||||
return type;
|
||||
|
@ -35,12 +35,12 @@ const IntrusivePtr<FuncType>& EventHandler::GetType(bool check_export)
|
|||
check_export);
|
||||
|
||||
if ( ! id )
|
||||
return FuncType::nil;
|
||||
return zeek::FuncType::nil;
|
||||
|
||||
if ( id->GetType()->Tag() != TYPE_FUNC )
|
||||
return FuncType::nil;
|
||||
if ( id->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||
return zeek::FuncType::nil;
|
||||
|
||||
type = id->GetType<FuncType>();
|
||||
type = id->GetType<zeek::FuncType>();
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ void EventHandler::NewEvent(zeek::Args* vl)
|
|||
return;
|
||||
|
||||
const auto& args = GetType()->Params();
|
||||
static auto call_argument_vector = zeek::id::find_type<VectorType>("call_argument_vector");
|
||||
static auto call_argument_vector = zeek::id::find_type<zeek::VectorType>("call_argument_vector");
|
||||
auto vargs = make_intrusive<VectorVal>(call_argument_vector);
|
||||
|
||||
for ( int i = 0; i < args->NumFields(); i++ )
|
||||
|
@ -120,7 +120,7 @@ void EventHandler::NewEvent(zeek::Args* vl)
|
|||
const auto& ftype = args->GetFieldType(i);
|
||||
auto fdefault = args->FieldDefault(i);
|
||||
|
||||
static auto call_argument = zeek::id::find_type<RecordType>("call_argument");
|
||||
static auto call_argument = zeek::id::find_type<zeek::RecordType>("call_argument");
|
||||
auto rec = make_intrusive<RecordVal>(call_argument);
|
||||
rec->Assign(0, make_intrusive<StringVal>(fname));
|
||||
|
||||
|
@ -144,4 +144,3 @@ void EventHandler::NewEvent(zeek::Args* vl)
|
|||
});
|
||||
mgr.Dispatch(ev);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ public:
|
|||
[[deprecated("Remove in v4.1. Use GetFunc().")]]
|
||||
Func* LocalHandler() { return local.get(); }
|
||||
|
||||
const IntrusivePtr<FuncType>& GetType(bool check_export = true);
|
||||
const IntrusivePtr<zeek::FuncType>& GetType(bool check_export = true);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
FuncType* FType(bool check_export = true)
|
||||
zeek::FuncType* FType(bool check_export = true)
|
||||
{ return GetType().get(); }
|
||||
|
||||
void SetFunc(IntrusivePtr<Func> f)
|
||||
|
@ -70,7 +70,7 @@ private:
|
|||
|
||||
std::string name;
|
||||
IntrusivePtr<Func> local;
|
||||
IntrusivePtr<FuncType> type;
|
||||
IntrusivePtr<zeek::FuncType> type;
|
||||
bool used; // this handler is indeed used somewhere
|
||||
bool enabled;
|
||||
bool error_handler; // this handler reports error messages.
|
||||
|
|
436
src/Expr.cc
436
src/Expr.cc
File diff suppressed because it is too large
Load diff
|
@ -704,7 +704,7 @@ protected:
|
|||
|
||||
class ArithCoerceExpr final : public UnaryExpr {
|
||||
public:
|
||||
ArithCoerceExpr(IntrusivePtr<Expr> op, TypeTag t);
|
||||
ArithCoerceExpr(IntrusivePtr<Expr> op, zeek::TypeTag t);
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> FoldSingleVal(Val* v, InternalTypeTag t) const;
|
||||
|
|
|
@ -58,7 +58,7 @@ BroFile::BroFile(FILE* arg_f)
|
|||
Init();
|
||||
f = arg_f;
|
||||
name = access = nullptr;
|
||||
t = base_type(TYPE_STRING);
|
||||
t = zeek::base_type(zeek::TYPE_STRING);
|
||||
is_open = (f != nullptr);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ BroFile::BroFile(FILE* arg_f, const char* arg_name, const char* arg_access)
|
|||
f = arg_f;
|
||||
name = copy_string(arg_name);
|
||||
access = copy_string(arg_access);
|
||||
t = base_type(TYPE_STRING);
|
||||
t = zeek::base_type(zeek::TYPE_STRING);
|
||||
is_open = (f != nullptr);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ BroFile::BroFile(const char* arg_name, const char* arg_access)
|
|||
f = nullptr;
|
||||
name = copy_string(arg_name);
|
||||
access = copy_string(arg_access);
|
||||
t = base_type(TYPE_STRING);
|
||||
t = zeek::base_type(zeek::TYPE_STRING);
|
||||
|
||||
if ( streq(name, "/dev/stdin") )
|
||||
f = stdin;
|
||||
|
@ -278,7 +278,7 @@ RecordVal* BroFile::Rotate()
|
|||
if ( f == stdin || f == stdout || f == stderr )
|
||||
return nullptr;
|
||||
|
||||
static auto rotate_info = zeek::id::find_type<RecordType>("rotate_info");
|
||||
static auto rotate_info = zeek::id::find_type<zeek::RecordType>("rotate_info");
|
||||
RecordVal* info = new RecordVal(rotate_info);
|
||||
FILE* newf = rotate_file(name, info);
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#include "IntrusivePtr.h"
|
||||
#include "util.h"
|
||||
|
||||
class BroType;
|
||||
class RecordVal;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(PrintStmt, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail);
|
||||
|
||||
|
@ -41,9 +41,9 @@ public:
|
|||
void SetBuf(bool buffered); // false=line buffered, true=fully buffered
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
BroType* FType() const { return t.get(); }
|
||||
zeek::BroType* FType() const { return t.get(); }
|
||||
|
||||
const IntrusivePtr<BroType>& GetType() const
|
||||
const IntrusivePtr<zeek::BroType>& GetType() const
|
||||
{ return t; }
|
||||
|
||||
// Whether the file is open in a general sense; it might
|
||||
|
@ -104,7 +104,7 @@ protected:
|
|||
void RaiseOpenEvent();
|
||||
|
||||
FILE* f;
|
||||
IntrusivePtr<BroType> t;
|
||||
IntrusivePtr<zeek::BroType> t;
|
||||
char* name;
|
||||
char* access;
|
||||
zeek::detail::Attributes* attrs;
|
||||
|
|
|
@ -175,7 +175,7 @@ Frame* Frame::Clone() const
|
|||
|
||||
static bool val_is_func(const IntrusivePtr<Val>& v, BroFunc* func)
|
||||
{
|
||||
if ( v->GetType()->Tag() != TYPE_FUNC )
|
||||
if ( v->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||
return false;
|
||||
|
||||
return v->AsFunc() == func;
|
||||
|
@ -333,7 +333,7 @@ broker::expected<broker::data> Frame::Serialize(const Frame* target, const id_li
|
|||
|
||||
const auto& val = target->frame[location].val;
|
||||
|
||||
TypeTag tag = val->GetType()->Tag();
|
||||
zeek::TypeTag tag = val->GetType()->Tag();
|
||||
|
||||
auto expected = bro_broker::val_to_data(val.get());
|
||||
if ( ! expected )
|
||||
|
@ -460,7 +460,7 @@ std::pair<bool, IntrusivePtr<Frame>> Frame::Unserialize(const broker::vector& da
|
|||
return std::make_pair(false, nullptr);
|
||||
|
||||
broker::integer g = *has_type;
|
||||
BroType t( static_cast<TypeTag>(g) );
|
||||
zeek::BroType t( static_cast<zeek::TypeTag>(g) );
|
||||
|
||||
auto val = bro_broker::data_to_val(std::move(val_tuple[0]), &t);
|
||||
if ( ! val )
|
||||
|
|
64
src/Func.cc
64
src/Func.cc
|
@ -216,7 +216,7 @@ void Func::CopyStateInto(Func* other) const
|
|||
}
|
||||
|
||||
void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||
function_flavor flavor) const
|
||||
zeek::FunctionFlavor flavor) const
|
||||
{
|
||||
// Helper function factoring out this code from BroFunc:Call() for
|
||||
// better readability.
|
||||
|
@ -232,32 +232,32 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
|||
}
|
||||
|
||||
switch ( flavor ) {
|
||||
case FUNC_FLAVOR_EVENT:
|
||||
case zeek::FUNC_FLAVOR_EVENT:
|
||||
if ( hook_result )
|
||||
reporter->InternalError("plugin returned non-void result for event %s",
|
||||
this->Name());
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_FLAVOR_HOOK:
|
||||
if ( hook_result->GetType()->Tag() != TYPE_BOOL )
|
||||
case zeek::FUNC_FLAVOR_HOOK:
|
||||
if ( hook_result->GetType()->Tag() != zeek::TYPE_BOOL )
|
||||
reporter->InternalError("plugin returned non-bool for hook %s",
|
||||
this->Name());
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_FLAVOR_FUNCTION:
|
||||
case zeek::FUNC_FLAVOR_FUNCTION:
|
||||
{
|
||||
const auto& yt = GetType()->Yield();
|
||||
|
||||
if ( (! yt) || yt->Tag() == TYPE_VOID )
|
||||
if ( (! yt) || yt->Tag() == zeek::TYPE_VOID )
|
||||
{
|
||||
if ( hook_result )
|
||||
reporter->InternalError("plugin returned non-void result for void method %s",
|
||||
this->Name());
|
||||
}
|
||||
|
||||
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != TYPE_ANY )
|
||||
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != zeek::TYPE_ANY )
|
||||
{
|
||||
reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s",
|
||||
hook_result->GetType()->Tag(), yt->Tag(), this->Name());
|
||||
|
@ -274,7 +274,7 @@ BroFunc::BroFunc(const IntrusivePtr<zeek::detail::ID>& arg_id, IntrusivePtr<zeek
|
|||
: Func(BRO_FUNC)
|
||||
{
|
||||
name = arg_id->Name();
|
||||
type = arg_id->GetType<FuncType>();
|
||||
type = arg_id->GetType<zeek::FuncType>();
|
||||
frame_size = arg_frame_size;
|
||||
|
||||
if ( arg_body )
|
||||
|
@ -326,8 +326,8 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
if ( bodies.empty() )
|
||||
{
|
||||
// Can only happen for events and hooks.
|
||||
assert(Flavor() == FUNC_FLAVOR_EVENT || Flavor() == FUNC_FLAVOR_HOOK);
|
||||
return Flavor() == FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr;
|
||||
assert(Flavor() == zeek::FUNC_FLAVOR_EVENT || Flavor() == zeek::FUNC_FLAVOR_HOOK);
|
||||
return Flavor() == zeek::FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr;
|
||||
}
|
||||
|
||||
auto f = make_intrusive<Frame>(frame_size, this, args);
|
||||
|
@ -384,7 +384,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
catch ( InterpreterException& e )
|
||||
{
|
||||
// Already reported, but now determine whether to unwind further.
|
||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
g_frame_stack.pop_back();
|
||||
call_stack.pop_back();
|
||||
|
@ -404,7 +404,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
break;
|
||||
}
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_HOOK )
|
||||
{
|
||||
// Ignore any return values of hook bodies, final return value
|
||||
// depends on whether a body returns as a result of break statement.
|
||||
|
@ -421,7 +421,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
|
||||
call_stack.pop_back();
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_HOOK )
|
||||
{
|
||||
if ( ! result )
|
||||
result = val_mgr->True();
|
||||
|
@ -429,7 +429,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
|
||||
// Warn if the function returns something, but we returned from
|
||||
// the function without an explicit return, or without a value.
|
||||
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID &&
|
||||
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != zeek::TYPE_VOID &&
|
||||
(flow != FLOW_RETURN /* we fell off the end */ ||
|
||||
! result /* explicit return with no result */) &&
|
||||
! f->HasDelayed() )
|
||||
|
@ -463,7 +463,7 @@ void BroFunc::AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
|||
|
||||
new_body = AddInits(std::move(new_body), new_inits);
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
// For functions, we replace the old body with the new one.
|
||||
assert(bodies.size() <= 1);
|
||||
|
@ -601,7 +601,7 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name,
|
|||
if ( id->HasVal() )
|
||||
reporter->InternalError("built-in function %s multiply defined", Name());
|
||||
|
||||
type = id->GetType<FuncType>();
|
||||
type = id->GetType<zeek::FuncType>();
|
||||
id->SetVal(make_intrusive<Val>(IntrusivePtr{NewRef{}, this}));
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ IntrusivePtr<Val> BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
HookCallFunction(this, parent, args),
|
||||
empty_hook_result);
|
||||
|
||||
CheckPluginResult(handled, hook_result, FUNC_FLAVOR_FUNCTION);
|
||||
CheckPluginResult(handled, hook_result, zeek::FUNC_FLAVOR_FUNCTION);
|
||||
|
||||
if ( handled )
|
||||
return hook_result;
|
||||
|
@ -758,19 +758,19 @@ void builtin_error(const char* msg, BroObj* arg)
|
|||
|
||||
void init_builtin_funcs()
|
||||
{
|
||||
ProcStats = zeek::id::find_type<RecordType>("ProcStats");
|
||||
NetStats = zeek::id::find_type<RecordType>("NetStats");
|
||||
MatcherStats = zeek::id::find_type<RecordType>("MatcherStats");
|
||||
ConnStats = zeek::id::find_type<RecordType>("ConnStats");
|
||||
ReassemblerStats = zeek::id::find_type<RecordType>("ReassemblerStats");
|
||||
DNSStats = zeek::id::find_type<RecordType>("DNSStats");
|
||||
GapStats = zeek::id::find_type<RecordType>("GapStats");
|
||||
EventStats = zeek::id::find_type<RecordType>("EventStats");
|
||||
TimerStats = zeek::id::find_type<RecordType>("TimerStats");
|
||||
FileAnalysisStats = zeek::id::find_type<RecordType>("FileAnalysisStats");
|
||||
ThreadStats = zeek::id::find_type<RecordType>("ThreadStats");
|
||||
BrokerStats = zeek::id::find_type<RecordType>("BrokerStats");
|
||||
ReporterStats = zeek::id::find_type<RecordType>("ReporterStats");
|
||||
ProcStats = zeek::id::find_type<zeek::RecordType>("ProcStats");
|
||||
NetStats = zeek::id::find_type<zeek::RecordType>("NetStats");
|
||||
MatcherStats = zeek::id::find_type<zeek::RecordType>("MatcherStats");
|
||||
ConnStats = zeek::id::find_type<zeek::RecordType>("ConnStats");
|
||||
ReassemblerStats = zeek::id::find_type<zeek::RecordType>("ReassemblerStats");
|
||||
DNSStats = zeek::id::find_type<zeek::RecordType>("DNSStats");
|
||||
GapStats = zeek::id::find_type<zeek::RecordType>("GapStats");
|
||||
EventStats = zeek::id::find_type<zeek::RecordType>("EventStats");
|
||||
TimerStats = zeek::id::find_type<zeek::RecordType>("TimerStats");
|
||||
FileAnalysisStats = zeek::id::find_type<zeek::RecordType>("FileAnalysisStats");
|
||||
ThreadStats = zeek::id::find_type<zeek::RecordType>("ThreadStats");
|
||||
BrokerStats = zeek::id::find_type<zeek::RecordType>("BrokerStats");
|
||||
ReporterStats = zeek::id::find_type<zeek::RecordType>("ReporterStats");
|
||||
|
||||
var_sizes = zeek::id::find_type("var_sizes")->AsTableType();
|
||||
|
||||
|
@ -803,7 +803,7 @@ bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call)
|
|||
}
|
||||
|
||||
const zeek::detail::Expr* fmt_str_arg = args[0];
|
||||
if ( fmt_str_arg->GetType()->Tag() != TYPE_STRING )
|
||||
if ( fmt_str_arg->GetType()->Tag() != zeek::TYPE_STRING )
|
||||
{
|
||||
call->Error("first argument to fmt() needs to be a format string");
|
||||
return false;
|
||||
|
@ -867,7 +867,7 @@ static int get_func_priority(const std::vector<IntrusivePtr<zeek::detail::Attr>>
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( ! IsIntegral(v->GetType()->Tag()) )
|
||||
if ( ! zeek::IsIntegral(v->GetType()->Tag()) )
|
||||
{
|
||||
a->Error("expression is not of integral type");
|
||||
continue;
|
||||
|
|
12
src/Func.h
12
src/Func.h
|
@ -20,13 +20,13 @@
|
|||
#include "ZeekArgs.h"
|
||||
|
||||
class Val;
|
||||
class FuncType;
|
||||
class Frame;
|
||||
class Scope;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(FuncType, zeek);
|
||||
|
||||
class Func : public BroObj {
|
||||
public:
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
~Func() override;
|
||||
|
||||
virtual bool IsPure() const = 0;
|
||||
function_flavor Flavor() const { return GetType()->Flavor(); }
|
||||
zeek::FunctionFlavor Flavor() const { return GetType()->Flavor(); }
|
||||
|
||||
struct Body {
|
||||
IntrusivePtr<zeek::detail::Stmt> stmts;
|
||||
|
@ -86,9 +86,9 @@ public:
|
|||
virtual Scope* GetScope() const { return scope.get(); }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
virtual FuncType* FType() const { return type.get(); }
|
||||
virtual zeek::FuncType* FType() const { return type.get(); }
|
||||
|
||||
const IntrusivePtr<FuncType>& GetType() const
|
||||
const IntrusivePtr<zeek::FuncType>& GetType() const
|
||||
{ return type; }
|
||||
|
||||
Kind GetKind() const { return kind; }
|
||||
|
@ -115,13 +115,13 @@ protected:
|
|||
|
||||
// Helper function for checking result of plugin hook.
|
||||
void CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||
function_flavor flavor) const;
|
||||
zeek::FunctionFlavor flavor) const;
|
||||
|
||||
std::vector<Body> bodies;
|
||||
IntrusivePtr<Scope> scope;
|
||||
Kind kind;
|
||||
uint32_t unique_id;
|
||||
IntrusivePtr<FuncType> type;
|
||||
IntrusivePtr<zeek::FuncType> type;
|
||||
std::string name;
|
||||
static inline std::vector<IntrusivePtr<Func>> unique_ids;
|
||||
};
|
||||
|
|
50
src/ID.cc
50
src/ID.cc
|
@ -19,24 +19,24 @@
|
|||
#include "zeekygen/ScriptInfo.h"
|
||||
#include "module_util.h"
|
||||
|
||||
IntrusivePtr<RecordType> zeek::id::conn_id;
|
||||
IntrusivePtr<RecordType> zeek::id::endpoint;
|
||||
IntrusivePtr<RecordType> zeek::id::connection;
|
||||
IntrusivePtr<RecordType> zeek::id::fa_file;
|
||||
IntrusivePtr<RecordType> zeek::id::fa_metadata;
|
||||
IntrusivePtr<EnumType> zeek::id::transport_proto;
|
||||
IntrusivePtr<TableType> zeek::id::string_set;
|
||||
IntrusivePtr<TableType> zeek::id::string_array;
|
||||
IntrusivePtr<TableType> zeek::id::count_set;
|
||||
IntrusivePtr<VectorType> zeek::id::string_vec;
|
||||
IntrusivePtr<VectorType> zeek::id::index_vec;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::conn_id;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::endpoint;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::connection;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::fa_file;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::fa_metadata;
|
||||
IntrusivePtr<zeek::EnumType> zeek::id::transport_proto;
|
||||
IntrusivePtr<zeek::TableType> zeek::id::string_set;
|
||||
IntrusivePtr<zeek::TableType> zeek::id::string_array;
|
||||
IntrusivePtr<zeek::TableType> zeek::id::count_set;
|
||||
IntrusivePtr<zeek::VectorType> zeek::id::string_vec;
|
||||
IntrusivePtr<zeek::VectorType> zeek::id::index_vec;
|
||||
|
||||
const IntrusivePtr<zeek::detail::ID>& zeek::id::find(std::string_view name)
|
||||
{
|
||||
return global_scope()->Find(name);
|
||||
}
|
||||
|
||||
const IntrusivePtr<BroType>& zeek::id::find_type(std::string_view name)
|
||||
const IntrusivePtr<zeek::BroType>& zeek::id::find_type(std::string_view name)
|
||||
{
|
||||
auto id = global_scope()->Find(name);
|
||||
|
||||
|
@ -89,17 +89,17 @@ IntrusivePtr<Func> zeek::id::find_func(std::string_view name)
|
|||
|
||||
void zeek::id::detail::init()
|
||||
{
|
||||
conn_id = zeek::id::find_type<RecordType>("conn_id");
|
||||
endpoint = zeek::id::find_type<RecordType>("endpoint");
|
||||
connection = zeek::id::find_type<RecordType>("connection");
|
||||
fa_file = zeek::id::find_type<RecordType>("fa_file");
|
||||
fa_metadata = zeek::id::find_type<RecordType>("fa_metadata");
|
||||
transport_proto = zeek::id::find_type<EnumType>("transport_proto");
|
||||
string_set = zeek::id::find_type<TableType>("string_set");
|
||||
string_array = zeek::id::find_type<TableType>("string_array");
|
||||
count_set = zeek::id::find_type<TableType>("count_set");
|
||||
string_vec = zeek::id::find_type<VectorType>("string_vec");
|
||||
index_vec = zeek::id::find_type<VectorType>("index_vec");
|
||||
conn_id = zeek::id::find_type<zeek::RecordType>("conn_id");
|
||||
endpoint = zeek::id::find_type<zeek::RecordType>("endpoint");
|
||||
connection = zeek::id::find_type<zeek::RecordType>("connection");
|
||||
fa_file = zeek::id::find_type<zeek::RecordType>("fa_file");
|
||||
fa_metadata = zeek::id::find_type<zeek::RecordType>("fa_metadata");
|
||||
transport_proto = zeek::id::find_type<zeek::EnumType>("transport_proto");
|
||||
string_set = zeek::id::find_type<zeek::TableType>("string_set");
|
||||
string_array = zeek::id::find_type<zeek::TableType>("string_array");
|
||||
count_set = zeek::id::find_type<zeek::TableType>("count_set");
|
||||
string_vec = zeek::id::find_type<zeek::VectorType>("string_vec");
|
||||
index_vec = zeek::id::find_type<zeek::VectorType>("index_vec");
|
||||
}
|
||||
|
||||
namespace zeek::detail {
|
||||
|
@ -133,7 +133,7 @@ std::string ID::ModuleName() const
|
|||
return extract_module_name(name);
|
||||
}
|
||||
|
||||
void ID::SetType(IntrusivePtr<BroType> t)
|
||||
void ID::SetType(IntrusivePtr<zeek::BroType> t)
|
||||
{
|
||||
type = std::move(t);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ void ID::UpdateValAttrs()
|
|||
if ( attr )
|
||||
{
|
||||
// Apply &log to all record fields.
|
||||
RecordType* rt = GetType()->AsRecordType();
|
||||
zeek::RecordType* rt = GetType()->AsRecordType();
|
||||
for ( int i = 0; i < rt->NumFields(); ++i )
|
||||
{
|
||||
TypeDecl* fd = rt->FieldDecl(i);
|
||||
|
|
35
src/ID.h
35
src/ID.h
|
@ -15,11 +15,12 @@
|
|||
|
||||
class Val;
|
||||
class Func;
|
||||
class BroType;
|
||||
class RecordType;
|
||||
class TableType;
|
||||
class VectorType;
|
||||
class EnumType;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(TableType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(VectorType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(EnumType, zeek);
|
||||
|
||||
enum [[deprecated("Remove in v4.1. Use zeek::detail::init_class instead.")]] init_class { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, };
|
||||
enum [[deprecated("Remove in v4.1. Use zeek::detail::IDScope instead.")]] IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL };
|
||||
|
@ -201,7 +202,7 @@ const IntrusivePtr<zeek::detail::ID>& find(std::string_view name);
|
|||
* @param name The identifier name to lookup
|
||||
* @return The type of the identifier.
|
||||
*/
|
||||
const IntrusivePtr<BroType>& find_type(std::string_view name);
|
||||
const IntrusivePtr<zeek::BroType>& find_type(std::string_view name);
|
||||
|
||||
/**
|
||||
* Lookup an ID by its name and return its type (as cast to @c T).
|
||||
|
@ -257,17 +258,17 @@ IntrusivePtr<T> find_const(std::string_view name)
|
|||
*/
|
||||
IntrusivePtr<Func> find_func(std::string_view name);
|
||||
|
||||
extern IntrusivePtr<RecordType> conn_id;
|
||||
extern IntrusivePtr<RecordType> endpoint;
|
||||
extern IntrusivePtr<RecordType> connection;
|
||||
extern IntrusivePtr<RecordType> fa_file;
|
||||
extern IntrusivePtr<RecordType> fa_metadata;
|
||||
extern IntrusivePtr<EnumType> transport_proto;
|
||||
extern IntrusivePtr<TableType> string_set;
|
||||
extern IntrusivePtr<TableType> string_array;
|
||||
extern IntrusivePtr<TableType> count_set;
|
||||
extern IntrusivePtr<VectorType> string_vec;
|
||||
extern IntrusivePtr<VectorType> index_vec;
|
||||
extern IntrusivePtr<zeek::RecordType> conn_id;
|
||||
extern IntrusivePtr<zeek::RecordType> endpoint;
|
||||
extern IntrusivePtr<zeek::RecordType> connection;
|
||||
extern IntrusivePtr<zeek::RecordType> fa_file;
|
||||
extern IntrusivePtr<zeek::RecordType> fa_metadata;
|
||||
extern IntrusivePtr<zeek::EnumType> transport_proto;
|
||||
extern IntrusivePtr<zeek::TableType> string_set;
|
||||
extern IntrusivePtr<zeek::TableType> string_array;
|
||||
extern IntrusivePtr<zeek::TableType> count_set;
|
||||
extern IntrusivePtr<zeek::VectorType> string_vec;
|
||||
extern IntrusivePtr<zeek::VectorType> index_vec;
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
|
66
src/IP.cc
66
src/IP.cc
|
@ -15,11 +15,11 @@
|
|||
|
||||
static IntrusivePtr<VectorVal> BuildOptionsVal(const u_char* data, int len)
|
||||
{
|
||||
auto vv = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("ip6_options"));
|
||||
auto vv = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("ip6_options"));
|
||||
|
||||
while ( len > 0 )
|
||||
{
|
||||
static auto ip6_option_type = zeek::id::find_type<RecordType>("ip6_option");
|
||||
static auto ip6_option_type = zeek::id::find_type<zeek::RecordType>("ip6_option");
|
||||
const struct ip6_opt* opt = (const struct ip6_opt*) data;
|
||||
auto rv = make_intrusive<RecordVal>(ip6_option_type);
|
||||
rv->Assign(0, val_mgr->Count(opt->ip6o_type));
|
||||
|
@ -56,7 +56,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
switch ( type ) {
|
||||
case IPPROTO_IPV6:
|
||||
{
|
||||
static auto ip6_hdr_type = zeek::id::find_type<RecordType>("ip6_hdr");
|
||||
static auto ip6_hdr_type = zeek::id::find_type<zeek::RecordType>("ip6_hdr");
|
||||
rv = make_intrusive<RecordVal>(ip6_hdr_type);
|
||||
const struct ip6_hdr* ip6 = (const struct ip6_hdr*)data;
|
||||
rv->Assign(0, val_mgr->Count((ntohl(ip6->ip6_flow) & 0x0ff00000)>>20));
|
||||
|
@ -68,14 +68,14 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
rv->Assign(6, make_intrusive<AddrVal>(IPAddr(ip6->ip6_dst)));
|
||||
if ( ! chain )
|
||||
chain = make_intrusive<VectorVal>(
|
||||
zeek::id::find_type<VectorType>("ip6_ext_hdr_chain"));
|
||||
zeek::id::find_type<zeek::VectorType>("ip6_ext_hdr_chain"));
|
||||
rv->Assign(7, std::move(chain));
|
||||
}
|
||||
break;
|
||||
|
||||
case IPPROTO_HOPOPTS:
|
||||
{
|
||||
static auto ip6_hopopts_type = zeek::id::find_type<RecordType>("ip6_hopopts");
|
||||
static auto ip6_hopopts_type = zeek::id::find_type<zeek::RecordType>("ip6_hopopts");
|
||||
rv = make_intrusive<RecordVal>(ip6_hopopts_type);
|
||||
const struct ip6_hbh* hbh = (const struct ip6_hbh*)data;
|
||||
rv->Assign(0, val_mgr->Count(hbh->ip6h_nxt));
|
||||
|
@ -88,7 +88,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
|
||||
case IPPROTO_DSTOPTS:
|
||||
{
|
||||
static auto ip6_dstopts_type = zeek::id::find_type<RecordType>("ip6_dstopts");
|
||||
static auto ip6_dstopts_type = zeek::id::find_type<zeek::RecordType>("ip6_dstopts");
|
||||
rv = make_intrusive<RecordVal>(ip6_dstopts_type);
|
||||
const struct ip6_dest* dst = (const struct ip6_dest*)data;
|
||||
rv->Assign(0, val_mgr->Count(dst->ip6d_nxt));
|
||||
|
@ -100,7 +100,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
|
||||
case IPPROTO_ROUTING:
|
||||
{
|
||||
static auto ip6_routing_type = zeek::id::find_type<RecordType>("ip6_routing");
|
||||
static auto ip6_routing_type = zeek::id::find_type<zeek::RecordType>("ip6_routing");
|
||||
rv = make_intrusive<RecordVal>(ip6_routing_type);
|
||||
const struct ip6_rthdr* rt = (const struct ip6_rthdr*)data;
|
||||
rv->Assign(0, val_mgr->Count(rt->ip6r_nxt));
|
||||
|
@ -114,7 +114,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
|
||||
case IPPROTO_FRAGMENT:
|
||||
{
|
||||
static auto ip6_fragment_type = zeek::id::find_type<RecordType>("ip6_fragment");
|
||||
static auto ip6_fragment_type = zeek::id::find_type<zeek::RecordType>("ip6_fragment");
|
||||
rv = make_intrusive<RecordVal>(ip6_fragment_type);
|
||||
const struct ip6_frag* frag = (const struct ip6_frag*)data;
|
||||
rv->Assign(0, val_mgr->Count(frag->ip6f_nxt));
|
||||
|
@ -128,7 +128,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
|
||||
case IPPROTO_AH:
|
||||
{
|
||||
static auto ip6_ah_type = zeek::id::find_type<RecordType>("ip6_ah");
|
||||
static auto ip6_ah_type = zeek::id::find_type<zeek::RecordType>("ip6_ah");
|
||||
rv = make_intrusive<RecordVal>(ip6_ah_type);
|
||||
rv->Assign(0, val_mgr->Count(((ip6_ext*)data)->ip6e_nxt));
|
||||
rv->Assign(1, val_mgr->Count(((ip6_ext*)data)->ip6e_len));
|
||||
|
@ -148,7 +148,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
|
||||
case IPPROTO_ESP:
|
||||
{
|
||||
static auto ip6_esp_type = zeek::id::find_type<RecordType>("ip6_esp");
|
||||
static auto ip6_esp_type = zeek::id::find_type<zeek::RecordType>("ip6_esp");
|
||||
rv = make_intrusive<RecordVal>(ip6_esp_type);
|
||||
const uint32_t* esp = (const uint32_t*)data;
|
||||
rv->Assign(0, val_mgr->Count(ntohl(esp[0])));
|
||||
|
@ -159,7 +159,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
#ifdef ENABLE_MOBILE_IPV6
|
||||
case IPPROTO_MOBILITY:
|
||||
{
|
||||
static auto ip6_mob_type = zeek::id::find_type<RecordType>("ip6_mobility_hdr");
|
||||
static auto ip6_mob_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_hdr");
|
||||
rv = make_intrusive<RecordVal>(ip6_mob_type);
|
||||
const struct ip6_mobility* mob = (const struct ip6_mobility*) data;
|
||||
rv->Assign(0, val_mgr->Count(mob->ip6mob_payload));
|
||||
|
@ -168,21 +168,21 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
|||
rv->Assign(3, val_mgr->Count(mob->ip6mob_rsv));
|
||||
rv->Assign(4, val_mgr->Count(ntohs(mob->ip6mob_chksum)));
|
||||
|
||||
static auto ip6_mob_msg_type = zeek::id::find_type<RecordType>("ip6_mobility_msg");
|
||||
static auto ip6_mob_msg_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_msg");
|
||||
auto msg = make_intrusive<RecordVal>(ip6_mob_msg_type);
|
||||
msg->Assign(0, val_mgr->Count(mob->ip6mob_type));
|
||||
|
||||
uint16_t off = sizeof(ip6_mobility);
|
||||
const u_char* msg_data = data + off;
|
||||
|
||||
static auto ip6_mob_brr_type = zeek::id::find_type<RecordType>("ip6_mobility_brr");
|
||||
static auto ip6_mob_hoti_type = zeek::id::find_type<RecordType>("ip6_mobility_hoti");
|
||||
static auto ip6_mob_coti_type = zeek::id::find_type<RecordType>("ip6_mobility_coti");
|
||||
static auto ip6_mob_hot_type = zeek::id::find_type<RecordType>("ip6_mobility_hot");
|
||||
static auto ip6_mob_cot_type = zeek::id::find_type<RecordType>("ip6_mobility_cot");
|
||||
static auto ip6_mob_bu_type = zeek::id::find_type<RecordType>("ip6_mobility_bu");
|
||||
static auto ip6_mob_back_type = zeek::id::find_type<RecordType>("ip6_mobility_back");
|
||||
static auto ip6_mob_be_type = zeek::id::find_type<RecordType>("ip6_mobility_be");
|
||||
static auto ip6_mob_brr_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_brr");
|
||||
static auto ip6_mob_hoti_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_hoti");
|
||||
static auto ip6_mob_coti_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_coti");
|
||||
static auto ip6_mob_hot_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_hot");
|
||||
static auto ip6_mob_cot_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_cot");
|
||||
static auto ip6_mob_bu_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_bu");
|
||||
static auto ip6_mob_back_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_back");
|
||||
static auto ip6_mob_be_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_be");
|
||||
|
||||
switch ( mob->ip6mob_type ) {
|
||||
case 0:
|
||||
|
@ -332,7 +332,7 @@ IntrusivePtr<RecordVal> IP_Hdr::ToIPHdrVal() const
|
|||
|
||||
if ( ip4 )
|
||||
{
|
||||
static auto ip4_hdr_type = zeek::id::find_type<RecordType>("ip4_hdr");
|
||||
static auto ip4_hdr_type = zeek::id::find_type<zeek::RecordType>("ip4_hdr");
|
||||
rval = make_intrusive<RecordVal>(ip4_hdr_type);
|
||||
rval->Assign(0, val_mgr->Count(ip4->ip_hl * 4));
|
||||
rval->Assign(1, val_mgr->Count(ip4->ip_tos));
|
||||
|
@ -358,7 +358,7 @@ RecordVal* IP_Hdr::BuildIPHdrVal() const
|
|||
|
||||
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal() const
|
||||
{
|
||||
static auto pkt_hdr_type = zeek::id::find_type<RecordType>("pkt_hdr");
|
||||
static auto pkt_hdr_type = zeek::id::find_type<zeek::RecordType>("pkt_hdr");
|
||||
return ToPktHdrVal(make_intrusive<RecordVal>(pkt_hdr_type), 0);
|
||||
}
|
||||
|
||||
|
@ -369,9 +369,9 @@ RecordVal* IP_Hdr::BuildPktHdrVal() const
|
|||
|
||||
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal(IntrusivePtr<RecordVal> pkt_hdr, int sindex) const
|
||||
{
|
||||
static auto tcp_hdr_type = zeek::id::find_type<RecordType>("tcp_hdr");
|
||||
static auto udp_hdr_type = zeek::id::find_type<RecordType>("udp_hdr");
|
||||
static auto icmp_hdr_type = zeek::id::find_type<RecordType>("icmp_hdr");
|
||||
static auto tcp_hdr_type = zeek::id::find_type<zeek::RecordType>("tcp_hdr");
|
||||
static auto udp_hdr_type = zeek::id::find_type<zeek::RecordType>("udp_hdr");
|
||||
static auto icmp_hdr_type = zeek::id::find_type<zeek::RecordType>("icmp_hdr");
|
||||
|
||||
if ( ip4 )
|
||||
pkt_hdr->Assign(sindex + 0, ToIPHdrVal());
|
||||
|
@ -678,14 +678,14 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
|
|||
|
||||
IntrusivePtr<VectorVal> IPv6_Hdr_Chain::ToVal() const
|
||||
{
|
||||
static auto ip6_ext_hdr_type = zeek::id::find_type<RecordType>("ip6_ext_hdr");
|
||||
static auto ip6_hopopts_type = zeek::id::find_type<RecordType>("ip6_hopopts");
|
||||
static auto ip6_dstopts_type = zeek::id::find_type<RecordType>("ip6_dstopts");
|
||||
static auto ip6_routing_type = zeek::id::find_type<RecordType>("ip6_routing");
|
||||
static auto ip6_fragment_type = zeek::id::find_type<RecordType>("ip6_fragment");
|
||||
static auto ip6_ah_type = zeek::id::find_type<RecordType>("ip6_ah");
|
||||
static auto ip6_esp_type = zeek::id::find_type<RecordType>("ip6_esp");
|
||||
static auto ip6_ext_hdr_chain_type = zeek::id::find_type<VectorType>("ip6_ext_hdr_chain");
|
||||
static auto ip6_ext_hdr_type = zeek::id::find_type<zeek::RecordType>("ip6_ext_hdr");
|
||||
static auto ip6_hopopts_type = zeek::id::find_type<zeek::RecordType>("ip6_hopopts");
|
||||
static auto ip6_dstopts_type = zeek::id::find_type<zeek::RecordType>("ip6_dstopts");
|
||||
static auto ip6_routing_type = zeek::id::find_type<zeek::RecordType>("ip6_routing");
|
||||
static auto ip6_fragment_type = zeek::id::find_type<zeek::RecordType>("ip6_fragment");
|
||||
static auto ip6_ah_type = zeek::id::find_type<zeek::RecordType>("ip6_ah");
|
||||
static auto ip6_esp_type = zeek::id::find_type<zeek::RecordType>("ip6_esp");
|
||||
static auto ip6_ext_hdr_chain_type = zeek::id::find_type<zeek::VectorType>("ip6_ext_hdr_chain");
|
||||
auto rval = make_intrusive<VectorVal>(ip6_ext_hdr_chain_type);
|
||||
|
||||
for ( size_t i = 1; i < chain.size(); ++i )
|
||||
|
|
|
@ -37,10 +37,10 @@ OpaqueMgr* OpaqueMgr::mgr()
|
|||
return &mgr;
|
||||
}
|
||||
|
||||
OpaqueVal::OpaqueVal(OpaqueType* t) : OpaqueVal({NewRef{}, t})
|
||||
OpaqueVal::OpaqueVal(zeek::OpaqueType* t) : OpaqueVal({NewRef{}, t})
|
||||
{}
|
||||
|
||||
OpaqueVal::OpaqueVal(IntrusivePtr<OpaqueType> t) : Val(std::move(t))
|
||||
OpaqueVal::OpaqueVal(IntrusivePtr<zeek::OpaqueType> t) : Val(std::move(t))
|
||||
{}
|
||||
|
||||
OpaqueVal::~OpaqueVal()
|
||||
|
@ -96,12 +96,12 @@ IntrusivePtr<OpaqueVal> OpaqueVal::Unserialize(const broker::data& data)
|
|||
return val;
|
||||
}
|
||||
|
||||
broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<BroType>& t)
|
||||
broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<zeek::BroType>& t)
|
||||
{
|
||||
if ( t->InternalType() == TYPE_INTERNAL_ERROR )
|
||||
if ( t->InternalType() == zeek::TYPE_INTERNAL_ERROR )
|
||||
return broker::ec::invalid_data;
|
||||
|
||||
if ( t->InternalType() == TYPE_INTERNAL_OTHER )
|
||||
if ( t->InternalType() == zeek::TYPE_INTERNAL_OTHER )
|
||||
{
|
||||
// Serialize by name.
|
||||
assert(t->GetName().size());
|
||||
|
@ -112,7 +112,7 @@ broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<BroTy
|
|||
return {broker::vector{false, static_cast<uint64_t>(t->Tag())}};
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> OpaqueVal::UnserializeType(const broker::data& data)
|
||||
IntrusivePtr<zeek::BroType> OpaqueVal::UnserializeType(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() == 2) )
|
||||
|
@ -142,7 +142,7 @@ IntrusivePtr<BroType> OpaqueVal::UnserializeType(const broker::data& data)
|
|||
if ( ! tag )
|
||||
return nullptr;
|
||||
|
||||
return base_type(static_cast<TypeTag>(*tag));
|
||||
return zeek::base_type(static_cast<zeek::TypeTag>(*tag));
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> OpaqueVal::DoClone(CloneState* state)
|
||||
|
@ -206,12 +206,12 @@ IntrusivePtr<StringVal> HashVal::DoGet()
|
|||
return val_mgr->EmptyString();
|
||||
}
|
||||
|
||||
HashVal::HashVal(IntrusivePtr<OpaqueType> t) : OpaqueVal(std::move(t))
|
||||
HashVal::HashVal(IntrusivePtr<zeek::OpaqueType> t) : OpaqueVal(std::move(t))
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
HashVal::HashVal(OpaqueType* t) : HashVal({NewRef{}, t})
|
||||
HashVal::HashVal(zeek::OpaqueType* t) : HashVal({NewRef{}, t})
|
||||
{}
|
||||
|
||||
MD5Val::MD5Val() : HashVal(md5_type)
|
||||
|
@ -226,7 +226,7 @@ MD5Val::~MD5Val()
|
|||
|
||||
void HashVal::digest_one(EVP_MD_CTX* h, const Val* v)
|
||||
{
|
||||
if ( v->GetType()->Tag() == TYPE_STRING )
|
||||
if ( v->GetType()->Tag() == zeek::TYPE_STRING )
|
||||
{
|
||||
const BroString* str = v->AsString();
|
||||
hash_update(h, str->Bytes(), str->Len());
|
||||
|
@ -723,14 +723,14 @@ IntrusivePtr<Val> BloomFilterVal::DoClone(CloneState* state)
|
|||
return state->NewClone(this, make_intrusive<BloomFilterVal>());
|
||||
}
|
||||
|
||||
bool BloomFilterVal::Typify(IntrusivePtr<BroType> arg_type)
|
||||
bool BloomFilterVal::Typify(IntrusivePtr<zeek::BroType> arg_type)
|
||||
{
|
||||
if ( type )
|
||||
return false;
|
||||
|
||||
type = std::move(arg_type);
|
||||
|
||||
auto tl = make_intrusive<TypeList>(type);
|
||||
auto tl = make_intrusive<zeek::TypeList>(type);
|
||||
tl->Append(type);
|
||||
hash = new CompositeHash(std::move(tl));
|
||||
|
||||
|
@ -882,14 +882,14 @@ IntrusivePtr<Val> CardinalityVal::DoClone(CloneState* state)
|
|||
make_intrusive<CardinalityVal>(new probabilistic::CardinalityCounter(*c)));
|
||||
}
|
||||
|
||||
bool CardinalityVal::Typify(IntrusivePtr<BroType> arg_type)
|
||||
bool CardinalityVal::Typify(IntrusivePtr<zeek::BroType> arg_type)
|
||||
{
|
||||
if ( type )
|
||||
return false;
|
||||
|
||||
type = std::move(arg_type);
|
||||
|
||||
auto tl = make_intrusive<TypeList>(type);
|
||||
auto tl = make_intrusive<zeek::TypeList>(type);
|
||||
tl->Append(type);
|
||||
hash = new CompositeHash(std::move(tl));
|
||||
|
||||
|
|
|
@ -88,8 +88,8 @@ private:
|
|||
class OpaqueVal : public Val {
|
||||
public:
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||
explicit OpaqueVal(OpaqueType* t);
|
||||
explicit OpaqueVal(IntrusivePtr<OpaqueType> t);
|
||||
explicit OpaqueVal(zeek::OpaqueType* t);
|
||||
explicit OpaqueVal(IntrusivePtr<zeek::OpaqueType> t);
|
||||
~OpaqueVal() override;
|
||||
|
||||
/**
|
||||
|
@ -148,13 +148,13 @@ protected:
|
|||
* Helper function for derived class that need to record a type
|
||||
* during serialization.
|
||||
*/
|
||||
static broker::expected<broker::data> SerializeType(const IntrusivePtr<BroType>& t);
|
||||
static broker::expected<broker::data> SerializeType(const IntrusivePtr<zeek::BroType>& t);
|
||||
|
||||
/**
|
||||
* Helper function for derived class that need to restore a type
|
||||
* during unserialization. Returns the type at reference count +1.
|
||||
*/
|
||||
static IntrusivePtr<BroType> UnserializeType(const broker::data& data);
|
||||
static IntrusivePtr<zeek::BroType> UnserializeType(const broker::data& data);
|
||||
};
|
||||
|
||||
namespace probabilistic {
|
||||
|
@ -187,8 +187,8 @@ protected:
|
|||
HashVal() { valid = false; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||
explicit HashVal(OpaqueType* t);
|
||||
explicit HashVal(IntrusivePtr<OpaqueType> t);
|
||||
explicit HashVal(zeek::OpaqueType* t);
|
||||
explicit HashVal(IntrusivePtr<zeek::OpaqueType> t);
|
||||
|
||||
virtual bool DoInit();
|
||||
virtual bool DoFeed(const void* data, size_t size);
|
||||
|
@ -304,10 +304,10 @@ public:
|
|||
|
||||
IntrusivePtr<Val> DoClone(CloneState* state) override;
|
||||
|
||||
const IntrusivePtr<BroType>& Type() const
|
||||
const IntrusivePtr<zeek::BroType>& Type() const
|
||||
{ return type; }
|
||||
|
||||
bool Typify(IntrusivePtr<BroType> type);
|
||||
bool Typify(IntrusivePtr<zeek::BroType> type);
|
||||
|
||||
void Add(const Val* val);
|
||||
size_t Count(const Val* val) const;
|
||||
|
@ -328,7 +328,7 @@ private:
|
|||
BloomFilterVal(const BloomFilterVal&);
|
||||
BloomFilterVal& operator=(const BloomFilterVal&);
|
||||
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
CompositeHash* hash;
|
||||
probabilistic::BloomFilter* bloom_filter;
|
||||
};
|
||||
|
@ -343,10 +343,10 @@ public:
|
|||
|
||||
void Add(const Val* val);
|
||||
|
||||
const IntrusivePtr<BroType>& Type() const
|
||||
const IntrusivePtr<zeek::BroType>& Type() const
|
||||
{ return type; }
|
||||
|
||||
bool Typify(IntrusivePtr<BroType> type);
|
||||
bool Typify(IntrusivePtr<zeek::BroType> type);
|
||||
|
||||
probabilistic::CardinalityCounter* Get() { return c; };
|
||||
|
||||
|
@ -355,7 +355,7 @@ protected:
|
|||
|
||||
DECLARE_OPAQUE_VALUE(CardinalityVal)
|
||||
private:
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
CompositeHash* hash;
|
||||
probabilistic::CardinalityCounter* c;
|
||||
};
|
||||
|
|
|
@ -43,16 +43,16 @@ void* PrefixTable::Insert(const IPAddr& addr, int width, void* data)
|
|||
void* PrefixTable::Insert(const Val* value, void* data)
|
||||
{
|
||||
// [elem] -> elem
|
||||
if ( value->GetType()->Tag() == TYPE_LIST &&
|
||||
if ( value->GetType()->Tag() == zeek::TYPE_LIST &&
|
||||
value->AsListVal()->Length() == 1 )
|
||||
value = value->AsListVal()->Idx(0).get();
|
||||
|
||||
switch ( value->GetType()->Tag() ) {
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
return Insert(value->AsAddr(), 128, data);
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
return Insert(value->AsSubNet().Prefix(),
|
||||
value->AsSubNet().LengthIPv6(), data);
|
||||
break;
|
||||
|
@ -103,16 +103,16 @@ void* PrefixTable::Lookup(const IPAddr& addr, int width, bool exact) const
|
|||
void* PrefixTable::Lookup(const Val* value, bool exact) const
|
||||
{
|
||||
// [elem] -> elem
|
||||
if ( value->GetType()->Tag() == TYPE_LIST &&
|
||||
if ( value->GetType()->Tag() == zeek::TYPE_LIST &&
|
||||
value->AsListVal()->Length() == 1 )
|
||||
value = value->AsListVal()->Idx(0).get();
|
||||
|
||||
switch ( value->GetType()->Tag() ) {
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
return Lookup(value->AsAddr(), 128, exact);
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
return Lookup(value->AsSubNet().Prefix(),
|
||||
value->AsSubNet().LengthIPv6(), exact);
|
||||
break;
|
||||
|
@ -142,16 +142,16 @@ void* PrefixTable::Remove(const IPAddr& addr, int width)
|
|||
void* PrefixTable::Remove(const Val* value)
|
||||
{
|
||||
// [elem] -> elem
|
||||
if ( value->GetType()->Tag() == TYPE_LIST &&
|
||||
if ( value->GetType()->Tag() == zeek::TYPE_LIST &&
|
||||
value->AsListVal()->Length() == 1 )
|
||||
value = value->AsListVal()->Idx(0).get();
|
||||
|
||||
switch ( value->GetType()->Tag() ) {
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
return Remove(value->AsAddr(), 128);
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
return Remove(value->AsSubNet().Prefix(),
|
||||
value->AsSubNet().LengthIPv6());
|
||||
break;
|
||||
|
|
|
@ -136,18 +136,18 @@ RuleConditionEval::RuleConditionEval(const char* func)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( id->GetType()->Tag() == TYPE_FUNC )
|
||||
if ( id->GetType()->Tag() == zeek::TYPE_FUNC )
|
||||
{
|
||||
// Validate argument quantity and type.
|
||||
FuncType* f = id->GetType()->AsFuncType();
|
||||
zeek::FuncType* f = id->GetType()->AsFuncType();
|
||||
|
||||
if ( f->Yield()->Tag() != TYPE_BOOL )
|
||||
if ( f->Yield()->Tag() != zeek::TYPE_BOOL )
|
||||
rules_error("eval function type must yield a 'bool'", func);
|
||||
|
||||
static auto signature_state = zeek::id::find_type<RecordType>("signature_state");
|
||||
TypeList tl;
|
||||
static auto signature_state = zeek::id::find_type<zeek::RecordType>("signature_state");
|
||||
zeek::TypeList tl;
|
||||
tl.Append(signature_state);
|
||||
tl.Append(base_type(TYPE_STRING));
|
||||
tl.Append(zeek::base_type(zeek::TYPE_STRING));
|
||||
|
||||
if ( ! f->CheckArgs(tl.Types()) )
|
||||
rules_error("eval function parameters must be a 'signature_state' "
|
||||
|
@ -164,7 +164,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state,
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( id->GetType()->Tag() != TYPE_FUNC )
|
||||
if ( id->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||
return id->GetVal()->AsBool();
|
||||
|
||||
// Call function with a signature_state value as argument.
|
||||
|
|
|
@ -81,7 +81,7 @@ RuleHdrTest::RuleHdrTest(Prot arg_prot, Comp arg_comp, vector<IPPrefix> arg_v)
|
|||
Val* RuleMatcher::BuildRuleStateValue(const Rule* rule,
|
||||
const RuleEndpointState* state) const
|
||||
{
|
||||
static auto signature_state = zeek::id::find_type<RecordType>("signature_state");
|
||||
static auto signature_state = zeek::id::find_type<zeek::RecordType>("signature_state");
|
||||
RecordVal* val = new RecordVal(signature_state);
|
||||
val->Assign(0, make_intrusive<StringVal>(rule->ID()));
|
||||
val->Assign(1, state->GetAnalyzer()->ConnVal());
|
||||
|
@ -1294,20 +1294,20 @@ static bool val_to_maskedval(Val* v, maskedvalue_list* append_to,
|
|||
MaskedValue* mval = new MaskedValue;
|
||||
|
||||
switch ( v->GetType()->Tag() ) {
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
mval->val = v->AsPortVal()->Port();
|
||||
mval->mask = 0xffffffff;
|
||||
break;
|
||||
|
||||
case TYPE_BOOL:
|
||||
case TYPE_COUNT:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_BOOL:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_ENUM:
|
||||
case zeek::TYPE_INT:
|
||||
mval->val = v->CoerceToUnsigned();
|
||||
mval->mask = 0xffffffff;
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
if ( prefix_vector )
|
||||
{
|
||||
|
@ -1362,7 +1362,7 @@ void id_to_maskedvallist(const char* id, maskedvalue_list* append_to,
|
|||
if ( ! v )
|
||||
return;
|
||||
|
||||
if ( v->GetType()->Tag() == TYPE_TABLE )
|
||||
if ( v->GetType()->Tag() == zeek::TYPE_TABLE )
|
||||
{
|
||||
auto lv = v->AsTableVal()->ToPureListVal();
|
||||
|
||||
|
@ -1384,7 +1384,7 @@ char* id_to_str(const char* id)
|
|||
if ( ! v )
|
||||
goto error;
|
||||
|
||||
if ( v->GetType()->Tag() != TYPE_STRING )
|
||||
if ( v->GetType()->Tag() != zeek::TYPE_STRING )
|
||||
{
|
||||
rules_error("Identifier must refer to string");
|
||||
goto error;
|
||||
|
@ -1407,10 +1407,10 @@ uint32_t id_to_uint(const char* id)
|
|||
if ( ! v )
|
||||
return 0;
|
||||
|
||||
TypeTag t = v->GetType()->Tag();
|
||||
zeek::TypeTag t = v->GetType()->Tag();
|
||||
|
||||
if ( t == TYPE_BOOL || t == TYPE_COUNT || t == TYPE_ENUM ||
|
||||
t == TYPE_INT || t == TYPE_PORT )
|
||||
if ( t == zeek::TYPE_BOOL || t == zeek::TYPE_COUNT || t == zeek::TYPE_ENUM ||
|
||||
t == zeek::TYPE_INT || t == zeek::TYPE_PORT )
|
||||
return v->CoerceToUnsigned();
|
||||
|
||||
rules_error("Identifier must refer to integer");
|
||||
|
|
|
@ -25,12 +25,12 @@ Scope::Scope(IntrusivePtr<zeek::detail::ID> id,
|
|||
{
|
||||
const auto& id_type = scope_id->GetType();
|
||||
|
||||
if ( id_type->Tag() == TYPE_ERROR )
|
||||
if ( id_type->Tag() == zeek::TYPE_ERROR )
|
||||
return;
|
||||
else if ( id_type->Tag() != TYPE_FUNC )
|
||||
else if ( id_type->Tag() != zeek::TYPE_FUNC )
|
||||
reporter->InternalError("bad scope id");
|
||||
|
||||
FuncType* ft = id->GetType()->AsFuncType();
|
||||
zeek::FuncType* ft = id->GetType()->AsFuncType();
|
||||
return_type = ft->Yield();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "TraverseTypes.h"
|
||||
|
||||
template <class T> class IntrusivePtr;
|
||||
class BroType;
|
||||
class ListVal;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||
|
||||
class Scope : public BroObj {
|
||||
|
@ -45,9 +45,9 @@ public:
|
|||
{ return attrs; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetReturnTrype().")]]
|
||||
BroType* ReturnType() const { return return_type.get(); }
|
||||
zeek::BroType* ReturnType() const { return return_type.get(); }
|
||||
|
||||
const IntrusivePtr<BroType>& GetReturnType() const
|
||||
const IntrusivePtr<zeek::BroType>& GetReturnType() const
|
||||
{ return return_type; }
|
||||
|
||||
size_t Length() const { return local.size(); }
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
protected:
|
||||
IntrusivePtr<zeek::detail::ID> scope_id;
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs;
|
||||
IntrusivePtr<BroType> return_type;
|
||||
IntrusivePtr<zeek::BroType> return_type;
|
||||
std::map<std::string, IntrusivePtr<zeek::detail::ID>, std::less<>> local;
|
||||
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||
};
|
||||
|
|
|
@ -906,10 +906,10 @@ FragReassembler* NetSessions::NextFragment(double t, const IP_Hdr* ip,
|
|||
Connection* NetSessions::FindConnection(Val* v)
|
||||
{
|
||||
const auto& vt = v->GetType();
|
||||
if ( ! IsRecord(vt->Tag()) )
|
||||
if ( ! zeek::IsRecord(vt->Tag()) )
|
||||
return nullptr;
|
||||
|
||||
RecordType* vr = vt->AsRecordType();
|
||||
zeek::RecordType* vr = vt->AsRecordType();
|
||||
auto vl = v->AsRecord();
|
||||
|
||||
int orig_h, orig_p; // indices into record's value list
|
||||
|
|
|
@ -58,10 +58,10 @@ bool BroSubstring::DoesCover(const BroSubstring* bst) const
|
|||
|
||||
VectorVal* BroSubstring::VecToPolicy(Vec* vec)
|
||||
{
|
||||
static auto sw_substring_type = zeek::id::find_type<RecordType>("sw_substring");
|
||||
static auto sw_align_type = zeek::id::find_type<RecordType>("sw_align");
|
||||
static auto sw_align_vec_type = zeek::id::find_type<VectorType>("sw_align_vec");
|
||||
static auto sw_substring_vec_type = zeek::id::find_type<VectorType>("sw_substring_vec");
|
||||
static auto sw_substring_type = zeek::id::find_type<zeek::RecordType>("sw_substring");
|
||||
static auto sw_align_type = zeek::id::find_type<zeek::RecordType>("sw_align");
|
||||
static auto sw_align_vec_type = zeek::id::find_type<zeek::VectorType>("sw_align_vec");
|
||||
static auto sw_substring_vec_type = zeek::id::find_type<zeek::VectorType>("sw_substring_vec");
|
||||
|
||||
auto result = make_intrusive<VectorVal>(sw_substring_vec_type);
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ void ProfileLogger::Log()
|
|||
if ( size > 100 * 1024 )
|
||||
print = true;
|
||||
|
||||
if ( v->GetType()->Tag() == TYPE_TABLE )
|
||||
if ( v->GetType()->Tag() == zeek::TYPE_TABLE )
|
||||
{
|
||||
entries = v->AsTable()->Length();
|
||||
total_table_entries += entries;
|
||||
|
@ -339,7 +339,7 @@ void ProfileLogger::SegmentProfile(const char* name, const Location* loc,
|
|||
|
||||
SampleLogger::SampleLogger()
|
||||
{
|
||||
static TableType* load_sample_info = nullptr;
|
||||
static zeek::TableType* load_sample_info = nullptr;
|
||||
|
||||
if ( ! load_sample_info )
|
||||
load_sample_info = zeek::id::find_type("load_sample_info")->AsTableType();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Val.h"
|
||||
#include "IntrusivePtr.h"
|
||||
|
||||
Tag::Tag(const IntrusivePtr<EnumType>& etype, type_t arg_type, subtype_t arg_subtype)
|
||||
Tag::Tag(const IntrusivePtr<zeek::EnumType>& etype, type_t arg_type, subtype_t arg_subtype)
|
||||
{
|
||||
assert(arg_type > 0);
|
||||
|
||||
|
@ -14,7 +14,7 @@ Tag::Tag(const IntrusivePtr<EnumType>& etype, type_t arg_type, subtype_t arg_sub
|
|||
val = etype->GetVal(i);
|
||||
}
|
||||
|
||||
Tag::Tag(EnumType* etype, type_t arg_type, subtype_t arg_subtype)
|
||||
Tag::Tag(zeek::EnumType* etype, type_t arg_type, subtype_t arg_subtype)
|
||||
: Tag({NewRef{}, etype}, arg_type, arg_subtype)
|
||||
{ }
|
||||
|
||||
|
@ -73,7 +73,7 @@ Tag& Tag::operator=(const Tag&& other) noexcept
|
|||
return *this;
|
||||
}
|
||||
|
||||
const IntrusivePtr<EnumVal>& Tag::AsVal(const IntrusivePtr<EnumType>& etype) const
|
||||
const IntrusivePtr<EnumVal>& Tag::AsVal(const IntrusivePtr<zeek::EnumType>& etype) const
|
||||
{
|
||||
if ( ! val )
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ const IntrusivePtr<EnumVal>& Tag::AsVal(const IntrusivePtr<EnumType>& etype) con
|
|||
return val;
|
||||
}
|
||||
|
||||
EnumVal* Tag::AsEnumVal(EnumType* etype) const
|
||||
EnumVal* Tag::AsEnumVal(zeek::EnumType* etype) const
|
||||
{
|
||||
return AsVal({NewRef{}, etype}).get();
|
||||
}
|
||||
|
|
17
src/Tag.h
17
src/Tag.h
|
@ -3,14 +3,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "zeek-config.h"
|
||||
#include "IntrusivePtr.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "IntrusivePtr.h"
|
||||
#include "util.h"
|
||||
|
||||
class EnumVal;
|
||||
class EnumType;
|
||||
FORWARD_DECLARE_NAMESPACED(EnumType, zeek);
|
||||
|
||||
/**
|
||||
* Class to identify an analyzer type.
|
||||
|
@ -115,10 +116,10 @@ protected:
|
|||
*
|
||||
* @param etype the script-layer enum type associated with the tag.
|
||||
*/
|
||||
const IntrusivePtr<EnumVal>& AsVal(const IntrusivePtr<EnumType>& etype) const;
|
||||
const IntrusivePtr<EnumVal>& AsVal(const IntrusivePtr<zeek::EnumType>& etype) const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use AsVal() instead.")]]
|
||||
EnumVal* AsEnumVal(EnumType* etype) const;
|
||||
EnumVal* AsEnumVal(zeek::EnumType* etype) const;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -131,10 +132,10 @@ protected:
|
|||
* @param subtype The sub type, which is left to an analyzer for
|
||||
* interpretation. By default it's set to zero.
|
||||
*/
|
||||
Tag(const IntrusivePtr<EnumType>& etype, type_t type, subtype_t subtype = 0);
|
||||
Tag(const IntrusivePtr<zeek::EnumType>& etype, type_t type, subtype_t subtype = 0);
|
||||
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr& instead.")]]
|
||||
Tag(EnumType* etype, type_t type, subtype_t subtype = 0);
|
||||
Tag(zeek::EnumType* etype, type_t type, subtype_t subtype = 0);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "zeek-config.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "IntrusivePtr.h"
|
||||
#include "NetVar.h"
|
||||
#include "IPAddr.h"
|
||||
#include "ID.h"
|
||||
#include "UID.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Connection;
|
||||
|
||||
/**
|
||||
|
@ -198,7 +199,7 @@ public:
|
|||
IntrusivePtr<VectorVal> ToVal() const
|
||||
{
|
||||
auto vv = make_intrusive<VectorVal>(
|
||||
zeek::id::find_type<VectorType>("EncapsulatingConnVector"));
|
||||
zeek::id::find_type<zeek::VectorType>("EncapsulatingConnVector"));
|
||||
|
||||
if ( conns )
|
||||
{
|
||||
|
|
49
src/Type.cc
49
src/Type.cc
|
@ -22,10 +22,12 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace zeek {
|
||||
|
||||
BroType::TypeAliasMap BroType::type_aliases;
|
||||
|
||||
// Note: This function must be thread-safe.
|
||||
const char* type_name(TypeTag t)
|
||||
const char* type_name(zeek::TypeTag t)
|
||||
{
|
||||
static constexpr const char* type_names[int(NUM_TYPES)] = {
|
||||
"void", // 0
|
||||
|
@ -62,9 +64,9 @@ const char* type_name(TypeTag t)
|
|||
return type_names[int(t)];
|
||||
}
|
||||
|
||||
BroType::BroType(TypeTag t, bool arg_base_type)
|
||||
BroType::BroType(zeek::TypeTag t, bool arg_base_type)
|
||||
: tag(t), internal_tag(to_internal_type_tag(tag)),
|
||||
is_network_order(::is_network_order(t)),
|
||||
is_network_order(zeek::is_network_order(t)),
|
||||
base_type(arg_base_type)
|
||||
{
|
||||
}
|
||||
|
@ -102,7 +104,7 @@ int BroType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
|||
if ( index->Exprs().length() != 1 && index->Exprs().length() != 2 )
|
||||
return DOES_NOT_MATCH_INDEX;
|
||||
|
||||
if ( check_and_promote_exprs_to_type(index, ::base_type(TYPE_INT).get()) )
|
||||
if ( check_and_promote_exprs_to_type(index, zeek::base_type(zeek::TYPE_INT).get()) )
|
||||
return MATCHES_INDEX_SCALAR;
|
||||
}
|
||||
|
||||
|
@ -409,7 +411,7 @@ IntrusivePtr<BroType> SetType::ShallowClone()
|
|||
SetType::~SetType() = default;
|
||||
|
||||
FuncType::FuncType(IntrusivePtr<RecordType> arg_args,
|
||||
IntrusivePtr<BroType> arg_yield, function_flavor arg_flavor)
|
||||
IntrusivePtr<BroType> arg_yield, FunctionFlavor arg_flavor)
|
||||
: BroType(TYPE_FUNC), args(std::move(arg_args)),
|
||||
arg_types(make_intrusive<TypeList>()), yield(std::move(arg_yield))
|
||||
{
|
||||
|
@ -1320,7 +1322,7 @@ const IntrusivePtr<BroType>& VectorType::Yield() const
|
|||
// return any as that's what other code historically expects for type
|
||||
// comparisions.
|
||||
if ( IsUnspecifiedVector() )
|
||||
return ::base_type(TYPE_ANY);
|
||||
return zeek::base_type(zeek::TYPE_ANY);
|
||||
|
||||
return yield_type;
|
||||
}
|
||||
|
@ -1369,22 +1371,6 @@ void VectorType::DescribeReST(ODesc* d, bool roles_only) const
|
|||
d->Add(fmt(":zeek:type:`%s`", yield_type->GetName().c_str()));
|
||||
}
|
||||
|
||||
const IntrusivePtr<BroType>& base_type(TypeTag tag)
|
||||
{
|
||||
static IntrusivePtr<BroType> base_types[NUM_TYPES];
|
||||
|
||||
// We could check here that "tag" actually corresponds to a basic type.
|
||||
if ( ! base_types[tag] )
|
||||
{
|
||||
base_types[tag] = make_intrusive<BroType>(tag, true);
|
||||
// Give the base types a pseudo-location for easier identification.
|
||||
Location l(type_name(tag), 0, 0, 0, 0);
|
||||
base_types[tag]->SetLocationInfo(&l);
|
||||
}
|
||||
|
||||
return base_types[tag];
|
||||
}
|
||||
|
||||
// Returns true if t1 is initialization-compatible with t2 (i.e., if an
|
||||
// initializer with type t1 can be used to initialize a value with type t2),
|
||||
// false otherwise. Assumes that t1's tag is different from t2's. Note
|
||||
|
@ -2081,3 +2067,22 @@ bool is_atomic_type(const BroType& t)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const IntrusivePtr<BroType>& base_type(zeek::TypeTag tag)
|
||||
{
|
||||
static IntrusivePtr<BroType> base_types[NUM_TYPES];
|
||||
|
||||
// We could check here that "tag" actually corresponds to a basic type.
|
||||
if ( ! base_types[tag] )
|
||||
{
|
||||
base_types[tag] = make_intrusive<BroType>(tag, true);
|
||||
// Give the base types a pseudo-location for easier identification.
|
||||
Location l(type_name(tag), 0, 0, 0, 0);
|
||||
base_types[tag]->SetLocationInfo(&l);
|
||||
}
|
||||
|
||||
return base_types[tag];
|
||||
}
|
||||
|
||||
|
||||
} // namespace zeek
|
||||
|
|
187
src/Type.h
187
src/Type.h
|
@ -14,8 +14,60 @@
|
|||
#include <list>
|
||||
#include <optional>
|
||||
|
||||
// BRO types.
|
||||
class EnumVal;
|
||||
class TableVal;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(ListExpr, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail);
|
||||
|
||||
// BRO types.
|
||||
enum [[deprecated("Remove in v4.1. Use zeek::TypeTag instead.")]] TypeTag {
|
||||
TYPE_VOID, // 0
|
||||
TYPE_BOOL, // 1
|
||||
TYPE_INT, // 2
|
||||
TYPE_COUNT, // 3
|
||||
TYPE_COUNTER, // 4
|
||||
TYPE_DOUBLE, // 5
|
||||
TYPE_TIME, // 6
|
||||
TYPE_INTERVAL, // 7
|
||||
TYPE_STRING, // 8
|
||||
TYPE_PATTERN, // 9
|
||||
TYPE_ENUM, // 10
|
||||
TYPE_TIMER, // 11
|
||||
TYPE_PORT, // 12
|
||||
TYPE_ADDR, // 13
|
||||
TYPE_SUBNET, // 14
|
||||
TYPE_ANY, // 15
|
||||
TYPE_TABLE, // 16
|
||||
TYPE_UNION, // 17
|
||||
TYPE_RECORD, // 18
|
||||
TYPE_LIST, // 19
|
||||
TYPE_FUNC, // 20
|
||||
TYPE_FILE, // 21
|
||||
TYPE_VECTOR, // 22
|
||||
TYPE_OPAQUE, // 23
|
||||
TYPE_TYPE, // 24
|
||||
TYPE_ERROR // 25
|
||||
#define NUM_TYPES (int(TYPE_ERROR) + 1)
|
||||
};
|
||||
|
||||
enum [[deprecated("Remove in v4.1. Use zeek::FunctionFlavor instead.")]] function_flavor {
|
||||
FUNC_FLAVOR_FUNCTION,
|
||||
FUNC_FLAVOR_EVENT,
|
||||
FUNC_FLAVOR_HOOK
|
||||
};
|
||||
|
||||
enum [[deprecated("Remove in v4.1. Use zeek::InternalTypeTag instead.")]] InternalTypeTag : uint16_t {
|
||||
TYPE_INTERNAL_VOID,
|
||||
TYPE_INTERNAL_INT, TYPE_INTERNAL_UNSIGNED, TYPE_INTERNAL_DOUBLE,
|
||||
TYPE_INTERNAL_STRING, TYPE_INTERNAL_ADDR, TYPE_INTERNAL_SUBNET,
|
||||
TYPE_INTERNAL_OTHER, TYPE_INTERNAL_ERROR
|
||||
};
|
||||
|
||||
namespace zeek {
|
||||
|
||||
// BRO types.
|
||||
enum TypeTag {
|
||||
TYPE_VOID, // 0
|
||||
TYPE_BOOL, // 1
|
||||
|
@ -46,12 +98,15 @@ enum TypeTag {
|
|||
#define NUM_TYPES (int(TYPE_ERROR) + 1)
|
||||
};
|
||||
|
||||
// Returns the name of the type.
|
||||
extern const char* type_name(TypeTag t);
|
||||
|
||||
constexpr bool is_network_order(TypeTag tag) noexcept
|
||||
{
|
||||
return tag == TYPE_PORT;
|
||||
}
|
||||
|
||||
enum function_flavor {
|
||||
enum FunctionFlavor {
|
||||
FUNC_FLAVOR_FUNCTION,
|
||||
FUNC_FLAVOR_EVENT,
|
||||
FUNC_FLAVOR_HOOK
|
||||
|
@ -116,9 +171,6 @@ constexpr InternalTypeTag to_internal_type_tag(TypeTag tag) noexcept
|
|||
return TYPE_INTERNAL_VOID;
|
||||
}
|
||||
|
||||
// Returns the name of the type.
|
||||
extern const char* type_name(TypeTag t);
|
||||
|
||||
class TypeList;
|
||||
class TableType;
|
||||
class SetType;
|
||||
|
@ -129,22 +181,20 @@ class EnumType;
|
|||
class VectorType;
|
||||
class TypeType;
|
||||
class OpaqueType;
|
||||
class EnumVal;
|
||||
class TableVal;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(ListExpr, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail);
|
||||
|
||||
const int DOES_NOT_MATCH_INDEX = 0;
|
||||
const int MATCHES_INDEX_SCALAR = 1;
|
||||
const int MATCHES_INDEX_VECTOR = 2;
|
||||
constexpr int DOES_NOT_MATCH_INDEX = 0;
|
||||
constexpr int MATCHES_INDEX_SCALAR = 1;
|
||||
constexpr int MATCHES_INDEX_VECTOR = 2;
|
||||
|
||||
class BroType : public BroObj {
|
||||
public:
|
||||
static inline const IntrusivePtr<BroType> nil;
|
||||
|
||||
explicit BroType(TypeTag tag, bool base_type = false);
|
||||
explicit BroType(zeek::TypeTag tag, bool base_type = false);
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag instead.")]]
|
||||
explicit BroType(::TypeTag tag, bool base_type = false)
|
||||
: BroType(static_cast<zeek::TypeTag>(tag), base_type)
|
||||
{}
|
||||
|
||||
// Performs a shallow clone operation of the Bro type.
|
||||
// This especially means that especially for tables the types
|
||||
|
@ -477,7 +527,13 @@ public:
|
|||
};
|
||||
|
||||
FuncType(IntrusivePtr<RecordType> args, IntrusivePtr<BroType> yield,
|
||||
function_flavor f);
|
||||
FunctionFlavor f);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::FunctionFlavor instead.")]]
|
||||
FuncType(IntrusivePtr<RecordType> args, IntrusivePtr<BroType> yield, ::function_flavor f)
|
||||
: FuncType(args, yield, static_cast<FunctionFlavor>(f))
|
||||
{}
|
||||
|
||||
IntrusivePtr<BroType> ShallowClone() override;
|
||||
|
||||
~FuncType() override;
|
||||
|
@ -492,13 +548,17 @@ public:
|
|||
{ return yield; }
|
||||
|
||||
void SetYieldType(IntrusivePtr<BroType> arg_yield) { yield = std::move(arg_yield); }
|
||||
function_flavor Flavor() const { return flavor; }
|
||||
FunctionFlavor Flavor() const { return flavor; }
|
||||
std::string FlavorString() const;
|
||||
|
||||
// Used to convert a function type to an event or hook type.
|
||||
void ClearYieldType(function_flavor arg_flav)
|
||||
void ClearYieldType(FunctionFlavor arg_flav)
|
||||
{ yield = nullptr; flavor = arg_flav; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::FunctionFlavor instead.")]]
|
||||
void ClearYieldType(::function_flavor arg_flav)
|
||||
{ yield = nullptr; flavor = static_cast<FunctionFlavor>(arg_flav); }
|
||||
|
||||
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||
bool CheckArgs(const type_list* args, bool is_init = false) const;
|
||||
bool CheckArgs(const std::vector<IntrusivePtr<BroType>>& args,
|
||||
|
@ -536,7 +596,7 @@ protected:
|
|||
IntrusivePtr<RecordType> args;
|
||||
IntrusivePtr<TypeList> arg_types;
|
||||
IntrusivePtr<BroType> yield;
|
||||
function_flavor flavor;
|
||||
FunctionFlavor flavor;
|
||||
std::vector<Prototype> prototypes;
|
||||
};
|
||||
|
||||
|
@ -583,7 +643,7 @@ public:
|
|||
const char* id = nullptr;
|
||||
};
|
||||
|
||||
typedef PList<TypeDecl> type_decl_list;
|
||||
using type_decl_list = PList<TypeDecl>;
|
||||
|
||||
class RecordType final : public BroType {
|
||||
public:
|
||||
|
@ -806,29 +866,6 @@ protected:
|
|||
IntrusivePtr<BroType> yield_type;
|
||||
};
|
||||
|
||||
extern IntrusivePtr<OpaqueType> md5_type;
|
||||
extern IntrusivePtr<OpaqueType> sha1_type;
|
||||
extern IntrusivePtr<OpaqueType> sha256_type;
|
||||
extern IntrusivePtr<OpaqueType> entropy_type;
|
||||
extern IntrusivePtr<OpaqueType> cardinality_type;
|
||||
extern IntrusivePtr<OpaqueType> topk_type;
|
||||
extern IntrusivePtr<OpaqueType> bloomfilter_type;
|
||||
extern IntrusivePtr<OpaqueType> x509_opaque_type;
|
||||
extern IntrusivePtr<OpaqueType> ocsp_resp_opaque_type;
|
||||
extern IntrusivePtr<OpaqueType> paraglob_type;
|
||||
|
||||
// Returns the basic (non-parameterized) type with the given type.
|
||||
const IntrusivePtr<BroType>& base_type(TypeTag tag);
|
||||
|
||||
// Returns the basic (non-parameterized) type with the given type.
|
||||
// The reference count of the type is not increased.
|
||||
[[deprecated("Remove in v4.1. Use ::base_type() instead")]]
|
||||
inline BroType* base_type_no_ref(TypeTag tag)
|
||||
{ return base_type(tag).get(); }
|
||||
|
||||
// Returns the basic error type.
|
||||
inline const IntrusivePtr<BroType>& error_type() { return base_type(TYPE_ERROR); }
|
||||
|
||||
// True if the two types are equivalent. If is_init is true then the test is
|
||||
// done in the context of an initialization. If match_record_field_names is
|
||||
// true then for record types the field names have to match, too.
|
||||
|
@ -887,7 +924,7 @@ inline bool is_atomic_type(const IntrusivePtr<BroType>& t)
|
|||
// True if the given type tag corresponds to type that can be assigned to.
|
||||
extern bool is_assignable(TypeTag t);
|
||||
inline bool is_assignable(BroType* t)
|
||||
{ return ::is_assignable(t->Tag()); }
|
||||
{ return zeek::is_assignable(t->Tag()); }
|
||||
|
||||
// True if the given type tag corresponds to an integral type.
|
||||
inline bool IsIntegral(TypeTag t) { return (t == TYPE_INT || t == TYPE_COUNT || t == TYPE_COUNTER); }
|
||||
|
@ -936,3 +973,65 @@ inline bool BothString(TypeTag t1, TypeTag t2) { return (IsString(t1) && IsStrin
|
|||
|
||||
// True if either tag is the error type.
|
||||
inline bool EitherError(TypeTag t1, TypeTag t2) { return (IsErrorType(t1) || IsErrorType(t2)); }
|
||||
|
||||
// Returns the basic (non-parameterized) type with the given type.
|
||||
const IntrusivePtr<zeek::BroType>& base_type(zeek::TypeTag tag);
|
||||
|
||||
// Returns the basic (non-parameterized) type with the given type.
|
||||
// The reference count of the type is not increased.
|
||||
[[deprecated("Remove in v4.1. Use ::base_type() instead")]]
|
||||
inline zeek::BroType* base_type_no_ref(TypeTag tag)
|
||||
{ return base_type(tag).get(); }
|
||||
|
||||
// Returns the basic error type.
|
||||
inline const IntrusivePtr<zeek::BroType>& error_type() { return base_type(TYPE_ERROR); }
|
||||
|
||||
} // namespace zeek
|
||||
|
||||
extern IntrusivePtr<zeek::OpaqueType> md5_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> sha1_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> sha256_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> entropy_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> cardinality_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> topk_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> bloomfilter_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> x509_opaque_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> ocsp_resp_opaque_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> paraglob_type;
|
||||
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::BroType instead.")]] = zeek::BroType;
|
||||
using TypeList [[deprecated("Remove in v4.1. Use zeek::TypeList instead.")]] = zeek::TypeList;
|
||||
using IndexType [[deprecated("Remove in v4.1. Use zeek::IndexType instead.")]] = zeek::IndexType;
|
||||
using TableType [[deprecated("Remove in v4.1. Use zeek::TableType instead.")]] = zeek::TableType;
|
||||
using SetType [[deprecated("Remove in v4.1. Use zeek::SetType instead.")]] = zeek::SetType;
|
||||
using FuncType [[deprecated("Remove in v4.1. Use zeek::FuncType instead.")]] = zeek::FuncType;
|
||||
using TypeType [[deprecated("Remove in v4.1. Use zeek::TypeType instead.")]] = zeek::TypeType;
|
||||
using TypeDecl [[deprecated("Remove in v4.1. Use zeek::TypeDecl instead.")]] = zeek::TypeDecl;
|
||||
using RecordType [[deprecated("Remove in v4.1. Use zeek::RecordType instead.")]] = zeek::RecordType;
|
||||
using SubNetType [[deprecated("Remove in v4.1. Use zeek::SubNetType instead.")]] = zeek::SubNetType;
|
||||
using FileType [[deprecated("Remove in v4.1. Use zeek::FileType instead.")]] = zeek::FileType;
|
||||
using OpaqueType [[deprecated("Remove in v4.1. Use zeek::OpaqueType instead.")]] = zeek::OpaqueType;
|
||||
using EnumType [[deprecated("Remove in v4.1. Use zeek::EnumType instead.")]] = zeek::EnumType;
|
||||
using VectorType [[deprecated("Remove in v4.1. Use zeek::VectorType instead.")]] = zeek::VectorType;
|
||||
using type_decl_list [[deprecated("Remove in v4.1. Use zeek::type_decl_list instead.")]] = zeek::type_decl_list;
|
||||
|
||||
constexpr auto IsIntegral [[deprecated("Remove in v4.1. Use zeek::IsIntegral instead.")]] = zeek::IsIntegral;
|
||||
constexpr auto IsArithmetic [[deprecated("Remove in v4.1. Use zeek::IsArithmetic instead.")]] = zeek::IsArithmetic;
|
||||
constexpr auto IsBool [[deprecated("Remove in v4.1. Use zeek::IsBool instead.")]] = zeek::IsBool;
|
||||
constexpr auto IsInterval [[deprecated("Remove in v4.1. Use zeek::IsInterval instead.")]] = zeek::IsInterval;
|
||||
constexpr auto IsRecord [[deprecated("Remove in v4.1. Use zeek::IsRecord instead.")]] = zeek::IsRecord;
|
||||
constexpr auto IsFunc [[deprecated("Remove in v4.1. Use zeek::IsFunc instead.")]] = zeek::IsFunc;
|
||||
constexpr auto IsVector [[deprecated("Remove in v4.1. Use zeek::IsVector instead.")]] = zeek::IsVector;
|
||||
constexpr auto IsString [[deprecated("Remove in v4.1. Use zeek::IsString instead.")]] = zeek::IsString;
|
||||
constexpr auto IsErrorType [[deprecated("Remove in v4.1. Use zeek::IsErrorType instead.")]] = zeek::IsErrorType;
|
||||
constexpr auto BothIntegral [[deprecated("Remove in v4.1. Use zeek::BothIntegral instead.")]] = zeek::BothIntegral;
|
||||
constexpr auto BothArithmetic [[deprecated("Remove in v4.1. Use zeek::BothArithmetic instead.")]] = zeek::BothArithmetic;
|
||||
constexpr auto EitherArithmetic [[deprecated("Remove in v4.1. Use zeek::EitherArithmetic instead.")]] = zeek::EitherArithmetic;
|
||||
constexpr auto BothBool [[deprecated("Remove in v4.1. Use zeek::BothBool instead.")]] = zeek::BothBool;
|
||||
constexpr auto BothInterval [[deprecated("Remove in v4.1. Use zeek::BothInterval instead.")]] = zeek::BothInterval;
|
||||
constexpr auto BothString [[deprecated("Remove in v4.1. Use zeek::BothString instead.")]] = zeek::BothString;
|
||||
constexpr auto EitherError [[deprecated("Remove in v4.1. Use zeek::EitherError instead.")]] = zeek::EitherError;
|
||||
constexpr auto base_type [[deprecated("Remove in v4.1. Use zeek::base_type instead.")]] = zeek::base_type;
|
||||
constexpr auto error_type [[deprecated("Remove in v4.1. Use zeek::error_type instead.")]] = zeek::error_type;
|
||||
constexpr auto type_name [[deprecated("Remove in v4.1. Use zeek::type_name instead.")]] = zeek::type_name;
|
||||
constexpr auto is_network_order [[deprecated("Remove in v4.1. Use zeek::is_network_order instead.")]] = zeek::is_network_order;
|
||||
|
|
394
src/Val.cc
394
src/Val.cc
File diff suppressed because it is too large
Load diff
212
src/Val.h
212
src/Val.h
|
@ -121,8 +121,12 @@ public:
|
|||
static inline const IntrusivePtr<Val> nil;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use IntervalVal(), TimeVal(), or DoubleVal() constructors.")]]
|
||||
Val(double d, TypeTag t)
|
||||
: val(d), type(base_type(t))
|
||||
Val(double d, zeek::TypeTag t)
|
||||
: val(d), type(zeek::base_type(t))
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use version that takes zeek::TypeTag instead.")]]
|
||||
Val(double d, ::TypeTag t) : Val(d, static_cast<zeek::TypeTag>(t))
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||
|
@ -136,16 +140,16 @@ public:
|
|||
explicit Val(IntrusivePtr<BroFile> f);
|
||||
|
||||
// Extra arg to differentiate from protected version.
|
||||
Val(IntrusivePtr<BroType> t, bool type_type)
|
||||
: type(make_intrusive<TypeType>(std::move(t)))
|
||||
Val(IntrusivePtr<zeek::BroType> t, bool type_type)
|
||||
: type(make_intrusive<zeek::TypeType>(std::move(t)))
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||
Val(BroType* t, bool type_type) : Val({NewRef{}, t}, type_type)
|
||||
Val(zeek::BroType* t, bool type_type) : Val({NewRef{}, t}, type_type)
|
||||
{}
|
||||
|
||||
Val()
|
||||
: val(bro_int_t(0)), type(base_type(TYPE_ERROR))
|
||||
: val(bro_int_t(0)), type(zeek::base_type(zeek::TYPE_ERROR))
|
||||
{}
|
||||
|
||||
~Val() override;
|
||||
|
@ -181,11 +185,11 @@ public:
|
|||
virtual bool RemoveFrom(Val* v) const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
BroType* Type() { return type.get(); }
|
||||
zeek::BroType* Type() { return type.get(); }
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
const BroType* Type() const { return type.get(); }
|
||||
const zeek::BroType* Type() const { return type.get(); }
|
||||
|
||||
const IntrusivePtr<BroType>& GetType() const
|
||||
const IntrusivePtr<zeek::BroType>& GetType() const
|
||||
{ return type; }
|
||||
|
||||
template <class T>
|
||||
|
@ -195,7 +199,7 @@ public:
|
|||
#define CONST_ACCESSOR(tag, ctype, accessor, name) \
|
||||
const ctype name() const \
|
||||
{ \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONST_ACCESSOR", type_name) \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONST_ACCESSOR", zeek::type_name) \
|
||||
return val.accessor; \
|
||||
}
|
||||
|
||||
|
@ -203,72 +207,72 @@ public:
|
|||
#define CONST_ACCESSOR2(tag, ctype, accessor, name) \
|
||||
ctype name() const \
|
||||
{ \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONST_ACCESSOR", type_name) \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONST_ACCESSOR", zeek::type_name) \
|
||||
return val.accessor; \
|
||||
}
|
||||
|
||||
CONST_ACCESSOR2(TYPE_BOOL, bool, int_val, AsBool)
|
||||
CONST_ACCESSOR2(TYPE_INT, bro_int_t, int_val, AsInt)
|
||||
CONST_ACCESSOR2(TYPE_COUNT, bro_uint_t, uint_val, AsCount)
|
||||
CONST_ACCESSOR2(TYPE_COUNTER, bro_uint_t, uint_val, AsCounter)
|
||||
CONST_ACCESSOR2(TYPE_DOUBLE, double, double_val, AsDouble)
|
||||
CONST_ACCESSOR2(TYPE_TIME, double, double_val, AsTime)
|
||||
CONST_ACCESSOR2(TYPE_INTERVAL, double, double_val, AsInterval)
|
||||
CONST_ACCESSOR2(TYPE_ENUM, int, int_val, AsEnum)
|
||||
CONST_ACCESSOR(TYPE_STRING, BroString*, string_val, AsString)
|
||||
CONST_ACCESSOR(TYPE_FUNC, Func*, func_val, AsFunc)
|
||||
CONST_ACCESSOR(TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsTable)
|
||||
CONST_ACCESSOR(TYPE_RECORD, std::vector<IntrusivePtr<Val>>*, record_val, AsRecord)
|
||||
CONST_ACCESSOR(TYPE_FILE, BroFile*, file_val, AsFile)
|
||||
CONST_ACCESSOR(TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
|
||||
CONST_ACCESSOR(TYPE_VECTOR, std::vector<IntrusivePtr<Val>>*, vector_val, AsVector)
|
||||
CONST_ACCESSOR2(zeek::TYPE_BOOL, bool, int_val, AsBool)
|
||||
CONST_ACCESSOR2(zeek::TYPE_INT, bro_int_t, int_val, AsInt)
|
||||
CONST_ACCESSOR2(zeek::TYPE_COUNT, bro_uint_t, uint_val, AsCount)
|
||||
CONST_ACCESSOR2(zeek::TYPE_COUNTER, bro_uint_t, uint_val, AsCounter)
|
||||
CONST_ACCESSOR2(zeek::TYPE_DOUBLE, double, double_val, AsDouble)
|
||||
CONST_ACCESSOR2(zeek::TYPE_TIME, double, double_val, AsTime)
|
||||
CONST_ACCESSOR2(zeek::TYPE_INTERVAL, double, double_val, AsInterval)
|
||||
CONST_ACCESSOR2(zeek::TYPE_ENUM, int, int_val, AsEnum)
|
||||
CONST_ACCESSOR(zeek::TYPE_STRING, BroString*, string_val, AsString)
|
||||
CONST_ACCESSOR(zeek::TYPE_FUNC, Func*, func_val, AsFunc)
|
||||
CONST_ACCESSOR(zeek::TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsTable)
|
||||
CONST_ACCESSOR(zeek::TYPE_RECORD, std::vector<IntrusivePtr<Val>>*, record_val, AsRecord)
|
||||
CONST_ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile)
|
||||
CONST_ACCESSOR(zeek::TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
|
||||
CONST_ACCESSOR(zeek::TYPE_VECTOR, std::vector<IntrusivePtr<Val>>*, vector_val, AsVector)
|
||||
|
||||
const IPPrefix& AsSubNet() const
|
||||
{
|
||||
CHECK_TAG(type->Tag(), TYPE_SUBNET, "Val::SubNet", type_name)
|
||||
CHECK_TAG(type->Tag(), zeek::TYPE_SUBNET, "Val::SubNet", zeek::type_name)
|
||||
return *val.subnet_val;
|
||||
}
|
||||
|
||||
BroType* AsType() const
|
||||
zeek::BroType* AsType() const
|
||||
{
|
||||
CHECK_TAG(type->Tag(), TYPE_TYPE, "Val::Type", type_name)
|
||||
CHECK_TAG(type->Tag(), zeek::TYPE_TYPE, "Val::Type", zeek::type_name)
|
||||
return type.get();
|
||||
}
|
||||
|
||||
const IPAddr& AsAddr() const
|
||||
{
|
||||
if ( type->Tag() != TYPE_ADDR )
|
||||
BadTag("Val::AsAddr", type_name(type->Tag()));
|
||||
if ( type->Tag() != zeek::TYPE_ADDR )
|
||||
BadTag("Val::AsAddr", zeek::type_name(type->Tag()));
|
||||
return *val.addr_val;
|
||||
}
|
||||
|
||||
#define ACCESSOR(tag, ctype, accessor, name) \
|
||||
ctype name() \
|
||||
{ \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::ACCESSOR", type_name) \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::ACCESSOR", zeek::type_name) \
|
||||
return val.accessor; \
|
||||
}
|
||||
|
||||
// Accessors for mutable values are called AsNonConst* and
|
||||
// are protected to avoid external state changes.
|
||||
// ACCESSOR(TYPE_STRING, BroString*, string_val, AsString)
|
||||
ACCESSOR(TYPE_FUNC, Func*, func_val, AsFunc)
|
||||
ACCESSOR(TYPE_FILE, BroFile*, file_val, AsFile)
|
||||
ACCESSOR(TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
|
||||
ACCESSOR(TYPE_VECTOR, std::vector<IntrusivePtr<Val>>*, vector_val, AsVector)
|
||||
// ACCESSOR(zeek::TYPE_STRING, BroString*, string_val, AsString)
|
||||
ACCESSOR(zeek::TYPE_FUNC, Func*, func_val, AsFunc)
|
||||
ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile)
|
||||
ACCESSOR(zeek::TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
|
||||
ACCESSOR(zeek::TYPE_VECTOR, std::vector<IntrusivePtr<Val>>*, vector_val, AsVector)
|
||||
|
||||
IntrusivePtr<Func> AsFuncPtr() const;
|
||||
|
||||
const IPPrefix& AsSubNet()
|
||||
{
|
||||
CHECK_TAG(type->Tag(), TYPE_SUBNET, "Val::SubNet", type_name)
|
||||
CHECK_TAG(type->Tag(), zeek::TYPE_SUBNET, "Val::SubNet", zeek::type_name)
|
||||
return *val.subnet_val;
|
||||
}
|
||||
|
||||
const IPAddr& AsAddr()
|
||||
{
|
||||
if ( type->Tag() != TYPE_ADDR )
|
||||
BadTag("Val::AsAddr", type_name(type->Tag()));
|
||||
if ( type->Tag() != zeek::TYPE_ADDR )
|
||||
BadTag("Val::AsAddr", zeek::type_name(type->Tag()));
|
||||
return *val.addr_val;
|
||||
}
|
||||
|
||||
|
@ -280,39 +284,39 @@ public:
|
|||
#define CONVERTER(tag, ctype, name) \
|
||||
ctype name() \
|
||||
{ \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", type_name) \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", zeek::type_name) \
|
||||
return (ctype)(this); \
|
||||
}
|
||||
|
||||
CONVERTER(TYPE_PATTERN, PatternVal*, AsPatternVal)
|
||||
CONVERTER(TYPE_PORT, PortVal*, AsPortVal)
|
||||
CONVERTER(TYPE_SUBNET, SubNetVal*, AsSubNetVal)
|
||||
CONVERTER(TYPE_ADDR, AddrVal*, AsAddrVal)
|
||||
CONVERTER(TYPE_TABLE, TableVal*, AsTableVal)
|
||||
CONVERTER(TYPE_RECORD, RecordVal*, AsRecordVal)
|
||||
CONVERTER(TYPE_LIST, ListVal*, AsListVal)
|
||||
CONVERTER(TYPE_STRING, StringVal*, AsStringVal)
|
||||
CONVERTER(TYPE_VECTOR, VectorVal*, AsVectorVal)
|
||||
CONVERTER(TYPE_ENUM, EnumVal*, AsEnumVal)
|
||||
CONVERTER(TYPE_OPAQUE, OpaqueVal*, AsOpaqueVal)
|
||||
CONVERTER(zeek::TYPE_PATTERN, PatternVal*, AsPatternVal)
|
||||
CONVERTER(zeek::TYPE_PORT, PortVal*, AsPortVal)
|
||||
CONVERTER(zeek::TYPE_SUBNET, SubNetVal*, AsSubNetVal)
|
||||
CONVERTER(zeek::TYPE_ADDR, AddrVal*, AsAddrVal)
|
||||
CONVERTER(zeek::TYPE_TABLE, TableVal*, AsTableVal)
|
||||
CONVERTER(zeek::TYPE_RECORD, RecordVal*, AsRecordVal)
|
||||
CONVERTER(zeek::TYPE_LIST, ListVal*, AsListVal)
|
||||
CONVERTER(zeek::TYPE_STRING, StringVal*, AsStringVal)
|
||||
CONVERTER(zeek::TYPE_VECTOR, VectorVal*, AsVectorVal)
|
||||
CONVERTER(zeek::TYPE_ENUM, EnumVal*, AsEnumVal)
|
||||
CONVERTER(zeek::TYPE_OPAQUE, OpaqueVal*, AsOpaqueVal)
|
||||
|
||||
#define CONST_CONVERTER(tag, ctype, name) \
|
||||
const ctype name() const \
|
||||
{ \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", type_name) \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", zeek::type_name) \
|
||||
return (const ctype)(this); \
|
||||
}
|
||||
|
||||
CONST_CONVERTER(TYPE_PATTERN, PatternVal*, AsPatternVal)
|
||||
CONST_CONVERTER(TYPE_PORT, PortVal*, AsPortVal)
|
||||
CONST_CONVERTER(TYPE_SUBNET, SubNetVal*, AsSubNetVal)
|
||||
CONST_CONVERTER(TYPE_ADDR, AddrVal*, AsAddrVal)
|
||||
CONST_CONVERTER(TYPE_TABLE, TableVal*, AsTableVal)
|
||||
CONST_CONVERTER(TYPE_RECORD, RecordVal*, AsRecordVal)
|
||||
CONST_CONVERTER(TYPE_LIST, ListVal*, AsListVal)
|
||||
CONST_CONVERTER(TYPE_STRING, StringVal*, AsStringVal)
|
||||
CONST_CONVERTER(TYPE_VECTOR, VectorVal*, AsVectorVal)
|
||||
CONST_CONVERTER(TYPE_OPAQUE, OpaqueVal*, AsOpaqueVal)
|
||||
CONST_CONVERTER(zeek::TYPE_PATTERN, PatternVal*, AsPatternVal)
|
||||
CONST_CONVERTER(zeek::TYPE_PORT, PortVal*, AsPortVal)
|
||||
CONST_CONVERTER(zeek::TYPE_SUBNET, SubNetVal*, AsSubNetVal)
|
||||
CONST_CONVERTER(zeek::TYPE_ADDR, AddrVal*, AsAddrVal)
|
||||
CONST_CONVERTER(zeek::TYPE_TABLE, TableVal*, AsTableVal)
|
||||
CONST_CONVERTER(zeek::TYPE_RECORD, RecordVal*, AsRecordVal)
|
||||
CONST_CONVERTER(zeek::TYPE_LIST, ListVal*, AsListVal)
|
||||
CONST_CONVERTER(zeek::TYPE_STRING, StringVal*, AsStringVal)
|
||||
CONST_CONVERTER(zeek::TYPE_VECTOR, VectorVal*, AsVectorVal)
|
||||
CONST_CONVERTER(zeek::TYPE_OPAQUE, OpaqueVal*, AsOpaqueVal)
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
virtual void DescribeReST(ODesc* d) const;
|
||||
|
@ -329,7 +333,7 @@ public:
|
|||
void SetID(zeek::detail::ID* id);
|
||||
#endif
|
||||
|
||||
static bool WouldOverflow(const BroType* from_type, const BroType* to_type, const Val* val);
|
||||
static bool WouldOverflow(const zeek::BroType* from_type, const zeek::BroType* to_type, const Val* val);
|
||||
|
||||
IntrusivePtr<TableVal> GetRecordFields();
|
||||
|
||||
|
@ -337,7 +341,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
friend class EnumType;
|
||||
friend class zeek::EnumType;
|
||||
friend class ListVal;
|
||||
friend class RecordVal;
|
||||
friend class VectorVal;
|
||||
|
@ -352,21 +356,21 @@ protected:
|
|||
static IntrusivePtr<Val> MakeCount(bro_uint_t u);
|
||||
|
||||
template<typename V>
|
||||
Val(V&& v, TypeTag t) noexcept
|
||||
: val(std::forward<V>(v)), type(base_type(t))
|
||||
Val(V&& v, zeek::TypeTag t) noexcept
|
||||
: val(std::forward<V>(v)), type(zeek::base_type(t))
|
||||
{}
|
||||
|
||||
template<typename V>
|
||||
Val(V&& v, IntrusivePtr<BroType> t) noexcept
|
||||
Val(V&& v, IntrusivePtr<zeek::BroType> t) noexcept
|
||||
: val(std::forward<V>(v)), type(std::move(t))
|
||||
{}
|
||||
|
||||
explicit Val(IntrusivePtr<BroType> t) noexcept
|
||||
explicit Val(IntrusivePtr<zeek::BroType> t) noexcept
|
||||
: type(std::move(t))
|
||||
{}
|
||||
|
||||
ACCESSOR(TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsNonConstTable)
|
||||
ACCESSOR(TYPE_RECORD, std::vector<IntrusivePtr<Val>>*, record_val, AsNonConstRecord)
|
||||
ACCESSOR(zeek::TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsNonConstTable)
|
||||
ACCESSOR(zeek::TYPE_RECORD, std::vector<IntrusivePtr<Val>>*, record_val, AsNonConstRecord)
|
||||
|
||||
// For internal use by the Val::Clone() methods.
|
||||
struct CloneState {
|
||||
|
@ -382,7 +386,7 @@ protected:
|
|||
virtual IntrusivePtr<Val> DoClone(CloneState* state);
|
||||
|
||||
BroValUnion val;
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
|
||||
#ifdef DEBUG
|
||||
// For debugging, we keep the name of the ID to which a Val is bound.
|
||||
|
@ -491,7 +495,7 @@ extern ValManager* val_mgr;
|
|||
class IntervalVal final : public Val {
|
||||
public:
|
||||
IntervalVal(double quantity, double units = Seconds)
|
||||
: Val(quantity * units, base_type(TYPE_INTERVAL))
|
||||
: Val(quantity * units, zeek::base_type(zeek::TYPE_INTERVAL))
|
||||
{}
|
||||
|
||||
protected:
|
||||
|
@ -501,14 +505,14 @@ protected:
|
|||
class TimeVal final : public Val {
|
||||
public:
|
||||
TimeVal(double t)
|
||||
: Val(t, base_type(TYPE_TIME))
|
||||
: Val(t, zeek::base_type(zeek::TYPE_TIME))
|
||||
{}
|
||||
};
|
||||
|
||||
class DoubleVal final : public Val {
|
||||
public:
|
||||
DoubleVal(double v)
|
||||
: Val(v, base_type(TYPE_DOUBLE))
|
||||
: Val(v, zeek::base_type(zeek::TYPE_DOUBLE))
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -647,10 +651,12 @@ protected:
|
|||
// element in their index.
|
||||
class ListVal final : public Val {
|
||||
public:
|
||||
explicit ListVal(TypeTag t);
|
||||
explicit ListVal(zeek::TypeTag t);
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag")]]
|
||||
explicit ListVal(::TypeTag t) : ListVal(static_cast<zeek::TypeTag>(t)) {}
|
||||
~ListVal() override;
|
||||
|
||||
TypeTag BaseTag() const { return tag; }
|
||||
zeek::TypeTag BaseTag() const { return tag; }
|
||||
|
||||
IntrusivePtr<Val> SizeVal() const override;
|
||||
|
||||
|
@ -698,7 +704,7 @@ protected:
|
|||
IntrusivePtr<Val> DoClone(CloneState* state) override;
|
||||
|
||||
std::vector<IntrusivePtr<Val>> vals;
|
||||
TypeTag tag;
|
||||
zeek::TypeTag tag;
|
||||
};
|
||||
|
||||
extern double bro_start_network_time;
|
||||
|
@ -758,10 +764,10 @@ class Frame;
|
|||
|
||||
class TableVal final : public Val, public notifier::Modifiable {
|
||||
public:
|
||||
explicit TableVal(IntrusivePtr<TableType> t, IntrusivePtr<zeek::detail::Attributes> attrs = nullptr);
|
||||
explicit TableVal(IntrusivePtr<zeek::TableType> t, IntrusivePtr<zeek::detail::Attributes> attrs = nullptr);
|
||||
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtrs instead.")]]
|
||||
explicit TableVal(TableType* t, Attributes* attrs = nullptr)
|
||||
explicit TableVal(zeek::TableType* t, Attributes* attrs = nullptr)
|
||||
: TableVal({NewRef{}, t}, {NewRef{}, attrs})
|
||||
{}
|
||||
|
||||
|
@ -933,14 +939,14 @@ public:
|
|||
{ return Remove(*k).release(); }
|
||||
|
||||
// Returns a ListVal representation of the table (which must be a set).
|
||||
IntrusivePtr<ListVal> ToListVal(TypeTag t = TYPE_ANY) const;
|
||||
IntrusivePtr<ListVal> ToListVal(zeek::TypeTag t = zeek::TYPE_ANY) const;
|
||||
|
||||
// Returns a ListVal representation of the table (which must be a set
|
||||
// with non-composite index type).
|
||||
IntrusivePtr<ListVal> ToPureListVal() const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use ToListVal() instead.")]]
|
||||
ListVal* ConvertToList(TypeTag t=TYPE_ANY) const;
|
||||
ListVal* ConvertToList(zeek::TypeTag t=zeek::TYPE_ANY) const;
|
||||
[[deprecated("Remove in v4.1. Use ToPureListVal() instead.")]]
|
||||
ListVal* ConvertToPureList() const; // must be single index type
|
||||
|
||||
|
@ -998,8 +1004,8 @@ public:
|
|||
notifier::Modifiable* Modifiable() override { return this; }
|
||||
|
||||
// Retrieves and saves all table state (key-value pairs) for
|
||||
// tables whose index type depends on the given RecordType.
|
||||
static void SaveParseTimeTableState(RecordType* rt);
|
||||
// tables whose index type depends on the given zeek::detail::RecordType.
|
||||
static void SaveParseTimeTableState(zeek::RecordType* rt);
|
||||
|
||||
// Rebuilds all TableVals whose state was previously saved by
|
||||
// SaveParseTimeTableState(). This is used to re-recreate the tables
|
||||
|
@ -1007,13 +1013,13 @@ public:
|
|||
static void RebuildParseTimeTables();
|
||||
|
||||
// Clears all state that was used to track TableVals that depending
|
||||
// on RecordTypes.
|
||||
// on zeek::detail::RecordTypes.
|
||||
static void DoneParsing();
|
||||
|
||||
protected:
|
||||
void Init(IntrusivePtr<TableType> t);
|
||||
void Init(IntrusivePtr<zeek::TableType> t);
|
||||
|
||||
using TableRecordDependencies = std::unordered_map<RecordType*, std::vector<IntrusivePtr<TableVal>>>;
|
||||
using TableRecordDependencies = std::unordered_map<zeek::RecordType*, std::vector<IntrusivePtr<TableVal>>>;
|
||||
|
||||
using ParseTimeTableState = std::vector<std::pair<IntrusivePtr<Val>, IntrusivePtr<Val>>>;
|
||||
using ParseTimeTableStates = std::unordered_map<TableVal*, ParseTimeTableState>;
|
||||
|
@ -1050,7 +1056,7 @@ protected:
|
|||
|
||||
IntrusivePtr<Val> DoClone(CloneState* state) override;
|
||||
|
||||
IntrusivePtr<TableType> table_type;
|
||||
IntrusivePtr<zeek::TableType> table_type;
|
||||
CompositeHash* table_hash;
|
||||
IntrusivePtr<zeek::detail::Attributes> attrs;
|
||||
IntrusivePtr<zeek::detail::Expr> expire_time;
|
||||
|
@ -1070,8 +1076,8 @@ protected:
|
|||
class RecordVal final : public Val, public notifier::Modifiable {
|
||||
public:
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||
explicit RecordVal(RecordType* t, bool init_fields = true);
|
||||
explicit RecordVal(IntrusivePtr<RecordType> t, bool init_fields = true);
|
||||
explicit RecordVal(zeek::RecordType* t, bool init_fields = true);
|
||||
explicit RecordVal(IntrusivePtr<zeek::RecordType> t, bool init_fields = true);
|
||||
|
||||
~RecordVal() override;
|
||||
|
||||
|
@ -1211,10 +1217,10 @@ public:
|
|||
//
|
||||
// The *allow_orphaning* parameter allows for a record to be demoted
|
||||
// down to a record type that contains less fields.
|
||||
IntrusivePtr<RecordVal> CoerceTo(IntrusivePtr<RecordType> other,
|
||||
IntrusivePtr<RecordVal> CoerceTo(IntrusivePtr<zeek::RecordType> other,
|
||||
IntrusivePtr<RecordVal> aggr,
|
||||
bool allow_orphaning = false) const;
|
||||
IntrusivePtr<RecordVal> CoerceTo(IntrusivePtr<RecordType> other,
|
||||
IntrusivePtr<RecordVal> CoerceTo(IntrusivePtr<zeek::RecordType> other,
|
||||
bool allow_orphaning = false);
|
||||
|
||||
unsigned int MemoryAllocation() const override;
|
||||
|
@ -1225,7 +1231,7 @@ public:
|
|||
// Extend the underlying arrays of record instances created during
|
||||
// parsing to match the number of fields in the record type (they may
|
||||
// mismatch as a result of parse-time record type redefinitions.
|
||||
static void ResizeParseTimeRecords(RecordType* rt);
|
||||
static void ResizeParseTimeRecords(zeek::RecordType* rt);
|
||||
|
||||
static void DoneParsing();
|
||||
|
||||
|
@ -1234,7 +1240,7 @@ protected:
|
|||
|
||||
BroObj* origin;
|
||||
|
||||
using RecordTypeValMap = std::unordered_map<RecordType*, std::vector<IntrusivePtr<RecordVal>>>;
|
||||
using RecordTypeValMap = std::unordered_map<zeek::RecordType*, std::vector<IntrusivePtr<RecordVal>>>;
|
||||
static RecordTypeValMap parse_time_records;
|
||||
};
|
||||
|
||||
|
@ -1244,12 +1250,12 @@ public:
|
|||
|
||||
protected:
|
||||
friend class Val;
|
||||
friend class EnumType;
|
||||
friend class zeek::EnumType;
|
||||
|
||||
template<class T, class... Ts>
|
||||
friend IntrusivePtr<T> make_intrusive(Ts&&... args);
|
||||
|
||||
EnumVal(IntrusivePtr<EnumType> t, int i) : Val(bro_int_t(i), std::move(t))
|
||||
EnumVal(IntrusivePtr<zeek::EnumType> t, int i) : Val(bro_int_t(i), std::move(t))
|
||||
{}
|
||||
|
||||
void ValDescribe(ODesc* d) const override;
|
||||
|
@ -1260,8 +1266,8 @@ protected:
|
|||
class VectorVal final : public Val, public notifier::Modifiable {
|
||||
public:
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||
explicit VectorVal(VectorType* t);
|
||||
explicit VectorVal(IntrusivePtr<VectorType> t);
|
||||
explicit VectorVal(zeek::VectorType* t);
|
||||
explicit VectorVal(IntrusivePtr<zeek::VectorType> t);
|
||||
~VectorVal() override;
|
||||
|
||||
IntrusivePtr<Val> SizeVal() const override;
|
||||
|
@ -1366,7 +1372,7 @@ protected:
|
|||
// If not a match, generates an error message and return nil. If is_init is
|
||||
// true, then the checking is done in the context of an initialization.
|
||||
extern IntrusivePtr<Val> check_and_promote(IntrusivePtr<Val> v,
|
||||
const BroType* t, bool is_init,
|
||||
const zeek::BroType* t, bool is_init,
|
||||
const Location* expr_location = nullptr);
|
||||
|
||||
extern bool same_val(const Val* v1, const Val* v2);
|
||||
|
@ -1378,22 +1384,22 @@ extern void describe_vals(const std::vector<IntrusivePtr<Val>>& vals,
|
|||
extern void delete_vals(val_list* vals);
|
||||
|
||||
// True if the given Val* has a vector type.
|
||||
inline bool is_vector(Val* v) { return v->GetType()->Tag() == TYPE_VECTOR; }
|
||||
inline bool is_vector(Val* v) { return v->GetType()->Tag() == zeek::TYPE_VECTOR; }
|
||||
inline bool is_vector(const IntrusivePtr<Val>& v) { return is_vector(v.get()); }
|
||||
|
||||
// Returns v casted to type T if the type supports that. Returns null if not.
|
||||
//
|
||||
// Note: This implements the script-level cast operator.
|
||||
extern IntrusivePtr<Val> cast_value_to_type(Val* v, BroType* t);
|
||||
extern IntrusivePtr<Val> cast_value_to_type(Val* v, zeek::BroType* t);
|
||||
|
||||
// Returns true if v can be casted to type T. If so, check_and_cast() will
|
||||
// succeed as well.
|
||||
//
|
||||
// Note: This implements the script-level type comparision operator.
|
||||
extern bool can_cast_value_to_type(const Val* v, BroType* t);
|
||||
extern bool can_cast_value_to_type(const Val* v, zeek::BroType* t);
|
||||
|
||||
// Returns true if values of type s may support casting to type t. This is
|
||||
// purely static check to weed out cases early on that will never succeed.
|
||||
// However, even this function returns true, casting may still fail for a
|
||||
// specific instance later.
|
||||
extern bool can_cast_value_to_type(const BroType* s, BroType* t);
|
||||
extern bool can_cast_value_to_type(const zeek::BroType* s, zeek::BroType* t);
|
||||
|
|
98
src/Var.cc
98
src/Var.cc
|
@ -19,7 +19,7 @@
|
|||
|
||||
using namespace zeek::detail;
|
||||
|
||||
static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const BroType* t,
|
||||
static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const zeek::BroType* t,
|
||||
IntrusivePtr<Val> aggr)
|
||||
{
|
||||
try
|
||||
|
@ -32,14 +32,14 @@ static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const BroType* t,
|
|||
}
|
||||
}
|
||||
|
||||
static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, BroType* t,
|
||||
static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, zeek::BroType* t,
|
||||
std::vector<IntrusivePtr<zeek::detail::Attr>>* attrs,
|
||||
const IntrusivePtr<zeek::detail::Expr>& init)
|
||||
{
|
||||
if ( ! IsFunc(id->GetType()->Tag()) )
|
||||
if ( ! zeek::IsFunc(id->GetType()->Tag()) )
|
||||
return false;
|
||||
|
||||
if ( ! IsFunc(t->Tag()) )
|
||||
if ( ! zeek::IsFunc(t->Tag()) )
|
||||
{
|
||||
t->Error("type incompatible with previous definition", id.get());
|
||||
return false;
|
||||
|
@ -54,7 +54,7 @@ static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, BroType* t,
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( canon_ft->Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
if ( canon_ft->Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
alt_ft->Error("redeclaration of function", canon_ft);
|
||||
return false;
|
||||
|
@ -105,12 +105,12 @@ static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, BroType* t,
|
|||
if ( a->Tag() == zeek::detail::ATTR_DEPRECATED )
|
||||
deprecated = true;
|
||||
|
||||
FuncType::Prototype p{deprecated, alt_args, std::move(offsets)};
|
||||
zeek::FuncType::Prototype p{deprecated, alt_args, std::move(offsets)};
|
||||
canon_ft->AddPrototype(std::move(p));
|
||||
return true;
|
||||
}
|
||||
|
||||
static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType> t,
|
||||
static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::BroType> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
|
@ -119,7 +119,7 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
{
|
||||
if ( id->GetType() )
|
||||
{
|
||||
if ( id->IsRedefinable() || (! init && attr && ! IsFunc(id->GetType()->Tag())) )
|
||||
if ( id->IsRedefinable() || (! init && attr && ! zeek::IsFunc(id->GetType()->Tag())) )
|
||||
{
|
||||
BroObj* redef_obj = init ? (BroObj*) init.get() : (BroObj*) t.get();
|
||||
if ( dt != VAR_REDEF )
|
||||
|
@ -128,7 +128,7 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
|
||||
else if ( dt != VAR_REDEF || init || ! attr )
|
||||
{
|
||||
if ( IsFunc(id->GetType()->Tag()) )
|
||||
if ( zeek::IsFunc(id->GetType()->Tag()) )
|
||||
add_prototype(id, t.get(), attr.get(), init);
|
||||
else
|
||||
id->Error("already defined", init.get());
|
||||
|
@ -149,10 +149,10 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
t = id->GetType();
|
||||
}
|
||||
|
||||
if ( id->GetType() && id->GetType()->Tag() != TYPE_ERROR )
|
||||
if ( id->GetType() && id->GetType()->Tag() != zeek::TYPE_ERROR )
|
||||
{
|
||||
if ( dt != VAR_REDEF &&
|
||||
(! init || ! do_init || (! t && ! (t = init_type(init.get())))) )
|
||||
(! init || ! do_init || (! t && ! (t = zeek::init_type(init.get())))) )
|
||||
{
|
||||
id->Error("already defined", init.get());
|
||||
return;
|
||||
|
@ -168,7 +168,7 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
|
||||
if ( t && t->IsSet() )
|
||||
{ // Check for set with explicit elements.
|
||||
SetType* st = t->AsTableType()->AsSetType();
|
||||
zeek::SetType* st = t->AsTableType()->AsSetType();
|
||||
const auto& elements = st->Elements();
|
||||
|
||||
if ( elements )
|
||||
|
@ -191,10 +191,10 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
return;
|
||||
}
|
||||
|
||||
t = init_type(init.get());
|
||||
t = zeek::init_type(init.get());
|
||||
if ( ! t )
|
||||
{
|
||||
id->SetType(error_type());
|
||||
id->SetType(zeek::error_type());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -245,9 +245,9 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
{
|
||||
IntrusivePtr<Val> aggr;
|
||||
|
||||
if ( t->Tag() == TYPE_RECORD )
|
||||
if ( t->Tag() == zeek::TYPE_RECORD )
|
||||
{
|
||||
aggr = make_intrusive<RecordVal>(cast_intrusive<RecordType>(t));
|
||||
aggr = make_intrusive<RecordVal>(cast_intrusive<zeek::RecordType>(t));
|
||||
|
||||
if ( init && t )
|
||||
// Have an initialization and type is not deduced.
|
||||
|
@ -255,12 +255,12 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
IntrusivePtr{NewRef{}, t->AsRecordType()});
|
||||
}
|
||||
|
||||
else if ( t->Tag() == TYPE_TABLE )
|
||||
aggr = make_intrusive<TableVal>(cast_intrusive<TableType>(t),
|
||||
else if ( t->Tag() == zeek::TYPE_TABLE )
|
||||
aggr = make_intrusive<TableVal>(cast_intrusive<zeek::TableType>(t),
|
||||
id->GetAttrs());
|
||||
|
||||
else if ( t->Tag() == TYPE_VECTOR )
|
||||
aggr = make_intrusive<VectorVal>(cast_intrusive<VectorType>(t));
|
||||
else if ( t->Tag() == zeek::TYPE_VECTOR )
|
||||
aggr = make_intrusive<VectorVal>(cast_intrusive<zeek::VectorType>(t));
|
||||
|
||||
IntrusivePtr<Val> v;
|
||||
|
||||
|
@ -297,9 +297,9 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
|
||||
id->UpdateValAttrs();
|
||||
|
||||
if ( t && t->Tag() == TYPE_FUNC &&
|
||||
(t->AsFuncType()->Flavor() == FUNC_FLAVOR_EVENT ||
|
||||
t->AsFuncType()->Flavor() == FUNC_FLAVOR_HOOK) )
|
||||
if ( t && t->Tag() == zeek::TYPE_FUNC &&
|
||||
(t->AsFuncType()->Flavor() == zeek::FUNC_FLAVOR_EVENT ||
|
||||
t->AsFuncType()->Flavor() == zeek::FUNC_FLAVOR_HOOK) )
|
||||
{
|
||||
// For events, add a function value (without any body) here so that
|
||||
// we can later access the ID even if no implementations have been
|
||||
|
@ -310,7 +310,7 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
}
|
||||
}
|
||||
|
||||
void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType> t,
|
||||
void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::BroType> t,
|
||||
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt)
|
||||
|
@ -318,7 +318,7 @@ void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType>
|
|||
make_var(id, std::move(t), c, std::move(init), std::move(attr), dt, true);
|
||||
}
|
||||
|
||||
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id, IntrusivePtr<BroType> t,
|
||||
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id, IntrusivePtr<zeek::BroType> t,
|
||||
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt)
|
||||
|
@ -360,14 +360,14 @@ extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::
|
|||
false, std::move(val));
|
||||
}
|
||||
|
||||
void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
||||
void add_type(zeek::detail::ID* id, IntrusivePtr<zeek::BroType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr)
|
||||
{
|
||||
std::string new_type_name = id->Name();
|
||||
std::string old_type_name = t->GetName();
|
||||
IntrusivePtr<BroType> tnew;
|
||||
IntrusivePtr<zeek::BroType> tnew;
|
||||
|
||||
if ( (t->Tag() == TYPE_RECORD || t->Tag() == TYPE_ENUM) &&
|
||||
if ( (t->Tag() == zeek::TYPE_RECORD || t->Tag() == zeek::TYPE_ENUM) &&
|
||||
old_type_name.empty() )
|
||||
// An extensible type (record/enum) being declared for first time.
|
||||
tnew = std::move(t);
|
||||
|
@ -375,10 +375,10 @@ void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
|||
// Clone the type to preserve type name aliasing.
|
||||
tnew = t->ShallowClone();
|
||||
|
||||
BroType::AddAlias(new_type_name, tnew.get());
|
||||
zeek::BroType::AddAlias(new_type_name, tnew.get());
|
||||
|
||||
if ( new_type_name != old_type_name && ! old_type_name.empty() )
|
||||
BroType::AddAlias(old_type_name, tnew.get());
|
||||
zeek::BroType::AddAlias(old_type_name, tnew.get());
|
||||
|
||||
tnew->SetName(id->Name());
|
||||
|
||||
|
@ -389,12 +389,12 @@ void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
|||
id->SetAttrs(make_intrusive<zeek::detail::Attributes>(std::move(*attr), tnew, false, false));
|
||||
}
|
||||
|
||||
static void transfer_arg_defaults(RecordType* args, RecordType* recv)
|
||||
static void transfer_arg_defaults(zeek::RecordType* args, zeek::RecordType* recv)
|
||||
{
|
||||
for ( int i = 0; i < args->NumFields(); ++i )
|
||||
{
|
||||
TypeDecl* args_i = args->FieldDecl(i);
|
||||
TypeDecl* recv_i = recv->FieldDecl(i);
|
||||
zeek::TypeDecl* args_i = args->FieldDecl(i);
|
||||
zeek::TypeDecl* recv_i = recv->FieldDecl(i);
|
||||
|
||||
const auto& def = args_i->attrs ? args_i->attrs->Find(zeek::detail::ATTR_DEFAULT) : nullptr;
|
||||
|
||||
|
@ -427,7 +427,7 @@ static zeek::detail::Attr* find_attr(const std::vector<IntrusivePtr<zeek::detail
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static std::optional<FuncType::Prototype> func_type_check(const FuncType* decl, const FuncType* impl)
|
||||
static std::optional<zeek::FuncType::Prototype> func_type_check(const zeek::FuncType* decl, const zeek::FuncType* impl)
|
||||
{
|
||||
if ( decl->Flavor() != impl->Flavor() )
|
||||
{
|
||||
|
@ -435,7 +435,7 @@ static std::optional<FuncType::Prototype> func_type_check(const FuncType* decl,
|
|||
return {};
|
||||
}
|
||||
|
||||
if ( impl->Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
if ( impl->Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
if ( same_type(decl, impl) )
|
||||
return decl->Prototypes()[0];
|
||||
|
@ -447,7 +447,7 @@ static std::optional<FuncType::Prototype> func_type_check(const FuncType* decl,
|
|||
return decl->FindPrototype(*impl->Params());
|
||||
}
|
||||
|
||||
static bool canonical_arg_types_match(const FuncType* decl, const FuncType* impl)
|
||||
static bool canonical_arg_types_match(const zeek::FuncType* decl, const zeek::FuncType* impl)
|
||||
{
|
||||
const auto& canon_args = decl->Params();
|
||||
const auto& impl_args = impl->Params();
|
||||
|
@ -463,21 +463,21 @@ static bool canonical_arg_types_match(const FuncType* decl, const FuncType* impl
|
|||
}
|
||||
|
||||
void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
||||
function_flavor flavor, bool is_redef,
|
||||
IntrusivePtr<FuncType> t,
|
||||
zeek::FunctionFlavor flavor, bool is_redef,
|
||||
IntrusivePtr<zeek::FuncType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs)
|
||||
{
|
||||
if ( flavor == FUNC_FLAVOR_EVENT )
|
||||
if ( flavor == zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
const auto& yt = t->Yield();
|
||||
|
||||
if ( yt && yt->Tag() != TYPE_VOID )
|
||||
if ( yt && yt->Tag() != zeek::TYPE_VOID )
|
||||
id->Error("event cannot yield a value", t.get());
|
||||
|
||||
t->ClearYieldType(flavor);
|
||||
}
|
||||
|
||||
std::optional<FuncType::Prototype> prototype;
|
||||
std::optional<zeek::FuncType::Prototype> prototype;
|
||||
|
||||
if ( id->GetType() )
|
||||
{
|
||||
|
@ -486,7 +486,7 @@ void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
|||
|
||||
if ( prototype )
|
||||
{
|
||||
if ( decl->Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
if ( decl->Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
// If a previous declaration of the function had &default
|
||||
// params, automatically transfer any that are missing
|
||||
|
@ -535,21 +535,21 @@ void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
|||
|
||||
if ( id->HasVal() )
|
||||
{
|
||||
function_flavor id_flavor = id->GetVal()->AsFunc()->Flavor();
|
||||
zeek::FunctionFlavor id_flavor = id->GetVal()->AsFunc()->Flavor();
|
||||
|
||||
if ( id_flavor != flavor )
|
||||
id->Error("inconsistent function flavor", t.get());
|
||||
|
||||
switch ( id_flavor ) {
|
||||
|
||||
case FUNC_FLAVOR_EVENT:
|
||||
case FUNC_FLAVOR_HOOK:
|
||||
case zeek::FUNC_FLAVOR_EVENT:
|
||||
case zeek::FUNC_FLAVOR_HOOK:
|
||||
if ( is_redef )
|
||||
// Clear out value so it will be replaced.
|
||||
id->SetVal(nullptr);
|
||||
break;
|
||||
|
||||
case FUNC_FLAVOR_FUNCTION:
|
||||
case zeek::FUNC_FLAVOR_FUNCTION:
|
||||
if ( ! id->IsRedefinable() )
|
||||
id->Error("already defined");
|
||||
break;
|
||||
|
@ -569,7 +569,7 @@ void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
|||
|
||||
for ( int i = 0; i < num_args; ++i )
|
||||
{
|
||||
TypeDecl* arg_i = args->FieldDecl(i);
|
||||
zeek::TypeDecl* arg_i = args->FieldDecl(i);
|
||||
auto arg_id = lookup_ID(arg_i->id, module_name);
|
||||
|
||||
if ( arg_id && ! arg_id->IsGlobal() )
|
||||
|
@ -752,7 +752,7 @@ ListVal* internal_list_val(const char* name)
|
|||
|
||||
if ( v )
|
||||
{
|
||||
if ( v->GetType()->Tag() == TYPE_LIST )
|
||||
if ( v->GetType()->Tag() == zeek::TYPE_LIST )
|
||||
return (ListVal*) v;
|
||||
|
||||
else if ( v->GetType()->IsSet() )
|
||||
|
@ -769,7 +769,7 @@ ListVal* internal_list_val(const char* name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
BroType* internal_type(const char* name)
|
||||
zeek::BroType* internal_type(const char* name)
|
||||
{
|
||||
return zeek::id::find_type(name).get();
|
||||
}
|
||||
|
|
14
src/Var.h
14
src/Var.h
|
@ -6,27 +6,27 @@
|
|||
#include "ID.h"
|
||||
#include "Type.h"
|
||||
|
||||
class FuncType;
|
||||
class Scope;
|
||||
class EventHandlerPtr;
|
||||
class StringVal;
|
||||
class TableVal;
|
||||
class ListVal;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(FuncType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||
|
||||
typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type;
|
||||
|
||||
extern void add_global(const IntrusivePtr<zeek::detail::ID>& id,
|
||||
IntrusivePtr<BroType> t,
|
||||
IntrusivePtr<zeek::BroType> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt);
|
||||
|
||||
extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id,
|
||||
IntrusivePtr<BroType> t,
|
||||
IntrusivePtr<zeek::BroType> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
|
@ -36,12 +36,12 @@ extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::
|
|||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
IntrusivePtr<Val> val = nullptr);
|
||||
|
||||
extern void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
||||
extern void add_type(zeek::detail::ID* id, IntrusivePtr<zeek::BroType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr);
|
||||
|
||||
extern void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
||||
function_flavor flavor, bool is_redef,
|
||||
IntrusivePtr<FuncType> t,
|
||||
zeek::FunctionFlavor flavor, bool is_redef,
|
||||
IntrusivePtr<zeek::FuncType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs = nullptr);
|
||||
|
||||
extern void end_func(IntrusivePtr<zeek::detail::Stmt> body);
|
||||
|
@ -77,7 +77,7 @@ extern TableVal* opt_internal_table(const char* name); // nil if not defined
|
|||
extern ListVal* internal_list_val(const char* name);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::id::find_type().")]]
|
||||
extern BroType* internal_type(const char* name);
|
||||
extern zeek::BroType* internal_type(const char* name);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::id::find_func().")]]
|
||||
extern Func* internal_func(const char* name);
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
%}
|
||||
|
||||
%header{
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Encoding* i, TypeTag t);
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Integer* i, TypeTag t);
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Encoding* i, zeek::TypeTag t);
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Integer* i, zeek::TypeTag t);
|
||||
IntrusivePtr<StringVal> asn1_oid_to_val(const ASN1Encoding* oid);
|
||||
IntrusivePtr<StringVal> asn1_oid_to_val(const ASN1ObjectIdentifier* oid);
|
||||
IntrusivePtr<StringVal> asn1_octet_string_to_val(const ASN1Encoding* s);
|
||||
|
@ -102,25 +102,25 @@ function binary_to_int64(bs: bytestring): int64
|
|||
|
||||
%code{
|
||||
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Integer* i, TypeTag t)
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Integer* i, zeek::TypeTag t)
|
||||
{
|
||||
return asn1_integer_to_val(i->encoding(), t);
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Encoding* i, TypeTag t)
|
||||
IntrusivePtr<Val> asn1_integer_to_val(const ASN1Encoding* i, zeek::TypeTag t)
|
||||
{
|
||||
auto v = binary_to_int64(i->content());
|
||||
|
||||
switch ( t ) {
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
return val_mgr->Bool(v);
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_INT:
|
||||
return val_mgr->Int(v);
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
return val_mgr->Count(v);
|
||||
default:
|
||||
reporter->Error("bad asn1_integer_to_val tag: %s", type_name(t));
|
||||
reporter->Error("bad asn1_integer_to_val tag: %s", zeek::type_name(t));
|
||||
return val_mgr->Count(v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
using namespace analyzer::bittorrent;
|
||||
|
||||
static IntrusivePtr<TableType> bt_tracker_headers;
|
||||
static IntrusivePtr<RecordType> bittorrent_peer;
|
||||
static IntrusivePtr<TableType> bittorrent_peer_set;
|
||||
static IntrusivePtr<RecordType> bittorrent_benc_value;
|
||||
static IntrusivePtr<TableType> bittorrent_benc_dir;
|
||||
static IntrusivePtr<zeek::TableType> bt_tracker_headers;
|
||||
static IntrusivePtr<zeek::RecordType> bittorrent_peer;
|
||||
static IntrusivePtr<zeek::TableType> bittorrent_peer_set;
|
||||
static IntrusivePtr<zeek::RecordType> bittorrent_benc_value;
|
||||
static IntrusivePtr<zeek::TableType> bittorrent_benc_dir;
|
||||
|
||||
BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
|
||||
: tcp::TCP_ApplicationAnalyzer("BITTORRENTTRACKER", c)
|
||||
|
@ -27,15 +27,15 @@ BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
|
|||
if ( ! bt_tracker_headers )
|
||||
{
|
||||
bt_tracker_headers =
|
||||
zeek::id::find_type<TableType>("bt_tracker_headers");
|
||||
zeek::id::find_type<zeek::TableType>("bt_tracker_headers");
|
||||
bittorrent_peer =
|
||||
zeek::id::find_type<RecordType>("bittorrent_peer");
|
||||
zeek::id::find_type<zeek::RecordType>("bittorrent_peer");
|
||||
bittorrent_peer_set =
|
||||
zeek::id::find_type<TableType>("bittorrent_peer_set");
|
||||
zeek::id::find_type<zeek::TableType>("bittorrent_peer_set");
|
||||
bittorrent_benc_value =
|
||||
zeek::id::find_type<RecordType>("bittorrent_benc_value");
|
||||
zeek::id::find_type<zeek::RecordType>("bittorrent_benc_value");
|
||||
bittorrent_benc_dir =
|
||||
zeek::id::find_type<TableType>("bittorrent_benc_dir");
|
||||
zeek::id::find_type<zeek::TableType>("bittorrent_benc_dir");
|
||||
}
|
||||
|
||||
keep_alive = false;
|
||||
|
|
|
@ -119,4 +119,3 @@ refine typeattr DHCP_Message += &let {
|
|||
refine typeattr Option += &let {
|
||||
proc_create_options = $context.flow.create_options(code);
|
||||
};
|
||||
|
||||
|
|
|
@ -594,7 +594,7 @@ bool DNS_Interpreter::ParseRR_SOA(DNS_MsgInfo* msg,
|
|||
|
||||
if ( dns_SOA_reply && ! msg->skip_event )
|
||||
{
|
||||
static auto dns_soa = zeek::id::find_type<RecordType>("dns_soa");
|
||||
static auto dns_soa = zeek::id::find_type<zeek::RecordType>("dns_soa");
|
||||
auto r = make_intrusive<RecordVal>(dns_soa);
|
||||
r->Assign(0, make_intrusive<StringVal>(new BroString(mname, mname_end - mname, true)));
|
||||
r->Assign(1, make_intrusive<StringVal>(new BroString(rname, rname_end - rname, true)));
|
||||
|
@ -1438,7 +1438,7 @@ DNS_MsgInfo::DNS_MsgInfo(DNS_RawMsgHdr* hdr, int arg_is_query)
|
|||
|
||||
IntrusivePtr<RecordVal> DNS_MsgInfo::BuildHdrVal()
|
||||
{
|
||||
static auto dns_msg = zeek::id::find_type<RecordType>("dns_msg");
|
||||
static auto dns_msg = zeek::id::find_type<zeek::RecordType>("dns_msg");
|
||||
auto r = make_intrusive<RecordVal>(dns_msg);
|
||||
|
||||
r->Assign(0, val_mgr->Count(id));
|
||||
|
@ -1460,7 +1460,7 @@ IntrusivePtr<RecordVal> DNS_MsgInfo::BuildHdrVal()
|
|||
|
||||
IntrusivePtr<RecordVal> DNS_MsgInfo::BuildAnswerVal()
|
||||
{
|
||||
static auto dns_answer = zeek::id::find_type<RecordType>("dns_answer");
|
||||
static auto dns_answer = zeek::id::find_type<zeek::RecordType>("dns_answer");
|
||||
auto r = make_intrusive<RecordVal>(dns_answer);
|
||||
|
||||
r->Assign(0, val_mgr->Count(int(answer_type)));
|
||||
|
@ -1476,7 +1476,7 @@ IntrusivePtr<RecordVal> DNS_MsgInfo::BuildEDNS_Val()
|
|||
{
|
||||
// We have to treat the additional record type in EDNS differently
|
||||
// than a regular resource record.
|
||||
static auto dns_edns_additional = zeek::id::find_type<RecordType>("dns_edns_additional");
|
||||
static auto dns_edns_additional = zeek::id::find_type<zeek::RecordType>("dns_edns_additional");
|
||||
auto r = make_intrusive<RecordVal>(dns_edns_additional);
|
||||
|
||||
r->Assign(0, val_mgr->Count(int(answer_type)));
|
||||
|
@ -1510,7 +1510,7 @@ IntrusivePtr<RecordVal> DNS_MsgInfo::BuildEDNS_Val()
|
|||
|
||||
IntrusivePtr<RecordVal> DNS_MsgInfo::BuildTSIG_Val(struct TSIG_DATA* tsig)
|
||||
{
|
||||
static auto dns_tsig_additional = zeek::id::find_type<RecordType>("dns_tsig_additional");
|
||||
static auto dns_tsig_additional = zeek::id::find_type<zeek::RecordType>("dns_tsig_additional");
|
||||
auto r = make_intrusive<RecordVal>(dns_tsig_additional);
|
||||
double rtime = tsig->time_s + tsig->time_ms / 1000.0;
|
||||
|
||||
|
@ -1530,7 +1530,7 @@ IntrusivePtr<RecordVal> DNS_MsgInfo::BuildTSIG_Val(struct TSIG_DATA* tsig)
|
|||
|
||||
IntrusivePtr<RecordVal> DNS_MsgInfo::BuildRRSIG_Val(RRSIG_DATA* rrsig)
|
||||
{
|
||||
static auto dns_rrsig_rr = zeek::id::find_type<RecordType>("dns_rrsig_rr");
|
||||
static auto dns_rrsig_rr = zeek::id::find_type<zeek::RecordType>("dns_rrsig_rr");
|
||||
auto r = make_intrusive<RecordVal>(dns_rrsig_rr);
|
||||
|
||||
r->Assign(0, query_name);
|
||||
|
@ -1551,7 +1551,7 @@ IntrusivePtr<RecordVal> DNS_MsgInfo::BuildRRSIG_Val(RRSIG_DATA* rrsig)
|
|||
|
||||
IntrusivePtr<RecordVal> DNS_MsgInfo::BuildDNSKEY_Val(DNSKEY_DATA* dnskey)
|
||||
{
|
||||
static auto dns_dnskey_rr = zeek::id::find_type<RecordType>("dns_dnskey_rr");
|
||||
static auto dns_dnskey_rr = zeek::id::find_type<zeek::RecordType>("dns_dnskey_rr");
|
||||
auto r = make_intrusive<RecordVal>(dns_dnskey_rr);
|
||||
|
||||
r->Assign(0, query_name);
|
||||
|
@ -1567,7 +1567,7 @@ IntrusivePtr<RecordVal> DNS_MsgInfo::BuildDNSKEY_Val(DNSKEY_DATA* dnskey)
|
|||
|
||||
IntrusivePtr<RecordVal> DNS_MsgInfo::BuildNSEC3_Val(NSEC3_DATA* nsec3)
|
||||
{
|
||||
static auto dns_nsec3_rr = zeek::id::find_type<RecordType>("dns_nsec3_rr");
|
||||
static auto dns_nsec3_rr = zeek::id::find_type<zeek::RecordType>("dns_nsec3_rr");
|
||||
auto r = make_intrusive<RecordVal>(dns_nsec3_rr);
|
||||
|
||||
r->Assign(0, query_name);
|
||||
|
@ -1587,7 +1587,7 @@ IntrusivePtr<RecordVal> DNS_MsgInfo::BuildNSEC3_Val(NSEC3_DATA* nsec3)
|
|||
|
||||
IntrusivePtr<RecordVal> DNS_MsgInfo::BuildDS_Val(DS_DATA* ds)
|
||||
{
|
||||
static auto dns_ds_rr = zeek::id::find_type<RecordType>("dns_ds_rr");
|
||||
static auto dns_ds_rr = zeek::id::find_type<zeek::RecordType>("dns_ds_rr");
|
||||
auto r = make_intrusive<RecordVal>(dns_ds_rr);
|
||||
|
||||
r->Assign(0, query_name);
|
||||
|
|
|
@ -615,7 +615,7 @@ HTTP_Message::~HTTP_Message()
|
|||
|
||||
IntrusivePtr<RecordVal> HTTP_Message::BuildMessageStat(bool interrupted, const char* msg)
|
||||
{
|
||||
static auto http_message_stat = zeek::id::find_type<RecordType>("http_message_stat");
|
||||
static auto http_message_stat = zeek::id::find_type<zeek::RecordType>("http_message_stat");
|
||||
auto stat = make_intrusive<RecordVal>(http_message_stat);
|
||||
int field = 0;
|
||||
stat->Assign(field++, make_intrusive<TimeVal>(start_time));
|
||||
|
@ -1152,7 +1152,7 @@ void HTTP_Analyzer::GenStats()
|
|||
{
|
||||
if ( http_stats )
|
||||
{
|
||||
static auto http_stats_rec = zeek::id::find_type<RecordType>("http_stats_rec");
|
||||
static auto http_stats_rec = zeek::id::find_type<zeek::RecordType>("http_stats_rec");
|
||||
auto r = make_intrusive<RecordVal>(http_stats_rec);
|
||||
r->Assign(0, val_mgr->Count(num_requests));
|
||||
r->Assign(1, val_mgr->Count(num_replies));
|
||||
|
|
|
@ -225,7 +225,7 @@ ICMP_Analyzer::BuildICMPVal(const struct icmp* icmpp, int len,
|
|||
{
|
||||
if ( ! icmp_conn_val )
|
||||
{
|
||||
static auto icmp_conn = zeek::id::find_type<RecordType>("icmp_conn");
|
||||
static auto icmp_conn = zeek::id::find_type<zeek::RecordType>("icmp_conn");
|
||||
icmp_conn_val = make_intrusive<RecordVal>(icmp_conn);
|
||||
|
||||
icmp_conn_val->Assign(0, make_intrusive<AddrVal>(Conn()->OrigAddr()));
|
||||
|
@ -351,7 +351,7 @@ IntrusivePtr<RecordVal> ICMP_Analyzer::ExtractICMP4Context(int len, const u_char
|
|||
}
|
||||
}
|
||||
|
||||
static auto icmp_context = zeek::id::find_type<RecordType>("icmp_context");
|
||||
static auto icmp_context = zeek::id::find_type<zeek::RecordType>("icmp_context");
|
||||
auto iprec = make_intrusive<RecordVal>(icmp_context);
|
||||
auto id_val = make_intrusive<RecordVal>(zeek::id::conn_id);
|
||||
|
||||
|
@ -411,7 +411,7 @@ IntrusivePtr<RecordVal> ICMP_Analyzer::ExtractICMP6Context(int len, const u_char
|
|||
}
|
||||
}
|
||||
|
||||
static auto icmp_context = zeek::id::find_type<RecordType>("icmp_context");
|
||||
static auto icmp_context = zeek::id::find_type<zeek::RecordType>("icmp_context");
|
||||
auto iprec = make_intrusive<RecordVal>(icmp_context);
|
||||
auto id_val = make_intrusive<RecordVal>(zeek::id::conn_id);
|
||||
|
||||
|
@ -724,11 +724,11 @@ void ICMP_Analyzer::Context6(double t, const struct icmp* icmpp,
|
|||
|
||||
IntrusivePtr<VectorVal> ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data)
|
||||
{
|
||||
static auto icmp6_nd_option_type = zeek::id::find_type<RecordType>("icmp6_nd_option");
|
||||
static auto icmp6_nd_prefix_info_type = zeek::id::find_type<RecordType>("icmp6_nd_prefix_info");
|
||||
static auto icmp6_nd_option_type = zeek::id::find_type<zeek::RecordType>("icmp6_nd_option");
|
||||
static auto icmp6_nd_prefix_info_type = zeek::id::find_type<zeek::RecordType>("icmp6_nd_prefix_info");
|
||||
|
||||
auto vv = make_intrusive<VectorVal>(
|
||||
zeek::id::find_type<VectorType>("icmp6_nd_options"));
|
||||
zeek::id::find_type<zeek::VectorType>("icmp6_nd_options"));
|
||||
|
||||
while ( caplen > 0 )
|
||||
{
|
||||
|
|
|
@ -44,8 +44,8 @@ inline void IRC_Analyzer::SkipLeadingWhitespace(string& str)
|
|||
|
||||
void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||
{
|
||||
static auto irc_join_list = zeek::id::find_type<TableType>("irc_join_list");
|
||||
static auto irc_join_info = zeek::id::find_type<RecordType>("irc_join_info");
|
||||
static auto irc_join_list = zeek::id::find_type<zeek::TableType>("irc_join_list");
|
||||
static auto irc_join_info = zeek::id::find_type<zeek::RecordType>("irc_join_info");
|
||||
tcp::TCP_ApplicationAnalyzer::DeliverStream(length, line, orig);
|
||||
|
||||
if ( starttls )
|
||||
|
|
|
@ -31,8 +31,8 @@ IntrusivePtr<RecordVal> proc_krb_kdc_req_arguments(KRB_KDC_REQ* msg, const BroAn
|
|||
{
|
||||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::KRB::KDC_Request);
|
||||
|
||||
rv->Assign(0, asn1_integer_to_val(msg->pvno()->data(), TYPE_COUNT));
|
||||
rv->Assign(1, asn1_integer_to_val(msg->msg_type()->data(), TYPE_COUNT));
|
||||
rv->Assign(0, asn1_integer_to_val(msg->pvno()->data(), zeek::TYPE_COUNT));
|
||||
rv->Assign(1, asn1_integer_to_val(msg->msg_type()->data(), zeek::TYPE_COUNT));
|
||||
|
||||
if ( msg->padata()->has_padata() )
|
||||
rv->Assign(2, proc_padata(msg->padata()->padata()->padata(), bro_analyzer, false));
|
||||
|
@ -64,7 +64,7 @@ IntrusivePtr<RecordVal> proc_krb_kdc_req_arguments(KRB_KDC_REQ* msg, const BroAn
|
|||
rv->Assign(9, GetTimeFromAsn1(element->data()->rtime(), 0));
|
||||
break;
|
||||
case 7:
|
||||
rv->Assign(10, asn1_integer_to_val(element->data()->nonce(), TYPE_COUNT));
|
||||
rv->Assign(10, asn1_integer_to_val(element->data()->nonce(), zeek::TYPE_COUNT));
|
||||
break;
|
||||
case 8:
|
||||
if ( element->data()->etype()->data()->size() )
|
||||
|
@ -132,10 +132,10 @@ bool proc_error_arguments(RecordVal* rv, const std::vector<KRB_ERROR_Arg*>* args
|
|||
switch ( (*args)[i]->seq_meta()->index() )
|
||||
{
|
||||
case 0:
|
||||
rv->Assign(0, asn1_integer_to_val((*args)[i]->args()->pvno(), TYPE_COUNT));
|
||||
rv->Assign(0, asn1_integer_to_val((*args)[i]->args()->pvno(), zeek::TYPE_COUNT));
|
||||
break;
|
||||
case 1:
|
||||
rv->Assign(1, asn1_integer_to_val((*args)[i]->args()->msg_type(), TYPE_COUNT));
|
||||
rv->Assign(1, asn1_integer_to_val((*args)[i]->args()->msg_type(), zeek::TYPE_COUNT));
|
||||
break;
|
||||
// ctime/stime handled above
|
||||
case 7:
|
||||
|
@ -205,8 +205,8 @@ refine connection KRB_Conn += {
|
|||
{
|
||||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::KRB::KDC_Response);
|
||||
|
||||
rv->Assign(0, asn1_integer_to_val(${msg.pvno.data}, TYPE_COUNT));
|
||||
rv->Assign(1, asn1_integer_to_val(${msg.msg_type.data}, TYPE_COUNT));
|
||||
rv->Assign(0, asn1_integer_to_val(${msg.pvno.data}, zeek::TYPE_COUNT));
|
||||
rv->Assign(1, asn1_integer_to_val(${msg.msg_type.data}, zeek::TYPE_COUNT));
|
||||
|
||||
if ( ${msg.padata.has_padata} )
|
||||
rv->Assign(2, proc_padata(${msg.padata.padata.padata}, bro_analyzer(), false));
|
||||
|
@ -246,7 +246,7 @@ refine connection KRB_Conn += {
|
|||
{
|
||||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::KRB::Error_Msg);
|
||||
proc_error_arguments(rv.get(), ${msg.args1}, 0);
|
||||
rv->Assign(4, asn1_integer_to_val(${msg.error_code}, TYPE_COUNT));
|
||||
rv->Assign(4, asn1_integer_to_val(${msg.error_code}, zeek::TYPE_COUNT));
|
||||
proc_error_arguments(rv.get(), ${msg.args2}, binary_to_int64(${msg.error_code.encoding.content}));
|
||||
zeek::BifEvent::enqueue_krb_error(bro_analyzer(), bro_analyzer()->Conn(), std::move(rv));
|
||||
}
|
||||
|
@ -291,8 +291,8 @@ refine connection KRB_Conn += {
|
|||
{
|
||||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::KRB::SAFE_Msg);
|
||||
|
||||
rv->Assign(0, asn1_integer_to_val(${msg.pvno.data}, TYPE_COUNT));
|
||||
rv->Assign(1, asn1_integer_to_val(${msg.msg_type.data}, TYPE_COUNT));
|
||||
rv->Assign(0, asn1_integer_to_val(${msg.pvno.data}, zeek::TYPE_COUNT));
|
||||
rv->Assign(1, asn1_integer_to_val(${msg.msg_type.data}, zeek::TYPE_COUNT));
|
||||
|
||||
uint timestamp_i = 0;
|
||||
int64 timestamp_usecs = 0;
|
||||
|
@ -325,7 +325,7 @@ refine connection KRB_Conn += {
|
|||
rv->Assign(3, to_stringval(${msg.safe_body.args[i].args.user_data.encoding.content}));
|
||||
break;
|
||||
case 3:
|
||||
rv->Assign(5, asn1_integer_to_val(${msg.safe_body.args[i].args.seq_number}, TYPE_COUNT));
|
||||
rv->Assign(5, asn1_integer_to_val(${msg.safe_body.args[i].args.seq_number}, zeek::TYPE_COUNT));
|
||||
break;
|
||||
case 4:
|
||||
rv->Assign(6, proc_host_address(bro_analyzer(), ${msg.safe_body.args[i].args.sender_addr}));
|
||||
|
|
|
@ -13,7 +13,7 @@ IntrusivePtr<VectorVal> proc_padata(const KRB_PA_Data_Sequence* data, const BroA
|
|||
%code{
|
||||
IntrusivePtr<VectorVal> proc_padata(const KRB_PA_Data_Sequence* data, const BroAnalyzer bro_analyzer, bool is_error)
|
||||
{
|
||||
auto vv = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("KRB::Type_Value_Vector"));
|
||||
auto vv = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("KRB::Type_Value_Vector"));
|
||||
|
||||
if ( ! data->data()->has_padata() )
|
||||
return vv;
|
||||
|
|
|
@ -29,13 +29,13 @@ IntrusivePtr<VectorVal> proc_cipher_list(const Array* list)
|
|||
{
|
||||
auto ciphers = make_intrusive<VectorVal>(zeek::id::index_vec);
|
||||
for ( uint i = 0; i < list->data()->size(); ++i )
|
||||
ciphers->Assign(ciphers->Size(), asn1_integer_to_val((*list->data())[i], TYPE_COUNT));
|
||||
ciphers->Assign(ciphers->Size(), asn1_integer_to_val((*list->data())[i], zeek::TYPE_COUNT));
|
||||
return ciphers;
|
||||
}
|
||||
|
||||
IntrusivePtr<VectorVal> proc_host_address_list(const BroAnalyzer a, const KRB_Host_Addresses* list)
|
||||
{
|
||||
auto addrs = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("KRB::Host_Address_Vector"));
|
||||
auto addrs = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("KRB::Host_Address_Vector"));
|
||||
|
||||
for ( uint i = 0; i < list->addresses()->size(); ++i )
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ IntrusivePtr<RecordVal> proc_host_address(const BroAnalyzer a, const KRB_Host_Ad
|
|||
}
|
||||
|
||||
auto unk = make_intrusive<RecordVal>(zeek::BifType::Record::KRB::Type_Value);
|
||||
unk->Assign(0, asn1_integer_to_val(addr->addr_type(), TYPE_COUNT));
|
||||
unk->Assign(0, asn1_integer_to_val(addr->addr_type(), zeek::TYPE_COUNT));
|
||||
unk->Assign(1, to_stringval(addr_bytes));
|
||||
rv->Assign(2, std::move(unk));
|
||||
return rv;
|
||||
|
@ -94,7 +94,7 @@ IntrusivePtr<RecordVal> proc_host_address(const BroAnalyzer a, const KRB_Host_Ad
|
|||
|
||||
IntrusivePtr<VectorVal> proc_tickets(const KRB_Ticket_Sequence* list)
|
||||
{
|
||||
auto tickets = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("KRB::Ticket_Vector"));
|
||||
auto tickets = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("KRB::Ticket_Vector"));
|
||||
|
||||
for ( uint i = 0; i < list->tickets()->size(); ++i )
|
||||
{
|
||||
|
@ -109,10 +109,10 @@ IntrusivePtr<RecordVal> proc_ticket(const KRB_Ticket* ticket)
|
|||
{
|
||||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::KRB::Ticket);
|
||||
|
||||
rv->Assign(0, asn1_integer_to_val(ticket->tkt_vno()->data(), TYPE_COUNT));
|
||||
rv->Assign(0, asn1_integer_to_val(ticket->tkt_vno()->data(), zeek::TYPE_COUNT));
|
||||
rv->Assign(1, to_stringval(ticket->realm()->data()->content()));
|
||||
rv->Assign(2, GetStringFromPrincipalName(ticket->sname()));
|
||||
rv->Assign(3, asn1_integer_to_val(ticket->enc_part()->data()->etype()->data(), TYPE_COUNT));
|
||||
rv->Assign(3, asn1_integer_to_val(ticket->enc_part()->data()->etype()->data(), zeek::TYPE_COUNT));
|
||||
rv->Assign(4, to_stringval(ticket->enc_part()->data()->ciphertext()->encoding()->content()));
|
||||
|
||||
return rv;
|
||||
|
@ -189,4 +189,3 @@ type KRB_Checksum = record {
|
|||
checksum_type: SequenceElement(true);
|
||||
checksum : SequenceElement(true);
|
||||
};
|
||||
|
||||
|
|
|
@ -1301,7 +1301,7 @@ RecordVal* MIME_Message::BuildHeaderVal(MIME_Header* h)
|
|||
|
||||
IntrusivePtr<RecordVal> MIME_Message::ToHeaderVal(MIME_Header* h)
|
||||
{
|
||||
static auto mime_header_rec = zeek::id::find_type<RecordType>("mime_header_rec");
|
||||
static auto mime_header_rec = zeek::id::find_type<zeek::RecordType>("mime_header_rec");
|
||||
auto header_record = make_intrusive<RecordVal>(mime_header_rec);
|
||||
header_record->Assign(0, to_string_val(h->get_name()));
|
||||
auto upper_hn = to_string_val(h->get_name());
|
||||
|
@ -1316,7 +1316,7 @@ TableVal* MIME_Message::BuildHeaderTable(MIME_HeaderList& hlist)
|
|||
|
||||
IntrusivePtr<TableVal> MIME_Message::ToHeaderTable(MIME_HeaderList& hlist)
|
||||
{
|
||||
static auto mime_header_list = zeek::id::find_type<TableType>("mime_header_list");
|
||||
static auto mime_header_list = zeek::id::find_type<zeek::TableType>("mime_header_list");
|
||||
auto t = make_intrusive<TableVal>(mime_header_list);
|
||||
|
||||
for ( unsigned int i = 0; i < hlist.size(); ++i )
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
IntrusivePtr<VectorVal> create_vector_of_count()
|
||||
{
|
||||
auto vt = make_intrusive<VectorType>(base_type(TYPE_COUNT));
|
||||
auto vt = make_intrusive<zeek::VectorType>(zeek::base_type(zeek::TYPE_COUNT));
|
||||
auto vv = make_intrusive<VectorVal>(std::move(vt));
|
||||
return vv;
|
||||
}
|
||||
|
|
|
@ -201,4 +201,3 @@ refine typeattr NTLM_Challenge += &let {
|
|||
refine typeattr NTLM_Authenticate += &let {
|
||||
proc : bool = $context.connection.proc_ntlm_authenticate(this);
|
||||
};
|
||||
|
||||
|
|
|
@ -160,4 +160,3 @@ refine flow NTP_Flow += {
|
|||
refine typeattr NTP_PDU += &let {
|
||||
proc: bool = $context.flow.proc_ntp_message(this);
|
||||
};
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ IntrusivePtr<RecordVal> MOUNT_Interp::mount3_mnt_reply(const u_char*& buf, int&
|
|||
auth_flavors_count = max_auth_flavors;
|
||||
}
|
||||
|
||||
auto enum_vector = make_intrusive<VectorType>(base_type(TYPE_ENUM));
|
||||
auto enum_vector = make_intrusive<zeek::VectorType>(zeek::base_type(zeek::TYPE_ENUM));
|
||||
auto auth_flavors = make_intrusive<VectorVal>(std::move(enum_vector));
|
||||
|
||||
for ( auto i = 0u; i < auth_flavors_count; ++i )
|
||||
|
|
|
@ -138,7 +138,7 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
|
|||
event = success ? pm_request_dump : pm_attempt_dump;
|
||||
if ( success )
|
||||
{
|
||||
static auto pm_mappings = zeek::id::find_type<TableType>("pm_mappings");
|
||||
static auto pm_mappings = zeek::id::find_type<zeek::TableType>("pm_mappings");
|
||||
auto mappings = make_intrusive<TableVal>(pm_mappings);
|
||||
uint32_t nmap = 0;
|
||||
|
||||
|
@ -191,7 +191,7 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
|
|||
|
||||
IntrusivePtr<Val> PortmapperInterp::ExtractMapping(const u_char*& buf, int& len)
|
||||
{
|
||||
static auto pm_mapping = zeek::id::find_type<RecordType>("pm_mapping");
|
||||
static auto pm_mapping = zeek::id::find_type<zeek::RecordType>("pm_mapping");
|
||||
auto mapping = make_intrusive<RecordVal>(pm_mapping);
|
||||
|
||||
mapping->Assign(0, val_mgr->Count(extract_XDR_uint32(buf, len)));
|
||||
|
@ -209,7 +209,7 @@ IntrusivePtr<Val> PortmapperInterp::ExtractMapping(const u_char*& buf, int& len)
|
|||
|
||||
IntrusivePtr<Val> PortmapperInterp::ExtractPortRequest(const u_char*& buf, int& len)
|
||||
{
|
||||
static auto pm_port_request = zeek::id::find_type<RecordType>("pm_port_request");
|
||||
static auto pm_port_request = zeek::id::find_type<zeek::RecordType>("pm_port_request");
|
||||
auto pr = make_intrusive<RecordVal>(pm_port_request);
|
||||
|
||||
pr->Assign(0, val_mgr->Count(extract_XDR_uint32(buf, len)));
|
||||
|
@ -227,7 +227,7 @@ IntrusivePtr<Val> PortmapperInterp::ExtractPortRequest(const u_char*& buf, int&
|
|||
|
||||
IntrusivePtr<Val> PortmapperInterp::ExtractCallItRequest(const u_char*& buf, int& len)
|
||||
{
|
||||
static auto pm_callit_request = zeek::id::find_type<RecordType>("pm_callit_request");
|
||||
static auto pm_callit_request = zeek::id::find_type<zeek::RecordType>("pm_callit_request");
|
||||
auto c = make_intrusive<RecordVal>(pm_callit_request);
|
||||
|
||||
c->Assign(0, val_mgr->Count(extract_XDR_uint32(buf, len)));
|
||||
|
|
|
@ -67,7 +67,7 @@ refine flow SIP_Flow += {
|
|||
|
||||
function build_sip_headers_val(): BroVal
|
||||
%{
|
||||
static auto mime_header_list = zeek::id::find_type<TableType>("mime_header_list");
|
||||
static auto mime_header_list = zeek::id::find_type<zeek::TableType>("mime_header_list");
|
||||
TableVal* t = new TableVal(mime_header_list);
|
||||
|
||||
for ( unsigned int i = 0; i < headers.size(); ++i )
|
||||
|
@ -102,7 +102,7 @@ refine flow SIP_Flow += {
|
|||
|
||||
function build_sip_header_val(name: const_bytestring, value: const_bytestring): BroVal
|
||||
%{
|
||||
static auto mime_header_rec = zeek::id::find_type<RecordType>("mime_header_rec");
|
||||
static auto mime_header_rec = zeek::id::find_type<zeek::RecordType>("mime_header_rec");
|
||||
RecordVal* header_record = new RecordVal(mime_header_rec);
|
||||
IntrusivePtr<StringVal> name_val;
|
||||
|
||||
|
|
|
@ -61,14 +61,14 @@ IntrusivePtr<Val> asn1_obj_to_val(const ASN1Encoding* obj)
|
|||
break;
|
||||
|
||||
case ASN1_INTEGER_TAG:
|
||||
rval->Assign(2, asn1_integer_to_val(obj, TYPE_INT));
|
||||
rval->Assign(2, asn1_integer_to_val(obj, zeek::TYPE_INT));
|
||||
break;
|
||||
|
||||
case APP_COUNTER32_TAG:
|
||||
case APP_UNSIGNED32_TAG:
|
||||
case APP_TIMETICKS_TAG:
|
||||
case APP_COUNTER64_TAG:
|
||||
rval->Assign(3, asn1_integer_to_val(obj, TYPE_COUNT));
|
||||
rval->Assign(3, asn1_integer_to_val(obj, zeek::TYPE_COUNT));
|
||||
break;
|
||||
|
||||
case APP_IPADDRESS_TAG:
|
||||
|
@ -87,7 +87,7 @@ IntrusivePtr<Val> asn1_obj_to_val(const ASN1Encoding* obj)
|
|||
|
||||
IntrusivePtr<Val> time_ticks_to_val(const TimeTicks* tt)
|
||||
{
|
||||
return asn1_integer_to_val(tt->asn1_integer(), TYPE_COUNT);
|
||||
return asn1_integer_to_val(tt->asn1_integer(), zeek::TYPE_COUNT);
|
||||
}
|
||||
|
||||
IntrusivePtr<RecordVal> build_hdr(const Header* header)
|
||||
|
@ -130,13 +130,13 @@ IntrusivePtr<RecordVal> build_hdrV3(const Header* header)
|
|||
bytestring const& flags = global_data->flags()->encoding()->content();
|
||||
uint8 flags_byte = flags.length() > 0 ? flags[0] : 0;
|
||||
|
||||
v3->Assign(0, asn1_integer_to_val(global_data->id(), TYPE_COUNT));
|
||||
v3->Assign(1, asn1_integer_to_val(global_data->max_size(), TYPE_COUNT));
|
||||
v3->Assign(0, asn1_integer_to_val(global_data->id(), zeek::TYPE_COUNT));
|
||||
v3->Assign(1, asn1_integer_to_val(global_data->max_size(), zeek::TYPE_COUNT));
|
||||
v3->Assign(2, val_mgr->Count(flags_byte));
|
||||
v3->Assign(3, val_mgr->Bool(flags_byte & 0x01));
|
||||
v3->Assign(4, val_mgr->Bool(flags_byte & 0x02));
|
||||
v3->Assign(5, val_mgr->Bool(flags_byte & 0x04));
|
||||
v3->Assign(6, asn1_integer_to_val(global_data->security_model(), TYPE_COUNT));
|
||||
v3->Assign(6, asn1_integer_to_val(global_data->security_model(), zeek::TYPE_COUNT));
|
||||
v3->Assign(7, asn1_octet_string_to_val(v3hdr->security_parameters()));
|
||||
|
||||
if ( v3hdr->next()->tag() == ASN1_SEQUENCE_TAG )
|
||||
|
@ -170,9 +170,9 @@ IntrusivePtr<VectorVal> build_bindings(const VarBindList* vbl)
|
|||
IntrusivePtr<RecordVal> build_pdu(const CommonPDU* pdu)
|
||||
{
|
||||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::SNMP::PDU);
|
||||
rv->Assign(0, asn1_integer_to_val(pdu->request_id(), TYPE_INT));
|
||||
rv->Assign(1, asn1_integer_to_val(pdu->error_status(), TYPE_INT));
|
||||
rv->Assign(2, asn1_integer_to_val(pdu->error_index(), TYPE_INT));
|
||||
rv->Assign(0, asn1_integer_to_val(pdu->request_id(), zeek::TYPE_INT));
|
||||
rv->Assign(1, asn1_integer_to_val(pdu->error_status(), zeek::TYPE_INT));
|
||||
rv->Assign(2, asn1_integer_to_val(pdu->error_index(), zeek::TYPE_INT));
|
||||
rv->Assign(3, build_bindings(pdu->var_bindings()));
|
||||
return rv;
|
||||
}
|
||||
|
@ -182,8 +182,8 @@ IntrusivePtr<RecordVal> build_trap_pdu(const TrapPDU* pdu)
|
|||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::SNMP::TrapPDU);
|
||||
rv->Assign(0, asn1_oid_to_val(pdu->enterprise()));
|
||||
rv->Assign(1, network_address_to_val(pdu->agent_addr()));
|
||||
rv->Assign(2, asn1_integer_to_val(pdu->generic_trap(), TYPE_INT));
|
||||
rv->Assign(3, asn1_integer_to_val(pdu->specific_trap(), TYPE_INT));
|
||||
rv->Assign(2, asn1_integer_to_val(pdu->generic_trap(), zeek::TYPE_INT));
|
||||
rv->Assign(3, asn1_integer_to_val(pdu->specific_trap(), zeek::TYPE_INT));
|
||||
rv->Assign(4, time_ticks_to_val(pdu->time_stamp()));
|
||||
rv->Assign(5, build_bindings(pdu->var_bindings()));
|
||||
return rv;
|
||||
|
@ -192,9 +192,9 @@ IntrusivePtr<RecordVal> build_trap_pdu(const TrapPDU* pdu)
|
|||
IntrusivePtr<RecordVal> build_bulk_pdu(const GetBulkRequestPDU* pdu)
|
||||
{
|
||||
auto rv = make_intrusive<RecordVal>(zeek::BifType::Record::SNMP::BulkPDU);
|
||||
rv->Assign(0, asn1_integer_to_val(pdu->request_id(), TYPE_INT));
|
||||
rv->Assign(1, asn1_integer_to_val(pdu->non_repeaters(), TYPE_COUNT));
|
||||
rv->Assign(2, asn1_integer_to_val(pdu->max_repititions(), TYPE_COUNT));
|
||||
rv->Assign(0, asn1_integer_to_val(pdu->request_id(), zeek::TYPE_INT));
|
||||
rv->Assign(1, asn1_integer_to_val(pdu->non_repeaters(), zeek::TYPE_COUNT));
|
||||
rv->Assign(2, asn1_integer_to_val(pdu->max_repititions(), zeek::TYPE_COUNT));
|
||||
rv->Assign(3, build_bindings(pdu->var_bindings()));
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ refine connection SOCKS_Conn += {
|
|||
%{
|
||||
if ( socks_request )
|
||||
{
|
||||
static auto socks_address = zeek::id::find_type<RecordType>("SOCKS::Address");
|
||||
static auto socks_address = zeek::id::find_type<zeek::RecordType>("SOCKS::Address");
|
||||
auto sa = make_intrusive<RecordVal>(socks_address);
|
||||
sa->Assign(0, make_intrusive<AddrVal>(htonl(${request.addr})));
|
||||
|
||||
|
@ -49,7 +49,7 @@ refine connection SOCKS_Conn += {
|
|||
%{
|
||||
if ( socks_reply )
|
||||
{
|
||||
static auto socks_address = zeek::id::find_type<RecordType>("SOCKS::Address");
|
||||
static auto socks_address = zeek::id::find_type<zeek::RecordType>("SOCKS::Address");
|
||||
auto sa = make_intrusive<RecordVal>(socks_address);
|
||||
sa->Assign(0, make_intrusive<AddrVal>(htonl(${reply.addr})));
|
||||
|
||||
|
@ -82,7 +82,7 @@ refine connection SOCKS_Conn += {
|
|||
return false;
|
||||
}
|
||||
|
||||
static auto socks_address = zeek::id::find_type<RecordType>("SOCKS::Address");
|
||||
static auto socks_address = zeek::id::find_type<zeek::RecordType>("SOCKS::Address");
|
||||
auto sa = make_intrusive<RecordVal>(socks_address);
|
||||
|
||||
// This is dumb and there must be a better way (checking for presence of a field)...
|
||||
|
@ -122,7 +122,7 @@ refine connection SOCKS_Conn += {
|
|||
|
||||
function socks5_reply(reply: SOCKS5_Reply): bool
|
||||
%{
|
||||
static auto socks_address = zeek::id::find_type<RecordType>("SOCKS::Address");
|
||||
static auto socks_address = zeek::id::find_type<zeek::RecordType>("SOCKS::Address");
|
||||
auto sa = make_intrusive<RecordVal>(socks_address);
|
||||
|
||||
// This is dumb and there must be a better way (checking for presence of a field)...
|
||||
|
|
|
@ -155,7 +155,7 @@ refine connection Handshake_Conn += {
|
|||
if ( ! ssl_extension_signature_algorithm )
|
||||
return true;
|
||||
|
||||
auto slist = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("signature_and_hashalgorithm_vec"));
|
||||
auto slist = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("signature_and_hashalgorithm_vec"));
|
||||
|
||||
if ( supported_signature_algorithms )
|
||||
{
|
||||
|
@ -492,7 +492,7 @@ refine connection Handshake_Conn += {
|
|||
if ( ! ssl_extension_pre_shared_key_server_hello )
|
||||
return true;
|
||||
|
||||
auto slist = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("psk_identity_vec"));
|
||||
auto slist = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("psk_identity_vec"));
|
||||
|
||||
if ( identities && identities->identities() )
|
||||
{
|
||||
|
|
|
@ -107,7 +107,7 @@ static RecordVal* build_syn_packet_val(bool is_orig, const IP_Hdr* ip,
|
|||
options += opt_len;
|
||||
}
|
||||
|
||||
static auto SYN_packet = zeek::id::find_type<RecordType>("SYN_packet");
|
||||
static auto SYN_packet = zeek::id::find_type<zeek::RecordType>("SYN_packet");
|
||||
RecordVal* v = new RecordVal(SYN_packet);
|
||||
|
||||
v->Assign(0, val_mgr->Bool(is_orig));
|
||||
|
@ -2078,7 +2078,7 @@ bool TCPStats_Endpoint::DataSent(double /* t */, uint64_t seq, int len, int capl
|
|||
|
||||
RecordVal* TCPStats_Endpoint::BuildStats()
|
||||
{
|
||||
static auto endpoint_stats = zeek::id::find_type<RecordType>("endpoint_stats");
|
||||
static auto endpoint_stats = zeek::id::find_type<zeek::RecordType>("endpoint_stats");
|
||||
RecordVal* stats = new RecordVal(endpoint_stats);
|
||||
|
||||
stats->Assign(0, val_mgr->Count(num_pkts));
|
||||
|
|
|
@ -98,9 +98,9 @@ bool TeredoEncapsulation::DoParse(const u_char* data, int& len,
|
|||
|
||||
IntrusivePtr<RecordVal> TeredoEncapsulation::BuildVal(const IP_Hdr* inner) const
|
||||
{
|
||||
static auto teredo_hdr_type = zeek::id::find_type<RecordType>("teredo_hdr");
|
||||
static auto teredo_auth_type = zeek::id::find_type<RecordType>("teredo_auth");
|
||||
static auto teredo_origin_type = zeek::id::find_type<RecordType>("teredo_origin");
|
||||
static auto teredo_hdr_type = zeek::id::find_type<zeek::RecordType>("teredo_hdr");
|
||||
static auto teredo_auth_type = zeek::id::find_type<zeek::RecordType>("teredo_auth");
|
||||
static auto teredo_origin_type = zeek::id::find_type<zeek::RecordType>("teredo_origin");
|
||||
|
||||
auto teredo_hdr = make_intrusive<RecordVal>(teredo_hdr_type);
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
IntrusivePtr<OpaqueType> bro_broker::opaque_of_data_type;
|
||||
IntrusivePtr<OpaqueType> bro_broker::opaque_of_set_iterator;
|
||||
IntrusivePtr<OpaqueType> bro_broker::opaque_of_table_iterator;
|
||||
IntrusivePtr<OpaqueType> bro_broker::opaque_of_vector_iterator;
|
||||
IntrusivePtr<OpaqueType> bro_broker::opaque_of_record_iterator;
|
||||
IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_data_type;
|
||||
IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_set_iterator;
|
||||
IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_table_iterator;
|
||||
IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_vector_iterator;
|
||||
IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_record_iterator;
|
||||
|
||||
static bool data_type_check(const broker::data& d, BroType* t);
|
||||
static bool data_type_check(const broker::data& d, zeek::BroType* t);
|
||||
|
||||
static broker::port::protocol to_broker_port_proto(TransportProto tp)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ TEST_CASE("converting Broker to Zeek protocol constants")
|
|||
struct val_converter {
|
||||
using result_type = IntrusivePtr<Val>;
|
||||
|
||||
BroType* type;
|
||||
zeek::BroType* type;
|
||||
|
||||
result_type operator()(broker::none)
|
||||
{
|
||||
|
@ -84,30 +84,30 @@ struct val_converter {
|
|||
|
||||
result_type operator()(bool a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_BOOL )
|
||||
if ( type->Tag() == zeek::TYPE_BOOL )
|
||||
return val_mgr->Bool(a);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result_type operator()(uint64_t a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_COUNT )
|
||||
if ( type->Tag() == zeek::TYPE_COUNT )
|
||||
return val_mgr->Count(a);
|
||||
if ( type->Tag() == TYPE_COUNTER )
|
||||
if ( type->Tag() == zeek::TYPE_COUNTER )
|
||||
return val_mgr->Count(a);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result_type operator()(int64_t a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_INT )
|
||||
if ( type->Tag() == zeek::TYPE_INT )
|
||||
return val_mgr->Int(a);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result_type operator()(double a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_DOUBLE )
|
||||
if ( type->Tag() == zeek::TYPE_DOUBLE )
|
||||
return make_intrusive<DoubleVal>(a);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ struct val_converter {
|
|||
result_type operator()(std::string& a)
|
||||
{
|
||||
switch ( type->Tag() ) {
|
||||
case TYPE_STRING:
|
||||
case zeek::TYPE_STRING:
|
||||
return make_intrusive<StringVal>(a.size(), a.data());
|
||||
case TYPE_FILE:
|
||||
case zeek::TYPE_FILE:
|
||||
{
|
||||
auto file = BroFile::Get(a.data());
|
||||
|
||||
|
@ -133,7 +133,7 @@ struct val_converter {
|
|||
|
||||
result_type operator()(broker::address& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_ADDR )
|
||||
if ( type->Tag() == zeek::TYPE_ADDR )
|
||||
{
|
||||
auto bits = reinterpret_cast<const in6_addr*>(&a.bytes());
|
||||
return make_intrusive<AddrVal>(IPAddr(*bits));
|
||||
|
@ -144,7 +144,7 @@ struct val_converter {
|
|||
|
||||
result_type operator()(broker::subnet& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_SUBNET )
|
||||
if ( type->Tag() == zeek::TYPE_SUBNET )
|
||||
{
|
||||
auto bits = reinterpret_cast<const in6_addr*>(&a.network().bytes());
|
||||
return make_intrusive<SubNetVal>(IPPrefix(IPAddr(*bits), a.length()));
|
||||
|
@ -155,7 +155,7 @@ struct val_converter {
|
|||
|
||||
result_type operator()(broker::port& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_PORT )
|
||||
if ( type->Tag() == zeek::TYPE_PORT )
|
||||
return val_mgr->Port(a.number(), bro_broker::to_bro_port_proto(a.type()));
|
||||
|
||||
return nullptr;
|
||||
|
@ -163,7 +163,7 @@ struct val_converter {
|
|||
|
||||
result_type operator()(broker::timestamp& a)
|
||||
{
|
||||
if ( type->Tag() != TYPE_TIME )
|
||||
if ( type->Tag() != zeek::TYPE_TIME )
|
||||
return nullptr;
|
||||
|
||||
using namespace std::chrono;
|
||||
|
@ -173,7 +173,7 @@ struct val_converter {
|
|||
|
||||
result_type operator()(broker::timespan& a)
|
||||
{
|
||||
if ( type->Tag() != TYPE_INTERVAL )
|
||||
if ( type->Tag() != zeek::TYPE_INTERVAL )
|
||||
return nullptr;
|
||||
|
||||
using namespace std::chrono;
|
||||
|
@ -183,7 +183,7 @@ struct val_converter {
|
|||
|
||||
result_type operator()(broker::enum_value& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_ENUM )
|
||||
if ( type->Tag() == zeek::TYPE_ENUM )
|
||||
{
|
||||
auto etype = type->AsEnumType();
|
||||
auto i = etype->Lookup(GLOBAL_MODULE_NAME, a.name.data());
|
||||
|
@ -217,8 +217,8 @@ struct val_converter {
|
|||
if ( expected_index_types.size() == 1 )
|
||||
{
|
||||
auto index_is_vector_or_record =
|
||||
expected_index_types[0]->Tag() == TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == TYPE_VECTOR;
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_VECTOR;
|
||||
|
||||
if ( index_is_vector_or_record )
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ struct val_converter {
|
|||
if ( expected_index_types.size() != indices->size() )
|
||||
return nullptr;
|
||||
|
||||
auto list_val = make_intrusive<ListVal>(TYPE_ANY);
|
||||
auto list_val = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||
|
||||
for ( auto i = 0u; i < indices->size(); ++i )
|
||||
{
|
||||
|
@ -276,8 +276,8 @@ struct val_converter {
|
|||
if ( expected_index_types.size() == 1 )
|
||||
{
|
||||
auto index_is_vector_or_record =
|
||||
expected_index_types[0]->Tag() == TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == TYPE_VECTOR;
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_VECTOR;
|
||||
|
||||
if ( index_is_vector_or_record )
|
||||
{
|
||||
|
@ -296,7 +296,7 @@ struct val_converter {
|
|||
if ( expected_index_types.size() != indices->size() )
|
||||
return nullptr;
|
||||
|
||||
auto list_val = make_intrusive<ListVal>(TYPE_ANY);
|
||||
auto list_val = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||
|
||||
for ( auto i = 0u; i < indices->size(); ++i )
|
||||
{
|
||||
|
@ -323,7 +323,7 @@ struct val_converter {
|
|||
|
||||
result_type operator()(broker::vector& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_VECTOR )
|
||||
if ( type->Tag() == zeek::TYPE_VECTOR )
|
||||
{
|
||||
auto vt = type->AsVectorType();
|
||||
auto rval = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, vt});
|
||||
|
@ -340,7 +340,7 @@ struct val_converter {
|
|||
|
||||
return rval;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_FUNC )
|
||||
else if ( type->Tag() == zeek::TYPE_FUNC )
|
||||
{
|
||||
if ( a.size() < 1 || a.size() > 2 )
|
||||
return nullptr;
|
||||
|
@ -361,7 +361,7 @@ struct val_converter {
|
|||
if ( ! t )
|
||||
return nullptr;
|
||||
|
||||
if ( t->Tag() != TYPE_FUNC )
|
||||
if ( t->Tag() != zeek::TYPE_FUNC )
|
||||
return nullptr;
|
||||
|
||||
if ( a.size() == 2 ) // We have a closure.
|
||||
|
@ -380,7 +380,7 @@ struct val_converter {
|
|||
|
||||
return rval;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_RECORD )
|
||||
else if ( type->Tag() == zeek::TYPE_RECORD )
|
||||
{
|
||||
auto rt = type->AsRecordType();
|
||||
auto rval = make_intrusive<RecordVal>(IntrusivePtr{NewRef{}, rt});
|
||||
|
@ -410,7 +410,7 @@ struct val_converter {
|
|||
|
||||
return rval;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_PATTERN )
|
||||
else if ( type->Tag() == zeek::TYPE_PATTERN )
|
||||
{
|
||||
if ( a.size() != 2 )
|
||||
return nullptr;
|
||||
|
@ -435,7 +435,7 @@ struct val_converter {
|
|||
auto rval = make_intrusive<PatternVal>(re);
|
||||
return rval;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_OPAQUE )
|
||||
else if ( type->Tag() == zeek::TYPE_OPAQUE )
|
||||
return OpaqueVal::Unserialize(a);
|
||||
|
||||
return nullptr;
|
||||
|
@ -445,7 +445,7 @@ struct val_converter {
|
|||
struct type_checker {
|
||||
using result_type = bool;
|
||||
|
||||
BroType* type;
|
||||
zeek::BroType* type;
|
||||
|
||||
result_type operator()(broker::none)
|
||||
{
|
||||
|
@ -454,30 +454,30 @@ struct type_checker {
|
|||
|
||||
result_type operator()(bool a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_BOOL )
|
||||
if ( type->Tag() == zeek::TYPE_BOOL )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
result_type operator()(uint64_t a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_COUNT )
|
||||
if ( type->Tag() == zeek::TYPE_COUNT )
|
||||
return true;
|
||||
if ( type->Tag() == TYPE_COUNTER )
|
||||
if ( type->Tag() == zeek::TYPE_COUNTER )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
result_type operator()(int64_t a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_INT )
|
||||
if ( type->Tag() == zeek::TYPE_INT )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
result_type operator()(double a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_DOUBLE )
|
||||
if ( type->Tag() == zeek::TYPE_DOUBLE )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -485,9 +485,9 @@ struct type_checker {
|
|||
result_type operator()(const std::string& a)
|
||||
{
|
||||
switch ( type->Tag() ) {
|
||||
case TYPE_STRING:
|
||||
case zeek::TYPE_STRING:
|
||||
return true;
|
||||
case TYPE_FILE:
|
||||
case zeek::TYPE_FILE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -496,7 +496,7 @@ struct type_checker {
|
|||
|
||||
result_type operator()(const broker::address& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_ADDR )
|
||||
if ( type->Tag() == zeek::TYPE_ADDR )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -504,7 +504,7 @@ struct type_checker {
|
|||
|
||||
result_type operator()(const broker::subnet& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_SUBNET )
|
||||
if ( type->Tag() == zeek::TYPE_SUBNET )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -512,7 +512,7 @@ struct type_checker {
|
|||
|
||||
result_type operator()(const broker::port& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_PORT )
|
||||
if ( type->Tag() == zeek::TYPE_PORT )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -520,7 +520,7 @@ struct type_checker {
|
|||
|
||||
result_type operator()(const broker::timestamp& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_TIME )
|
||||
if ( type->Tag() == zeek::TYPE_TIME )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -528,7 +528,7 @@ struct type_checker {
|
|||
|
||||
result_type operator()(const broker::timespan& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_INTERVAL )
|
||||
if ( type->Tag() == zeek::TYPE_INTERVAL )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -536,7 +536,7 @@ struct type_checker {
|
|||
|
||||
result_type operator()(const broker::enum_value& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_ENUM )
|
||||
if ( type->Tag() == zeek::TYPE_ENUM )
|
||||
{
|
||||
auto etype = type->AsEnumType();
|
||||
auto i = etype->Lookup(GLOBAL_MODULE_NAME, a.name.data());
|
||||
|
@ -564,8 +564,8 @@ struct type_checker {
|
|||
if ( expected_index_types.size() == 1 )
|
||||
{
|
||||
auto index_is_vector_or_record =
|
||||
expected_index_types[0]->Tag() == TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == TYPE_VECTOR;
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_VECTOR;
|
||||
|
||||
if ( index_is_vector_or_record )
|
||||
// Disambiguate from composite key w/ multiple vals.
|
||||
|
@ -623,8 +623,8 @@ struct type_checker {
|
|||
if ( expected_index_types.size() == 1 )
|
||||
{
|
||||
auto index_is_vector_or_record =
|
||||
expected_index_types[0]->Tag() == TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == TYPE_VECTOR;
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_RECORD ||
|
||||
expected_index_types[0]->Tag() == zeek::TYPE_VECTOR;
|
||||
|
||||
if ( index_is_vector_or_record )
|
||||
// Disambiguate from composite key w/ multiple vals.
|
||||
|
@ -672,7 +672,7 @@ struct type_checker {
|
|||
|
||||
result_type operator()(const broker::vector& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_VECTOR )
|
||||
if ( type->Tag() == zeek::TYPE_VECTOR )
|
||||
{
|
||||
auto vt = type->AsVectorType();
|
||||
|
||||
|
@ -684,7 +684,7 @@ struct type_checker {
|
|||
|
||||
return true;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_FUNC )
|
||||
else if ( type->Tag() == zeek::TYPE_FUNC )
|
||||
{
|
||||
if ( a.size() < 1 || a.size() > 2 )
|
||||
return false;
|
||||
|
@ -705,12 +705,12 @@ struct type_checker {
|
|||
if ( ! t )
|
||||
return false;
|
||||
|
||||
if ( t->Tag() != TYPE_FUNC )
|
||||
if ( t->Tag() != zeek::TYPE_FUNC )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_RECORD )
|
||||
else if ( type->Tag() == zeek::TYPE_RECORD )
|
||||
{
|
||||
auto rt = type->AsRecordType();
|
||||
auto idx = 0u;
|
||||
|
@ -734,7 +734,7 @@ struct type_checker {
|
|||
|
||||
return true;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_PATTERN )
|
||||
else if ( type->Tag() == zeek::TYPE_PATTERN )
|
||||
{
|
||||
if ( a.size() != 2 )
|
||||
return false;
|
||||
|
@ -759,7 +759,7 @@ struct type_checker {
|
|||
|
||||
return true;
|
||||
}
|
||||
else if ( type->Tag() == TYPE_OPAQUE )
|
||||
else if ( type->Tag() == zeek::TYPE_OPAQUE )
|
||||
{
|
||||
// TODO: Could avoid doing the full unserialization here
|
||||
// and just check if the type is a correct match.
|
||||
|
@ -771,17 +771,17 @@ struct type_checker {
|
|||
}
|
||||
};
|
||||
|
||||
static bool data_type_check(const broker::data& d, BroType* t)
|
||||
static bool data_type_check(const broker::data& d, zeek::BroType* t)
|
||||
{
|
||||
if ( t->Tag() == TYPE_ANY )
|
||||
if ( t->Tag() == zeek::TYPE_ANY )
|
||||
return true;
|
||||
|
||||
return caf::visit(type_checker{t}, d);
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> bro_broker::data_to_val(broker::data d, BroType* type)
|
||||
IntrusivePtr<Val> bro_broker::data_to_val(broker::data d, zeek::BroType* type)
|
||||
{
|
||||
if ( type->Tag() == TYPE_ANY )
|
||||
if ( type->Tag() == zeek::TYPE_ANY )
|
||||
return bro_broker::make_data_val(move(d));
|
||||
|
||||
return caf::visit(val_converter{type}, std::move(d));
|
||||
|
@ -790,20 +790,20 @@ IntrusivePtr<Val> bro_broker::data_to_val(broker::data d, BroType* type)
|
|||
broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
||||
{
|
||||
switch ( v->GetType()->Tag() ) {
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
return {v->AsBool()};
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_INT:
|
||||
return {v->AsInt()};
|
||||
case TYPE_COUNT:
|
||||
case zeek::TYPE_COUNT:
|
||||
return {v->AsCount()};
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNTER:
|
||||
return {v->AsCounter()};
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
{
|
||||
auto p = v->AsPortVal();
|
||||
return {broker::port(p->Port(), to_broker_port_proto(p->PortType()))};
|
||||
}
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
{
|
||||
auto a = v->AsAddr();
|
||||
in6_addr tmp;
|
||||
|
@ -813,7 +813,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
broker::address::byte_order::network)};
|
||||
}
|
||||
break;
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
auto s = v->AsSubNet();
|
||||
in6_addr tmp;
|
||||
|
@ -824,33 +824,33 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
return {broker::subnet(std::move(a), s.Length())};
|
||||
}
|
||||
break;
|
||||
case TYPE_DOUBLE:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
return {v->AsDouble()};
|
||||
case TYPE_TIME:
|
||||
case zeek::TYPE_TIME:
|
||||
{
|
||||
auto secs = broker::fractional_seconds{v->AsTime()};
|
||||
auto since_epoch = std::chrono::duration_cast<broker::timespan>(secs);
|
||||
return {broker::timestamp{since_epoch}};
|
||||
}
|
||||
case TYPE_INTERVAL:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
{
|
||||
auto secs = broker::fractional_seconds{v->AsInterval()};
|
||||
return {std::chrono::duration_cast<broker::timespan>(secs)};
|
||||
}
|
||||
case TYPE_ENUM:
|
||||
case zeek::TYPE_ENUM:
|
||||
{
|
||||
auto enum_type = v->GetType()->AsEnumType();
|
||||
auto enum_name = enum_type->Lookup(v->AsEnum());
|
||||
return {broker::enum_value(enum_name ? enum_name : "<unknown enum>")};
|
||||
}
|
||||
case TYPE_STRING:
|
||||
case zeek::TYPE_STRING:
|
||||
{
|
||||
auto s = v->AsString();
|
||||
return {string(reinterpret_cast<const char*>(s->Bytes()), s->Len())};
|
||||
}
|
||||
case TYPE_FILE:
|
||||
case zeek::TYPE_FILE:
|
||||
return {string(v->AsFile()->Name())};
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_FUNC:
|
||||
{
|
||||
const Func* f = v->AsFunc();
|
||||
std::string name(f->Name());
|
||||
|
@ -878,7 +878,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
|
||||
return {std::move(rval)};
|
||||
}
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
auto is_set = v->GetType()->IsSet();
|
||||
auto table = v->AsTable();
|
||||
|
@ -934,7 +934,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
|
||||
return {std::move(rval)};
|
||||
}
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
auto vec = v->AsVectorVal();
|
||||
broker::vector rval;
|
||||
|
@ -957,7 +957,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
|
||||
return {std::move(rval)};
|
||||
}
|
||||
case TYPE_RECORD:
|
||||
case zeek::TYPE_RECORD:
|
||||
{
|
||||
auto rec = v->AsRecordVal();
|
||||
broker::vector rval;
|
||||
|
@ -984,13 +984,13 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
|
||||
return {std::move(rval)};
|
||||
}
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_PATTERN:
|
||||
{
|
||||
const RE_Matcher* p = v->AsPattern();
|
||||
broker::vector rval = {p->PatternText(), p->AnywherePatternText()};
|
||||
return {std::move(rval)};
|
||||
}
|
||||
case TYPE_OPAQUE:
|
||||
case zeek::TYPE_OPAQUE:
|
||||
{
|
||||
auto c = v->AsOpaqueVal()->Serialize();
|
||||
if ( ! c )
|
||||
|
@ -1003,7 +1003,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
}
|
||||
default:
|
||||
reporter->Error("unsupported Broker::Data type: %s",
|
||||
type_name(v->GetType()->Tag()));
|
||||
zeek::type_name(v->GetType()->Tag()));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1137,17 +1137,17 @@ void bro_broker::DataVal::ValDescribe(ODesc* d) const
|
|||
d->Add("}");
|
||||
}
|
||||
|
||||
bool bro_broker::DataVal::canCastTo(BroType* t) const
|
||||
bool bro_broker::DataVal::canCastTo(zeek::BroType* t) const
|
||||
{
|
||||
return data_type_check(data, t);
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> bro_broker::DataVal::castTo(BroType* t)
|
||||
IntrusivePtr<Val> bro_broker::DataVal::castTo(zeek::BroType* t)
|
||||
{
|
||||
return data_to_val(data, t);
|
||||
}
|
||||
|
||||
const IntrusivePtr<BroType>& bro_broker::DataVal::ScriptDataType()
|
||||
const IntrusivePtr<zeek::BroType>& bro_broker::DataVal::ScriptDataType()
|
||||
{
|
||||
static auto script_data_type = zeek::id::find_type("Broker::Data");
|
||||
return script_data_type;
|
||||
|
@ -1305,7 +1305,7 @@ threading::Field* bro_broker::data_to_threading_field(broker::data d)
|
|||
|
||||
return new threading::Field(name->c_str(),
|
||||
secondary != broker::nil ? caf::get<std::string>(secondary).c_str() : nullptr,
|
||||
static_cast<TypeTag>(*type),
|
||||
static_cast<TypeTag>(*subtype),
|
||||
static_cast<zeek::TypeTag>(*type),
|
||||
static_cast<zeek::TypeTag>(*subtype),
|
||||
*optional);
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ struct Field;
|
|||
|
||||
namespace bro_broker {
|
||||
|
||||
extern IntrusivePtr<OpaqueType> opaque_of_data_type;
|
||||
extern IntrusivePtr<OpaqueType> opaque_of_set_iterator;
|
||||
extern IntrusivePtr<OpaqueType> opaque_of_table_iterator;
|
||||
extern IntrusivePtr<OpaqueType> opaque_of_vector_iterator;
|
||||
extern IntrusivePtr<OpaqueType> opaque_of_record_iterator;
|
||||
extern IntrusivePtr<zeek::OpaqueType> opaque_of_data_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> opaque_of_set_iterator;
|
||||
extern IntrusivePtr<zeek::OpaqueType> opaque_of_table_iterator;
|
||||
extern IntrusivePtr<zeek::OpaqueType> opaque_of_vector_iterator;
|
||||
extern IntrusivePtr<zeek::OpaqueType> opaque_of_record_iterator;
|
||||
|
||||
/**
|
||||
* Convert a broker port protocol to a bro port protocol.
|
||||
|
@ -65,7 +65,7 @@ broker::expected<broker::data> val_to_data(const Val* v);
|
|||
* @return a pointer to a new Bro value or a nullptr if the conversion was not
|
||||
* possible.
|
||||
*/
|
||||
IntrusivePtr<Val> data_to_val(broker::data d, BroType* type);
|
||||
IntrusivePtr<Val> data_to_val(broker::data d, zeek::BroType* type);
|
||||
|
||||
/**
|
||||
* Convert a Bro threading::Value to a Broker data value.
|
||||
|
@ -109,13 +109,13 @@ public:
|
|||
|
||||
void ValDescribe(ODesc* d) const override;
|
||||
|
||||
IntrusivePtr<Val> castTo(BroType* t);
|
||||
bool canCastTo(BroType* t) const;
|
||||
IntrusivePtr<Val> castTo(zeek::BroType* t);
|
||||
bool canCastTo(zeek::BroType* t) const;
|
||||
|
||||
// Returns the Bro type that scripts use to represent a Broker data
|
||||
// instance. This may be wrapping the opaque value inside another
|
||||
// type.
|
||||
static const IntrusivePtr<BroType>& ScriptDataType();
|
||||
static const IntrusivePtr<zeek::BroType>& ScriptDataType();
|
||||
|
||||
broker::data data;
|
||||
|
||||
|
@ -177,11 +177,11 @@ struct type_name_getter {
|
|||
|
||||
result_type operator()(const broker::vector&)
|
||||
{
|
||||
assert(tag == TYPE_VECTOR || tag == TYPE_RECORD);
|
||||
return tag == TYPE_VECTOR ? "vector" : "record";
|
||||
assert(tag == zeek::TYPE_VECTOR || tag == zeek::TYPE_RECORD);
|
||||
return tag == zeek::TYPE_VECTOR ? "vector" : "record";
|
||||
}
|
||||
|
||||
TypeTag tag;
|
||||
zeek::TypeTag tag;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -204,14 +204,14 @@ broker::data& opaque_field_to_data(RecordVal* v, Frame* f);
|
|||
* is not currently stored in the Broker data.
|
||||
*/
|
||||
template <typename T>
|
||||
T& require_data_type(broker::data& d, TypeTag tag, Frame* f)
|
||||
T& require_data_type(broker::data& d, zeek::TypeTag tag, Frame* f)
|
||||
{
|
||||
auto ptr = caf::get_if<T>(&d);
|
||||
if ( ! ptr )
|
||||
reporter->RuntimeError(f->GetCall()->GetLocationInfo(),
|
||||
"data is of type '%s' not of type '%s'",
|
||||
caf::visit(type_name_getter{tag}, d),
|
||||
type_name(tag));
|
||||
zeek::type_name(tag));
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ T& require_data_type(broker::data& d, TypeTag tag, Frame* f)
|
|||
* @see require_data_type() and opaque_field_to_data().
|
||||
*/
|
||||
template <typename T>
|
||||
inline T& require_data_type(RecordVal* v, TypeTag tag, Frame* f)
|
||||
inline T& require_data_type(RecordVal* v, zeek::TypeTag tag, Frame* f)
|
||||
{
|
||||
return require_data_type<T>(opaque_field_to_data(v, f), tag, f);
|
||||
}
|
||||
|
@ -230,12 +230,17 @@ inline T& require_data_type(RecordVal* v, TypeTag tag, Frame* f)
|
|||
class SetIterator : public OpaqueVal {
|
||||
public:
|
||||
|
||||
SetIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
SetIterator(RecordVal* v, zeek::TypeTag tag, Frame* f)
|
||||
: OpaqueVal(bro_broker::opaque_of_set_iterator),
|
||||
dat(require_data_type<broker::set>(v, TYPE_TABLE, f)),
|
||||
dat(require_data_type<broker::set>(v, zeek::TYPE_TABLE, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag instead.")]]
|
||||
SetIterator(RecordVal* v, ::TypeTag tag, Frame* f)
|
||||
: SetIterator(v, static_cast<zeek::TypeTag>(tag), f)
|
||||
{}
|
||||
|
||||
broker::set dat;
|
||||
broker::set::iterator it;
|
||||
|
||||
|
@ -250,12 +255,17 @@ protected:
|
|||
class TableIterator : public OpaqueVal {
|
||||
public:
|
||||
|
||||
TableIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
TableIterator(RecordVal* v, zeek::TypeTag tag, Frame* f)
|
||||
: OpaqueVal(bro_broker::opaque_of_table_iterator),
|
||||
dat(require_data_type<broker::table>(v, TYPE_TABLE, f)),
|
||||
dat(require_data_type<broker::table>(v, zeek::TYPE_TABLE, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag instead.")]]
|
||||
TableIterator(RecordVal* v, ::TypeTag tag, Frame* f)
|
||||
: TableIterator(v, static_cast<zeek::TypeTag>(tag), f)
|
||||
{}
|
||||
|
||||
broker::table dat;
|
||||
broker::table::iterator it;
|
||||
|
||||
|
@ -270,12 +280,17 @@ protected:
|
|||
class VectorIterator : public OpaqueVal {
|
||||
public:
|
||||
|
||||
VectorIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
VectorIterator(RecordVal* v, zeek::TypeTag tag, Frame* f)
|
||||
: OpaqueVal(bro_broker::opaque_of_vector_iterator),
|
||||
dat(require_data_type<broker::vector>(v, TYPE_VECTOR, f)),
|
||||
dat(require_data_type<broker::vector>(v, zeek::TYPE_VECTOR, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag instead.")]]
|
||||
VectorIterator(RecordVal* v, ::TypeTag tag, Frame* f)
|
||||
: VectorIterator(v, static_cast<zeek::TypeTag>(tag), f)
|
||||
{}
|
||||
|
||||
broker::vector dat;
|
||||
broker::vector::iterator it;
|
||||
|
||||
|
@ -290,12 +305,17 @@ protected:
|
|||
class RecordIterator : public OpaqueVal {
|
||||
public:
|
||||
|
||||
RecordIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
RecordIterator(RecordVal* v, zeek::TypeTag tag, Frame* f)
|
||||
: OpaqueVal(bro_broker::opaque_of_record_iterator),
|
||||
dat(require_data_type<broker::vector>(v, TYPE_RECORD, f)),
|
||||
dat(require_data_type<broker::vector>(v, zeek::TYPE_RECORD, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag instead.")]]
|
||||
RecordIterator(RecordVal* v, ::TypeTag tag, Frame* f)
|
||||
: RecordIterator(v, static_cast<zeek::TypeTag>(tag), f)
|
||||
{}
|
||||
|
||||
broker::vector dat;
|
||||
broker::vector::iterator it;
|
||||
|
||||
|
|
|
@ -152,13 +152,13 @@ void Manager::InitPostScript()
|
|||
log_id_type = zeek::id::find_type("Log::ID")->AsEnumType();
|
||||
writer_id_type = zeek::id::find_type("Log::Writer")->AsEnumType();
|
||||
|
||||
opaque_of_data_type = make_intrusive<OpaqueType>("Broker::Data");
|
||||
opaque_of_set_iterator = make_intrusive<OpaqueType>("Broker::SetIterator");
|
||||
opaque_of_table_iterator = make_intrusive<OpaqueType>("Broker::TableIterator");
|
||||
opaque_of_vector_iterator = make_intrusive<OpaqueType>("Broker::VectorIterator");
|
||||
opaque_of_record_iterator = make_intrusive<OpaqueType>("Broker::RecordIterator");
|
||||
opaque_of_store_handle = make_intrusive<OpaqueType>("Broker::Store");
|
||||
vector_of_data_type = make_intrusive<VectorType>(zeek::id::find_type("Broker::Data"));
|
||||
opaque_of_data_type = make_intrusive<zeek::OpaqueType>("Broker::Data");
|
||||
opaque_of_set_iterator = make_intrusive<zeek::OpaqueType>("Broker::SetIterator");
|
||||
opaque_of_table_iterator = make_intrusive<zeek::OpaqueType>("Broker::TableIterator");
|
||||
opaque_of_vector_iterator = make_intrusive<zeek::OpaqueType>("Broker::VectorIterator");
|
||||
opaque_of_record_iterator = make_intrusive<zeek::OpaqueType>("Broker::RecordIterator");
|
||||
opaque_of_store_handle = make_intrusive<zeek::OpaqueType>("Broker::Store");
|
||||
vector_of_data_type = make_intrusive<zeek::VectorType>(zeek::id::find_type("Broker::Data"));
|
||||
|
||||
// Register as a "dont-count" source first, we may change that later.
|
||||
iosource_mgr->Register(this, true);
|
||||
|
@ -430,7 +430,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
|
|||
if ( ! data )
|
||||
{
|
||||
Error("Failed to publish ID with unsupported type: %s (%s)",
|
||||
id.c_str(), type_name(val->GetType()->Tag()));
|
||||
id.c_str(), zeek::type_name(val->GetType()->Tag()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -639,14 +639,14 @@ void Manager::Error(const char* format, ...)
|
|||
|
||||
bool Manager::AutoPublishEvent(string topic, Val* event)
|
||||
{
|
||||
if ( event->GetType()->Tag() != TYPE_FUNC )
|
||||
if ( event->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||
{
|
||||
Error("Broker::auto_publish must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto event_val = event->AsFunc();
|
||||
if ( event_val->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
if ( event_val->Flavor() != zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
Error("Broker::auto_publish must operate on an event");
|
||||
return false;
|
||||
|
@ -668,7 +668,7 @@ bool Manager::AutoPublishEvent(string topic, Val* event)
|
|||
|
||||
bool Manager::AutoUnpublishEvent(const string& topic, Val* event)
|
||||
{
|
||||
if ( event->GetType()->Tag() != TYPE_FUNC )
|
||||
if ( event->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||
{
|
||||
Error("Broker::auto_event_stop must operate on an event");
|
||||
return false;
|
||||
|
@ -676,7 +676,7 @@ bool Manager::AutoUnpublishEvent(const string& topic, Val* event)
|
|||
|
||||
auto event_val = event->AsFunc();
|
||||
|
||||
if ( event_val->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
if ( event_val->Flavor() != zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
Error("Broker::auto_event_stop must operate on an event");
|
||||
return false;
|
||||
|
@ -714,7 +714,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
|
|||
{
|
||||
// Event val must come first.
|
||||
|
||||
if ( arg_val->GetType()->Tag() != TYPE_FUNC )
|
||||
if ( arg_val->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||
{
|
||||
Error("attempt to convert non-event into an event type");
|
||||
return rval;
|
||||
|
@ -722,7 +722,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
|
|||
|
||||
func = arg_val->AsFunc();
|
||||
|
||||
if ( func->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
if ( func->Flavor() != zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
Error("attempt to convert non-event into an event type");
|
||||
return rval;
|
||||
|
@ -748,8 +748,8 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
|
|||
{
|
||||
rval->Assign(0, nullptr);
|
||||
Error("event parameter #%d type mismatch, got %s, expect %s", i,
|
||||
type_name(got_type->Tag()),
|
||||
type_name(expected_type->Tag()));
|
||||
zeek::type_name(got_type->Tag()),
|
||||
zeek::type_name(expected_type->Tag()));
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -764,7 +764,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
|
|||
{
|
||||
rval->Assign(0, nullptr);
|
||||
Error("failed to convert param #%d of type %s to broker data",
|
||||
i, type_name(got_type->Tag()));
|
||||
i, zeek::type_name(got_type->Tag()));
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1001,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
|||
vl.emplace_back(std::move(val));
|
||||
else
|
||||
{
|
||||
auto expected_name = type_name(expected_type->Tag());
|
||||
auto expected_name = zeek::type_name(expected_type->Tag());
|
||||
|
||||
reporter->Warning("failed to convert remote event '%s' arg #%d,"
|
||||
" got %s, expected %s",
|
||||
|
@ -1201,7 +1201,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
|
|||
if ( ! val )
|
||||
{
|
||||
reporter->Error("Failed to receive ID with unsupported type: %s (%s)",
|
||||
id_name.c_str(), type_name(id->GetType()->Tag()));
|
||||
id_name.c_str(), zeek::type_name(id->GetType()->Tag()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1246,13 +1246,13 @@ void Manager::ProcessStatus(broker::status stat)
|
|||
if ( ! event )
|
||||
return;
|
||||
|
||||
static auto ei = zeek::id::find_type<RecordType>("Broker::EndpointInfo");
|
||||
static auto ei = zeek::id::find_type<zeek::RecordType>("Broker::EndpointInfo");
|
||||
auto endpoint_info = make_intrusive<RecordVal>(ei);
|
||||
|
||||
if ( ctx )
|
||||
{
|
||||
endpoint_info->Assign(0, make_intrusive<StringVal>(to_string(ctx->node)));
|
||||
static auto ni = zeek::id::find_type<RecordType>("Broker::NetworkInfo");
|
||||
static auto ni = zeek::id::find_type<zeek::RecordType>("Broker::NetworkInfo");
|
||||
auto network_info = make_intrusive<RecordVal>(ni);
|
||||
|
||||
if ( ctx->network )
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
class Frame;
|
||||
class Func;
|
||||
class VectorType;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(VectorType, zeek);
|
||||
|
||||
namespace bro_broker {
|
||||
|
||||
|
@ -396,9 +397,9 @@ private:
|
|||
|
||||
size_t log_batch_size;
|
||||
Func* log_topic_func;
|
||||
IntrusivePtr<VectorType> vector_of_data_type;
|
||||
EnumType* log_id_type;
|
||||
EnumType* writer_id_type;
|
||||
IntrusivePtr<zeek::VectorType> vector_of_data_type;
|
||||
zeek::EnumType* log_id_type;
|
||||
zeek::EnumType* writer_id_type;
|
||||
|
||||
static int script_scope;
|
||||
};
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
namespace bro_broker {
|
||||
|
||||
IntrusivePtr<OpaqueType> opaque_of_store_handle;
|
||||
IntrusivePtr<zeek::OpaqueType> opaque_of_store_handle;
|
||||
|
||||
IntrusivePtr<EnumVal> query_status(bool success)
|
||||
{
|
||||
static EnumType* store_query_status = nullptr;
|
||||
static zeek::EnumType* store_query_status = nullptr;
|
||||
static int success_val;
|
||||
static int failure_val;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace bro_broker {
|
||||
|
||||
extern IntrusivePtr<OpaqueType> opaque_of_store_handle;
|
||||
extern IntrusivePtr<zeek::OpaqueType> opaque_of_store_handle;
|
||||
|
||||
/**
|
||||
* Create a Broker::QueryStatus value.
|
||||
|
|
|
@ -63,7 +63,7 @@ function Broker::__set_create%(%): Broker::Data
|
|||
function Broker::__set_clear%(s: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
v.clear();
|
||||
return val_mgr->True();
|
||||
%}
|
||||
|
@ -71,14 +71,14 @@ function Broker::__set_clear%(s: Broker::Data%): bool
|
|||
function Broker::__set_size%(s: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
return val_mgr->Count(static_cast<uint64_t>(v.size()));
|
||||
%}
|
||||
|
||||
function Broker::__set_contains%(s: Broker::Data, key: any%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
|
@ -93,7 +93,7 @@ function Broker::__set_contains%(s: Broker::Data, key: any%): bool
|
|||
function Broker::__set_insert%(s: Broker::Data, key: any%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
|
||||
|
@ -109,7 +109,7 @@ function Broker::__set_insert%(s: Broker::Data, key: any%): bool
|
|||
function Broker::__set_remove%(s: Broker::Data, key: any%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
|
@ -123,7 +123,7 @@ function Broker::__set_remove%(s: Broker::Data, key: any%): bool
|
|||
|
||||
function Broker::__set_iterator%(s: Broker::Data%): opaque of Broker::SetIterator
|
||||
%{
|
||||
return make_intrusive<bro_broker::SetIterator>(s->AsRecordVal(), TYPE_TABLE, frame);
|
||||
return make_intrusive<bro_broker::SetIterator>(s->AsRecordVal(), zeek::TYPE_TABLE, frame);
|
||||
%}
|
||||
|
||||
function Broker::__set_iterator_last%(it: opaque of Broker::SetIterator%): bool
|
||||
|
@ -166,7 +166,7 @@ function Broker::__table_create%(%): Broker::Data
|
|||
function Broker::__table_clear%(t: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
v.clear();
|
||||
return val_mgr->True();
|
||||
%}
|
||||
|
@ -174,14 +174,14 @@ function Broker::__table_clear%(t: Broker::Data%): bool
|
|||
function Broker::__table_size%(t: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
return val_mgr->Count(static_cast<uint64_t>(v.size()));
|
||||
%}
|
||||
|
||||
function Broker::__table_contains%(t: Broker::Data, key: any%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
|
||||
|
@ -197,7 +197,7 @@ function Broker::__table_contains%(t: Broker::Data, key: any%): bool
|
|||
function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::Data
|
||||
%{
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
|
||||
|
@ -232,7 +232,7 @@ function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::
|
|||
function Broker::__table_remove%(t: Broker::Data, key: any%): Broker::Data
|
||||
%{
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
|
||||
|
@ -257,7 +257,7 @@ function Broker::__table_remove%(t: Broker::Data, key: any%): Broker::Data
|
|||
function Broker::__table_lookup%(t: Broker::Data, key: any%): Broker::Data
|
||||
%{
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
|
||||
|
@ -277,7 +277,7 @@ function Broker::__table_lookup%(t: Broker::Data, key: any%): Broker::Data
|
|||
|
||||
function Broker::__table_iterator%(t: Broker::Data%): opaque of Broker::TableIterator
|
||||
%{
|
||||
return make_intrusive<bro_broker::TableIterator>(t->AsRecordVal(), TYPE_TABLE, frame);
|
||||
return make_intrusive<bro_broker::TableIterator>(t->AsRecordVal(), zeek::TYPE_TABLE, frame);
|
||||
%}
|
||||
|
||||
function Broker::__table_iterator_last%(it: opaque of Broker::TableIterator%): bool
|
||||
|
@ -325,7 +325,7 @@ function Broker::__vector_create%(%): Broker::Data
|
|||
function Broker::__vector_clear%(v: Broker::Data%): bool
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
vec.clear();
|
||||
return val_mgr->True();
|
||||
%}
|
||||
|
@ -333,14 +333,14 @@ function Broker::__vector_clear%(v: Broker::Data%): bool
|
|||
function Broker::__vector_size%(v: Broker::Data%): count
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
return val_mgr->Count(static_cast<uint64_t>(vec.size()));
|
||||
%}
|
||||
|
||||
function Broker::__vector_insert%(v: Broker::Data, idx:count, d: any%): bool
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
auto item = bro_broker::val_to_data(d);
|
||||
|
||||
if ( ! item )
|
||||
|
@ -357,7 +357,7 @@ function Broker::__vector_insert%(v: Broker::Data, idx:count, d: any%): bool
|
|||
function Broker::__vector_replace%(v: Broker::Data, idx: count, d: any%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
auto item = bro_broker::val_to_data(d);
|
||||
|
||||
if ( ! item )
|
||||
|
@ -377,7 +377,7 @@ function Broker::__vector_replace%(v: Broker::Data, idx: count, d: any%): Broker
|
|||
function Broker::__vector_remove%(v: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return make_intrusive<RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
@ -390,7 +390,7 @@ function Broker::__vector_remove%(v: Broker::Data, idx: count%): Broker::Data
|
|||
function Broker::__vector_lookup%(v: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return make_intrusive<RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
@ -400,7 +400,7 @@ function Broker::__vector_lookup%(v: Broker::Data, idx: count%): Broker::Data
|
|||
|
||||
function Broker::__vector_iterator%(v: Broker::Data%): opaque of Broker::VectorIterator
|
||||
%{
|
||||
return make_intrusive<bro_broker::VectorIterator>(v->AsRecordVal(), TYPE_VECTOR, frame);
|
||||
return make_intrusive<bro_broker::VectorIterator>(v->AsRecordVal(), zeek::TYPE_VECTOR, frame);
|
||||
%}
|
||||
|
||||
function Broker::__vector_iterator_last%(it: opaque of Broker::VectorIterator%): bool
|
||||
|
@ -443,14 +443,14 @@ function Broker::__record_create%(sz: count%): Broker::Data
|
|||
function Broker::__record_size%(r: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::vector>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
zeek::TYPE_RECORD, frame);
|
||||
return val_mgr->Count(static_cast<uint64_t>(v.size()));
|
||||
%}
|
||||
|
||||
function Broker::__record_assign%(r: Broker::Data, idx: count, d: any%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::vector>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
zeek::TYPE_RECORD, frame);
|
||||
if ( idx >= v.size() )
|
||||
return val_mgr->False();
|
||||
|
||||
|
@ -469,7 +469,7 @@ function Broker::__record_assign%(r: Broker::Data, idx: count, d: any%): bool
|
|||
function Broker::__record_lookup%(r: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::vector>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
zeek::TYPE_RECORD, frame);
|
||||
|
||||
if ( idx >= v.size() || caf::get_if<broker::none>(&v[idx]) )
|
||||
return make_intrusive<RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
@ -479,7 +479,7 @@ function Broker::__record_lookup%(r: Broker::Data, idx: count%): Broker::Data
|
|||
|
||||
function Broker::__record_iterator%(r: Broker::Data%): opaque of Broker::RecordIterator
|
||||
%{
|
||||
return make_intrusive<bro_broker::RecordIterator>(r->AsRecordVal(), TYPE_RECORD, frame);
|
||||
return make_intrusive<bro_broker::RecordIterator>(r->AsRecordVal(), zeek::TYPE_RECORD, frame);
|
||||
%}
|
||||
|
||||
function Broker::__record_iterator_last%(it: opaque of Broker::RecordIterator%): bool
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
static bool is_string_set(const BroType* type)
|
||||
static bool is_string_set(const zeek::BroType* type)
|
||||
{
|
||||
if ( ! type->IsSet() )
|
||||
return false;
|
||||
|
@ -17,14 +17,14 @@ static bool is_string_set(const BroType* type)
|
|||
if ( index_types.size() != 1 )
|
||||
return false;
|
||||
|
||||
return index_types[0]->Tag() == TYPE_STRING;
|
||||
return index_types[0]->Tag() == zeek::TYPE_STRING;
|
||||
}
|
||||
|
||||
std::set<std::string> val_to_topic_set(Val* val)
|
||||
{
|
||||
std::set<std::string> rval;
|
||||
|
||||
if ( val->GetType()->Tag() == TYPE_STRING )
|
||||
if ( val->GetType()->Tag() == zeek::TYPE_STRING )
|
||||
rval.emplace(val->AsString()->CheckString());
|
||||
else
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ static bool publish_event_args(val_list& args, const BroString* topic,
|
|||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = false;
|
||||
|
||||
if ( args[0]->GetType()->Tag() == TYPE_RECORD )
|
||||
if ( args[0]->GetType()->Tag() == zeek::TYPE_RECORD )
|
||||
rval = broker_mgr->PublishEvent(topic->CheckString(),
|
||||
args[0]->AsRecordVal());
|
||||
else
|
||||
|
|
|
@ -20,7 +20,7 @@ static void analyzer_del_func(void* v)
|
|||
|
||||
AnalyzerSet::AnalyzerSet(File* arg_file) : file(arg_file)
|
||||
{
|
||||
auto t = make_intrusive<TypeList>();
|
||||
auto t = make_intrusive<zeek::TypeList>();
|
||||
t->Append(file_mgr->GetTagType());
|
||||
t->Append(zeek::BifType::Record::Files::AnalyzerArgs);
|
||||
analyzer_hash = new CompositeHash(std::move(t));
|
||||
|
@ -156,7 +156,7 @@ bool AnalyzerSet::RemoveMod::Perform(AnalyzerSet* set)
|
|||
std::unique_ptr<HashKey> AnalyzerSet::GetKey(const file_analysis::Tag& t,
|
||||
IntrusivePtr<RecordVal> args) const
|
||||
{
|
||||
auto lv = make_intrusive<ListVal>(TYPE_ANY);
|
||||
auto lv = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||
lv->Append(t.AsVal());
|
||||
lv->Append(std::move(args));
|
||||
auto key = analyzer_hash->MakeHashKey(*lv, true);
|
||||
|
|
|
@ -23,10 +23,10 @@ using namespace file_analysis;
|
|||
|
||||
static IntrusivePtr<TableVal> empty_connection_table()
|
||||
{
|
||||
auto tbl_index = make_intrusive<TypeList>(zeek::id::conn_id);
|
||||
auto tbl_index = make_intrusive<zeek::TypeList>(zeek::id::conn_id);
|
||||
tbl_index->Append(zeek::id::conn_id);
|
||||
auto tbl_type = make_intrusive<TableType>(std::move(tbl_index),
|
||||
zeek::id::connection);
|
||||
auto tbl_type = make_intrusive<zeek::TableType>(std::move(tbl_index),
|
||||
zeek::id::connection);
|
||||
return make_intrusive<TableVal>(std::move(tbl_type));
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ double File::LookupFieldDefaultInterval(int idx) const
|
|||
return v->AsInterval();
|
||||
}
|
||||
|
||||
int File::Idx(const std::string& field, const RecordType* type)
|
||||
int File::Idx(const std::string& field, const zeek::RecordType* type)
|
||||
{
|
||||
int rval = type->FieldOffset(field.c_str());
|
||||
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
#include "WeirdState.h"
|
||||
|
||||
class Connection;
|
||||
class RecordType;
|
||||
class RecordVal;
|
||||
class EventHandlerPtr;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
|
||||
|
||||
namespace file_analysis {
|
||||
|
||||
class FileReassembler;
|
||||
|
@ -336,8 +337,8 @@ protected:
|
|||
* @param type the record type for which the field will be looked up.
|
||||
* @return the field offset in #val record corresponding to \a field_name.
|
||||
*/
|
||||
static int Idx(const std::string& field_name, const RecordType* type);
|
||||
static int Idx(const std::string& field_name, const IntrusivePtr<RecordType>& type)
|
||||
static int Idx(const std::string& field_name, const zeek::RecordType* type);
|
||||
static int Idx(const std::string& field_name, const IntrusivePtr<zeek::RecordType>& type)
|
||||
{ return Idx(field_name, type.get()); }
|
||||
|
||||
/**
|
||||
|
|
|
@ -519,8 +519,8 @@ string Manager::DetectMIME(const u_char* data, uint64_t len) const
|
|||
|
||||
IntrusivePtr<VectorVal> file_analysis::GenMIMEMatchesVal(const RuleMatcher::MIME_Matches& m)
|
||||
{
|
||||
static auto mime_matches = zeek::id::find_type<VectorType>("mime_matches");
|
||||
static auto mime_match = zeek::id::find_type<RecordType>("mime_match");
|
||||
static auto mime_matches = zeek::id::find_type<zeek::VectorType>("mime_matches");
|
||||
static auto mime_match = zeek::id::find_type<zeek::RecordType>("mime_match");
|
||||
auto rval = make_intrusive<VectorVal>(mime_matches);
|
||||
|
||||
for ( RuleMatcher::MIME_Matches::const_iterator it = m.begin();
|
||||
|
|
|
@ -428,7 +428,7 @@ private:
|
|||
MIMEMap mime_types;/**< Mapping of MIME types to analyzers. */
|
||||
|
||||
inline static TableVal* disabled = nullptr; /**< Table of disabled analyzers. */
|
||||
inline static TableType* tag_set_type = nullptr; /**< Type for set[tag]. */
|
||||
inline static zeek::TableType* tag_set_type = nullptr; /**< Type for set[tag]. */
|
||||
|
||||
size_t cumulative_files;
|
||||
size_t max_files;
|
||||
|
|
|
@ -62,7 +62,7 @@ void Entropy::Finalize()
|
|||
montepi = scc = ent = mean = chisq = 0.0;
|
||||
entropy->Get(&ent, &chisq, &mean, &montepi, &scc);
|
||||
|
||||
static auto entropy_test_result = zeek::id::find_type<RecordType>("entropy_test_result");
|
||||
static auto entropy_test_result = zeek::id::find_type<zeek::RecordType>("entropy_test_result");
|
||||
auto ent_result = make_intrusive<RecordVal>(entropy_test_result);
|
||||
ent_result->Assign<DoubleVal>(0, ent);
|
||||
ent_result->Assign<DoubleVal>(1, chisq);
|
||||
|
|
|
@ -620,7 +620,7 @@ void file_analysis::OCSP::ParseResponse(OCSP_RESPONSE *resp)
|
|||
//ocsp_resp_record->Assign(7, make_intrusive<StringVal>(len, buf));
|
||||
//BIO_reset(bio);
|
||||
|
||||
certs_vector = new VectorVal(zeek::id::find_type<VectorType>("x509_opaque_vector"));
|
||||
certs_vector = new VectorVal(zeek::id::find_type<zeek::VectorType>("x509_opaque_vector"));
|
||||
vl.emplace_back(AdoptRef{}, certs_vector);
|
||||
|
||||
#if ( OPENSSL_VERSION_NUMBER < 0x10100000L ) || defined(LIBRESSL_VERSION_NUMBER)
|
||||
|
@ -675,4 +675,3 @@ void file_analysis::OCSP::ParseExtensionsSpecific(X509_EXTENSION* ex, bool globa
|
|||
#endif
|
||||
ParseSignedCertificateTimestamps(ex);
|
||||
}
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext)
|
|||
else if ( gen->type == GEN_IPADD )
|
||||
{
|
||||
if ( ips == nullptr )
|
||||
ips = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("addr_vec"));
|
||||
ips = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("addr_vec"));
|
||||
|
||||
uint32_t* addr = (uint32_t*) gen->d.ip->data;
|
||||
|
||||
|
|
|
@ -96,8 +96,8 @@ public:
|
|||
bool want_record;
|
||||
|
||||
TableVal* tab;
|
||||
RecordType* rtype;
|
||||
RecordType* itype;
|
||||
zeek::RecordType* rtype;
|
||||
zeek::RecordType* itype;
|
||||
|
||||
PDict<InputHash>* currDict;
|
||||
PDict<InputHash>* lastDict;
|
||||
|
@ -114,7 +114,7 @@ class Manager::EventStream final : public Manager::Stream {
|
|||
public:
|
||||
EventHandlerPtr event;
|
||||
|
||||
RecordType* fields;
|
||||
zeek::RecordType* fields;
|
||||
unsigned int num_fields;
|
||||
|
||||
bool want_record;
|
||||
|
@ -217,7 +217,7 @@ ReaderBackend* Manager::CreateBackend(ReaderFrontend* frontend, EnumVal* tag)
|
|||
// Create a new input reader object to be used at whomevers leisure later on.
|
||||
bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||
{
|
||||
RecordType* rtype = description->GetType()->AsRecordType();
|
||||
zeek::RecordType* rtype = description->GetType()->AsRecordType();
|
||||
if ( ! ( same_type(rtype, zeek::BifType::Record::Input::TableDescription, false)
|
||||
|| same_type(rtype, zeek::BifType::Record::Input::EventDescription, false)
|
||||
|| same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) ) )
|
||||
|
@ -305,7 +305,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
|||
|
||||
bool Manager::CreateEventStream(RecordVal* fval)
|
||||
{
|
||||
RecordType* rtype = fval->GetType()->AsRecordType();
|
||||
zeek::RecordType* rtype = fval->GetType()->AsRecordType();
|
||||
if ( ! same_type(rtype, zeek::BifType::Record::Input::EventDescription, false) )
|
||||
{
|
||||
reporter->Error("EventDescription argument not of right type");
|
||||
|
@ -315,7 +315,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
|||
string stream_name = fval->GetFieldOrDefault("name")->AsString()->CheckString();
|
||||
|
||||
auto fields_val = fval->GetFieldOrDefault("fields");
|
||||
RecordType* fields = fields_val->AsType()->AsTypeType()->GetType()->AsRecordType();
|
||||
zeek::RecordType* fields = fields_val->AsType()->AsTypeType()->GetType()->AsRecordType();
|
||||
|
||||
auto want_record = fval->GetFieldOrDefault("want_record");
|
||||
|
||||
|
@ -326,7 +326,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
|||
|
||||
bool allow_file_func = false;
|
||||
|
||||
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str());
|
||||
return false;
|
||||
|
@ -371,8 +371,8 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
|||
|
||||
reporter->Error("Input stream %s: Incompatible type for event in field %d. Need type '%s':%s, got '%s':%s",
|
||||
stream_name.c_str(), i + 3,
|
||||
type_name(fields->GetFieldType(i)->Tag()), desc2.Description(),
|
||||
type_name(args[i + 2]->Tag()), desc1.Description());
|
||||
zeek::type_name(fields->GetFieldType(i)->Tag()), desc2.Description(),
|
||||
zeek::type_name(args[i + 2]->Tag()), desc1.Description());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -396,8 +396,8 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
|||
fields->Describe(&desc2);
|
||||
reporter->Error("Input stream %s: Incompatible type '%s':%s for event, which needs type '%s':%s\n",
|
||||
stream_name.c_str(),
|
||||
type_name(args[2]->Tag()), desc1.Description(),
|
||||
type_name(fields->Tag()), desc2.Description());
|
||||
zeek::type_name(args[2]->Tag()), desc1.Description(),
|
||||
zeek::type_name(fields->Tag()), desc2.Description());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
|||
|
||||
bool Manager::CreateTableStream(RecordVal* fval)
|
||||
{
|
||||
RecordType* rtype = fval->GetType()->AsRecordType();
|
||||
zeek::RecordType* rtype = fval->GetType()->AsRecordType();
|
||||
if ( ! same_type(rtype, zeek::BifType::Record::Input::TableDescription, false) )
|
||||
{
|
||||
reporter->Error("TableDescription argument not of right type");
|
||||
|
@ -470,13 +470,13 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
|||
|
||||
auto pred = fval->GetFieldOrDefault("pred");
|
||||
auto idx_val = fval->GetFieldOrDefault("idx");
|
||||
RecordType* idx = idx_val->AsType()->AsTypeType()->GetType()->AsRecordType();
|
||||
zeek::RecordType* idx = idx_val->AsType()->AsTypeType()->GetType()->AsRecordType();
|
||||
|
||||
IntrusivePtr<RecordType> val;
|
||||
IntrusivePtr<zeek::RecordType> val;
|
||||
auto val_val = fval->GetFieldOrDefault("val");
|
||||
|
||||
if ( val_val )
|
||||
val = val_val->AsType()->AsTypeType()->GetType<RecordType>();
|
||||
val = val_val->AsType()->AsTypeType()->GetType<zeek::RecordType>();
|
||||
|
||||
auto dst = fval->GetFieldOrDefault("destination");
|
||||
|
||||
|
@ -501,8 +501,8 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
|||
tl[j]->Describe(&desc2);
|
||||
|
||||
reporter->Error("Input stream %s: Table type does not match index type. Need type '%s':%s, got '%s':%s", stream_name.c_str(),
|
||||
type_name(idx->GetFieldType(j)->Tag()), desc1.Description(),
|
||||
type_name(tl[j]->Tag()), desc2.Description());
|
||||
zeek::type_name(idx->GetFieldType(j)->Tag()), desc1.Description(),
|
||||
zeek::type_name(tl[j]->Tag()), desc2.Description());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
|||
{
|
||||
const auto& etype = event->GetType();
|
||||
|
||||
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("Input stream %s: Stream event is a function, not an event", stream_name.c_str());
|
||||
return false;
|
||||
|
@ -698,7 +698,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* e
|
|||
|
||||
const auto& etype = ev->GetType();
|
||||
|
||||
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("Input stream %s: Error event is a function, not an event", stream_name.c_str());
|
||||
return false;
|
||||
|
@ -724,7 +724,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* e
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( args[1]->Tag() != TYPE_STRING )
|
||||
if ( args[1]->Tag() != zeek::TYPE_STRING )
|
||||
{
|
||||
reporter->Error("Input stream %s: Error event's second attribute must be of type string", stream_name.c_str());
|
||||
return false;
|
||||
|
@ -741,7 +741,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* e
|
|||
|
||||
bool Manager::CreateAnalysisStream(RecordVal* fval)
|
||||
{
|
||||
RecordType* rtype = fval->GetType()->AsRecordType();
|
||||
zeek::RecordType* rtype = fval->GetType()->AsRecordType();
|
||||
|
||||
if ( ! same_type(rtype, zeek::BifType::Record::Input::AnalysisDescription, false) )
|
||||
{
|
||||
|
@ -763,7 +763,7 @@ bool Manager::CreateAnalysisStream(RecordVal* fval)
|
|||
|
||||
// reader takes in a byte stream as the only field
|
||||
Field** fields = new Field*[1];
|
||||
fields[0] = new Field("bytestream", nullptr, TYPE_STRING, TYPE_VOID, false);
|
||||
fields[0] = new Field("bytestream", nullptr, zeek::TYPE_STRING, zeek::TYPE_VOID, false);
|
||||
stream->reader->Init(1, fields);
|
||||
|
||||
readers[stream->reader] = stream;
|
||||
|
@ -774,31 +774,31 @@ bool Manager::CreateAnalysisStream(RecordVal* fval)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Manager::IsCompatibleType(BroType* t, bool atomic_only)
|
||||
bool Manager::IsCompatibleType(zeek::BroType* t, bool atomic_only)
|
||||
{
|
||||
if ( ! t )
|
||||
return false;
|
||||
|
||||
switch ( t->Tag() ) {
|
||||
case TYPE_BOOL:
|
||||
case TYPE_INT:
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case TYPE_PORT:
|
||||
case TYPE_SUBNET:
|
||||
case TYPE_ADDR:
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_TIME:
|
||||
case TYPE_INTERVAL:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_STRING:
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_BOOL:
|
||||
case zeek::TYPE_INT:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
case zeek::TYPE_PORT:
|
||||
case zeek::TYPE_SUBNET:
|
||||
case zeek::TYPE_ADDR:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
case zeek::TYPE_TIME:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
case zeek::TYPE_ENUM:
|
||||
case zeek::TYPE_STRING:
|
||||
case zeek::TYPE_PATTERN:
|
||||
return true;
|
||||
|
||||
case TYPE_RECORD:
|
||||
case zeek::TYPE_RECORD:
|
||||
return ! atomic_only;
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
if ( atomic_only )
|
||||
return false;
|
||||
|
@ -809,7 +809,7 @@ bool Manager::IsCompatibleType(BroType* t, bool atomic_only)
|
|||
return IsCompatibleType(t->AsSetType()->GetIndices()->GetPureType().get(), true);
|
||||
}
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
if ( atomic_only )
|
||||
return false;
|
||||
|
@ -879,7 +879,7 @@ bool Manager::RemoveStreamContinuation(ReaderFrontend* reader)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
|
||||
bool Manager::UnrollRecordType(vector<Field*> *fields, const zeek::RecordType *rec,
|
||||
const string& nameprepend, bool allow_file_func) const
|
||||
{
|
||||
for ( int i = 0; i < rec->NumFields(); i++ )
|
||||
|
@ -893,21 +893,22 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
|
|||
// stuff that we actually cannot read :)
|
||||
if ( allow_file_func )
|
||||
{
|
||||
if ( ( rec->GetFieldType(i)->Tag() == TYPE_FILE ||
|
||||
rec->GetFieldType(i)->Tag() == TYPE_FUNC ||
|
||||
rec->GetFieldType(i)->Tag() == TYPE_OPAQUE ) &&
|
||||
if ( ( rec->GetFieldType(i)->Tag() == zeek::TYPE_FILE ||
|
||||
rec->GetFieldType(i)->Tag() == zeek::TYPE_FUNC ||
|
||||
rec->GetFieldType(i)->Tag() == zeek::TYPE_OPAQUE ) &&
|
||||
rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) )
|
||||
{
|
||||
reporter->Info("Encountered incompatible type \"%s\" in type definition for field \"%s\" in ReaderFrontend. Ignoring optional field.", type_name(rec->GetFieldType(i)->Tag()), name.c_str());
|
||||
reporter->Info("Encountered incompatible type \"%s\" in type definition for field \"%s\" in ReaderFrontend. Ignoring optional field.", zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
reporter->Error("Incompatible type \"%s\" in type definition for for field \"%s\" in ReaderFrontend", type_name(rec->GetFieldType(i)->Tag()), name.c_str());
|
||||
reporter->Error("Incompatible type \"%s\" in type definition for for field \"%s\" in ReaderFrontend",
|
||||
zeek::type_name(rec->GetFieldType(i)->Tag()), name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( rec->GetFieldType(i)->Tag() == TYPE_RECORD )
|
||||
if ( rec->GetFieldType(i)->Tag() == zeek::TYPE_RECORD )
|
||||
{
|
||||
string prep = nameprepend + rec->FieldName(i) + ".";
|
||||
|
||||
|
@ -929,17 +930,17 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
|
|||
string name = nameprepend + rec->FieldName(i);
|
||||
const char* secondary = nullptr;
|
||||
IntrusivePtr<Val> c;
|
||||
TypeTag ty = rec->GetFieldType(i)->Tag();
|
||||
TypeTag st = TYPE_VOID;
|
||||
zeek::TypeTag ty = rec->GetFieldType(i)->Tag();
|
||||
zeek::TypeTag st = zeek::TYPE_VOID;
|
||||
bool optional = false;
|
||||
|
||||
if ( ty == TYPE_TABLE )
|
||||
if ( ty == zeek::TYPE_TABLE )
|
||||
st = rec->GetFieldType(i)->AsSetType()->GetIndices()->GetPureType()->Tag();
|
||||
|
||||
else if ( ty == TYPE_VECTOR )
|
||||
else if ( ty == zeek::TYPE_VECTOR )
|
||||
st = rec->GetFieldType(i)->AsVectorType()->Yield()->Tag();
|
||||
|
||||
else if ( ty == TYPE_PORT &&
|
||||
else if ( ty == zeek::TYPE_PORT &&
|
||||
rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_TYPE_COLUMN) )
|
||||
{
|
||||
// we have an annotation for the second column
|
||||
|
@ -947,7 +948,7 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
|
|||
c = rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_TYPE_COLUMN)->GetExpr()->Eval(nullptr);
|
||||
|
||||
assert(c);
|
||||
assert(c->GetType()->Tag() == TYPE_STRING);
|
||||
assert(c->GetType()->Tag() == zeek::TYPE_STRING);
|
||||
|
||||
secondary = c->AsStringVal()->AsString()->CheckString();
|
||||
}
|
||||
|
@ -992,16 +993,16 @@ Val* Manager::RecordValToIndexVal(RecordVal *r) const
|
|||
{
|
||||
IntrusivePtr<Val> idxval;
|
||||
|
||||
RecordType *type = r->GetType()->AsRecordType();
|
||||
zeek::RecordType *type = r->GetType()->AsRecordType();
|
||||
|
||||
int num_fields = type->NumFields();
|
||||
|
||||
if ( num_fields == 1 && type->FieldDecl(0)->type->Tag() != TYPE_RECORD )
|
||||
if ( num_fields == 1 && type->FieldDecl(0)->type->Tag() != zeek::TYPE_RECORD )
|
||||
idxval = r->GetFieldOrDefault(0);
|
||||
|
||||
else
|
||||
{
|
||||
auto l = make_intrusive<ListVal>(TYPE_ANY);
|
||||
auto l = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||
for ( int j = 0 ; j < num_fields; j++ )
|
||||
l->Append(r->GetFieldOrDefault(j));
|
||||
|
||||
|
@ -1013,23 +1014,23 @@ Val* Manager::RecordValToIndexVal(RecordVal *r) const
|
|||
}
|
||||
|
||||
|
||||
Val* Manager::ValueToIndexVal(const Stream* i, int num_fields, const RecordType *type, const Value* const *vals, bool& have_error) const
|
||||
Val* Manager::ValueToIndexVal(const Stream* i, int num_fields, const zeek::RecordType *type, const Value* const *vals, bool& have_error) const
|
||||
{
|
||||
Val* idxval;
|
||||
int position = 0;
|
||||
|
||||
|
||||
if ( num_fields == 1 && type->GetFieldType(0)->Tag() != TYPE_RECORD )
|
||||
if ( num_fields == 1 && type->GetFieldType(0)->Tag() != zeek::TYPE_RECORD )
|
||||
{
|
||||
idxval = ValueToVal(i, vals[0], type->GetFieldType(0).get(), have_error);
|
||||
position = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ListVal *l = new ListVal(TYPE_ANY);
|
||||
ListVal *l = new ListVal(zeek::TYPE_ANY);
|
||||
for ( int j = 0 ; j < type->NumFields(); j++ )
|
||||
{
|
||||
if ( type->GetFieldType(j)->Tag() == TYPE_RECORD )
|
||||
if ( type->GetFieldType(j)->Tag() == zeek::TYPE_RECORD )
|
||||
l->Append({AdoptRef{}, ValueToRecordVal(i, vals,
|
||||
type->GetFieldType(j)->AsRecordType(), &position, have_error)});
|
||||
else
|
||||
|
@ -1071,7 +1072,7 @@ void Manager::SendEntry(ReaderFrontend* reader, Value* *vals)
|
|||
else if ( i->stream_type == ANALYSIS_STREAM )
|
||||
{
|
||||
readFields = 1;
|
||||
assert(vals[0]->type == TYPE_STRING);
|
||||
assert(vals[0]->type == zeek::TYPE_STRING);
|
||||
file_mgr->DataIn(reinterpret_cast<u_char*>(vals[0]->val.string_val.data),
|
||||
vals[0]->val.string_val.length,
|
||||
static_cast<AnalysisStream*>(i)->file_id, i->name);
|
||||
|
@ -1438,7 +1439,7 @@ void Manager::Put(ReaderFrontend* reader, Value* *vals)
|
|||
else if ( i->stream_type == ANALYSIS_STREAM )
|
||||
{
|
||||
readFields = 1;
|
||||
assert(vals[0]->type == TYPE_STRING);
|
||||
assert(vals[0]->type == zeek::TYPE_STRING);
|
||||
file_mgr->DataIn(reinterpret_cast<u_char*>(vals[0]->val.string_val.data),
|
||||
vals[0]->val.string_val.length,
|
||||
static_cast<AnalysisStream*>(i)->file_id, i->name);
|
||||
|
@ -1479,7 +1480,7 @@ int Manager::SendEventStreamEvent(Stream* i, EnumVal* type, const Value* const *
|
|||
{
|
||||
Val* val = nullptr;
|
||||
|
||||
if ( stream->fields->GetFieldType(j)->Tag() == TYPE_RECORD )
|
||||
if ( stream->fields->GetFieldType(j)->Tag() == zeek::TYPE_RECORD )
|
||||
val = ValueToRecordVal(i, vals,
|
||||
stream->fields->GetFieldType(j)->AsRecordType(),
|
||||
&position, convert_error);
|
||||
|
@ -1816,7 +1817,7 @@ void Manager::SendEvent(EventHandlerPtr ev, list<Val*> events) const
|
|||
|
||||
// Convert a bro list value to a bro record value.
|
||||
// I / we could think about moving this functionality to val.cc
|
||||
RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType *request_type, int* position) const
|
||||
RecordVal* Manager::ListValToRecordVal(ListVal* list, zeek::RecordType *request_type, int* position) const
|
||||
{
|
||||
assert(position != nullptr); // we need the pointer to point to data;
|
||||
|
||||
|
@ -1830,7 +1831,7 @@ RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType *request_type,
|
|||
assert ( (*position) <= maxpos );
|
||||
|
||||
Val* fieldVal = nullptr;
|
||||
if ( request_type->GetFieldType(i)->Tag() == TYPE_RECORD )
|
||||
if ( request_type->GetFieldType(i)->Tag() == zeek::TYPE_RECORD )
|
||||
fieldVal = ListValToRecordVal(list, request_type->GetFieldType(i)->AsRecordType(), position);
|
||||
else
|
||||
{
|
||||
|
@ -1846,7 +1847,7 @@ RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType *request_type,
|
|||
|
||||
// Convert a threading value to a record value
|
||||
RecordVal* Manager::ValueToRecordVal(const Stream* stream, const Value* const *vals,
|
||||
RecordType *request_type, int* position, bool& have_error) const
|
||||
zeek::RecordType *request_type, int* position, bool& have_error) const
|
||||
{
|
||||
assert(position != nullptr); // we need the pointer to point to data.
|
||||
|
||||
|
@ -1854,10 +1855,10 @@ RecordVal* Manager::ValueToRecordVal(const Stream* stream, const Value* const *v
|
|||
for ( int i = 0; i < request_type->NumFields(); i++ )
|
||||
{
|
||||
Val* fieldVal = nullptr;
|
||||
if ( request_type->GetFieldType(i)->Tag() == TYPE_RECORD )
|
||||
if ( request_type->GetFieldType(i)->Tag() == zeek::TYPE_RECORD )
|
||||
fieldVal = ValueToRecordVal(stream, vals, request_type->GetFieldType(i)->AsRecordType(), position, have_error);
|
||||
else if ( request_type->GetFieldType(i)->Tag() == TYPE_FILE ||
|
||||
request_type->GetFieldType(i)->Tag() == TYPE_FUNC )
|
||||
else if ( request_type->GetFieldType(i)->Tag() == zeek::TYPE_FILE ||
|
||||
request_type->GetFieldType(i)->Tag() == zeek::TYPE_FUNC )
|
||||
{
|
||||
// If those two unsupported types are encountered here, they have
|
||||
// been let through by the type checking.
|
||||
|
@ -1889,35 +1890,35 @@ int Manager::GetValueLength(const Value* val) const
|
|||
int length = 0;
|
||||
|
||||
switch (val->type) {
|
||||
case TYPE_BOOL:
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_BOOL:
|
||||
case zeek::TYPE_INT:
|
||||
length += sizeof(val->val.int_val);
|
||||
break;
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
length += sizeof(val->val.uint_val);
|
||||
break;
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
length += sizeof(val->val.port_val.port);
|
||||
length += sizeof(val->val.port_val.proto);
|
||||
break;
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_TIME:
|
||||
case TYPE_INTERVAL:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
case zeek::TYPE_TIME:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
length += sizeof(val->val.double_val);
|
||||
break;
|
||||
|
||||
case TYPE_STRING:
|
||||
case TYPE_ENUM:
|
||||
case zeek::TYPE_STRING:
|
||||
case zeek::TYPE_ENUM:
|
||||
{
|
||||
length += val->val.string_val.length + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
{
|
||||
switch ( val->val.addr_val.family ) {
|
||||
case IPv4:
|
||||
|
@ -1932,7 +1933,7 @@ int Manager::GetValueLength(const Value* val) const
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
switch ( val->val.subnet_val.prefix.family ) {
|
||||
case IPv4:
|
||||
|
@ -1949,20 +1950,20 @@ int Manager::GetValueLength(const Value* val) const
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_PATTERN:
|
||||
{
|
||||
length += strlen(val->val.pattern_text_val) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
for ( int i = 0; i < val->val.set_val.size; i++ )
|
||||
length += GetValueLength(val->val.set_val.vals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
int j = val->val.vector_val.size;
|
||||
for ( int i = 0; i < j; i++ )
|
||||
|
@ -1985,17 +1986,17 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
|
|||
assert( val->present ); // presence has to be checked elsewhere
|
||||
|
||||
switch ( val->type ) {
|
||||
case TYPE_BOOL:
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_BOOL:
|
||||
case zeek::TYPE_INT:
|
||||
memcpy(data+startpos, (const void*) &(val->val.int_val), sizeof(val->val.int_val));
|
||||
return sizeof(val->val.int_val);
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
memcpy(data+startpos, (const void*) &(val->val.uint_val), sizeof(val->val.uint_val));
|
||||
return sizeof(val->val.uint_val);
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
{
|
||||
int length = 0;
|
||||
memcpy(data+startpos, (const void*) &(val->val.port_val.port),
|
||||
|
@ -2008,15 +2009,15 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
|
|||
}
|
||||
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_TIME:
|
||||
case TYPE_INTERVAL:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
case zeek::TYPE_TIME:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
memcpy(data+startpos, (const void*) &(val->val.double_val),
|
||||
sizeof(val->val.double_val));
|
||||
return sizeof(val->val.double_val);
|
||||
|
||||
case TYPE_STRING:
|
||||
case TYPE_ENUM:
|
||||
case zeek::TYPE_STRING:
|
||||
case zeek::TYPE_ENUM:
|
||||
{
|
||||
memcpy(data+startpos, val->val.string_val.data, val->val.string_val.length);
|
||||
// Add a \0 to the end. To be able to hash zero-length
|
||||
|
@ -2025,7 +2026,7 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
|
|||
return val->val.string_val.length + 1;
|
||||
}
|
||||
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
{
|
||||
int length = 0;
|
||||
switch ( val->val.addr_val.family ) {
|
||||
|
@ -2046,7 +2047,7 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
|
|||
return length;
|
||||
}
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
int length = 0;
|
||||
switch ( val->val.subnet_val.prefix.family ) {
|
||||
|
@ -2074,7 +2075,7 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
|
|||
return length;
|
||||
}
|
||||
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_PATTERN:
|
||||
{
|
||||
// include null-terminator
|
||||
int length = strlen(val->val.pattern_text_val) + 1;
|
||||
|
@ -2082,7 +2083,7 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
|
|||
return length;
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
int length = 0;
|
||||
int j = val->val.set_val.size;
|
||||
|
@ -2092,7 +2093,7 @@ int Manager::CopyValue(char *data, const int startpos, const Value* val) const
|
|||
return length;
|
||||
}
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
int length = 0;
|
||||
int j = val->val.vector_val.size;
|
||||
|
@ -2158,12 +2159,12 @@ HashKey* Manager::HashValues(const int num_elements, const Value* const *vals) c
|
|||
// have_error is a reference to a boolean which is set to true as soon as an error occurs.
|
||||
// When have_error is set to true at the beginning of the function, it is assumed that
|
||||
// an error already occurred in the past and processing is aborted.
|
||||
Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_type, bool& have_error) const
|
||||
Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::BroType* request_type, bool& have_error) const
|
||||
{
|
||||
if ( have_error )
|
||||
return nullptr;
|
||||
|
||||
if ( request_type->Tag() != TYPE_ANY && request_type->Tag() != val->type )
|
||||
if ( request_type->Tag() != zeek::TYPE_ANY && request_type->Tag() != val->type )
|
||||
{
|
||||
reporter->InternalError("Typetags don't match: %d vs %d in stream %s", request_type->Tag(), val->type, i->name.c_str());
|
||||
return nullptr;
|
||||
|
@ -2173,35 +2174,35 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
|
|||
return nullptr; // unset field
|
||||
|
||||
switch ( val->type ) {
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
return val_mgr->Bool(val->val.int_val)->Ref();
|
||||
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_INT:
|
||||
return val_mgr->Int(val->val.int_val).release();
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
return val_mgr->Count(val->val.int_val).release();
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
return new DoubleVal(val->val.double_val);
|
||||
|
||||
case TYPE_TIME:
|
||||
case zeek::TYPE_TIME:
|
||||
return new TimeVal(val->val.double_val);
|
||||
|
||||
case TYPE_INTERVAL:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
return new IntervalVal(val->val.double_val);
|
||||
|
||||
case TYPE_STRING:
|
||||
case zeek::TYPE_STRING:
|
||||
{
|
||||
BroString *s = new BroString((const u_char*)val->val.string_val.data, val->val.string_val.length, true);
|
||||
return new StringVal(s);
|
||||
}
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
return val_mgr->Port(val->val.port_val.port, val->val.port_val.proto)->Ref();
|
||||
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
{
|
||||
IPAddr* addr = nullptr;
|
||||
switch ( val->val.addr_val.family ) {
|
||||
|
@ -2222,7 +2223,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
|
|||
return addrval;
|
||||
}
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
IPAddr* addr = nullptr;
|
||||
switch ( val->val.subnet_val.prefix.family ) {
|
||||
|
@ -2243,20 +2244,20 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
|
|||
return subnetval;
|
||||
}
|
||||
|
||||
case TYPE_PATTERN:
|
||||
case zeek::TYPE_PATTERN:
|
||||
{
|
||||
RE_Matcher* re = new RE_Matcher(val->val.pattern_text_val);
|
||||
re->Compile();
|
||||
return new PatternVal(re);
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
// all entries have to have the same type...
|
||||
const auto& type = request_type->AsTableType()->GetIndices()->GetPureType();
|
||||
auto set_index = make_intrusive<TypeList>(type);
|
||||
auto set_index = make_intrusive<zeek::TypeList>(type);
|
||||
set_index->Append(type);
|
||||
auto s = make_intrusive<SetType>(std::move(set_index), nullptr);
|
||||
auto s = make_intrusive<zeek::SetType>(std::move(set_index), nullptr);
|
||||
TableVal* t = new TableVal(std::move(s));
|
||||
for ( int j = 0; j < val->val.set_val.size; j++ )
|
||||
{
|
||||
|
@ -2268,11 +2269,11 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
|
|||
return t;
|
||||
}
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
// all entries have to have the same type...
|
||||
const auto& type = request_type->AsVectorType()->Yield();
|
||||
auto vt = make_intrusive<VectorType>(type);
|
||||
auto vt = make_intrusive<zeek::VectorType>(type);
|
||||
auto v = make_intrusive<VectorVal>(std::move(vt));
|
||||
|
||||
for ( int j = 0; j < val->val.vector_val.size; j++ )
|
||||
|
@ -2284,7 +2285,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
|
|||
return v.release();
|
||||
}
|
||||
|
||||
case TYPE_ENUM: {
|
||||
case zeek::TYPE_ENUM: {
|
||||
// Convert to string first to not have to deal with missing
|
||||
// \0's...
|
||||
string enum_string(val->val.string_val.data, val->val.string_val.length);
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
*
|
||||
* @return True if the type is compatible with the input framework.
|
||||
*/
|
||||
static bool IsCompatibleType(BroType* t, bool atomic_only=false);
|
||||
static bool IsCompatibleType(zeek::BroType* t, bool atomic_only=false);
|
||||
|
||||
protected:
|
||||
friend class ReaderFrontend;
|
||||
|
@ -199,7 +199,7 @@ private:
|
|||
// 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
|
||||
// records
|
||||
bool UnrollRecordType(std::vector<threading::Field*> *fields, const RecordType *rec, const std::string& nameprepend, bool allow_file_func) const;
|
||||
bool UnrollRecordType(std::vector<threading::Field*> *fields, const zeek::RecordType *rec, const std::string& nameprepend, bool allow_file_func) const;
|
||||
|
||||
// Send events
|
||||
void SendEvent(EventHandlerPtr ev, const int numvals, ...) const;
|
||||
|
@ -222,19 +222,19 @@ private:
|
|||
int CopyValue(char *data, const int startpos, const threading::Value* val) const;
|
||||
|
||||
// Convert Threading::Value to an internal Bro Type (works with Records).
|
||||
Val* ValueToVal(const Stream* i, const threading::Value* val, BroType* request_type, bool& have_error) const;
|
||||
Val* ValueToVal(const Stream* i, const threading::Value* val, zeek::BroType* request_type, bool& have_error) const;
|
||||
|
||||
// Convert Threading::Value to an internal Bro list type.
|
||||
Val* ValueToIndexVal(const Stream* i, int num_fields, const RecordType* type, const threading::Value* const *vals, bool& have_error) const;
|
||||
Val* ValueToIndexVal(const Stream* i, int num_fields, const zeek::RecordType* type, const threading::Value* const *vals, bool& have_error) const;
|
||||
|
||||
// Converts a threading::value to a record type. Mostly used by
|
||||
// ValueToVal.
|
||||
RecordVal* ValueToRecordVal(const Stream* i, const threading::Value* const *vals, RecordType *request_type, int* position, bool& have_error) const;
|
||||
RecordVal* ValueToRecordVal(const Stream* i, const threading::Value* const *vals, zeek::RecordType *request_type, int* position, bool& have_error) const;
|
||||
|
||||
Val* RecordValToIndexVal(RecordVal *r) const;
|
||||
|
||||
// Converts a Bro ListVal to a RecordVal given the record type.
|
||||
RecordVal* ListValToRecordVal(ListVal* list, RecordType *request_type, int* position) const;
|
||||
RecordVal* ListValToRecordVal(ListVal* list, zeek::RecordType *request_type, int* position) const;
|
||||
|
||||
// Internally signal errors, warnings, etc.
|
||||
// These are sent on to input scriptland and reporter.log
|
||||
|
|
|
@ -18,16 +18,16 @@ using namespace std;
|
|||
using threading::Value;
|
||||
using threading::Field;
|
||||
|
||||
FieldMapping::FieldMapping(const string& arg_name, const TypeTag& arg_type, int arg_position)
|
||||
: name(arg_name), type(arg_type), subtype(TYPE_ERROR)
|
||||
FieldMapping::FieldMapping(const string& arg_name, const zeek::TypeTag& arg_type, int arg_position)
|
||||
: name(arg_name), type(arg_type), subtype(zeek::TYPE_ERROR)
|
||||
{
|
||||
position = arg_position;
|
||||
secondary_position = -1;
|
||||
present = true;
|
||||
}
|
||||
|
||||
FieldMapping::FieldMapping(const string& arg_name, const TypeTag& arg_type,
|
||||
const TypeTag& arg_subtype, int arg_position)
|
||||
FieldMapping::FieldMapping(const string& arg_name, const zeek::TypeTag& arg_type,
|
||||
const zeek::TypeTag& arg_subtype, int arg_position)
|
||||
: name(arg_name), type(arg_type), subtype(arg_subtype)
|
||||
{
|
||||
position = arg_position;
|
||||
|
@ -407,7 +407,7 @@ bool Ascii::DoUpdate()
|
|||
if ( (*fit).secondary_position != -1 )
|
||||
{
|
||||
// we have a port definition :)
|
||||
assert(val->type == TYPE_PORT );
|
||||
assert(val->type == zeek::TYPE_PORT );
|
||||
// Error(Fmt("Got type %d != PORT with secondary position!", val->type));
|
||||
|
||||
val->val.port_val.proto = formatter->ParseProto(stringfields[(*fit).secondary_position]);
|
||||
|
@ -434,7 +434,7 @@ bool Ascii::DoUpdate()
|
|||
//printf("fpos: %d, second.num_fields: %d\n", fpos, (*it).second.num_fields);
|
||||
assert ( fpos == NumFields() );
|
||||
|
||||
if ( Info().mode == MODE_STREAM )
|
||||
if ( Info().mode == MODE_STREAM )
|
||||
Put(fields);
|
||||
else
|
||||
SendEntry(fields);
|
||||
|
|
|
@ -16,14 +16,25 @@ namespace input { namespace reader {
|
|||
// Description for input field mapping.
|
||||
struct FieldMapping {
|
||||
std::string name;
|
||||
TypeTag type;
|
||||
TypeTag subtype; // internal type for sets and vectors
|
||||
zeek::TypeTag type;
|
||||
zeek::TypeTag subtype; // internal type for sets and vectors
|
||||
int position;
|
||||
int secondary_position; // for ports: pos of the second field
|
||||
bool present;
|
||||
|
||||
FieldMapping(const std::string& arg_name, const TypeTag& arg_type, int arg_position);
|
||||
FieldMapping(const std::string& arg_name, const TypeTag& arg_type, const TypeTag& arg_subtype, int arg_position);
|
||||
FieldMapping(const std::string& arg_name, const zeek::TypeTag& arg_type, int arg_position);
|
||||
FieldMapping(const std::string& arg_name, const zeek::TypeTag& arg_type, const zeek::TypeTag& arg_subtype, int arg_position);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek:TypeTag.")]]
|
||||
FieldMapping(const std::string& arg_name, const ::TypeTag& arg_type, int arg_position)
|
||||
: FieldMapping(arg_name, static_cast<zeek::TypeTag>(arg_type), arg_position)
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek:TypeTag.")]]
|
||||
FieldMapping(const std::string& arg_name, const ::TypeTag& arg_type, const ::TypeTag& arg_subtype, int arg_position)
|
||||
: FieldMapping(arg_name, static_cast<zeek::TypeTag>(arg_type), static_cast<zeek::TypeTag>(arg_subtype), arg_position)
|
||||
{}
|
||||
|
||||
FieldMapping(const FieldMapping& arg);
|
||||
FieldMapping() { position = -1; secondary_position = -1; }
|
||||
|
||||
|
|
|
@ -123,17 +123,17 @@ bool Benchmark::DoUpdate()
|
|||
return true;
|
||||
}
|
||||
|
||||
threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
|
||||
threading::Value* Benchmark::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtype)
|
||||
{
|
||||
Value* val = new Value(type, subtype, true);
|
||||
|
||||
// basically construct something random from the fields that we want.
|
||||
|
||||
switch ( type ) {
|
||||
case TYPE_ENUM:
|
||||
case zeek::TYPE_ENUM:
|
||||
assert(false); // no enums, please.
|
||||
|
||||
case TYPE_STRING:
|
||||
case zeek::TYPE_STRING:
|
||||
{
|
||||
std::string rnd = RandomString(10);
|
||||
val->val.string_val.data = copy_string(rnd.c_str());
|
||||
|
@ -141,46 +141,46 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
val->val.int_val = 1; // we never lie.
|
||||
break;
|
||||
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_INT:
|
||||
val->val.int_val = random();
|
||||
break;
|
||||
|
||||
case TYPE_TIME:
|
||||
case zeek::TYPE_TIME:
|
||||
val->val.double_val = CurrTime();
|
||||
break;
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_INTERVAL:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
val->val.double_val = random();
|
||||
break;
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
val->val.uint_val = random();
|
||||
break;
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
val->val.port_val.port = random() / (RAND_MAX / 60000);
|
||||
val->val.port_val.proto = TRANSPORT_UNKNOWN;
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
val->val.subnet_val.prefix = ascii->ParseAddr("192.168.17.1");
|
||||
val->val.subnet_val.length = 16;
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
val->val.addr_val = ascii->ParseAddr("192.168.17.1");
|
||||
break;
|
||||
|
||||
case TYPE_TABLE:
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_TABLE:
|
||||
case zeek::TYPE_VECTOR:
|
||||
// First - common initialization
|
||||
// Then - initialization for table.
|
||||
// Then - initialization for vector.
|
||||
|
@ -191,12 +191,12 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
|
|||
|
||||
Value** lvals = new Value* [length];
|
||||
|
||||
if ( type == TYPE_TABLE )
|
||||
if ( type == zeek::TYPE_TABLE )
|
||||
{
|
||||
val->val.set_val.vals = lvals;
|
||||
val->val.set_val.size = length;
|
||||
}
|
||||
else if ( type == TYPE_VECTOR )
|
||||
else if ( type == zeek::TYPE_VECTOR )
|
||||
{
|
||||
val->val.vector_val.vals = lvals;
|
||||
val->val.vector_val.size = length;
|
||||
|
@ -209,7 +209,7 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
|
|||
|
||||
for ( unsigned int pos = 0; pos < length; pos++ )
|
||||
{
|
||||
Value* newval = EntryToVal(subtype, TYPE_ENUM);
|
||||
Value* newval = EntryToVal(subtype, zeek::TYPE_ENUM);
|
||||
if ( newval == nullptr )
|
||||
{
|
||||
Error("Error while reading set");
|
||||
|
@ -251,9 +251,9 @@ bool Benchmark::DoHeartbeat(double network_time, double current_time)
|
|||
{
|
||||
// we have to document at what time we changed the factor to what value.
|
||||
Value** v = new Value*[2];
|
||||
v[0] = new Value(TYPE_COUNT, true);
|
||||
v[0] = new Value(zeek::TYPE_COUNT, true);
|
||||
v[0]->val.uint_val = num_lines;
|
||||
v[1] = new Value(TYPE_TIME, true);
|
||||
v[1] = new Value(zeek::TYPE_TIME, true);
|
||||
v[1]->val.double_val = CurrTime();
|
||||
|
||||
SendEvent("lines_changed", 2, v);
|
||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
|||
private:
|
||||
double CurrTime();
|
||||
std::string RandomString(const int len);
|
||||
threading::Value* EntryToVal(TypeTag Type, TypeTag subtype);
|
||||
threading::Value* EntryToVal(zeek::TypeTag Type, zeek::TypeTag subtype);
|
||||
|
||||
int num_lines;
|
||||
double multiplication_factor;
|
||||
|
|
|
@ -99,7 +99,7 @@ bool Binary::DoInit(const ReaderInfo& info, int num_fields,
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( fields[0]->type != TYPE_STRING )
|
||||
if ( fields[0]->type != zeek::TYPE_STRING )
|
||||
{
|
||||
Error("Filter for binary reader contains a non-string field.");
|
||||
return false;
|
||||
|
@ -241,7 +241,7 @@ bool Binary::DoUpdate()
|
|||
Value** fields = new Value*[1];
|
||||
|
||||
// filter has exactly one text field. convert to it.
|
||||
Value* val = new Value(TYPE_STRING, true);
|
||||
Value* val = new Value(zeek::TYPE_STRING, true);
|
||||
val->val.string_val.data = chunk;
|
||||
val->val.string_val.length = size;
|
||||
fields[0] = val;
|
||||
|
|
|
@ -35,18 +35,18 @@ Config::Config(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
|||
if ( ! id->IsOption() )
|
||||
continue;
|
||||
|
||||
if ( id->GetType()->Tag() == TYPE_RECORD ||
|
||||
if ( id->GetType()->Tag() == zeek::TYPE_RECORD ||
|
||||
! input::Manager::IsCompatibleType(id->GetType().get()) )
|
||||
{
|
||||
option_types[id->Name()] = std::make_tuple(TYPE_ERROR, id->GetType()->Tag());
|
||||
option_types[id->Name()] = std::make_tuple(zeek::TYPE_ERROR, id->GetType()->Tag());
|
||||
continue;
|
||||
}
|
||||
|
||||
TypeTag primary = id->GetType()->Tag();
|
||||
TypeTag secondary = TYPE_VOID;
|
||||
if ( primary == TYPE_TABLE )
|
||||
zeek::TypeTag primary = id->GetType()->Tag();
|
||||
zeek::TypeTag secondary = zeek::TYPE_VOID;
|
||||
if ( primary == zeek::TYPE_TABLE )
|
||||
secondary = id->GetType()->AsSetType()->GetIndices()->GetPureType()->Tag();
|
||||
else if ( primary == TYPE_VECTOR )
|
||||
else if ( primary == zeek::TYPE_VECTOR )
|
||||
secondary = id->GetType()->AsVectorType()->Yield()->Tag();
|
||||
|
||||
option_types[id->Name()] = std::make_tuple(primary, secondary);
|
||||
|
@ -209,9 +209,10 @@ bool Config::DoUpdate()
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( std::get<0>((*typeit).second) == TYPE_ERROR )
|
||||
if ( std::get<0>((*typeit).second) == zeek::TYPE_ERROR )
|
||||
{
|
||||
Warning(Fmt("Option '%s' has type '%s', which is not supported for file input. Ignoring line.", key.c_str(), type_name(std::get<1>((*typeit).second))));
|
||||
Warning(Fmt("Option '%s' has type '%s', which is not supported for file input. Ignoring line.",
|
||||
key.c_str(), zeek::type_name(std::get<1>((*typeit).second))));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -244,11 +245,11 @@ bool Config::DoUpdate()
|
|||
|
||||
{
|
||||
Value** fields = new Value*[2];
|
||||
Value* keyval = new threading::Value(TYPE_STRING, true);
|
||||
Value* keyval = new threading::Value(zeek::TYPE_STRING, true);
|
||||
keyval->val.string_val.length = key.size();
|
||||
keyval->val.string_val.data = copy_string(key.c_str());
|
||||
fields[0] = keyval;
|
||||
Value* val = new threading::Value(TYPE_STRING, true);
|
||||
Value* val = new threading::Value(zeek::TYPE_STRING, true);
|
||||
val->val.string_val.length = value.size();
|
||||
val->val.string_val.data = copy_string(value.c_str());
|
||||
fields[1] = val;
|
||||
|
@ -261,13 +262,13 @@ bool Config::DoUpdate()
|
|||
|
||||
{
|
||||
Value** vals = new Value*[4];
|
||||
vals[0] = new Value(TYPE_STRING, true);
|
||||
vals[0] = new Value(zeek::TYPE_STRING, true);
|
||||
vals[0]->val.string_val.data = copy_string(Info().name);
|
||||
vals[0]->val.string_val.length = strlen(Info().name);
|
||||
vals[1] = new Value(TYPE_STRING, true);
|
||||
vals[1] = new Value(zeek::TYPE_STRING, true);
|
||||
vals[1]->val.string_val.data = copy_string(Info().source);
|
||||
vals[1]->val.string_val.length = strlen(Info().source);
|
||||
vals[2] = new Value(TYPE_STRING, true);
|
||||
vals[2] = new Value(zeek::TYPE_STRING, true);
|
||||
vals[2]->val.string_val.data = copy_string(key.c_str());
|
||||
vals[2]->val.string_val.length = key.size();
|
||||
vals[3] = eventval;
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
std::string empty_field;
|
||||
|
||||
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<zeek::TypeTag, zeek::TypeTag>> option_types;
|
||||
std::unordered_map<std::string, std::string> option_values;
|
||||
};
|
||||
|
||||
|
|
|
@ -396,12 +396,12 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( fields[0]->type != TYPE_STRING )
|
||||
if ( fields[0]->type != zeek::TYPE_STRING )
|
||||
{
|
||||
Error("First field for raw reader always has to be of type string.");
|
||||
return false;
|
||||
}
|
||||
if ( use_stderr && fields[1]->type != TYPE_BOOL )
|
||||
if ( use_stderr && fields[1]->type != zeek::TYPE_BOOL )
|
||||
{
|
||||
Error("Second field for raw reader always has to be of type bool.");
|
||||
return false;
|
||||
|
@ -605,14 +605,14 @@ bool Raw::DoUpdate()
|
|||
Value** fields = new Value*[2]; // just always reserve 2. This means that our [] is too long by a count of 1 if not using stderr. But who cares...
|
||||
|
||||
// filter has exactly one text field. convert to it.
|
||||
Value* val = new Value(TYPE_STRING, true);
|
||||
Value* val = new Value(zeek::TYPE_STRING, true);
|
||||
val->val.string_val.data = outbuf.release();
|
||||
val->val.string_val.length = length;
|
||||
fields[0] = val;
|
||||
|
||||
if ( use_stderr )
|
||||
{
|
||||
Value* bval = new Value(TYPE_BOOL, true);
|
||||
Value* bval = new Value(zeek::TYPE_BOOL, true);
|
||||
bval->val.int_val = 0;
|
||||
fields[1] = bval;
|
||||
}
|
||||
|
@ -633,11 +633,11 @@ bool Raw::DoUpdate()
|
|||
break;
|
||||
|
||||
Value** fields = new Value*[2];
|
||||
Value* val = new Value(TYPE_STRING, true);
|
||||
Value* val = new Value(zeek::TYPE_STRING, true);
|
||||
val->val.string_val.data = outbuf.release();
|
||||
val->val.string_val.length = length;
|
||||
fields[0] = val;
|
||||
Value* bval = new Value(TYPE_BOOL, true);
|
||||
Value* bval = new Value(zeek::TYPE_BOOL, true);
|
||||
bval->val.int_val = 1; // yes, we are stderr
|
||||
fields[1] = bval;
|
||||
|
||||
|
@ -675,15 +675,15 @@ bool Raw::DoUpdate()
|
|||
assert(false);
|
||||
|
||||
Value** vals = new Value*[4];
|
||||
vals[0] = new Value(TYPE_STRING, true);
|
||||
vals[0] = new Value(zeek::TYPE_STRING, true);
|
||||
vals[0]->val.string_val.data = copy_string(Info().name);
|
||||
vals[0]->val.string_val.length = strlen(Info().name);
|
||||
vals[1] = new Value(TYPE_STRING, true);
|
||||
vals[1] = new Value(zeek::TYPE_STRING, true);
|
||||
vals[1]->val.string_val.data = copy_string(Info().source);
|
||||
vals[1]->val.string_val.length = strlen(Info().source);
|
||||
vals[2] = new Value(TYPE_COUNT, true);
|
||||
vals[2] = new Value(zeek::TYPE_COUNT, true);
|
||||
vals[2]->val.int_val = code;
|
||||
vals[3] = new Value(TYPE_BOOL, true);
|
||||
vals[3] = new Value(zeek::TYPE_BOOL, true);
|
||||
vals[3]->val.int_val = signal;
|
||||
|
||||
// and in this case we can signal end_of_data even for the streaming reader
|
||||
|
|
|
@ -136,8 +136,8 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
Value* val = new Value(field->type, true);
|
||||
|
||||
switch ( field->type ) {
|
||||
case TYPE_ENUM:
|
||||
case TYPE_STRING:
|
||||
case zeek::TYPE_ENUM:
|
||||
case zeek::TYPE_STRING:
|
||||
{
|
||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||
int length = sqlite3_column_bytes(st, pos);
|
||||
|
@ -150,7 +150,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
{
|
||||
if ( sqlite3_column_type(st, pos) != SQLITE_INTEGER )
|
||||
{
|
||||
|
@ -172,22 +172,22 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_INT:
|
||||
val->val.int_val = sqlite3_column_int64(st, pos);
|
||||
break;
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_TIME:
|
||||
case TYPE_INTERVAL:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
case zeek::TYPE_TIME:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
val->val.double_val = sqlite3_column_double(st, pos);
|
||||
break;
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
val->val.uint_val = sqlite3_column_int64(st, pos);
|
||||
break;
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
{
|
||||
val->val.port_val.port = sqlite3_column_int(st, pos);
|
||||
val->val.port_val.proto = TRANSPORT_UNKNOWN;
|
||||
|
@ -206,7 +206,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||
|
@ -219,7 +219,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
{
|
||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||
|
@ -227,8 +227,8 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_TABLE:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||
|
@ -281,7 +281,7 @@ bool SQLite::DoUpdate()
|
|||
|
||||
if ( fields[j]->secondary_name != nullptr && strcmp(fields[j]->secondary_name, name) == 0 )
|
||||
{
|
||||
assert(fields[j]->type == TYPE_PORT);
|
||||
assert(fields[j]->type == zeek::TYPE_PORT);
|
||||
if ( submapping[j] != -1 )
|
||||
{
|
||||
Error(Fmt("SQLite statement returns several columns with name %s! Cannot decide which to choose, aborting", name));
|
||||
|
|
|
@ -594,8 +594,8 @@ void Packet::ProcessLayer2()
|
|||
|
||||
IntrusivePtr<RecordVal> Packet::ToRawPktHdrVal() const
|
||||
{
|
||||
static auto raw_pkt_hdr_type = zeek::id::find_type<RecordType>("raw_pkt_hdr");
|
||||
static auto l2_hdr_type = zeek::id::find_type<RecordType>("l2_hdr");
|
||||
static auto raw_pkt_hdr_type = zeek::id::find_type<zeek::RecordType>("raw_pkt_hdr");
|
||||
static auto l2_hdr_type = zeek::id::find_type<zeek::RecordType>("l2_hdr");
|
||||
auto pkt_hdr = make_intrusive<RecordVal>(raw_pkt_hdr_type);
|
||||
auto l2_hdr = make_intrusive<RecordVal>(l2_hdr_type);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ struct Manager::Stream {
|
|||
EnumVal* id;
|
||||
bool enabled;
|
||||
string name;
|
||||
RecordType* columns;
|
||||
zeek::RecordType* columns;
|
||||
EventHandlerPtr event;
|
||||
list<Filter*> filters;
|
||||
|
||||
|
@ -236,7 +236,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
|||
return false;
|
||||
}
|
||||
|
||||
RecordType* columns = sval->GetField("columns")
|
||||
zeek::RecordType* columns = sval->GetField("columns")
|
||||
->AsType()->AsTypeType()->GetType()->AsRecordType();
|
||||
|
||||
bool log_attr_present = false;
|
||||
|
@ -271,7 +271,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
|||
// Make sure the event is prototyped as expected.
|
||||
const auto& etype = event->GetType();
|
||||
|
||||
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
if ( etype->Flavor() != zeek::FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("stream event is a function, not an event");
|
||||
return false;
|
||||
|
@ -386,7 +386,7 @@ bool Manager::DisableStream(EnumVal* id)
|
|||
}
|
||||
|
||||
// Helper for recursive record field unrolling.
|
||||
bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
||||
bool Manager::TraverseRecord(Stream* stream, Filter* filter, zeek::RecordType* rt,
|
||||
TableVal* include, TableVal* exclude, const string& path, const list<int>& indices)
|
||||
{
|
||||
// Only include extensions for the outer record.
|
||||
|
@ -395,7 +395,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
|||
int i = 0;
|
||||
for ( int j = 0; j < num_ext_fields + rt->NumFields(); ++j )
|
||||
{
|
||||
RecordType* rtype;
|
||||
zeek::RecordType* rtype;
|
||||
// If this is an ext field, set the rtype appropriately
|
||||
if ( j < num_ext_fields )
|
||||
{
|
||||
|
@ -429,9 +429,9 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
|||
if ( j < num_ext_fields )
|
||||
new_path = filter->ext_prefix + new_path;
|
||||
|
||||
if ( t->InternalType() == TYPE_INTERNAL_OTHER )
|
||||
if ( t->InternalType() == zeek::TYPE_INTERNAL_OTHER )
|
||||
{
|
||||
if ( t->Tag() == TYPE_RECORD )
|
||||
if ( t->Tag() == zeek::TYPE_RECORD )
|
||||
{
|
||||
// Recurse.
|
||||
if ( ! TraverseRecord(stream, filter,
|
||||
|
@ -445,23 +445,23 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
|||
continue;
|
||||
}
|
||||
|
||||
else if ( t->Tag() == TYPE_TABLE &&
|
||||
else if ( t->Tag() == zeek::TYPE_TABLE &&
|
||||
t->AsTableType()->IsSet() )
|
||||
{
|
||||
// That's ok, we handle it below.
|
||||
}
|
||||
|
||||
else if ( t->Tag() == TYPE_VECTOR )
|
||||
else if ( t->Tag() == zeek::TYPE_VECTOR )
|
||||
{
|
||||
// That's ok, we handle it below.
|
||||
}
|
||||
|
||||
else if ( t->Tag() == TYPE_FILE )
|
||||
else if ( t->Tag() == zeek::TYPE_FILE )
|
||||
{
|
||||
// That's ok, we handle it below.
|
||||
}
|
||||
|
||||
else if ( t->Tag() == TYPE_FUNC )
|
||||
else if ( t->Tag() == zeek::TYPE_FUNC )
|
||||
{
|
||||
// That's ok, we handle it below.
|
||||
}
|
||||
|
@ -509,12 +509,12 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
|||
++filter->num_fields;
|
||||
filter->fields = (threading::Field**) tmp;
|
||||
|
||||
TypeTag st = TYPE_VOID;
|
||||
zeek::TypeTag st = zeek::TYPE_VOID;
|
||||
|
||||
if ( t->Tag() == TYPE_TABLE )
|
||||
if ( t->Tag() == zeek::TYPE_TABLE )
|
||||
st = t->AsSetType()->GetIndices()->GetPureType()->Tag();
|
||||
|
||||
else if ( t->Tag() == TYPE_VECTOR )
|
||||
else if ( t->Tag() == zeek::TYPE_VECTOR )
|
||||
st = t->AsVectorType()->Yield()->Tag();
|
||||
|
||||
bool optional = (bool)rtype->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL);
|
||||
|
@ -580,18 +580,19 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
filter->num_ext_fields = 0;
|
||||
if ( filter->ext_func )
|
||||
{
|
||||
if ( filter->ext_func->GetType()->Yield()->Tag() == TYPE_RECORD )
|
||||
if ( filter->ext_func->GetType()->Yield()->Tag() == zeek::TYPE_RECORD )
|
||||
{
|
||||
filter->num_ext_fields = filter->ext_func->GetType()->Yield()->AsRecordType()->NumFields();
|
||||
}
|
||||
else if ( filter->ext_func->GetType()->Yield()->Tag() == TYPE_VOID )
|
||||
else if ( filter->ext_func->GetType()->Yield()->Tag() == zeek::TYPE_VOID )
|
||||
{
|
||||
// This is a special marker for the default no-implementation
|
||||
// of the ext_func and we'll allow it to slide.
|
||||
}
|
||||
else
|
||||
{
|
||||
reporter->Error("Return value of log_ext is not a record (got %s)", type_name(filter->ext_func->GetType()->Yield()->Tag()));
|
||||
reporter->Error("Return value of log_ext is not a record (got %s)",
|
||||
zeek::type_name(filter->ext_func->GetType()->Yield()->Tag()));
|
||||
delete filter;
|
||||
return false;
|
||||
}
|
||||
|
@ -646,7 +647,7 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
{
|
||||
threading::Field* field = filter->fields[i];
|
||||
DBG_LOG(DBG_LOGGING, " field %10s: %s",
|
||||
field->name, type_name(field->type));
|
||||
field->name, zeek::type_name(field->type));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -739,8 +740,8 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
|
|||
IntrusivePtr<Val> rec_arg;
|
||||
const auto& rt = filter->path_func->GetType()->Params()->GetFieldType("rec");
|
||||
|
||||
if ( rt->Tag() == TYPE_RECORD )
|
||||
rec_arg = columns->CoerceTo(cast_intrusive<RecordType>(rt), true);
|
||||
if ( rt->Tag() == zeek::TYPE_RECORD )
|
||||
rec_arg = columns->CoerceTo(cast_intrusive<zeek::RecordType>(rt), true);
|
||||
else
|
||||
// Can be TYPE_ANY here.
|
||||
rec_arg = columns;
|
||||
|
@ -752,7 +753,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
|
|||
if ( ! v )
|
||||
return false;
|
||||
|
||||
if ( v->GetType()->Tag() != TYPE_STRING )
|
||||
if ( v->GetType()->Tag() != zeek::TYPE_STRING )
|
||||
{
|
||||
reporter->Error("path_func did not return string");
|
||||
return false;
|
||||
|
@ -912,7 +913,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
|
|||
return true;
|
||||
}
|
||||
|
||||
threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
||||
threading::Value* Manager::ValToLogVal(Val* val, zeek::BroType* ty)
|
||||
{
|
||||
if ( ! ty )
|
||||
ty = val->GetType().get();
|
||||
|
@ -923,12 +924,12 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
|||
threading::Value* lval = new threading::Value(ty->Tag());
|
||||
|
||||
switch ( lval->type ) {
|
||||
case TYPE_BOOL:
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_BOOL:
|
||||
case zeek::TYPE_INT:
|
||||
lval->val.int_val = val->InternalInt();
|
||||
break;
|
||||
|
||||
case TYPE_ENUM:
|
||||
case zeek::TYPE_ENUM:
|
||||
{
|
||||
const char* s =
|
||||
val->GetType()->AsEnumType()->Lookup(val->InternalInt());
|
||||
|
@ -948,31 +949,31 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
lval->val.uint_val = val->InternalUnsigned();
|
||||
break;
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
lval->val.port_val.port = val->AsPortVal()->Port();
|
||||
lval->val.port_val.proto = val->AsPortVal()->PortType();
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
val->AsSubNet().ConvertToThreadingValue(&lval->val.subnet_val);
|
||||
break;
|
||||
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
val->AsAddr().ConvertToThreadingValue(&lval->val.addr_val);
|
||||
break;
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_TIME:
|
||||
case TYPE_INTERVAL:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
case zeek::TYPE_TIME:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
lval->val.double_val = val->InternalDouble();
|
||||
break;
|
||||
|
||||
case TYPE_STRING:
|
||||
case zeek::TYPE_STRING:
|
||||
{
|
||||
const BroString* s = val->AsString();
|
||||
char* buf = new char[s->Len()];
|
||||
|
@ -983,7 +984,7 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_FILE:
|
||||
case zeek::TYPE_FILE:
|
||||
{
|
||||
const BroFile* f = val->AsFile();
|
||||
string s = f->Name();
|
||||
|
@ -992,7 +993,7 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_FUNC:
|
||||
{
|
||||
ODesc d;
|
||||
const Func* f = val->AsFunc();
|
||||
|
@ -1003,13 +1004,13 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
auto set = val->AsTableVal()->ToPureListVal();
|
||||
if ( ! set )
|
||||
// ToPureListVal has reported an internal warning
|
||||
// already. Just keep going by making something up.
|
||||
set = make_intrusive<ListVal>(TYPE_INT);
|
||||
set = make_intrusive<ListVal>(zeek::TYPE_INT);
|
||||
|
||||
lval->val.set_val.size = set->Length();
|
||||
lval->val.set_val.vals = new threading::Value* [lval->val.set_val.size];
|
||||
|
@ -1020,7 +1021,7 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
VectorVal* vec = val->AsVectorVal();
|
||||
lval->val.vector_val.size = vec->Size();
|
||||
|
@ -1038,7 +1039,7 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
|
|||
}
|
||||
|
||||
default:
|
||||
reporter->InternalError("unsupported type %s for log_write", type_name(lval->type));
|
||||
reporter->InternalError("unsupported type %s for log_write", zeek::type_name(lval->type));
|
||||
}
|
||||
|
||||
return lval;
|
||||
|
@ -1372,7 +1373,7 @@ bool Manager::RemoteLogsAreEnabled(EnumVal* stream_id)
|
|||
return stream->enable_remote;
|
||||
}
|
||||
|
||||
RecordType* Manager::StreamColumns(EnumVal* stream_id)
|
||||
zeek::RecordType* Manager::StreamColumns(EnumVal* stream_id)
|
||||
{
|
||||
auto stream = FindStream(stream_id);
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ public:
|
|||
* @return the type which corresponds to the columns in a log entry for
|
||||
* a given log stream.
|
||||
*/
|
||||
RecordType* StreamColumns(EnumVal* stream_id);
|
||||
zeek::RecordType* StreamColumns(EnumVal* stream_id);
|
||||
|
||||
protected:
|
||||
friend class WriterFrontend;
|
||||
|
@ -255,13 +255,13 @@ private:
|
|||
struct Stream;
|
||||
struct WriterInfo;
|
||||
|
||||
bool TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
||||
bool TraverseRecord(Stream* stream, Filter* filter, zeek::RecordType* rt,
|
||||
TableVal* include, TableVal* exclude, const std::string& path, const std::list<int>& indices);
|
||||
|
||||
threading::Value** RecordToFilterVals(Stream* stream, Filter* filter,
|
||||
RecordVal* columns);
|
||||
|
||||
threading::Value* ValToLogVal(Val* val, BroType* ty = nullptr);
|
||||
threading::Value* ValToLogVal(Val* val, zeek::BroType* ty = nullptr);
|
||||
Stream* FindStream(EnumVal* id);
|
||||
void RemoveDisabledWriters(Stream* stream);
|
||||
void InstallRotationTimer(WriterInfo* winfo);
|
||||
|
|
|
@ -35,7 +35,7 @@ bool None::DoInit(const WriterInfo& info, int num_fields,
|
|||
{
|
||||
const threading::Field* field = fields[i];
|
||||
std::cout << " field " << field->name << ": "
|
||||
<< type_name(field->type) << std::endl;
|
||||
<< zeek::type_name(field->type) << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
@ -54,5 +54,3 @@ bool None::DoRotate(const char* rotated_path, double open, double close, bool te
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,37 +58,37 @@ string SQLite::GetTableType(int arg_type, int arg_subtype) {
|
|||
string type;
|
||||
|
||||
switch ( arg_type ) {
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
type = "boolean";
|
||||
break;
|
||||
|
||||
case TYPE_INT:
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case TYPE_PORT: // note that we do not save the protocol at the moment. Just like in the case of the ascii-writer
|
||||
case zeek::TYPE_INT:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
case zeek::TYPE_PORT: // note that we do not save the protocol at the moment. Just like in the case of the ascii-writer
|
||||
type = "integer";
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_SUBNET:
|
||||
case zeek::TYPE_ADDR:
|
||||
type = "text"; // sqlite3 does not have a type for internet addresses
|
||||
break;
|
||||
|
||||
case TYPE_TIME:
|
||||
case TYPE_INTERVAL:
|
||||
case TYPE_DOUBLE:
|
||||
case zeek::TYPE_TIME:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
type = "double precision";
|
||||
break;
|
||||
|
||||
case TYPE_ENUM:
|
||||
case TYPE_STRING:
|
||||
case TYPE_FILE:
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_ENUM:
|
||||
case zeek::TYPE_STRING:
|
||||
case zeek::TYPE_FILE:
|
||||
case zeek::TYPE_FUNC:
|
||||
type = "text";
|
||||
break;
|
||||
|
||||
case TYPE_TABLE:
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_TABLE:
|
||||
case zeek::TYPE_VECTOR:
|
||||
type = "text"; // dirty - but sqlite does not directly support arrays. so - we just roll it into a ","-separated string.
|
||||
break;
|
||||
|
||||
|
@ -243,40 +243,40 @@ int SQLite::AddParams(Value* val, int pos)
|
|||
return sqlite3_bind_null(st, pos);
|
||||
|
||||
switch ( val->type ) {
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
return sqlite3_bind_int(st, pos, val->val.int_val != 0 ? 1 : 0 );
|
||||
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_INT:
|
||||
return sqlite3_bind_int(st, pos, val->val.int_val);
|
||||
|
||||
case TYPE_COUNT:
|
||||
case TYPE_COUNTER:
|
||||
case zeek::TYPE_COUNT:
|
||||
case zeek::TYPE_COUNTER:
|
||||
return sqlite3_bind_int(st, pos, val->val.uint_val);
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
return sqlite3_bind_int(st, pos, val->val.port_val.port);
|
||||
|
||||
case TYPE_SUBNET:
|
||||
case zeek::TYPE_SUBNET:
|
||||
{
|
||||
string out = io->Render(val->val.subnet_val);
|
||||
return sqlite3_bind_text(st, pos, out.data(), out.size(), SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
case TYPE_ADDR:
|
||||
case zeek::TYPE_ADDR:
|
||||
{
|
||||
string out = io->Render(val->val.addr_val);
|
||||
return sqlite3_bind_text(st, pos, out.data(), out.size(), SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
case TYPE_TIME:
|
||||
case TYPE_INTERVAL:
|
||||
case TYPE_DOUBLE:
|
||||
case zeek::TYPE_TIME:
|
||||
case zeek::TYPE_INTERVAL:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
return sqlite3_bind_double(st, pos, val->val.double_val);
|
||||
|
||||
case TYPE_ENUM:
|
||||
case TYPE_STRING:
|
||||
case TYPE_FILE:
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_ENUM:
|
||||
case zeek::TYPE_STRING:
|
||||
case zeek::TYPE_FILE:
|
||||
case zeek::TYPE_FUNC:
|
||||
{
|
||||
if ( ! val->val.string_val.length || val->val.string_val.length == 0 )
|
||||
return sqlite3_bind_null(st, pos);
|
||||
|
@ -284,7 +284,7 @@ int SQLite::AddParams(Value* val, int pos)
|
|||
return sqlite3_bind_text(st, pos, val->val.string_val.data, val->val.string_val.length, SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
{
|
||||
ODesc desc;
|
||||
desc.Clear();
|
||||
|
@ -306,7 +306,7 @@ int SQLite::AddParams(Value* val, int pos)
|
|||
return sqlite3_bind_text(st, pos, (const char*) desc.Bytes(), desc.Len(), SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
ODesc desc;
|
||||
desc.Clear();
|
||||
|
@ -367,4 +367,3 @@ bool SQLite::DoRotate(const char* rotated_path, double open, double close, bool
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ function Option::set_change_handler%(ID: string, on_change: any, priority: int &
|
|||
return val_mgr->False();
|
||||
}
|
||||
|
||||
if ( on_change->GetType()->AsFuncType()->Flavor() != FUNC_FLAVOR_FUNCTION )
|
||||
if ( on_change->GetType()->AsFuncType()->Flavor() != zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
builtin_error("Option::on_change needs function argument; not hook or event");
|
||||
return val_mgr->False();
|
||||
|
|
152
src/parse.y
152
src/parse.y
|
@ -135,16 +135,16 @@ bool defining_global_ID = false;
|
|||
std::vector<int> saved_in_init;
|
||||
|
||||
static Location func_hdr_location;
|
||||
EnumType *cur_enum_type = 0;
|
||||
static zeek::detail::ID* cur_decl_type_id = 0;
|
||||
zeek::EnumType* cur_enum_type = nullptr;
|
||||
static zeek::detail::ID* cur_decl_type_id = nullptr;
|
||||
|
||||
static void parser_new_enum (void)
|
||||
{
|
||||
/* Starting a new enum definition. */
|
||||
assert(cur_enum_type == NULL);
|
||||
assert(cur_enum_type == nullptr);
|
||||
|
||||
if ( cur_decl_type_id )
|
||||
cur_enum_type = new EnumType(cur_decl_type_id->Name());
|
||||
cur_enum_type = new zeek::EnumType(cur_decl_type_id->Name());
|
||||
else
|
||||
reporter->FatalError("incorrect syntax for enum type declaration");
|
||||
}
|
||||
|
@ -153,23 +153,23 @@ static void parser_redef_enum (zeek::detail::ID *id)
|
|||
{
|
||||
/* Redef an enum. id points to the enum to be redefined.
|
||||
Let cur_enum_type point to it. */
|
||||
assert(cur_enum_type == NULL);
|
||||
assert(cur_enum_type == nullptr);
|
||||
|
||||
// abort on errors; enums need to be accessible to continue parsing
|
||||
if ( ! id->GetType() )
|
||||
reporter->FatalError("unknown enum identifier \"%s\"", id->Name());
|
||||
else
|
||||
{
|
||||
if ( ! id->GetType() || id->GetType()->Tag() != TYPE_ENUM )
|
||||
if ( ! id->GetType() || id->GetType()->Tag() != zeek::TYPE_ENUM )
|
||||
reporter->FatalError("identifier \"%s\" is not an enum", id->Name());
|
||||
cur_enum_type = id->GetType()->AsEnumType();
|
||||
}
|
||||
}
|
||||
|
||||
static void extend_record(zeek::detail::ID* id, std::unique_ptr<type_decl_list> fields,
|
||||
static void extend_record(zeek::detail::ID* id, std::unique_ptr<zeek::type_decl_list> fields,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs)
|
||||
{
|
||||
std::set<BroType*> types = BroType::GetAliases(id->Name());
|
||||
std::set<zeek::BroType*> types = zeek::BroType::GetAliases(id->Name());
|
||||
|
||||
if ( types.empty() )
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ static void extend_record(zeek::detail::ID* id, std::unique_ptr<type_decl_list>
|
|||
|
||||
static IntrusivePtr<zeek::detail::Attributes>
|
||||
make_attributes(std::vector<IntrusivePtr<zeek::detail::Attr>>* attrs,
|
||||
IntrusivePtr<BroType> t, bool in_record, bool is_global)
|
||||
IntrusivePtr<zeek::BroType> t, bool in_record, bool is_global)
|
||||
{
|
||||
if ( ! attrs )
|
||||
return nullptr;
|
||||
|
@ -222,7 +222,7 @@ static bool expr_is_table_type_name(const zeek::detail::Expr* expr)
|
|||
if ( type->IsTable() )
|
||||
return true;
|
||||
|
||||
if ( type->Tag() == TYPE_TYPE )
|
||||
if ( type->Tag() == zeek::TYPE_TYPE )
|
||||
return type->AsTypeType()->GetType()->IsTable();
|
||||
|
||||
return false;
|
||||
|
@ -241,12 +241,12 @@ static bool expr_is_table_type_name(const zeek::detail::Expr* expr)
|
|||
zeek::detail::EventExpr* event_expr;
|
||||
zeek::detail::Stmt* stmt;
|
||||
zeek::detail::ListExpr* list;
|
||||
BroType* type;
|
||||
RecordType* record;
|
||||
FuncType* func_type;
|
||||
TypeList* type_l;
|
||||
TypeDecl* type_decl;
|
||||
type_decl_list* type_decl_l;
|
||||
zeek::BroType* type;
|
||||
zeek::RecordType* record;
|
||||
zeek::FuncType* func_type;
|
||||
zeek::TypeList* type_l;
|
||||
zeek::TypeDecl* type_decl;
|
||||
zeek::type_decl_list* type_decl_l;
|
||||
zeek::detail::Case* c_case;
|
||||
zeek::detail::case_list* case_l;
|
||||
zeek::detail::Attr* attr;
|
||||
|
@ -498,7 +498,7 @@ expr:
|
|||
auto func_id = current_scope()->GenerateTemporary("anonymous-function");
|
||||
func_id->SetInferReturnType(true);
|
||||
begin_func(std::move(func_id), current_module.c_str(),
|
||||
FUNC_FLAVOR_FUNCTION, false,
|
||||
zeek::FUNC_FLAVOR_FUNCTION, false,
|
||||
{AdoptRef{}, $3});
|
||||
}
|
||||
lambda_body
|
||||
|
@ -600,16 +600,16 @@ expr:
|
|||
const auto& ctor_type = $1->AsNameExpr()->Id()->GetType();
|
||||
|
||||
switch ( ctor_type->Tag() ) {
|
||||
case TYPE_RECORD:
|
||||
case zeek::TYPE_RECORD:
|
||||
{
|
||||
auto rce = make_intrusive<zeek::detail::RecordConstructorExpr>(
|
||||
IntrusivePtr<zeek::detail::ListExpr>{AdoptRef{}, $4});
|
||||
auto rt = cast_intrusive<RecordType>(ctor_type);
|
||||
auto rt = cast_intrusive<zeek::RecordType>(ctor_type);
|
||||
$$ = new zeek::detail::RecordCoerceExpr(std::move(rce), std::move(rt));
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
if ( ctor_type->IsTable() )
|
||||
$$ = new zeek::detail::TableConstructorExpr({AdoptRef{}, $4}, 0, ctor_type);
|
||||
else
|
||||
|
@ -617,7 +617,7 @@ expr:
|
|||
|
||||
break;
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
$$ = new zeek::detail::VectorConstructorExpr({AdoptRef{}, $4}, ctor_type);
|
||||
break;
|
||||
|
||||
|
@ -686,13 +686,13 @@ expr:
|
|||
if ( ! id->GetType() )
|
||||
{
|
||||
id->Error("undeclared variable");
|
||||
id->SetType(error_type());
|
||||
id->SetType(zeek::error_type());
|
||||
$$ = new zeek::detail::NameExpr(std::move(id));
|
||||
}
|
||||
|
||||
else if ( id->IsEnumConst() )
|
||||
{
|
||||
EnumType* t = id->GetType()->AsEnumType();
|
||||
zeek::EnumType* t = id->GetType()->AsEnumType();
|
||||
int intval = t->Lookup(id->ModuleName(),
|
||||
id->Name());
|
||||
if ( intval < 0 )
|
||||
|
@ -731,8 +731,8 @@ expr:
|
|||
set_location(@1, @3);
|
||||
IntrusivePtr<zeek::detail::Expr> e{AdoptRef{}, $2};
|
||||
|
||||
if ( IsIntegral(e->GetType()->Tag()) )
|
||||
e = make_intrusive<zeek::detail::ArithCoerceExpr>(std::move(e), TYPE_INT);
|
||||
if ( zeek::IsIntegral(e->GetType()->Tag()) )
|
||||
e = make_intrusive<zeek::detail::ArithCoerceExpr>(std::move(e), zeek::TYPE_INT);
|
||||
|
||||
$$ = new zeek::detail::SizeExpr(std::move(e));
|
||||
}
|
||||
|
@ -774,13 +774,13 @@ enum_body:
|
|||
enum_body_list
|
||||
{
|
||||
$$ = cur_enum_type;
|
||||
cur_enum_type = NULL;
|
||||
cur_enum_type = nullptr;
|
||||
}
|
||||
|
||||
| enum_body_list ','
|
||||
{
|
||||
$$ = cur_enum_type;
|
||||
cur_enum_type = NULL;
|
||||
cur_enum_type = nullptr;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -801,7 +801,7 @@ enum_body_elem:
|
|||
set_location(@1, @3);
|
||||
assert(cur_enum_type);
|
||||
|
||||
if ( $3->GetType()->Tag() != TYPE_COUNT )
|
||||
if ( $3->GetType()->Tag() != zeek::TYPE_COUNT )
|
||||
reporter->Error("enumerator is not a count constant");
|
||||
else
|
||||
cur_enum_type->AddName(current_module, $1,
|
||||
|
@ -828,84 +828,84 @@ enum_body_elem:
|
|||
type:
|
||||
TOK_BOOL {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_BOOL)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_BOOL)->Ref();
|
||||
}
|
||||
|
||||
| TOK_INT {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_INT)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_INT)->Ref();
|
||||
}
|
||||
|
||||
| TOK_COUNT {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_COUNT)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_COUNT)->Ref();
|
||||
}
|
||||
|
||||
| TOK_COUNTER {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_COUNTER)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_COUNTER)->Ref();
|
||||
}
|
||||
|
||||
| TOK_DOUBLE {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_DOUBLE)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_DOUBLE)->Ref();
|
||||
}
|
||||
|
||||
| TOK_TIME {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_TIME)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_TIME)->Ref();
|
||||
}
|
||||
|
||||
| TOK_INTERVAL {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_INTERVAL)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_INTERVAL)->Ref();
|
||||
}
|
||||
|
||||
| TOK_STRING {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_STRING)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_STRING)->Ref();
|
||||
}
|
||||
|
||||
| TOK_PATTERN {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_PATTERN)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_PATTERN)->Ref();
|
||||
}
|
||||
|
||||
| TOK_TIMER {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_TIMER)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_TIMER)->Ref();
|
||||
}
|
||||
|
||||
| TOK_PORT {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_PORT)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_PORT)->Ref();
|
||||
}
|
||||
|
||||
| TOK_ADDR {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_ADDR)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_ADDR)->Ref();
|
||||
}
|
||||
|
||||
| TOK_SUBNET {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_SUBNET)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_SUBNET)->Ref();
|
||||
}
|
||||
|
||||
| TOK_ANY {
|
||||
set_location(@1);
|
||||
$$ = base_type(TYPE_ANY)->Ref();
|
||||
$$ = zeek::base_type(zeek::TYPE_ANY)->Ref();
|
||||
}
|
||||
|
||||
| TOK_TABLE '[' type_list ']' TOK_OF type
|
||||
{
|
||||
set_location(@1, @6);
|
||||
$$ = new TableType({AdoptRef{}, $3}, {AdoptRef{}, $6});
|
||||
$$ = new zeek::TableType({AdoptRef{}, $3}, {AdoptRef{}, $6});
|
||||
}
|
||||
|
||||
| TOK_SET '[' type_list ']'
|
||||
{
|
||||
set_location(@1, @4);
|
||||
$$ = new SetType({AdoptRef{}, $3}, nullptr);
|
||||
$$ = new zeek::SetType({AdoptRef{}, $3}, nullptr);
|
||||
}
|
||||
|
||||
| TOK_RECORD '{'
|
||||
|
@ -915,7 +915,7 @@ type:
|
|||
'}'
|
||||
{
|
||||
set_location(@1, @5);
|
||||
$$ = new RecordType($4);
|
||||
$$ = new zeek::RecordType($4);
|
||||
}
|
||||
|
||||
| TOK_UNION '{' type_list '}'
|
||||
|
@ -951,7 +951,7 @@ type:
|
|||
| TOK_VECTOR TOK_OF type
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new VectorType({AdoptRef{}, $3});
|
||||
$$ = new zeek::VectorType({AdoptRef{}, $3});
|
||||
}
|
||||
|
||||
| TOK_FUNCTION func_params
|
||||
|
@ -963,31 +963,31 @@ type:
|
|||
| TOK_EVENT '(' formal_args ')'
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new FuncType({AdoptRef{}, $3}, nullptr, FUNC_FLAVOR_EVENT);
|
||||
$$ = new zeek::FuncType({AdoptRef{}, $3}, nullptr, zeek::FUNC_FLAVOR_EVENT);
|
||||
}
|
||||
|
||||
| TOK_HOOK '(' formal_args ')'
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new FuncType({AdoptRef{}, $3}, base_type(TYPE_BOOL), FUNC_FLAVOR_HOOK);
|
||||
$$ = new zeek::FuncType({AdoptRef{}, $3}, zeek::base_type(zeek::TYPE_BOOL), zeek::FUNC_FLAVOR_HOOK);
|
||||
}
|
||||
|
||||
| TOK_FILE TOK_OF type
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new FileType({AdoptRef{}, $3});
|
||||
$$ = new zeek::FileType({AdoptRef{}, $3});
|
||||
}
|
||||
|
||||
| TOK_FILE
|
||||
{
|
||||
set_location(@1);
|
||||
$$ = new FileType(base_type(TYPE_STRING));
|
||||
$$ = new zeek::FileType(zeek::base_type(zeek::TYPE_STRING));
|
||||
}
|
||||
|
||||
| TOK_OPAQUE TOK_OF TOK_ID
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new OpaqueType($3);
|
||||
$$ = new zeek::OpaqueType($3);
|
||||
}
|
||||
|
||||
| resolve_id
|
||||
|
@ -997,7 +997,7 @@ type:
|
|||
zeek::detail::NullStmt here;
|
||||
if ( $1 )
|
||||
$1->Error("not a Zeek type", &here);
|
||||
$$ = error_type()->Ref();
|
||||
$$ = zeek::error_type()->Ref();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1014,7 +1014,7 @@ type_list:
|
|||
{ $1->AppendEvenIfNotPure({AdoptRef{}, $3}); }
|
||||
| type
|
||||
{
|
||||
$$ = new TypeList({NewRef{}, $1});
|
||||
$$ = new zeek::TypeList({NewRef{}, $1});
|
||||
$$->Append({AdoptRef{}, $1});
|
||||
}
|
||||
;
|
||||
|
@ -1026,7 +1026,7 @@ type_decl_list:
|
|||
}
|
||||
|
|
||||
{
|
||||
$$ = new type_decl_list();
|
||||
$$ = new zeek::type_decl_list();
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ type_decl:
|
|||
{
|
||||
set_location(@1, @4);
|
||||
auto attrs = make_attributes($4, {NewRef{}, $3}, in_record > 0, false);
|
||||
$$ = new TypeDecl($1, {AdoptRef{}, $3}, std::move(attrs));
|
||||
$$ = new zeek::TypeDecl($1, {AdoptRef{}, $3}, std::move(attrs));
|
||||
|
||||
if ( in_record > 0 && cur_decl_type_id )
|
||||
zeekygen_mgr->RecordField(cur_decl_type_id, $$, ::filename);
|
||||
|
@ -1044,11 +1044,11 @@ type_decl:
|
|||
|
||||
formal_args:
|
||||
formal_args_decl_list
|
||||
{ $$ = new RecordType($1); }
|
||||
{ $$ = new zeek::RecordType($1); }
|
||||
| formal_args_decl_list ';'
|
||||
{ $$ = new RecordType($1); }
|
||||
{ $$ = new zeek::RecordType($1); }
|
||||
|
|
||||
{ $$ = new RecordType(new type_decl_list()); }
|
||||
{ $$ = new zeek::RecordType(new zeek::type_decl_list()); }
|
||||
;
|
||||
|
||||
formal_args_decl_list:
|
||||
|
@ -1057,7 +1057,7 @@ formal_args_decl_list:
|
|||
| formal_args_decl_list ',' formal_args_decl
|
||||
{ $1->push_back($3); }
|
||||
| formal_args_decl
|
||||
{ $$ = new type_decl_list(); $$->push_back($1); }
|
||||
{ $$ = new zeek::type_decl_list(); $$->push_back($1); }
|
||||
;
|
||||
|
||||
formal_args_decl:
|
||||
|
@ -1065,7 +1065,7 @@ formal_args_decl:
|
|||
{
|
||||
set_location(@1, @4);
|
||||
auto attrs = make_attributes($4, {NewRef{}, $3}, true, false);
|
||||
$$ = new TypeDecl($1, {AdoptRef{}, $3}, std::move(attrs));
|
||||
$$ = new zeek::TypeDecl($1, {AdoptRef{}, $3}, std::move(attrs));
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1136,7 +1136,7 @@ decl:
|
|||
if ( ! $3->GetType() )
|
||||
$3->Error("unknown identifier");
|
||||
else
|
||||
extend_record($3, std::unique_ptr<type_decl_list>($8),
|
||||
extend_record($3, std::unique_ptr<zeek::type_decl_list>($8),
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>($11));
|
||||
}
|
||||
|
||||
|
@ -1180,7 +1180,7 @@ func_hdr:
|
|||
{
|
||||
IntrusivePtr id{AdoptRef{}, $2};
|
||||
begin_func(id, current_module.c_str(),
|
||||
FUNC_FLAVOR_FUNCTION, 0, {NewRef{}, $3},
|
||||
zeek::FUNC_FLAVOR_FUNCTION, 0, {NewRef{}, $3},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$4});
|
||||
$$ = $3;
|
||||
zeekygen_mgr->Identifier(std::move(id));
|
||||
|
@ -1195,23 +1195,23 @@ func_hdr:
|
|||
}
|
||||
|
||||
begin_func({NewRef{}, $2}, current_module.c_str(),
|
||||
FUNC_FLAVOR_EVENT, 0, {NewRef{}, $3},
|
||||
zeek::FUNC_FLAVOR_EVENT, 0, {NewRef{}, $3},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$4});
|
||||
$$ = $3;
|
||||
}
|
||||
| TOK_HOOK def_global_id func_params opt_attr
|
||||
{
|
||||
$3->ClearYieldType(FUNC_FLAVOR_HOOK);
|
||||
$3->SetYieldType(base_type(TYPE_BOOL));
|
||||
$3->ClearYieldType(zeek::FUNC_FLAVOR_HOOK);
|
||||
$3->SetYieldType(zeek::base_type(zeek::TYPE_BOOL));
|
||||
begin_func({NewRef{}, $2}, current_module.c_str(),
|
||||
FUNC_FLAVOR_HOOK, 0, {NewRef{}, $3},
|
||||
zeek::FUNC_FLAVOR_HOOK, 0, {NewRef{}, $3},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$4});
|
||||
$$ = $3;
|
||||
}
|
||||
| TOK_REDEF TOK_EVENT event_id func_params opt_attr
|
||||
{
|
||||
begin_func({NewRef{}, $3}, current_module.c_str(),
|
||||
FUNC_FLAVOR_EVENT, 1, {NewRef{}, $4},
|
||||
zeek::FUNC_FLAVOR_EVENT, 1, {NewRef{}, $4},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$5});
|
||||
$$ = $4;
|
||||
}
|
||||
|
@ -1275,16 +1275,16 @@ begin_func:
|
|||
func_params
|
||||
{
|
||||
auto id = current_scope()->GenerateTemporary("anonymous-function");
|
||||
begin_func(id, current_module.c_str(), FUNC_FLAVOR_FUNCTION, 0, {AdoptRef{}, $1});
|
||||
begin_func(id, current_module.c_str(), zeek::FUNC_FLAVOR_FUNCTION, 0, {AdoptRef{}, $1});
|
||||
$$ = id.release();
|
||||
}
|
||||
;
|
||||
|
||||
func_params:
|
||||
'(' formal_args ')' ':' type
|
||||
{ $$ = new FuncType({AdoptRef{}, $2}, {AdoptRef{}, $5}, FUNC_FLAVOR_FUNCTION); }
|
||||
{ $$ = new zeek::FuncType({AdoptRef{}, $2}, {AdoptRef{}, $5}, zeek::FUNC_FLAVOR_FUNCTION); }
|
||||
| '(' formal_args ')'
|
||||
{ $$ = new FuncType({AdoptRef{}, $2}, base_type(TYPE_VOID), FUNC_FLAVOR_FUNCTION); }
|
||||
{ $$ = new zeek::FuncType({AdoptRef{}, $2}, zeek::base_type(zeek::TYPE_VOID), zeek::FUNC_FLAVOR_FUNCTION); }
|
||||
;
|
||||
|
||||
opt_type:
|
||||
|
@ -1328,7 +1328,7 @@ index_slice:
|
|||
make_intrusive<zeek::detail::SizeExpr>(
|
||||
IntrusivePtr<zeek::detail::Expr>{NewRef{}, $1});
|
||||
|
||||
if ( ! IsIntegral(low->GetType()->Tag()) || ! IsIntegral(high->GetType()->Tag()) )
|
||||
if ( ! zeek::IsIntegral(low->GetType()->Tag()) || ! zeek::IsIntegral(high->GetType()->Tag()) )
|
||||
reporter->Error("slice notation must have integral values as indexes");
|
||||
|
||||
auto le = make_intrusive<zeek::detail::ListExpr>(std::move(low));
|
||||
|
@ -1387,7 +1387,7 @@ attr:
|
|||
{ $$ = new zeek::detail::Attr(zeek::detail::ATTR_DEPRECATED); }
|
||||
| TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
|
||||
{
|
||||
if ( IsString($3->GetType()->Tag()) )
|
||||
if ( zeek::IsString($3->GetType()->Tag()) )
|
||||
$$ = new zeek::detail::Attr(
|
||||
zeek::detail::ATTR_DEPRECATED,
|
||||
make_intrusive<zeek::detail::ConstExpr>(IntrusivePtr{AdoptRef{}, $3}));
|
||||
|
@ -1667,7 +1667,7 @@ case_type:
|
|||
| TOK_TYPE type TOK_AS TOK_ID
|
||||
{
|
||||
const char* name = $4;
|
||||
IntrusivePtr<BroType> type{AdoptRef{}, $2};
|
||||
IntrusivePtr<zeek::BroType> type{AdoptRef{}, $2};
|
||||
auto case_var = lookup_ID(name, current_module.c_str());
|
||||
|
||||
if ( case_var && case_var->IsGlobal() )
|
||||
|
@ -1831,8 +1831,8 @@ global_or_event_id:
|
|||
{
|
||||
const auto& t = $$->GetType();
|
||||
|
||||
if ( t->Tag() != TYPE_FUNC ||
|
||||
t->AsFuncType()->Flavor() != FUNC_FLAVOR_FUNCTION )
|
||||
if ( t->Tag() != zeek::TYPE_FUNC ||
|
||||
t->AsFuncType()->Flavor() != zeek::FUNC_FLAVOR_FUNCTION )
|
||||
reporter->Warning("%s", $$->GetDeprecationWarning().c_str());
|
||||
}
|
||||
|
||||
|
@ -1884,7 +1884,7 @@ opt_deprecated:
|
|||
|
|
||||
TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
|
||||
{
|
||||
if ( IsString($3->GetType()->Tag()) )
|
||||
if ( zeek::IsString($3->GetType()->Tag()) )
|
||||
$$ = new zeek::detail::ConstExpr({AdoptRef{}, $3});
|
||||
else
|
||||
{
|
||||
|
|
|
@ -52,10 +52,10 @@ public:
|
|||
/**
|
||||
* @return The enum type associated with the script-layer "Tag".
|
||||
*/
|
||||
const IntrusivePtr<EnumType>& GetTagType() const;
|
||||
const IntrusivePtr<zeek::EnumType>& GetTagType() const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetTagType() instead.")]]
|
||||
EnumType* GetTagEnumType() const;
|
||||
zeek::EnumType* GetTagEnumType() const;
|
||||
|
||||
/**
|
||||
* Get a component name from its tag.
|
||||
|
@ -128,7 +128,7 @@ public:
|
|||
|
||||
private:
|
||||
std::string module; /**< Script layer module in which component tags live. */
|
||||
IntrusivePtr<EnumType> tag_enum_type; /**< Enum type of component tags. */
|
||||
IntrusivePtr<zeek::EnumType> tag_enum_type; /**< Enum type of component tags. */
|
||||
std::map<std::string, C*> components_by_name;
|
||||
std::map<T, C*> components_by_tag;
|
||||
std::map<int, C*> components_by_val;
|
||||
|
@ -137,7 +137,7 @@ private:
|
|||
template <class T, class C>
|
||||
ComponentManager<T, C>::ComponentManager(const std::string& arg_module, const std::string& local_id)
|
||||
: module(arg_module),
|
||||
tag_enum_type(make_intrusive<EnumType>(module + "::" + local_id))
|
||||
tag_enum_type(make_intrusive<zeek::EnumType>(module + "::" + local_id))
|
||||
{
|
||||
auto id = install_ID(local_id.c_str(), module.c_str(), true, true);
|
||||
add_type(id.get(), tag_enum_type, nullptr);
|
||||
|
@ -163,13 +163,13 @@ std::list<C*> ComponentManager<T, C>::GetComponents() const
|
|||
}
|
||||
|
||||
template <class T, class C>
|
||||
const IntrusivePtr<EnumType>& ComponentManager<T, C>::GetTagType() const
|
||||
const IntrusivePtr<zeek::EnumType>& ComponentManager<T, C>::GetTagType() const
|
||||
{
|
||||
return tag_enum_type;
|
||||
}
|
||||
|
||||
template <class T, class C>
|
||||
EnumType* ComponentManager<T, C>::GetTagEnumType() const
|
||||
zeek::EnumType* ComponentManager<T, C>::GetTagEnumType() const
|
||||
{
|
||||
return tag_enum_type.get();
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ static void topk_element_hash_delete_func(void* val)
|
|||
delete e;
|
||||
}
|
||||
|
||||
void TopkVal::Typify(IntrusivePtr<BroType> t)
|
||||
void TopkVal::Typify(IntrusivePtr<zeek::BroType> t)
|
||||
{
|
||||
assert(!hash && !type);
|
||||
type = std::move(t);
|
||||
auto tl = make_intrusive<TypeList>(type);
|
||||
auto tl = make_intrusive<zeek::TypeList>(type);
|
||||
tl->Append(type);
|
||||
hash = new CompositeHash(std::move(tl));
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ IntrusivePtr<VectorVal> TopkVal::GetTopK(int k) const // returns vector
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto v = make_intrusive<VectorType>(type);
|
||||
auto v = make_intrusive<zeek::VectorType>(type);
|
||||
auto t = make_intrusive<VectorVal>(std::move(v));
|
||||
|
||||
// this does no estimation if the results is correct!
|
||||
|
|
|
@ -161,9 +161,9 @@ private:
|
|||
*
|
||||
* @param t type that is tracked
|
||||
*/
|
||||
void Typify(IntrusivePtr<BroType> t);
|
||||
void Typify(IntrusivePtr<zeek::BroType> t);
|
||||
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
CompositeHash* hash;
|
||||
std::list<Bucket*> buckets;
|
||||
PDict<Element>* elementDict;
|
||||
|
|
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