IPBasedConnKey: Add GetTransportProto() helper

This commit is contained in:
Arne Welzel 2025-07-01 11:53:03 +02:00
parent a975d65d01
commit 661fa91231
2 changed files with 17 additions and 16 deletions

View file

@ -7,6 +7,7 @@
#include "zeek/Conn.h"
#include "zeek/ConnKey.h"
#include "zeek/IPAddr.h"
#include "zeek/net_util.h"
namespace zeek {
@ -63,6 +64,19 @@ public:
*/
uint16_t Proto() const { return PackedTuple().proto; }
/**
* @return The TransportProto value for this key's IP proto.
*/
TransportProto GetTransportProto() const {
switch ( Proto() ) {
case IPPROTO_TCP: return TRANSPORT_TCP;
case IPPROTO_UDP: return TRANSPORT_UDP;
case IPPROTO_ICMP:
case IPPROTO_ICMPV6: return TRANSPORT_ICMP;
default: return TRANSPORT_UNKNOWN;
}
}
/**
* Return a modifiable reference to the embedded PackedConnTuple.
*