mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
Add/use unspecified IPAddr constants
The analyzer-scheduling code was otherwise frequently converting the unspecified v4/v6 addresses from strings.
This commit is contained in:
parent
48873570b5
commit
ba929ce2c4
3 changed files with 18 additions and 4 deletions
|
@ -14,6 +14,10 @@ const uint8_t IPAddr::v4_mapped_prefix[12] = { 0, 0, 0, 0,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
0, 0, 0xff, 0xff };
|
0, 0, 0xff, 0xff };
|
||||||
|
|
||||||
|
const IPAddr IPAddr::v4_unspecified = IPAddr(in4_addr{});
|
||||||
|
|
||||||
|
const IPAddr IPAddr::v6_unspecified = IPAddr();
|
||||||
|
|
||||||
ConnIDKey BuildConnIDKey(const ConnID& id)
|
ConnIDKey BuildConnIDKey(const ConnID& id)
|
||||||
{
|
{
|
||||||
ConnIDKey key;
|
ConnIDKey key;
|
||||||
|
|
10
src/IPAddr.h
10
src/IPAddr.h
|
@ -430,6 +430,16 @@ public:
|
||||||
return ConvertString(s, &tmp);
|
return ConvertString(s, &tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unspecified IPv4 addr, "0.0.0.0".
|
||||||
|
*/
|
||||||
|
static const IPAddr v4_unspecified;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unspecified IPv6 addr, "::".
|
||||||
|
*/
|
||||||
|
static const IPAddr v6_unspecified;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class IPPrefix;
|
friend class IPPrefix;
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,10 @@ using namespace analyzer;
|
||||||
Manager::ConnIndex::ConnIndex(const IPAddr& _orig, const IPAddr& _resp,
|
Manager::ConnIndex::ConnIndex(const IPAddr& _orig, const IPAddr& _resp,
|
||||||
uint16_t _resp_p, uint16_t _proto)
|
uint16_t _resp_p, uint16_t _proto)
|
||||||
{
|
{
|
||||||
if ( _orig == IPAddr(string("0.0.0.0")) )
|
if ( _orig == IPAddr::v4_unspecified )
|
||||||
// don't use the IPv4 mapping, use the literal unspecified address
|
// don't use the IPv4 mapping, use the literal unspecified address
|
||||||
// to indicate a wildcard
|
// to indicate a wildcard
|
||||||
orig = IPAddr(string("::"));
|
orig = IPAddr::v6_unspecified;
|
||||||
else
|
else
|
||||||
orig = _orig;
|
orig = _orig;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ Manager::ConnIndex::ConnIndex(const IPAddr& _orig, const IPAddr& _resp,
|
||||||
|
|
||||||
Manager::ConnIndex::ConnIndex()
|
Manager::ConnIndex::ConnIndex()
|
||||||
{
|
{
|
||||||
orig = resp = IPAddr("0.0.0.0");
|
orig = resp = IPAddr::v4_unspecified;
|
||||||
resp_p = 0;
|
resp_p = 0;
|
||||||
proto = 0;
|
proto = 0;
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ Manager::tag_set Manager::GetScheduled(const Connection* conn)
|
||||||
result.insert(i->second->analyzer);
|
result.insert(i->second->analyzer);
|
||||||
|
|
||||||
// Try wildcard for originator.
|
// Try wildcard for originator.
|
||||||
c.orig = IPAddr(string("::"));
|
c.orig = IPAddr::v6_unspecified;
|
||||||
all = conns.equal_range(c);
|
all = conns.equal_range(c);
|
||||||
|
|
||||||
for ( conns_map::iterator i = all.first; i != all.second; i++ )
|
for ( conns_map::iterator i = all.first; i != all.second; i++ )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue