mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +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
|
@ -21,6 +21,7 @@
|
|||
#include <netinet/ip_icmp.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "IPAddr.h"
|
||||
|
||||
#ifdef HAVE_NETINET_IP6_H
|
||||
#include <netinet/ip6.h>
|
||||
|
@ -32,30 +33,6 @@ struct ip6_hdr {
|
|||
};
|
||||
#endif
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifdef BROv6
|
||||
typedef uint32* addr_type; // a pointer to 4 uint32's
|
||||
typedef const uint32* const_addr_type;
|
||||
#define NUM_ADDR_WORDS 4
|
||||
|
||||
typedef struct {
|
||||
uint32 net[4];
|
||||
uint32 width;
|
||||
} subnet_type;
|
||||
|
||||
#else
|
||||
typedef uint32 addr_type;
|
||||
typedef const uint32 const_addr_type;
|
||||
#define NUM_ADDR_WORDS 1
|
||||
|
||||
typedef struct {
|
||||
uint32 net;
|
||||
uint32 width;
|
||||
} subnet_type;
|
||||
|
||||
#endif
|
||||
|
||||
// For Solaris.
|
||||
#if !defined(TCPOPT_WINDOW) && defined(TCPOPT_WSCALE)
|
||||
#define TCPOPT_WINDOW TCPOPT_WSCALE
|
||||
|
@ -86,78 +63,18 @@ extern int ones_complement_checksum(const void* p, int b, uint32 sum);
|
|||
|
||||
extern int tcp_checksum(const struct ip* ip, const struct tcphdr* tp, int len);
|
||||
extern int udp_checksum(const struct ip* ip, const struct udphdr* up, int len);
|
||||
#ifdef BROv6
|
||||
extern int udp6_checksum(const struct ip6_hdr* ip, const struct udphdr* up,
|
||||
int len);
|
||||
#endif
|
||||
extern int icmp_checksum(const struct icmp* icmpp, int len);
|
||||
|
||||
// Given an address in host order, returns its "classical network prefix",
|
||||
// also in host order.
|
||||
extern uint32 addr_to_net(uint32 addr);
|
||||
// Returns 'A', 'B', 'C' or 'D'
|
||||
extern char addr_to_class(uint32 addr);
|
||||
|
||||
// Returns a pointer to static storage giving the ASCII dotted representation
|
||||
// of the given address, which should be passed in network order.
|
||||
extern const char* dotted_addr(uint32 addr, int alternative=0);
|
||||
extern const char* dotted_addr(const uint32* addr, int alternative=0);
|
||||
|
||||
// Same, but for the network prefix.
|
||||
extern const char* dotted_net(uint32 addr);
|
||||
extern const char* dotted_net6(const uint32* addr);
|
||||
|
||||
// Given an ASCII dotted representation, returns the corresponding address
|
||||
// in network order.
|
||||
extern uint32 dotted_to_addr(const char* addr_text);
|
||||
extern uint32* dotted_to_addr6(const char* addr_text);
|
||||
|
||||
extern int is_v4_addr(const uint32 addr[4]);
|
||||
extern uint32 to_v4_addr(const uint32* addr);
|
||||
|
||||
extern uint32 mask_addr(uint32 a, uint32 top_bits_to_keep);
|
||||
extern const uint32* mask_addr(const uint32* a, uint32 top_bits_to_keep);
|
||||
|
||||
extern const char* fmt_conn_id(const IPAddr& src_addr, uint32 src_port,
|
||||
const IPAddr& dst_addr, uint32 dst_port);
|
||||
extern const char* fmt_conn_id(const uint32* src_addr, uint32 src_port,
|
||||
const uint32* dst_addr, uint32 dst_port);
|
||||
|
||||
inline void copy_addr(const uint32* src_a, uint32* dst_a)
|
||||
{
|
||||
#ifdef BROv6
|
||||
dst_a[0] = src_a[0];
|
||||
dst_a[1] = src_a[1];
|
||||
dst_a[2] = src_a[2];
|
||||
dst_a[3] = src_a[3];
|
||||
#else
|
||||
dst_a[0] = src_a[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int addr_eq(const uint32* a1, const uint32* a2)
|
||||
{
|
||||
#ifdef BROv6
|
||||
return a1[0] == a2[0] &&
|
||||
a1[1] == a2[1] &&
|
||||
a1[2] == a2[2] &&
|
||||
a1[3] == a2[3];
|
||||
#else
|
||||
return a1[0] == a2[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int subnet_eq(const subnet_type* s1, const subnet_type* s2)
|
||||
{
|
||||
#ifdef BROv6
|
||||
return s1->net[0] == s2->net[0] &&
|
||||
s1->net[1] == s2->net[1] &&
|
||||
s1->net[2] == s2->net[2] &&
|
||||
s1->net[3] == s2->net[3] &&
|
||||
s1->width == s2->width;
|
||||
#else
|
||||
return s1->net == s2->net && s1->width == s2->width;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Read 4 bytes from data and return in network order.
|
||||
extern uint32 extract_uint32(const u_char* data);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue