Merge branch 'master' into topic/icmp6

Conflicts:
	policy/bro.init
	policy/icmp.bro
	src/Analyzer.cc
	src/AnalyzerTags.h
	src/DPM.cc
	src/ICMP.h
	src/Sessions.cc
	src/event.bif
	src/net_util.cc
This commit is contained in:
Daniel Thayer 2012-02-15 15:58:53 -06:00
commit ef31099fd7
1250 changed files with 56739 additions and 54904 deletions

View file

@ -1,5 +1,3 @@
// $Id: Val.h 6916 2009-09-24 20:48:36Z vern $
//
// See the file "COPYING" in the main distribution directory for copyright.
#ifndef val_h
@ -30,7 +28,6 @@ class SerialInfo;
class PortVal;
class AddrVal;
class NetVal;
class SubNetVal;
class IntervalVal;
@ -39,6 +36,7 @@ class TableVal;
class RecordVal;
class ListVal;
class StringVal;
class EnumVal;
class MutableVal;
class StateAccess;
@ -87,7 +85,7 @@ public:
#endif
}
Val(int i, TypeTag t)
Val(int32 i, TypeTag t)
{
val.int_val = bro_int_t(i);
type = base_type(t);
@ -97,27 +95,7 @@ public:
#endif
}
Val(long i, TypeTag t)
{
val.int_val = bro_int_t(i);
type = base_type(t);
attribs = 0;
#ifdef DEBUG
bound_id = 0;
#endif
}
Val(unsigned int u, TypeTag t)
{
val.uint_val = bro_uint_t(u);
type = base_type(t);
attribs = 0;
#ifdef DEBUG
bound_id = 0;
#endif
}
Val(unsigned long u, TypeTag t)
Val(uint32 u, TypeTag t)
{
val.uint_val = bro_uint_t(u);
type = base_type(t);
@ -163,6 +141,15 @@ public:
// class has ref'd it.
Val(BroFile* f);
Val(BroType* t, bool type_type) // Extra arg to differentiate from protected version.
{
type = new TypeType(t->Ref());
attribs = 0;
#ifdef DEBUG
bound_id = 0;
#endif
}
Val()
{
val.int_val = 0;
@ -178,13 +165,6 @@ public:
Val* Ref() { ::Ref(this); return this; }
virtual Val* Clone() const;
RecordVal* GetAttribs(bool instantiate);
void SetAttribs(RecordVal* arg_attribs)
{
Unref((Val*) attribs);
attribs = arg_attribs;
}
int IsZero() const;
int IsOne() const;
@ -252,10 +232,16 @@ public:
return &val.subnet_val;
}
BroType* AsType() const
{
CHECK_TAG(type->Tag(), TYPE_TYPE, "Val::Type", type_name)
return type;
}
// ... in network byte order
const addr_type AsAddr() const
{
if ( type->Tag() != TYPE_ADDR && type->Tag() != TYPE_NET )
if ( type->Tag() != TYPE_ADDR )
BadTag("Val::AsAddr", type_name(type->Tag()));
return val.addr_val;
}
@ -295,13 +281,13 @@ public:
CONVERTER(TYPE_PATTERN, PatternVal*, AsPatternVal)
CONVERTER(TYPE_PORT, PortVal*, AsPortVal)
CONVERTER(TYPE_NET, NetVal*, AsNetVal)
CONVERTER(TYPE_SUBNET, SubNetVal*, AsSubNetVal)
CONVERTER(TYPE_TABLE, TableVal*, AsTableVal)
CONVERTER(TYPE_RECORD, RecordVal*, AsRecordVal)
CONVERTER(TYPE_LIST, ListVal*, AsListVal)
CONVERTER(TYPE_STRING, StringVal*, AsStringVal)
CONVERTER(TYPE_VECTOR, VectorVal*, AsVectorVal)
CONVERTER(TYPE_ENUM, EnumVal*, AsEnumVal)
#define CONST_CONVERTER(tag, ctype, name) \
const ctype name() const \
@ -312,7 +298,6 @@ public:
CONST_CONVERTER(TYPE_PATTERN, PatternVal*, AsPatternVal)
CONST_CONVERTER(TYPE_PORT, PortVal*, AsPortVal)
CONST_CONVERTER(TYPE_NET, NetVal*, AsNetVal)
CONST_CONVERTER(TYPE_SUBNET, SubNetVal*, AsSubNetVal)
CONST_CONVERTER(TYPE_TABLE, TableVal*, AsTableVal)
CONST_CONVERTER(TYPE_RECORD, RecordVal*, AsRecordVal)
@ -340,6 +325,7 @@ public:
}
void Describe(ODesc* d) const;
virtual void DescribeReST(ODesc* d) const;
bool Serialize(SerialInfo* info) const;
static Val* Unserialize(UnserialInfo* info, TypeTag type = TYPE_ANY)
@ -374,6 +360,7 @@ protected:
}
virtual void ValDescribe(ODesc* d) const;
virtual void ValDescribeReST(ODesc* d) const;
Val(TypeTag t)
{
@ -585,23 +572,6 @@ protected:
DECLARE_SERIAL(AddrVal);
};
class NetVal : public AddrVal {
public:
NetVal(const char* text);
NetVal(uint32 addr);
NetVal(const uint32* addr);
Val* SizeVal() const;
protected:
friend class Val;
NetVal() {}
void ValDescribe(ODesc* d) const;
DECLARE_SERIAL(NetVal);
};
class SubNetVal : public Val {
public:
SubNetVal(const char* text);
@ -901,7 +871,7 @@ protected:
DECLARE_SERIAL(TableVal);
const TableType* table_type;
TableType* table_type;
CompositeHash* table_hash;
Attributes* attrs;
double expire_time;
@ -921,7 +891,8 @@ public:
{ return new Val(record_type->NumFields(), TYPE_COUNT); }
void Assign(int field, Val* new_val, Opcode op = OP_ASSIGN);
Val* Lookup(int field) const;
Val* Lookup(int field) const; // Does not Ref() value.
Val* LookupWithDefault(int field) const; // Does Ref() value.
void Describe(ODesc* d) const;
@ -930,7 +901,22 @@ public:
void SetOrigin(BroObj* o) { origin = o; }
BroObj* GetOrigin() const { return origin; }
// Returns a new value representing the value coerced to the given
// type. If coercion is not possible, returns 0. The non-const
// version may return the current value ref'ed if its type matches
// directly.
//
// *aggr* is optional; if non-zero, we add to it. See
// Expr::InitVal(). We leave it out in the non-const version to make
// the choice unambigious.
//
// The *allow_orphaning* parameter allows for a record to be demoted
// down to a record type that contains less fields.
RecordVal* CoerceTo(const RecordType* other, Val* aggr, bool allow_orphaning = false) const;
RecordVal* CoerceTo(RecordType* other, bool allow_orphaning = false);
unsigned int MemoryAllocation() const;
void DescribeReST(ODesc* d) const;
protected:
friend class Val;
@ -966,9 +952,6 @@ protected:
};
// The minimum index for vectors (0 or 1).
const int VECTOR_MIN = 1;
class VectorVal : public MutableVal {
public:
VectorVal(VectorType* t);