mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
Do not allocate one OpaqueType per OpaqueVal.
Instead, we now allocate type information globally in NetVar.cc. Addresses #986.
This commit is contained in:
parent
e78c20c0f8
commit
9ac00f8c79
6 changed files with 29 additions and 9 deletions
|
@ -149,6 +149,11 @@ RecordType* OS_version;
|
||||||
EnumType* OS_version_inference;
|
EnumType* OS_version_inference;
|
||||||
TableVal* generate_OS_version_event;
|
TableVal* generate_OS_version_event;
|
||||||
|
|
||||||
|
OpaqueType* md5_type;
|
||||||
|
OpaqueType* sha1_type;
|
||||||
|
OpaqueType* sha256_type;
|
||||||
|
OpaqueType* entropy_type;
|
||||||
|
|
||||||
double table_expire_interval;
|
double table_expire_interval;
|
||||||
double table_expire_delay;
|
double table_expire_delay;
|
||||||
int table_incremental_step;
|
int table_incremental_step;
|
||||||
|
@ -253,6 +258,11 @@ void init_event_handlers()
|
||||||
|
|
||||||
void init_general_global_var()
|
void init_general_global_var()
|
||||||
{
|
{
|
||||||
|
md5_type = new OpaqueType("md5");
|
||||||
|
sha1_type = new OpaqueType("sha1");
|
||||||
|
sha256_type = new OpaqueType("sha256");
|
||||||
|
entropy_type = new OpaqueType("entropy");
|
||||||
|
|
||||||
table_expire_interval = opt_internal_double("table_expire_interval");
|
table_expire_interval = opt_internal_double("table_expire_interval");
|
||||||
table_expire_delay = opt_internal_double("table_expire_delay");
|
table_expire_delay = opt_internal_double("table_expire_delay");
|
||||||
table_incremental_step = opt_internal_int("table_incremental_step");
|
table_incremental_step = opt_internal_int("table_incremental_step");
|
||||||
|
|
|
@ -152,6 +152,12 @@ extern RecordType* OS_version;
|
||||||
extern EnumType* OS_version_inference;
|
extern EnumType* OS_version_inference;
|
||||||
extern TableVal* generate_OS_version_event;
|
extern TableVal* generate_OS_version_event;
|
||||||
|
|
||||||
|
class OpaqueType;
|
||||||
|
extern OpaqueType* md5_type;
|
||||||
|
extern OpaqueType* sha1_type;
|
||||||
|
extern OpaqueType* sha256_type;
|
||||||
|
extern OpaqueType* entropy_type;
|
||||||
|
|
||||||
extern double table_expire_interval;
|
extern double table_expire_interval;
|
||||||
extern double table_expire_delay;
|
extern double table_expire_delay;
|
||||||
extern int table_incremental_step;
|
extern int table_incremental_step;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "OpaqueVal.h"
|
#include "OpaqueVal.h"
|
||||||
|
#include "NetVar.h"
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
#include "Serializer.h"
|
#include "Serializer.h"
|
||||||
|
|
||||||
|
@ -72,6 +73,8 @@ bool HashVal::DoUnserialize(UnserialInfo* info)
|
||||||
return UNSERIALIZE(&valid);
|
return UNSERIALIZE(&valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MD5Val::MD5Val() : HashVal(md5_type) { }
|
||||||
|
|
||||||
void MD5Val::digest(val_list& vlist, u_char result[MD5_DIGEST_LENGTH])
|
void MD5Val::digest(val_list& vlist, u_char result[MD5_DIGEST_LENGTH])
|
||||||
{
|
{
|
||||||
MD5_CTX h;
|
MD5_CTX h;
|
||||||
|
@ -189,6 +192,8 @@ bool MD5Val::DoUnserialize(UnserialInfo* info)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHA1Val::SHA1Val() : HashVal(sha1_type) { }
|
||||||
|
|
||||||
void SHA1Val::digest(val_list& vlist, u_char result[SHA_DIGEST_LENGTH])
|
void SHA1Val::digest(val_list& vlist, u_char result[SHA_DIGEST_LENGTH])
|
||||||
{
|
{
|
||||||
SHA_CTX h;
|
SHA_CTX h;
|
||||||
|
@ -297,6 +302,8 @@ bool SHA1Val::DoUnserialize(UnserialInfo* info)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHA256Val::SHA256Val() : HashVal(sha256_type) { }
|
||||||
|
|
||||||
void SHA256Val::digest(val_list& vlist, u_char result[SHA256_DIGEST_LENGTH])
|
void SHA256Val::digest(val_list& vlist, u_char result[SHA256_DIGEST_LENGTH])
|
||||||
{
|
{
|
||||||
SHA256_CTX h;
|
SHA256_CTX h;
|
||||||
|
@ -410,6 +417,7 @@ bool SHA256Val::DoUnserialize(UnserialInfo* info)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntropyVal::EntropyVal() : OpaqueVal(entropy_type) { }
|
||||||
|
|
||||||
bool EntropyVal::Feed(const void* data, size_t size)
|
bool EntropyVal::Feed(const void* data, size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
u_char key[MD5_DIGEST_LENGTH],
|
u_char key[MD5_DIGEST_LENGTH],
|
||||||
u_char result[MD5_DIGEST_LENGTH]);
|
u_char result[MD5_DIGEST_LENGTH]);
|
||||||
|
|
||||||
MD5Val() : HashVal(new OpaqueType("md5")) { }
|
MD5Val();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Val;
|
friend class Val;
|
||||||
|
@ -55,7 +55,7 @@ class SHA1Val : public HashVal {
|
||||||
public:
|
public:
|
||||||
static void digest(val_list& vlist, u_char result[SHA_DIGEST_LENGTH]);
|
static void digest(val_list& vlist, u_char result[SHA_DIGEST_LENGTH]);
|
||||||
|
|
||||||
SHA1Val() : HashVal(new OpaqueType("sha1")) { }
|
SHA1Val();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Val;
|
friend class Val;
|
||||||
|
@ -74,7 +74,7 @@ class SHA256Val : public HashVal {
|
||||||
public:
|
public:
|
||||||
static void digest(val_list& vlist, u_char result[SHA256_DIGEST_LENGTH]);
|
static void digest(val_list& vlist, u_char result[SHA256_DIGEST_LENGTH]);
|
||||||
|
|
||||||
SHA256Val() : HashVal(new OpaqueType("sha256")) { }
|
SHA256Val();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Val;
|
friend class Val;
|
||||||
|
@ -91,7 +91,7 @@ private:
|
||||||
|
|
||||||
class EntropyVal : public OpaqueVal {
|
class EntropyVal : public OpaqueVal {
|
||||||
public:
|
public:
|
||||||
EntropyVal() : OpaqueVal(new OpaqueType("entropy")) { }
|
EntropyVal();
|
||||||
|
|
||||||
bool Feed(const void* data, size_t size);
|
bool Feed(const void* data, size_t size);
|
||||||
bool Get(double *r_ent, double *r_chisq, double *r_mean,
|
bool Get(double *r_ent, double *r_chisq, double *r_mean,
|
||||||
|
|
|
@ -3125,13 +3125,12 @@ void VectorVal::ValDescribe(ODesc* d) const
|
||||||
d->Add("]");
|
d->Add("]");
|
||||||
}
|
}
|
||||||
|
|
||||||
OpaqueVal::OpaqueVal(OpaqueType* t) : Val(t), type(t)
|
OpaqueVal::OpaqueVal(OpaqueType* t) : Val(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
OpaqueVal::~OpaqueVal()
|
OpaqueVal::~OpaqueVal()
|
||||||
{
|
{
|
||||||
Unref(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_SERIAL(OpaqueVal, SER_OPAQUE_VAL);
|
IMPLEMENT_SERIAL(OpaqueVal, SER_OPAQUE_VAL);
|
||||||
|
|
|
@ -1024,9 +1024,6 @@ protected:
|
||||||
OpaqueVal() { }
|
OpaqueVal() { }
|
||||||
|
|
||||||
DECLARE_SERIAL(OpaqueVal);
|
DECLARE_SERIAL(OpaqueVal);
|
||||||
|
|
||||||
private:
|
|
||||||
OpaqueType* type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Checks the given value for consistency with the given type. If an
|
// Checks the given value for consistency with the given type. If an
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue