mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Moving Pkt{Src,Dumper} a directory level up.
Also renaming PktSourceComponent to PktSrcComponent.
This commit is contained in:
parent
ecf1e32f60
commit
caa55ad352
23 changed files with 274 additions and 311 deletions
|
@ -1,10 +1,4 @@
|
||||||
- Move the current_{iosrc,pkt_src,etc.} into manager
|
|
||||||
- Remove all 2ndary path code
|
|
||||||
- Remove all flow src code.
|
|
||||||
- Move pktsrc/*.{h,cc} up a level? Or create a subsublibrary there?
|
|
||||||
- Create a global Packet data structure and pass that around instead
|
|
||||||
of the pcap_* stuff?
|
|
||||||
- PktDumper: Move Dump() to public and remove Record()
|
- PktDumper: Move Dump() to public and remove Record()
|
||||||
- Wrap BPF_Program into namespace and clean up
|
- Wrap BPF_Program into namespace and clean up
|
||||||
- Tests, in particular the packet dumping needs testing.
|
|
||||||
- Add an interface for derived pkt source to run a BPF filter.
|
- Add an interface for derived pkt source to run a BPF filter.
|
||||||
|
- Tests, in particular the packet dumping needs testing.
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
#include "Serializer.h"
|
#include "Serializer.h"
|
||||||
#include "PacketDumper.h"
|
#include "PacketDumper.h"
|
||||||
#include "iosource/Manager.h"
|
#include "iosource/Manager.h"
|
||||||
#include "iosource/pktsrc/PktSrc.h"
|
#include "iosource/PktSrc.h"
|
||||||
#include "iosource/pktsrc/PktDumper.h"
|
#include "iosource/PktDumper.h"
|
||||||
#include "plugin/Manager.h"
|
#include "plugin/Manager.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
#include "Func.h"
|
#include "Func.h"
|
||||||
#include "RemoteSerializer.h"
|
#include "RemoteSerializer.h"
|
||||||
#include "iosource/IOSource.h"
|
#include "iosource/IOSource.h"
|
||||||
#include "iosource/pktsrc/PktSrc.h"
|
#include "iosource/PktSrc.h"
|
||||||
#include "iosource/pktsrc/PktDumper.h"
|
#include "iosource/PktDumper.h"
|
||||||
|
|
||||||
extern void net_init(name_list& interfaces, name_list& readfiles,
|
extern void net_init(name_list& interfaces, name_list& readfiles,
|
||||||
const char* writefile, const char* filter,
|
const char* writefile, const char* filter,
|
||||||
|
|
|
@ -6,15 +6,11 @@ include_directories(BEFORE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(pktsrc)
|
|
||||||
|
|
||||||
set(iosource_SRCS
|
set(iosource_SRCS
|
||||||
Component.cc
|
Component.cc
|
||||||
Manager.cc
|
Manager.cc
|
||||||
|
PktDumper.cc
|
||||||
pktsrc/Component.cc
|
PktSrc.cc
|
||||||
pktsrc/PktDumper.cc
|
|
||||||
pktsrc/PktSrc.cc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
bro_add_subdir_library(iosource ${iosource_SRCS})
|
bro_add_subdir_library(iosource ${iosource_SRCS})
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
|
|
||||||
#include "Desc.h"
|
#include "Desc.h"
|
||||||
|
#include "Reporter.h"
|
||||||
|
|
||||||
using namespace iosource;
|
using namespace iosource;
|
||||||
|
|
||||||
|
@ -18,3 +19,149 @@ Component::Component(plugin::component::Type type, const std::string& name)
|
||||||
Component::~Component()
|
Component::~Component()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PktSrcComponent::PktSrcComponent(const std::string& arg_name, const std::string& arg_prefix, InputType arg_type, factory_callback arg_factory)
|
||||||
|
: iosource::Component(plugin::component::PKTSRC, arg_name)
|
||||||
|
{
|
||||||
|
tokenize_string(arg_prefix, ":", &prefixes);
|
||||||
|
type = arg_type;
|
||||||
|
factory = arg_factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
PktSrcComponent::~PktSrcComponent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& PktSrcComponent::Prefixes() const
|
||||||
|
{
|
||||||
|
return prefixes;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PktSrcComponent::HandlesPrefix(const string& prefix) const
|
||||||
|
{
|
||||||
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
|
i != prefixes.end(); i++ )
|
||||||
|
{
|
||||||
|
if ( *i == prefix )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PktSrcComponent::DoesLive() const
|
||||||
|
{
|
||||||
|
return type == LIVE || type == BOTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PktSrcComponent::DoesTrace() const
|
||||||
|
{
|
||||||
|
return type == TRACE || type == BOTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
PktSrcComponent::factory_callback PktSrcComponent::Factory() const
|
||||||
|
{
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PktSrcComponent::Describe(ODesc* d) const
|
||||||
|
{
|
||||||
|
iosource::Component::Describe(d);
|
||||||
|
|
||||||
|
string prefs;
|
||||||
|
|
||||||
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
|
i != prefixes.end(); i++ )
|
||||||
|
{
|
||||||
|
if ( prefs.size() )
|
||||||
|
prefs += ", ";
|
||||||
|
|
||||||
|
prefs += *i;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->Add(" (interface prefix");
|
||||||
|
if ( prefixes.size() > 1 )
|
||||||
|
d->Add("es");
|
||||||
|
|
||||||
|
d->Add(": ");
|
||||||
|
d->Add(prefs);
|
||||||
|
d->Add("; ");
|
||||||
|
|
||||||
|
switch ( type ) {
|
||||||
|
case LIVE:
|
||||||
|
d->Add("live input");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRACE:
|
||||||
|
d->Add("trace input");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BOTH:
|
||||||
|
d->Add("live and trace input");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
reporter->InternalError("unknown PkrSrc type");
|
||||||
|
}
|
||||||
|
|
||||||
|
d->Add(")");
|
||||||
|
}
|
||||||
|
|
||||||
|
PktDumperComponent::PktDumperComponent(const std::string& name, const std::string& arg_prefix, factory_callback arg_factory)
|
||||||
|
: plugin::Component(plugin::component::PKTDUMPER, name)
|
||||||
|
{
|
||||||
|
tokenize_string(arg_prefix, ":", &prefixes);
|
||||||
|
factory = arg_factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
PktDumperComponent::~PktDumperComponent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PktDumperComponent::factory_callback PktDumperComponent::Factory() const
|
||||||
|
{
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& PktDumperComponent::Prefixes() const
|
||||||
|
{
|
||||||
|
return prefixes;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PktDumperComponent::HandlesPrefix(const string& prefix) const
|
||||||
|
{
|
||||||
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
|
i != prefixes.end(); i++ )
|
||||||
|
{
|
||||||
|
if ( *i == prefix )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PktDumperComponent::Describe(ODesc* d) const
|
||||||
|
{
|
||||||
|
plugin::Component::Describe(d);
|
||||||
|
|
||||||
|
string prefs;
|
||||||
|
|
||||||
|
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
||||||
|
i != prefixes.end(); i++ )
|
||||||
|
{
|
||||||
|
if ( prefs.size() )
|
||||||
|
prefs += ", ";
|
||||||
|
|
||||||
|
prefs += *i;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->Add(" (dumper prefix");
|
||||||
|
|
||||||
|
if ( prefixes.size() > 1 )
|
||||||
|
d->Add("es");
|
||||||
|
|
||||||
|
d->Add(": ");
|
||||||
|
d->Add(prefs);
|
||||||
|
d->Add(")");
|
||||||
|
}
|
||||||
|
|
|
@ -3,11 +3,16 @@
|
||||||
#ifndef IOSOURCE_PLUGIN_COMPONENT_H
|
#ifndef IOSOURCE_PLUGIN_COMPONENT_H
|
||||||
#define IOSOURCE_PLUGIN_COMPONENT_H
|
#define IOSOURCE_PLUGIN_COMPONENT_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "plugin/Component.h"
|
#include "plugin/Component.h"
|
||||||
|
|
||||||
namespace iosource {
|
namespace iosource {
|
||||||
|
|
||||||
class IOSource;
|
class IOSource;
|
||||||
|
class PktSrc;
|
||||||
|
class PktDumper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component description for plugins providing IOSources.
|
* Component description for plugins providing IOSources.
|
||||||
|
@ -38,6 +43,110 @@ protected:
|
||||||
Component(plugin::component::Type type, const std::string& name);
|
Component(plugin::component::Type type, const std::string& name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component description for plugins providing a PktSrc for packet input.
|
||||||
|
*/
|
||||||
|
class PktSrcComponent : public iosource::Component {
|
||||||
|
public:
|
||||||
|
enum InputType { LIVE, TRACE, BOTH };
|
||||||
|
|
||||||
|
typedef PktSrc* (*factory_callback)(const std::string& path, const std::string& filter, bool is_live);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XXX
|
||||||
|
*/
|
||||||
|
PktSrcComponent(const std::string& name, const std::string& prefixes, InputType type, factory_callback factory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~PktSrcComponent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the prefix(es) passed to the constructor.
|
||||||
|
*/
|
||||||
|
const std::vector<std::string>& Prefixes() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given prefix is among the one specified for the component.
|
||||||
|
*/
|
||||||
|
bool HandlesPrefix(const std::string& prefix) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if packet source instantiated by the component handle
|
||||||
|
* live traffic.
|
||||||
|
*/
|
||||||
|
bool DoesLive() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if packet source instantiated by the component handle
|
||||||
|
* offline traces.
|
||||||
|
*/
|
||||||
|
bool DoesTrace() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the source's factory function.
|
||||||
|
*/
|
||||||
|
factory_callback Factory() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a human-readable description of the component. This goes
|
||||||
|
* into the output of \c "bro -NN".
|
||||||
|
*/
|
||||||
|
virtual void Describe(ODesc* d) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::string> prefixes;
|
||||||
|
InputType type;
|
||||||
|
factory_callback factory;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component description for plugins providing a PktDumper for packet output.
|
||||||
|
*
|
||||||
|
* PktDumpers aren't IOSurces but we locate them here to keep them along with
|
||||||
|
* the PktSrc.
|
||||||
|
*/
|
||||||
|
class PktDumperComponent : public plugin::Component {
|
||||||
|
public:
|
||||||
|
typedef PktDumper* (*factory_callback)(const std::string& path, bool append);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XXX
|
||||||
|
*/
|
||||||
|
PktDumperComponent(const std::string& name, const std::string& prefixes, factory_callback factory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~PktDumperComponent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the prefix(es) passed to the constructor.
|
||||||
|
*/
|
||||||
|
const std::vector<std::string>& Prefixes() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given prefix is among the one specified for the component.
|
||||||
|
*/
|
||||||
|
bool HandlesPrefix(const std::string& prefix) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the source's factory function.
|
||||||
|
*/
|
||||||
|
factory_callback Factory() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a human-readable description of the component. This goes
|
||||||
|
* into the output of \c "bro -NN".
|
||||||
|
*/
|
||||||
|
virtual void Describe(ODesc* d) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::string> prefixes;
|
||||||
|
factory_callback factory;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
|
|
||||||
#include "Manager.h"
|
#include "Manager.h"
|
||||||
#include "IOSource.h"
|
#include "IOSource.h"
|
||||||
#include "pktsrc/PktSrc.h"
|
#include "PktSrc.h"
|
||||||
#include "pktsrc/PktDumper.h"
|
#include "PktDumper.h"
|
||||||
#include "pktsrc/Component.h"
|
|
||||||
#include "plugin/Manager.h"
|
#include "plugin/Manager.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -222,14 +221,14 @@ PktSrc* Manager::OpenPktSrc(const std::string& path, const std::string& filter,
|
||||||
|
|
||||||
// Find the component providing packet sources of the requested prefix.
|
// Find the component providing packet sources of the requested prefix.
|
||||||
|
|
||||||
pktsrc::SourceComponent* component = 0;
|
PktSrcComponent* component = 0;
|
||||||
|
|
||||||
std::list<pktsrc::SourceComponent*> all_components = plugin_mgr->Components<pktsrc::SourceComponent>();
|
std::list<PktSrcComponent*> all_components = plugin_mgr->Components<PktSrcComponent>();
|
||||||
|
|
||||||
for ( std::list<pktsrc::SourceComponent*>::const_iterator i = all_components.begin();
|
for ( std::list<PktSrcComponent*>::const_iterator i = all_components.begin();
|
||||||
i != all_components.end(); i++ )
|
i != all_components.end(); i++ )
|
||||||
{
|
{
|
||||||
pktsrc::SourceComponent* c = *i;
|
PktSrcComponent* c = *i;
|
||||||
|
|
||||||
if ( c->HandlesPrefix(prefix) &&
|
if ( c->HandlesPrefix(prefix) &&
|
||||||
(( is_live && c->DoesLive() ) ||
|
(( is_live && c->DoesLive() ) ||
|
||||||
|
@ -272,11 +271,11 @@ PktDumper* Manager::OpenPktDumper(const string& path, bool append)
|
||||||
|
|
||||||
// Find the component providing packet dumpers of the requested prefix.
|
// Find the component providing packet dumpers of the requested prefix.
|
||||||
|
|
||||||
pktsrc::DumperComponent* component = 0;
|
PktDumperComponent* component = 0;
|
||||||
|
|
||||||
std::list<pktsrc::DumperComponent*> all_components = plugin_mgr->Components<pktsrc::DumperComponent>();
|
std::list<PktDumperComponent*> all_components = plugin_mgr->Components<PktDumperComponent>();
|
||||||
|
|
||||||
for ( std::list<pktsrc::DumperComponent*>::const_iterator i = all_components.begin();
|
for ( std::list<PktDumperComponent*>::const_iterator i = all_components.begin();
|
||||||
i != all_components.end(); i++ )
|
i != all_components.end(); i++ )
|
||||||
{
|
{
|
||||||
if ( (*i)->HandlesPrefix(prefix) )
|
if ( (*i)->HandlesPrefix(prefix) )
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#ifndef IOSOURCE_PKTSRC_PKTDUMPER_H
|
#ifndef IOSOURCE_PKTSRC_PKTDUMPER_H
|
||||||
#define IOSOURCE_PKTSRC_PKTDUMPER_H
|
#define IOSOURCE_PKTSRC_PKTDUMPER_H
|
||||||
|
|
||||||
#include "../IOSource.h"
|
#include "IOSource.h"
|
||||||
|
|
||||||
namespace iosource {
|
namespace iosource {
|
||||||
|
|
|
@ -7,7 +7,7 @@ extern "C" {
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "../IOSource.h"
|
#include "IOSource.h"
|
||||||
|
|
||||||
namespace iosource {
|
namespace iosource {
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
|
|
||||||
add_subdirectory(pcap)
|
|
|
@ -1,155 +0,0 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
|
||||||
|
|
||||||
#include "Component.h"
|
|
||||||
|
|
||||||
#include "../Desc.h"
|
|
||||||
#include "../Reporter.h"
|
|
||||||
|
|
||||||
using namespace iosource::pktsrc;
|
|
||||||
|
|
||||||
SourceComponent::SourceComponent(const std::string& arg_name, const std::string& arg_prefix, InputType arg_type, factory_callback arg_factory)
|
|
||||||
: iosource::Component(plugin::component::PKTSRC, arg_name)
|
|
||||||
{
|
|
||||||
tokenize_string(arg_prefix, ":", &prefixes);
|
|
||||||
type = arg_type;
|
|
||||||
factory = arg_factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceComponent::~SourceComponent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<std::string>& SourceComponent::Prefixes() const
|
|
||||||
{
|
|
||||||
return prefixes;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SourceComponent::HandlesPrefix(const string& prefix) const
|
|
||||||
{
|
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
|
||||||
i != prefixes.end(); i++ )
|
|
||||||
{
|
|
||||||
if ( *i == prefix )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SourceComponent::DoesLive() const
|
|
||||||
{
|
|
||||||
return type == LIVE || type == BOTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SourceComponent::DoesTrace() const
|
|
||||||
{
|
|
||||||
return type == TRACE || type == BOTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceComponent::factory_callback SourceComponent::Factory() const
|
|
||||||
{
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SourceComponent::Describe(ODesc* d) const
|
|
||||||
{
|
|
||||||
iosource::Component::Describe(d);
|
|
||||||
|
|
||||||
string prefs;
|
|
||||||
|
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
|
||||||
i != prefixes.end(); i++ )
|
|
||||||
{
|
|
||||||
if ( prefs.size() )
|
|
||||||
prefs += ", ";
|
|
||||||
|
|
||||||
prefs += *i;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->Add(" (interface prefix");
|
|
||||||
if ( prefixes.size() > 1 )
|
|
||||||
d->Add("es");
|
|
||||||
|
|
||||||
d->Add(": ");
|
|
||||||
d->Add(prefs);
|
|
||||||
d->Add("; ");
|
|
||||||
|
|
||||||
switch ( type ) {
|
|
||||||
case LIVE:
|
|
||||||
d->Add("live input");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TRACE:
|
|
||||||
d->Add("trace input");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BOTH:
|
|
||||||
d->Add("live and trace input");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
reporter->InternalError("unknown PkrSrc type");
|
|
||||||
}
|
|
||||||
|
|
||||||
d->Add(")");
|
|
||||||
}
|
|
||||||
|
|
||||||
DumperComponent::DumperComponent(const std::string& name, const std::string& arg_prefix, factory_callback arg_factory)
|
|
||||||
: plugin::Component(plugin::component::PKTDUMPER, name)
|
|
||||||
{
|
|
||||||
tokenize_string(arg_prefix, ":", &prefixes);
|
|
||||||
factory = arg_factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
DumperComponent::~DumperComponent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DumperComponent::factory_callback DumperComponent::Factory() const
|
|
||||||
{
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<std::string>& DumperComponent::Prefixes() const
|
|
||||||
{
|
|
||||||
return prefixes;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DumperComponent::HandlesPrefix(const string& prefix) const
|
|
||||||
{
|
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
|
||||||
i != prefixes.end(); i++ )
|
|
||||||
{
|
|
||||||
if ( *i == prefix )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DumperComponent::Describe(ODesc* d) const
|
|
||||||
{
|
|
||||||
plugin::Component::Describe(d);
|
|
||||||
|
|
||||||
string prefs;
|
|
||||||
|
|
||||||
for ( std::vector<std::string>::const_iterator i = prefixes.begin();
|
|
||||||
i != prefixes.end(); i++ )
|
|
||||||
{
|
|
||||||
if ( prefs.size() )
|
|
||||||
prefs += ", ";
|
|
||||||
|
|
||||||
prefs += *i;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->Add(" (dumper prefix");
|
|
||||||
|
|
||||||
if ( prefixes.size() > 1 )
|
|
||||||
d->Add("es");
|
|
||||||
|
|
||||||
d->Add(": ");
|
|
||||||
d->Add(prefs);
|
|
||||||
d->Add(")");
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,124 +0,0 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
|
||||||
|
|
||||||
#ifndef IOSOURCE_PKTSRC_PLUGIN_COMPONENT_H
|
|
||||||
#define IOSOURCE_PKTSRC_PLUGIN_COMPONENT_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "../Component.h"
|
|
||||||
|
|
||||||
namespace iosource {
|
|
||||||
|
|
||||||
class PktSrc;
|
|
||||||
class PktDumper;
|
|
||||||
|
|
||||||
namespace pktsrc {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Component description for plugins providing a PktSrc for packet input.
|
|
||||||
*/
|
|
||||||
class SourceComponent : public iosource::Component {
|
|
||||||
public:
|
|
||||||
enum InputType { LIVE, TRACE, BOTH };
|
|
||||||
|
|
||||||
typedef PktSrc* (*factory_callback)(const std::string& path, const std::string& filter, bool is_live);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XXX
|
|
||||||
*/
|
|
||||||
SourceComponent(const std::string& name, const std::string& prefixes, InputType type, factory_callback factory);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~SourceComponent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the prefix(es) passed to the constructor.
|
|
||||||
*/
|
|
||||||
const std::vector<std::string>& Prefixes() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the given prefix is among the one specified for the component.
|
|
||||||
*/
|
|
||||||
bool HandlesPrefix(const std::string& prefix) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if packet source instantiated by the component handle
|
|
||||||
* live traffic.
|
|
||||||
*/
|
|
||||||
bool DoesLive() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if packet source instantiated by the component handle
|
|
||||||
* offline traces.
|
|
||||||
*/
|
|
||||||
bool DoesTrace() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the source's factory function.
|
|
||||||
*/
|
|
||||||
factory_callback Factory() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a human-readable description of the component. This goes
|
|
||||||
* into the output of \c "bro -NN".
|
|
||||||
*/
|
|
||||||
virtual void Describe(ODesc* d) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::string> prefixes;
|
|
||||||
InputType type;
|
|
||||||
factory_callback factory;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Component description for plugins providing a PktDumper for packet output.
|
|
||||||
*
|
|
||||||
* PktDumpers aren't IOSurces but we locate them here to keep them along with
|
|
||||||
* the PktSrc.
|
|
||||||
*/
|
|
||||||
class DumperComponent : public plugin::Component {
|
|
||||||
public:
|
|
||||||
typedef PktDumper* (*factory_callback)(const std::string& path, bool append);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XXX
|
|
||||||
*/
|
|
||||||
DumperComponent(const std::string& name, const std::string& prefixes, factory_callback factory);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor.
|
|
||||||
*/
|
|
||||||
~DumperComponent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the prefix(es) passed to the constructor.
|
|
||||||
*/
|
|
||||||
const std::vector<std::string>& Prefixes() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the given prefix is among the one specified for the component.
|
|
||||||
*/
|
|
||||||
bool HandlesPrefix(const std::string& prefix) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the source's factory function.
|
|
||||||
*/
|
|
||||||
factory_callback Factory() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a human-readable description of the component. This goes
|
|
||||||
* into the output of \c "bro -NN".
|
|
||||||
*/
|
|
||||||
virtual void Describe(ODesc* d) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::string> prefixes;
|
|
||||||
factory_callback factory;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "analyzer/Component.h"
|
#include "analyzer/Component.h"
|
||||||
#include "file_analysis/Component.h"
|
#include "file_analysis/Component.h"
|
||||||
#include "iosource/Component.h"
|
#include "iosource/Component.h"
|
||||||
#include "iosource/pktsrc/Component.h"
|
|
||||||
|
|
||||||
// We allow to override this externally for testing purposes.
|
// We allow to override this externally for testing purposes.
|
||||||
#ifndef BRO_PLUGIN_API_VERSION
|
#ifndef BRO_PLUGIN_API_VERSION
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue