mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Deprecate bro_int_t and bro_uint_t
This commit is contained in:
parent
d066013793
commit
f624c18383
67 changed files with 331 additions and 320 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 66442960aa29ca5478c924872e4b4c0da437958d
|
Subproject commit c76100f46f38573d3d79eea684410e9fb983bff0
|
|
@ -1 +1 @@
|
||||||
Subproject commit 698d6ae19b4a042094c30d5ac0b272adc4fbd845
|
Subproject commit 91dd2edaa89b7d8f1e05104d6b4c147b7e3ec111
|
|
@ -161,7 +161,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const
|
||||||
void Attr::AddTag(ODesc* d) const
|
void Attr::AddTag(ODesc* d) const
|
||||||
{
|
{
|
||||||
if ( d->IsBinary() )
|
if ( d->IsBinary() )
|
||||||
d->Add(static_cast<bro_int_t>(Tag()));
|
d->Add(static_cast<zeek_int_t>(Tag()));
|
||||||
else
|
else
|
||||||
d->Add(attr_name(Tag()));
|
d->Add(attr_name(Tag()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
{
|
{
|
||||||
case TYPE_INTERNAL_INT:
|
case TYPE_INTERNAL_INT:
|
||||||
{
|
{
|
||||||
bro_int_t i;
|
zeek_int_t i;
|
||||||
hk.Read("int", i);
|
hk.Read("int", i);
|
||||||
|
|
||||||
if ( tag == TYPE_ENUM )
|
if ( tag == TYPE_ENUM )
|
||||||
|
@ -179,7 +179,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
|
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case TYPE_INTERNAL_UNSIGNED:
|
||||||
{
|
{
|
||||||
bro_uint_t u;
|
zeek_uint_t u;
|
||||||
hk.Read("unsigned", u);
|
hk.Read("unsigned", u);
|
||||||
|
|
||||||
switch ( tag )
|
switch ( tag )
|
||||||
|
@ -783,11 +783,11 @@ bool CompositeHash::ReserveSingleTypeKeySize(HashKey& hk, Type* bt, const Val* v
|
||||||
switch ( t )
|
switch ( t )
|
||||||
{
|
{
|
||||||
case TYPE_INTERNAL_INT:
|
case TYPE_INTERNAL_INT:
|
||||||
hk.ReserveType<bro_int_t>("int");
|
hk.ReserveType<zeek_int_t>("int");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case TYPE_INTERNAL_UNSIGNED:
|
||||||
hk.ReserveType<bro_int_t>("unsigned");
|
hk.ReserveType<zeek_int_t>("unsigned");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_ADDR:
|
case TYPE_INTERNAL_ADDR:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "zeek/ZeekString.h" // for byte_vec
|
#include "zeek/ZeekString.h" // for byte_vec
|
||||||
#include "zeek/util.h" // for bro_int_t
|
#include "zeek/util.h" // for zeek_int_t
|
||||||
|
|
||||||
namespace zeek
|
namespace zeek
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ public:
|
||||||
SP();
|
SP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddCount(bro_int_t n)
|
void AddCount(zeek_int_t n)
|
||||||
{
|
{
|
||||||
if ( ! IsReadable() )
|
if ( ! IsReadable() )
|
||||||
{
|
{
|
||||||
|
|
26
src/Expr.cc
26
src/Expr.cc
|
@ -318,8 +318,8 @@ const char* assign_to_index(ValPtr v1, ValPtr v2, ValPtr v3, bool& iterators_inv
|
||||||
if ( lv->Length() > 1 )
|
if ( lv->Length() > 1 )
|
||||||
{
|
{
|
||||||
auto len = v1_vect->Size();
|
auto len = v1_vect->Size();
|
||||||
bro_int_t first = get_slice_index(lv->Idx(0)->CoerceToInt(), len);
|
zeek_int_t first = get_slice_index(lv->Idx(0)->CoerceToInt(), len);
|
||||||
bro_int_t last = get_slice_index(lv->Idx(1)->CoerceToInt(), len);
|
zeek_int_t last = get_slice_index(lv->Idx(1)->CoerceToInt(), len);
|
||||||
|
|
||||||
// Remove the elements from the vector within the slice.
|
// Remove the elements from the vector within the slice.
|
||||||
for ( auto idx = first; idx < last; idx++ )
|
for ( auto idx = first; idx < last; idx++ )
|
||||||
|
@ -828,8 +828,8 @@ ValPtr BinaryExpr::Fold(Val* v1, Val* v2) const
|
||||||
if ( it == TYPE_INTERNAL_SUBNET )
|
if ( it == TYPE_INTERNAL_SUBNET )
|
||||||
return SubNetFold(v1, v2);
|
return SubNetFold(v1, v2);
|
||||||
|
|
||||||
bro_int_t i1 = 0, i2 = 0, i3 = 0;
|
zeek_int_t i1 = 0, i2 = 0, i3 = 0;
|
||||||
bro_uint_t u1 = 0, u2 = 0, u3 = 0;
|
zeek_uint_t u1 = 0, u2 = 0, u3 = 0;
|
||||||
double d1 = 0.0, d2 = 0.0, d3 = 0.0;
|
double d1 = 0.0, d2 = 0.0, d3 = 0.0;
|
||||||
bool is_integral = false;
|
bool is_integral = false;
|
||||||
bool is_unsigned = false;
|
bool is_unsigned = false;
|
||||||
|
@ -1414,7 +1414,7 @@ IncrExpr::IncrExpr(BroExprTag arg_tag, ExprPtr arg_op) : UnaryExpr(arg_tag, arg_
|
||||||
|
|
||||||
ValPtr IncrExpr::DoSingleEval(Frame* f, Val* v) const
|
ValPtr IncrExpr::DoSingleEval(Frame* f, Val* v) const
|
||||||
{
|
{
|
||||||
bro_int_t k = v->CoerceToInt();
|
zeek_int_t k = v->CoerceToInt();
|
||||||
|
|
||||||
if ( Tag() == EXPR_INCR )
|
if ( Tag() == EXPR_INCR )
|
||||||
++k;
|
++k;
|
||||||
|
@ -3052,7 +3052,7 @@ StringValPtr index_string(const String* s, const ListVal* lv)
|
||||||
|
|
||||||
if ( lv->Length() == 1 )
|
if ( lv->Length() == 1 )
|
||||||
{
|
{
|
||||||
bro_int_t idx = lv->Idx(0)->AsInt();
|
zeek_int_t idx = lv->Idx(0)->AsInt();
|
||||||
|
|
||||||
if ( idx < 0 )
|
if ( idx < 0 )
|
||||||
idx += len;
|
idx += len;
|
||||||
|
@ -3062,9 +3062,9 @@ StringValPtr index_string(const String* s, const ListVal* lv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bro_int_t first = get_slice_index(lv->Idx(0)->AsInt(), len);
|
zeek_int_t first = get_slice_index(lv->Idx(0)->AsInt(), len);
|
||||||
bro_int_t last = get_slice_index(lv->Idx(1)->AsInt(), len);
|
zeek_int_t last = get_slice_index(lv->Idx(1)->AsInt(), len);
|
||||||
bro_int_t substring_len = last - first;
|
zeek_int_t substring_len = last - first;
|
||||||
|
|
||||||
if ( substring_len < 0 )
|
if ( substring_len < 0 )
|
||||||
substring = nullptr;
|
substring = nullptr;
|
||||||
|
@ -3087,15 +3087,15 @@ VectorValPtr index_slice(VectorVal* vect, int _first, int _last)
|
||||||
size_t len = vect->Size();
|
size_t len = vect->Size();
|
||||||
auto result = make_intrusive<VectorVal>(vect->GetType<VectorType>());
|
auto result = make_intrusive<VectorVal>(vect->GetType<VectorType>());
|
||||||
|
|
||||||
bro_int_t first = get_slice_index(_first, len);
|
zeek_int_t first = get_slice_index(_first, len);
|
||||||
bro_int_t last = get_slice_index(_last, len);
|
zeek_int_t last = get_slice_index(_last, len);
|
||||||
bro_int_t sub_length = last - first;
|
zeek_int_t sub_length = last - first;
|
||||||
|
|
||||||
if ( sub_length >= 0 )
|
if ( sub_length >= 0 )
|
||||||
{
|
{
|
||||||
result->Resize(sub_length);
|
result->Resize(sub_length);
|
||||||
|
|
||||||
for ( bro_int_t idx = first; idx < last; idx++ )
|
for ( zeek_int_t idx = first; idx < last; idx++ )
|
||||||
result->Assign(idx - first, vect->ValAt(idx));
|
result->Assign(idx - first, vect->ValAt(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "zeek/IPAddr.h"
|
#include "zeek/IPAddr.h"
|
||||||
#include "zeek/Reassem.h"
|
#include "zeek/Reassem.h"
|
||||||
#include "zeek/Timer.h"
|
#include "zeek/Timer.h"
|
||||||
#include "zeek/util.h" // for bro_uint_t
|
#include "zeek/util.h" // for zeek_uint_t
|
||||||
|
|
||||||
namespace zeek
|
namespace zeek
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ namespace detail
|
||||||
class FragReassembler;
|
class FragReassembler;
|
||||||
class FragTimer;
|
class FragTimer;
|
||||||
|
|
||||||
using FragReassemblerKey = std::tuple<IPAddr, IPAddr, bro_uint_t>;
|
using FragReassemblerKey = std::tuple<IPAddr, IPAddr, zeek_uint_t>;
|
||||||
|
|
||||||
class FragReassembler : public Reassembler
|
class FragReassembler : public Reassembler
|
||||||
{
|
{
|
||||||
|
|
18
src/Hash.cc
18
src/Hash.cc
|
@ -119,12 +119,12 @@ HashKey::HashKey(int i)
|
||||||
Set(i);
|
Set(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashKey::HashKey(bro_int_t bi)
|
HashKey::HashKey(zeek_int_t bi)
|
||||||
{
|
{
|
||||||
Set(bi);
|
Set(bi);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashKey::HashKey(bro_uint_t bu)
|
HashKey::HashKey(zeek_uint_t bu)
|
||||||
{
|
{
|
||||||
Set(bu);
|
Set(bu);
|
||||||
}
|
}
|
||||||
|
@ -273,16 +273,16 @@ void HashKey::Set(int i)
|
||||||
size = write_size = sizeof(i);
|
size = write_size = sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashKey::Set(bro_int_t bi)
|
void HashKey::Set(zeek_int_t bi)
|
||||||
{
|
{
|
||||||
key_u.bi = bi;
|
key_u.bi = bi;
|
||||||
key = reinterpret_cast<char*>(&key_u);
|
key = reinterpret_cast<char*>(&key_u);
|
||||||
size = write_size = sizeof(bi);
|
size = write_size = sizeof(bi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashKey::Set(bro_uint_t bu)
|
void HashKey::Set(zeek_uint_t bu)
|
||||||
{
|
{
|
||||||
key_u.bi = bro_int_t(bu);
|
key_u.bi = zeek_int_t(bu);
|
||||||
key = reinterpret_cast<char*>(&key_u);
|
key = reinterpret_cast<char*>(&key_u);
|
||||||
size = write_size = sizeof(bu);
|
size = write_size = sizeof(bu);
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ void HashKey::Write(const char* tag, int i, bool align)
|
||||||
Write(tag, &i, sizeof(i), align ? sizeof(i) : 0);
|
Write(tag, &i, sizeof(i), align ? sizeof(i) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashKey::Write(const char* tag, bro_int_t bi, bool align)
|
void HashKey::Write(const char* tag, zeek_int_t bi, bool align)
|
||||||
{
|
{
|
||||||
if ( ! IsAllocated() )
|
if ( ! IsAllocated() )
|
||||||
{
|
{
|
||||||
|
@ -361,7 +361,7 @@ void HashKey::Write(const char* tag, bro_int_t bi, bool align)
|
||||||
Write(tag, &bi, sizeof(bi), align ? sizeof(bi) : 0);
|
Write(tag, &bi, sizeof(bi), align ? sizeof(bi) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashKey::Write(const char* tag, bro_uint_t bu, bool align)
|
void HashKey::Write(const char* tag, zeek_uint_t bu, bool align)
|
||||||
{
|
{
|
||||||
if ( ! IsAllocated() )
|
if ( ! IsAllocated() )
|
||||||
{
|
{
|
||||||
|
@ -464,12 +464,12 @@ void HashKey::Read(const char* tag, int& i, bool align) const
|
||||||
Read(tag, &i, sizeof(i), align ? sizeof(i) : 0);
|
Read(tag, &i, sizeof(i), align ? sizeof(i) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashKey::Read(const char* tag, bro_int_t& i, bool align) const
|
void HashKey::Read(const char* tag, zeek_int_t& i, bool align) const
|
||||||
{
|
{
|
||||||
Read(tag, &i, sizeof(i), align ? sizeof(i) : 0);
|
Read(tag, &i, sizeof(i), align ? sizeof(i) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashKey::Read(const char* tag, bro_uint_t& u, bool align) const
|
void HashKey::Read(const char* tag, zeek_uint_t& u, bool align) const
|
||||||
{
|
{
|
||||||
Read(tag, &u, sizeof(u), align ? sizeof(u) : 0);
|
Read(tag, &u, sizeof(u), align ? sizeof(u) : 0);
|
||||||
}
|
}
|
||||||
|
|
20
src/Hash.h
20
src/Hash.h
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "zeek/util.h" // for bro_int_t
|
#include "zeek/util.h" // for zeek_int_t
|
||||||
|
|
||||||
// to allow bro_md5_hmac access to the hmac seed
|
// to allow bro_md5_hmac access to the hmac seed
|
||||||
#include "zeek/ZeekArgs.h"
|
#include "zeek/ZeekArgs.h"
|
||||||
|
@ -234,8 +234,8 @@ public:
|
||||||
explicit HashKey() { }
|
explicit HashKey() { }
|
||||||
explicit HashKey(bool b);
|
explicit HashKey(bool b);
|
||||||
explicit HashKey(int i);
|
explicit HashKey(int i);
|
||||||
explicit HashKey(bro_int_t bi);
|
explicit HashKey(zeek_int_t bi);
|
||||||
explicit HashKey(bro_uint_t bu);
|
explicit HashKey(zeek_uint_t bu);
|
||||||
explicit HashKey(uint32_t u);
|
explicit HashKey(uint32_t u);
|
||||||
HashKey(const uint32_t u[], size_t n);
|
HashKey(const uint32_t u[], size_t n);
|
||||||
explicit HashKey(double d);
|
explicit HashKey(double d);
|
||||||
|
@ -297,8 +297,8 @@ public:
|
||||||
// at the current marker.
|
// at the current marker.
|
||||||
void Write(const char* tag, bool b);
|
void Write(const char* tag, bool b);
|
||||||
void Write(const char* tag, int i, bool align = true);
|
void Write(const char* tag, int i, bool align = true);
|
||||||
void Write(const char* tag, bro_int_t bi, bool align = true);
|
void Write(const char* tag, zeek_int_t bi, bool align = true);
|
||||||
void Write(const char* tag, bro_uint_t bu, bool align = true);
|
void Write(const char* tag, zeek_uint_t bu, bool align = true);
|
||||||
void Write(const char* tag, uint32_t u, bool align = true);
|
void Write(const char* tag, uint32_t u, bool align = true);
|
||||||
void Write(const char* tag, double d, bool align = true);
|
void Write(const char* tag, double d, bool align = true);
|
||||||
|
|
||||||
|
@ -325,8 +325,8 @@ public:
|
||||||
// to the read of the item is controlled by the align boolean.
|
// to the read of the item is controlled by the align boolean.
|
||||||
void Read(const char* tag, bool& b) const;
|
void Read(const char* tag, bool& b) const;
|
||||||
void Read(const char* tag, int& i, bool align = true) const;
|
void Read(const char* tag, int& i, bool align = true) const;
|
||||||
void Read(const char* tag, bro_int_t& bi, bool align = true) const;
|
void Read(const char* tag, zeek_int_t& bi, bool align = true) const;
|
||||||
void Read(const char* tag, bro_uint_t& bu, bool align = true) const;
|
void Read(const char* tag, zeek_uint_t& bu, bool align = true) const;
|
||||||
void Read(const char* tag, uint32_t& u, bool align = true) const;
|
void Read(const char* tag, uint32_t& u, bool align = true) const;
|
||||||
void Read(const char* tag, double& d, bool align = true) const;
|
void Read(const char* tag, double& d, bool align = true) const;
|
||||||
|
|
||||||
|
@ -351,8 +351,8 @@ protected:
|
||||||
// use the key_u union for storage.
|
// use the key_u union for storage.
|
||||||
void Set(bool b);
|
void Set(bool b);
|
||||||
void Set(int i);
|
void Set(int i);
|
||||||
void Set(bro_int_t bi);
|
void Set(zeek_int_t bi);
|
||||||
void Set(bro_uint_t bu);
|
void Set(zeek_uint_t bu);
|
||||||
void Set(uint32_t u);
|
void Set(uint32_t u);
|
||||||
void Set(double d);
|
void Set(double d);
|
||||||
void Set(const void* p);
|
void Set(const void* p);
|
||||||
|
@ -360,7 +360,7 @@ protected:
|
||||||
union {
|
union {
|
||||||
bool b;
|
bool b;
|
||||||
int i;
|
int i;
|
||||||
bro_int_t bi;
|
zeek_int_t bi;
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
double d;
|
double d;
|
||||||
const void* p;
|
const void* p;
|
||||||
|
|
|
@ -191,9 +191,9 @@ int check_for_unused_event_handlers;
|
||||||
|
|
||||||
int record_all_packets;
|
int record_all_packets;
|
||||||
|
|
||||||
bro_uint_t bits_per_uid;
|
zeek_uint_t bits_per_uid;
|
||||||
|
|
||||||
bro_uint_t tunnel_max_changes_per_connection;
|
zeek_uint_t tunnel_max_changes_per_connection;
|
||||||
|
|
||||||
} // namespace zeek::detail. The namespace has be closed here before we include the netvar_def
|
} // namespace zeek::detail. The namespace has be closed here before we include the netvar_def
|
||||||
// files.
|
// files.
|
||||||
|
|
|
@ -92,9 +92,9 @@ extern int check_for_unused_event_handlers;
|
||||||
|
|
||||||
extern int record_all_packets;
|
extern int record_all_packets;
|
||||||
|
|
||||||
extern bro_uint_t bits_per_uid;
|
extern zeek_uint_t bits_per_uid;
|
||||||
|
|
||||||
extern bro_uint_t tunnel_max_changes_per_connection;
|
extern zeek_uint_t tunnel_max_changes_per_connection;
|
||||||
|
|
||||||
// Initializes globals that don't pertain to network/event analysis.
|
// Initializes globals that don't pertain to network/event analysis.
|
||||||
extern void init_general_global_var();
|
extern void init_general_global_var();
|
||||||
|
|
|
@ -12,7 +12,7 @@ inline bool double_to_count_would_overflow(double v)
|
||||||
return v < 0.0 || v > static_cast<double>(UINT64_MAX);
|
return v < 0.0 || v > static_cast<double>(UINT64_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool int_to_count_would_overflow(bro_int_t v)
|
inline bool int_to_count_would_overflow(zeek_int_t v)
|
||||||
{
|
{
|
||||||
return v < 0.0;
|
return v < 0.0;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ inline bool double_to_int_would_overflow(double v)
|
||||||
return v < static_cast<double>(INT64_MIN) || v > static_cast<double>(INT64_MAX);
|
return v < static_cast<double>(INT64_MIN) || v > static_cast<double>(INT64_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool count_to_int_would_overflow(bro_uint_t v)
|
inline bool count_to_int_would_overflow(zeek_uint_t v)
|
||||||
{
|
{
|
||||||
return v > INT64_MAX;
|
return v > INT64_MAX;
|
||||||
}
|
}
|
||||||
|
|
18
src/Type.cc
18
src/Type.cc
|
@ -1624,7 +1624,7 @@ void EnumType::AddName(const string& module_name, const char* name, bool is_expo
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumType::AddName(const string& module_name, const char* name, bro_int_t val, bool is_export,
|
void EnumType::AddName(const string& module_name, const char* name, zeek_int_t val, bool is_export,
|
||||||
detail::Expr* deprecation, bool from_redef)
|
detail::Expr* deprecation, bool from_redef)
|
||||||
{
|
{
|
||||||
/* explicit value specified */
|
/* explicit value specified */
|
||||||
|
@ -1638,7 +1638,7 @@ void EnumType::AddName(const string& module_name, const char* name, bro_int_t va
|
||||||
CheckAndAddName(module_name, name, val, is_export, deprecation, from_redef);
|
CheckAndAddName(module_name, name, val, is_export, deprecation, from_redef);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumType::CheckAndAddName(const string& module_name, const char* name, bro_int_t val,
|
void EnumType::CheckAndAddName(const string& module_name, const char* name, zeek_int_t val,
|
||||||
bool is_export, detail::Expr* deprecation, bool from_redef)
|
bool is_export, detail::Expr* deprecation, bool from_redef)
|
||||||
{
|
{
|
||||||
if ( from_redef )
|
if ( from_redef )
|
||||||
|
@ -1696,14 +1696,14 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, bro_
|
||||||
t->AsEnumType()->AddNameInternal(module_name, name, val, is_export);
|
t->AsEnumType()->AddNameInternal(module_name, name, val, is_export);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumType::AddNameInternal(const string& module_name, const char* name, bro_int_t val,
|
void EnumType::AddNameInternal(const string& module_name, const char* name, zeek_int_t val,
|
||||||
bool is_export)
|
bool is_export)
|
||||||
{
|
{
|
||||||
string fullname = detail::make_full_var_name(module_name.c_str(), name);
|
string fullname = detail::make_full_var_name(module_name.c_str(), name);
|
||||||
names[fullname] = val;
|
names[fullname] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumType::AddNameInternal(const string& full_name, bro_int_t val)
|
void EnumType::AddNameInternal(const string& full_name, zeek_int_t val)
|
||||||
{
|
{
|
||||||
names[full_name] = val;
|
names[full_name] = val;
|
||||||
|
|
||||||
|
@ -1711,12 +1711,12 @@ void EnumType::AddNameInternal(const string& full_name, bro_int_t val)
|
||||||
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
|
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_int_t EnumType::Lookup(const string& module_name, const char* name) const
|
zeek_int_t EnumType::Lookup(const string& module_name, const char* name) const
|
||||||
{
|
{
|
||||||
return Lookup(detail::make_full_var_name(module_name.c_str(), name));
|
return Lookup(detail::make_full_var_name(module_name.c_str(), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_int_t EnumType::Lookup(const string& full_name) const
|
zeek_int_t EnumType::Lookup(const string& full_name) const
|
||||||
{
|
{
|
||||||
NameMap::const_iterator pos = names.find(full_name.c_str());
|
NameMap::const_iterator pos = names.find(full_name.c_str());
|
||||||
|
|
||||||
|
@ -1726,7 +1726,7 @@ bro_int_t EnumType::Lookup(const string& full_name) const
|
||||||
return pos->second;
|
return pos->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* EnumType::Lookup(bro_int_t value) const
|
const char* EnumType::Lookup(zeek_int_t value) const
|
||||||
{
|
{
|
||||||
for ( NameMap::const_iterator iter = names.begin(); iter != names.end(); ++iter )
|
for ( NameMap::const_iterator iter = names.begin(); iter != names.end(); ++iter )
|
||||||
if ( iter->second == value )
|
if ( iter->second == value )
|
||||||
|
@ -1744,7 +1744,7 @@ EnumType::enum_name_list EnumType::Names() const
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EnumValPtr& EnumType::GetEnumVal(bro_int_t i)
|
const EnumValPtr& EnumType::GetEnumVal(zeek_int_t i)
|
||||||
{
|
{
|
||||||
auto it = vals.find(i);
|
auto it = vals.find(i);
|
||||||
|
|
||||||
|
@ -1784,7 +1784,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
|
|
||||||
// Create temporary, reverse name map so that enums can be documented
|
// Create temporary, reverse name map so that enums can be documented
|
||||||
// in ascending order of their actual integral value instead of by name.
|
// in ascending order of their actual integral value instead of by name.
|
||||||
using RevNameMap = std::map<bro_int_t, std::string>;
|
using RevNameMap = std::map<zeek_int_t, std::string>;
|
||||||
RevNameMap rev;
|
RevNameMap rev;
|
||||||
|
|
||||||
for ( NameMap::const_iterator it = names.begin(); it != names.end(); ++it )
|
for ( NameMap::const_iterator it = names.begin(); it != names.end(); ++it )
|
||||||
|
|
24
src/Type.h
24
src/Type.h
|
@ -766,7 +766,7 @@ protected:
|
||||||
class EnumType final : public Type
|
class EnumType final : public Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using enum_name_list = std::list<std::pair<std::string, bro_int_t>>;
|
using enum_name_list = std::list<std::pair<std::string, zeek_int_t>>;
|
||||||
|
|
||||||
explicit EnumType(const EnumType* e);
|
explicit EnumType(const EnumType* e);
|
||||||
explicit EnumType(const std::string& arg_name);
|
explicit EnumType(const std::string& arg_name);
|
||||||
|
@ -781,15 +781,15 @@ public:
|
||||||
// The value of this name is set to val. Once a value has been
|
// The value of this name is set to val. Once a value has been
|
||||||
// explicitly assigned using this method, no further names can be
|
// explicitly assigned using this method, no further names can be
|
||||||
// added that aren't likewise explicitly initalized.
|
// added that aren't likewise explicitly initalized.
|
||||||
void AddName(const std::string& module_name, const char* name, bro_int_t val, bool is_export,
|
void AddName(const std::string& module_name, const char* name, zeek_int_t val, bool is_export,
|
||||||
detail::Expr* deprecation = nullptr, bool from_redef = false);
|
detail::Expr* deprecation = nullptr, bool from_redef = false);
|
||||||
|
|
||||||
// -1 indicates not found. Second version is for full names
|
// -1 indicates not found. Second version is for full names
|
||||||
// that already incorporate the module.
|
// that already incorporate the module.
|
||||||
bro_int_t Lookup(const std::string& module_name, const char* name) const;
|
zeek_int_t Lookup(const std::string& module_name, const char* name) const;
|
||||||
bro_int_t Lookup(const std::string& full_name) const;
|
zeek_int_t Lookup(const std::string& full_name) const;
|
||||||
|
|
||||||
const char* Lookup(bro_int_t value) const; // Returns 0 if not found
|
const char* Lookup(zeek_int_t value) const; // Returns 0 if not found
|
||||||
|
|
||||||
// Returns the list of defined names with their values. The names
|
// Returns the list of defined names with their values. The names
|
||||||
// will be fully qualified with their module name.
|
// will be fully qualified with their module name.
|
||||||
|
@ -799,30 +799,30 @@ public:
|
||||||
|
|
||||||
void DescribeReST(ODesc* d, bool roles_only = false) const override;
|
void DescribeReST(ODesc* d, bool roles_only = false) const override;
|
||||||
|
|
||||||
const EnumValPtr& GetEnumVal(bro_int_t i);
|
const EnumValPtr& GetEnumVal(zeek_int_t i);
|
||||||
|
|
||||||
// Only for use by C++-generated code. Non-protected because we
|
// Only for use by C++-generated code. Non-protected because we
|
||||||
// don't know in advance the names of the functions that will
|
// don't know in advance the names of the functions that will
|
||||||
// access it.
|
// access it.
|
||||||
void AddNameInternal(const std::string& full_name, bro_int_t val);
|
void AddNameInternal(const std::string& full_name, zeek_int_t val);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddNameInternal(const std::string& module_name, const char* name, bro_int_t val,
|
void AddNameInternal(const std::string& module_name, const char* name, zeek_int_t val,
|
||||||
bool is_export);
|
bool is_export);
|
||||||
|
|
||||||
void CheckAndAddName(const std::string& module_name, const char* name, bro_int_t val,
|
void CheckAndAddName(const std::string& module_name, const char* name, zeek_int_t val,
|
||||||
bool is_export, detail::Expr* deprecation = nullptr,
|
bool is_export, detail::Expr* deprecation = nullptr,
|
||||||
bool from_redef = false);
|
bool from_redef = false);
|
||||||
|
|
||||||
void DoDescribe(ODesc* d) const override;
|
void DoDescribe(ODesc* d) const override;
|
||||||
|
|
||||||
using NameMap = std::map<std::string, bro_int_t>;
|
using NameMap = std::map<std::string, zeek_int_t>;
|
||||||
NameMap names;
|
NameMap names;
|
||||||
|
|
||||||
// Whether any of the elements of the enum were added via redef's.
|
// Whether any of the elements of the enum were added via redef's.
|
||||||
bool has_redefs = false;
|
bool has_redefs = false;
|
||||||
|
|
||||||
using ValMap = std::unordered_map<bro_int_t, EnumValPtr>;
|
using ValMap = std::unordered_map<zeek_int_t, EnumValPtr>;
|
||||||
ValMap vals;
|
ValMap vals;
|
||||||
|
|
||||||
// The counter is initialized to 0 and incremented on every implicit
|
// The counter is initialized to 0 and incremented on every implicit
|
||||||
|
@ -831,7 +831,7 @@ protected:
|
||||||
// specified, the counter is set to -1. This way counter can be used
|
// specified, the counter is set to -1. This way counter can be used
|
||||||
// as a flag to prevent mixing of auto-increment and explicit
|
// as a flag to prevent mixing of auto-increment and explicit
|
||||||
// enumerator specifications.
|
// enumerator specifications.
|
||||||
bro_int_t counter;
|
zeek_int_t counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VectorType final : public Type
|
class VectorType final : public Type
|
||||||
|
|
10
src/UID.cc
10
src/UID.cc
|
@ -12,15 +12,15 @@ using namespace std;
|
||||||
namespace zeek
|
namespace zeek
|
||||||
{
|
{
|
||||||
|
|
||||||
void UID::Set(bro_uint_t bits, const uint64_t* v, size_t n)
|
void UID::Set(zeek_uint_t bits, const uint64_t* v, size_t n)
|
||||||
{
|
{
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
for ( size_t i = 0; i < BRO_UID_LEN; ++i )
|
for ( size_t i = 0; i < UID_LEN; ++i )
|
||||||
uid[i] = 0;
|
uid[i] = 0;
|
||||||
|
|
||||||
if ( bits > BRO_UID_LEN * 64 )
|
if ( bits > UID_LEN * 64 )
|
||||||
bits = BRO_UID_LEN * 64;
|
bits = UID_LEN * 64;
|
||||||
|
|
||||||
div_t res = div(bits, 64);
|
div_t res = div(bits, 64);
|
||||||
size_t size = res.rem ? res.quot + 1 : res.quot;
|
size_t size = res.rem ? res.quot + 1 : res.quot;
|
||||||
|
@ -38,7 +38,7 @@ std::string UID::Base62(std::string prefix) const
|
||||||
reporter->InternalError("use of uninitialized UID");
|
reporter->InternalError("use of uninitialized UID");
|
||||||
|
|
||||||
char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation
|
char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation
|
||||||
for ( size_t i = 0; i < BRO_UID_LEN; ++i )
|
for ( size_t i = 0; i < UID_LEN; ++i )
|
||||||
prefix.append(util::uitoa_n(uid[i], tmp, sizeof(tmp), 62));
|
prefix.append(util::uitoa_n(uid[i], tmp, sizeof(tmp), 62));
|
||||||
|
|
||||||
return prefix;
|
return prefix;
|
||||||
|
|
16
src/UID.h
16
src/UID.h
|
@ -5,13 +5,13 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "zeek/util.h" // for bro_int_t
|
#include "zeek/util.h" // for zeek_int_t
|
||||||
|
|
||||||
#define BRO_UID_LEN 2
|
|
||||||
|
|
||||||
namespace zeek
|
namespace zeek
|
||||||
{
|
{
|
||||||
|
|
||||||
|
constexpr int UID_LEN = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class for creating/managing UIDs of arbitrary bit-length and converting
|
* A class for creating/managing UIDs of arbitrary bit-length and converting
|
||||||
* them to human-readable strings in Base62 format.
|
* them to human-readable strings in Base62 format.
|
||||||
|
@ -28,7 +28,7 @@ public:
|
||||||
* Construct a UID of a given bit-length, optionally from given values.
|
* Construct a UID of a given bit-length, optionally from given values.
|
||||||
* @see UID::Set
|
* @see UID::Set
|
||||||
*/
|
*/
|
||||||
explicit UID(bro_uint_t bits, const uint64_t* v = nullptr, size_t n = 0) { Set(bits, v, n); }
|
explicit UID(zeek_uint_t bits, const uint64_t* v = nullptr, size_t n = 0) { Set(bits, v, n); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
|
@ -38,7 +38,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Initialize a UID of a given bit-length, optionally from given values.
|
* Initialize a UID of a given bit-length, optionally from given values.
|
||||||
* @param bits The desired length in bits of the UID, up to a max of
|
* @param bits The desired length in bits of the UID, up to a max of
|
||||||
* BRO_UID_LEN * 64.
|
* UID_LEN * 64.
|
||||||
* @param v A pointer to an array of values with which to initialize the
|
* @param v A pointer to an array of values with which to initialize the
|
||||||
* UID. If empty or doesn't contain enough values to satisfy
|
* UID. If empty or doesn't contain enough values to satisfy
|
||||||
* \a bits, then values are automatically generated using
|
* \a bits, then values are automatically generated using
|
||||||
|
@ -46,7 +46,7 @@ public:
|
||||||
* 64, then a value is truncated to bit in desired bit-length.
|
* 64, then a value is truncated to bit in desired bit-length.
|
||||||
* @param n number of 64-bit elements in array pointed to by \a v.
|
* @param n number of 64-bit elements in array pointed to by \a v.
|
||||||
*/
|
*/
|
||||||
void Set(bro_uint_t bits, const uint64_t* v = nullptr, size_t n = 0);
|
void Set(zeek_uint_t bits, const uint64_t* v = nullptr, size_t n = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a base62 (characters 0-9, A-Z, a-z) representation of the UID.
|
* Returns a base62 (characters 0-9, A-Z, a-z) representation of the UID.
|
||||||
|
@ -80,7 +80,7 @@ public:
|
||||||
friend bool operator!=(const UID& u1, const UID& u2) { return ! (u1 == u2); }
|
friend bool operator!=(const UID& u1, const UID& u2) { return ! (u1 == u2); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t uid[BRO_UID_LEN];
|
uint64_t uid[UID_LEN];
|
||||||
bool initialized; // Since technically uid == 0 is a legit UID
|
bool initialized; // Since technically uid == 0 is a legit UID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,3 +98,5 @@ inline UID& UID::operator=(const UID& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace zeek
|
} // namespace zeek
|
||||||
|
|
||||||
|
constexpr int BRO_UID_LEN [[deprecated("Remove in v6.1. Use zeek::UID_LEN")]] = zeek::UID_LEN;
|
||||||
|
|
24
src/Val.cc
24
src/Val.cc
|
@ -160,20 +160,20 @@ bool Val::IsOne() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_int_t Val::InternalInt() const
|
zeek_int_t Val::InternalInt() const
|
||||||
{
|
{
|
||||||
if ( type->InternalType() == TYPE_INTERNAL_INT )
|
if ( type->InternalType() == TYPE_INTERNAL_INT )
|
||||||
return AsInt();
|
return AsInt();
|
||||||
else if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
else if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
||||||
// ### should check here for overflow
|
// ### should check here for overflow
|
||||||
return static_cast<bro_int_t>(AsCount());
|
return static_cast<zeek_int_t>(AsCount());
|
||||||
else
|
else
|
||||||
InternalWarning("bad request for InternalInt");
|
InternalWarning("bad request for InternalInt");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_uint_t Val::InternalUnsigned() const
|
zeek_uint_t Val::InternalUnsigned() const
|
||||||
{
|
{
|
||||||
if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
||||||
return AsCount();
|
return AsCount();
|
||||||
|
@ -193,28 +193,28 @@ double Val::InternalDouble() const
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_int_t Val::CoerceToInt() const
|
zeek_int_t Val::CoerceToInt() const
|
||||||
{
|
{
|
||||||
if ( type->InternalType() == TYPE_INTERNAL_INT )
|
if ( type->InternalType() == TYPE_INTERNAL_INT )
|
||||||
return AsInt();
|
return AsInt();
|
||||||
else if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
else if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
||||||
return static_cast<bro_int_t>(AsCount());
|
return static_cast<zeek_int_t>(AsCount());
|
||||||
else if ( type->InternalType() == TYPE_INTERNAL_DOUBLE )
|
else if ( type->InternalType() == TYPE_INTERNAL_DOUBLE )
|
||||||
return static_cast<bro_int_t>(AsDouble());
|
return static_cast<zeek_int_t>(AsDouble());
|
||||||
else
|
else
|
||||||
InternalWarning("bad request for CoerceToInt");
|
InternalWarning("bad request for CoerceToInt");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_uint_t Val::CoerceToUnsigned() const
|
zeek_uint_t Val::CoerceToUnsigned() const
|
||||||
{
|
{
|
||||||
if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
||||||
return AsCount();
|
return AsCount();
|
||||||
else if ( type->InternalType() == TYPE_INTERNAL_INT )
|
else if ( type->InternalType() == TYPE_INTERNAL_INT )
|
||||||
return static_cast<bro_uint_t>(AsInt());
|
return static_cast<zeek_uint_t>(AsInt());
|
||||||
else if ( type->InternalType() == TYPE_INTERNAL_DOUBLE )
|
else if ( type->InternalType() == TYPE_INTERNAL_DOUBLE )
|
||||||
return static_cast<bro_uint_t>(AsDouble());
|
return static_cast<zeek_uint_t>(AsDouble());
|
||||||
else
|
else
|
||||||
InternalWarning("bad request for CoerceToUnsigned");
|
InternalWarning("bad request for CoerceToUnsigned");
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ uint32_t PortVal::Mask(uint32_t port_num, TransportProto port_type)
|
||||||
return port_num;
|
return port_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortVal::PortVal(uint32_t p) : UnsignedValImplementation(base_type(TYPE_PORT), bro_uint_t(p)) { }
|
PortVal::PortVal(uint32_t p) : UnsignedValImplementation(base_type(TYPE_PORT), zeek_uint_t(p)) { }
|
||||||
|
|
||||||
uint32_t PortVal::Port() const
|
uint32_t PortVal::Port() const
|
||||||
{
|
{
|
||||||
|
@ -3911,12 +3911,12 @@ ValPtr Val::MakeBool(bool b)
|
||||||
return make_intrusive<BoolVal>(b);
|
return make_intrusive<BoolVal>(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValPtr Val::MakeInt(bro_int_t i)
|
ValPtr Val::MakeInt(zeek_int_t i)
|
||||||
{
|
{
|
||||||
return make_intrusive<IntVal>(i);
|
return make_intrusive<IntVal>(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValPtr Val::MakeCount(bro_uint_t u)
|
ValPtr Val::MakeCount(zeek_uint_t u)
|
||||||
{
|
{
|
||||||
return make_intrusive<CountVal>(u);
|
return make_intrusive<CountVal>(u);
|
||||||
}
|
}
|
||||||
|
|
60
src/Val.h
60
src/Val.h
|
@ -112,12 +112,12 @@ public:
|
||||||
bool IsZero() const;
|
bool IsZero() const;
|
||||||
bool IsOne() const;
|
bool IsOne() const;
|
||||||
|
|
||||||
bro_int_t InternalInt() const;
|
zeek_int_t InternalInt() const;
|
||||||
bro_uint_t InternalUnsigned() const;
|
zeek_uint_t InternalUnsigned() const;
|
||||||
double InternalDouble() const;
|
double InternalDouble() const;
|
||||||
|
|
||||||
bro_int_t CoerceToInt() const;
|
zeek_int_t CoerceToInt() const;
|
||||||
bro_uint_t CoerceToUnsigned() const;
|
zeek_uint_t CoerceToUnsigned() const;
|
||||||
double CoerceToDouble() const;
|
double CoerceToDouble() const;
|
||||||
|
|
||||||
// Returns a new Val with the "size" of this Val. What constitutes
|
// Returns a new Val with the "size" of this Val. What constitutes
|
||||||
|
@ -153,10 +153,10 @@ public:
|
||||||
|
|
||||||
#define UNDERLYING_ACCESSOR_DECL(ztype, ctype, name) ctype name() const;
|
#define UNDERLYING_ACCESSOR_DECL(ztype, ctype, name) ctype name() const;
|
||||||
|
|
||||||
UNDERLYING_ACCESSOR_DECL(detail::IntValImplementation, bro_int_t, AsInt)
|
UNDERLYING_ACCESSOR_DECL(detail::IntValImplementation, zeek_int_t, AsInt)
|
||||||
UNDERLYING_ACCESSOR_DECL(BoolVal, bool, AsBool)
|
UNDERLYING_ACCESSOR_DECL(BoolVal, bool, AsBool)
|
||||||
UNDERLYING_ACCESSOR_DECL(EnumVal, int, AsEnum)
|
UNDERLYING_ACCESSOR_DECL(EnumVal, int, AsEnum)
|
||||||
UNDERLYING_ACCESSOR_DECL(detail::UnsignedValImplementation, bro_uint_t, AsCount)
|
UNDERLYING_ACCESSOR_DECL(detail::UnsignedValImplementation, zeek_uint_t, AsCount)
|
||||||
UNDERLYING_ACCESSOR_DECL(detail::DoubleValImplementation, double, AsDouble)
|
UNDERLYING_ACCESSOR_DECL(detail::DoubleValImplementation, double, AsDouble)
|
||||||
UNDERLYING_ACCESSOR_DECL(TimeVal, double, AsTime)
|
UNDERLYING_ACCESSOR_DECL(TimeVal, double, AsTime)
|
||||||
UNDERLYING_ACCESSOR_DECL(IntervalVal, double, AsInterval)
|
UNDERLYING_ACCESSOR_DECL(IntervalVal, double, AsInterval)
|
||||||
|
@ -251,8 +251,8 @@ protected:
|
||||||
virtual void ValDescribeReST(ODesc* d) const;
|
virtual void ValDescribeReST(ODesc* d) const;
|
||||||
|
|
||||||
static ValPtr MakeBool(bool b);
|
static ValPtr MakeBool(bool b);
|
||||||
static ValPtr MakeInt(bro_int_t i);
|
static ValPtr MakeInt(zeek_int_t i);
|
||||||
static ValPtr MakeCount(bro_uint_t u);
|
static ValPtr MakeCount(zeek_uint_t u);
|
||||||
|
|
||||||
explicit Val(TypePtr t) noexcept : type(std::move(t)) { }
|
explicit Val(TypePtr t) noexcept : type(std::move(t)) { }
|
||||||
|
|
||||||
|
@ -298,10 +298,10 @@ protected:
|
||||||
class ValManager
|
class ValManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr bro_uint_t PREALLOCATED_COUNTS = 4096;
|
static constexpr zeek_uint_t PREALLOCATED_COUNTS = 4096;
|
||||||
static constexpr bro_uint_t PREALLOCATED_INTS = 512;
|
static constexpr zeek_uint_t PREALLOCATED_INTS = 512;
|
||||||
static constexpr bro_int_t PREALLOCATED_INT_LOWEST = -255;
|
static constexpr zeek_int_t PREALLOCATED_INT_LOWEST = -255;
|
||||||
static constexpr bro_int_t PREALLOCATED_INT_HIGHEST = PREALLOCATED_INT_LOWEST +
|
static constexpr zeek_int_t PREALLOCATED_INT_HIGHEST = PREALLOCATED_INT_LOWEST +
|
||||||
PREALLOCATED_INTS - 1;
|
PREALLOCATED_INTS - 1;
|
||||||
|
|
||||||
ValManager();
|
ValManager();
|
||||||
|
@ -353,23 +353,23 @@ namespace detail
|
||||||
class IntValImplementation : public Val
|
class IntValImplementation : public Val
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IntValImplementation(TypePtr t, bro_int_t v) : Val(std::move(t)), int_val(v) { }
|
IntValImplementation(TypePtr t, zeek_int_t v) : Val(std::move(t)), int_val(v) { }
|
||||||
|
|
||||||
bro_int_t Get() const { return int_val; }
|
zeek_int_t Get() const { return int_val; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bro_int_t int_val;
|
zeek_int_t int_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnsignedValImplementation : public Val
|
class UnsignedValImplementation : public Val
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UnsignedValImplementation(TypePtr t, bro_uint_t v) : Val(std::move(t)), uint_val(v) { }
|
UnsignedValImplementation(TypePtr t, zeek_uint_t v) : Val(std::move(t)), uint_val(v) { }
|
||||||
|
|
||||||
bro_uint_t Get() const { return uint_val; }
|
zeek_uint_t Get() const { return uint_val; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bro_uint_t uint_val;
|
zeek_uint_t uint_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DoubleValImplementation : public Val
|
class DoubleValImplementation : public Val
|
||||||
|
@ -388,7 +388,7 @@ protected:
|
||||||
class IntVal final : public detail::IntValImplementation
|
class IntVal final : public detail::IntValImplementation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IntVal(bro_int_t v) : detail::IntValImplementation(base_type(TYPE_INT), v) { }
|
IntVal(zeek_int_t v) : detail::IntValImplementation(base_type(TYPE_INT), v) { }
|
||||||
|
|
||||||
// No Get() method since in the current implementation the
|
// No Get() method since in the current implementation the
|
||||||
// inherited one serves that role.
|
// inherited one serves that role.
|
||||||
|
@ -397,7 +397,7 @@ public:
|
||||||
class BoolVal final : public detail::IntValImplementation
|
class BoolVal final : public detail::IntValImplementation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoolVal(bro_int_t v) : detail::IntValImplementation(base_type(TYPE_BOOL), v) { }
|
BoolVal(zeek_int_t v) : detail::IntValImplementation(base_type(TYPE_BOOL), v) { }
|
||||||
|
|
||||||
bool Get() const { return static_cast<bool>(int_val); }
|
bool Get() const { return static_cast<bool>(int_val); }
|
||||||
};
|
};
|
||||||
|
@ -405,7 +405,7 @@ public:
|
||||||
class CountVal : public detail::UnsignedValImplementation
|
class CountVal : public detail::UnsignedValImplementation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CountVal(bro_uint_t v) : detail::UnsignedValImplementation(base_type(TYPE_COUNT), v) { }
|
CountVal(zeek_uint_t v) : detail::UnsignedValImplementation(base_type(TYPE_COUNT), v) { }
|
||||||
|
|
||||||
// Same as for IntVal: no Get() method needed.
|
// Same as for IntVal: no Get() method needed.
|
||||||
};
|
};
|
||||||
|
@ -1118,13 +1118,13 @@ public:
|
||||||
// The following provide efficient record field assignments.
|
// The following provide efficient record field assignments.
|
||||||
void Assign(int field, bool new_val)
|
void Assign(int field, bool new_val)
|
||||||
{
|
{
|
||||||
(*record_val)[field] = ZVal(bro_int_t(new_val));
|
(*record_val)[field] = ZVal(zeek_int_t(new_val));
|
||||||
AddedField(field);
|
AddedField(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assign(int field, int new_val)
|
void Assign(int field, int new_val)
|
||||||
{
|
{
|
||||||
(*record_val)[field] = ZVal(bro_int_t(new_val));
|
(*record_val)[field] = ZVal(zeek_int_t(new_val));
|
||||||
AddedField(field);
|
AddedField(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,12 +1133,12 @@ public:
|
||||||
// than the other.
|
// than the other.
|
||||||
void Assign(int field, uint32_t new_val)
|
void Assign(int field, uint32_t new_val)
|
||||||
{
|
{
|
||||||
(*record_val)[field] = ZVal(bro_uint_t(new_val));
|
(*record_val)[field] = ZVal(zeek_uint_t(new_val));
|
||||||
AddedField(field);
|
AddedField(field);
|
||||||
}
|
}
|
||||||
void Assign(int field, uint64_t new_val)
|
void Assign(int field, uint64_t new_val)
|
||||||
{
|
{
|
||||||
(*record_val)[field] = ZVal(bro_uint_t(new_val));
|
(*record_val)[field] = ZVal(zeek_uint_t(new_val));
|
||||||
AddedField(field);
|
AddedField(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1469,7 +1469,7 @@ protected:
|
||||||
|
|
||||||
template <class T, class... Ts> friend IntrusivePtr<T> make_intrusive(Ts&&... args);
|
template <class T, class... Ts> friend IntrusivePtr<T> make_intrusive(Ts&&... args);
|
||||||
|
|
||||||
EnumVal(EnumTypePtr t, bro_int_t i) : detail::IntValImplementation(std::move(t), i) { }
|
EnumVal(EnumTypePtr t, zeek_int_t i) : detail::IntValImplementation(std::move(t), i) { }
|
||||||
|
|
||||||
void ValDescribe(ODesc* d) const override;
|
void ValDescribe(ODesc* d) const override;
|
||||||
ValPtr DoClone(CloneState* state) override;
|
ValPtr DoClone(CloneState* state) override;
|
||||||
|
@ -1607,8 +1607,8 @@ public:
|
||||||
* @param index The position in the vector of the element to return.
|
* @param index The position in the vector of the element to return.
|
||||||
* @return The element's underlying value.
|
* @return The element's underlying value.
|
||||||
*/
|
*/
|
||||||
bro_int_t IntAt(unsigned int index) const { return (*vector_val)[index]->int_val; }
|
zeek_int_t IntAt(unsigned int index) const { return (*vector_val)[index]->int_val; }
|
||||||
bro_uint_t CountAt(unsigned int index) const { return (*vector_val)[index]->uint_val; }
|
zeek_uint_t CountAt(unsigned int index) const { return (*vector_val)[index]->uint_val; }
|
||||||
double DoubleAt(unsigned int index) const { return (*vector_val)[index]->double_val; }
|
double DoubleAt(unsigned int index) const { return (*vector_val)[index]->double_val; }
|
||||||
const RecordVal* RecordValAt(unsigned int index) const
|
const RecordVal* RecordValAt(unsigned int index) const
|
||||||
{
|
{
|
||||||
|
@ -1689,10 +1689,10 @@ private:
|
||||||
#define UNDERLYING_ACCESSOR_DEF(ztype, ctype, name) \
|
#define UNDERLYING_ACCESSOR_DEF(ztype, ctype, name) \
|
||||||
inline ctype Val::name() const { return static_cast<const ztype*>(this)->Get(); }
|
inline ctype Val::name() const { return static_cast<const ztype*>(this)->Get(); }
|
||||||
|
|
||||||
UNDERLYING_ACCESSOR_DEF(detail::IntValImplementation, bro_int_t, AsInt)
|
UNDERLYING_ACCESSOR_DEF(detail::IntValImplementation, zeek_int_t, AsInt)
|
||||||
UNDERLYING_ACCESSOR_DEF(BoolVal, bool, AsBool)
|
UNDERLYING_ACCESSOR_DEF(BoolVal, bool, AsBool)
|
||||||
UNDERLYING_ACCESSOR_DEF(EnumVal, int, AsEnum)
|
UNDERLYING_ACCESSOR_DEF(EnumVal, int, AsEnum)
|
||||||
UNDERLYING_ACCESSOR_DEF(detail::UnsignedValImplementation, bro_uint_t, AsCount)
|
UNDERLYING_ACCESSOR_DEF(detail::UnsignedValImplementation, zeek_uint_t, AsCount)
|
||||||
UNDERLYING_ACCESSOR_DEF(detail::DoubleValImplementation, double, AsDouble)
|
UNDERLYING_ACCESSOR_DEF(detail::DoubleValImplementation, double, AsDouble)
|
||||||
UNDERLYING_ACCESSOR_DEF(TimeVal, double, AsTime)
|
UNDERLYING_ACCESSOR_DEF(TimeVal, double, AsTime)
|
||||||
UNDERLYING_ACCESSOR_DEF(IntervalVal, double, AsInterval)
|
UNDERLYING_ACCESSOR_DEF(IntervalVal, double, AsInterval)
|
||||||
|
|
16
src/ZVal.h
16
src/ZVal.h
|
@ -63,8 +63,8 @@ class ZBody;
|
||||||
ZVal(const TypePtr& t);
|
ZVal(const TypePtr& t);
|
||||||
|
|
||||||
// Construct directly.
|
// Construct directly.
|
||||||
ZVal(bro_int_t v) { int_val = v; }
|
ZVal(zeek_int_t v) { int_val = v; }
|
||||||
ZVal(bro_uint_t v) { uint_val = v; }
|
ZVal(zeek_uint_t v) { uint_val = v; }
|
||||||
ZVal(double v) { double_val = v; }
|
ZVal(double v) { double_val = v; }
|
||||||
|
|
||||||
ZVal(StringVal* v) { string_val = v; }
|
ZVal(StringVal* v) { string_val = v; }
|
||||||
|
@ -96,8 +96,8 @@ class ZBody;
|
||||||
// ensure that they're providing the correct type.
|
// ensure that they're providing the correct type.
|
||||||
ValPtr ToVal(const TypePtr& t) const;
|
ValPtr ToVal(const TypePtr& t) const;
|
||||||
|
|
||||||
bro_int_t AsInt() const { return int_val; }
|
zeek_int_t AsInt() const { return int_val; }
|
||||||
bro_uint_t AsCount() const { return uint_val; }
|
zeek_uint_t AsCount() const { return uint_val; }
|
||||||
double AsDouble() const { return double_val; }
|
double AsDouble() const { return double_val; }
|
||||||
|
|
||||||
StringVal* AsString() const { return string_val; }
|
StringVal* AsString() const { return string_val; }
|
||||||
|
@ -119,8 +119,8 @@ class ZBody;
|
||||||
|
|
||||||
// The following return references that can be used to
|
// The following return references that can be used to
|
||||||
// populate the ZVal. Handy for compiled ZAM code.
|
// populate the ZVal. Handy for compiled ZAM code.
|
||||||
bro_int_t& AsIntRef() { return int_val; }
|
zeek_int_t& AsIntRef() { return int_val; }
|
||||||
bro_uint_t& AsCountRef() { return uint_val; }
|
zeek_uint_t& AsCountRef() { return uint_val; }
|
||||||
double& AsDoubleRef() { return double_val; }
|
double& AsDoubleRef() { return double_val; }
|
||||||
StringVal*& AsStringRef() { return string_val; }
|
StringVal*& AsStringRef() { return string_val; }
|
||||||
AddrVal*& AsAddrRef() { return addr_val; }
|
AddrVal*& AsAddrRef() { return addr_val; }
|
||||||
|
@ -168,10 +168,10 @@ private:
|
||||||
friend class zeek::detail::ZBody;
|
friend class zeek::detail::ZBody;
|
||||||
|
|
||||||
// Used for bool, int, enum.
|
// Used for bool, int, enum.
|
||||||
bro_int_t int_val;
|
zeek_int_t int_val;
|
||||||
|
|
||||||
// Used for count and port.
|
// Used for count and port.
|
||||||
bro_uint_t uint_val;
|
zeek_uint_t uint_val;
|
||||||
|
|
||||||
// Used for double, time, interval.
|
// Used for double, time, interval.
|
||||||
double double_val;
|
double double_val;
|
||||||
|
|
|
@ -490,7 +490,7 @@ void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name, detail::
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type,
|
void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type,
|
||||||
bro_int_t value)
|
zeek_int_t value)
|
||||||
{
|
{
|
||||||
auto benc_value = make_intrusive<RecordVal>(bittorrent_benc_value);
|
auto benc_value = make_intrusive<RecordVal>(bittorrent_benc_value);
|
||||||
auto name_ = make_intrusive<StringVal>(name_len, name);
|
auto name_ = make_intrusive<StringVal>(name_len, name);
|
||||||
|
|
|
@ -90,7 +90,7 @@ protected:
|
||||||
void ResponseBody();
|
void ResponseBody();
|
||||||
void ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, int value_len,
|
void ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, int value_len,
|
||||||
char* value);
|
char* value);
|
||||||
void ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, bro_int_t value);
|
void ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, zeek_int_t value);
|
||||||
int ResponseParseBenc();
|
int ResponseParseBenc();
|
||||||
void EmitResponse();
|
void EmitResponse();
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ protected:
|
||||||
char res_buf[BTTRACKER_BUF];
|
char res_buf[BTTRACKER_BUF];
|
||||||
char* res_buf_pos;
|
char* res_buf_pos;
|
||||||
unsigned int res_buf_len;
|
unsigned int res_buf_len;
|
||||||
bro_uint_t res_status;
|
zeek_uint_t res_status;
|
||||||
TableVal* res_val_headers;
|
TableVal* res_val_headers;
|
||||||
TableVal* res_val_peers;
|
TableVal* res_val_peers;
|
||||||
TableVal* res_val_benc;
|
TableVal* res_val_benc;
|
||||||
|
@ -135,7 +135,7 @@ protected:
|
||||||
unsigned int benc_str_have;
|
unsigned int benc_str_have;
|
||||||
|
|
||||||
char* benc_int;
|
char* benc_int;
|
||||||
bro_int_t benc_int_val;
|
zeek_int_t benc_int_val;
|
||||||
|
|
||||||
// True on protocol violation.
|
// True on protocol violation.
|
||||||
bool stop_orig, stop_resp;
|
bool stop_orig, stop_resp;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void KRB_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64_
|
||||||
}
|
}
|
||||||
|
|
||||||
StringValPtr KRB_Analyzer::GetAuthenticationInfo(const String* principal, const String* ciphertext,
|
StringValPtr KRB_Analyzer::GetAuthenticationInfo(const String* principal, const String* ciphertext,
|
||||||
const bro_uint_t enctype)
|
const zeek_uint_t enctype)
|
||||||
{
|
{
|
||||||
#ifdef USE_KRB5
|
#ifdef USE_KRB5
|
||||||
if ( ! krb_available )
|
if ( ! krb_available )
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
static analyzer::Analyzer* Instantiate(Connection* conn) { return new KRB_Analyzer(conn); }
|
static analyzer::Analyzer* Instantiate(Connection* conn) { return new KRB_Analyzer(conn); }
|
||||||
|
|
||||||
StringValPtr GetAuthenticationInfo(const String* principal, const String* ciphertext,
|
StringValPtr GetAuthenticationInfo(const String* principal, const String* ciphertext,
|
||||||
const bro_uint_t enctype);
|
const zeek_uint_t enctype);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
binpac::KRB::KRB_Conn* interp;
|
binpac::KRB::KRB_Conn* interp;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
void EndpointEOF(bool is_orig) override;
|
void EndpointEOF(bool is_orig) override;
|
||||||
|
|
||||||
StringValPtr GetAuthenticationInfo(const String* principal, const String* ciphertext,
|
StringValPtr GetAuthenticationInfo(const String* principal, const String* ciphertext,
|
||||||
const bro_uint_t enctype)
|
const zeek_uint_t enctype)
|
||||||
{
|
{
|
||||||
return val_mgr->EmptyString();
|
return val_mgr->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ bool NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BifEnum::NFS3::PROC_READ:
|
case BifEnum::NFS3::PROC_READ:
|
||||||
bro_uint_t offset;
|
zeek_uint_t offset;
|
||||||
offset = c->RequestVal()->AsRecordVal()->GetFieldAs<CountVal>(1);
|
offset = c->RequestVal()->AsRecordVal()->GetFieldAs<CountVal>(1);
|
||||||
reply = nfs3_read_reply(buf, n, nfs_status, offset);
|
reply = nfs3_read_reply(buf, n, nfs_status, offset);
|
||||||
event = nfs_proc_read;
|
event = nfs_proc_read;
|
||||||
|
@ -546,7 +546,7 @@ RecordValPtr NFS_Interp::nfs3_readargs(const u_char*& buf, int& n)
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordValPtr NFS_Interp::nfs3_read_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status,
|
RecordValPtr NFS_Interp::nfs3_read_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status,
|
||||||
bro_uint_t offset)
|
zeek_uint_t offset)
|
||||||
{
|
{
|
||||||
auto rep = make_intrusive<RecordVal>(BifType::Record::NFS3::read_reply_t);
|
auto rep = make_intrusive<RecordVal>(BifType::Record::NFS3::read_reply_t);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ protected:
|
||||||
RecordValPtr nfs3_lookup_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status);
|
RecordValPtr nfs3_lookup_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status);
|
||||||
RecordValPtr nfs3_readargs(const u_char*& buf, int& n);
|
RecordValPtr nfs3_readargs(const u_char*& buf, int& n);
|
||||||
RecordValPtr nfs3_read_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status,
|
RecordValPtr nfs3_read_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status,
|
||||||
bro_uint_t offset);
|
zeek_uint_t offset);
|
||||||
RecordValPtr nfs3_readlink_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status);
|
RecordValPtr nfs3_readlink_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status);
|
||||||
RecordValPtr nfs3_link_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status);
|
RecordValPtr nfs3_link_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status);
|
||||||
RecordValPtr nfs3_writeargs(const u_char*& buf, int& n);
|
RecordValPtr nfs3_writeargs(const u_char*& buf, int& n);
|
||||||
|
|
|
@ -2414,7 +2414,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, Type* request_type,
|
||||||
// Well, this is kind of stupid, because EnumType just
|
// Well, this is kind of stupid, because EnumType just
|
||||||
// mangles the module name and the var name together again...
|
// mangles the module name and the var name together again...
|
||||||
// but well.
|
// but well.
|
||||||
bro_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str());
|
zeek_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str());
|
||||||
if ( index == -1 )
|
if ( index == -1 )
|
||||||
{
|
{
|
||||||
Warning(i, "Value '%s' for stream '%s' is not a valid enum.", enum_string.c_str(),
|
Warning(i, "Value '%s' for stream '%s' is not a valid enum.", enum_string.c_str(),
|
||||||
|
|
|
@ -1041,7 +1041,7 @@ threading::Value* Manager::ValToLogVal(Val* val, Type* ty)
|
||||||
lval->val.set_val.size = set->Length();
|
lval->val.set_val.size = set->Length();
|
||||||
lval->val.set_val.vals = new threading::Value*[lval->val.set_val.size];
|
lval->val.set_val.vals = new threading::Value*[lval->val.set_val.size];
|
||||||
|
|
||||||
for ( bro_int_t i = 0; i < lval->val.set_val.size; i++ )
|
for ( zeek_int_t i = 0; i < lval->val.set_val.size; i++ )
|
||||||
lval->val.set_val.vals[i] = ValToLogVal(set->Idx(i).get());
|
lval->val.set_val.vals[i] = ValToLogVal(set->Idx(i).get());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1053,7 +1053,7 @@ threading::Value* Manager::ValToLogVal(Val* val, Type* ty)
|
||||||
lval->val.vector_val.size = vec->Size();
|
lval->val.vector_val.size = vec->Size();
|
||||||
lval->val.vector_val.vals = new threading::Value*[lval->val.vector_val.size];
|
lval->val.vector_val.vals = new threading::Value*[lval->val.vector_val.size];
|
||||||
|
|
||||||
for ( bro_int_t i = 0; i < lval->val.vector_val.size; i++ )
|
for ( zeek_int_t i = 0; i < lval->val.vector_val.size; i++ )
|
||||||
{
|
{
|
||||||
lval->val.vector_val.vals[i] = ValToLogVal(vec->ValAt(i).get(),
|
lval->val.vector_val.vals[i] = ValToLogVal(vec->ValAt(i).get(),
|
||||||
vec->GetType()->Yield().get());
|
vec->GetType()->Yield().get());
|
||||||
|
|
|
@ -296,7 +296,7 @@ int SQLite::AddParams(Value* val, int pos)
|
||||||
if ( ! val->val.set_val.size )
|
if ( ! val->val.set_val.size )
|
||||||
desc.Add(empty_field);
|
desc.Add(empty_field);
|
||||||
else
|
else
|
||||||
for ( bro_int_t j = 0; j < val->val.set_val.size; j++ )
|
for ( zeek_int_t j = 0; j < val->val.set_val.size; j++ )
|
||||||
{
|
{
|
||||||
if ( j > 0 )
|
if ( j > 0 )
|
||||||
desc.AddRaw(set_separator);
|
desc.AddRaw(set_separator);
|
||||||
|
@ -319,7 +319,7 @@ int SQLite::AddParams(Value* val, int pos)
|
||||||
if ( ! val->val.vector_val.size )
|
if ( ! val->val.vector_val.size )
|
||||||
desc.Add(empty_field);
|
desc.Add(empty_field);
|
||||||
else
|
else
|
||||||
for ( bro_int_t j = 0; j < val->val.vector_val.size; j++ )
|
for ( zeek_int_t j = 0; j < val->val.vector_val.size; j++ )
|
||||||
{
|
{
|
||||||
if ( j > 0 )
|
if ( j > 0 )
|
||||||
desc.AddRaw(set_separator);
|
desc.AddRaw(set_separator);
|
||||||
|
|
|
@ -139,7 +139,7 @@ bool IPBasedAnalyzer::CheckHeaderTrunc(size_t min_hdr_len, size_t remaining, Pac
|
||||||
bool IPBasedAnalyzer::IsLikelyServerPort(uint32_t port) const
|
bool IPBasedAnalyzer::IsLikelyServerPort(uint32_t port) const
|
||||||
{
|
{
|
||||||
// We keep a cached in-core version of the table to speed up the lookup.
|
// We keep a cached in-core version of the table to speed up the lookup.
|
||||||
static std::set<bro_uint_t> port_cache;
|
static std::set<zeek_uint_t> port_cache;
|
||||||
static bool have_cache = false;
|
static bool have_cache = false;
|
||||||
|
|
||||||
if ( ! have_cache )
|
if ( ! have_cache )
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bro_uint_t skip_bytes = 0;
|
zeek_uint_t skip_bytes = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,7 +429,7 @@ static zeek::RecordValPtr build_syn_packet_val(bool is_orig, const zeek::IP_Hdr*
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_window(analyzer::tcp::TCP_Endpoint* endpoint, analyzer::tcp::TCP_Endpoint* peer,
|
static void init_window(analyzer::tcp::TCP_Endpoint* endpoint, analyzer::tcp::TCP_Endpoint* peer,
|
||||||
analyzer::tcp::TCP_Flags flags, bro_int_t scale, uint32_t base_seq,
|
analyzer::tcp::TCP_Flags flags, zeek_int_t scale, uint32_t base_seq,
|
||||||
uint32_t ack_seq)
|
uint32_t ack_seq)
|
||||||
{
|
{
|
||||||
// ### In the following, we could be fooled by an
|
// ### In the following, we could be fooled by an
|
||||||
|
|
|
@ -38,7 +38,7 @@ void UDPSessionAdapter::UpdateConnVal(RecordVal* conn_val)
|
||||||
|
|
||||||
void UDPSessionAdapter::UpdateEndpointVal(const ValPtr& endp_arg, bool is_orig)
|
void UDPSessionAdapter::UpdateEndpointVal(const ValPtr& endp_arg, bool is_orig)
|
||||||
{
|
{
|
||||||
bro_int_t size = is_orig ? request_len : reply_len;
|
zeek_int_t size = is_orig ? request_len : reply_len;
|
||||||
auto endp = endp_arg->AsRecordVal();
|
auto endp = endp_arg->AsRecordVal();
|
||||||
|
|
||||||
if ( size < 0 )
|
if ( size < 0 )
|
||||||
|
|
|
@ -30,8 +30,8 @@ private:
|
||||||
void UpdateEndpointVal(const ValPtr& endp_arg, bool is_orig);
|
void UpdateEndpointVal(const ValPtr& endp_arg, bool is_orig);
|
||||||
void ChecksumEvent(bool is_orig, uint32_t threshold);
|
void ChecksumEvent(bool is_orig, uint32_t threshold);
|
||||||
|
|
||||||
bro_int_t request_len = -1;
|
zeek_int_t request_len = -1;
|
||||||
bro_int_t reply_len = -1;
|
zeek_int_t reply_len = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace zeek::packet_analysis::UDP
|
} // namespace zeek::packet_analysis::UDP
|
||||||
|
|
|
@ -467,7 +467,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
{D} {
|
{D} {
|
||||||
RET_CONST(zeek::val_mgr->Count(static_cast<bro_uint_t>(strtoull(yytext, (char**) NULL, 10))).release())
|
RET_CONST(zeek::val_mgr->Count(static_cast<zeek_uint_t>(strtoull(yytext, (char**) NULL, 10))).release())
|
||||||
}
|
}
|
||||||
{FLOAT} RET_CONST(new zeek::DoubleVal(atof(yytext)))
|
{FLOAT} RET_CONST(new zeek::DoubleVal(atof(yytext)))
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref())
|
||||||
{FLOAT}{OWS}msec(s?) RET_CONST(new zeek::IntervalVal(atof(yytext),Milliseconds))
|
{FLOAT}{OWS}msec(s?) RET_CONST(new zeek::IntervalVal(atof(yytext),Milliseconds))
|
||||||
{FLOAT}{OWS}usec(s?) RET_CONST(new zeek::IntervalVal(atof(yytext),Microseconds))
|
{FLOAT}{OWS}usec(s?) RET_CONST(new zeek::IntervalVal(atof(yytext),Microseconds))
|
||||||
|
|
||||||
"0x"{HEX}+ RET_CONST(zeek::val_mgr->Count(static_cast<bro_uint_t>(strtoull(yytext, 0, 16))).release())
|
"0x"{HEX}+ RET_CONST(zeek::val_mgr->Count(static_cast<zeek_uint_t>(strtoull(yytext, 0, 16))).release())
|
||||||
|
|
||||||
({H}".")+{HTLD} RET_CONST(zeek::detail::dns_mgr->LookupHost(yytext).release())
|
({H}".")+{HTLD} RET_CONST(zeek::detail::dns_mgr->LookupHost(yytext).release())
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
// find optimization opportunities, including inlining.
|
// find optimization opportunities, including inlining.
|
||||||
//
|
//
|
||||||
// For some Zeek scripting types, we use their natural C++ counterparts,
|
// For some Zeek scripting types, we use their natural C++ counterparts,
|
||||||
// such as "bro_uint_t" for "count" values. In the source code these
|
// such as "zeek_uint_t" for "count" values. In the source code these
|
||||||
// are referred to as "native" types. Other types, like tables, keep
|
// are referred to as "native" types. Other types, like tables, keep
|
||||||
// their interpreter-equivalent type (e.g., TableVal). These are dealt
|
// their interpreter-equivalent type (e.g., TableVal). These are dealt
|
||||||
// with almost entirely using IntrusivePtr's. The few exceptions (i.e.,
|
// with almost entirely using IntrusivePtr's. The few exceptions (i.e.,
|
||||||
|
@ -899,7 +899,7 @@ private:
|
||||||
//
|
//
|
||||||
|
|
||||||
// "Native" types are those Zeek scripting types that we support
|
// "Native" types are those Zeek scripting types that we support
|
||||||
// using low-level C++ types (like "bro_uint_t" for "count").
|
// using low-level C++ types (like "zeek_uint_t" for "count").
|
||||||
// Types that we instead support using some form of ValPtr
|
// Types that we instead support using some form of ValPtr
|
||||||
// representation are "non-native".
|
// representation are "non-native".
|
||||||
bool IsNativeType(const TypePtr& t) const;
|
bool IsNativeType(const TypePtr& t) const;
|
||||||
|
|
|
@ -216,8 +216,8 @@ void CPPCompile::GenProlog()
|
||||||
NL();
|
NL();
|
||||||
|
|
||||||
const_info[TYPE_BOOL] = CreateConstInitInfo("Bool", "ValPtr", "bool");
|
const_info[TYPE_BOOL] = CreateConstInitInfo("Bool", "ValPtr", "bool");
|
||||||
const_info[TYPE_INT] = CreateConstInitInfo("Int", "ValPtr", "bro_int_t");
|
const_info[TYPE_INT] = CreateConstInitInfo("Int", "ValPtr", "zeek_int_t");
|
||||||
const_info[TYPE_COUNT] = CreateConstInitInfo("Count", "ValPtr", "bro_uint_t");
|
const_info[TYPE_COUNT] = CreateConstInitInfo("Count", "ValPtr", "zeek_uint_t");
|
||||||
const_info[TYPE_DOUBLE] = CreateConstInitInfo("Double", "ValPtr", "double");
|
const_info[TYPE_DOUBLE] = CreateConstInitInfo("Double", "ValPtr", "double");
|
||||||
const_info[TYPE_TIME] = CreateConstInitInfo("Time", "ValPtr", "double");
|
const_info[TYPE_TIME] = CreateConstInitInfo("Time", "ValPtr", "double");
|
||||||
const_info[TYPE_INTERVAL] = CreateConstInitInfo("Interval", "ValPtr", "double");
|
const_info[TYPE_INTERVAL] = CreateConstInitInfo("Interval", "ValPtr", "double");
|
||||||
|
|
|
@ -666,10 +666,10 @@ string CPPCompile::GenArithCoerceExpr(const Expr* e, GenType gt)
|
||||||
switch ( t->InternalType() )
|
switch ( t->InternalType() )
|
||||||
{
|
{
|
||||||
case TYPE_INTERNAL_INT:
|
case TYPE_INTERNAL_INT:
|
||||||
cast_name = "bro_int_t";
|
cast_name = "zeek_int_t";
|
||||||
break;
|
break;
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case TYPE_INTERNAL_UNSIGNED:
|
||||||
cast_name = "bro_uint_t";
|
cast_name = "zeek_uint_t";
|
||||||
break;
|
break;
|
||||||
case TYPE_INTERNAL_DOUBLE:
|
case TYPE_INTERNAL_DOUBLE:
|
||||||
cast_name = "double";
|
cast_name = "double";
|
||||||
|
|
|
@ -392,7 +392,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bro_uint_t p;
|
zeek_uint_t p;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Abstract class for compound items (those defined in terms of other items).
|
// Abstract class for compound items (those defined in terms of other items).
|
||||||
|
|
|
@ -195,7 +195,7 @@ inline PatternValPtr re_append__CPP(const PatternValPtr& p1, const PatternValPtr
|
||||||
extern ValPtr schedule__CPP(double dt, EventHandlerPtr event, std::vector<ValPtr> args);
|
extern ValPtr schedule__CPP(double dt, EventHandlerPtr event, std::vector<ValPtr> args);
|
||||||
|
|
||||||
// Simple helper functions for supporting absolute value.
|
// Simple helper functions for supporting absolute value.
|
||||||
inline bro_uint_t iabs__CPP(bro_int_t v)
|
inline zeek_uint_t iabs__CPP(zeek_int_t v)
|
||||||
{
|
{
|
||||||
return v < 0 ? -v : v;
|
return v < 0 ? -v : v;
|
||||||
}
|
}
|
||||||
|
@ -207,28 +207,28 @@ inline double fabs__CPP(double v)
|
||||||
|
|
||||||
// The following operations are provided using functions to support
|
// The following operations are provided using functions to support
|
||||||
// error checking/reporting.
|
// error checking/reporting.
|
||||||
inline bro_int_t idiv__CPP(bro_int_t v1, bro_int_t v2)
|
inline zeek_int_t idiv__CPP(zeek_int_t v1, zeek_int_t v2)
|
||||||
{
|
{
|
||||||
if ( v2 == 0 )
|
if ( v2 == 0 )
|
||||||
reporter->CPPRuntimeError("division by zero");
|
reporter->CPPRuntimeError("division by zero");
|
||||||
return v1 / v2;
|
return v1 / v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bro_int_t imod__CPP(bro_int_t v1, bro_int_t v2)
|
inline zeek_int_t imod__CPP(zeek_int_t v1, zeek_int_t v2)
|
||||||
{
|
{
|
||||||
if ( v2 == 0 )
|
if ( v2 == 0 )
|
||||||
reporter->CPPRuntimeError("modulo by zero");
|
reporter->CPPRuntimeError("modulo by zero");
|
||||||
return v1 % v2;
|
return v1 % v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bro_uint_t udiv__CPP(bro_uint_t v1, bro_uint_t v2)
|
inline zeek_uint_t udiv__CPP(zeek_uint_t v1, zeek_uint_t v2)
|
||||||
{
|
{
|
||||||
if ( v2 == 0 )
|
if ( v2 == 0 )
|
||||||
reporter->CPPRuntimeError("division by zero");
|
reporter->CPPRuntimeError("division by zero");
|
||||||
return v1 / v2;
|
return v1 / v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bro_uint_t umod__CPP(bro_uint_t v1, bro_uint_t v2)
|
inline zeek_uint_t umod__CPP(zeek_uint_t v1, zeek_uint_t v2)
|
||||||
{
|
{
|
||||||
if ( v2 == 0 )
|
if ( v2 == 0 )
|
||||||
reporter->CPPRuntimeError("modulo by zero");
|
reporter->CPPRuntimeError("modulo by zero");
|
||||||
|
|
|
@ -83,8 +83,8 @@ extern VectorValPtr vector_select__CPP(const VectorValPtr& v1, VectorValPtr v2,
|
||||||
extern VectorValPtr vector_coerce_to__CPP(const VectorValPtr& v, const TypePtr& targ);
|
extern VectorValPtr vector_coerce_to__CPP(const VectorValPtr& v, const TypePtr& targ);
|
||||||
|
|
||||||
// Similar coercion, but works for v having perhaps not the correct type.
|
// Similar coercion, but works for v having perhaps not the correct type.
|
||||||
extern VectorValPtr vec_coerce_to_bro_int_t__CPP(const VectorValPtr& v, TypePtr targ);
|
extern VectorValPtr vec_coerce_to_zeek_int_t__CPP(const VectorValPtr& v, TypePtr targ);
|
||||||
extern VectorValPtr vec_coerce_to_bro_uint_t__CPP(const VectorValPtr& v, TypePtr targ);
|
extern VectorValPtr vec_coerce_to_zeek_uint_t__CPP(const VectorValPtr& v, TypePtr targ);
|
||||||
extern VectorValPtr vec_coerce_to_double__CPP(const VectorValPtr& v, TypePtr targ);
|
extern VectorValPtr vec_coerce_to_double__CPP(const VectorValPtr& v, TypePtr targ);
|
||||||
|
|
||||||
// A dummy function used during code generation for unsupported operations
|
// A dummy function used during code generation for unsupported operations
|
||||||
|
|
|
@ -161,17 +161,17 @@ const char* CPPCompile::TypeName(const TypePtr& t)
|
||||||
case TYPE_BOOL:
|
case TYPE_BOOL:
|
||||||
return "bool";
|
return "bool";
|
||||||
case TYPE_COUNT:
|
case TYPE_COUNT:
|
||||||
return "bro_uint_t";
|
return "zeek_uint_t";
|
||||||
case TYPE_DOUBLE:
|
case TYPE_DOUBLE:
|
||||||
return "double";
|
return "double";
|
||||||
case TYPE_ENUM:
|
case TYPE_ENUM:
|
||||||
return "int";
|
return "int";
|
||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
return "bro_int_t";
|
return "zeek_int_t";
|
||||||
case TYPE_INTERVAL:
|
case TYPE_INTERVAL:
|
||||||
return "double";
|
return "double";
|
||||||
case TYPE_PORT:
|
case TYPE_PORT:
|
||||||
return "bro_uint_t";
|
return "zeek_uint_t";
|
||||||
case TYPE_TIME:
|
case TYPE_TIME:
|
||||||
return "double";
|
return "double";
|
||||||
case TYPE_VOID:
|
case TYPE_VOID:
|
||||||
|
|
|
@ -99,7 +99,7 @@ private:
|
||||||
// unseen confluence regions outer to those, and (2) they
|
// unseen confluence regions outer to those, and (2) they
|
||||||
// can get quite deep due when inlining, so there are savings
|
// can get quite deep due when inlining, so there are savings
|
||||||
// to avoid having to track outer to them.
|
// to avoid having to track outer to them.
|
||||||
std::vector<bro_uint_t> barrier_blocks;
|
std::vector<zeek_uint_t> barrier_blocks;
|
||||||
|
|
||||||
// The following is parallel to confluence_blocks except
|
// The following is parallel to confluence_blocks except
|
||||||
// the front entry tracks identifiers at the outermost
|
// the front entry tracks identifiers at the outermost
|
||||||
|
|
|
@ -70,7 +70,7 @@ void IDOptInfo::Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e,
|
void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e,
|
||||||
const std::vector<const Stmt*>& conf_blocks, bro_uint_t conf_start)
|
const std::vector<const Stmt*>& conf_blocks, zeek_uint_t conf_start)
|
||||||
{
|
{
|
||||||
if ( tracing )
|
if ( tracing )
|
||||||
printf("ID %s defined at %d: %s\n", trace_ID, s ? s->GetOptInfo()->stmt_num : NO_DEF,
|
printf("ID %s defined at %d: %s\n", trace_ID, s ? s->GetOptInfo()->stmt_num : NO_DEF,
|
||||||
|
@ -174,7 +174,7 @@ void IDOptInfo::BranchBackTo(const Stmt* from, const Stmt* to, bool close_all)
|
||||||
auto from_reg = ActiveRegion();
|
auto from_reg = ActiveRegion();
|
||||||
auto f_oi = from->GetOptInfo();
|
auto f_oi = from->GetOptInfo();
|
||||||
auto t_oi = to->GetOptInfo();
|
auto t_oi = to->GetOptInfo();
|
||||||
bro_uint_t t_r_ind = FindRegionBeforeIndex(t_oi->stmt_num);
|
zeek_uint_t t_r_ind = FindRegionBeforeIndex(t_oi->stmt_num);
|
||||||
auto& t_r = usage_regions[t_r_ind];
|
auto& t_r = usage_regions[t_r_ind];
|
||||||
|
|
||||||
if ( from_reg && from_reg->DefinedAfter() != t_r.DefinedAfter() &&
|
if ( from_reg && from_reg->DefinedAfter() != t_r.DefinedAfter() &&
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
// It should be processed starting at conf_start (note that
|
// It should be processed starting at conf_start (note that
|
||||||
// conf_blocks may be empty).
|
// conf_blocks may be empty).
|
||||||
void DefinedAfter(const Stmt* s, const ExprPtr& e, const std::vector<const Stmt*>& conf_blocks,
|
void DefinedAfter(const Stmt* s, const ExprPtr& e, const std::vector<const Stmt*>& conf_blocks,
|
||||||
bro_uint_t conf_start);
|
zeek_uint_t conf_start);
|
||||||
|
|
||||||
// Called upon encountering a "return" statement.
|
// Called upon encountering a "return" statement.
|
||||||
void ReturnAt(const Stmt* s);
|
void ReturnAt(const Stmt* s);
|
||||||
|
|
|
@ -478,7 +478,7 @@ void ZAMCompiler::ReMapFrame()
|
||||||
frame1_to_frame2.resize(frame_layout1.size(), -1);
|
frame1_to_frame2.resize(frame_layout1.size(), -1);
|
||||||
managed_slotsI.clear();
|
managed_slotsI.clear();
|
||||||
|
|
||||||
for ( bro_uint_t i = 0; i < insts1.size(); ++i )
|
for ( zeek_uint_t i = 0; i < insts1.size(); ++i )
|
||||||
{
|
{
|
||||||
auto inst = insts1[i];
|
auto inst = insts1[i];
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ void ZAMCompiler::ReMapInterpreterFrame()
|
||||||
remapped_intrp_frame_sizes[func] = next_interp_slot;
|
remapped_intrp_frame_sizes[func] = next_interp_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAMCompiler::ReMapVar(const ID* id, int slot, bro_uint_t inst)
|
void ZAMCompiler::ReMapVar(const ID* id, int slot, zeek_uint_t inst)
|
||||||
{
|
{
|
||||||
// A greedy algorithm for this is to simply find the first suitable
|
// A greedy algorithm for this is to simply find the first suitable
|
||||||
// frame slot. We do that with one twist: we also look for a
|
// frame slot. We do that with one twist: we also look for a
|
||||||
|
@ -731,7 +731,7 @@ void ZAMCompiler::ReMapVar(const ID* id, int slot, bro_uint_t inst)
|
||||||
|
|
||||||
void ZAMCompiler::CheckSlotAssignment(int slot, const ZInstI* inst)
|
void ZAMCompiler::CheckSlotAssignment(int slot, const ZInstI* inst)
|
||||||
{
|
{
|
||||||
ASSERT(slot >= 0 && static_cast<bro_uint_t>(slot) < frame_denizens.size());
|
ASSERT(slot >= 0 && static_cast<zeek_uint_t>(slot) < frame_denizens.size());
|
||||||
|
|
||||||
// We construct temporaries such that their values are never used
|
// We construct temporaries such that their values are never used
|
||||||
// earlier than their definitions in loop bodies. For other
|
// earlier than their definitions in loop bodies. For other
|
||||||
|
@ -770,7 +770,7 @@ void ZAMCompiler::CheckSlotUse(int slot, const ZInstI* inst)
|
||||||
if ( slot < 0 )
|
if ( slot < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(static_cast<bro_uint_t>(slot) < frame_denizens.size());
|
ASSERT(static_cast<zeek_uint_t>(slot) < frame_denizens.size());
|
||||||
|
|
||||||
if ( denizen_beginning.count(slot) == 0 )
|
if ( denizen_beginning.count(slot) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -957,9 +957,9 @@ ZInstI* ZAMCompiler::FirstLiveInst(ZInstI* i, bool follow_gotos)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_uint_t ZAMCompiler::FirstLiveInst(bro_uint_t i, bool follow_gotos)
|
zeek_uint_t ZAMCompiler::FirstLiveInst(zeek_uint_t i, bool follow_gotos)
|
||||||
{
|
{
|
||||||
bro_uint_t num_inspected = 0;
|
zeek_uint_t num_inspected = 0;
|
||||||
while ( i < insts1.size() )
|
while ( i < insts1.size() )
|
||||||
{
|
{
|
||||||
auto i0 = insts1[i];
|
auto i0 = insts1[i];
|
||||||
|
@ -987,7 +987,7 @@ bro_uint_t ZAMCompiler::FirstLiveInst(bro_uint_t i, bool follow_gotos)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAMCompiler::KillInst(bro_uint_t i)
|
void ZAMCompiler::KillInst(zeek_uint_t i)
|
||||||
{
|
{
|
||||||
auto inst = insts1[i];
|
auto inst = insts1[i];
|
||||||
|
|
||||||
|
@ -1042,7 +1042,7 @@ void ZAMCompiler::KillInst(bro_uint_t i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAMCompiler::KillInsts(bro_uint_t i)
|
void ZAMCompiler::KillInsts(zeek_uint_t i)
|
||||||
{
|
{
|
||||||
auto inst = insts1[i];
|
auto inst = insts1[i];
|
||||||
|
|
||||||
|
|
|
@ -416,11 +416,11 @@ bool ZAMCompiler::BuiltIn_to_lower(const NameExpr* n, const ExprPList& args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bro_uint_t ZAMCompiler::ConstArgsMask(const ExprPList& args, int nargs) const
|
zeek_uint_t ZAMCompiler::ConstArgsMask(const ExprPList& args, int nargs) const
|
||||||
{
|
{
|
||||||
ASSERT(args.length() == nargs);
|
ASSERT(args.length() == nargs);
|
||||||
|
|
||||||
bro_uint_t mask = 0;
|
zeek_uint_t mask = 0;
|
||||||
|
|
||||||
for ( int i = 0; i < nargs; ++i )
|
for ( int i = 0; i < nargs; ++i )
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,9 +76,9 @@ public:
|
||||||
|
|
||||||
template <typename T> const CaseMaps<T>& GetCases() const
|
template <typename T> const CaseMaps<T>& GetCases() const
|
||||||
{
|
{
|
||||||
if constexpr ( std::is_same_v<T, bro_int_t> )
|
if constexpr ( std::is_same_v<T, zeek_int_t> )
|
||||||
return int_cases;
|
return int_cases;
|
||||||
else if constexpr ( std::is_same_v<T, bro_uint_t> )
|
else if constexpr ( std::is_same_v<T, zeek_uint_t> )
|
||||||
return uint_cases;
|
return uint_cases;
|
||||||
else if constexpr ( std::is_same_v<T, double> )
|
else if constexpr ( std::is_same_v<T, double> )
|
||||||
return double_cases;
|
return double_cases;
|
||||||
|
@ -256,7 +256,7 @@ private:
|
||||||
// being the first argument (argument "0" in the list) and the
|
// being the first argument (argument "0" in the list) and the
|
||||||
// low-ordered bit being the last. Second parameter is the number
|
// low-ordered bit being the last. Second parameter is the number
|
||||||
// of arguments that should be present.
|
// of arguments that should be present.
|
||||||
bro_uint_t ConstArgsMask(const ExprPList& args, int nargs) const;
|
zeek_uint_t ConstArgsMask(const ExprPList& args, int nargs) const;
|
||||||
|
|
||||||
int ConvertToInt(const Expr* e)
|
int ConvertToInt(const Expr* e)
|
||||||
{
|
{
|
||||||
|
@ -419,7 +419,7 @@ private:
|
||||||
|
|
||||||
// Computes the remapping for a variable currently in the given slot,
|
// Computes the remapping for a variable currently in the given slot,
|
||||||
// whose scope begins at the given instruction.
|
// whose scope begins at the given instruction.
|
||||||
void ReMapVar(const ID* id, int slot, bro_uint_t inst);
|
void ReMapVar(const ID* id, int slot, zeek_uint_t inst);
|
||||||
|
|
||||||
// Look to initialize the beginning of local lifetime based on slot
|
// Look to initialize the beginning of local lifetime based on slot
|
||||||
// assignment at instruction inst.
|
// assignment at instruction inst.
|
||||||
|
@ -463,7 +463,7 @@ private:
|
||||||
// First form returns nil if there's nothing live after i.
|
// First form returns nil if there's nothing live after i.
|
||||||
// Second form returns insts1.size() in that case.
|
// Second form returns insts1.size() in that case.
|
||||||
ZInstI* FirstLiveInst(ZInstI* i, bool follow_gotos = false);
|
ZInstI* FirstLiveInst(ZInstI* i, bool follow_gotos = false);
|
||||||
bro_uint_t FirstLiveInst(bro_uint_t i, bool follow_gotos = false);
|
zeek_uint_t FirstLiveInst(zeek_uint_t i, bool follow_gotos = false);
|
||||||
|
|
||||||
// Same, but not including i.
|
// Same, but not including i.
|
||||||
ZInstI* NextLiveInst(ZInstI* i, bool follow_gotos = false)
|
ZInstI* NextLiveInst(ZInstI* i, bool follow_gotos = false)
|
||||||
|
@ -482,12 +482,12 @@ private:
|
||||||
// into insts1; any labels associated with it are transferred
|
// into insts1; any labels associated with it are transferred
|
||||||
// to its next live successor, if any.
|
// to its next live successor, if any.
|
||||||
void KillInst(ZInstI* i) { KillInst(i->inst_num); }
|
void KillInst(ZInstI* i) { KillInst(i->inst_num); }
|
||||||
void KillInst(bro_uint_t i);
|
void KillInst(zeek_uint_t i);
|
||||||
|
|
||||||
// The same, but kills any successor instructions until finding
|
// The same, but kills any successor instructions until finding
|
||||||
// one that's labeled.
|
// one that's labeled.
|
||||||
void KillInsts(ZInstI* i) { KillInsts(i->inst_num); }
|
void KillInsts(ZInstI* i) { KillInsts(i->inst_num); }
|
||||||
void KillInsts(bro_uint_t i);
|
void KillInsts(zeek_uint_t i);
|
||||||
|
|
||||||
// The first of these is used as we compile down to ZInstI's.
|
// The first of these is used as we compile down to ZInstI's.
|
||||||
// The second is the final intermediary code. They're separate
|
// The second is the final intermediary code. They're separate
|
||||||
|
@ -569,8 +569,8 @@ private:
|
||||||
|
|
||||||
// Intermediary switch tables (branching to ZInst's rather
|
// Intermediary switch tables (branching to ZInst's rather
|
||||||
// than concrete instruction offsets).
|
// than concrete instruction offsets).
|
||||||
CaseMapsI<bro_int_t> int_casesI;
|
CaseMapsI<zeek_int_t> int_casesI;
|
||||||
CaseMapsI<bro_uint_t> uint_casesI;
|
CaseMapsI<zeek_uint_t> uint_casesI;
|
||||||
CaseMapsI<double> double_casesI;
|
CaseMapsI<double> double_casesI;
|
||||||
|
|
||||||
// Note, we use this not only for strings but for addresses
|
// Note, we use this not only for strings but for addresses
|
||||||
|
@ -578,8 +578,8 @@ private:
|
||||||
CaseMapsI<std::string> str_casesI;
|
CaseMapsI<std::string> str_casesI;
|
||||||
|
|
||||||
// Same, but for the concretized versions.
|
// Same, but for the concretized versions.
|
||||||
CaseMaps<bro_int_t> int_cases;
|
CaseMaps<zeek_int_t> int_cases;
|
||||||
CaseMaps<bro_uint_t> uint_cases;
|
CaseMaps<zeek_uint_t> uint_cases;
|
||||||
CaseMaps<double> double_cases;
|
CaseMaps<double> double_cases;
|
||||||
CaseMaps<std::string> str_cases;
|
CaseMaps<std::string> str_cases;
|
||||||
|
|
||||||
|
|
|
@ -442,7 +442,7 @@ template <typename T> void ZAMCompiler::DumpCases(const T& cases, const char* ty
|
||||||
std::string case_val;
|
std::string case_val;
|
||||||
if constexpr ( std::is_same_v<T, std::string> )
|
if constexpr ( std::is_same_v<T, std::string> )
|
||||||
case_val = m.first;
|
case_val = m.first;
|
||||||
else if constexpr ( std::is_same_v<T, bro_int_t> || std::is_same_v<T, bro_uint_t> ||
|
else if constexpr ( std::is_same_v<T, zeek_int_t> || std::is_same_v<T, zeek_uint_t> ||
|
||||||
std::is_same_v<T, double> )
|
std::is_same_v<T, double> )
|
||||||
case_val = std::to_string(m.first);
|
case_val = std::to_string(m.first);
|
||||||
|
|
||||||
|
|
|
@ -641,7 +641,7 @@ const ZAMStmt ZAMCompiler::CompileIndex(const NameExpr* n1, int n2_slot, const T
|
||||||
auto var_ind = ind->Tag() == EXPR_NAME;
|
auto var_ind = ind->Tag() == EXPR_NAME;
|
||||||
auto n3 = var_ind ? ind->AsNameExpr() : nullptr;
|
auto n3 = var_ind ? ind->AsNameExpr() : nullptr;
|
||||||
auto c3 = var_ind ? nullptr : ind->AsConstExpr();
|
auto c3 = var_ind ? nullptr : ind->AsConstExpr();
|
||||||
bro_uint_t c = 0;
|
zeek_uint_t c = 0;
|
||||||
|
|
||||||
if ( ! var_ind )
|
if ( ! var_ind )
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,8 +126,8 @@ public:
|
||||||
void IterFinished() { ++iter; }
|
void IterFinished() { ++iter; }
|
||||||
|
|
||||||
// Counter of where we are in the iteration.
|
// Counter of where we are in the iteration.
|
||||||
bro_uint_t iter; // initialized to 0 at start of loop
|
zeek_uint_t iter; // initialized to 0 at start of loop
|
||||||
bro_uint_t n; // we loop from 0 ... n-1
|
zeek_uint_t n; // we loop from 0 ... n-1
|
||||||
|
|
||||||
// The low-level value we're iterating over.
|
// The low-level value we're iterating over.
|
||||||
const std::vector<std::optional<ZVal>>* vv;
|
const std::vector<std::optional<ZVal>>* vv;
|
||||||
|
|
|
@ -297,14 +297,14 @@ op-type I U D A N S T V *
|
||||||
explicit-result-type
|
explicit-result-type
|
||||||
set-type $$
|
set-type $$
|
||||||
set-type2 $1
|
set-type2 $1
|
||||||
eval-type I $$ = ZVal(bro_int_t($1 < 0 ? -$1 : $1));
|
eval-type I $$ = ZVal(zeek_int_t($1 < 0 ? -$1 : $1));
|
||||||
eval-type U $$ = ZVal($1);
|
eval-type U $$ = ZVal($1);
|
||||||
eval-type D $$ = ZVal($1 < 0 ? -$1 : $1);
|
eval-type D $$ = ZVal($1 < 0 ? -$1 : $1);
|
||||||
eval-type A $$ = ZVal(bro_uint_t($1->AsAddr().GetFamily() == IPv4 ? 32 : 128));
|
eval-type A $$ = ZVal(zeek_uint_t($1->AsAddr().GetFamily() == IPv4 ? 32 : 128));
|
||||||
eval-type N $$ = ZVal(pow(2.0, double(128 - $1->AsSubNet().LengthIPv6())));
|
eval-type N $$ = ZVal(pow(2.0, double(128 - $1->AsSubNet().LengthIPv6())));
|
||||||
eval-type S $$ = ZVal(bro_uint_t($1->Len()));
|
eval-type S $$ = ZVal(zeek_uint_t($1->Len()));
|
||||||
eval-type T $$ = ZVal(bro_uint_t($1->Size()));
|
eval-type T $$ = ZVal(zeek_uint_t($1->Size()));
|
||||||
eval-type V $$ = ZVal(bro_uint_t($1->Size()));
|
eval-type V $$ = ZVal(zeek_uint_t($1->Size()));
|
||||||
eval auto v = frame[z.v2].ToVal(z.t2)->SizeVal();
|
eval auto v = frame[z.v2].ToVal(z.t2)->SizeVal();
|
||||||
$$ = BuildVal(v, z.t);
|
$$ = BuildVal(v, z.t);
|
||||||
|
|
||||||
|
@ -510,12 +510,12 @@ eval $1 % $2
|
||||||
binary-expr-op And-And
|
binary-expr-op And-And
|
||||||
op-type I
|
op-type I
|
||||||
vector
|
vector
|
||||||
eval bro_int_t($1 && $2)
|
eval zeek_int_t($1 && $2)
|
||||||
|
|
||||||
binary-expr-op Or-Or
|
binary-expr-op Or-Or
|
||||||
op-type I
|
op-type I
|
||||||
vector
|
vector
|
||||||
eval bro_int_t($1 || $2)
|
eval zeek_int_t($1 || $2)
|
||||||
|
|
||||||
binary-expr-op And
|
binary-expr-op And
|
||||||
op-type U P T
|
op-type U P T
|
||||||
|
@ -833,13 +833,13 @@ internal-op Val-Is-In-Vector
|
||||||
type VVV
|
type VVV
|
||||||
eval auto& vec = frame[z.v3].vector_val;
|
eval auto& vec = frame[z.v3].vector_val;
|
||||||
auto ind = frame[z.v2].int_val;
|
auto ind = frame[z.v2].int_val;
|
||||||
frame[z.v1].int_val = ind >= 0 && static_cast<bro_uint_t>(ind) < vec->Size();
|
frame[z.v1].int_val = ind >= 0 && static_cast<zeek_uint_t>(ind) < vec->Size();
|
||||||
|
|
||||||
internal-op Const-Is-In-Vector
|
internal-op Const-Is-In-Vector
|
||||||
type VCV
|
type VCV
|
||||||
eval auto& vec = frame[z.v2].vector_val;
|
eval auto& vec = frame[z.v2].vector_val;
|
||||||
auto ind = z.c.int_val;
|
auto ind = z.c.int_val;
|
||||||
frame[z.v1].int_val = ind >= 0 && static_cast<bro_uint_t>(ind) < vec->Size();
|
frame[z.v1].int_val = ind >= 0 && static_cast<zeek_uint_t>(ind) < vec->Size();
|
||||||
|
|
||||||
expr-op Cond
|
expr-op Cond
|
||||||
type VVVV
|
type VVVV
|
||||||
|
@ -944,7 +944,7 @@ eval EvalIndexVec(frame[z.v3].uint_val)
|
||||||
macro EvalIndexVec(index)
|
macro EvalIndexVec(index)
|
||||||
auto vv = frame[z.v2].vector_val->RawVec();
|
auto vv = frame[z.v2].vector_val->RawVec();
|
||||||
const auto& vec = *vv;
|
const auto& vec = *vv;
|
||||||
bro_uint_t ind = index;
|
zeek_uint_t ind = index;
|
||||||
if ( ind >= vv->size() )
|
if ( ind >= vv->size() )
|
||||||
ZAM_run_time_error(z.loc, "no such index");
|
ZAM_run_time_error(z.loc, "no such index");
|
||||||
AssignV1(CopyVal(*vec[ind]))
|
AssignV1(CopyVal(*vec[ind]))
|
||||||
|
@ -959,7 +959,7 @@ eval EvalIndexAnyVec(frame[z.v3].uint_val)
|
||||||
|
|
||||||
macro EvalIndexAnyVec(index)
|
macro EvalIndexAnyVec(index)
|
||||||
auto vv = frame[z.v2].vector_val;
|
auto vv = frame[z.v2].vector_val;
|
||||||
bro_uint_t ind = index;
|
zeek_uint_t ind = index;
|
||||||
if ( ind >= vv->Size() )
|
if ( ind >= vv->Size() )
|
||||||
ZAM_run_time_error(z.loc, "no such index");
|
ZAM_run_time_error(z.loc, "no such index");
|
||||||
AssignV1(ZVal(vv->ValAt(ind).release()))
|
AssignV1(ZVal(vv->ValAt(ind).release()))
|
||||||
|
@ -1141,7 +1141,7 @@ eval auto v = frame[z.v2].int_val;
|
||||||
ZAM_run_time_error(z.loc, "underflow converting int to count");
|
ZAM_run_time_error(z.loc, "underflow converting int to count");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
frame[z.v1].uint_val = bro_uint_t(v);
|
frame[z.v1].uint_val = zeek_uint_t(v);
|
||||||
|
|
||||||
internal-op Coerce-UD
|
internal-op Coerce-UD
|
||||||
type VV
|
type VV
|
||||||
|
@ -1156,7 +1156,7 @@ eval auto v = frame[z.v2].double_val;
|
||||||
ZAM_run_time_error(z.loc, "overflow converting double to count");
|
ZAM_run_time_error(z.loc, "overflow converting double to count");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
frame[z.v1].uint_val = bro_uint_t(v);
|
frame[z.v1].uint_val = zeek_uint_t(v);
|
||||||
|
|
||||||
internal-op Coerce-IU
|
internal-op Coerce-IU
|
||||||
type VV
|
type VV
|
||||||
|
@ -1166,7 +1166,7 @@ eval auto v = frame[z.v2].uint_val;
|
||||||
ZAM_run_time_error(z.loc, "overflow converting count to int");
|
ZAM_run_time_error(z.loc, "overflow converting count to int");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
frame[z.v1].int_val = bro_int_t(v);
|
frame[z.v1].int_val = zeek_int_t(v);
|
||||||
|
|
||||||
internal-op Coerce-ID
|
internal-op Coerce-ID
|
||||||
type VV
|
type VV
|
||||||
|
@ -1181,7 +1181,7 @@ eval auto v = frame[z.v2].double_val;
|
||||||
ZAM_run_time_error(z.loc, "overflow converting double to int");
|
ZAM_run_time_error(z.loc, "overflow converting double to int");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
frame[z.v1].int_val = bro_int_t(v);
|
frame[z.v1].int_val = zeek_int_t(v);
|
||||||
|
|
||||||
internal-op Coerce-DI
|
internal-op Coerce-DI
|
||||||
type VV
|
type VV
|
||||||
|
@ -1804,7 +1804,7 @@ op CheckAnyLen
|
||||||
op1-read
|
op1-read
|
||||||
type Vi
|
type Vi
|
||||||
eval auto v = frame[z.v1].list_val;
|
eval auto v = frame[z.v1].list_val;
|
||||||
if ( v->Vals().size() != static_cast<bro_uint_t>(z.v2) )
|
if ( v->Vals().size() != static_cast<zeek_uint_t>(z.v2) )
|
||||||
ZAM_run_time_error(z.loc, "mismatch in list lengths");
|
ZAM_run_time_error(z.loc, "mismatch in list lengths");
|
||||||
|
|
||||||
op Print
|
op Print
|
||||||
|
@ -2002,11 +2002,11 @@ eval EvalSubBytes(frame[z.v2], frame[z.v3].uint_val, z.v4)
|
||||||
|
|
||||||
internal-op Sub-Bytes
|
internal-op Sub-Bytes
|
||||||
type VViV
|
type VViV
|
||||||
eval EvalSubBytes(frame[z.v2], bro_uint_t(z.v4), frame[z.v3].int_val)
|
eval EvalSubBytes(frame[z.v2], zeek_uint_t(z.v4), frame[z.v3].int_val)
|
||||||
|
|
||||||
internal-op Sub-Bytes
|
internal-op Sub-Bytes
|
||||||
type VVii
|
type VVii
|
||||||
eval EvalSubBytes(frame[z.v2], bro_uint_t(z.v3), z.v4)
|
eval EvalSubBytes(frame[z.v2], zeek_uint_t(z.v3), z.v4)
|
||||||
|
|
||||||
internal-op Sub-Bytes
|
internal-op Sub-Bytes
|
||||||
type VVVC
|
type VVVC
|
||||||
|
@ -2018,11 +2018,11 @@ eval EvalSubBytes(z.c, frame[z.v2].uint_val, z.v3)
|
||||||
|
|
||||||
internal-op Sub-Bytes
|
internal-op Sub-Bytes
|
||||||
type ViVC
|
type ViVC
|
||||||
eval EvalSubBytes(z.c, bro_uint_t(z.v3), frame[z.v2].uint_val)
|
eval EvalSubBytes(z.c, zeek_uint_t(z.v3), frame[z.v2].uint_val)
|
||||||
|
|
||||||
internal-op Sub-Bytes
|
internal-op Sub-Bytes
|
||||||
type ViiC
|
type ViiC
|
||||||
eval EvalSubBytes(z.c, bro_uint_t(z.v2), z.v3)
|
eval EvalSubBytes(z.c, zeek_uint_t(z.v2), z.v3)
|
||||||
|
|
||||||
|
|
||||||
internal-op To-Lower
|
internal-op To-Lower
|
||||||
|
@ -2167,4 +2167,4 @@ internal-op Files--Set-Reassembly-Buffer
|
||||||
op1-read
|
op1-read
|
||||||
type VC
|
type VC
|
||||||
eval auto f = frame[z.v1].string_val->CheckString();
|
eval auto f = frame[z.v1].string_val->CheckString();
|
||||||
file_mgr->SetReassemblyBuffer(f, bro_uint_t(z.v2));
|
file_mgr->SetReassemblyBuffer(f, zeek_uint_t(z.v2));
|
||||||
|
|
|
@ -502,8 +502,8 @@ const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v,
|
||||||
// Now fill out the corresponding jump table.
|
// Now fill out the corresponding jump table.
|
||||||
//
|
//
|
||||||
// We will only use one of these.
|
// We will only use one of these.
|
||||||
CaseMapI<bro_int_t> new_int_cases;
|
CaseMapI<zeek_int_t> new_int_cases;
|
||||||
CaseMapI<bro_uint_t> new_uint_cases;
|
CaseMapI<zeek_uint_t> new_uint_cases;
|
||||||
CaseMapI<double> new_double_cases;
|
CaseMapI<double> new_double_cases;
|
||||||
CaseMapI<std::string> new_str_cases;
|
CaseMapI<std::string> new_str_cases;
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ StringVal* ZAM_to_lower(const StringVal* sv)
|
||||||
return new StringVal(new String(1, lower_s, n));
|
return new StringVal(new String(1, lower_s, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringVal* ZAM_sub_bytes(const StringVal* s, bro_uint_t start, bro_int_t n)
|
StringVal* ZAM_sub_bytes(const StringVal* s, zeek_uint_t start, zeek_int_t n)
|
||||||
{
|
{
|
||||||
if ( start > 0 )
|
if ( start > 0 )
|
||||||
--start; // make it 0-based
|
--start; // make it 0-based
|
||||||
|
|
|
@ -52,6 +52,6 @@ extern bool ZAM_error;
|
||||||
extern void ZAM_run_time_warning(const Location* loc, const char* msg);
|
extern void ZAM_run_time_warning(const Location* loc, const char* msg);
|
||||||
|
|
||||||
extern StringVal* ZAM_to_lower(const StringVal* sv);
|
extern StringVal* ZAM_to_lower(const StringVal* sv);
|
||||||
extern StringVal* ZAM_sub_bytes(const StringVal* s, bro_uint_t start, bro_int_t n);
|
extern StringVal* ZAM_sub_bytes(const StringVal* s, zeek_uint_t start, zeek_int_t n);
|
||||||
|
|
||||||
} // namespace zeek::detail
|
} // namespace zeek::detail
|
||||||
|
|
|
@ -47,7 +47,7 @@ void report_ZOP_profile()
|
||||||
// assigned value was missing (which we can only tell for managed types),
|
// assigned value was missing (which we can only tell for managed types),
|
||||||
// true otherwise.
|
// true otherwise.
|
||||||
|
|
||||||
static bool copy_vec_elem(VectorVal* vv, bro_uint_t ind, ZVal zv, const TypePtr& t)
|
static bool copy_vec_elem(VectorVal* vv, zeek_uint_t ind, ZVal zv, const TypePtr& t)
|
||||||
{
|
{
|
||||||
if ( vv->Size() <= ind )
|
if ( vv->Size() <= ind )
|
||||||
vv->Resize(ind + 1);
|
vv->Resize(ind + 1);
|
||||||
|
@ -118,11 +118,11 @@ static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, con
|
||||||
|
|
||||||
VEC_COERCE(DI, TYPE_DOUBLE, double, AsInt(), false_func, "")
|
VEC_COERCE(DI, TYPE_DOUBLE, double, AsInt(), false_func, "")
|
||||||
VEC_COERCE(DU, TYPE_DOUBLE, double, AsCount(), false_func, "")
|
VEC_COERCE(DU, TYPE_DOUBLE, double, AsCount(), false_func, "")
|
||||||
VEC_COERCE(ID, TYPE_INT, bro_int_t, AsDouble(), double_to_int_would_overflow, "double to signed")
|
VEC_COERCE(ID, TYPE_INT, zeek_int_t, AsDouble(), double_to_int_would_overflow, "double to signed")
|
||||||
VEC_COERCE(IU, TYPE_INT, bro_int_t, AsCount(), count_to_int_would_overflow, "unsigned to signed")
|
VEC_COERCE(IU, TYPE_INT, zeek_int_t, AsCount(), count_to_int_would_overflow, "unsigned to signed")
|
||||||
VEC_COERCE(UD, TYPE_COUNT, bro_uint_t, AsDouble(), double_to_count_would_overflow,
|
VEC_COERCE(UD, TYPE_COUNT, zeek_uint_t, AsDouble(), double_to_count_would_overflow,
|
||||||
"double to unsigned")
|
"double to unsigned")
|
||||||
VEC_COERCE(UI, TYPE_COUNT, bro_int_t, AsInt(), int_to_count_would_overflow, "signed to unsigned")
|
VEC_COERCE(UI, TYPE_COUNT, zeek_int_t, AsInt(), int_to_count_would_overflow, "signed to unsigned")
|
||||||
|
|
||||||
ZBody::ZBody(const char* _func_name, const ZAMCompiler* zc) : Stmt(STMT_ZAM)
|
ZBody::ZBody(const char* _func_name, const ZAMCompiler* zc) : Stmt(STMT_ZAM)
|
||||||
{
|
{
|
||||||
|
@ -141,8 +141,8 @@ ZBody::ZBody(const char* _func_name, const ZAMCompiler* zc) : Stmt(STMT_ZAM)
|
||||||
globals = zc->Globals();
|
globals = zc->Globals();
|
||||||
num_globals = globals.size();
|
num_globals = globals.size();
|
||||||
|
|
||||||
int_cases = zc->GetCases<bro_int_t>();
|
int_cases = zc->GetCases<zeek_int_t>();
|
||||||
uint_cases = zc->GetCases<bro_uint_t>();
|
uint_cases = zc->GetCases<zeek_uint_t>();
|
||||||
double_cases = zc->GetCases<double>();
|
double_cases = zc->GetCases<double>();
|
||||||
str_cases = zc->GetCases<std::string>();
|
str_cases = zc->GetCases<std::string>();
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,8 @@ private:
|
||||||
double* CPU_time = nullptr; // cumulative CPU time for the program
|
double* CPU_time = nullptr; // cumulative CPU time for the program
|
||||||
std::vector<double>* inst_CPU = nullptr; // per-instruction CPU time.
|
std::vector<double>* inst_CPU = nullptr; // per-instruction CPU time.
|
||||||
|
|
||||||
CaseMaps<bro_int_t> int_cases;
|
CaseMaps<zeek_int_t> int_cases;
|
||||||
CaseMaps<bro_uint_t> uint_cases;
|
CaseMaps<zeek_uint_t> uint_cases;
|
||||||
CaseMaps<double> double_cases;
|
CaseMaps<double> double_cases;
|
||||||
CaseMaps<std::string> str_cases;
|
CaseMaps<std::string> str_cases;
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ using std::string;
|
||||||
namespace zeek::detail
|
namespace zeek::detail
|
||||||
{
|
{
|
||||||
|
|
||||||
void ZInst::Dump(bro_uint_t inst_num, const FrameReMap* mappings) const
|
void ZInst::Dump(zeek_uint_t inst_num, const FrameReMap* mappings) const
|
||||||
{
|
{
|
||||||
// printf("v%d ", n);
|
// printf("v%d ", n);
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ int ZInst::NumSlots() const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ZInst::VName(int n, bro_uint_t inst_num, const FrameReMap* mappings) const
|
string ZInst::VName(int n, zeek_uint_t inst_num, const FrameReMap* mappings) const
|
||||||
{
|
{
|
||||||
if ( n > NumFrameSlots() )
|
if ( n > NumFrameSlots() )
|
||||||
return "";
|
return "";
|
||||||
|
@ -223,7 +223,7 @@ string ZInst::VName(int n, bro_uint_t inst_num, const FrameReMap* mappings) cons
|
||||||
return "<special>";
|
return "<special>";
|
||||||
|
|
||||||
// Find which identifier manifests at this instruction.
|
// Find which identifier manifests at this instruction.
|
||||||
ASSERT(slot >= 0 && static_cast<bro_uint_t>(slot) < mappings->size());
|
ASSERT(slot >= 0 && static_cast<zeek_uint_t>(slot) < mappings->size());
|
||||||
|
|
||||||
auto& map = (*mappings)[slot];
|
auto& map = (*mappings)[slot];
|
||||||
|
|
||||||
|
@ -323,12 +323,12 @@ string ZInstI::VName(int n, const FrameMap* frame_ids, const FrameReMap* remappi
|
||||||
|
|
||||||
if ( remappings && live )
|
if ( remappings && live )
|
||||||
{ // Find which identifier manifests at this instruction.
|
{ // Find which identifier manifests at this instruction.
|
||||||
ASSERT(slot >= 0 && static_cast<bro_uint_t>(slot) < remappings->size());
|
ASSERT(slot >= 0 && static_cast<zeek_uint_t>(slot) < remappings->size());
|
||||||
|
|
||||||
auto& map = (*remappings)[slot];
|
auto& map = (*remappings)[slot];
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
auto inst_num_u = static_cast<bro_uint_t>(inst_num);
|
auto inst_num_u = static_cast<zeek_uint_t>(inst_num);
|
||||||
for ( i = 0; i < map.id_start.size(); ++i )
|
for ( i = 0; i < map.id_start.size(); ++i )
|
||||||
{
|
{
|
||||||
// See discussion for ZInst::VName.
|
// See discussion for ZInst::VName.
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
|
|
||||||
// The ZAM instruction number where a given identifier starts its
|
// The ZAM instruction number where a given identifier starts its
|
||||||
// scope, parallel to "ids".
|
// scope, parallel to "ids".
|
||||||
std::vector<bro_uint_t> id_start;
|
std::vector<zeek_uint_t> id_start;
|
||||||
|
|
||||||
// The current end of the frame slot's scope. Gets updated as
|
// The current end of the frame slot's scope. Gets updated as
|
||||||
// new IDs are added to share the slot.
|
// new IDs are added to share the slot.
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
virtual ~ZInst() = default;
|
virtual ~ZInst() = default;
|
||||||
|
|
||||||
// Methods for printing out the instruction for debugging/maintenance.
|
// Methods for printing out the instruction for debugging/maintenance.
|
||||||
void Dump(bro_uint_t inst_num, const FrameReMap* mappings) const;
|
void Dump(zeek_uint_t inst_num, const FrameReMap* mappings) const;
|
||||||
void Dump(const std::string& id1, const std::string& id2, const std::string& id3,
|
void Dump(const std::string& id1, const std::string& id2, const std::string& id3,
|
||||||
const std::string& id4) const;
|
const std::string& id4) const;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
// by its number within a larger set. "mappings" provides the
|
// by its number within a larger set. "mappings" provides the
|
||||||
// mappings used to translate raw slots to the corresponding
|
// mappings used to translate raw slots to the corresponding
|
||||||
// script variable(s).
|
// script variable(s).
|
||||||
std::string VName(int n, bro_uint_t inst_num, const FrameReMap* mappings) const;
|
std::string VName(int n, zeek_uint_t inst_num, const FrameReMap* mappings) const;
|
||||||
|
|
||||||
// Number of slots that refer to a frame element. These always
|
// Number of slots that refer to a frame element. These always
|
||||||
// come first, if we use additional slots.
|
// come first, if we use additional slots.
|
||||||
|
|
|
@ -103,7 +103,7 @@ Value::~Value()
|
||||||
|
|
||||||
else if ( type == TYPE_TABLE )
|
else if ( type == TYPE_TABLE )
|
||||||
{
|
{
|
||||||
for ( bro_int_t i = 0; i < val.set_val.size; i++ )
|
for ( zeek_int_t i = 0; i < val.set_val.size; i++ )
|
||||||
delete val.set_val.vals[i];
|
delete val.set_val.vals[i];
|
||||||
|
|
||||||
delete[] val.set_val.vals;
|
delete[] val.set_val.vals;
|
||||||
|
@ -111,7 +111,7 @@ Value::~Value()
|
||||||
|
|
||||||
else if ( type == TYPE_VECTOR )
|
else if ( type == TYPE_VECTOR )
|
||||||
{
|
{
|
||||||
for ( bro_int_t i = 0; i < val.vector_val.size; i++ )
|
for ( zeek_int_t i = 0; i < val.vector_val.size; i++ )
|
||||||
delete val.vector_val.vals[i];
|
delete val.vector_val.vals[i];
|
||||||
|
|
||||||
delete[] val.vector_val.vals;
|
delete[] val.vector_val.vals;
|
||||||
|
@ -286,7 +286,7 @@ bool Value::Read(detail::SerializationFormat* fmt)
|
||||||
|
|
||||||
val.set_val.vals = new Value*[val.set_val.size];
|
val.set_val.vals = new Value*[val.set_val.size];
|
||||||
|
|
||||||
for ( bro_int_t i = 0; i < val.set_val.size; ++i )
|
for ( zeek_int_t i = 0; i < val.set_val.size; ++i )
|
||||||
{
|
{
|
||||||
val.set_val.vals[i] = new Value;
|
val.set_val.vals[i] = new Value;
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ bool Value::Read(detail::SerializationFormat* fmt)
|
||||||
|
|
||||||
val.vector_val.vals = new Value*[val.vector_val.size];
|
val.vector_val.vals = new Value*[val.vector_val.size];
|
||||||
|
|
||||||
for ( bro_int_t i = 0; i < val.vector_val.size; ++i )
|
for ( zeek_int_t i = 0; i < val.vector_val.size; ++i )
|
||||||
{
|
{
|
||||||
val.vector_val.vals[i] = new Value;
|
val.vector_val.vals[i] = new Value;
|
||||||
|
|
||||||
|
|
|
@ -117,13 +117,13 @@ struct Value
|
||||||
|
|
||||||
struct set_t
|
struct set_t
|
||||||
{
|
{
|
||||||
bro_int_t size;
|
zeek_int_t size;
|
||||||
Value** vals;
|
Value** vals;
|
||||||
};
|
};
|
||||||
using vec_t = set_t;
|
using vec_t = set_t;
|
||||||
struct port_t
|
struct port_t
|
||||||
{
|
{
|
||||||
bro_uint_t port;
|
zeek_uint_t port;
|
||||||
TransportProto proto;
|
TransportProto proto;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@ struct Value
|
||||||
* including only the types we can log directly. See IsCompatibleType().
|
* including only the types we can log directly. See IsCompatibleType().
|
||||||
*/
|
*/
|
||||||
union _val {
|
union _val {
|
||||||
bro_int_t int_val;
|
zeek_int_t int_val;
|
||||||
bro_uint_t uint_val;
|
zeek_uint_t uint_val;
|
||||||
port_t port_val;
|
port_t port_val;
|
||||||
double double_val;
|
double double_val;
|
||||||
set_t set_val;
|
set_t set_val;
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool Ascii::Describe(ODesc* desc, Value* val, const string& name) const
|
||||||
|
|
||||||
desc->AddEscapeSequence(separators.set_separator);
|
desc->AddEscapeSequence(separators.set_separator);
|
||||||
|
|
||||||
for ( bro_int_t j = 0; j < val->val.set_val.size; j++ )
|
for ( zeek_int_t j = 0; j < val->val.set_val.size; j++ )
|
||||||
{
|
{
|
||||||
if ( j > 0 )
|
if ( j > 0 )
|
||||||
desc->AddRaw(separators.set_separator);
|
desc->AddRaw(separators.set_separator);
|
||||||
|
@ -180,7 +180,7 @@ bool Ascii::Describe(ODesc* desc, Value* val, const string& name) const
|
||||||
|
|
||||||
desc->AddEscapeSequence(separators.set_separator);
|
desc->AddEscapeSequence(separators.set_separator);
|
||||||
|
|
||||||
for ( bro_int_t j = 0; j < val->val.vector_val.size; j++ )
|
for ( zeek_int_t j = 0; j < val->val.vector_val.size; j++ )
|
||||||
{
|
{
|
||||||
if ( j > 0 )
|
if ( j > 0 )
|
||||||
desc->AddRaw(separators.set_separator);
|
desc->AddRaw(separators.set_separator);
|
||||||
|
|
|
@ -184,7 +184,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na
|
||||||
{
|
{
|
||||||
writer.StartArray();
|
writer.StartArray();
|
||||||
|
|
||||||
for ( bro_int_t idx = 0; idx < val->val.set_val.size; idx++ )
|
for ( zeek_int_t idx = 0; idx < val->val.set_val.size; idx++ )
|
||||||
BuildJSON(writer, val->val.set_val.vals[idx]);
|
BuildJSON(writer, val->val.set_val.vals[idx]);
|
||||||
|
|
||||||
writer.EndArray();
|
writer.EndArray();
|
||||||
|
@ -195,7 +195,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na
|
||||||
{
|
{
|
||||||
writer.StartArray();
|
writer.StartArray();
|
||||||
|
|
||||||
for ( bro_int_t idx = 0; idx < val->val.vector_val.size; idx++ )
|
for ( zeek_int_t idx = 0; idx < val->val.vector_val.size; idx++ )
|
||||||
BuildJSON(writer, val->val.vector_val.vals[idx]);
|
BuildJSON(writer, val->val.vector_val.vals[idx]);
|
||||||
|
|
||||||
writer.EndArray();
|
writer.EndArray();
|
||||||
|
|
|
@ -77,8 +77,10 @@ extern "C"
|
||||||
|
|
||||||
#include "zeek/3rdparty/ghc/filesystem.hpp"
|
#include "zeek/3rdparty/ghc/filesystem.hpp"
|
||||||
|
|
||||||
using bro_int_t = int64_t;
|
using zeek_int_t = int64_t;
|
||||||
using bro_uint_t = uint64_t;
|
using zeek_uint_t = uint64_t;
|
||||||
|
using bro_int_t [[deprecated("Remove in v6.1. Use zeek_int_t.")]] = zeek_int_t;
|
||||||
|
using bro_uint_t [[deprecated("Remove in v6.1. Use zeek_uint_t.")]] = zeek_uint_t;
|
||||||
|
|
||||||
#ifndef HAVE_STRCASESTR
|
#ifndef HAVE_STRCASESTR
|
||||||
extern char* strcasestr(const char* s, const char* find);
|
extern char* strcasestr(const char* s, const char* find);
|
||||||
|
@ -509,7 +511,7 @@ inline char* safe_strncpy(char* dest, const char* src, size_t n)
|
||||||
|
|
||||||
// Memory alignment helpers.
|
// Memory alignment helpers.
|
||||||
|
|
||||||
inline bool is_power_of_2(bro_uint_t x)
|
inline bool is_power_of_2(zeek_uint_t x)
|
||||||
{
|
{
|
||||||
return ((x - 1) & x) == 0;
|
return ((x - 1) & x) == 0;
|
||||||
}
|
}
|
||||||
|
|
22
src/zeek.bif
22
src/zeek.bif
|
@ -36,9 +36,9 @@ zeek::TableType* var_sizes;
|
||||||
|
|
||||||
static zeek::iosource::PktDumper* addl_pkt_dumper = nullptr;
|
static zeek::iosource::PktDumper* addl_pkt_dumper = nullptr;
|
||||||
|
|
||||||
bro_int_t parse_int(const char*& fmt)
|
zeek_int_t parse_int(const char*& fmt)
|
||||||
{
|
{
|
||||||
bro_int_t k = 0;
|
zeek_int_t k = 0;
|
||||||
while ( isdigit(*fmt) )
|
while ( isdigit(*fmt) )
|
||||||
{
|
{
|
||||||
k = k * 10 + (*fmt - '0');
|
k = k * 10 + (*fmt - '0');
|
||||||
|
@ -201,7 +201,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, zeek::ODesc* d)
|
||||||
|
|
||||||
else if ( it == zeek::TYPE_INTERNAL_UNSIGNED )
|
else if ( it == zeek::TYPE_INTERNAL_UNSIGNED )
|
||||||
{
|
{
|
||||||
bro_uint_t u = v->CoerceToUnsigned();
|
zeek_uint_t u = v->CoerceToUnsigned();
|
||||||
|
|
||||||
if ( v->GetType()->IsNetworkOrder() )
|
if ( v->GetType()->IsNetworkOrder() )
|
||||||
{
|
{
|
||||||
|
@ -949,7 +949,7 @@ function hrw_weight%(key_digest: count, site_id: count%): count
|
||||||
## provided by the OS.
|
## provided by the OS.
|
||||||
function rand%(max: count%): count
|
function rand%(max: count%): count
|
||||||
%{
|
%{
|
||||||
auto result = bro_uint_t(double(max) * double(zeek::util::detail::random_number()) / (zeek::util::detail::max_random() + 1.0));
|
auto result = zeek_uint_t(double(max) * double(zeek::util::detail::random_number()) / (zeek::util::detail::max_random() + 1.0));
|
||||||
return zeek::val_mgr->Count(result);
|
return zeek::val_mgr->Count(result);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -2435,7 +2435,7 @@ function to_int%(str: string%): int
|
||||||
const char* s = str->CheckString();
|
const char* s = str->CheckString();
|
||||||
char* end_s;
|
char* end_s;
|
||||||
|
|
||||||
bro_int_t i = strtoll(s, &end_s, 10);
|
zeek_int_t i = strtoll(s, &end_s, 10);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Not clear we should complain. For example, is " 205 "
|
// Not clear we should complain. For example, is " 205 "
|
||||||
|
@ -2472,7 +2472,7 @@ function int_to_count%(n: int%): count
|
||||||
## by rint().
|
## by rint().
|
||||||
function double_to_int%(d: double%): int
|
function double_to_int%(d: double%): int
|
||||||
%{
|
%{
|
||||||
return zeek::val_mgr->Int(bro_int_t(rint(d)));
|
return zeek::val_mgr->Int(zeek_int_t(rint(d)));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
## Converts a :zeek:type:`double` to a :zeek:type:`int`.
|
## Converts a :zeek:type:`double` to a :zeek:type:`int`.
|
||||||
|
@ -2488,7 +2488,7 @@ function double_to_count%(d: double%): count
|
||||||
if ( d < 0.0 )
|
if ( d < 0.0 )
|
||||||
zeek::emit_builtin_error("bad conversion to count", @ARG@[0]);
|
zeek::emit_builtin_error("bad conversion to count", @ARG@[0]);
|
||||||
|
|
||||||
return zeek::val_mgr->Count(bro_uint_t(rint(d)));
|
return zeek::val_mgr->Count(zeek_uint_t(rint(d)));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
## Converts a :zeek:type:`string` to a :zeek:type:`count`.
|
## Converts a :zeek:type:`string` to a :zeek:type:`count`.
|
||||||
|
@ -3037,13 +3037,13 @@ function addr_to_ptr_name%(a: addr%): string
|
||||||
## .. zeek:see:: hexdump hexstr_to_bytestring
|
## .. zeek:see:: hexdump hexstr_to_bytestring
|
||||||
function bytestring_to_hexstr%(bytestring: string%): string
|
function bytestring_to_hexstr%(bytestring: string%): string
|
||||||
%{
|
%{
|
||||||
bro_uint_t len = bytestring->AsString()->Len();
|
zeek_uint_t len = bytestring->AsString()->Len();
|
||||||
const u_char* bytes = bytestring->AsString()->Bytes();
|
const u_char* bytes = bytestring->AsString()->Bytes();
|
||||||
auto hextr_buf = std::make_unique<char[]>((2 * len) + 1);
|
auto hextr_buf = std::make_unique<char[]>((2 * len) + 1);
|
||||||
auto hexstr = hextr_buf.get();
|
auto hexstr = hextr_buf.get();
|
||||||
|
|
||||||
hexstr[0] = 0;
|
hexstr[0] = 0;
|
||||||
for ( bro_uint_t i = 0; i < len; ++i )
|
for ( zeek_uint_t i = 0; i < len; ++i )
|
||||||
snprintf(hexstr + (2 * i), 3, "%.2hhx", bytes[i]);
|
snprintf(hexstr + (2 * i), 3, "%.2hhx", bytes[i]);
|
||||||
|
|
||||||
return zeek::make_intrusive<zeek::StringVal>(hexstr);
|
return zeek::make_intrusive<zeek::StringVal>(hexstr);
|
||||||
|
@ -3062,7 +3062,7 @@ function bytestring_to_hexstr%(bytestring: string%): string
|
||||||
## .. zeek:see:: hexdump bytestring_to_hexstr
|
## .. zeek:see:: hexdump bytestring_to_hexstr
|
||||||
function hexstr_to_bytestring%(hexstr: string%): string
|
function hexstr_to_bytestring%(hexstr: string%): string
|
||||||
%{
|
%{
|
||||||
bro_uint_t len = hexstr->AsString()->Len();
|
zeek_uint_t len = hexstr->AsString()->Len();
|
||||||
if ( len % 2 != 0 )
|
if ( len % 2 != 0 )
|
||||||
{
|
{
|
||||||
zeek::reporter->Error("Hex string '%s' has invalid length (not divisible by 2)", hexstr->CheckString());
|
zeek::reporter->Error("Hex string '%s' has invalid length (not divisible by 2)", hexstr->CheckString());
|
||||||
|
@ -3075,7 +3075,7 @@ function hexstr_to_bytestring%(hexstr: string%): string
|
||||||
auto bytestring = bytestring_buf.get();
|
auto bytestring = bytestring_buf.get();
|
||||||
memset(bytestring, 0, outlen);
|
memset(bytestring, 0, outlen);
|
||||||
|
|
||||||
for ( bro_uint_t i = 0; i < len/2; ++i )
|
for ( zeek_uint_t i = 0; i < len/2; ++i )
|
||||||
{
|
{
|
||||||
int res = sscanf(bytes + (2*i), "%2hhx", &bytestring[i]);
|
int res = sscanf(bytes + (2*i), "%2hhx", &bytestring[i]);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
# @TEST-DOC: Smoke test for a custom Spicy analyzer hooked into Zeek with JIT via Zeek itself.
|
# @TEST-DOC: Smoke test for a custom Spicy analyzer hooked into Zeek with JIT via Zeek itself.
|
||||||
#
|
#
|
||||||
# @TEST-REQUIRES: $SCRIPTS/have-spicy
|
# @TEST-REQUIRES: $SCRIPTS/have-spicy
|
||||||
# @TEST-EXEC: zeek -NN test.zeek test.spicy test.evt | grep -q ANALYZER_SPICY_TEST
|
|
||||||
# @TEST-EXEC: HILTI_DEBUG=compiler zeek -r ${TRACES}/http/post.trace test.spicy test.evt test.zeek "Spicy::enable_print = T;" >>output 2>&1
|
# Use a script here to prevent spicy from outputting warnings during compilation. If the build is
|
||||||
|
# failing, the script can be modified to not redirect the output.
|
||||||
|
# @TEST-EXEC: HILTI_CXX=$SCRIPTS/hilti-ignore-cxx-errors zeek -NN test.zeek test.spicy test.evt | grep -q ANALYZER_SPICY_TEST
|
||||||
|
# @TEST-EXEC: HILTI_CXX=$SCRIPTS/hilti-ignore-cxx-errors zeek -r ${TRACES}/http/post.trace test.spicy test.evt test.zeek "Spicy::enable_print = T;" >>output 2>&1
|
||||||
# @TEST-EXEC: btest-diff output
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
# @TEST-START-FILE test.spicy
|
# @TEST-START-FILE test.spicy
|
||||||
|
|
4
testing/scripts/hilti-ignore-cxx-errors
Executable file
4
testing/scripts/hilti-ignore-cxx-errors
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
COMPILER=$(awk -F= '/CMAKE_CXX_COMPILER:/ {print $2}' ${BUILD}/CMakeCache.txt)
|
||||||
|
${COMPILER} "$@" >/dev/null 2>&1
|
Loading…
Add table
Add a link
Reference in a new issue