Deprecate RecordVal(RecordType*) ctor

Replaced with one that takes IntrusivePtr
This commit is contained in:
Jon Siwek 2020-05-14 19:31:43 -07:00
parent 4debad8caf
commit 440b0623ac
22 changed files with 135 additions and 181 deletions

3
NEWS
View file

@ -184,6 +184,9 @@ Deprecated Functionality
equivalent name now in ``zeek::BifCont::``, and changed to ``IntrusivePtr`` equivalent name now in ``zeek::BifCont::``, and changed to ``IntrusivePtr``
if the old name was some ``Val*`` type. if the old name was some ``Val*`` type.
- Constructors for ``Val`` types that take a ``BroType*`` are all generally
deprecated, with alternatives that instead take an ``IntrusivePtr`` argument.
Zeek 3.1.0 Zeek 3.1.0
========== ==========

View file

@ -927,7 +927,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
ASSERT(int(values.size()) == num_fields); ASSERT(int(values.size()) == num_fields);
auto rv = make_intrusive<RecordVal>(rt); auto rv = make_intrusive<RecordVal>(IntrusivePtr{NewRef{}, rt});
for ( int i = 0; i < num_fields; ++i ) for ( int i = 0; i < num_fields; ++i )
rv->Assign(i, values[i]); rv->Assign(i, values[i]);

View file

@ -381,8 +381,6 @@ DNS_Mgr::DNS_Mgr(DNS_MgrMode arg_mode)
mode = arg_mode; mode = arg_mode;
dm_rec = nullptr;
cache_name = dir = nullptr; cache_name = dir = nullptr;
asyncs_pending = 0; asyncs_pending = 0;
@ -452,7 +450,7 @@ void DNS_Mgr::InitSource()
void DNS_Mgr::InitPostScript() void DNS_Mgr::InitPostScript()
{ {
dm_rec = zeek::id::find_type("dns_mapping")->AsRecordType(); dm_rec = zeek::id::find_type<RecordType>("dns_mapping");
// Registering will call Init() // Registering will call Init()
iosource_mgr->Register(this, true); iosource_mgr->Register(this, true);

View file

@ -149,7 +149,7 @@ protected:
bool did_init; bool did_init;
RecordType* dm_rec; IntrusivePtr<RecordType> dm_rec;
typedef std::list<LookupCallback*> CallbackList; typedef std::list<LookupCallback*> CallbackList;

View file

@ -3031,12 +3031,12 @@ IntrusivePtr<Val> RecordConstructorExpr::InitVal(const BroType* t, IntrusivePtr<
IntrusivePtr<Val> RecordConstructorExpr::Fold(Val* v) const IntrusivePtr<Val> RecordConstructorExpr::Fold(Val* v) const
{ {
ListVal* lv = v->AsListVal(); ListVal* lv = v->AsListVal();
RecordType* rt = type->AsRecordType(); auto rt = cast_intrusive<RecordType>(type);
if ( lv->Length() != rt->NumFields() ) if ( lv->Length() != rt->NumFields() )
RuntimeErrorWithCallStack("inconsistency evaluating record constructor"); RuntimeErrorWithCallStack("inconsistency evaluating record constructor");
auto rv = make_intrusive<RecordVal>(rt); auto rv = make_intrusive<RecordVal>(std::move(rt));
for ( int i = 0; i < lv->Length(); ++i ) for ( int i = 0; i < lv->Length(); ++i )
rv->Assign(i, lv->Idx(i)); rv->Assign(i, lv->Idx(i));
@ -3643,7 +3643,7 @@ IntrusivePtr<Val> RecordCoerceExpr::InitVal(const BroType* t, IntrusivePtr<Val>
IntrusivePtr<Val> RecordCoerceExpr::Fold(Val* v) const IntrusivePtr<Val> RecordCoerceExpr::Fold(Val* v) const
{ {
auto val = make_intrusive<RecordVal>(GetType()->AsRecordType()); auto val = make_intrusive<RecordVal>(GetType<RecordType>());
RecordType* val_type = val->GetType()->AsRecordType(); RecordType* val_type = val->GetType()->AsRecordType();
RecordVal* rv = v->AsRecordVal(); RecordVal* rv = v->AsRecordVal();

View file

@ -748,19 +748,19 @@ void builtin_error(const char* msg, BroObj* arg)
void init_builtin_funcs() void init_builtin_funcs()
{ {
ProcStats = zeek::id::find_type("ProcStats")->AsRecordType(); ProcStats = zeek::id::find_type<RecordType>("ProcStats");
NetStats = zeek::id::find_type("NetStats")->AsRecordType(); NetStats = zeek::id::find_type<RecordType>("NetStats");
MatcherStats = zeek::id::find_type("MatcherStats")->AsRecordType(); MatcherStats = zeek::id::find_type<RecordType>("MatcherStats");
ConnStats = zeek::id::find_type("ConnStats")->AsRecordType(); ConnStats = zeek::id::find_type<RecordType>("ConnStats");
ReassemblerStats = zeek::id::find_type("ReassemblerStats")->AsRecordType(); ReassemblerStats = zeek::id::find_type<RecordType>("ReassemblerStats");
DNSStats = zeek::id::find_type("DNSStats")->AsRecordType(); DNSStats = zeek::id::find_type<RecordType>("DNSStats");
GapStats = zeek::id::find_type("GapStats")->AsRecordType(); GapStats = zeek::id::find_type<RecordType>("GapStats");
EventStats = zeek::id::find_type("EventStats")->AsRecordType(); EventStats = zeek::id::find_type<RecordType>("EventStats");
TimerStats = zeek::id::find_type("TimerStats")->AsRecordType(); TimerStats = zeek::id::find_type<RecordType>("TimerStats");
FileAnalysisStats = zeek::id::find_type("FileAnalysisStats")->AsRecordType(); FileAnalysisStats = zeek::id::find_type<RecordType>("FileAnalysisStats");
ThreadStats = zeek::id::find_type("ThreadStats")->AsRecordType(); ThreadStats = zeek::id::find_type<RecordType>("ThreadStats");
BrokerStats = zeek::id::find_type("BrokerStats")->AsRecordType(); BrokerStats = zeek::id::find_type<RecordType>("BrokerStats");
ReporterStats = zeek::id::find_type("ReporterStats")->AsRecordType(); ReporterStats = zeek::id::find_type<RecordType>("ReporterStats");
var_sizes = zeek::id::find_type("var_sizes")->AsTableType(); var_sizes = zeek::id::find_type("var_sizes")->AsTableType();

129
src/IP.cc
View file

@ -13,43 +13,15 @@
#include "BroString.h" #include "BroString.h"
#include "Reporter.h" #include "Reporter.h"
static RecordType* ip4_hdr_type = nullptr;
static RecordType* ip6_hdr_type = nullptr;
static RecordType* ip6_ext_hdr_type = nullptr;
static RecordType* ip6_option_type = nullptr;
static RecordType* ip6_hopopts_type = nullptr;
static RecordType* ip6_dstopts_type = nullptr;
static RecordType* ip6_routing_type = nullptr;
static RecordType* ip6_fragment_type = nullptr;
static RecordType* ip6_ah_type = nullptr;
static RecordType* ip6_esp_type = nullptr;
static RecordType* ip6_mob_type = nullptr;
static RecordType* ip6_mob_msg_type = nullptr;
static RecordType* ip6_mob_brr_type = nullptr;
static RecordType* ip6_mob_hoti_type = nullptr;
static RecordType* ip6_mob_coti_type = nullptr;
static RecordType* ip6_mob_hot_type = nullptr;
static RecordType* ip6_mob_cot_type = nullptr;
static RecordType* ip6_mob_bu_type = nullptr;
static RecordType* ip6_mob_back_type = nullptr;
static RecordType* ip6_mob_be_type = nullptr;
static inline RecordType* hdrType(RecordType*& type, const char* name)
{
if ( ! type )
type = zeek::id::find_type(name)->AsRecordType();
return type;
}
static IntrusivePtr<VectorVal> BuildOptionsVal(const u_char* data, int len) static IntrusivePtr<VectorVal> BuildOptionsVal(const u_char* data, int len)
{ {
auto vv = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("ip6_options")); auto vv = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("ip6_options"));
while ( len > 0 ) while ( len > 0 )
{ {
static auto ip6_option_type = zeek::id::find_type<RecordType>("ip6_option");
const struct ip6_opt* opt = (const struct ip6_opt*) data; const struct ip6_opt* opt = (const struct ip6_opt*) data;
auto rv = make_intrusive<RecordVal>(hdrType(ip6_option_type, "ip6_option")); auto rv = make_intrusive<RecordVal>(ip6_option_type);
rv->Assign(0, val_mgr->Count(opt->ip6o_type)); rv->Assign(0, val_mgr->Count(opt->ip6o_type));
if ( opt->ip6o_type == 0 ) if ( opt->ip6o_type == 0 )
@ -84,7 +56,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
switch ( type ) { switch ( type ) {
case IPPROTO_IPV6: case IPPROTO_IPV6:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_hdr_type, "ip6_hdr")); static auto ip6_hdr_type = zeek::id::find_type<RecordType>("ip6_hdr");
rv = make_intrusive<RecordVal>(ip6_hdr_type);
const struct ip6_hdr* ip6 = (const struct ip6_hdr*)data; const struct ip6_hdr* ip6 = (const struct ip6_hdr*)data;
rv->Assign(0, val_mgr->Count((ntohl(ip6->ip6_flow) & 0x0ff00000)>>20)); rv->Assign(0, val_mgr->Count((ntohl(ip6->ip6_flow) & 0x0ff00000)>>20));
rv->Assign(1, val_mgr->Count(ntohl(ip6->ip6_flow) & 0x000fffff)); rv->Assign(1, val_mgr->Count(ntohl(ip6->ip6_flow) & 0x000fffff));
@ -102,7 +75,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case IPPROTO_HOPOPTS: case IPPROTO_HOPOPTS:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_hopopts_type, "ip6_hopopts")); static auto ip6_hopopts_type = zeek::id::find_type<RecordType>("ip6_hopopts");
rv = make_intrusive<RecordVal>(ip6_hopopts_type);
const struct ip6_hbh* hbh = (const struct ip6_hbh*)data; const struct ip6_hbh* hbh = (const struct ip6_hbh*)data;
rv->Assign(0, val_mgr->Count(hbh->ip6h_nxt)); rv->Assign(0, val_mgr->Count(hbh->ip6h_nxt));
rv->Assign(1, val_mgr->Count(hbh->ip6h_len)); rv->Assign(1, val_mgr->Count(hbh->ip6h_len));
@ -114,7 +88,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case IPPROTO_DSTOPTS: case IPPROTO_DSTOPTS:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_dstopts_type, "ip6_dstopts")); static auto ip6_dstopts_type = zeek::id::find_type<RecordType>("ip6_dstopts");
rv = make_intrusive<RecordVal>(ip6_dstopts_type);
const struct ip6_dest* dst = (const struct ip6_dest*)data; const struct ip6_dest* dst = (const struct ip6_dest*)data;
rv->Assign(0, val_mgr->Count(dst->ip6d_nxt)); rv->Assign(0, val_mgr->Count(dst->ip6d_nxt));
rv->Assign(1, val_mgr->Count(dst->ip6d_len)); rv->Assign(1, val_mgr->Count(dst->ip6d_len));
@ -125,7 +100,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case IPPROTO_ROUTING: case IPPROTO_ROUTING:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_routing_type, "ip6_routing")); static auto ip6_routing_type = zeek::id::find_type<RecordType>("ip6_routing");
rv = make_intrusive<RecordVal>(ip6_routing_type);
const struct ip6_rthdr* rt = (const struct ip6_rthdr*)data; const struct ip6_rthdr* rt = (const struct ip6_rthdr*)data;
rv->Assign(0, val_mgr->Count(rt->ip6r_nxt)); rv->Assign(0, val_mgr->Count(rt->ip6r_nxt));
rv->Assign(1, val_mgr->Count(rt->ip6r_len)); rv->Assign(1, val_mgr->Count(rt->ip6r_len));
@ -138,7 +114,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case IPPROTO_FRAGMENT: case IPPROTO_FRAGMENT:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_fragment_type, "ip6_fragment")); static auto ip6_fragment_type = zeek::id::find_type<RecordType>("ip6_fragment");
rv = make_intrusive<RecordVal>(ip6_fragment_type);
const struct ip6_frag* frag = (const struct ip6_frag*)data; const struct ip6_frag* frag = (const struct ip6_frag*)data;
rv->Assign(0, val_mgr->Count(frag->ip6f_nxt)); rv->Assign(0, val_mgr->Count(frag->ip6f_nxt));
rv->Assign(1, val_mgr->Count(frag->ip6f_reserved)); rv->Assign(1, val_mgr->Count(frag->ip6f_reserved));
@ -151,7 +128,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case IPPROTO_AH: case IPPROTO_AH:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_ah_type, "ip6_ah")); static auto ip6_ah_type = zeek::id::find_type<RecordType>("ip6_ah");
rv = make_intrusive<RecordVal>(ip6_ah_type);
rv->Assign(0, val_mgr->Count(((ip6_ext*)data)->ip6e_nxt)); rv->Assign(0, val_mgr->Count(((ip6_ext*)data)->ip6e_nxt));
rv->Assign(1, val_mgr->Count(((ip6_ext*)data)->ip6e_len)); rv->Assign(1, val_mgr->Count(((ip6_ext*)data)->ip6e_len));
rv->Assign(2, val_mgr->Count(ntohs(((uint16_t*)data)[1]))); rv->Assign(2, val_mgr->Count(ntohs(((uint16_t*)data)[1])));
@ -170,7 +148,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case IPPROTO_ESP: case IPPROTO_ESP:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_esp_type, "ip6_esp")); static auto ip6_esp_type = zeek::id::find_type<RecordType>("ip6_esp");
rv = make_intrusive<RecordVal>(ip6_esp_type);
const uint32_t* esp = (const uint32_t*)data; const uint32_t* esp = (const uint32_t*)data;
rv->Assign(0, val_mgr->Count(ntohl(esp[0]))); rv->Assign(0, val_mgr->Count(ntohl(esp[0])));
rv->Assign(1, val_mgr->Count(ntohl(esp[1]))); rv->Assign(1, val_mgr->Count(ntohl(esp[1])));
@ -180,7 +159,8 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
#ifdef ENABLE_MOBILE_IPV6 #ifdef ENABLE_MOBILE_IPV6
case IPPROTO_MOBILITY: case IPPROTO_MOBILITY:
{ {
rv = make_intrusive<RecordVal>(hdrType(ip6_mob_type, "ip6_mobility_hdr")); static auto ip6_mob_type = zeek::id::find_type<RecordType>("ip6_mobility_hdr");
rv = make_intrusive<RecordVal>(ip6_mob_type);
const struct ip6_mobility* mob = (const struct ip6_mobility*) data; const struct ip6_mobility* mob = (const struct ip6_mobility*) data;
rv->Assign(0, val_mgr->Count(mob->ip6mob_payload)); rv->Assign(0, val_mgr->Count(mob->ip6mob_payload));
rv->Assign(1, val_mgr->Count(mob->ip6mob_len)); rv->Assign(1, val_mgr->Count(mob->ip6mob_len));
@ -188,16 +168,26 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
rv->Assign(3, val_mgr->Count(mob->ip6mob_rsv)); rv->Assign(3, val_mgr->Count(mob->ip6mob_rsv));
rv->Assign(4, val_mgr->Count(ntohs(mob->ip6mob_chksum))); rv->Assign(4, val_mgr->Count(ntohs(mob->ip6mob_chksum)));
auto msg = make_intrusive<RecordVal>(hdrType(ip6_mob_msg_type, "ip6_mobility_msg")); static auto ip6_mob_msg_type = zeek::id::find_type<RecordType>("ip6_mobility_msg");
auto msg = make_intrusive<RecordVal>(ip6_mob_msg_type);
msg->Assign(0, val_mgr->Count(mob->ip6mob_type)); msg->Assign(0, val_mgr->Count(mob->ip6mob_type));
uint16_t off = sizeof(ip6_mobility); uint16_t off = sizeof(ip6_mobility);
const u_char* msg_data = data + off; const u_char* msg_data = data + off;
static auto ip6_mob_brr_type = zeek::id::find_type<RecordType>("ip6_mobility_brr");
static auto ip6_mob_hoti_type = zeek::id::find_type<RecordType>("ip6_mobility_hoti");
static auto ip6_mob_coti_type = zeek::id::find_type<RecordType>("ip6_mobility_coti");
static auto ip6_mob_hot_type = zeek::id::find_type<RecordType>("ip6_mobility_hot");
static auto ip6_mob_cot_type = zeek::id::find_type<RecordType>("ip6_mobility_cot");
static auto ip6_mob_bu_type = zeek::id::find_type<RecordType>("ip6_mobility_bu");
static auto ip6_mob_back_type = zeek::id::find_type<RecordType>("ip6_mobility_back");
static auto ip6_mob_be_type = zeek::id::find_type<RecordType>("ip6_mobility_be");
switch ( mob->ip6mob_type ) { switch ( mob->ip6mob_type ) {
case 0: case 0:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_brr")); auto m = make_intrusive<RecordVal>(ip6_mob_brr_type);
m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data)))); m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data))));
off += sizeof(uint16_t); off += sizeof(uint16_t);
m->Assign(1, BuildOptionsVal(data + off, Length() - off)); m->Assign(1, BuildOptionsVal(data + off, Length() - off));
@ -207,7 +197,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case 1: case 1:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_hoti")); auto m = make_intrusive<RecordVal>(ip6_mobility_hoti_type);
m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data)))); m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))))); m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
off += sizeof(uint16_t) + sizeof(uint64_t); off += sizeof(uint16_t) + sizeof(uint64_t);
@ -218,7 +208,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case 2: case 2:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_coti")); auto m = make_intrusive<RecordVal>(ip6_mobility_coti_type);
m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data)))); m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))))); m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
off += sizeof(uint16_t) + sizeof(uint64_t); off += sizeof(uint16_t) + sizeof(uint64_t);
@ -229,7 +219,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case 3: case 3:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_hot")); auto m = make_intrusive<RecordVal>(ip6_mobility_hot_type);
m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data)))); m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))))); m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
m->Assign(2, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t)))))); m->Assign(2, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t))))));
@ -241,7 +231,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case 4: case 4:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_cot")); auto m = make_intrusive<RecordVal>(ip6_mobility_cot_type);
m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data)))); m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))))); m->Assign(1, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
m->Assign(2, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t)))))); m->Assign(2, val_mgr->Count(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t))))));
@ -253,7 +243,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case 5: case 5:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_bu")); auto m = make_intrusive<RecordVal>(ip6_mobility_bu_type);
m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data)))); m->Assign(0, val_mgr->Count(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->Bool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x8000)); m->Assign(1, val_mgr->Bool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x8000));
m->Assign(2, val_mgr->Bool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x4000)); m->Assign(2, val_mgr->Bool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x4000));
@ -268,7 +258,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case 6: case 6:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_back")); auto m = make_intrusive<RecordVal>(ip6_mobility_back_type);
m->Assign(0, val_mgr->Count(*((uint8_t*)msg_data))); m->Assign(0, val_mgr->Count(*((uint8_t*)msg_data)));
m->Assign(1, val_mgr->Bool(*((uint8_t*)(msg_data + sizeof(uint8_t))) & 0x80)); m->Assign(1, val_mgr->Bool(*((uint8_t*)(msg_data + sizeof(uint8_t))) & 0x80));
m->Assign(2, val_mgr->Count(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))))); m->Assign(2, val_mgr->Count(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t))))));
@ -281,7 +271,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
case 7: case 7:
{ {
auto m = make_intrusive<RecordVal>(hdrType(ip6_mob_brr_type, "ip6_mobility_be")); auto m = make_intrusive<RecordVal>(ip6_mobility_be_type);
m->Assign(0, val_mgr->Count(*((uint8_t*)msg_data))); m->Assign(0, val_mgr->Count(*((uint8_t*)msg_data)));
const in6_addr* hoa = (const in6_addr*)(msg_data + sizeof(uint16_t)); const in6_addr* hoa = (const in6_addr*)(msg_data + sizeof(uint16_t));
m->Assign(1, make_intrusive<AddrVal>(IPAddr(*hoa))); m->Assign(1, make_intrusive<AddrVal>(IPAddr(*hoa)));
@ -339,7 +329,8 @@ IntrusivePtr<RecordVal> IP_Hdr::ToIPHdrVal() const
if ( ip4 ) if ( ip4 )
{ {
rval = make_intrusive<RecordVal>(hdrType(ip4_hdr_type, "ip4_hdr")); static auto ip4_hdr_type = zeek::id::find_type<RecordType>("ip4_hdr");
rval = make_intrusive<RecordVal>(ip4_hdr_type);
rval->Assign(0, val_mgr->Count(ip4->ip_hl * 4)); rval->Assign(0, val_mgr->Count(ip4->ip_hl * 4));
rval->Assign(1, val_mgr->Count(ip4->ip_tos)); rval->Assign(1, val_mgr->Count(ip4->ip_tos));
rval->Assign(2, val_mgr->Count(ntohs(ip4->ip_len))); rval->Assign(2, val_mgr->Count(ntohs(ip4->ip_len)));
@ -364,11 +355,7 @@ RecordVal* IP_Hdr::BuildIPHdrVal() const
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal() const IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal() const
{ {
static RecordType* pkt_hdr_type = nullptr; static auto pkt_hdr_type = zeek::id::find_type<RecordType>("pkt_hdr");
if ( ! pkt_hdr_type )
pkt_hdr_type = zeek::id::find_type("pkt_hdr")->AsRecordType();
return ToPktHdrVal(make_intrusive<RecordVal>(pkt_hdr_type), 0); return ToPktHdrVal(make_intrusive<RecordVal>(pkt_hdr_type), 0);
} }
@ -379,16 +366,9 @@ RecordVal* IP_Hdr::BuildPktHdrVal() const
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal(IntrusivePtr<RecordVal> pkt_hdr, int sindex) const IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal(IntrusivePtr<RecordVal> pkt_hdr, int sindex) const
{ {
static RecordType* tcp_hdr_type = nullptr; static auto tcp_hdr_type = zeek::id::find_type<RecordType>("tcp_hdr");
static RecordType* udp_hdr_type = nullptr; static auto udp_hdr_type = zeek::id::find_type<RecordType>("udp_hdr");
static RecordType* icmp_hdr_type = nullptr; static auto icmp_hdr_type = zeek::id::find_type<RecordType>("icmp_hdr");
if ( ! tcp_hdr_type )
{
tcp_hdr_type = zeek::id::find_type("tcp_hdr")->AsRecordType();
udp_hdr_type = zeek::id::find_type("udp_hdr")->AsRecordType();
icmp_hdr_type = zeek::id::find_type("icmp_hdr")->AsRecordType();
}
if ( ip4 ) if ( ip4 )
pkt_hdr->Assign(sindex + 0, ToIPHdrVal()); pkt_hdr->Assign(sindex + 0, ToIPHdrVal());
@ -695,20 +675,15 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
IntrusivePtr<VectorVal> IPv6_Hdr_Chain::ToVal() const IntrusivePtr<VectorVal> IPv6_Hdr_Chain::ToVal() const
{ {
if ( ! ip6_ext_hdr_type ) static auto ip6_ext_hdr_type = zeek::id::find_type<RecordType>("ip6_ext_hdr");
{ static auto ip6_hopopts_type = zeek::id::find_type<RecordType>("ip6_hopopts");
ip6_ext_hdr_type = zeek::id::find_type("ip6_ext_hdr")->AsRecordType(); static auto ip6_dstopts_type = zeek::id::find_type<RecordType>("ip6_dstopts");
ip6_hopopts_type = zeek::id::find_type("ip6_hopopts")->AsRecordType(); static auto ip6_routing_type = zeek::id::find_type<RecordType>("ip6_routing");
ip6_dstopts_type = zeek::id::find_type("ip6_dstopts")->AsRecordType(); static auto ip6_fragment_type = zeek::id::find_type<RecordType>("ip6_fragment");
ip6_routing_type = zeek::id::find_type("ip6_routing")->AsRecordType(); static auto ip6_ah_type = zeek::id::find_type<RecordType>("ip6_ah");
ip6_fragment_type = zeek::id::find_type("ip6_fragment")->AsRecordType(); static auto ip6_esp_type = zeek::id::find_type<RecordType>("ip6_esp");
ip6_ah_type = zeek::id::find_type("ip6_ah")->AsRecordType(); static auto ip6_ext_hdr_chain_type = zeek::id::find_type<VectorType>("ip6_ext_hdr_chain");
ip6_esp_type = zeek::id::find_type("ip6_esp")->AsRecordType(); auto rval = make_intrusive<VectorVal>(ip6_ext_hdr_chain_type);
ip6_mob_type = zeek::id::find_type("ip6_mobility_hdr")->AsRecordType();
}
auto rval = make_intrusive<VectorVal>(
zeek::id::find_type<VectorType>("ip6_ext_hdr_chain"));
for ( size_t i = 1; i < chain.size(); ++i ) for ( size_t i = 1; i < chain.size(); ++i )
{ {

View file

@ -58,20 +58,12 @@ bool BroSubstring::DoesCover(const BroSubstring* bst) const
VectorVal* BroSubstring::VecToPolicy(Vec* vec) VectorVal* BroSubstring::VecToPolicy(Vec* vec)
{ {
RecordType* sw_substring_type = static auto sw_substring_type = zeek::id::find_type<RecordType>("sw_substring");
zeek::id::find_type("sw_substring")->AsRecordType(); static auto sw_align_type = zeek::id::find_type<RecordType>("sw_align");
if ( ! sw_substring_type ) static auto sw_align_vec_type = zeek::id::find_type<VectorType>("sw_align_vec");
return nullptr; static auto sw_substring_vec_type = zeek::id::find_type<VectorType>("sw_substring_vec");
RecordType* sw_align_type = auto result = make_intrusive<VectorVal>(sw_substring_vec_type);
zeek::id::find_type("sw_align")->AsRecordType();
if ( ! sw_align_type )
return nullptr;
auto sw_align_vec_type = zeek::id::find_type<VectorType>("sw_align_vec");
auto result =
make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("sw_substring_vec"));
if ( vec ) if ( vec )
{ {

View file

@ -201,7 +201,7 @@ static IntrusivePtr<EnumVal> lookup_enum_val(const char* module_name, const char
static void print_log(const std::vector<IntrusivePtr<Val>>& vals) static void print_log(const std::vector<IntrusivePtr<Val>>& vals)
{ {
auto plval = lookup_enum_val("Log", "PRINTLOG"); auto plval = lookup_enum_val("Log", "PRINTLOG");
auto record = make_intrusive<RecordVal>(zeek::id::find_type("Log::PrintLogInfo")->AsRecordType()); auto record = make_intrusive<RecordVal>(zeek::id::find_type<RecordType>("Log::PrintLogInfo"));
auto vec = make_intrusive<VectorVal>(zeek::id::string_vec); auto vec = make_intrusive<VectorVal>(zeek::id::string_vec);
for ( const auto& val : vals ) for ( const auto& val : vals )
@ -1662,7 +1662,7 @@ IntrusivePtr<Val> InitStmt::Exec(Frame* f, stmt_flow_type& flow) const
switch ( t->Tag() ) { switch ( t->Tag() ) {
case TYPE_RECORD: case TYPE_RECORD:
v = new RecordVal(t->AsRecordType()); v = new RecordVal(cast_intrusive<RecordType>(t));
break; break;
case TYPE_VECTOR: case TYPE_VECTOR:
v = new VectorVal(cast_intrusive<VectorType>(t)); v = new VectorVal(cast_intrusive<VectorType>(t));

View file

@ -2691,7 +2691,7 @@ RecordVal::RecordVal(IntrusivePtr<RecordType> t, bool init_fields) : Val(std::mo
TypeTag tag = type->Tag(); TypeTag tag = type->Tag();
if ( tag == TYPE_RECORD ) if ( tag == TYPE_RECORD )
def = make_intrusive<RecordVal>(type->AsRecordType()); def = make_intrusive<RecordVal>(cast_intrusive<RecordType>(type));
else if ( tag == TYPE_TABLE ) else if ( tag == TYPE_TABLE )
def = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, type->AsTableType()}, def = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, type->AsTableType()},
@ -2788,7 +2788,7 @@ IntrusivePtr<RecordVal> RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool
return nullptr; return nullptr;
if ( ! aggr ) if ( ! aggr )
aggr = new RecordVal(const_cast<RecordType*>(t->AsRecordType())); aggr = new RecordVal({NewRef{}, const_cast<RecordType*>(t)});
RecordVal* ar = aggr->AsRecordVal(); RecordVal* ar = aggr->AsRecordVal();
RecordType* ar_t = aggr->GetType()->AsRecordType(); RecordType* ar_t = aggr->GetType()->AsRecordType();
@ -2932,7 +2932,7 @@ IntrusivePtr<Val> RecordVal::DoClone(CloneState* state)
// record. As we cannot guarantee that it will ber zeroed out at the // record. As we cannot guarantee that it will ber zeroed out at the
// approproate time (as it seems to be guaranteed for the original record) // approproate time (as it seems to be guaranteed for the original record)
// we don't touch it. // we don't touch it.
auto rv = make_intrusive<RecordVal>(GetType()->AsRecordType(), false); auto rv = make_intrusive<RecordVal>(GetType<RecordType>(), false);
rv->origin = nullptr; rv->origin = nullptr;
state->NewClone(this, rv); state->NewClone(this, rv);

View file

@ -930,6 +930,7 @@ protected:
class RecordVal final : public Val, public notifier::Modifiable { class RecordVal final : public Val, public notifier::Modifiable {
public: public:
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
explicit RecordVal(RecordType* t, bool init_fields = true); explicit RecordVal(RecordType* t, bool init_fields = true);
explicit RecordVal(IntrusivePtr<RecordType> t, bool init_fields = true); explicit RecordVal(IntrusivePtr<RecordType> t, bool init_fields = true);

View file

@ -241,7 +241,7 @@ static void make_var(ID* id, IntrusivePtr<BroType> t, init_class c,
if ( t->Tag() == TYPE_RECORD ) if ( t->Tag() == TYPE_RECORD )
{ {
aggr = make_intrusive<RecordVal>(t->AsRecordType()); aggr = make_intrusive<RecordVal>(cast_intrusive<RecordType>(t));
if ( init && t ) if ( init && t )
// Have an initialization and type is not deduced. // Have an initialization and type is not deduced.

View file

@ -15,11 +15,11 @@
using namespace analyzer::bittorrent; using namespace analyzer::bittorrent;
static TableType* bt_tracker_headers = nullptr; static IntrusivePtr<TableType> bt_tracker_headers;
static RecordType* bittorrent_peer; static IntrusivePtr<RecordType> bittorrent_peer;
static TableType* bittorrent_peer_set; static IntrusivePtr<TableType> bittorrent_peer_set;
static RecordType* bittorrent_benc_value; static IntrusivePtr<RecordType> bittorrent_benc_value;
static TableType* bittorrent_benc_dir; static IntrusivePtr<TableType> bittorrent_benc_dir;
BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c) BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
: tcp::TCP_ApplicationAnalyzer("BITTORRENTTRACKER", c) : tcp::TCP_ApplicationAnalyzer("BITTORRENTTRACKER", c)
@ -27,15 +27,15 @@ BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
if ( ! bt_tracker_headers ) if ( ! bt_tracker_headers )
{ {
bt_tracker_headers = bt_tracker_headers =
zeek::id::find_type("bt_tracker_headers")->AsTableType(); zeek::id::find_type<TableType>("bt_tracker_headers");
bittorrent_peer = bittorrent_peer =
zeek::id::find_type("bittorrent_peer")->AsRecordType(); zeek::id::find_type<RecordType>("bittorrent_peer");
bittorrent_peer_set = bittorrent_peer_set =
zeek::id::find_type("bittorrent_peer_set")->AsTableType(); zeek::id::find_type<TableType>("bittorrent_peer_set");
bittorrent_benc_value = bittorrent_benc_value =
zeek::id::find_type("bittorrent_benc_value")->AsRecordType(); zeek::id::find_type<RecordType>("bittorrent_benc_value");
bittorrent_benc_dir = bittorrent_benc_dir =
zeek::id::find_type("bittorrent_benc_dir")->AsTableType(); zeek::id::find_type<TableType>("bittorrent_benc_dir");
} }
keep_alive = false; keep_alive = false;
@ -45,7 +45,7 @@ BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
req_buf_pos = req_buf; req_buf_pos = req_buf;
req_buf_len = 0; req_buf_len = 0;
req_val_uri = nullptr; req_val_uri = nullptr;
req_val_headers = new TableVal({NewRef{}, bt_tracker_headers}); req_val_headers = new TableVal(bt_tracker_headers);
res_state = BTT_RES_STATUS; res_state = BTT_RES_STATUS;
res_allow_blank_line = false; res_allow_blank_line = false;
@ -53,9 +53,9 @@ BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c)
res_buf_pos = res_buf; res_buf_pos = res_buf;
res_buf_len = 0; res_buf_len = 0;
res_status = 0; res_status = 0;
res_val_headers = new TableVal({NewRef{}, bt_tracker_headers}); res_val_headers = new TableVal(bt_tracker_headers);
res_val_peers = new TableVal({NewRef{}, bittorrent_peer_set}); res_val_peers = new TableVal(bittorrent_peer_set);
res_val_benc = new TableVal({NewRef{}, bittorrent_benc_dir}); res_val_benc = new TableVal(bittorrent_benc_dir);
InitBencParser(); InitBencParser();
@ -136,8 +136,7 @@ void BitTorrentTracker_Analyzer::ClientRequest(int len, const u_char* data)
req_buf_len -= (req_buf_pos - req_buf); req_buf_len -= (req_buf_pos - req_buf);
memmove(req_buf, req_buf_pos, req_buf_len); memmove(req_buf, req_buf_pos, req_buf_len);
req_buf_pos = req_buf; req_buf_pos = req_buf;
req_val_headers = req_val_headers = new TableVal(bt_tracker_headers);
new TableVal({NewRef{}, bt_tracker_headers});
} }
} }
} }
@ -199,9 +198,9 @@ void BitTorrentTracker_Analyzer::ServerReply(int len, const u_char* data)
res_buf_pos = res_buf; res_buf_pos = res_buf;
res_status = 0; res_status = 0;
res_val_headers = new TableVal({NewRef{}, bt_tracker_headers}); res_val_headers = new TableVal(bt_tracker_headers);
res_val_peers = new TableVal({NewRef{}, bittorrent_peer_set}); res_val_peers = new TableVal(bittorrent_peer_set);
res_val_benc = new TableVal({NewRef{}, bittorrent_benc_dir}); res_val_benc = new TableVal(bittorrent_benc_dir);
InitBencParser(); InitBencParser();
} }

View file

@ -724,15 +724,8 @@ void ICMP_Analyzer::Context6(double t, const struct icmp* icmpp,
IntrusivePtr<VectorVal> ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data) IntrusivePtr<VectorVal> ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data)
{ {
static RecordType* icmp6_nd_option_type = nullptr; static auto icmp6_nd_option_type = zeek::id::find_type<RecordType>("icmp6_nd_option");
static RecordType* icmp6_nd_prefix_info_type = nullptr; static auto icmp6_nd_prefix_info_type = zeek::id::find_type<RecordType>("icmp6_nd_prefix_info");
if ( ! icmp6_nd_option_type )
{
icmp6_nd_option_type = zeek::id::find_type("icmp6_nd_option")->AsRecordType();
icmp6_nd_prefix_info_type =
zeek::id::find_type("icmp6_nd_prefix_info")->AsRecordType();
}
auto vv = make_intrusive<VectorVal>( auto vv = make_intrusive<VectorVal>(
zeek::id::find_type<VectorType>("icmp6_nd_options")); zeek::id::find_type<VectorType>("icmp6_nd_options"));

View file

@ -98,16 +98,9 @@ bool TeredoEncapsulation::DoParse(const u_char* data, int& len,
IntrusivePtr<RecordVal> TeredoEncapsulation::BuildVal(const IP_Hdr* inner) const IntrusivePtr<RecordVal> TeredoEncapsulation::BuildVal(const IP_Hdr* inner) const
{ {
static RecordType* teredo_hdr_type = nullptr; static auto teredo_hdr_type = zeek::id::find_type<RecordType>("teredo_hdr");
static RecordType* teredo_auth_type = nullptr; static auto teredo_auth_type = zeek::id::find_type<RecordType>("teredo_auth");
static RecordType* teredo_origin_type = nullptr; static auto teredo_origin_type = zeek::id::find_type<RecordType>("teredo_origin");
if ( ! teredo_hdr_type )
{
teredo_hdr_type = zeek::id::find_type("teredo_hdr")->AsRecordType();
teredo_auth_type = zeek::id::find_type("teredo_auth")->AsRecordType();
teredo_origin_type = zeek::id::find_type("teredo_origin")->AsRecordType();
}
auto teredo_hdr = make_intrusive<RecordVal>(teredo_hdr_type); auto teredo_hdr = make_intrusive<RecordVal>(teredo_hdr_type);

View file

@ -387,7 +387,7 @@ struct val_converter {
else if ( type->Tag() == TYPE_RECORD ) else if ( type->Tag() == TYPE_RECORD )
{ {
auto rt = type->AsRecordType(); auto rt = type->AsRecordType();
auto rval = make_intrusive<RecordVal>(rt); auto rval = make_intrusive<RecordVal>(IntrusivePtr{NewRef{}, rt});
auto idx = 0u; auto idx = 0u;
for ( auto i = 0u; i < static_cast<size_t>(rt->NumFields()); ++i ) for ( auto i = 0u; i < static_cast<size_t>(rt->NumFields()); ++i )

View file

@ -1245,13 +1245,13 @@ void Manager::ProcessStatus(broker::status stat)
if ( ! event ) if ( ! event )
return; return;
auto ei = zeek::id::find_type("Broker::EndpointInfo")->AsRecordType(); static auto ei = zeek::id::find_type<RecordType>("Broker::EndpointInfo");
auto endpoint_info = make_intrusive<RecordVal>(ei); auto endpoint_info = make_intrusive<RecordVal>(ei);
if ( ctx ) if ( ctx )
{ {
endpoint_info->Assign(0, make_intrusive<StringVal>(to_string(ctx->node))); endpoint_info->Assign(0, make_intrusive<StringVal>(to_string(ctx->node)));
auto ni = zeek::id::find_type("Broker::NetworkInfo")->AsRecordType(); static auto ni = zeek::id::find_type<RecordType>("Broker::NetworkInfo");
auto network_info = make_intrusive<RecordVal>(ni); auto network_info = make_intrusive<RecordVal>(ni);
if ( ctx->network ) if ( ctx->network )

View file

@ -99,9 +99,9 @@ function Broker::__peers%(%): PeerInfos
for ( auto& p : broker_mgr->Peers() ) for ( auto& p : broker_mgr->Peers() )
{ {
auto pi = zeek::id::find_type("Broker::PeerInfo")->AsRecordType(); const auto& pi = zeek::id::find_type<RecordType>("Broker::PeerInfo");
auto ei = zeek::id::find_type("Broker::EndpointInfo")->AsRecordType(); const auto& ei = zeek::id::find_type<RecordType>("Broker::EndpointInfo");
auto ni = zeek::id::find_type("Broker::NetworkInfo")->AsRecordType(); const auto& ni = zeek::id::find_type<RecordType>("Broker::NetworkInfo");
auto peer_info = new RecordVal(pi); auto peer_info = new RecordVal(pi);
auto endpoint_info = new RecordVal(ei); auto endpoint_info = new RecordVal(ei);
auto network_info = new RecordVal(ni); auto network_info = new RecordVal(ni);

View file

@ -1906,7 +1906,7 @@ RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType *request_type,
{ {
assert(position != nullptr); // we need the pointer to point to data; assert(position != nullptr); // we need the pointer to point to data;
RecordVal* rec = new RecordVal(request_type->AsRecordType()); RecordVal* rec = new RecordVal({NewRef{}, request_type});
assert(list != nullptr); assert(list != nullptr);
int maxpos = list->Length(); int maxpos = list->Length();
@ -1936,7 +1936,7 @@ RecordVal* Manager::ValueToRecordVal(const Stream* stream, const Value* const *v
{ {
assert(position != nullptr); // we need the pointer to point to data. assert(position != nullptr); // we need the pointer to point to data.
RecordVal* rec = new RecordVal(request_type->AsRecordType()); RecordVal* rec = new RecordVal({NewRef{}, request_type});
for ( int i = 0; i < request_type->NumFields(); i++ ) for ( int i = 0; i < request_type->NumFields(); i++ )
{ {
Val* fieldVal = nullptr; Val* fieldVal = nullptr;

View file

@ -4,19 +4,19 @@
#include "threading/Manager.h" #include "threading/Manager.h"
#include "broker/Manager.h" #include "broker/Manager.h"
RecordType* ProcStats; IntrusivePtr<RecordType> ProcStats;
RecordType* NetStats; IntrusivePtr<RecordType> NetStats;
RecordType* MatcherStats; IntrusivePtr<RecordType> MatcherStats;
RecordType* ReassemblerStats; IntrusivePtr<RecordType> ReassemblerStats;
RecordType* DNSStats; IntrusivePtr<RecordType> DNSStats;
RecordType* ConnStats; IntrusivePtr<RecordType> ConnStats;
RecordType* GapStats; IntrusivePtr<RecordType> GapStats;
RecordType* EventStats; IntrusivePtr<RecordType> EventStats;
RecordType* ThreadStats; IntrusivePtr<RecordType> ThreadStats;
RecordType* TimerStats; IntrusivePtr<RecordType> TimerStats;
RecordType* FileAnalysisStats; IntrusivePtr<RecordType> FileAnalysisStats;
RecordType* BrokerStats; IntrusivePtr<RecordType> BrokerStats;
RecordType* ReporterStats; IntrusivePtr<RecordType> ReporterStats;
%%} %%}
## Returns packet capture statistics. Statistics include the number of ## Returns packet capture statistics. Statistics include the number of

View file

@ -1172,7 +1172,7 @@ IntrusivePtr<RecordVal> Supervisor::Node::ToRecord() const
static IntrusivePtr<Val> supervisor_role_to_cluster_node_type(BifEnum::Supervisor::ClusterRole role) static IntrusivePtr<Val> supervisor_role_to_cluster_node_type(BifEnum::Supervisor::ClusterRole role)
{ {
static auto node_type = global_scope()->Find("Cluster::NodeType")->GetType()->AsEnumType(); static auto node_type = zeek::id::find_type<EnumType>("Cluster::NodeType");
switch ( role ) { switch ( role ) {
case BifEnum::Supervisor::LOGGER: case BifEnum::Supervisor::LOGGER:
@ -1193,9 +1193,9 @@ bool Supervisor::SupervisedNode::InitCluster() const
if ( config.cluster.empty() ) if ( config.cluster.empty() )
return false; return false;
const auto& cluster_node_type = global_scope()->Find("Cluster::Node")->GetType()->AsRecordType(); const auto& cluster_node_type = zeek::id::find_type<RecordType>("Cluster::Node");
const auto& cluster_nodes_id = global_scope()->Find("Cluster::nodes"); const auto& cluster_nodes_id = zeek::id::find("Cluster::nodes");
const auto& cluster_manager_is_logger_id = global_scope()->Find("Cluster::manager_is_logger"); const auto& cluster_manager_is_logger_id = zeek::id::find("Cluster::manager_is_logger");
auto cluster_nodes = cluster_nodes_id->GetVal()->AsTableVal(); auto cluster_nodes = cluster_nodes_id->GetVal()->AsTableVal();
auto has_logger = false; auto has_logger = false;
std::optional<std::string> manager_name; std::optional<std::string> manager_name;

View file

@ -1891,7 +1891,7 @@ function reading_traces%(%): bool
## .. zeek:see:: reading_live_traffic reading_traces ## .. zeek:see:: reading_live_traffic reading_traces
function packet_source%(%): PacketSource function packet_source%(%): PacketSource
%{ %{
auto ps_type = zeek::id::find_type("PacketSource")->AsRecordType(); static auto ps_type = zeek::id::find_type<RecordType>("PacketSource");
auto ps = iosource_mgr->GetPktSrc(); auto ps = iosource_mgr->GetPktSrc();
auto r = make_intrusive<RecordVal>(ps_type); auto r = make_intrusive<RecordVal>(ps_type);