mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
IPBasedConnKey: Add GetTransportProto() helper
This commit is contained in:
parent
a975d65d01
commit
661fa91231
2 changed files with 17 additions and 16 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue