mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Move bro_broker code to zeek::Broker namespace
This commit is contained in:
parent
cba1bc18a5
commit
f1cfd5aa2b
18 changed files with 420 additions and 329 deletions
|
@ -72,7 +72,7 @@ void EventHandler::Call(zeek::Args* vl, bool no_remote)
|
|||
|
||||
for ( auto i = 0u; i < vl->size(); ++i )
|
||||
{
|
||||
auto opt_data = bro_broker::val_to_data((*vl)[i].get());
|
||||
auto opt_data = zeek::Broker::detail::val_to_data((*vl)[i].get());
|
||||
|
||||
if ( opt_data )
|
||||
xs.emplace_back(std::move(*opt_data));
|
||||
|
|
|
@ -4834,7 +4834,7 @@ ValPtr CastExpr::Eval(Frame* f) const
|
|||
GetType()->Describe(&d);
|
||||
d.Add("'");
|
||||
|
||||
if ( same_type(v->GetType(), bro_broker::DataVal::ScriptDataType()) &&
|
||||
if ( same_type(v->GetType(), zeek::Broker::detail::DataVal::ScriptDataType()) &&
|
||||
! v->AsRecordVal()->GetField(0) )
|
||||
d.Add(" (nil $data field)");
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ broker::expected<broker::data> Frame::Serialize(const Frame* target, const id_li
|
|||
|
||||
zeek::TypeTag tag = val->GetType()->Tag();
|
||||
|
||||
auto expected = bro_broker::val_to_data(val.get());
|
||||
auto expected = zeek::Broker::detail::val_to_data(val.get());
|
||||
if ( ! expected )
|
||||
return broker::ec::invalid_data;
|
||||
|
||||
|
@ -477,7 +477,7 @@ std::pair<bool, FramePtr> Frame::Unserialize(const broker::vector& data)
|
|||
broker::integer g = *has_type;
|
||||
zeek::Type t( static_cast<zeek::TypeTag>(g) );
|
||||
|
||||
auto val = bro_broker::data_to_val(std::move(val_tuple[0]), &t);
|
||||
auto val = zeek::Broker::detail::data_to_val(std::move(val_tuple[0]), &t);
|
||||
if ( ! val )
|
||||
return std::make_pair(false, nullptr);
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ void net_run()
|
|||
}
|
||||
#endif
|
||||
current_iosrc = nullptr;
|
||||
auto communication_enabled = broker_mgr->Active();
|
||||
auto communication_enabled = zeek::broker_mgr->Active();
|
||||
|
||||
if ( ! ready.empty() )
|
||||
{
|
||||
|
|
18
src/Val.cc
18
src/Val.cc
|
@ -2179,7 +2179,7 @@ void TableVal::SendToStore(const Val* index, const TableEntryVal* new_entry_val,
|
|||
index_val = index;
|
||||
}
|
||||
|
||||
auto broker_index = bro_broker::val_to_data(index_val);
|
||||
auto broker_index = zeek::Broker::detail::val_to_data(index_val);
|
||||
|
||||
if ( ! broker_index )
|
||||
{
|
||||
|
@ -2209,10 +2209,10 @@ void TableVal::SendToStore(const Val* index, const TableEntryVal* new_entry_val,
|
|||
// element already expired? Let's not insert it.
|
||||
break;
|
||||
|
||||
expiry = bro_broker::convert_expiry(e);
|
||||
expiry = zeek::Broker::detail::convert_expiry(e);
|
||||
}
|
||||
else
|
||||
expiry = bro_broker::convert_expiry(expire_time);
|
||||
expiry = zeek::Broker::detail::convert_expiry(expire_time);
|
||||
}
|
||||
|
||||
if ( table_type->IsSet() )
|
||||
|
@ -2226,7 +2226,7 @@ void TableVal::SendToStore(const Val* index, const TableEntryVal* new_entry_val,
|
|||
}
|
||||
|
||||
auto new_value = new_entry_val->GetVal().get();
|
||||
auto broker_val = bro_broker::val_to_data(new_value);
|
||||
auto broker_val = zeek::Broker::detail::val_to_data(new_value);
|
||||
if ( ! broker_val )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker data conversation for table value");
|
||||
|
@ -3579,14 +3579,14 @@ ValPtr cast_value_to_type(Val* v, Type* t)
|
|||
if ( same_type(v->GetType(), t) )
|
||||
return {NewRef{}, v};
|
||||
|
||||
if ( same_type(v->GetType(), bro_broker::DataVal::ScriptDataType()) )
|
||||
if ( same_type(v->GetType(), zeek::Broker::detail::DataVal::ScriptDataType()) )
|
||||
{
|
||||
const auto& dv = v->AsRecordVal()->GetField(0);
|
||||
|
||||
if ( ! dv )
|
||||
return nullptr;
|
||||
|
||||
return static_cast<bro_broker::DataVal*>(dv.get())->castTo(t);
|
||||
return static_cast<zeek::Broker::detail::DataVal*>(dv.get())->castTo(t);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -3605,14 +3605,14 @@ bool can_cast_value_to_type(const Val* v, Type* t)
|
|||
if ( same_type(v->GetType(), t) )
|
||||
return true;
|
||||
|
||||
if ( same_type(v->GetType(), bro_broker::DataVal::ScriptDataType()) )
|
||||
if ( same_type(v->GetType(), zeek::Broker::detail::DataVal::ScriptDataType()) )
|
||||
{
|
||||
const auto& dv = v->AsRecordVal()->GetField(0);
|
||||
|
||||
if ( ! dv )
|
||||
return false;
|
||||
|
||||
return static_cast<const bro_broker::DataVal *>(dv.get())->canCastTo(t);
|
||||
return static_cast<const zeek::Broker::detail::DataVal *>(dv.get())->canCastTo(t);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -3628,7 +3628,7 @@ bool can_cast_value_to_type(const Type* s, Type* t)
|
|||
if ( same_type(s, t) )
|
||||
return true;
|
||||
|
||||
if ( same_type(s, bro_broker::DataVal::ScriptDataType()) )
|
||||
if ( same_type(s, zeek::Broker::detail::DataVal::ScriptDataType()) )
|
||||
// As Broker is dynamically typed, we don't know if we will be able
|
||||
// to convert the type as intended. We optimistically assume that we
|
||||
// will.
|
||||
|
|
|
@ -14,11 +14,16 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
zeek::OpaqueTypePtr bro_broker::opaque_of_data_type;
|
||||
zeek::OpaqueTypePtr bro_broker::opaque_of_set_iterator;
|
||||
zeek::OpaqueTypePtr bro_broker::opaque_of_table_iterator;
|
||||
zeek::OpaqueTypePtr bro_broker::opaque_of_vector_iterator;
|
||||
zeek::OpaqueTypePtr bro_broker::opaque_of_record_iterator;
|
||||
zeek::OpaqueTypePtr zeek::Broker::detail::opaque_of_data_type;
|
||||
zeek::OpaqueTypePtr& bro_broker::opaque_of_data_type = zeek::Broker::detail::opaque_of_data_type;
|
||||
zeek::OpaqueTypePtr zeek::Broker::detail::opaque_of_set_iterator;
|
||||
zeek::OpaqueTypePtr& bro_broker::opaque_of_set_iterator = zeek::Broker::detail::opaque_of_set_iterator;
|
||||
zeek::OpaqueTypePtr zeek::Broker::detail::opaque_of_table_iterator;
|
||||
zeek::OpaqueTypePtr& bro_broker::opaque_of_table_iterator = zeek::Broker::detail::opaque_of_table_iterator;
|
||||
zeek::OpaqueTypePtr zeek::Broker::detail::opaque_of_vector_iterator;
|
||||
zeek::OpaqueTypePtr& bro_broker::opaque_of_vector_iterator = zeek::Broker::detail::opaque_of_vector_iterator;
|
||||
zeek::OpaqueTypePtr zeek::Broker::detail::opaque_of_record_iterator;
|
||||
zeek::OpaqueTypePtr& bro_broker::opaque_of_record_iterator = zeek::Broker::detail::opaque_of_record_iterator;
|
||||
|
||||
static bool data_type_check(const broker::data& d, zeek::Type* t);
|
||||
|
||||
|
@ -47,7 +52,7 @@ TEST_CASE("converting Zeek to Broker protocol constants")
|
|||
broker::port::protocol::unknown);
|
||||
}
|
||||
|
||||
TransportProto bro_broker::to_bro_port_proto(broker::port::protocol tp)
|
||||
TransportProto zeek::Broker::detail::to_zeek_port_proto(broker::port::protocol tp)
|
||||
{
|
||||
switch ( tp ) {
|
||||
case broker::port::protocol::tcp:
|
||||
|
@ -64,11 +69,11 @@ TransportProto bro_broker::to_bro_port_proto(broker::port::protocol tp)
|
|||
|
||||
TEST_CASE("converting Broker to Zeek protocol constants")
|
||||
{
|
||||
using bro_broker::to_bro_port_proto;
|
||||
CHECK_EQ(to_bro_port_proto(broker::port::protocol::tcp), TRANSPORT_TCP);
|
||||
CHECK_EQ(to_bro_port_proto(broker::port::protocol::udp), TRANSPORT_UDP);
|
||||
CHECK_EQ(to_bro_port_proto(broker::port::protocol::icmp), TRANSPORT_ICMP);
|
||||
CHECK_EQ(to_bro_port_proto(broker::port::protocol::unknown),
|
||||
using zeek::Broker::detail::to_zeek_port_proto;
|
||||
CHECK_EQ(to_zeek_port_proto(broker::port::protocol::tcp), TRANSPORT_TCP);
|
||||
CHECK_EQ(to_zeek_port_proto(broker::port::protocol::udp), TRANSPORT_UDP);
|
||||
CHECK_EQ(to_zeek_port_proto(broker::port::protocol::icmp), TRANSPORT_ICMP);
|
||||
CHECK_EQ(to_zeek_port_proto(broker::port::protocol::unknown),
|
||||
TRANSPORT_UNKNOWN);
|
||||
}
|
||||
|
||||
|
@ -154,7 +159,7 @@ struct val_converter {
|
|||
result_type operator()(broker::port& a)
|
||||
{
|
||||
if ( type->Tag() == zeek::TYPE_PORT )
|
||||
return zeek::val_mgr->Port(a.number(), bro_broker::to_bro_port_proto(a.type()));
|
||||
return zeek::val_mgr->Port(a.number(), zeek::Broker::detail::to_zeek_port_proto(a.type()));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -239,8 +244,8 @@ struct val_converter {
|
|||
|
||||
for ( size_t i = 0; i < indices->size(); ++i )
|
||||
{
|
||||
auto index_val = bro_broker::data_to_val(move((*indices)[i]),
|
||||
expected_index_types[i].get());
|
||||
auto index_val = zeek::Broker::detail::data_to_val(move((*indices)[i]),
|
||||
expected_index_types[i].get());
|
||||
|
||||
if ( ! index_val )
|
||||
return nullptr;
|
||||
|
@ -298,8 +303,8 @@ struct val_converter {
|
|||
|
||||
for ( size_t i = 0; i < indices->size(); ++i )
|
||||
{
|
||||
auto index_val = bro_broker::data_to_val(move((*indices)[i]),
|
||||
expected_index_types[i].get());
|
||||
auto index_val = zeek::Broker::detail::data_to_val(move((*indices)[i]),
|
||||
expected_index_types[i].get());
|
||||
|
||||
if ( ! index_val )
|
||||
return nullptr;
|
||||
|
@ -307,8 +312,8 @@ struct val_converter {
|
|||
list_val->Append(std::move(index_val));
|
||||
}
|
||||
|
||||
auto value_val = bro_broker::data_to_val(move(item.second),
|
||||
tt->Yield().get());
|
||||
auto value_val = zeek::Broker::detail::data_to_val(move(item.second),
|
||||
tt->Yield().get());
|
||||
|
||||
if ( ! value_val )
|
||||
return nullptr;
|
||||
|
@ -328,7 +333,7 @@ struct val_converter {
|
|||
|
||||
for ( auto& item : a )
|
||||
{
|
||||
auto item_val = bro_broker::data_to_val(move(item), vt->Yield().get());
|
||||
auto item_val = zeek::Broker::detail::data_to_val(move(item), vt->Yield().get());
|
||||
|
||||
if ( ! item_val )
|
||||
return nullptr;
|
||||
|
@ -396,8 +401,8 @@ struct val_converter {
|
|||
continue;
|
||||
}
|
||||
|
||||
auto item_val = bro_broker::data_to_val(move(a[idx]),
|
||||
rt->GetFieldType(i).get());
|
||||
auto item_val = zeek::Broker::detail::data_to_val(move(a[idx]),
|
||||
rt->GetFieldType(i).get());
|
||||
|
||||
if ( ! item_val )
|
||||
return nullptr;
|
||||
|
@ -775,15 +780,15 @@ static bool data_type_check(const broker::data& d, zeek::Type* t)
|
|||
return caf::visit(type_checker{t}, d);
|
||||
}
|
||||
|
||||
zeek::ValPtr bro_broker::data_to_val(broker::data d, zeek::Type* type)
|
||||
zeek::ValPtr zeek::Broker::detail::data_to_val(broker::data d, zeek::Type* type)
|
||||
{
|
||||
if ( type->Tag() == zeek::TYPE_ANY )
|
||||
return bro_broker::make_data_val(move(d));
|
||||
return zeek::Broker::detail::make_data_val(move(d));
|
||||
|
||||
return caf::visit(val_converter{type}, std::move(d));
|
||||
}
|
||||
|
||||
broker::expected<broker::data> bro_broker::val_to_data(const zeek::Val* v)
|
||||
broker::expected<broker::data> zeek::Broker::detail::val_to_data(const zeek::Val* v)
|
||||
{
|
||||
switch ( v->GetType()->Tag() ) {
|
||||
case zeek::TYPE_BOOL:
|
||||
|
@ -1004,7 +1009,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const zeek::Val* v)
|
|||
return broker::ec::invalid_data;
|
||||
}
|
||||
|
||||
zeek::RecordValPtr bro_broker::make_data_val(zeek::Val* v)
|
||||
zeek::RecordValPtr zeek::Broker::detail::make_data_val(zeek::Val* v)
|
||||
{
|
||||
auto rval = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
auto data = val_to_data(v);
|
||||
|
@ -1017,7 +1022,7 @@ zeek::RecordValPtr bro_broker::make_data_val(zeek::Val* v)
|
|||
return rval;
|
||||
}
|
||||
|
||||
zeek::RecordValPtr bro_broker::make_data_val(broker::data d)
|
||||
zeek::RecordValPtr zeek::Broker::detail::make_data_val(broker::data d)
|
||||
{
|
||||
auto rval = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
rval->Assign(0, zeek::make_intrusive<DataVal>(move(d)));
|
||||
|
@ -1106,12 +1111,12 @@ struct data_type_getter {
|
|||
}
|
||||
};
|
||||
|
||||
zeek::EnumValPtr bro_broker::get_data_type(zeek::RecordVal* v, zeek::detail::Frame* frame)
|
||||
zeek::EnumValPtr zeek::Broker::detail::get_data_type(zeek::RecordVal* v, zeek::detail::Frame* frame)
|
||||
{
|
||||
return caf::visit(data_type_getter{}, opaque_field_to_data(v, frame));
|
||||
}
|
||||
|
||||
broker::data& bro_broker::opaque_field_to_data(zeek::RecordVal* v, zeek::detail::Frame* f)
|
||||
broker::data& zeek::Broker::detail::opaque_field_to_data(zeek::RecordVal* v, zeek::detail::Frame* f)
|
||||
{
|
||||
const auto& d = v->GetField(0);
|
||||
|
||||
|
@ -1124,50 +1129,50 @@ broker::data& bro_broker::opaque_field_to_data(zeek::RecordVal* v, zeek::detail:
|
|||
return static_cast<DataVal*>(d.get())->data;
|
||||
}
|
||||
|
||||
void bro_broker::DataVal::ValDescribe(zeek::ODesc* d) const
|
||||
void zeek::Broker::detail::DataVal::ValDescribe(zeek::ODesc* d) const
|
||||
{
|
||||
d->Add("broker::data{");
|
||||
d->Add(broker::to_string(data));
|
||||
d->Add("}");
|
||||
}
|
||||
|
||||
bool bro_broker::DataVal::canCastTo(zeek::Type* t) const
|
||||
bool zeek::Broker::detail::DataVal::canCastTo(zeek::Type* t) const
|
||||
{
|
||||
return data_type_check(data, t);
|
||||
}
|
||||
|
||||
zeek::ValPtr bro_broker::DataVal::castTo(zeek::Type* t)
|
||||
zeek::ValPtr zeek::Broker::detail::DataVal::castTo(zeek::Type* t)
|
||||
{
|
||||
return data_to_val(data, t);
|
||||
}
|
||||
|
||||
const zeek::TypePtr& bro_broker::DataVal::ScriptDataType()
|
||||
const zeek::TypePtr& zeek::Broker::detail::DataVal::ScriptDataType()
|
||||
{
|
||||
static auto script_data_type = zeek::id::find_type("Broker::Data");
|
||||
return script_data_type;
|
||||
}
|
||||
|
||||
IMPLEMENT_OPAQUE_VALUE(bro_broker::DataVal)
|
||||
IMPLEMENT_OPAQUE_VALUE(zeek::Broker::detail::DataVal)
|
||||
|
||||
broker::expected<broker::data> bro_broker::DataVal::DoSerialize() const
|
||||
broker::expected<broker::data> zeek::Broker::detail::DataVal::DoSerialize() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
bool bro_broker::DataVal::DoUnserialize(const broker::data& data_)
|
||||
bool zeek::Broker::detail::DataVal::DoUnserialize(const broker::data& data_)
|
||||
{
|
||||
data = data_;
|
||||
return true;
|
||||
}
|
||||
|
||||
IMPLEMENT_OPAQUE_VALUE(bro_broker::SetIterator)
|
||||
IMPLEMENT_OPAQUE_VALUE(zeek::Broker::detail::SetIterator)
|
||||
|
||||
broker::expected<broker::data> bro_broker::SetIterator::DoSerialize() const
|
||||
broker::expected<broker::data> zeek::Broker::detail::SetIterator::DoSerialize() const
|
||||
{
|
||||
return broker::vector{dat, *it};
|
||||
}
|
||||
|
||||
bool bro_broker::SetIterator::DoUnserialize(const broker::data& data)
|
||||
bool zeek::Broker::detail::SetIterator::DoUnserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() == 2) )
|
||||
|
@ -1187,14 +1192,14 @@ bool bro_broker::SetIterator::DoUnserialize(const broker::data& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
IMPLEMENT_OPAQUE_VALUE(bro_broker::TableIterator)
|
||||
IMPLEMENT_OPAQUE_VALUE(zeek::Broker::detail::TableIterator)
|
||||
|
||||
broker::expected<broker::data> bro_broker::TableIterator::DoSerialize() const
|
||||
broker::expected<broker::data> zeek::Broker::detail::TableIterator::DoSerialize() const
|
||||
{
|
||||
return broker::vector{dat, it->first};
|
||||
}
|
||||
|
||||
bool bro_broker::TableIterator::DoUnserialize(const broker::data& data)
|
||||
bool zeek::Broker::detail::TableIterator::DoUnserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() == 2) )
|
||||
|
@ -1214,15 +1219,15 @@ bool bro_broker::TableIterator::DoUnserialize(const broker::data& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
IMPLEMENT_OPAQUE_VALUE(bro_broker::VectorIterator)
|
||||
IMPLEMENT_OPAQUE_VALUE(zeek::Broker::detail::VectorIterator)
|
||||
|
||||
broker::expected<broker::data> bro_broker::VectorIterator::DoSerialize() const
|
||||
broker::expected<broker::data> zeek::Broker::detail::VectorIterator::DoSerialize() const
|
||||
{
|
||||
broker::integer difference = it - dat.begin();
|
||||
return broker::vector{dat, difference};
|
||||
}
|
||||
|
||||
bool bro_broker::VectorIterator::DoUnserialize(const broker::data& data)
|
||||
bool zeek::Broker::detail::VectorIterator::DoUnserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() == 2) )
|
||||
|
@ -1239,15 +1244,15 @@ bool bro_broker::VectorIterator::DoUnserialize(const broker::data& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
IMPLEMENT_OPAQUE_VALUE(bro_broker::RecordIterator)
|
||||
IMPLEMENT_OPAQUE_VALUE(zeek::Broker::detail::RecordIterator)
|
||||
|
||||
broker::expected<broker::data> bro_broker::RecordIterator::DoSerialize() const
|
||||
broker::expected<broker::data> zeek::Broker::detail::RecordIterator::DoSerialize() const
|
||||
{
|
||||
broker::integer difference = it - dat.begin();
|
||||
return broker::vector{dat, difference};
|
||||
}
|
||||
|
||||
bool bro_broker::RecordIterator::DoUnserialize(const broker::data& data)
|
||||
bool zeek::Broker::detail::RecordIterator::DoUnserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() == 2) )
|
||||
|
@ -1264,7 +1269,7 @@ bool bro_broker::RecordIterator::DoUnserialize(const broker::data& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
broker::data bro_broker::threading_field_to_data(const zeek::threading::Field* f)
|
||||
broker::data zeek::Broker::detail::threading_field_to_data(const zeek::threading::Field* f)
|
||||
{
|
||||
auto name = f->name;
|
||||
auto type = static_cast<uint64_t>(f->type);
|
||||
|
@ -1279,7 +1284,7 @@ broker::data bro_broker::threading_field_to_data(const zeek::threading::Field* f
|
|||
return broker::vector({name, secondary, type, subtype, optional});
|
||||
}
|
||||
|
||||
zeek::threading::Field* bro_broker::data_to_threading_field(broker::data d)
|
||||
zeek::threading::Field* zeek::Broker::detail::data_to_threading_field(broker::data d)
|
||||
{
|
||||
if ( ! caf::holds_alternative<broker::vector>(d) )
|
||||
return nullptr;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace threading {
|
|||
using Field [[deprecated("Remove in v4.1. Use zeek::threading::Field.")]] = zeek::threading::Field;
|
||||
}
|
||||
|
||||
namespace bro_broker {
|
||||
namespace zeek::Broker::detail {
|
||||
|
||||
extern zeek::OpaqueTypePtr opaque_of_data_type;
|
||||
extern zeek::OpaqueTypePtr opaque_of_set_iterator;
|
||||
|
@ -24,9 +24,9 @@ extern zeek::OpaqueTypePtr opaque_of_vector_iterator;
|
|||
extern zeek::OpaqueTypePtr opaque_of_record_iterator;
|
||||
|
||||
/**
|
||||
* Convert a broker port protocol to a bro port protocol.
|
||||
* Convert a broker port protocol to a zeek port protocol.
|
||||
*/
|
||||
TransportProto to_bro_port_proto(broker::port::protocol tp);
|
||||
TransportProto to_zeek_port_proto(broker::port::protocol tp);
|
||||
|
||||
/**
|
||||
* Create a Broker::Data value from a Bro value.
|
||||
|
@ -104,7 +104,7 @@ class DataVal : public zeek::OpaqueVal {
|
|||
public:
|
||||
|
||||
DataVal(broker::data arg_data)
|
||||
: OpaqueVal(bro_broker::opaque_of_data_type), data(std::move(arg_data))
|
||||
: OpaqueVal(zeek::Broker::detail::opaque_of_data_type), data(std::move(arg_data))
|
||||
{}
|
||||
|
||||
void ValDescribe(zeek::ODesc* d) const override;
|
||||
|
@ -121,10 +121,10 @@ public:
|
|||
|
||||
protected:
|
||||
DataVal()
|
||||
: OpaqueVal(bro_broker::opaque_of_data_type)
|
||||
: OpaqueVal(zeek::Broker::detail::opaque_of_data_type)
|
||||
{}
|
||||
|
||||
DECLARE_OPAQUE_VALUE(bro_broker::DataVal)
|
||||
DECLARE_OPAQUE_VALUE(zeek::Broker::detail::DataVal)
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -231,7 +231,7 @@ class SetIterator : public zeek::OpaqueVal {
|
|||
public:
|
||||
|
||||
SetIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_set_iterator),
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_set_iterator),
|
||||
dat(require_data_type<broker::set>(v, zeek::TYPE_TABLE, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
@ -241,17 +241,17 @@ public:
|
|||
|
||||
protected:
|
||||
SetIterator()
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_set_iterator)
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_set_iterator)
|
||||
{}
|
||||
|
||||
DECLARE_OPAQUE_VALUE(bro_broker::SetIterator)
|
||||
DECLARE_OPAQUE_VALUE(zeek::Broker::detail::SetIterator)
|
||||
};
|
||||
|
||||
class TableIterator : public zeek::OpaqueVal {
|
||||
public:
|
||||
|
||||
TableIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_table_iterator),
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_table_iterator),
|
||||
dat(require_data_type<broker::table>(v, zeek::TYPE_TABLE, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
@ -261,17 +261,17 @@ public:
|
|||
|
||||
protected:
|
||||
TableIterator()
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_table_iterator)
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_table_iterator)
|
||||
{}
|
||||
|
||||
DECLARE_OPAQUE_VALUE(bro_broker::TableIterator)
|
||||
DECLARE_OPAQUE_VALUE(zeek::Broker::detail::TableIterator)
|
||||
};
|
||||
|
||||
class VectorIterator : public zeek::OpaqueVal {
|
||||
public:
|
||||
|
||||
VectorIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_vector_iterator),
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_vector_iterator),
|
||||
dat(require_data_type<broker::vector>(v, zeek::TYPE_VECTOR, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
@ -281,17 +281,17 @@ public:
|
|||
|
||||
protected:
|
||||
VectorIterator()
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_vector_iterator)
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_vector_iterator)
|
||||
{}
|
||||
|
||||
DECLARE_OPAQUE_VALUE(bro_broker::VectorIterator)
|
||||
DECLARE_OPAQUE_VALUE(zeek::Broker::detail::VectorIterator)
|
||||
};
|
||||
|
||||
class RecordIterator : public zeek::OpaqueVal {
|
||||
public:
|
||||
|
||||
RecordIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_record_iterator),
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_record_iterator),
|
||||
dat(require_data_type<broker::vector>(v, zeek::TYPE_RECORD, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
@ -301,10 +301,58 @@ public:
|
|||
|
||||
protected:
|
||||
RecordIterator()
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_record_iterator)
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_record_iterator)
|
||||
{}
|
||||
|
||||
DECLARE_OPAQUE_VALUE(bro_broker::RecordIterator)
|
||||
DECLARE_OPAQUE_VALUE(zeek::Broker::detail::RecordIterator)
|
||||
};
|
||||
|
||||
} // namespace zeek::Broker
|
||||
|
||||
namespace bro_broker {
|
||||
extern zeek::OpaqueTypePtr& opaque_of_data_type;
|
||||
extern zeek::OpaqueTypePtr& opaque_of_set_iterator;
|
||||
extern zeek::OpaqueTypePtr& opaque_of_table_iterator;
|
||||
extern zeek::OpaqueTypePtr& opaque_of_vector_iterator;
|
||||
extern zeek::OpaqueTypePtr& opaque_of_record_iterator;
|
||||
|
||||
constexpr auto to_bro_port_proto [[deprecated("Remove in v4.1. Use zeek::Broker::detail::to_zeek_port_proto.")]] = zeek::Broker::detail::to_zeek_port_proto;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::Broker::detail::make_data_val.")]]
|
||||
inline zeek::RecordValPtr make_data_val(zeek::Val* v) { return zeek::Broker::detail::make_data_val(v); }
|
||||
[[deprecated("Remove in v4.1. Use zeek::Broker::detail::make_data_val.")]]
|
||||
inline zeek::RecordValPtr make_data_val(broker::data d) { return zeek::Broker::detail::make_data_val(d); }
|
||||
|
||||
constexpr auto get_data_type [[deprecated("Remove in v4.1. Use zeek::Broker::detail::get_data_type.")]] = zeek::Broker::detail::get_data_type;
|
||||
constexpr auto val_to_data [[deprecated("Remove in v4.1. Use zeek::Broker::detail::val_to_data.")]] = zeek::Broker::detail::val_to_data;
|
||||
constexpr auto data_to_val [[deprecated("Remove in v4.1. Use zeek::Broker::detail::data_to_val.")]] = zeek::Broker::detail::data_to_val;
|
||||
constexpr auto threading_val_to_data [[deprecated("Remove in v4.1. Use zeek::Broker::detail::threading_val_to_data.")]] = zeek::Broker::detail::threading_val_to_data;
|
||||
constexpr auto threading_field_to_data [[deprecated("Remove in v4.1. Use zeek::Broker::detail::threading_field_to_data.")]] = zeek::Broker::detail::threading_field_to_data;
|
||||
constexpr auto data_to_threading_val [[deprecated("Remove in v4.1. Use zeek::Broker::detail::data_to_threading_val.")]] = zeek::Broker::detail::data_to_threading_val;
|
||||
constexpr auto data_to_threading_field [[deprecated("Remove in v4.1. Use zeek::Broker::detail::data_to_threading_field.")]] = zeek::Broker::detail::data_to_threading_field;
|
||||
|
||||
using DataVal [[deprecated("Remove in v4.1. Use zeek::Broker::detail::DataVal.")]] = zeek::Broker::detail::DataVal;
|
||||
using type_name_getter [[deprecated("Remove in v4.1. Use zeek::Broker::detail::type_name_getter.")]] = zeek::Broker::detail::type_name_getter;
|
||||
|
||||
constexpr auto opaque_field_to_data [[deprecated("Remove in v4.1. Use zeek::Broker::detail::opaque_field_to_data.")]] = zeek::Broker::detail::opaque_field_to_data;
|
||||
|
||||
template <typename T>
|
||||
[[deprecated("Remove in v4.1. Use zeek::Broker::detail::require_data_type.")]]
|
||||
T& require_data_type(broker::data& d, zeek::TypeTag tag, zeek::detail::Frame* f)
|
||||
{
|
||||
return zeek::Broker::detail::require_data_type<T>(d, tag, f);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[deprecated("Remove in v4.1. Use zeek::Broker::detail::require_data_type.")]]
|
||||
inline T& require_data_type(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
|
||||
{
|
||||
return zeek::Broker::detail::require_data_type<T>(v, tag, f);
|
||||
}
|
||||
|
||||
using SetIterator [[deprecated("Remove in v4.1. Use zeek::Broker::detail::SetIterator.")]] = zeek::Broker::detail::SetIterator;
|
||||
using TableIterator [[deprecated("Remove in v4.1. Use zeek::Broker::detail::TableIterator.")]] = zeek::Broker::detail::TableIterator;
|
||||
using VectorIterator [[deprecated("Remove in v4.1. Use zeek::Broker::detail::VectorIterator.")]] = zeek::Broker::detail::VectorIterator;
|
||||
using RecordIterator [[deprecated("Remove in v4.1. Use zeek::Broker::detail::RecordIterator.")]] = zeek::Broker::detail::RecordIterator;
|
||||
|
||||
} // namespace bro_broker
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace bro_broker {
|
||||
namespace zeek::Broker {
|
||||
|
||||
static inline zeek::Val* get_option(const char* option)
|
||||
{
|
||||
|
@ -154,12 +154,12 @@ void Manager::InitPostScript()
|
|||
zeek_table_manager = get_option("Broker::table_store_master")->AsBool();
|
||||
zeek_table_db_directory = get_option("Broker::table_store_db_directory")->AsString()->CheckString();
|
||||
|
||||
opaque_of_data_type = zeek::make_intrusive<zeek::OpaqueType>("Broker::Data");
|
||||
opaque_of_set_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::SetIterator");
|
||||
opaque_of_table_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::TableIterator");
|
||||
opaque_of_vector_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::VectorIterator");
|
||||
opaque_of_record_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::RecordIterator");
|
||||
opaque_of_store_handle = zeek::make_intrusive<zeek::OpaqueType>("Broker::Store");
|
||||
detail::opaque_of_data_type = zeek::make_intrusive<zeek::OpaqueType>("Broker::Data");
|
||||
detail::opaque_of_set_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::SetIterator");
|
||||
detail::opaque_of_table_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::TableIterator");
|
||||
detail::opaque_of_vector_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::VectorIterator");
|
||||
detail::opaque_of_record_iterator = zeek::make_intrusive<zeek::OpaqueType>("Broker::RecordIterator");
|
||||
detail::opaque_of_store_handle = zeek::make_intrusive<zeek::OpaqueType>("Broker::Store");
|
||||
vector_of_data_type = zeek::make_intrusive<zeek::VectorType>(zeek::id::find_type("Broker::Data"));
|
||||
|
||||
// Register as a "dont-count" source first, we may change that later.
|
||||
|
@ -243,7 +243,7 @@ void Manager::InitializeBrokerStoreForwarding()
|
|||
if ( ! zeek_table_manager )
|
||||
continue;
|
||||
|
||||
auto backend = bro_broker::to_backend_type(e);
|
||||
auto backend = detail::to_backend_type(e);
|
||||
auto suffix = ".store";
|
||||
|
||||
switch ( backend ) {
|
||||
|
@ -448,7 +448,7 @@ bool Manager::PublishEvent(string topic, zeek::RecordVal* args)
|
|||
for ( auto i = 0u; i < vv->Size(); ++i )
|
||||
{
|
||||
const auto& val = vv->At(i)->AsRecordVal()->GetField(0);
|
||||
auto data_val = static_cast<DataVal*>(val.get());
|
||||
auto data_val = static_cast<detail::DataVal*>(val.get());
|
||||
xs.emplace_back(data_val->data);
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
|
|||
// receiving side, but not sure what use that would be.
|
||||
return false;
|
||||
|
||||
auto data = val_to_data(val.get());
|
||||
auto data = detail::val_to_data(val.get());
|
||||
|
||||
if ( ! data )
|
||||
{
|
||||
|
@ -528,7 +528,7 @@ bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer,
|
|||
|
||||
for ( auto i = 0; i < num_fields; ++i )
|
||||
{
|
||||
auto field_data = threading_field_to_data(fields[i]);
|
||||
auto field_data = detail::threading_field_to_data(fields[i]);
|
||||
fields_data.push_back(move(field_data));
|
||||
}
|
||||
|
||||
|
@ -806,10 +806,10 @@ zeek::RecordVal* Manager::MakeEvent(val_list* args, zeek::detail::Frame* frame)
|
|||
|
||||
zeek::RecordValPtr data_val;
|
||||
|
||||
if ( same_type(got_type, bro_broker::DataVal::ScriptDataType()) )
|
||||
if ( same_type(got_type, detail::DataVal::ScriptDataType()) )
|
||||
data_val = {zeek::NewRef{}, (*args)[i]->AsRecordVal()};
|
||||
else
|
||||
data_val = make_data_val((*args)[i]);
|
||||
data_val = detail::make_data_val((*args)[i]);
|
||||
|
||||
if ( ! data_val->GetField(0) )
|
||||
{
|
||||
|
@ -1031,7 +1031,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table,
|
|||
|
||||
const auto& its = table->GetType()->AsTableType()->GetIndexTypes();
|
||||
assert( its.size() == 1 );
|
||||
auto zeek_key = data_to_val(key, its[0].get());
|
||||
auto zeek_key = detail::data_to_val(key, its[0].get());
|
||||
if ( ! zeek_key )
|
||||
{
|
||||
zeek::reporter->Error("ProcessStoreEvent %s: could not convert key \"%s\" for store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(key).c_str(), store_id.c_str());
|
||||
|
@ -1045,7 +1045,7 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table,
|
|||
}
|
||||
|
||||
// it is a table
|
||||
auto zeek_value = data_to_val(data, table->GetType()->Yield().get());
|
||||
auto zeek_value = detail::data_to_val(data, table->GetType()->Yield().get());
|
||||
if ( ! zeek_value )
|
||||
{
|
||||
zeek::reporter->Error("ProcessStoreEvent %s: could not convert value \"%s\" for key \"%s\" in store \"%s\" while receiving remote data. This probably means the tables have different types on different nodes.", type, to_string(data).c_str(), to_string(key).c_str(), store_id.c_str());
|
||||
|
@ -1107,7 +1107,7 @@ void Manager::ProcessStoreEvent(broker::data msg)
|
|||
DBG_LOG(zeek::DBG_BROKER, "Store %s: Erase key %s", erase.store_id().c_str(), to_string(key).c_str());
|
||||
const auto& its = table->GetType()->AsTableType()->GetIndexTypes();
|
||||
assert( its.size() == 1 );
|
||||
auto zeek_key = data_to_val(key, its[0].get());
|
||||
auto zeek_key = detail::data_to_val(key, its[0].get());
|
||||
if ( ! zeek_key )
|
||||
{
|
||||
zeek::reporter->Error("ProcessStoreEvent: could not convert key \"%s\" for store \"%s\" while receiving remote erase. This probably means the tables have different types on different nodes.", to_string(key).c_str(), insert.store_id().c_str());
|
||||
|
@ -1190,7 +1190,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
|||
{
|
||||
auto got_type = args[i].get_type_name();
|
||||
const auto& expected_type = arg_types[i];
|
||||
auto val = data_to_val(std::move(args[i]), expected_type.get());
|
||||
auto val = detail::data_to_val(std::move(args[i]), expected_type.get());
|
||||
|
||||
if ( val )
|
||||
vl.emplace_back(std::move(val));
|
||||
|
@ -1219,7 +1219,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
|||
zeek::event_mgr.Enqueue(handler, std::move(vl), SOURCE_BROKER);
|
||||
}
|
||||
|
||||
bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
||||
bool Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
||||
{
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str());
|
||||
if ( ! lc.valid() )
|
||||
|
@ -1229,14 +1229,14 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
|||
return false;
|
||||
}
|
||||
|
||||
auto stream_id = data_to_val(std::move(lc.stream_id()), log_id_type);
|
||||
auto stream_id = detail::data_to_val(std::move(lc.stream_id()), log_id_type);
|
||||
if ( ! stream_id )
|
||||
{
|
||||
zeek::reporter->Warning("failed to unpack remote log stream id");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto writer_id = data_to_val(std::move(lc.writer_id()), writer_id_type);
|
||||
auto writer_id = detail::data_to_val(std::move(lc.writer_id()), writer_id_type);
|
||||
if ( ! writer_id )
|
||||
{
|
||||
zeek::reporter->Warning("failed to unpack remote log writer id");
|
||||
|
@ -1264,7 +1264,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
|||
|
||||
for ( size_t i = 0; i < num_fields; ++i )
|
||||
{
|
||||
if ( auto field = data_to_threading_field(std::move((*fields_data)[i])) )
|
||||
if ( auto field = detail::data_to_threading_field(std::move((*fields_data)[i])) )
|
||||
fields[i] = field;
|
||||
else
|
||||
{
|
||||
|
@ -1284,7 +1284,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
|
||||
bool Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
|
||||
{
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received log-write: %s", RenderMessage(lw.as_data()).c_str());
|
||||
|
||||
|
@ -1299,7 +1299,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
|
|||
auto& stream_id_name = lw.stream_id().name;
|
||||
|
||||
// Get stream ID.
|
||||
auto stream_id = data_to_val(std::move(lw.stream_id()), log_id_type);
|
||||
auto stream_id = detail::data_to_val(std::move(lw.stream_id()), log_id_type);
|
||||
|
||||
if ( ! stream_id )
|
||||
{
|
||||
|
@ -1309,7 +1309,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
|
|||
}
|
||||
|
||||
// Get writer ID.
|
||||
auto writer_id = data_to_val(std::move(lw.writer_id()), writer_id_type);
|
||||
auto writer_id = detail::data_to_val(std::move(lw.writer_id()), writer_id_type);
|
||||
if ( ! writer_id )
|
||||
{
|
||||
zeek::reporter->Warning("failed to unpack remote log writer id for stream: %s", stream_id_name.data());
|
||||
|
@ -1391,7 +1391,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
|
|||
return false;
|
||||
}
|
||||
|
||||
auto val = data_to_val(std::move(id_value), id->GetType().get());
|
||||
auto val = detail::data_to_val(std::move(id_value), id->GetType().get());
|
||||
|
||||
if ( ! val )
|
||||
{
|
||||
|
@ -1413,24 +1413,24 @@ void Manager::ProcessStatus(broker::status stat)
|
|||
zeek::EventHandlerPtr event;
|
||||
switch (stat.code()) {
|
||||
case broker::sc::unspecified:
|
||||
event = Broker::status;
|
||||
event = ::Broker::status;
|
||||
break;
|
||||
|
||||
case broker::sc::peer_added:
|
||||
++peer_count;
|
||||
assert(ctx);
|
||||
zeek::log_mgr->SendAllWritersTo(*ctx);
|
||||
event = Broker::peer_added;
|
||||
event = ::Broker::peer_added;
|
||||
break;
|
||||
|
||||
case broker::sc::peer_removed:
|
||||
--peer_count;
|
||||
event = Broker::peer_removed;
|
||||
event = ::Broker::peer_removed;
|
||||
break;
|
||||
|
||||
case broker::sc::peer_lost:
|
||||
--peer_count;
|
||||
event = Broker::peer_lost;
|
||||
event = ::Broker::peer_lost;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1476,7 +1476,7 @@ void Manager::ProcessError(broker::error err)
|
|||
{
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received error message: %s", RenderMessage(err).c_str());
|
||||
|
||||
if ( ! Broker::error )
|
||||
if ( ! ::Broker::error )
|
||||
return;
|
||||
|
||||
BifEnum::Broker::ErrorCode ec;
|
||||
|
@ -1502,12 +1502,12 @@ void Manager::ProcessError(broker::error err)
|
|||
msg = fmt("[%s] %s", caf::to_string(err.category()).c_str(), caf::to_string(err.context()).c_str());
|
||||
}
|
||||
|
||||
zeek::event_mgr.Enqueue(Broker::error,
|
||||
zeek::event_mgr.Enqueue(::Broker::error,
|
||||
zeek::BifType::Enum::Broker::ErrorCode->GetEnumVal(ec),
|
||||
zeek::make_intrusive<zeek::StringVal>(msg));
|
||||
}
|
||||
|
||||
void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response response)
|
||||
void Manager::ProcessStoreResponse(detail::StoreHandleVal* s, broker::store::response response)
|
||||
{
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received store response: %s", RenderMessage(response).c_str());
|
||||
|
||||
|
@ -1529,7 +1529,7 @@ void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response re
|
|||
}
|
||||
|
||||
if ( response.answer )
|
||||
request->second->Result(query_result(make_data_val(std::move(*response.answer))));
|
||||
request->second->Result(detail::query_result(detail::make_data_val(std::move(*response.answer))));
|
||||
else if ( response.answer.error() == broker::ec::request_timeout )
|
||||
{
|
||||
// Fine, trigger's timeout takes care of things.
|
||||
|
@ -1543,7 +1543,7 @@ void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response re
|
|||
// this type of error (which is less easily handled programmatically).
|
||||
}
|
||||
else if ( response.answer.error() == broker::ec::no_such_key )
|
||||
request->second->Result(query_result());
|
||||
request->second->Result(detail::query_result());
|
||||
else
|
||||
zeek::reporter->InternalWarning("unknown store response status: %s",
|
||||
to_string(response.answer.error()).c_str());
|
||||
|
@ -1552,8 +1552,8 @@ void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response re
|
|||
pending_queries.erase(request);
|
||||
}
|
||||
|
||||
StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type,
|
||||
broker::backend_options opts)
|
||||
detail::StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type,
|
||||
broker::backend_options opts)
|
||||
{
|
||||
if ( bstate->endpoint.is_shutdown() )
|
||||
return nullptr;
|
||||
|
@ -1594,7 +1594,7 @@ StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto handle = new StoreHandleVal{*result};
|
||||
auto handle = new detail::StoreHandleVal{*result};
|
||||
Ref(handle);
|
||||
|
||||
data_stores.emplace(name, handle);
|
||||
|
@ -1611,7 +1611,7 @@ StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type,
|
|||
return handle;
|
||||
}
|
||||
|
||||
void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleVal* handle)
|
||||
void Manager::BrokerStoreToZeekTable(const std::string& name, const detail::StoreHandleVal* handle)
|
||||
{
|
||||
if ( ! handle->forward_to )
|
||||
return;
|
||||
|
@ -1631,7 +1631,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV
|
|||
|
||||
for ( const auto& key : *set )
|
||||
{
|
||||
auto zeek_key = data_to_val(key, its[0].get());
|
||||
auto zeek_key = detail::data_to_val(key, its[0].get());
|
||||
if ( ! zeek_key )
|
||||
{
|
||||
zeek::reporter->Error("Failed to convert key \"%s\" while importing broker store to table for store \"%s\". Aborting import.", to_string(key).c_str(), name.c_str());
|
||||
|
@ -1654,7 +1654,7 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV
|
|||
continue;
|
||||
}
|
||||
|
||||
auto zeek_value = data_to_val(*value, table->GetType()->Yield().get());
|
||||
auto zeek_value = detail::data_to_val(*value, table->GetType()->Yield().get());
|
||||
if ( ! zeek_value )
|
||||
{
|
||||
zeek::reporter->Error("Could not convert %s to table value while trying to import Broker store %s. Aborting import.", to_string(value).c_str(), name.c_str());
|
||||
|
@ -1669,9 +1669,9 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const StoreHandleV
|
|||
return;
|
||||
}
|
||||
|
||||
StoreHandleVal* Manager::MakeClone(const string& name, double resync_interval,
|
||||
double stale_interval,
|
||||
double mutation_buffer_interval)
|
||||
detail::StoreHandleVal* Manager::MakeClone(const string& name, double resync_interval,
|
||||
double stale_interval,
|
||||
double mutation_buffer_interval)
|
||||
{
|
||||
if ( bstate->endpoint.is_shutdown() )
|
||||
return nullptr;
|
||||
|
@ -1691,7 +1691,7 @@ StoreHandleVal* Manager::MakeClone(const string& name, double resync_interval,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto handle = new StoreHandleVal{*result};
|
||||
auto handle = new detail::StoreHandleVal{*result};
|
||||
Ref(handle);
|
||||
|
||||
data_stores.emplace(name, handle);
|
||||
|
@ -1700,7 +1700,7 @@ StoreHandleVal* Manager::MakeClone(const string& name, double resync_interval,
|
|||
return handle;
|
||||
}
|
||||
|
||||
StoreHandleVal* Manager::LookupStore(const string& name)
|
||||
detail::StoreHandleVal* Manager::LookupStore(const string& name)
|
||||
{
|
||||
auto i = data_stores.find(name);
|
||||
return i == data_stores.end() ? nullptr : i->second;
|
||||
|
@ -1733,8 +1733,8 @@ bool Manager::CloseStore(const string& name)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Manager::TrackStoreQuery(StoreHandleVal* handle, broker::request_id id,
|
||||
StoreQueryCallback* cb)
|
||||
bool Manager::TrackStoreQuery(detail::StoreHandleVal* handle, broker::request_id id,
|
||||
detail::StoreQueryCallback* cb)
|
||||
{
|
||||
auto rval = pending_queries.emplace(std::make_pair(id, handle), cb).second;
|
||||
|
||||
|
@ -1784,4 +1784,4 @@ void Manager::PrepareForwarding(const std::string &name)
|
|||
DBG_LOG(zeek::DBG_BROKER, "Resolved table forward for data store %s", name.c_str());
|
||||
}
|
||||
|
||||
} // namespace bro_broker
|
||||
} // namespace zeek::Broker
|
||||
|
|
|
@ -30,12 +30,14 @@ ZEEK_FORWARD_DECLARE_NAMESPACED(TableVal, zeek);
|
|||
namespace zeek {
|
||||
using VectorTypePtr = zeek::IntrusivePtr<zeek::VectorType>;
|
||||
using TableValPtr = zeek::IntrusivePtr<zeek::TableVal>;
|
||||
}
|
||||
|
||||
namespace bro_broker {
|
||||
namespace Broker {
|
||||
|
||||
namespace detail {
|
||||
class StoreHandleVal;
|
||||
class StoreQueryCallback;
|
||||
};
|
||||
|
||||
class BrokerState;
|
||||
|
||||
/**
|
||||
|
@ -271,8 +273,8 @@ public:
|
|||
* @param opts The backend options.
|
||||
* @return a pointer to the newly created store a nullptr on failure.
|
||||
*/
|
||||
StoreHandleVal* MakeMaster(const std::string& name, broker::backend type,
|
||||
broker::backend_options opts);
|
||||
detail::StoreHandleVal* MakeMaster(const std::string& name, broker::backend type,
|
||||
broker::backend_options opts);
|
||||
|
||||
/**
|
||||
* Create a new *clone* data store.
|
||||
|
@ -292,17 +294,17 @@ public:
|
|||
* the master. A negative/zero value indicates to never buffer commands.
|
||||
* @return a pointer to the newly created store a nullptr on failure.
|
||||
*/
|
||||
StoreHandleVal* MakeClone(const std::string& name,
|
||||
double resync_interval = 10.0,
|
||||
double stale_interval = 300.0,
|
||||
double mutation_buffer_interval = 120.0);
|
||||
detail::StoreHandleVal* MakeClone(const std::string& name,
|
||||
double resync_interval = 10.0,
|
||||
double stale_interval = 300.0,
|
||||
double mutation_buffer_interval = 120.0);
|
||||
|
||||
/**
|
||||
* Lookup a data store by it's identifier name and type.
|
||||
* @param name the store's name.
|
||||
* @return a pointer to the store handle if it exists else nullptr.
|
||||
*/
|
||||
StoreHandleVal* LookupStore(const std::string& name);
|
||||
detail::StoreHandleVal* LookupStore(const std::string& name);
|
||||
|
||||
/**
|
||||
* Register a Zeek table that is associated with a Broker store that is backing it. This
|
||||
|
@ -328,8 +330,8 @@ public:
|
|||
* @param cb the callback info to use when the query completes or times out.
|
||||
* @return true if now tracking a data store query.
|
||||
*/
|
||||
bool TrackStoreQuery(StoreHandleVal* handle, broker::request_id id,
|
||||
StoreQueryCallback* cb);
|
||||
bool TrackStoreQuery(detail::StoreHandleVal* handle, broker::request_id id,
|
||||
detail::StoreQueryCallback* cb);
|
||||
|
||||
/**
|
||||
* Send all pending log write messages.
|
||||
|
@ -370,7 +372,7 @@ private:
|
|||
bool ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu);
|
||||
void ProcessStatus(broker::status stat);
|
||||
void ProcessError(broker::error err);
|
||||
void ProcessStoreResponse(StoreHandleVal*, broker::store::response response);
|
||||
void ProcessStoreResponse(detail::StoreHandleVal*, broker::store::response response);
|
||||
void FlushPendingQueries();
|
||||
// Initializes the masters for Broker backed Zeek tables when using the &backend attribute
|
||||
void InitializeBrokerStoreForwarding();
|
||||
|
@ -378,7 +380,7 @@ private:
|
|||
void PrepareForwarding(const std::string& name);
|
||||
// Send the content of a Broker store to the backing table. This is typically used
|
||||
// when a master/clone is created.
|
||||
void BrokerStoreToZeekTable(const std::string& name, const StoreHandleVal* handle);
|
||||
void BrokerStoreToZeekTable(const std::string& name, const detail::StoreHandleVal* handle);
|
||||
|
||||
void Error(const char* format, ...)
|
||||
__attribute__((format (printf, 2, 3)));
|
||||
|
@ -397,7 +399,7 @@ private:
|
|||
};
|
||||
|
||||
// Data stores
|
||||
using query_id = std::pair<broker::request_id, StoreHandleVal*>;
|
||||
using query_id = std::pair<broker::request_id, detail::StoreHandleVal*>;
|
||||
|
||||
struct query_id_hasher {
|
||||
size_t operator()(const query_id& qid) const
|
||||
|
@ -412,9 +414,9 @@ private:
|
|||
std::vector<LogBuffer> log_buffers; // Indexed by stream ID enum.
|
||||
std::string default_log_topic_prefix;
|
||||
std::shared_ptr<BrokerState> bstate;
|
||||
std::unordered_map<std::string, StoreHandleVal*> data_stores;
|
||||
std::unordered_map<std::string, detail::StoreHandleVal*> data_stores;
|
||||
std::unordered_map<std::string, zeek::TableValPtr> forwarded_stores;
|
||||
std::unordered_map<query_id, StoreQueryCallback*,
|
||||
std::unordered_map<query_id, detail::StoreQueryCallback*,
|
||||
query_id_hasher> pending_queries;
|
||||
std::vector<std::string> forwarded_prefixes;
|
||||
|
||||
|
@ -436,6 +438,15 @@ private:
|
|||
static int script_scope;
|
||||
};
|
||||
|
||||
} // namespace bro_broker
|
||||
} // namespace Broker
|
||||
|
||||
extern bro_broker::Manager* broker_mgr;
|
||||
extern Broker::Manager* broker_mgr;
|
||||
|
||||
} // namespace zeek
|
||||
|
||||
extern zeek::Broker::Manager*& broker_mgr [[deprecated("Remove in v4.1. Use zeek::broker_mgr.")]];
|
||||
|
||||
namespace bro_broker {
|
||||
using Stats [[deprecated("Remove in v4.1. Use zeek::Broker::Stats.")]] = zeek::Broker::Stats;
|
||||
using Manager [[deprecated("Remove in v4.1. Use zeek::Broker::Manager.")]] = zeek::Broker::Manager;
|
||||
} // namespace bro_broker
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "Store.h"
|
||||
#include "broker/Store.h"
|
||||
#include "Desc.h"
|
||||
#include "ID.h"
|
||||
#include "broker/Manager.h"
|
||||
|
||||
namespace bro_broker {
|
||||
zeek::OpaqueTypePtr zeek::Broker::detail::opaque_of_store_handle;
|
||||
zeek::OpaqueTypePtr& bro_broker::opaque_of_store_handle = zeek::Broker::detail::opaque_of_store_handle;
|
||||
|
||||
zeek::OpaqueTypePtr opaque_of_store_handle;
|
||||
namespace zeek::Broker::detail {
|
||||
|
||||
zeek::EnumValPtr query_status(bool success)
|
||||
{
|
||||
|
@ -123,4 +124,4 @@ broker::backend_options to_backend_options(broker::backend backend,
|
|||
return broker::backend_options{};
|
||||
}
|
||||
|
||||
} // namespace bro_broker
|
||||
} // namespace zeek::Broker
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <broker/backend.hh>
|
||||
#include <broker/backend_options.hh>
|
||||
|
||||
namespace bro_broker {
|
||||
namespace zeek::Broker::detail {
|
||||
|
||||
extern zeek::OpaqueTypePtr opaque_of_store_handle;
|
||||
|
||||
|
@ -71,7 +71,7 @@ static broker::optional<broker::timespan> convert_expiry(double e)
|
|||
class StoreQueryCallback {
|
||||
public:
|
||||
StoreQueryCallback(zeek::detail::trigger::Trigger* arg_trigger, const zeek::detail::CallExpr* arg_call,
|
||||
broker::store store)
|
||||
broker::store store)
|
||||
: trigger(arg_trigger), call(arg_call), store(std::move(store))
|
||||
{
|
||||
Ref(trigger);
|
||||
|
@ -114,7 +114,7 @@ private:
|
|||
class StoreHandleVal : public zeek::OpaqueVal {
|
||||
public:
|
||||
StoreHandleVal(broker::store s)
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_store_handle), store{s}, proxy{store}, store_pid{store.frontend_id()}
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_store_handle), store{s}, proxy{store}, store_pid{store.frontend_id()}
|
||||
{ }
|
||||
|
||||
void ValDescribe(zeek::ODesc* d) const override;
|
||||
|
@ -131,7 +131,7 @@ protected:
|
|||
{ return { zeek::NewRef{}, this }; }
|
||||
|
||||
StoreHandleVal()
|
||||
: zeek::OpaqueVal(bro_broker::opaque_of_store_handle)
|
||||
: zeek::OpaqueVal(zeek::Broker::detail::opaque_of_store_handle)
|
||||
{}
|
||||
|
||||
DECLARE_OPAQUE_VALUE(StoreHandleVal)
|
||||
|
@ -144,4 +144,29 @@ broker::backend to_backend_type(BifEnum::Broker::BackendType type);
|
|||
broker::backend_options to_backend_options(broker::backend backend,
|
||||
zeek::RecordVal* options);
|
||||
|
||||
} // namespace zeek::Broker
|
||||
|
||||
namespace bro_broker {
|
||||
|
||||
extern zeek::OpaqueTypePtr& opaque_of_store_handle [[deprecated("Remove in v4.1. Use zeek::Broker::detail::opaque_of_store_handle.")]];
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::Broker::detail::query_result.")]]
|
||||
inline zeek::RecordValPtr query_result()
|
||||
{
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::Broker::detail::query_result.")]]
|
||||
inline zeek::RecordValPtr query_result(zeek::RecordValPtr data)
|
||||
{
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
constexpr auto convert_expiry [[deprecated("Remove in v4.1. Use zeek::Broker::detail::convert_expiry.")]] = zeek::Broker::detail::convert_expiry;
|
||||
using StoreQueryCallback [[deprecated("Remove in v4.1. Use zeek::Broker::detail::StoreQueryCallback.")]] = zeek::Broker::detail::StoreQueryCallback;
|
||||
using StoreHandleVal [[deprecated("Remove in v4.1. Use zeek::Broker::detail::StoreHandleVal.")]] = zeek::Broker::detail::StoreHandleVal;
|
||||
|
||||
constexpr auto to_backend_type [[deprecated("Remove in v4.1. Use zeek::Broker::detail::to_backend_type.")]] = zeek::Broker::detail::to_backend_type;
|
||||
constexpr auto to_backend_options [[deprecated("Remove in v4.1. Use zeek::Broker::detail::to_backend_options.")]] = zeek::Broker::detail::to_backend_options;
|
||||
|
||||
} // namespace bro_broker
|
||||
|
|
|
@ -59,7 +59,7 @@ enum PeerStatus %{
|
|||
|
||||
function Broker::__listen%(a: string, p: port%): port
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
|
||||
if ( ! p->IsTCP() )
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ function Broker::__listen%(a: string, p: port%): port
|
|||
|
||||
function Broker::__peer%(a: string, p: port, retry: interval%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
|
||||
if ( ! p->IsTCP() )
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ function Broker::__peer%(a: string, p: port, retry: interval%): bool
|
|||
|
||||
function Broker::__unpeer%(a: string, p: port%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
|
||||
if ( ! p->IsTCP() )
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ function Broker::__unpeer%(a: string, p: port%): bool
|
|||
|
||||
function Broker::__peers%(%): PeerInfos
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = zeek::make_intrusive<zeek::VectorVal>(zeek::id::find_type<VectorType>("Broker::PeerInfos"));
|
||||
auto i = 0;
|
||||
|
||||
|
@ -142,6 +142,6 @@ function Broker::__peers%(%): PeerInfos
|
|||
|
||||
function Broker::__node_id%(%): string
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
return zeek::make_intrusive<zeek::StringVal>(broker_mgr->NodeID());
|
||||
%}
|
||||
|
|
|
@ -33,12 +33,12 @@ type Broker::TableItem: record;
|
|||
|
||||
function Broker::__data%(d: any%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(d);
|
||||
return zeek::Broker::detail::make_data_val(d);
|
||||
%}
|
||||
|
||||
function Broker::__data_type%(d: Broker::Data%): Broker::DataType
|
||||
%{
|
||||
return bro_broker::get_data_type(d->AsRecordVal(), frame);
|
||||
return zeek::Broker::detail::get_data_type(d->AsRecordVal(), frame);
|
||||
%}
|
||||
|
||||
# For testing only.
|
||||
|
@ -57,29 +57,29 @@ function Broker::__opaque_clone_through_serialization%(d: any%): any
|
|||
|
||||
function Broker::__set_create%(%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::set());
|
||||
return zeek::Broker::detail::make_data_val(broker::set());
|
||||
%}
|
||||
|
||||
function Broker::__set_clear%(s: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
v.clear();
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
function Broker::__set_size%(s: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
return zeek::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(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
auto k = zeek::Broker::detail::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
{
|
||||
|
@ -92,10 +92,10 @@ 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(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
auto k = zeek::Broker::detail::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
{
|
||||
|
@ -108,9 +108,9 @@ 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(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::set>(s->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
auto k = zeek::Broker::detail::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
{
|
||||
|
@ -123,18 +123,18 @@ function Broker::__set_remove%(s: Broker::Data, key: any%): bool
|
|||
|
||||
function Broker::__set_iterator%(s: Broker::Data%): opaque of Broker::SetIterator
|
||||
%{
|
||||
return zeek::make_intrusive<bro_broker::SetIterator>(s->AsRecordVal(), zeek::TYPE_TABLE, frame);
|
||||
return zeek::make_intrusive<zeek::Broker::detail::SetIterator>(s->AsRecordVal(), zeek::TYPE_TABLE, frame);
|
||||
%}
|
||||
|
||||
function Broker::__set_iterator_last%(it: opaque of Broker::SetIterator%): bool
|
||||
%{
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
auto set_it = static_cast<zeek::Broker::detail::SetIterator*>(it);
|
||||
return zeek::val_mgr->Bool(set_it->it == set_it->dat.end());
|
||||
%}
|
||||
|
||||
function Broker::__set_iterator_next%(it: opaque of Broker::SetIterator%): bool
|
||||
%{
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
auto set_it = static_cast<zeek::Broker::detail::SetIterator*>(it);
|
||||
|
||||
if ( set_it->it == set_it->dat.end() )
|
||||
return zeek::val_mgr->False();
|
||||
|
@ -145,7 +145,7 @@ function Broker::__set_iterator_next%(it: opaque of Broker::SetIterator%): bool
|
|||
|
||||
function Broker::__set_iterator_value%(it: opaque of Broker::SetIterator%): Broker::Data
|
||||
%{
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
auto set_it = static_cast<zeek::Broker::detail::SetIterator*>(it);
|
||||
auto rval = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
||||
if ( set_it->it == set_it->dat.end() )
|
||||
|
@ -154,18 +154,18 @@ function Broker::__set_iterator_value%(it: opaque of Broker::SetIterator%): Brok
|
|||
return rval;
|
||||
}
|
||||
|
||||
rval->Assign(0, zeek::make_intrusive<bro_broker::DataVal>(*set_it->it));
|
||||
rval->Assign(0, zeek::make_intrusive<zeek::Broker::detail::DataVal>(*set_it->it));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
function Broker::__table_create%(%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::table());
|
||||
return zeek::Broker::detail::make_data_val(broker::table());
|
||||
%}
|
||||
|
||||
function Broker::__table_clear%(t: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
v.clear();
|
||||
return zeek::val_mgr->True();
|
||||
|
@ -173,17 +173,17 @@ 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(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
return zeek::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(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
auto k = zeek::Broker::detail::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
{
|
||||
|
@ -196,10 +196,10 @@ 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(),
|
||||
auto& table = zeek::Broker::detail::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
auto k = zeek::Broker::detail::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::
|
|||
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
}
|
||||
|
||||
auto v = bro_broker::val_to_data(val);
|
||||
auto v = zeek::Broker::detail::val_to_data(val);
|
||||
|
||||
if ( ! v )
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::
|
|||
try
|
||||
{
|
||||
auto& prev = table.at(*k);
|
||||
auto rval = bro_broker::make_data_val(move(prev));
|
||||
auto rval = zeek::Broker::detail::make_data_val(move(prev));
|
||||
prev = std::move(*v);
|
||||
return rval;
|
||||
}
|
||||
|
@ -231,10 +231,10 @@ 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(),
|
||||
auto& table = zeek::Broker::detail::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
auto k = zeek::Broker::detail::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ function Broker::__table_remove%(t: Broker::Data, key: any%): Broker::Data
|
|||
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
else
|
||||
{
|
||||
auto rval = bro_broker::make_data_val(move(it->second));
|
||||
auto rval = zeek::Broker::detail::make_data_val(move(it->second));
|
||||
table.erase(it);
|
||||
return rval;
|
||||
}
|
||||
|
@ -256,10 +256,10 @@ 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(),
|
||||
auto& table = zeek::Broker::detail::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
zeek::TYPE_TABLE, frame);
|
||||
|
||||
auto k = bro_broker::val_to_data(key);
|
||||
auto k = zeek::Broker::detail::val_to_data(key);
|
||||
|
||||
if ( ! k )
|
||||
{
|
||||
|
@ -272,23 +272,23 @@ function Broker::__table_lookup%(t: Broker::Data, key: any%): Broker::Data
|
|||
if ( it == table.end() )
|
||||
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
else
|
||||
return bro_broker::make_data_val(it->second);
|
||||
return zeek::Broker::detail::make_data_val(it->second);
|
||||
%}
|
||||
|
||||
function Broker::__table_iterator%(t: Broker::Data%): opaque of Broker::TableIterator
|
||||
%{
|
||||
return zeek::make_intrusive<bro_broker::TableIterator>(t->AsRecordVal(), zeek::TYPE_TABLE, frame);
|
||||
return zeek::make_intrusive<zeek::Broker::detail::TableIterator>(t->AsRecordVal(), zeek::TYPE_TABLE, frame);
|
||||
%}
|
||||
|
||||
function Broker::__table_iterator_last%(it: opaque of Broker::TableIterator%): bool
|
||||
%{
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
auto ti = static_cast<zeek::Broker::detail::TableIterator*>(it);
|
||||
return zeek::val_mgr->Bool(ti->it == ti->dat.end());
|
||||
%}
|
||||
|
||||
function Broker::__table_iterator_next%(it: opaque of Broker::TableIterator%): bool
|
||||
%{
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
auto ti = static_cast<zeek::Broker::detail::TableIterator*>(it);
|
||||
|
||||
if ( ti->it == ti->dat.end() )
|
||||
return zeek::val_mgr->False();
|
||||
|
@ -299,7 +299,7 @@ function Broker::__table_iterator_next%(it: opaque of Broker::TableIterator%): b
|
|||
|
||||
function Broker::__table_iterator_value%(it: opaque of Broker::TableIterator%): Broker::TableItem
|
||||
%{
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
auto ti = static_cast<zeek::Broker::detail::TableIterator*>(it);
|
||||
auto rval = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::TableItem);
|
||||
auto key_val = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
auto val_val = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
@ -312,19 +312,19 @@ function Broker::__table_iterator_value%(it: opaque of Broker::TableIterator%):
|
|||
return rval;
|
||||
}
|
||||
|
||||
key_val->Assign(0, zeek::make_intrusive<bro_broker::DataVal>(ti->it->first));
|
||||
val_val->Assign(0, zeek::make_intrusive<bro_broker::DataVal>(ti->it->second));
|
||||
key_val->Assign(0, zeek::make_intrusive<zeek::Broker::detail::DataVal>(ti->it->first));
|
||||
val_val->Assign(0, zeek::make_intrusive<zeek::Broker::detail::DataVal>(ti->it->second));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
function Broker::__vector_create%(%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::vector());
|
||||
return zeek::Broker::detail::make_data_val(broker::vector());
|
||||
%}
|
||||
|
||||
function Broker::__vector_clear%(v: Broker::Data%): bool
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = zeek::Broker::detail::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
vec.clear();
|
||||
return zeek::val_mgr->True();
|
||||
|
@ -332,16 +332,16 @@ 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(),
|
||||
auto& vec = zeek::Broker::detail::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
return zeek::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(),
|
||||
auto& vec = zeek::Broker::detail::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
auto item = bro_broker::val_to_data(d);
|
||||
auto item = zeek::Broker::detail::val_to_data(d);
|
||||
|
||||
if ( ! item )
|
||||
{
|
||||
|
@ -356,9 +356,9 @@ 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(),
|
||||
auto& vec = zeek::Broker::detail::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
auto item = bro_broker::val_to_data(d);
|
||||
auto item = zeek::Broker::detail::val_to_data(d);
|
||||
|
||||
if ( ! item )
|
||||
{
|
||||
|
@ -369,49 +369,49 @@ function Broker::__vector_replace%(v: Broker::Data, idx: count, d: any%): Broker
|
|||
if ( idx >= vec.size() )
|
||||
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
||||
auto rval = bro_broker::make_data_val(move(vec[idx]));
|
||||
auto rval = zeek::Broker::detail::make_data_val(move(vec[idx]));
|
||||
vec[idx] = std::move(*item);
|
||||
return rval;
|
||||
%}
|
||||
|
||||
function Broker::__vector_remove%(v: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = zeek::Broker::detail::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
||||
auto rval = bro_broker::make_data_val(move(vec[idx]));
|
||||
auto rval = zeek::Broker::detail::make_data_val(move(vec[idx]));
|
||||
vec.erase(vec.begin() + idx);
|
||||
return rval;
|
||||
%}
|
||||
|
||||
function Broker::__vector_lookup%(v: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = zeek::Broker::detail::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
zeek::TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
||||
return bro_broker::make_data_val(vec[idx]);
|
||||
return zeek::Broker::detail::make_data_val(vec[idx]);
|
||||
%}
|
||||
|
||||
function Broker::__vector_iterator%(v: Broker::Data%): opaque of Broker::VectorIterator
|
||||
%{
|
||||
return zeek::make_intrusive<bro_broker::VectorIterator>(v->AsRecordVal(), zeek::TYPE_VECTOR, frame);
|
||||
return zeek::make_intrusive<zeek::Broker::detail::VectorIterator>(v->AsRecordVal(), zeek::TYPE_VECTOR, frame);
|
||||
%}
|
||||
|
||||
function Broker::__vector_iterator_last%(it: opaque of Broker::VectorIterator%): bool
|
||||
%{
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
auto vi = static_cast<zeek::Broker::detail::VectorIterator*>(it);
|
||||
return zeek::val_mgr->Bool(vi->it == vi->dat.end());
|
||||
%}
|
||||
|
||||
function Broker::__vector_iterator_next%(it: opaque of Broker::VectorIterator%): bool
|
||||
%{
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
auto vi = static_cast<zeek::Broker::detail::VectorIterator*>(it);
|
||||
|
||||
if ( vi->it == vi->dat.end() )
|
||||
return zeek::val_mgr->False();
|
||||
|
@ -422,7 +422,7 @@ function Broker::__vector_iterator_next%(it: opaque of Broker::VectorIterator%):
|
|||
|
||||
function Broker::__vector_iterator_value%(it: opaque of Broker::VectorIterator%): Broker::Data
|
||||
%{
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
auto vi = static_cast<zeek::Broker::detail::VectorIterator*>(it);
|
||||
auto rval = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
||||
if ( vi->it == vi->dat.end() )
|
||||
|
@ -431,30 +431,30 @@ function Broker::__vector_iterator_value%(it: opaque of Broker::VectorIterator%)
|
|||
return rval;
|
||||
}
|
||||
|
||||
rval->Assign(0, zeek::make_intrusive<bro_broker::DataVal>(*vi->it));
|
||||
rval->Assign(0, zeek::make_intrusive<zeek::Broker::detail::DataVal>(*vi->it));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
function Broker::__record_create%(sz: count%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::vector(sz));
|
||||
return zeek::Broker::detail::make_data_val(broker::vector(sz));
|
||||
%}
|
||||
|
||||
function Broker::__record_size%(r: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::vector>(r->AsRecordVal(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::vector>(r->AsRecordVal(),
|
||||
zeek::TYPE_RECORD, frame);
|
||||
return zeek::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(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::vector>(r->AsRecordVal(),
|
||||
zeek::TYPE_RECORD, frame);
|
||||
if ( idx >= v.size() )
|
||||
return zeek::val_mgr->False();
|
||||
|
||||
auto item = bro_broker::val_to_data(d);
|
||||
auto item = zeek::Broker::detail::val_to_data(d);
|
||||
|
||||
if ( ! item )
|
||||
{
|
||||
|
@ -468,29 +468,29 @@ 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(),
|
||||
auto& v = zeek::Broker::detail::require_data_type<broker::vector>(r->AsRecordVal(),
|
||||
zeek::TYPE_RECORD, frame);
|
||||
|
||||
if ( idx >= v.size() || caf::get_if<broker::none>(&v[idx]) )
|
||||
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
||||
return bro_broker::make_data_val(v[idx]);
|
||||
return zeek::Broker::detail::make_data_val(v[idx]);
|
||||
%}
|
||||
|
||||
function Broker::__record_iterator%(r: Broker::Data%): opaque of Broker::RecordIterator
|
||||
%{
|
||||
return zeek::make_intrusive<bro_broker::RecordIterator>(r->AsRecordVal(), zeek::TYPE_RECORD, frame);
|
||||
return zeek::make_intrusive<zeek::Broker::detail::RecordIterator>(r->AsRecordVal(), zeek::TYPE_RECORD, frame);
|
||||
%}
|
||||
|
||||
function Broker::__record_iterator_last%(it: opaque of Broker::RecordIterator%): bool
|
||||
%{
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
auto ri = static_cast<zeek::Broker::detail::RecordIterator*>(it);
|
||||
return zeek::val_mgr->Bool(ri->it == ri->dat.end());
|
||||
%}
|
||||
|
||||
function Broker::__record_iterator_next%(it: opaque of Broker::RecordIterator%): bool
|
||||
%{
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
auto ri = static_cast<zeek::Broker::detail::RecordIterator*>(it);
|
||||
|
||||
if ( ri->it == ri->dat.end() )
|
||||
return zeek::val_mgr->False();
|
||||
|
@ -501,7 +501,7 @@ function Broker::__record_iterator_next%(it: opaque of Broker::RecordIterator%):
|
|||
|
||||
function Broker::__record_iterator_value%(it: opaque of Broker::RecordIterator%): Broker::Data
|
||||
%{
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
auto ri = static_cast<zeek::Broker::detail::RecordIterator*>(it);
|
||||
auto rval = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
|
||||
|
||||
if ( ri->it == ri->dat.end() )
|
||||
|
@ -513,6 +513,6 @@ function Broker::__record_iterator_value%(it: opaque of Broker::RecordIterator%)
|
|||
if ( caf::get_if<broker::none>(&(*ri->it)) )
|
||||
return rval; // field isn't set
|
||||
|
||||
rval->Assign(0, zeek::make_intrusive<bro_broker::DataVal>(*ri->it));
|
||||
rval->Assign(0, zeek::make_intrusive<zeek::Broker::detail::DataVal>(*ri->it));
|
||||
return rval;
|
||||
%}
|
||||
|
|
|
@ -50,16 +50,16 @@ std::set<std::string> val_to_topic_set(zeek::Val* val)
|
|||
static bool publish_event_args(val_list& args, const zeek::String* topic,
|
||||
zeek::detail::Frame* frame)
|
||||
{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = false;
|
||||
|
||||
if ( args[0]->GetType()->Tag() == zeek::TYPE_RECORD )
|
||||
rval = broker_mgr->PublishEvent(topic->CheckString(),
|
||||
args[0]->AsRecordVal());
|
||||
rval = zeek::broker_mgr->PublishEvent(topic->CheckString(),
|
||||
args[0]->AsRecordVal());
|
||||
else
|
||||
{
|
||||
auto ev = broker_mgr->MakeEvent(&args, frame);
|
||||
rval = broker_mgr->PublishEvent(topic->CheckString(), ev);
|
||||
auto ev = zeek::broker_mgr->MakeEvent(&args, frame);
|
||||
rval = zeek::broker_mgr->PublishEvent(topic->CheckString(), ev);
|
||||
Unref(ev);
|
||||
}
|
||||
|
||||
|
@ -82,14 +82,14 @@ type Broker::Event: record;
|
|||
## event.
|
||||
function Broker::make_event%(...%): Broker::Event
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
const auto& bif_args = @ARGS@;
|
||||
val_list args(bif_args->size());
|
||||
|
||||
for ( auto i = 0u; i < bif_args->size(); ++i )
|
||||
args.push_back((*bif_args)[i].get());
|
||||
|
||||
return RecordValPtr{zeek::AdoptRef{}, broker_mgr->MakeEvent(&args, frame)};
|
||||
return RecordValPtr{zeek::AdoptRef{}, zeek::broker_mgr->MakeEvent(&args, frame)};
|
||||
%}
|
||||
|
||||
## Publishes an event at a given topic.
|
||||
|
@ -115,50 +115,50 @@ function Broker::publish%(topic: string, ...%): bool
|
|||
|
||||
function Broker::__flush_logs%(%): count
|
||||
%{
|
||||
auto rval = broker_mgr->FlushLogBuffers();
|
||||
auto rval = zeek::broker_mgr->FlushLogBuffers();
|
||||
return zeek::val_mgr->Count(static_cast<uint64_t>(rval));
|
||||
%}
|
||||
|
||||
function Broker::__publish_id%(topic: string, id: string%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = broker_mgr->PublishIdentifier(topic->CheckString(),
|
||||
id->CheckString());
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = zeek::broker_mgr->PublishIdentifier(topic->CheckString(),
|
||||
id->CheckString());
|
||||
return zeek::val_mgr->Bool(rval);
|
||||
%}
|
||||
|
||||
function Broker::__auto_publish%(topic: string, ev: any%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = broker_mgr->AutoPublishEvent(topic->CheckString(), ev);
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = zeek::broker_mgr->AutoPublishEvent(topic->CheckString(), ev);
|
||||
return zeek::val_mgr->Bool(rval);
|
||||
%}
|
||||
|
||||
function Broker::__auto_unpublish%(topic: string, ev: any%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = broker_mgr->AutoUnpublishEvent(topic->CheckString(), ev);
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = zeek::broker_mgr->AutoUnpublishEvent(topic->CheckString(), ev);
|
||||
return zeek::val_mgr->Bool(rval);
|
||||
%}
|
||||
|
||||
function Broker::__subscribe%(topic_prefix: string%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = broker_mgr->Subscribe(topic_prefix->CheckString());
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = zeek::broker_mgr->Subscribe(topic_prefix->CheckString());
|
||||
return zeek::val_mgr->Bool(rval);
|
||||
%}
|
||||
|
||||
function Broker::__forward%(topic_prefix: string%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = broker_mgr->Forward(topic_prefix->CheckString());
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = zeek::broker_mgr->Forward(topic_prefix->CheckString());
|
||||
return zeek::val_mgr->Bool(rval);
|
||||
%}
|
||||
|
||||
function Broker::__unsubscribe%(topic_prefix: string%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = broker_mgr->Unsubscribe(topic_prefix->CheckString());
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto rval = zeek::broker_mgr->Unsubscribe(topic_prefix->CheckString());
|
||||
return zeek::val_mgr->Bool(rval);
|
||||
%}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "broker/Data.h"
|
||||
#include "Trigger.h"
|
||||
|
||||
static bro_broker::StoreHandleVal* to_store_handle(zeek::Val* h)
|
||||
{ return dynamic_cast<bro_broker::StoreHandleVal*>(h); }
|
||||
static zeek::Broker::detail::StoreHandleVal* to_store_handle(zeek::Val* h)
|
||||
{ return dynamic_cast<zeek::Broker::detail::StoreHandleVal*>(h); }
|
||||
%%}
|
||||
|
||||
module Broker;
|
||||
|
@ -26,7 +26,7 @@ enum BackendType %{
|
|||
function Broker::__create_master%(id: string, b: BackendType,
|
||||
options: BackendOptions &default = BackendOptions()%): opaque of Broker::Store
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto name = id->CheckString();
|
||||
auto rval = broker_mgr->LookupStore(name);
|
||||
|
||||
|
@ -34,8 +34,8 @@ function Broker::__create_master%(id: string, b: BackendType,
|
|||
return ValPtr{zeek::NewRef{}, rval};
|
||||
|
||||
auto e = static_cast<BifEnum::Broker::BackendType>(b->AsEnum());
|
||||
auto type = bro_broker::to_backend_type(e);
|
||||
auto opts = bro_broker::to_backend_options(type, options->AsRecordVal());
|
||||
auto type = zeek::Broker::detail::to_backend_type(e);
|
||||
auto opts = zeek::Broker::detail::to_backend_options(type, options->AsRecordVal());
|
||||
|
||||
ValPtr store{zeek::AdoptRef{}, broker_mgr->MakeMaster(name, type, std::move(opts))};
|
||||
|
||||
|
@ -52,7 +52,7 @@ function Broker::__create_clone%(id: string, resync_interval: interval,
|
|||
stale_interval: interval,
|
||||
mutation_buffer_interval: interval%): opaque of Broker::Store
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto name = id->CheckString();
|
||||
auto rval = broker_mgr->LookupStore(name);
|
||||
|
||||
|
@ -75,7 +75,7 @@ function Broker::__create_clone%(id: string, resync_interval: interval,
|
|||
|
||||
function Broker::__is_closed%(h: opaque of Broker::Store%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto handle = to_store_handle(h);
|
||||
|
||||
if ( ! handle )
|
||||
|
@ -86,7 +86,7 @@ function Broker::__is_closed%(h: opaque of Broker::Store%): bool
|
|||
|
||||
function Broker::__close%(h: opaque of Broker::Store%): bool
|
||||
%{
|
||||
bro_broker::Manager::ScriptScopeGuard ssg;
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
auto handle = to_store_handle(h);
|
||||
|
||||
if ( ! handle )
|
||||
|
@ -116,15 +116,15 @@ function Broker::__exists%(h: opaque of Broker::Store,
|
|||
if ( ! handle )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker store handle", h);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker data conversion for key argument", k);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto trigger = frame->GetTrigger();
|
||||
|
@ -132,7 +132,7 @@ function Broker::__exists%(h: opaque of Broker::Store,
|
|||
if ( ! trigger )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto timeout = trigger->TimeoutValue();
|
||||
|
@ -140,14 +140,14 @@ function Broker::__exists%(h: opaque of Broker::Store,
|
|||
if ( timeout < 0 )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries must specify a timeout block");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
frame->SetDelayed();
|
||||
trigger->Hold();
|
||||
|
||||
auto cb = new bro_broker::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto cb = new zeek::Broker::detail::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto req_id = handle->proxy.exists(std::move(*key));
|
||||
broker_mgr->TrackStoreQuery(handle, req_id, cb);
|
||||
|
||||
|
@ -162,15 +162,15 @@ function Broker::__get%(h: opaque of Broker::Store,
|
|||
if ( ! handle )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker store handle", h);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker data conversion for key argument", k);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto trigger = frame->GetTrigger();
|
||||
|
@ -178,7 +178,7 @@ function Broker::__get%(h: opaque of Broker::Store,
|
|||
if ( ! trigger )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto timeout = trigger->TimeoutValue();
|
||||
|
@ -186,14 +186,14 @@ function Broker::__get%(h: opaque of Broker::Store,
|
|||
if ( timeout < 0 )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries must specify a timeout block");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
frame->SetDelayed();
|
||||
trigger->Hold();
|
||||
|
||||
auto cb = new bro_broker::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto cb = new zeek::Broker::detail::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto req_id = handle->proxy.get(std::move(*key));
|
||||
broker_mgr->TrackStoreQuery(handle, req_id, cb);
|
||||
|
||||
|
@ -208,22 +208,22 @@ function Broker::__put_unique%(h: opaque of Broker::Store,
|
|||
if ( ! handle )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker store handle", h);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto val = bro_broker::val_to_data(v);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto val = zeek::Broker::detail::val_to_data(v);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker data conversion for key argument", k);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
if ( ! val )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker data conversion for value argument", v);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto trigger = frame->GetTrigger();
|
||||
|
@ -231,7 +231,7 @@ function Broker::__put_unique%(h: opaque of Broker::Store,
|
|||
if ( ! trigger )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto timeout = trigger->TimeoutValue();
|
||||
|
@ -239,17 +239,17 @@ function Broker::__put_unique%(h: opaque of Broker::Store,
|
|||
if ( timeout < 0 )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries must specify a timeout block");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
frame->SetDelayed();
|
||||
trigger->Hold();
|
||||
|
||||
auto cb = new bro_broker::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto cb = new zeek::Broker::detail::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
|
||||
auto req_id = handle->proxy.put_unique(std::move(*key), std::move(*val),
|
||||
bro_broker::convert_expiry(e));
|
||||
zeek::Broker::detail::convert_expiry(e));
|
||||
broker_mgr->TrackStoreQuery(handle, req_id, cb);
|
||||
|
||||
return nullptr;
|
||||
|
@ -263,23 +263,23 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
|
|||
if ( ! handle )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker store handle", h);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker data conversion for key argument", k);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto index = bro_broker::val_to_data(i);
|
||||
auto index = zeek::Broker::detail::val_to_data(i);
|
||||
|
||||
if ( ! index )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker data conversion for index argument", i);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto trigger = frame->GetTrigger();
|
||||
|
@ -287,7 +287,7 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
|
|||
if ( ! trigger )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto timeout = trigger->TimeoutValue();
|
||||
|
@ -295,14 +295,14 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
|
|||
if ( timeout < 0 )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries must specify a timeout block");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
frame->SetDelayed();
|
||||
trigger->Hold();
|
||||
|
||||
auto cb = new bro_broker::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto cb = new zeek::Broker::detail::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto req_id = handle->proxy.get_index_from_value(std::move(*key),
|
||||
std::move(*index));
|
||||
broker_mgr->TrackStoreQuery(handle, req_id, cb);
|
||||
|
@ -317,7 +317,7 @@ function Broker::__keys%(h: opaque of Broker::Store%): Broker::QueryResult
|
|||
if ( ! handle )
|
||||
{
|
||||
zeek::emit_builtin_error("invalid Broker store handle", h);
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto trigger = frame->GetTrigger();
|
||||
|
@ -325,7 +325,7 @@ function Broker::__keys%(h: opaque of Broker::Store%): Broker::QueryResult
|
|||
if ( ! trigger )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
auto timeout = trigger->TimeoutValue();
|
||||
|
@ -333,13 +333,13 @@ function Broker::__keys%(h: opaque of Broker::Store%): Broker::QueryResult
|
|||
if ( timeout < 0 )
|
||||
{
|
||||
zeek::emit_builtin_error("Broker queries must specify a timeout block");
|
||||
return bro_broker::query_result();
|
||||
return zeek::Broker::detail::query_result();
|
||||
}
|
||||
|
||||
frame->SetDelayed();
|
||||
trigger->Hold();
|
||||
|
||||
auto cb = new bro_broker::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
auto cb = new zeek::Broker::detail::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
handle->store);
|
||||
auto req_id = handle->proxy.keys();
|
||||
broker_mgr->TrackStoreQuery(handle, req_id, cb);
|
||||
|
@ -358,8 +358,8 @@ function Broker::__put%(h: opaque of Broker::Store,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto val = bro_broker::val_to_data(v);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto val = zeek::Broker::detail::val_to_data(v);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -373,7 +373,7 @@ function Broker::__put%(h: opaque of Broker::Store,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
handle->store.put(std::move(*key), std::move(*val), bro_broker::convert_expiry(e));
|
||||
handle->store.put(std::move(*key), std::move(*val), zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -387,7 +387,7 @@ function Broker::__erase%(h: opaque of Broker::Store, k: any%): bool
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -410,8 +410,8 @@ function Broker::__increment%(h: opaque of Broker::Store, k: any, a: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto amount = bro_broker::val_to_data(a);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto amount = zeek::Broker::detail::val_to_data(a);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -426,7 +426,7 @@ function Broker::__increment%(h: opaque of Broker::Store, k: any, a: any,
|
|||
}
|
||||
|
||||
handle->store.increment(std::move(*key), std::move(*amount),
|
||||
bro_broker::convert_expiry(e));
|
||||
zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -441,8 +441,8 @@ function Broker::__decrement%(h: opaque of Broker::Store, k: any, a: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto amount = bro_broker::val_to_data(a);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto amount = zeek::Broker::detail::val_to_data(a);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -456,7 +456,7 @@ function Broker::__decrement%(h: opaque of Broker::Store, k: any, a: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
handle->store.decrement(std::move(*key), std::move(*amount), bro_broker::convert_expiry(e));
|
||||
handle->store.decrement(std::move(*key), std::move(*amount), zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -471,8 +471,8 @@ function Broker::__append%(h: opaque of Broker::Store, k: any, s: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto str = bro_broker::val_to_data(s);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto str = zeek::Broker::detail::val_to_data(s);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -486,7 +486,7 @@ function Broker::__append%(h: opaque of Broker::Store, k: any, s: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
handle->store.append(std::move(*key), std::move(*str), bro_broker::convert_expiry(e));
|
||||
handle->store.append(std::move(*key), std::move(*str), zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -501,8 +501,8 @@ function Broker::__insert_into_set%(h: opaque of Broker::Store, k: any, i: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto idx = bro_broker::val_to_data(i);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto idx = zeek::Broker::detail::val_to_data(i);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -517,7 +517,7 @@ function Broker::__insert_into_set%(h: opaque of Broker::Store, k: any, i: any,
|
|||
}
|
||||
|
||||
handle->store.insert_into(std::move(*key), std::move(*idx),
|
||||
bro_broker::convert_expiry(e));
|
||||
zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -532,9 +532,9 @@ function Broker::__insert_into_table%(h: opaque of Broker::Store, k: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto idx = bro_broker::val_to_data(i);
|
||||
auto val = bro_broker::val_to_data(v);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto idx = zeek::Broker::detail::val_to_data(i);
|
||||
auto val = zeek::Broker::detail::val_to_data(v);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -555,7 +555,7 @@ function Broker::__insert_into_table%(h: opaque of Broker::Store, k: any,
|
|||
}
|
||||
|
||||
handle->store.insert_into(std::move(*key), std::move(*idx),
|
||||
std::move(*val), bro_broker::convert_expiry(e));
|
||||
std::move(*val), zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -570,8 +570,8 @@ function Broker::__remove_from%(h: opaque of Broker::Store, k: any, i: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto idx = bro_broker::val_to_data(i);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto idx = zeek::Broker::detail::val_to_data(i);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -586,7 +586,7 @@ function Broker::__remove_from%(h: opaque of Broker::Store, k: any, i: any,
|
|||
}
|
||||
|
||||
handle->store.remove_from(std::move(*key), std::move(*idx),
|
||||
bro_broker::convert_expiry(e));
|
||||
zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -601,8 +601,8 @@ function Broker::__push%(h: opaque of Broker::Store, k: any, v: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto val = bro_broker::val_to_data(v);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
auto val = zeek::Broker::detail::val_to_data(v);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -616,7 +616,7 @@ function Broker::__push%(h: opaque of Broker::Store, k: any, v: any,
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
handle->store.push(std::move(*key), std::move(*val), bro_broker::convert_expiry(e));
|
||||
handle->store.push(std::move(*key), std::move(*val), zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
@ -630,7 +630,7 @@ function Broker::__pop%(h: opaque of Broker::Store, k: any, e: interval%): bool
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
auto key = bro_broker::val_to_data(k);
|
||||
auto key = zeek::Broker::detail::val_to_data(k);
|
||||
|
||||
if ( ! key )
|
||||
{
|
||||
|
@ -638,7 +638,7 @@ function Broker::__pop%(h: opaque of Broker::Store, k: any, e: interval%): bool
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
handle->store.pop(std::move(*key), bro_broker::convert_expiry(e));
|
||||
handle->store.pop(std::move(*key), zeek::Broker::detail::convert_expiry(e));
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
|
|
|
@ -78,9 +78,9 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
|
|||
return zeek::val_mgr->False();
|
||||
}
|
||||
|
||||
if ( same_type(val->GetType(), bro_broker::DataVal::ScriptDataType()) )
|
||||
if ( same_type(val->GetType(), zeek::Broker::detail::DataVal::ScriptDataType()) )
|
||||
{
|
||||
auto dv = static_cast<bro_broker::DataVal*>(val->AsRecordVal()->GetField(0).get());
|
||||
auto dv = static_cast<zeek::Broker::detail::DataVal*>(val->AsRecordVal()->GetField(0).get());
|
||||
auto val_from_data = dv->castTo(i->GetType().get());
|
||||
|
||||
if ( ! val_from_data )
|
||||
|
|
|
@ -429,7 +429,7 @@ broker::expected<broker::data> TopkVal::DoSerialize() const
|
|||
{
|
||||
Element* element = *eit;
|
||||
d.emplace_back(element->epsilon);
|
||||
auto v = bro_broker::val_to_data(element->value.get());
|
||||
auto v = zeek::Broker::detail::val_to_data(element->value.get());
|
||||
if ( ! v )
|
||||
return broker::ec::invalid_data;
|
||||
|
||||
|
@ -494,7 +494,7 @@ bool TopkVal::DoUnserialize(const broker::data& data)
|
|||
for ( uint64_t j = 0; j < *elements_count; j++ )
|
||||
{
|
||||
auto epsilon = caf::get_if<uint64_t>(&(*v)[idx++]);
|
||||
auto val = bro_broker::data_to_val((*v)[idx++], type.get());
|
||||
auto val = zeek::Broker::detail::data_to_val((*v)[idx++], type.get());
|
||||
|
||||
if ( ! (epsilon && val) )
|
||||
return false;
|
||||
|
|
|
@ -113,7 +113,8 @@ zeek::file_analysis::Manager*& file_mgr = zeek::file_mgr;
|
|||
zeekygen::Manager* zeekygen_mgr = nullptr;
|
||||
zeek::iosource::Manager* zeek::iosource_mgr = nullptr;
|
||||
zeek::iosource::Manager*& iosource_mgr = zeek::iosource_mgr;
|
||||
bro_broker::Manager* broker_mgr = nullptr;
|
||||
zeek::Broker::Manager* zeek::broker_mgr = nullptr;
|
||||
zeek::Broker::Manager*& broker_mgr = zeek::broker_mgr;
|
||||
zeek::Supervisor* zeek::supervisor_mgr = nullptr;
|
||||
zeek::detail::trigger::Manager* trigger_mgr = nullptr;
|
||||
|
||||
|
@ -311,7 +312,7 @@ void terminate_bro()
|
|||
zeek::log_mgr->Terminate();
|
||||
zeek::input_mgr->Terminate();
|
||||
zeek::thread_mgr->Terminate();
|
||||
broker_mgr->Terminate();
|
||||
zeek::broker_mgr->Terminate();
|
||||
zeek::detail::dns_mgr->Terminate();
|
||||
|
||||
zeek::event_mgr.Drain();
|
||||
|
@ -588,7 +589,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
zeek::input_mgr = new input::Manager();
|
||||
zeek::file_mgr = new file_analysis::Manager();
|
||||
auto broker_real_time = ! options.pcap_file && ! options.deterministic_mode;
|
||||
broker_mgr = new bro_broker::Manager(broker_real_time);
|
||||
broker_mgr = new zeek::Broker::Manager(broker_real_time);
|
||||
trigger_mgr = new zeek::detail::trigger::Manager();
|
||||
|
||||
zeek::plugin_mgr->InitPreScript();
|
||||
|
@ -665,7 +666,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
zeek::log_mgr->InitPostScript();
|
||||
zeek::plugin_mgr->InitPostScript();
|
||||
zeekygen_mgr->InitPostScript();
|
||||
broker_mgr->InitPostScript();
|
||||
zeek::broker_mgr->InitPostScript();
|
||||
zeek::detail::timer_mgr->InitPostScript();
|
||||
zeek::event_mgr.InitPostScript();
|
||||
|
||||
|
@ -876,7 +877,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
if ( zeek::reporter->Errors() > 0 && ! zeekenv("ZEEK_ALLOW_INIT_ERRORS") )
|
||||
zeek::reporter->FatalError("errors occurred while initializing");
|
||||
|
||||
broker_mgr->ZeekInitDone();
|
||||
zeek::broker_mgr->ZeekInitDone();
|
||||
zeek::reporter->ZeekInitDone();
|
||||
zeek::analyzer_mgr->DumpDebug();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue