mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Update plugin btests for namespace changes
This commit is contained in:
parent
70c2397f69
commit
874e170341
43 changed files with 420 additions and 317 deletions
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include "foo.bif.h"
|
||||
|
||||
using namespace analyzer::FOO;
|
||||
using namespace btest::analyzer::FOO;
|
||||
using namespace zeek::analyzer;
|
||||
|
||||
FOO_Analyzer::FOO_Analyzer(Connection* c) : tcp::TCP_ApplicationAnalyzer("FOO", c)
|
||||
FOO_Analyzer::FOO_Analyzer(zeek::Connection* c) : tcp::TCP_ApplicationAnalyzer("FOO", c)
|
||||
{
|
||||
interp = new binpac::FOO::FOO_Conn(this);
|
||||
had_gap = false;
|
||||
|
@ -53,7 +54,7 @@ void FOO_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
|
|||
catch ( const binpac::Exception& e )
|
||||
{
|
||||
printf("Exception: %s\n", e.c_msg());
|
||||
ProtocolViolation(fmt("Binpac exception: %s", e.c_msg()));
|
||||
ProtocolViolation(zeek::util::fmt("Binpac exception: %s", e.c_msg()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
#include "foo_pac.h"
|
||||
|
||||
namespace analyzer { namespace FOO {
|
||||
namespace btest::analyzer::FOO {
|
||||
|
||||
class FOO_Analyzer : public tcp::TCP_ApplicationAnalyzer {
|
||||
class FOO_Analyzer : public zeek::analyzer::tcp::TCP_ApplicationAnalyzer {
|
||||
public:
|
||||
FOO_Analyzer(Connection* conn);
|
||||
FOO_Analyzer(zeek::Connection* conn);
|
||||
virtual ~FOO_Analyzer();
|
||||
|
||||
// Overriden from Analyzer.
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
// Overriden from tcp::TCP_ApplicationAnalyzer.
|
||||
virtual void EndpointEOF(bool is_orig);
|
||||
|
||||
static analyzer::Analyzer* InstantiateAnalyzer(Connection* conn)
|
||||
static zeek::analyzer::Analyzer* InstantiateAnalyzer(zeek::Connection* conn)
|
||||
{ return new FOO_Analyzer(conn); }
|
||||
|
||||
protected:
|
||||
|
@ -32,6 +32,6 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
} } // namespace analyzer::FOO
|
||||
} // namespace btest::analyzer::FOO
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
|
||||
#include "FOO.h"
|
||||
|
||||
namespace plugin {
|
||||
namespace Foo_FOO {
|
||||
namespace btest::plugin::Foo_FOO {
|
||||
|
||||
class Plugin : public plugin::Plugin {
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
public:
|
||||
plugin::Configuration Configure()
|
||||
zeek::plugin::Configuration Configure()
|
||||
{
|
||||
AddComponent(new ::analyzer::Component("FOO",
|
||||
::analyzer::FOO::FOO_Analyzer::InstantiateAnalyzer));
|
||||
AddComponent(new zeek::analyzer::Component("FOO",
|
||||
btest::analyzer::FOO::FOO_Analyzer::InstantiateAnalyzer));
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "FOO::Foo";
|
||||
config.description = "Foo Analyzer analyzer";
|
||||
config.version.major = 1;
|
||||
|
@ -23,4 +22,3 @@ public:
|
|||
} plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ refine flow FOO_Flow += {
|
|||
%{
|
||||
// printf("FOO %d %d\n", msg->hdr()->len(), msg->hdr_len());
|
||||
connection()->bro_analyzer()->ProtocolConfirmation();
|
||||
BifEvent::Foo::generate_foo_message(
|
||||
zeek::BifEvent::Foo::enqueue_foo_message(
|
||||
connection()->bro_analyzer(),
|
||||
connection()->bro_analyzer()->Conn(),
|
||||
is_orig(),
|
||||
|
@ -57,4 +57,3 @@ refine flow FOO_Flow += {
|
|||
refine typeattr FOO_PDU += &let {
|
||||
proc: bool = $context.flow.proc_foo_message(this);
|
||||
};
|
||||
|
||||
|
|
|
@ -5,23 +5,22 @@
|
|||
#include <events.bif.h>
|
||||
#include <file_analysis/Manager.h>
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
Foo::Foo(RecordVal* args, file_analysis::File* file)
|
||||
: file_analysis::Analyzer(file_mgr->GetComponentTag("FOO"), args, file)
|
||||
Foo::Foo(zeek::RecordValPtr args, zeek::file_analysis::File* file)
|
||||
: zeek::file_analysis::Analyzer(zeek::file_mgr->GetComponentTag("FOO"), std::move(args), file)
|
||||
{
|
||||
}
|
||||
|
||||
file_analysis::Analyzer* Foo::Instantiate(RecordVal* args, file_analysis::File* file)
|
||||
zeek::file_analysis::Analyzer* Foo::Instantiate(zeek::RecordValPtr args, zeek::file_analysis::File* file)
|
||||
{
|
||||
return new Foo(args, file);
|
||||
return new Foo(std::move(args), file);
|
||||
}
|
||||
|
||||
bool Foo::DeliverStream(const u_char* data, uint64 len)
|
||||
bool Foo::DeliverStream(const u_char* data, uint64_t len)
|
||||
{
|
||||
val_list* args = new val_list;
|
||||
args->append(GetFile()->GetVal()->Ref());
|
||||
args->append(new StringVal(new BroString(data, len, 0)));
|
||||
mgr.QueueEvent(foo_piece, args);
|
||||
zeek::event_mgr.Enqueue(foo_piece,
|
||||
GetFile()->ToVal(),
|
||||
zeek::make_intrusive<zeek::StringVal>(new zeek::String(data, len, 0)));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,17 +4,16 @@
|
|||
#include <Val.h>
|
||||
#include <file_analysis/Analyzer.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Foo : public file_analysis::Analyzer {
|
||||
class Foo : public zeek::file_analysis::Analyzer {
|
||||
public:
|
||||
virtual bool DeliverStream(const u_char* data, uint64 len);
|
||||
virtual bool DeliverStream(const u_char* data, uint64_t len);
|
||||
|
||||
static file_analysis::Analyzer* Instantiate(RecordVal* args, file_analysis::File* file);
|
||||
static zeek::file_analysis::Analyzer* Instantiate(zeek::RecordValPtr args, zeek::file_analysis::File* file);
|
||||
|
||||
protected:
|
||||
Foo(RecordVal* args, file_analysis::File* file);
|
||||
Foo(zeek::RecordValPtr args, zeek::file_analysis::File* file);
|
||||
};
|
||||
|
||||
} }
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
#include "file_analysis/Component.h"
|
||||
#include "file_analysis/File.h"
|
||||
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Foo { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::file_analysis::Component("Foo", ::plugin::Demo_Foo::Foo::Instantiate));
|
||||
AddComponent(new zeek::file_analysis::Component("Foo", btest::plugin::Demo_Foo::Foo::Instantiate));
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Foo";
|
||||
config.description = "A Foo test analyzer";
|
||||
config.version.major = 1;
|
||||
|
|
16
testing/btest/plugins/file-plugin/src/Plugin.h
Normal file
16
testing/btest/plugins/file-plugin/src/Plugin.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
|
@ -8,17 +8,17 @@
|
|||
#include <zeek/Desc.h>
|
||||
#include <zeek/threading/Formatter.h>
|
||||
|
||||
namespace plugin { namespace Demo_Hooks { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Hooks { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Hooks;
|
||||
using namespace btest::plugin::Demo_Hooks;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
EnableHook(HOOK_CALL_FUNCTION);
|
||||
EnableHook(META_HOOK_PRE);
|
||||
EnableHook(META_HOOK_POST);
|
||||
EnableHook(zeek::plugin::HOOK_CALL_FUNCTION);
|
||||
EnableHook(zeek::plugin::META_HOOK_PRE);
|
||||
EnableHook(zeek::plugin::META_HOOK_POST);
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Hooks";
|
||||
config.description = "Exercises all plugin hooks";
|
||||
config.version.major = 1;
|
||||
|
@ -27,34 +27,34 @@ plugin::Configuration Plugin::Configure()
|
|||
return config;
|
||||
}
|
||||
|
||||
static void describe_hook_args(const plugin::HookArgumentList& args, ODesc* d)
|
||||
static void describe_hook_args(const zeek::plugin::HookArgumentList& args, zeek::ODesc* d)
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
for ( plugin::HookArgumentList::const_iterator i = args.begin(); i != args.end(); i++ )
|
||||
for ( const auto& arg : args )
|
||||
{
|
||||
if ( ! first )
|
||||
d->Add(", ");
|
||||
|
||||
i->Describe(d);
|
||||
arg.Describe(d);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<bool, zeek::IntrusivePtr<Val>> Plugin::HookFunctionCall(
|
||||
const Func* func, Frame* frame, zeek::Args* args)
|
||||
std::pair<bool, zeek::ValPtr> Plugin::HookFunctionCall(
|
||||
const zeek::Func* func, zeek::detail::Frame* frame, zeek::Args* args)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
HookArgument(func).Describe(&d);
|
||||
HookArgument(args).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookFunctionCall",
|
||||
zeek::plugin::HookArgument(func).Describe(&d);
|
||||
zeek::plugin::HookArgument(args).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookFunctionCall",
|
||||
d.Description());
|
||||
|
||||
if ( streq(func->Name(), "foo") )
|
||||
if ( zeek::util::streq(func->Name(), "foo") )
|
||||
{
|
||||
auto& vl = *args;
|
||||
vl[0] = val_mgr->Count(42);
|
||||
vl[0] = zeek::val_mgr->Count(42);
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -62,10 +62,10 @@ std::pair<bool, zeek::IntrusivePtr<Val>> Plugin::HookFunctionCall(
|
|||
|
||||
void Plugin::MetaHookPre(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
describe_hook_args(args, &d);
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", network_time, " MetaHookPre",
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", zeek::run_state::network_time, " MetaHookPre",
|
||||
hook_name(hook), d.Description());
|
||||
}
|
||||
|
||||
|
@ -73,15 +73,15 @@ void Plugin::MetaHookPost(zeek::plugin::HookType hook,
|
|||
const zeek::plugin::HookArgumentList& args,
|
||||
zeek::plugin::HookArgument result)
|
||||
{
|
||||
ODesc d1;
|
||||
zeek::ODesc d1;
|
||||
d1.SetShort();
|
||||
describe_hook_args(args, &d1);
|
||||
|
||||
ODesc d2;
|
||||
zeek::ODesc d2;
|
||||
d2.SetShort();
|
||||
result.Describe(&d2);
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", network_time, " MetaHookPost",
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", zeek::run_state::network_time, " MetaHookPost",
|
||||
hook_name(hook), d1.Description(),
|
||||
d2.Description());
|
||||
}
|
||||
|
|
|
@ -3,15 +3,14 @@
|
|||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Hooks {
|
||||
namespace btest::plugin::Demo_Hooks {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
|
||||
std::pair<bool, zeek::IntrusivePtr<Val>> HookFunctionCall(
|
||||
const Func* func, Frame* frame, zeek::Args* args) override;
|
||||
std::pair<bool, zeek::ValPtr> HookFunctionCall(
|
||||
const zeek::Func* func, zeek::detail::Frame* frame, zeek::Args* args) override;
|
||||
|
||||
void MetaHookPre(zeek::plugin::HookType hook,
|
||||
const zeek::plugin::HookArgumentList& args) override;
|
||||
|
@ -20,10 +19,9 @@ protected:
|
|||
zeek::plugin::HookArgument result) override;
|
||||
|
||||
// Overridden from plugin::Plugin.
|
||||
plugin::Configuration Configure() override;
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
#include <Conn.h>
|
||||
#include <Desc.h>
|
||||
#include <threading/Formatter.h>
|
||||
#include <RunState.h>
|
||||
|
||||
namespace plugin { namespace Demo_Hooks { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Hooks { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Hooks;
|
||||
using namespace btest::plugin::Demo_Hooks;
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
|
@ -34,7 +35,7 @@ zeek::plugin::Configuration Plugin::Configure()
|
|||
return config;
|
||||
}
|
||||
|
||||
static void describe_hook_args(const zeek::plugin::HookArgumentList& args, ODesc* d)
|
||||
static void describe_hook_args(const zeek::plugin::HookArgumentList& args, zeek::ODesc* d)
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
|
@ -50,36 +51,36 @@ static void describe_hook_args(const zeek::plugin::HookArgumentList& args, ODesc
|
|||
|
||||
int Plugin::HookLoadFile(const LoadType type, const std::string& file, const std::string& resolved)
|
||||
{
|
||||
fprintf(stderr, "%.6f %-15s %s %s\n", network_time, "| HookLoadFile",
|
||||
fprintf(stderr, "%.6f %-15s %s %s\n", zeek::run_state::network_time, "| HookLoadFile",
|
||||
file.c_str(), resolved.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame* frame, val_list* args)
|
||||
std::pair<bool, zeek::Val*> Plugin::HookCallFunction(const zeek::Func* func, zeek::detail::Frame* frame, zeek::ValPList* args)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
zeek::plugin::HookArgument(func).Describe(&d);
|
||||
zeek::plugin::HookArgument(args).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookCallFunction",
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookCallFunction",
|
||||
d.Description());
|
||||
|
||||
return std::pair<bool, Val*>(false, NULL);
|
||||
return std::pair<bool, zeek::Val*>(false, NULL);
|
||||
}
|
||||
|
||||
bool Plugin::HookQueueEvent(Event* event)
|
||||
bool Plugin::HookQueueEvent(zeek::Event* event)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
zeek::plugin::HookArgument(event).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookQueueEvent",
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookQueueEvent",
|
||||
d.Description());
|
||||
|
||||
static int i = 0;
|
||||
|
||||
if ( network_time && i == 0 )
|
||||
if ( zeek::run_state::network_time && i == 0 )
|
||||
{
|
||||
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| RequestObjDtor",
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| RequestObjDtor",
|
||||
d.Description());
|
||||
|
||||
RequestBroObjDtor(event);
|
||||
|
@ -91,61 +92,63 @@ bool Plugin::HookQueueEvent(Event* event)
|
|||
|
||||
void Plugin::HookDrainEvents()
|
||||
{
|
||||
fprintf(stderr, "%.6f %-15s\n", network_time, "| HookDrainEvents");
|
||||
fprintf(stderr, "%.6f %-15s\n", zeek::run_state::network_time, "| HookDrainEvents");
|
||||
}
|
||||
|
||||
void Plugin::HookUpdateNetworkTime(double network_time)
|
||||
{
|
||||
fprintf(stderr, "%.6f %-15s %.6f\n", ::network_time, "| HookUpdateNetworkTime",
|
||||
network_time);
|
||||
fprintf(stderr, "%.6f %-15s %.6f\n", zeek::run_state::network_time, "| HookUpdateNetworkTime",
|
||||
zeek::run_state::network_time);
|
||||
}
|
||||
|
||||
void Plugin::HookBroObjDtor(void* obj)
|
||||
{
|
||||
fprintf(stderr, "%.6f %-15s\n", ::network_time, "| HookBroObjDtor");
|
||||
fprintf(stderr, "%.6f %-15s\n", zeek::run_state::network_time, "| HookBroObjDtor");
|
||||
}
|
||||
|
||||
void Plugin::MetaHookPre(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
describe_hook_args(args, &d);
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", network_time, " MetaHookPre",
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", zeek::run_state::network_time, " MetaHookPre",
|
||||
hook_name(hook), d.Description());
|
||||
}
|
||||
|
||||
void Plugin::MetaHookPost(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args, zeek::plugin::HookArgument result)
|
||||
{
|
||||
ODesc d1;
|
||||
zeek::ODesc d1;
|
||||
d1.SetShort();
|
||||
describe_hook_args(args, &d1);
|
||||
|
||||
ODesc d2;
|
||||
zeek::ODesc d2;
|
||||
d2.SetShort();
|
||||
result.Describe(&d2);
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", network_time, " MetaHookPost",
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", zeek::run_state::network_time, " MetaHookPost",
|
||||
hook_name(hook), d1.Description(),
|
||||
d2.Description());
|
||||
}
|
||||
|
||||
void Plugin::HookSetupAnalyzerTree(Connection *conn)
|
||||
void Plugin::HookSetupAnalyzerTree(zeek::Connection* conn)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
conn->Describe(&d);
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookSetupAnalyzerTree", d.Description());
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookSetupAnalyzerTree", d.Description());
|
||||
}
|
||||
|
||||
void Plugin::HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields)
|
||||
void Plugin::HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
|
||||
d.Add("{");
|
||||
for ( int i=0; i < num_fields; i++ )
|
||||
{
|
||||
const threading::Field* f = fields[i];
|
||||
const zeek::threading::Field* f = fields[i];
|
||||
|
||||
if ( i > 0 )
|
||||
d.Add(", ");
|
||||
|
@ -157,10 +160,10 @@ void Plugin::HookLogInit(const std::string& writer, const std::string& instantia
|
|||
}
|
||||
d.Add("}");
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s %d/%d %s\n", network_time, "| HookLogInit", info.path, local, remote, d.Description());
|
||||
fprintf(stderr, "%.6f %-15s %s %d/%d %s\n", zeek::run_state::network_time, "| HookLogInit", info.path, local, remote, d.Description());
|
||||
}
|
||||
|
||||
void Plugin::RenderVal(const threading::Value* val, ODesc &d) const
|
||||
void Plugin::RenderVal(const zeek::threading::Value* val, zeek::ODesc &d) const
|
||||
{
|
||||
if ( ! val->present )
|
||||
{
|
||||
|
@ -170,47 +173,47 @@ void Plugin::RenderVal(const threading::Value* val, ODesc &d) const
|
|||
|
||||
switch ( val->type ) {
|
||||
|
||||
case TYPE_BOOL:
|
||||
case zeek::TYPE_BOOL:
|
||||
d.Add(val->val.int_val ? "T" : "F");
|
||||
break;
|
||||
|
||||
case TYPE_INT:
|
||||
case zeek::TYPE_INT:
|
||||
d.Add(val->val.int_val);
|
||||
break;
|
||||
|
||||
case TYPE_COUNT:
|
||||
case zeek::TYPE_COUNT:
|
||||
d.Add(val->val.uint_val);
|
||||
break;
|
||||
|
||||
case TYPE_PORT:
|
||||
case zeek::TYPE_PORT:
|
||||
d.Add(val->val.port_val.port);
|
||||
break;
|
||||
|
||||
case TYPE_SUBNET:
|
||||
d.Add(threading::formatter::Formatter::Render(val->val.subnet_val));
|
||||
case zeek::TYPE_SUBNET:
|
||||
d.Add(zeek::threading::Formatter::Render(val->val.subnet_val));
|
||||
break;
|
||||
|
||||
case TYPE_ADDR:
|
||||
d.Add(threading::formatter::Formatter::Render(val->val.addr_val));
|
||||
case zeek::TYPE_ADDR:
|
||||
d.Add(zeek::threading::Formatter::Render(val->val.addr_val));
|
||||
break;
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
case zeek::TYPE_DOUBLE:
|
||||
d.Add(val->val.double_val, true);
|
||||
break;
|
||||
|
||||
case TYPE_INTERVAL:
|
||||
case TYPE_TIME:
|
||||
d.Add(threading::formatter::Formatter::Render(val->val.double_val));
|
||||
case zeek::TYPE_INTERVAL:
|
||||
case zeek::TYPE_TIME:
|
||||
d.Add(zeek::threading::Formatter::Render(val->val.double_val));
|
||||
break;
|
||||
|
||||
case TYPE_ENUM:
|
||||
case TYPE_STRING:
|
||||
case TYPE_FILE:
|
||||
case TYPE_FUNC:
|
||||
case zeek::TYPE_ENUM:
|
||||
case zeek::TYPE_STRING:
|
||||
case zeek::TYPE_FILE:
|
||||
case zeek::TYPE_FUNC:
|
||||
d.AddN(val->val.string_val.data, val->val.string_val.length);
|
||||
break;
|
||||
|
||||
case TYPE_TABLE:
|
||||
case zeek::TYPE_TABLE:
|
||||
for ( int j = 0; j < val->val.set_val.size; j++ )
|
||||
{
|
||||
if ( j > 0 )
|
||||
|
@ -220,7 +223,7 @@ void Plugin::RenderVal(const threading::Value* val, ODesc &d) const
|
|||
}
|
||||
break;
|
||||
|
||||
case TYPE_VECTOR:
|
||||
case zeek::TYPE_VECTOR:
|
||||
for ( int j = 0; j < val->val.vector_val.size; j++ )
|
||||
{
|
||||
if ( j > 0 )
|
||||
|
@ -235,15 +238,17 @@ void Plugin::RenderVal(const threading::Value* val, ODesc &d) const
|
|||
}
|
||||
}
|
||||
|
||||
bool Plugin::HookLogWrite(const std::string& writer, const std::string& filter, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields, threading::Value** vals)
|
||||
bool Plugin::HookLogWrite(const std::string& writer, const std::string& filter,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields, zeek::threading::Value** vals)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
|
||||
d.Add("[");
|
||||
for ( int i=0; i < num_fields; i++ )
|
||||
{
|
||||
const threading::Field* f = fields[i];
|
||||
const threading::Value* val = vals[i];
|
||||
const zeek::threading::Field* f = fields[i];
|
||||
const zeek::threading::Value* val = vals[i];
|
||||
|
||||
if ( i > 0 )
|
||||
d.Add(", ");
|
||||
|
@ -255,6 +260,6 @@ bool Plugin::HookLogWrite(const std::string& writer, const std::string& filter,
|
|||
}
|
||||
d.Add("]");
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s %s\n", network_time, "| HookLogWrite", info.path, d.Description());
|
||||
fprintf(stderr, "%.6f %-15s %s %s\n", zeek::run_state::network_time, "| HookLogWrite", info.path, d.Description());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,25 +3,30 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Hooks {
|
||||
namespace btest::plugin::Demo_Hooks {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
int HookLoadFile(const LoadType type, const std::string& file, const std::string& resolved) override;
|
||||
std::pair<bool, Val*> HookCallFunction(const Func* func, Frame* frame, val_list* args) override;
|
||||
bool HookQueueEvent(Event* event) override;
|
||||
std::pair<bool, zeek::Val*> HookCallFunction(const zeek::Func* func, zeek::detail::Frame* frame, zeek::ValPList* args) override;
|
||||
bool HookQueueEvent(zeek::Event* event) override;
|
||||
void HookDrainEvents() override;
|
||||
void HookUpdateNetworkTime(double network_time) override;
|
||||
void HookBroObjDtor(void* obj) override;
|
||||
void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields) override;
|
||||
bool HookLogWrite(const std::string& writer, const std::string& filter, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields, threading::Value** vals) override;
|
||||
void HookSetupAnalyzerTree(Connection *conn) override;
|
||||
void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields) override;
|
||||
bool HookLogWrite(const std::string& writer, const std::string& filter,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info,
|
||||
int num_fields, const zeek::threading::Field* const* fields,
|
||||
zeek::threading::Value** vals) override;
|
||||
void HookSetupAnalyzerTree(zeek::Connection *conn) 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;
|
||||
void MetaHookPost(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args,
|
||||
zeek::plugin::HookArgument result) override;
|
||||
|
||||
void RenderVal(const threading::Value* val, ODesc &d) const;
|
||||
void RenderVal(const zeek::threading::Value* val, zeek::ODesc &d) const;
|
||||
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
|
@ -30,4 +35,3 @@ protected:
|
|||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
#include <Desc.h>
|
||||
#include <threading/Formatter.h>
|
||||
|
||||
namespace plugin { namespace Demo_Hooks { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Hooks { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Hooks;
|
||||
using namespace btest::plugin::Demo_Hooks;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
EnableHook(HOOK_CALL_FUNCTION);
|
||||
EnableHook(META_HOOK_PRE);
|
||||
EnableHook(META_HOOK_POST);
|
||||
EnableHook(zeek::plugin::HOOK_CALL_FUNCTION);
|
||||
EnableHook(zeek::plugin::META_HOOK_PRE);
|
||||
EnableHook(zeek::plugin::META_HOOK_POST);
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Hooks";
|
||||
config.description = "Exercises all plugin hooks";
|
||||
config.version.major = 1;
|
||||
|
@ -27,7 +27,7 @@ plugin::Configuration Plugin::Configure()
|
|||
return config;
|
||||
}
|
||||
|
||||
static void describe_hook_args(const plugin::HookArgumentList& args, ODesc* d)
|
||||
static void describe_hook_args(const zeek::plugin::HookArgumentList& args, zeek::ODesc* d)
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
|
@ -41,20 +41,21 @@ static void describe_hook_args(const plugin::HookArgumentList& args, ODesc* d)
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame* frame, val_list* args)
|
||||
std::pair<bool, zeek::Val*> Plugin::HookCallFunction(const zeek::Func* func, zeek::detail::Frame* frame,
|
||||
zeek::ValPList* args)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
HookArgument(func).Describe(&d);
|
||||
HookArgument(args).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookCallFunction",
|
||||
zeek::plugin::HookArgument(func).Describe(&d);
|
||||
zeek::plugin::HookArgument(args).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookCallFunction",
|
||||
d.Description());
|
||||
|
||||
if ( streq(func->Name(), "foo") )
|
||||
if ( zeek::util::streq(func->Name(), "foo") )
|
||||
{
|
||||
auto& vl = *args;
|
||||
Unref(vl[0]);
|
||||
vl[0] = val_mgr->Count(13).release();
|
||||
vl[0] = zeek::val_mgr->Count(13).release();
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -64,11 +65,11 @@ std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame* frame, v
|
|||
/* Frame* frame, */
|
||||
/* zeek::Args* args) */
|
||||
/* { */
|
||||
/* ODesc d; */
|
||||
/* zeek::ODesc d; */
|
||||
/* d.SetShort(); */
|
||||
/* HookArgument(func).Describe(&d); */
|
||||
/* HookArgument(args).Describe(&d); */
|
||||
/* fprintf(stderr, "%.6f %-15s %s\n", network_time, "| HookFunctionCall", */
|
||||
/* fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookFunctionCall", */
|
||||
/* d.Description()); */
|
||||
|
||||
/* if ( streq(func->Name(), "foo") ) */
|
||||
|
@ -82,25 +83,25 @@ std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame* frame, v
|
|||
|
||||
void Plugin::MetaHookPre(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
describe_hook_args(args, &d);
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", network_time, " MetaHookPre",
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", zeek::run_state::network_time, " MetaHookPre",
|
||||
hook_name(hook), d.Description());
|
||||
}
|
||||
|
||||
void Plugin::MetaHookPost(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args,
|
||||
zeek::plugin::HookArgument result)
|
||||
{
|
||||
ODesc d1;
|
||||
zeek::ODesc d1;
|
||||
d1.SetShort();
|
||||
describe_hook_args(args, &d1);
|
||||
|
||||
ODesc d2;
|
||||
zeek::ODesc d2;
|
||||
d2.SetShort();
|
||||
result.Describe(&d2);
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", network_time, " MetaHookPost",
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", zeek::run_state::network_time, " MetaHookPost",
|
||||
hook_name(hook), d1.Description(),
|
||||
d2.Description());
|
||||
}
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Hooks {
|
||||
namespace btest::plugin::Demo_Hooks {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
std::pair<bool, Val*> HookCallFunction(const Func* func, Frame* frame, val_list* args) override;
|
||||
std::pair<bool, zeek::Val*> HookCallFunction(const zeek::Func* func, zeek::detail::Frame* frame, zeek::ValPList* args) override;
|
||||
|
||||
/* std::pair<bool, IntrusivePtr<Val>> HookFunctionCall(const Func* func, */
|
||||
/* Frame* frame, */
|
||||
|
@ -22,10 +21,9 @@ protected:
|
|||
zeek::plugin::HookArgument result) override;
|
||||
|
||||
// Overridden from plugin::Plugin.
|
||||
plugin::Configuration Configure() override;
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,18 +6,19 @@
|
|||
#include <Conn.h>
|
||||
#include <Desc.h>
|
||||
#include <threading/Formatter.h>
|
||||
#include <RunState.h>
|
||||
|
||||
namespace plugin { namespace Log_Hooks { Plugin plugin; } }
|
||||
namespace btest::plugin::Log_Hooks { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Log_Hooks;
|
||||
using namespace btest::plugin::Log_Hooks;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
round = 0;
|
||||
EnableHook(HOOK_LOG_INIT);
|
||||
EnableHook(HOOK_LOG_WRITE);
|
||||
EnableHook(zeek::plugin::HOOK_LOG_INIT);
|
||||
EnableHook(zeek::plugin::HOOK_LOG_WRITE);
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Log::Hooks";
|
||||
config.description = "Exercises Log hooks";
|
||||
config.version.major = 1;
|
||||
|
@ -26,14 +27,16 @@ plugin::Configuration Plugin::Configure()
|
|||
return config;
|
||||
}
|
||||
|
||||
void Plugin::HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields)
|
||||
void Plugin::HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local,
|
||||
bool remote, const zeek::logging::WriterBackend::WriterInfo& info,
|
||||
int num_fields, const zeek::threading::Field* const* fields)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
|
||||
d.Add("{");
|
||||
for ( int i=0; i < num_fields; i++ )
|
||||
{
|
||||
const threading::Field* f = fields[i];
|
||||
const zeek::threading::Field* f = fields[i];
|
||||
|
||||
if ( i > 0 )
|
||||
d.Add(", ");
|
||||
|
@ -45,10 +48,13 @@ void Plugin::HookLogInit(const std::string& writer, const std::string& instantia
|
|||
}
|
||||
d.Add("}");
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s %d/%d %s\n", network_time, "| HookLogInit", info.path, local, remote, d.Description());
|
||||
fprintf(stderr, "%.6f %-15s %s %d/%d %s\n", zeek::run_state::network_time,
|
||||
"| HookLogInit", info.path, local, remote, d.Description());
|
||||
}
|
||||
|
||||
bool Plugin::HookLogWrite(const std::string& writer, const std::string& filter, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields, threading::Value** vals)
|
||||
bool Plugin::HookLogWrite(const std::string& writer, const std::string& filter,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields, zeek::threading::Value** vals)
|
||||
{
|
||||
round++;
|
||||
if ( round == 1 ) // do not output line
|
||||
|
|
|
@ -3,17 +3,20 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Log_Hooks {
|
||||
namespace btest::plugin::Log_Hooks {
|
||||
|
||||
class Plugin : public ::plugin::Plugin
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields) override;
|
||||
bool HookLogWrite(const std::string& writer, const std::string& filter, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields, threading::Value** vals) override;
|
||||
void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local,
|
||||
bool remote, const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields) override;
|
||||
bool HookLogWrite(const std::string& writer, const std::string& filter,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields, zeek::threading::Value** vals) override;
|
||||
|
||||
// Overridden from plugin::Plugin.
|
||||
plugin::Configuration Configure() override;
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
|
||||
private:
|
||||
int round;
|
||||
|
@ -22,4 +25,3 @@ private:
|
|||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
|
||||
#include "Foo.h"
|
||||
#include "iosource/Packet.h"
|
||||
#include "RunState.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
Foo::Foo(const std::string& path, bool is_live)
|
||||
{
|
||||
|
@ -18,7 +19,7 @@ Foo::~Foo()
|
|||
|
||||
void Foo::Open()
|
||||
{
|
||||
props.open_time = network_time;
|
||||
props.open_time = zeek::run_state::network_time;
|
||||
props.hdr_size = 0;
|
||||
Opened(props);
|
||||
}
|
||||
|
@ -28,14 +29,14 @@ void Foo::Close()
|
|||
Closed();
|
||||
}
|
||||
|
||||
bool Foo::Dump(const Packet* pkt)
|
||||
bool Foo::Dump(const zeek::Packet* pkt)
|
||||
{
|
||||
double t = double(pkt->ts.tv_sec) + double(pkt->ts.tv_usec) / 1e6;
|
||||
fprintf(stdout, "Dumping to %s: %.6f len %u\n", props.path.c_str(), t, (unsigned int)pkt->len);
|
||||
return true;
|
||||
}
|
||||
|
||||
iosource::PktDumper* Foo::Instantiate(const std::string& path, bool append)
|
||||
zeek::iosource::PktDumper* Foo::Instantiate(const std::string& path, bool append)
|
||||
{
|
||||
return new Foo(path, append);
|
||||
}
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <Val.h>
|
||||
#include <iosource/PktDumper.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Foo : public iosource::PktDumper {
|
||||
class Foo : public zeek::iosource::PktDumper {
|
||||
public:
|
||||
Foo(const std::string& path, bool is_live);
|
||||
virtual ~Foo();
|
||||
|
||||
static PktDumper* Instantiate(const std::string& path, bool append);
|
||||
static zeek::iosource::PktDumper* Instantiate(const std::string& path, bool append);
|
||||
|
||||
protected:
|
||||
virtual void Open();
|
||||
virtual void Close();
|
||||
virtual bool Dump(const Packet* pkt);
|
||||
virtual bool Dump(const zeek::Packet* pkt);
|
||||
|
||||
private:
|
||||
Properties props;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
#include "Foo.h"
|
||||
#include "iosource/Component.h"
|
||||
|
||||
namespace btest::plugin::Demo_Foo { Plugin plugin; }
|
||||
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::iosource::PktDumperComponent("FooPktDumper", "foo", ::plugin::Demo_Foo::Foo::Instantiate));
|
||||
AddComponent(new zeek::iosource::PktDumperComponent("FooPktDumper", "foo", btest::plugin::Demo_Foo::Foo::Instantiate));
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Foo";
|
||||
config.description = "A Foo packet dumper";
|
||||
config.version.major = 1;
|
||||
|
|
17
testing/btest/plugins/pktdumper-plugin/src/Plugin.h
Normal file
17
testing/btest/plugins/pktdumper-plugin/src/Plugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ extern "C" {
|
|||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
Foo::Foo(const std::string& path, bool is_live)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ Foo::Foo(const std::string& path, bool is_live)
|
|||
props.is_live = 0;
|
||||
}
|
||||
|
||||
iosource::PktSrc* Foo::Instantiate(const std::string& path, bool is_live)
|
||||
zeek::iosource::PktSrc* Foo::Instantiate(const std::string& path, bool is_live)
|
||||
{
|
||||
return new Foo(path, is_live);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ void Foo::Close()
|
|||
Closed();
|
||||
}
|
||||
|
||||
bool Foo::ExtractNextPacket(Packet* pkt)
|
||||
bool Foo::ExtractNextPacket(zeek::Packet* pkt)
|
||||
{
|
||||
if ( packet.empty() )
|
||||
{
|
||||
|
|
|
@ -4,19 +4,18 @@
|
|||
#include <Val.h>
|
||||
#include <iosource/PktSrc.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Foo : public iosource::PktSrc {
|
||||
class Foo : public zeek::iosource::PktSrc {
|
||||
public:
|
||||
Foo(const std::string& path, bool is_live);
|
||||
|
||||
static PktSrc* Instantiate(const std::string& path, bool is_live);
|
||||
static zeek::iosource::PktSrc* Instantiate(const std::string& path, bool is_live);
|
||||
|
||||
protected:
|
||||
virtual void Open();
|
||||
virtual void Close();
|
||||
virtual bool ExtractNextPacket(Packet* pkt);
|
||||
virtual bool ExtractNextPacket(zeek::Packet* pkt);
|
||||
virtual void DoneWithPacket();
|
||||
virtual bool PrecompileFilter(int index, const std::string& filter);
|
||||
virtual bool SetFilter(int index);
|
||||
|
@ -28,4 +27,3 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
#include "Foo.h"
|
||||
#include "iosource/Component.h"
|
||||
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Foo { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::iosource::PktSrcComponent("FooPktSrc", "foo", ::iosource::PktSrcComponent::BOTH, ::plugin::Demo_Foo::Foo::Instantiate));
|
||||
AddComponent(new zeek::iosource::PktSrcComponent("FooPktSrc", "foo", zeek::iosource::PktSrcComponent::BOTH,
|
||||
btest::plugin::Demo_Foo::Foo::Instantiate));
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Foo";
|
||||
config.description = "A Foo packet source";
|
||||
config.version.major = 1;
|
||||
|
|
17
testing/btest/plugins/pktsrc-plugin/src/Plugin.h
Normal file
17
testing/btest/plugins/pktsrc-plugin/src/Plugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
#include "Plugin.h"
|
||||
|
||||
namespace plugin { namespace Testing_NoPatchVersion { Plugin plugin; } }
|
||||
namespace btest::plugin::Testing_NoPatchVersion { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Testing_NoPatchVersion;
|
||||
using namespace btest::plugin::Testing_NoPatchVersion;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Testing::NoPatchVersion";
|
||||
config.description = "Testing a plugin without a specified patch version";
|
||||
config.version.major = 0;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Testing_NoPatchVersion {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
#include "Plugin.h"
|
||||
|
||||
namespace plugin { namespace Testing_WithPatchVersion { Plugin plugin; } }
|
||||
namespace btest::plugin::Testing_WithPatchVersion { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Testing_WithPatchVersion;
|
||||
using namespace btest::plugin::Testing_WithPatchVersion;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Testing::WithPatchVersion";
|
||||
config.description = "Testing a plugin with a specified patch version";
|
||||
config.version.major = 0;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Testing_WithPatchVersion {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
#include <analyzer/protocol/tcp/TCP_Reassembler.h>
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
Foo::Foo(Connection* conn)
|
||||
: analyzer::tcp::TCP_ApplicationAnalyzer("Foo", conn)
|
||||
Foo::Foo(zeek::Connection* conn)
|
||||
: zeek::analyzer::tcp::TCP_ApplicationAnalyzer("Foo", conn)
|
||||
{
|
||||
interp = new binpac::Foo::Foo_Conn(this);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ Foo::~Foo()
|
|||
|
||||
void Foo::Done()
|
||||
{
|
||||
analyzer::tcp::TCP_ApplicationAnalyzer::Done();
|
||||
zeek::analyzer::tcp::TCP_ApplicationAnalyzer::Done();
|
||||
|
||||
interp->FlowEOF(true);
|
||||
interp->FlowEOF(false);
|
||||
|
@ -28,13 +28,13 @@ void Foo::Done()
|
|||
|
||||
void Foo::EndpointEOF(bool is_orig)
|
||||
{
|
||||
analyzer::tcp::TCP_ApplicationAnalyzer::EndpointEOF(is_orig);
|
||||
zeek::analyzer::tcp::TCP_ApplicationAnalyzer::EndpointEOF(is_orig);
|
||||
interp->FlowEOF(is_orig);
|
||||
}
|
||||
|
||||
void Foo::DeliverStream(int len, const u_char* data, bool orig)
|
||||
{
|
||||
analyzer::tcp::TCP_ApplicationAnalyzer::DeliverStream(len, data, orig);
|
||||
zeek::analyzer::tcp::TCP_ApplicationAnalyzer::DeliverStream(len, data, orig);
|
||||
|
||||
assert(TCP());
|
||||
|
||||
|
@ -48,12 +48,12 @@ void Foo::DeliverStream(int len, const u_char* data, bool orig)
|
|||
}
|
||||
catch ( const binpac::Exception& e )
|
||||
{
|
||||
ProtocolViolation(fmt("Binpac exception: %s", e.c_msg()));
|
||||
ProtocolViolation(zeek::util::fmt("Binpac exception: %s", e.c_msg()));
|
||||
}
|
||||
}
|
||||
|
||||
void Foo::Undelivered(uint64 seq, int len, bool orig)
|
||||
void Foo::Undelivered(uint64_t seq, int len, bool orig)
|
||||
{
|
||||
analyzer::tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
|
||||
zeek::analyzer::tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
|
||||
interp->NewGap(orig, len);
|
||||
}
|
||||
|
|
|
@ -6,24 +6,23 @@
|
|||
|
||||
namespace binpac { namespace Foo { class Foo_Conn; } }
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Foo : public analyzer::tcp::TCP_ApplicationAnalyzer {
|
||||
class Foo : public zeek::analyzer::tcp::TCP_ApplicationAnalyzer {
|
||||
public:
|
||||
Foo(Connection* conn);
|
||||
Foo(zeek::Connection* conn);
|
||||
~Foo();
|
||||
|
||||
virtual void Done();
|
||||
virtual void DeliverStream(int len, const u_char* data, bool orig);
|
||||
virtual void Undelivered(uint64 seq, int len, bool orig);
|
||||
virtual void Undelivered(uint64_t seq, int len, bool orig);
|
||||
virtual void EndpointEOF(bool is_orig);
|
||||
|
||||
static analyzer::Analyzer* Instantiate(Connection* conn)
|
||||
static zeek::analyzer::Analyzer* Instantiate(zeek::Connection* conn)
|
||||
{ return new Foo(conn); }
|
||||
|
||||
protected:
|
||||
binpac::Foo::Foo_Conn* interp;
|
||||
};
|
||||
|
||||
} }
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
#include "Foo.h"
|
||||
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Foo { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::analyzer::Component("Foo", plugin::Demo_Foo::Foo::Instantiate, 1));
|
||||
AddComponent(new zeek::analyzer::Component("Foo", btest::plugin::Demo_Foo::Foo::Instantiate, 1));
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Foo";
|
||||
config.description = "A Foo test analyzer";
|
||||
config.version.major = 1;
|
||||
|
|
17
testing/btest/plugins/protocol-plugin/src/Plugin.h
Normal file
17
testing/btest/plugins/protocol-plugin/src/Plugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ refine connection Foo_Conn += {
|
|||
|
||||
function Foo_data(msg: Foo_Message): bool
|
||||
%{
|
||||
auto data = zeek::make_intrusive<StringVal>(${msg.data}.length(), (const char*) ${msg.data}.data());
|
||||
auto data = zeek::make_intrusive<zeek::StringVal>(${msg.data}.length(), (const char*) ${msg.data}.data());
|
||||
zeek::BifEvent::enqueue_foo_message(bro_analyzer(), bro_analyzer()->Conn(), std::move(data));
|
||||
return true;
|
||||
%}
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
#include "threading/SerialTypes.h"
|
||||
#include "threading/Manager.h"
|
||||
|
||||
using namespace input::reader;
|
||||
using threading::Value;
|
||||
using threading::Field;
|
||||
using namespace btest::input::reader;
|
||||
using zeek::threading::Value;
|
||||
using zeek::threading::Field;
|
||||
|
||||
Foo::Foo(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||
Foo::Foo(zeek::input::ReaderFrontend *frontend) : zeek::input::ReaderBackend(frontend)
|
||||
{
|
||||
ascii = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo());
|
||||
ascii = new zeek::threading::formatter::Ascii(this, zeek::threading::formatter::Ascii::SeparatorInfo());
|
||||
}
|
||||
|
||||
Foo::~Foo()
|
||||
|
@ -29,7 +29,7 @@ void Foo::DoClose()
|
|||
{
|
||||
}
|
||||
|
||||
bool Foo::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fields)
|
||||
bool Foo::DoInit(const zeek::input::ReaderBackend::ReaderInfo& info, int num_fields, const Field* const* fields)
|
||||
{
|
||||
DoUpdate();
|
||||
return true;
|
||||
|
@ -71,7 +71,7 @@ bool Foo::DoUpdate()
|
|||
return true;
|
||||
}
|
||||
|
||||
threading::Value* Foo::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtype)
|
||||
zeek::threading::Value* Foo::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtype)
|
||||
{
|
||||
Value* val = new Value(type, true);
|
||||
|
||||
|
|
|
@ -4,28 +4,29 @@
|
|||
#include "input/ReaderBackend.h"
|
||||
#include "threading/formatters/Ascii.h"
|
||||
|
||||
namespace input { namespace reader {
|
||||
namespace btest::input::reader {
|
||||
|
||||
/**
|
||||
* A Foo reader to measure performance of the input framework.
|
||||
*/
|
||||
class Foo : public ReaderBackend {
|
||||
class Foo : public zeek::input::ReaderBackend {
|
||||
public:
|
||||
Foo(ReaderFrontend* frontend);
|
||||
Foo(zeek::input::ReaderFrontend* frontend);
|
||||
~Foo();
|
||||
|
||||
static ReaderBackend* Instantiate(ReaderFrontend* frontend) { return new Foo(frontend); }
|
||||
static zeek::input::ReaderBackend* Instantiate(zeek::input::ReaderFrontend* frontend) { return new Foo(frontend); }
|
||||
|
||||
protected:
|
||||
virtual bool DoInit(const ReaderInfo& info, int arg_num_fields, const threading::Field* const* fields);
|
||||
virtual bool DoInit(const zeek::input::ReaderBackend::ReaderInfo& info, int arg_num_fields,
|
||||
const zeek::threading::Field* const* fields);
|
||||
virtual void DoClose();
|
||||
virtual bool DoUpdate();
|
||||
virtual bool DoHeartbeat(double network_time, double current_time);
|
||||
|
||||
private:
|
||||
std::string RandomString(const int len);
|
||||
threading::Value* EntryToVal(zeek::TypeTag Type, zeek::TypeTag subtype);
|
||||
threading::formatter::Ascii* ascii;
|
||||
zeek::threading::Value* EntryToVal(zeek::TypeTag Type, zeek::TypeTag subtype);
|
||||
zeek::threading::formatter::Ascii* ascii;
|
||||
};
|
||||
|
||||
} }
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
#include "Foo.h"
|
||||
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Foo { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::input::Component("Foo", ::input::reader::Foo::Instantiate));
|
||||
AddComponent(new zeek::input::Component("Foo", btest::input::reader::Foo::Instantiate));
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Foo";
|
||||
config.description = "A Foo test input reader";
|
||||
config.version.major = 1;
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Plugin : public ::plugin::Plugin
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from plugin::Plugin.
|
||||
virtual plugin::Configuration Configure();
|
||||
virtual zeek::plugin::Configuration Configure();
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
#include <Desc.h>
|
||||
#include <threading/Formatter.h>
|
||||
|
||||
namespace plugin { namespace Reporter_Hook { Plugin plugin; } }
|
||||
namespace btest::plugin::Reporter_Hook { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Reporter_Hook;
|
||||
using namespace btest::plugin::Reporter_Hook;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
EnableHook(HOOK_REPORTER);
|
||||
EnableHook(zeek::plugin::HOOK_REPORTER);
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Reporter::Hook";
|
||||
config.description = "Exercise Reporter Hook";
|
||||
config.version.major = 1;
|
||||
|
@ -24,12 +24,12 @@ plugin::Configuration Plugin::Configure()
|
|||
return config;
|
||||
}
|
||||
|
||||
bool Plugin::HookReporter(const std::string& prefix, const EventHandlerPtr event,
|
||||
const Connection* conn, const val_list* addl, bool location,
|
||||
const Location* location1, const Location* location2,
|
||||
bool Plugin::HookReporter(const std::string& prefix, const zeek::EventHandlerPtr event,
|
||||
const zeek::Connection* conn, const zeek::ValPList* addl, bool location,
|
||||
const zeek::detail::Location* location1, const zeek::detail::Location* location2,
|
||||
bool time, const std::string& message)
|
||||
{
|
||||
ODesc d;
|
||||
zeek::ODesc d;
|
||||
if ( location1 )
|
||||
location1->Describe(&d);
|
||||
if ( location2 )
|
||||
|
@ -42,4 +42,3 @@ bool Plugin::HookReporter(const std::string& prefix, const EventHandlerPtr event
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,22 +3,20 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Reporter_Hook {
|
||||
namespace btest::plugin::Reporter_Hook {
|
||||
|
||||
class Plugin : public ::plugin::Plugin
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
bool HookReporter(const std::string& prefix, const EventHandlerPtr event,
|
||||
const Connection* conn, const val_list* addl, bool location,
|
||||
const Location* location1, const Location* location2,
|
||||
bool HookReporter(const std::string& prefix, const zeek::EventHandlerPtr event,
|
||||
const zeek::Connection* conn, const zeek::ValPList* addl, bool location,
|
||||
const zeek::detail::Location* location1, const zeek::detail::Location* location2,
|
||||
bool time, const std::string& buffer) override;
|
||||
|
||||
// Overridden from plugin::Plugin.
|
||||
plugin::Configuration Configure() override;
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
|
||||
#include "Foo.h"
|
||||
|
||||
using namespace logging;
|
||||
using namespace writer;
|
||||
using namespace btest::logging::writer;
|
||||
|
||||
bool Foo::DoInit(const WriterInfo& info, int num_fields,
|
||||
const threading::Field* const * fields)
|
||||
Foo::~Foo()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
|
||||
bool Foo::DoInit(const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const * fields)
|
||||
{
|
||||
desc.EnableEscaping();
|
||||
desc.AddEscapeSequence("|");
|
||||
threading::formatter::Ascii::SeparatorInfo sep_info("|", ",", "-", "");
|
||||
formatter = new threading::formatter::Ascii(this, sep_info);
|
||||
zeek::threading::formatter::Ascii::SeparatorInfo sep_info("|", ",", "-", "");
|
||||
formatter = new zeek::threading::formatter::Ascii(this, sep_info);
|
||||
path = info.path;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Foo::DoWrite(int num_fields, const threading::Field* const* fields,
|
||||
threading::Value** vals)
|
||||
bool Foo::DoWrite(int num_fields, const zeek::threading::Field* const* fields,
|
||||
zeek::threading::Value** vals)
|
||||
{
|
||||
desc.Clear();
|
||||
|
||||
|
@ -28,4 +32,3 @@ bool Foo::DoWrite(int num_fields, const threading::Field* const* fields,
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
#include "threading/formatters/Ascii.h"
|
||||
#include "Desc.h"
|
||||
|
||||
namespace logging { namespace writer {
|
||||
namespace btest::logging::writer {
|
||||
|
||||
class Foo : public WriterBackend {
|
||||
class Foo : public zeek::logging::WriterBackend {
|
||||
public:
|
||||
Foo(WriterFrontend* frontend) : WriterBackend(frontend) {}
|
||||
~Foo() {};
|
||||
Foo(zeek::logging::WriterFrontend* frontend) : zeek::logging::WriterBackend(frontend) {}
|
||||
~Foo();
|
||||
|
||||
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
||||
static zeek::logging::WriterBackend* Instantiate(zeek::logging::WriterFrontend* frontend)
|
||||
{ return new Foo(frontend); }
|
||||
|
||||
protected:
|
||||
virtual bool DoInit(const WriterInfo& info, int num_fields,
|
||||
const threading::Field* const * fields);
|
||||
virtual bool DoInit(const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const * fields);
|
||||
|
||||
virtual bool DoWrite(int num_fields, const threading::Field* const* fields,
|
||||
threading::Value** vals);
|
||||
virtual bool DoWrite(int num_fields, const zeek::threading::Field* const* fields,
|
||||
zeek::threading::Value** vals);
|
||||
virtual bool DoSetBuf(bool enabled) { return true; }
|
||||
virtual bool DoRotate(const char* rotated_path, double open,
|
||||
double close, bool terminating) { return true; }
|
||||
|
@ -30,8 +30,8 @@ protected:
|
|||
|
||||
private:
|
||||
std::string path;
|
||||
ODesc desc;
|
||||
threading::formatter::Formatter* formatter;
|
||||
zeek::ODesc desc;
|
||||
zeek::threading::Formatter* formatter;
|
||||
};
|
||||
|
||||
} }
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
#include "Foo.h"
|
||||
|
||||
namespace plugin { namespace Demo_Foo { Plugin plugin; } }
|
||||
namespace btest::plugin::Demo_Foo { Plugin plugin; }
|
||||
|
||||
using namespace plugin::Demo_Foo;
|
||||
using namespace btest::plugin::Demo_Foo;
|
||||
|
||||
plugin::Configuration Plugin::Configure()
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
AddComponent(new ::logging::Component("Foo", ::logging::writer::Foo::Instantiate));
|
||||
AddComponent(new zeek::logging::Component("Foo", btest::logging::writer::Foo::Instantiate));
|
||||
|
||||
plugin::Configuration config;
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Foo";
|
||||
config.description = "A Foo test logging writer";
|
||||
config.version.major = 1;
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace plugin {
|
||||
namespace Demo_Foo {
|
||||
namespace btest::plugin::Demo_Foo {
|
||||
|
||||
class Plugin : public ::plugin::Plugin
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from plugin::Plugin.
|
||||
virtual plugin::Configuration Configure();
|
||||
virtual zeek::plugin::Configuration Configure();
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue