mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Remove --enable-brov6 flag, IPv6 now supported by default.
Internally, all BROv6 preprocessor switches were removed and addr/subnet representations wrapped in the new IPAddr/IPPrefix classes. Some script-layer changes of note: - dns_AAAA_reply event signature changed: the string representation of an IPv6 addr is easily derived from the addr value, it doesn't need to be another parameter. This event also now generated directly by the DNS analyzer instead of being "faked" into a dns_A_reply event. - removed addr_to_count BIF. It used to return the host-order count representation of IPv4 addresses only. To make it more generic, we might later add a BIF to return a vector of counts in order to support IPv6. - changed the result of enclosing addr variables in vertical pipes (e.g. |my_addr|) to return the bit-width of the address type which is 128 for IPv6 and 32 for IPv4. It used to function the same way as addr_to_count mentioned above. - remove bro_has_ipv6 BIF
This commit is contained in:
parent
2c439fd0a2
commit
b3f1f45082
85 changed files with 1428 additions and 1684 deletions
52
src/Val.h
52
src/Val.h
|
@ -18,6 +18,7 @@
|
|||
#include "ID.h"
|
||||
#include "Scope.h"
|
||||
#include "StateAccess.h"
|
||||
#include "IPAddr.h"
|
||||
|
||||
class Val;
|
||||
class Func;
|
||||
|
@ -53,11 +54,11 @@ typedef union {
|
|||
// Used for count, counter, port, subnet.
|
||||
bro_uint_t uint_val;
|
||||
|
||||
// Used for addr, net
|
||||
addr_type addr_val;
|
||||
// Used for addr
|
||||
IPAddr* addr_val;
|
||||
|
||||
// Used for subnet
|
||||
subnet_type subnet_val;
|
||||
IPPrefix* subnet_val;
|
||||
|
||||
// Used for double, time, interval.
|
||||
double double_val;
|
||||
|
@ -226,10 +227,10 @@ public:
|
|||
CONST_ACCESSOR(TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
|
||||
CONST_ACCESSOR(TYPE_VECTOR, vector<Val*>*, vector_val, AsVector)
|
||||
|
||||
const subnet_type* AsSubNet() const
|
||||
const IPPrefix* AsSubNet() const
|
||||
{
|
||||
CHECK_TAG(type->Tag(), TYPE_SUBNET, "Val::SubNet", type_name)
|
||||
return &val.subnet_val;
|
||||
return val.subnet_val;
|
||||
}
|
||||
|
||||
BroType* AsType() const
|
||||
|
@ -238,8 +239,7 @@ public:
|
|||
return type;
|
||||
}
|
||||
|
||||
// ... in network byte order
|
||||
const addr_type AsAddr() const
|
||||
const IPAddr* AsAddr() const
|
||||
{
|
||||
if ( type->Tag() != TYPE_ADDR )
|
||||
BadTag("Val::AsAddr", type_name(type->Tag()));
|
||||
|
@ -261,10 +261,17 @@ public:
|
|||
ACCESSOR(TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
|
||||
ACCESSOR(TYPE_VECTOR, vector<Val*>*, vector_val, AsVector)
|
||||
|
||||
subnet_type* AsSubNet()
|
||||
IPPrefix* AsSubNet()
|
||||
{
|
||||
CHECK_TAG(type->Tag(), TYPE_SUBNET, "Val::SubNet", type_name)
|
||||
return &val.subnet_val;
|
||||
return val.subnet_val;
|
||||
}
|
||||
|
||||
IPAddr* AsAddr()
|
||||
{
|
||||
if ( type->Tag() != TYPE_ADDR )
|
||||
BadTag("Val::AsAddr", type_name(type->Tag()));
|
||||
return val.addr_val;
|
||||
}
|
||||
|
||||
// Gives fast access to the bits of something that is one of
|
||||
|
@ -282,6 +289,7 @@ public:
|
|||
CONVERTER(TYPE_PATTERN, PatternVal*, AsPatternVal)
|
||||
CONVERTER(TYPE_PORT, PortVal*, AsPortVal)
|
||||
CONVERTER(TYPE_SUBNET, SubNetVal*, AsSubNetVal)
|
||||
CONVERTER(TYPE_ADDR, AddrVal*, AsAddrVal)
|
||||
CONVERTER(TYPE_TABLE, TableVal*, AsTableVal)
|
||||
CONVERTER(TYPE_RECORD, RecordVal*, AsRecordVal)
|
||||
CONVERTER(TYPE_LIST, ListVal*, AsListVal)
|
||||
|
@ -299,6 +307,7 @@ public:
|
|||
CONST_CONVERTER(TYPE_PATTERN, PatternVal*, AsPatternVal)
|
||||
CONST_CONVERTER(TYPE_PORT, PortVal*, AsPortVal)
|
||||
CONST_CONVERTER(TYPE_SUBNET, SubNetVal*, AsSubNetVal)
|
||||
CONST_CONVERTER(TYPE_ADDR, AddrVal*, AsAddrVal)
|
||||
CONST_CONVERTER(TYPE_TABLE, TableVal*, AsTableVal)
|
||||
CONST_CONVERTER(TYPE_RECORD, RecordVal*, AsRecordVal)
|
||||
CONST_CONVERTER(TYPE_LIST, ListVal*, AsListVal)
|
||||
|
@ -555,6 +564,7 @@ public:
|
|||
// Constructor for address already in network order.
|
||||
AddrVal(uint32 addr);
|
||||
AddrVal(const uint32* addr);
|
||||
AddrVal(const IPAddr& addr);
|
||||
|
||||
unsigned int MemoryAllocation() const;
|
||||
|
||||
|
@ -564,9 +574,6 @@ protected:
|
|||
AddrVal(TypeTag t) : Val(t) { }
|
||||
AddrVal(BroType* t) : Val(t) { }
|
||||
|
||||
void Init(uint32 addr);
|
||||
void Init(const uint32* addr);
|
||||
|
||||
DECLARE_SERIAL(AddrVal);
|
||||
};
|
||||
|
||||
|
@ -574,30 +581,27 @@ class SubNetVal : public Val {
|
|||
public:
|
||||
SubNetVal(const char* text);
|
||||
SubNetVal(const char* text, int width);
|
||||
SubNetVal(uint32 addr, int width); // for address already massaged
|
||||
SubNetVal(const uint32* addr, int width); // ditto
|
||||
SubNetVal(uint32 addr, int width);
|
||||
SubNetVal(const uint32* addr, int width);
|
||||
SubNetVal(const IPAddr& addr, int width);
|
||||
~SubNetVal();
|
||||
|
||||
Val* SizeVal() const;
|
||||
|
||||
int Width() const { return val.subnet_val.width; }
|
||||
addr_type Mask() const; // returns host byte order
|
||||
const IPAddr& Prefix() const { return val.subnet_val->Prefix(); }
|
||||
int Width() const { return val.subnet_val->Length(); }
|
||||
IPAddr Mask() const;
|
||||
|
||||
bool Contains(const uint32 addr) const;
|
||||
bool Contains(const uint32* addr) const;
|
||||
bool Contains(const IPAddr& addr) const;
|
||||
|
||||
unsigned int MemoryAllocation() const
|
||||
{
|
||||
return Val::MemoryAllocation() + padded_sizeof(*this) - padded_sizeof(Val);
|
||||
}
|
||||
unsigned int MemoryAllocation() const;
|
||||
|
||||
protected:
|
||||
friend class Val;
|
||||
SubNetVal() {}
|
||||
|
||||
void Init(const char* text, int width);
|
||||
void Init(uint32 addr, int width);
|
||||
void Init(const uint32 *addr, int width);
|
||||
|
||||
void ValDescribe(ODesc* d) const;
|
||||
|
||||
DECLARE_SERIAL(SubNetVal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue