Update plugin btests for namespace changes

This commit is contained in:
Tim Wojtulewicz 2020-08-21 18:10:39 +00:00
parent 70c2397f69
commit 874e170341
43 changed files with 420 additions and 317 deletions

View file

@ -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);
}

View file

@ -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;
};
} }
}

View file

@ -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;

View 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;
}

View file

@ -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;
%}