mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18: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
69
src/IP.h
69
src/IP.h
|
@ -4,63 +4,33 @@
|
|||
#define ip_h
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "IPAddr.h"
|
||||
#include <net_util.h>
|
||||
|
||||
class IP_Hdr {
|
||||
public:
|
||||
IP_Hdr(struct ip* arg_ip4)
|
||||
: ip4(arg_ip4), ip6(0),
|
||||
src_addr(arg_ip4->ip_src), dst_addr(arg_ip4->ip_dst), del(1)
|
||||
{
|
||||
ip4 = arg_ip4;
|
||||
ip6 = 0;
|
||||
del = 1;
|
||||
|
||||
#ifdef BROv6
|
||||
src_addr[0] = src_addr[1] = src_addr[2] = 0;
|
||||
dst_addr[0] = dst_addr[1] = dst_addr[2] = 0;
|
||||
|
||||
src_addr[3] = ip4->ip_src.s_addr;
|
||||
dst_addr[3] = ip4->ip_dst.s_addr;
|
||||
#endif
|
||||
}
|
||||
|
||||
IP_Hdr(const struct ip* arg_ip4)
|
||||
: ip4(arg_ip4), ip6(0),
|
||||
src_addr(arg_ip4->ip_src), dst_addr(arg_ip4->ip_dst), del(0)
|
||||
{
|
||||
ip4 = arg_ip4;
|
||||
ip6 = 0;
|
||||
del = 0;
|
||||
|
||||
#ifdef BROv6
|
||||
src_addr[0] = src_addr[1] = src_addr[2] = 0;
|
||||
dst_addr[0] = dst_addr[1] = dst_addr[2] = 0;
|
||||
|
||||
src_addr[3] = ip4->ip_src.s_addr;
|
||||
dst_addr[3] = ip4->ip_dst.s_addr;
|
||||
#endif
|
||||
}
|
||||
|
||||
IP_Hdr(struct ip6_hdr* arg_ip6)
|
||||
: ip4(0), ip6(arg_ip6),
|
||||
src_addr(arg_ip6->ip6_src), dst_addr(arg_ip6->ip6_dst), del(1)
|
||||
{
|
||||
ip4 = 0;
|
||||
ip6 = arg_ip6;
|
||||
del = 1;
|
||||
|
||||
#ifdef BROv6
|
||||
memcpy(src_addr, ip6->ip6_src.s6_addr, 16);
|
||||
memcpy(dst_addr, ip6->ip6_dst.s6_addr, 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
IP_Hdr(const struct ip6_hdr* arg_ip6)
|
||||
: ip4(0), ip6(arg_ip6),
|
||||
src_addr(arg_ip6->ip6_src), dst_addr(arg_ip6->ip6_dst), del(0)
|
||||
{
|
||||
ip4 = 0;
|
||||
ip6 = arg_ip6;
|
||||
del = 0;
|
||||
|
||||
#ifdef BROv6
|
||||
memcpy(src_addr, ip6->ip6_src.s6_addr, 16);
|
||||
memcpy(dst_addr, ip6->ip6_dst.s6_addr, 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
~IP_Hdr()
|
||||
|
@ -77,19 +47,10 @@ public:
|
|||
const struct ip* IP4_Hdr() const { return ip4; }
|
||||
const struct ip6_hdr* IP6_Hdr() const { return ip6; }
|
||||
|
||||
#ifdef BROv6
|
||||
const uint32* SrcAddr() const { return src_addr; }
|
||||
const uint32* DstAddr() const { return dst_addr; }
|
||||
#else
|
||||
const uint32* SrcAddr() const
|
||||
{ return ip4 ? &(ip4->ip_src.s_addr) : 0; }
|
||||
const uint32* DstAddr() const
|
||||
{ return ip4 ? &(ip4->ip_dst.s_addr) : 0; }
|
||||
#endif
|
||||
|
||||
uint32 SrcAddr4() const { return ip4->ip_src.s_addr; }
|
||||
uint32 DstAddr4() const { return ip4->ip_dst.s_addr; }
|
||||
const IPAddr& SrcAddr() const { return src_addr; }
|
||||
const IPAddr& DstAddr() const { return dst_addr; }
|
||||
|
||||
//TODO: needs adapting/replacement for IPv6 support
|
||||
uint16 ID4() const { return ip4 ? ip4->ip_id : 0; }
|
||||
|
||||
const u_char* Payload() const
|
||||
|
@ -131,10 +92,8 @@ public:
|
|||
private:
|
||||
const struct ip* ip4;
|
||||
const struct ip6_hdr* ip6;
|
||||
#ifdef BROv6
|
||||
uint32 src_addr[NUM_ADDR_WORDS];
|
||||
uint32 dst_addr[NUM_ADDR_WORDS];
|
||||
#endif
|
||||
IPAddr src_addr;
|
||||
IPAddr dst_addr;
|
||||
int del;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue