TapAnalyzer: More verdict to action rename

Relates to #4725 #4337
This commit is contained in:
Arne Welzel 2025-08-05 19:56:07 +02:00
parent 1e05588e8e
commit b4925fbd16
3 changed files with 44 additions and 44 deletions

View file

@ -25,7 +25,7 @@ enum class PacketAction : uint8_t {
* Reason why delivery of a packet would be skipped. * Reason why delivery of a packet would be skipped.
*/ */
enum class SkipReason : uint8_t { enum class SkipReason : uint8_t {
None, ///< None is used when the verdict is Deliver. None, ///< None is used when the action is Deliver.
Unknown, ///< Placeholder if no other value fits. Unknown, ///< Placeholder if no other value fits.
BadChecksum, ///< The packet's checksum is invalid and ignore_checksums is false. BadChecksum, ///< The packet's checksum is invalid and ignore_checksums is false.
BadProtoHeader, ///< Something was off with the lengths or offsets in the protocol header. BadProtoHeader, ///< Something was off with the lengths or offsets in the protocol header.
@ -53,7 +53,7 @@ public:
* *
* @param pkt The packet being processed. * @param pkt The packet being processed.
* @param action Either Deliver or Skip as determined by session analyzers. * @param action Either Deliver or Skip as determined by session analyzers.
* @param skip_reason If verdict is Skip, an indication why this packet is skipped, otherwise None. * @param skip_reason If action is Skip, an indication why this packet is skipped, otherwise None.
*/ */
virtual void TapPacket(const Packet& pkt, PacketAction action, SkipReason skip_reason) = 0; virtual void TapPacket(const Packet& pkt, PacketAction action, SkipReason skip_reason) = 0;
@ -195,10 +195,10 @@ public:
* Helper to forward a packet to all attached TapAnalyzer instances. * Helper to forward a packet to all attached TapAnalyzer instances.
* *
* @param pkt The packet. * @param pkt The packet.
* @param verdict Whether the packet will be delivered or skipped. * @param action Whether the packet will be delivered or skipped.
* @param skip_reason If verdict is Skip, should be an indication why this packet is skipped. * @param skip_reason If action is Skip, should be an indication why this packet is skipped.
*/ */
void TapPacket(const Packet* pkt, PacketAction verdict = PacketAction::Deliver, void TapPacket(const Packet* pkt, PacketAction action = PacketAction::Deliver,
SkipReason skip_reason = SkipReason::None) const; SkipReason skip_reason = SkipReason::None) const;
/** /**

View file

@ -2,86 +2,86 @@
<...>/ip4-tcp-bad-chksum.pcap <...>/ip4-tcp-bad-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=54 orig=1, verdict=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9 Packet(len=54 orig=1, action=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/ip4-tcp-good-chksum.pcap <...>/ip4-tcp-good-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=54 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=54 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/ip4-udp-bad-chksum.pcap <...>/ip4-udp-bad-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=46 orig=1, verdict=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9 Packet(len=46 orig=1, action=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/ip4-udp-good-chksum.pcap <...>/ip4-udp-good-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=46 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=46 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/ip4-icmp-bad-chksum.pcap <...>/ip4-icmp-bad-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=42 orig=1, verdict=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9 Packet(len=42 orig=1, action=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/ip4-icmp-good-chksum.pcap <...>/ip4-icmp-good-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=42 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=42 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/ip6-icmp6-bad-chksum.pcap <...>/ip6-icmp6-bad-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=69 orig=1, verdict=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9 Packet(len=69 orig=1, action=1 skip_reason=1) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/ip6-icmp6-good-chksum.pcap <...>/ip6-icmp6-good-chksum.pcap
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=69 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=69 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/get.trace <...>/get.trace
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=78 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=78 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=74 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=74 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=202 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=202 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=1514 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=1514 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=1514 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=1514 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=1514 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=1514 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=729 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=729 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===
<...>/get.trace <...>/get.trace
Init() uid=HhAvVGS1DHFjwGM9 Init() uid=HhAvVGS1DHFjwGM9
Analyzer added to HhAvVGS1DHFjwGM9 Analyzer added to HhAvVGS1DHFjwGM9
Packet(len=78 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=78 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=74 orig=0, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=74 orig=0, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=202 orig=1, verdict=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9 Packet(len=202 orig=1, action=0 skip_reason=0) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=0, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=0, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=1514 orig=0, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=1514 orig=0, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=1514 orig=0, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=1514 orig=0, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=1514 orig=0, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=1514 orig=0, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=729 orig=0, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=729 orig=0, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=0, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=0, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Packet(len=66 orig=1, verdict=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9 Packet(len=66 orig=1, action=1 skip_reason=3) uid=HhAvVGS1DHFjwGM9
Done() uid=HhAvVGS1DHFjwGM9 Done() uid=HhAvVGS1DHFjwGM9
=== ===

View file

@ -14,10 +14,10 @@ class MyTapAnalyzer : public zeek::packet_analysis::TapAnalyzer {
public: public:
MyTapAnalyzer(zeek::Connection* conn) : conn(conn) {} MyTapAnalyzer(zeek::Connection* conn) : conn(conn) {}
void TapPacket(const zeek::Packet& pkt, zeek::packet_analysis::PacketAction verdict, void TapPacket(const zeek::Packet& pkt, zeek::packet_analysis::PacketAction action,
const zeek::packet_analysis::SkipReason skip_reason) override { const zeek::packet_analysis::SkipReason skip_reason) override {
std::printf("Packet(len=%d orig=%d, verdict=%d skip_reason=%d) uid=%s\n", pkt.len, pkt.is_orig, std::printf("Packet(len=%d orig=%d, action=%d skip_reason=%d) uid=%s\n", pkt.len, pkt.is_orig,
static_cast<int>(verdict), static_cast<int>(skip_reason), conn->GetUID().Base62().c_str()); static_cast<int>(action), static_cast<int>(skip_reason), conn->GetUID().Base62().c_str());
} }
void Init() override { std::printf("Init() uid=%s\n", conn->GetUID().Base62().c_str()); } void Init() override { std::printf("Init() uid=%s\n", conn->GetUID().Base62().c_str()); }