Minor API changes to analyzers.

This commit is contained in:
Robin Sommer 2013-11-26 11:22:23 -08:00
parent d34f23c8d4
commit d727af097b
6 changed files with 27 additions and 12 deletions

View file

@ -644,12 +644,12 @@ void Analyzer::FlipRoles()
resp_supporters = tmp; resp_supporters = tmp;
} }
void Analyzer::ProtocolConfirmation() void Analyzer::ProtocolConfirmation(Tag arg_tag)
{ {
if ( protocol_confirmed ) if ( protocol_confirmed )
return; return;
EnumVal* tval = tag.AsEnumVal(); EnumVal* tval = arg_tag ? arg_tag.AsEnumVal() : tag.AsEnumVal();
Ref(tval); Ref(tval);
val_list* vl = new val_list; val_list* vl = new val_list;

View file

@ -97,8 +97,8 @@ public:
/** /**
* Constructor. As this version of the constructor does not receive a * Constructor. As this version of the constructor does not receive a
* name or tag, setTag() must be called before the instance can be * name or tag, SetAnalyzerTag() must be called before the instance
* used. * can be used.
* *
* @param conn The connection the analyzer is associated with. * @param conn The connection the analyzer is associated with.
*/ */
@ -471,8 +471,11 @@ public:
* may turn into \c protocol_confirmed event at the script-layer (but * may turn into \c protocol_confirmed event at the script-layer (but
* only once per analyzer for each connection, even if the method is * only once per analyzer for each connection, even if the method is
* called multiple times). * called multiple times).
*
* If tag is given, it overrides the analyzer tag passed to the
* scripting layer; the default is the one of the analyzer itself.
*/ */
virtual void ProtocolConfirmation(); virtual void ProtocolConfirmation(Tag tag = Tag());
/** /**
* Signals Bro's protocol detection that the analyzer has found a * Signals Bro's protocol detection that the analyzer has found a

View file

@ -17,6 +17,8 @@ Component::Component(const char* arg_name, factory_callback arg_factory, Tag::su
factory = arg_factory; factory = arg_factory;
enabled = arg_enabled; enabled = arg_enabled;
partial = arg_partial; partial = arg_partial;
analyzer_mgr->RegisterComponent(this, "ANALYZER_");
} }
Component::Component(const Component& other) Component::Component(const Component& other)
@ -28,6 +30,8 @@ Component::Component(const Component& other)
factory = other.factory; factory = other.factory;
enabled = other.enabled; enabled = other.enabled;
partial = other.partial; partial = other.partial;
// TODO: Do we need the RegisterComponent() call here?
} }
Component::~Component() Component::~Component()

View file

@ -86,11 +86,6 @@ Manager::~Manager()
void Manager::InitPreScript() void Manager::InitPreScript()
{ {
std::list<Component*> analyzers = plugin_mgr->Components<Component>();
for ( std::list<Component*>::const_iterator i = analyzers.begin(); i != analyzers.end(); i++ )
RegisterComponent(*i, "ANALYZER_");
// Cache these tags. // Cache these tags.
analyzer_backdoor = GetComponentTag("BACKDOOR"); analyzer_backdoor = GetComponentTag("BACKDOOR");
analyzer_connsize = GetComponentTag("CONNSIZE"); analyzer_connsize = GetComponentTag("CONNSIZE");
@ -202,6 +197,11 @@ void Manager::DisableAllAnalyzers()
(*i)->SetEnabled(false); (*i)->SetEnabled(false);
} }
analyzer::Tag Manager::GetAnalyzerTag(const char* name)
{
return GetComponentTag(name);
}
bool Manager::IsEnabled(Tag tag) bool Manager::IsEnabled(Tag tag)
{ {
if ( ! tag ) if ( ! tag )

View file

@ -133,6 +133,14 @@ public:
*/ */
void DisableAllAnalyzers(); void DisableAllAnalyzers();
/**
* Returns the tag associated with an analyer name, or the tag
* associated with an error if no such analyzer exists.
*
* @param name The canonical analyzer name to check.
*/
Tag GetAnalyzerTag(const char* name);
/** /**
* Returns true if an analyzer is enabled. * Returns true if an analyzer is enabled.
* *

View file

@ -294,8 +294,8 @@ public:
// TCP_ENDPOINT_RESET. If gen_event is true and the connection // TCP_ENDPOINT_RESET. If gen_event is true and the connection
// is now fully closed, a connection_finished event will be // is now fully closed, a connection_finished event will be
// generated; otherwise not. // generated; otherwise not.
virtual void ConnectionClosed(TCP_Endpoint* endpoint, virtual void ConnectionClosed(analyzer::tcp::TCP_Endpoint* endpoint,
TCP_Endpoint* peer, int gen_event); analyzer::tcp::TCP_Endpoint* peer, int gen_event);
virtual void ConnectionFinished(int half_finished); virtual void ConnectionFinished(int half_finished);
virtual void ConnectionReset(); virtual void ConnectionReset();