diff --git a/CHANGES b/CHANGES index 647a6ec3de..2488227d58 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,9 @@ +2.3-427 | 2015-02-20 13:49:33 -0800 + + * Removing dependency on PCAP_NETMASK_UNKNOWN to compile with + libpcap < 1.1.1. (Robin Sommer) + 2.3-426 | 2015-02-20 12:45:51 -0800 * Add 'while' statement to Bro language. Really. (Jon Siwek) diff --git a/VERSION b/VERSION index 07a0bd75a8..ceb17112a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3-426 +2.3-427 diff --git a/src/iosource/PktSrc.cc b/src/iosource/PktSrc.cc index 527dadd393..5612c32e51 100644 --- a/src/iosource/PktSrc.cc +++ b/src/iosource/PktSrc.cc @@ -13,6 +13,15 @@ using namespace iosource; +PktSrc::Properties::Properties() + { + selectable_fd = -1; + link_type = -1; + hdr_size = -1; + netmask = NETMASK_UNKNOWN; + is_live = false; + } + PktSrc::PktSrc() { have_packet = false; @@ -50,7 +59,7 @@ int PktSrc::LinkType() const uint32 PktSrc::Netmask() const { - return IsOpen() ? props.netmask : PCAP_NETMASK_UNKNOWN; + return IsOpen() ? props.netmask : NETMASK_UNKNOWN; } bool PktSrc::IsError() const diff --git a/src/iosource/PktSrc.h b/src/iosource/PktSrc.h index 7137798129..378ac3f5ee 100644 --- a/src/iosource/PktSrc.h +++ b/src/iosource/PktSrc.h @@ -16,6 +16,8 @@ namespace iosource { */ class PktSrc : public IOSource { public: + static const int NETMASK_UNKNOWN = 0xffffffff; + /** * Struct for returning statistics on a packet source. */ @@ -67,7 +69,7 @@ public: /** * Returns the netmask associated with the source, or \c - * PCAP_NETMASK_UNKNOWN if unknown. + * NETMASK_UNKNOWN if unknown. */ uint32 Netmask() const; @@ -253,8 +255,8 @@ protected: int hdr_size; /** - * The netmask associated with the source, or \c - * PCAP_NETMASK_UNKNOWN if unknown. + * Returns the netmask associated with the source, or \c + * NETMASK_UNKNOWN if unknown. */ uint32 netmask; @@ -264,14 +266,7 @@ protected: */ bool is_live; - Properties() - { - selectable_fd = -1; - link_type = -1; - hdr_size = -1; - netmask = PCAP_NETMASK_UNKNOWN; - is_live = false; - } + Properties(); }; /** diff --git a/src/iosource/pcap/Source.cc b/src/iosource/pcap/Source.cc index 72b19b2f14..a68f0ca322 100644 --- a/src/iosource/pcap/Source.cc +++ b/src/iosource/pcap/Source.cc @@ -77,6 +77,12 @@ void PcapSource::OpenLive() props.netmask = 0xffffff00; } +#ifdef PCAP_NETMASK_UNKNOWN + // Defined in libpcap >= 1.1.1 + if ( props.netmask == PCAP_NETMASK_UNKNOWN ) + props.netmask = PktSrc::NETMASK_UNKNOWN; +#endif + // We use the smallest time-out possible to return almost immediately if // no packets are available. (We can't use set_nonblocking() as it's // broken on FreeBSD: even when select() indicates that we can read