Deprecate internal_type(), replace with zeek::lookup_type()

This commit is contained in:
Jon Siwek 2020-05-08 17:44:20 -07:00
parent 32b895f4ba
commit ac06259eec
44 changed files with 218 additions and 182 deletions

View file

@ -13,6 +13,8 @@
#include "BroString.h"
#include "Reporter.h"
using namespace zeek;
static RecordType* ip4_hdr_type = nullptr;
static RecordType* ip6_hdr_type = nullptr;
static RecordType* ip6_ext_hdr_type = nullptr;
@ -37,14 +39,14 @@ static RecordType* ip6_mob_be_type = nullptr;
static inline RecordType* hdrType(RecordType*& type, const char* name)
{
if ( ! type )
type = internal_type(name)->AsRecordType();
type = lookup_type(name)->AsRecordType();
return type;
}
static IntrusivePtr<VectorVal> BuildOptionsVal(const u_char* data, int len)
{
auto vv = make_intrusive<VectorVal>(internal_type("ip6_options")->AsVectorType());
auto vv = make_intrusive<VectorVal>(lookup_type("ip6_options")->AsVectorType());
while ( len > 0 )
{
@ -95,7 +97,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
rv->Assign(6, make_intrusive<AddrVal>(IPAddr(ip6->ip6_dst)));
if ( ! chain )
chain = make_intrusive<VectorVal>(
internal_type("ip6_ext_hdr_chain")->AsVectorType());
lookup_type("ip6_ext_hdr_chain")->AsVectorType());
rv->Assign(7, std::move(chain));
}
break;
@ -367,7 +369,7 @@ IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal() const
static RecordType* pkt_hdr_type = nullptr;
if ( ! pkt_hdr_type )
pkt_hdr_type = internal_type("pkt_hdr")->AsRecordType();
pkt_hdr_type = lookup_type("pkt_hdr")->AsRecordType();
return ToPktHdrVal(make_intrusive<RecordVal>(pkt_hdr_type), 0);
}
@ -385,9 +387,9 @@ IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal(IntrusivePtr<RecordVal> pkt_hdr, int
if ( ! tcp_hdr_type )
{
tcp_hdr_type = internal_type("tcp_hdr")->AsRecordType();
udp_hdr_type = internal_type("udp_hdr")->AsRecordType();
icmp_hdr_type = internal_type("icmp_hdr")->AsRecordType();
tcp_hdr_type = lookup_type("tcp_hdr")->AsRecordType();
udp_hdr_type = lookup_type("udp_hdr")->AsRecordType();
icmp_hdr_type = lookup_type("icmp_hdr")->AsRecordType();
}
if ( ip4 )
@ -697,18 +699,18 @@ IntrusivePtr<VectorVal> IPv6_Hdr_Chain::ToVal() const
{
if ( ! ip6_ext_hdr_type )
{
ip6_ext_hdr_type = internal_type("ip6_ext_hdr")->AsRecordType();
ip6_hopopts_type = internal_type("ip6_hopopts")->AsRecordType();
ip6_dstopts_type = internal_type("ip6_dstopts")->AsRecordType();
ip6_routing_type = internal_type("ip6_routing")->AsRecordType();
ip6_fragment_type = internal_type("ip6_fragment")->AsRecordType();
ip6_ah_type = internal_type("ip6_ah")->AsRecordType();
ip6_esp_type = internal_type("ip6_esp")->AsRecordType();
ip6_mob_type = internal_type("ip6_mobility_hdr")->AsRecordType();
ip6_ext_hdr_type = lookup_type("ip6_ext_hdr")->AsRecordType();
ip6_hopopts_type = lookup_type("ip6_hopopts")->AsRecordType();
ip6_dstopts_type = lookup_type("ip6_dstopts")->AsRecordType();
ip6_routing_type = lookup_type("ip6_routing")->AsRecordType();
ip6_fragment_type = lookup_type("ip6_fragment")->AsRecordType();
ip6_ah_type = lookup_type("ip6_ah")->AsRecordType();
ip6_esp_type = lookup_type("ip6_esp")->AsRecordType();
ip6_mob_type = lookup_type("ip6_mobility_hdr")->AsRecordType();
}
auto rval = make_intrusive<VectorVal>(
internal_type("ip6_ext_hdr_chain")->AsVectorType());
lookup_type("ip6_ext_hdr_chain")->AsVectorType());
for ( size_t i = 1; i < chain.size(); ++i )
{