diff --git a/scripts/base/init-bare.zeek b/scripts/base/init-bare.zeek index 9045370db9..ce7e815a78 100644 --- a/scripts/base/init-bare.zeek +++ b/scripts/base/init-bare.zeek @@ -996,7 +996,7 @@ const UDP_ACTIVE = 1; ##< Endpoint has sent something. const ignore_checksums = F &redef; ## Checksums are ignored for all packets with a src address within this set of -## addresses. Useful for cases where a host might be seeing packets collected +## networks. Useful for cases where a host might be seeing packets collected ## from local hosts before checksums were applied by hardware. This frequently ## manifests when sniffing a local management interface on a host and Zeek sees ## packets before the hardware has had a chance to apply the checksums. diff --git a/src/Val.cc b/src/Val.cc index 419742f300..66e8b8d568 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -1991,9 +1991,15 @@ ValPtr TableVal::FindOrDefault(const ValPtr& index) return Default(index); } -bool TableVal::Contains(const IPAddr& addr) +const bool TableVal::Contains(const IPAddr& addr) { - return subnets ? subnets->Lookup(addr, true) != 0 : false; + if ( ! subnets ) + { + reporter->InternalError("LookupSubnets called on wrong table type"); + return false; + } + + return (subnets->Lookup(addr, true) != 0); } Val* TableVal::Lookup(Val* index, bool use_default_val) diff --git a/src/Val.h b/src/Val.h index a38aae2c08..104bbb2e97 100644 --- a/src/Val.h +++ b/src/Val.h @@ -906,9 +906,15 @@ public: [[deprecated("Remove in v4.1. Use Find() or FindOrDefault().")]] Val* Lookup(Val* index, bool use_default_val = true); - // Returns true if this is a table[subnet]/set[subnet] and the - // given address was found in the table. Otherwise returns false. - bool Contains(const IPAddr& addr); + /** + * Returns true if this is a table[subnet]/set[subnet] and the + * given address was found in the table. Otherwise returns false. + * @param addr The address to look for. + * @return Boolean value to indicate if addr is in the table or set. If + * self is not a table[subnet]/set[subnet] an internal error will be + * generated and false will be returned. + */ + bool Contains(const IPAddr& addr) const; // For a table[subnet]/set[subnet], return all subnets that cover // the given subnet.