mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 20:48:21 +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
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue