mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
GH-1620: Add event and plugin hook to track packets not processed
This commit is contained in:
parent
8fece3d8ea
commit
fe932944c4
16 changed files with 194 additions and 25 deletions
|
@ -26,6 +26,7 @@ zeek::plugin::Configuration Plugin::Configure()
|
|||
EnableHook(zeek::plugin::HOOK_SETUP_ANALYZER_TREE);
|
||||
EnableHook(zeek::plugin::HOOK_LOG_INIT);
|
||||
EnableHook(zeek::plugin::HOOK_LOG_WRITE);
|
||||
EnableHook(zeek::plugin::HOOK_UNPROCESSED_PACKET);
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Hooks";
|
||||
|
@ -272,3 +273,18 @@ bool Plugin::HookLogWrite(const std::string& writer, const std::string& filter,
|
|||
fprintf(stderr, "%.6f %-15s %s %s\n", zeek::run_state::network_time, "| HookLogWrite", info.path, d.Description());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Plugin::HookUnprocessedPacket(const zeek::Packet* packet)
|
||||
{
|
||||
zeek::ODesc d;
|
||||
d.Add("[");
|
||||
d.Add("ts=");
|
||||
d.Add(packet->time);
|
||||
d.Add(" len=");
|
||||
d.Add(packet->len);
|
||||
d.Add(" header=");
|
||||
d.AddN(reinterpret_cast<const char*>(packet->data), 10);
|
||||
d.Add("]");
|
||||
|
||||
fprintf(stderr, "%.6f %-23s %s\n", zeek::run_state::network_time, "| HookUnprocessedPacket", d.Description());
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ protected:
|
|||
int num_fields, const zeek::threading::Field* const* fields,
|
||||
zeek::threading::Value** vals) override;
|
||||
void HookSetupAnalyzerTree(zeek::Connection *conn) override;
|
||||
void HookUnprocessedPacket(const zeek::Packet* packet) override;
|
||||
void MetaHookPre(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args) override;
|
||||
void MetaHookPost(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args,
|
||||
zeek::plugin::HookArgument result) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue