mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
Added plugin.unprocessed_packet_hook btest
This commit is contained in:
parent
d0f8c50417
commit
6e8dae316b
8 changed files with 540 additions and 2 deletions
|
@ -0,0 +1,4 @@
|
|||
event packet_not_processed(pkt: pcap_packet)
|
||||
{
|
||||
print fmt("packet_not_processed: ts=%d.%d", pkt$ts_sec, pkt$ts_usec);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include <Func.h>
|
||||
#include <Event.h>
|
||||
#include <Conn.h>
|
||||
#include <Desc.h>
|
||||
#include <threading/Formatter.h>
|
||||
#include <RunState.h>
|
||||
|
||||
namespace btest::plugin::Demo_Unprocessed_Packet { Plugin plugin; }
|
||||
|
||||
using namespace btest::plugin::Demo_Unprocessed_Packet;
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
EnableHook(zeek::plugin::HOOK_UNPROCESSED_PACKET);
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Unprocessed_Packet";
|
||||
config.description = "Exercises all plugin hooks";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
return config;
|
||||
}
|
||||
|
||||
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("]");
|
||||
|
||||
fprintf(stdout, "%.6f %-23s %s\n", zeek::run_state::network_time, "| HookUnprocessedPacket", d.Description());
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Demo_Unprocessed_Packet {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
void HookUnprocessedPacket(const zeek::Packet* packet) override;
|
||||
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue