Add type field to session::Key to help avoid collisions in map

This commit is contained in:
Tim Wojtulewicz 2021-05-20 11:00:11 -07:00
parent 30ab914cd8
commit 3a8047f535
4 changed files with 20 additions and 13 deletions

View file

@ -4,7 +4,8 @@
namespace zeek::session::detail {
Key::Key(const void* session, size_t size, bool copy) : size(size)
Key::Key(const void* session, size_t size, size_t type, bool copy) :
size(size), type(type)
{
data = reinterpret_cast<const uint8_t*>(session);
@ -63,6 +64,8 @@ bool Key::operator<(const Key& rhs) const
{
if ( size != rhs.size )
return size < rhs.size;
else if ( type != rhs.type )
return type < rhs.type;
return memcmp(data, rhs.data, size) < 0;
}