mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00

There's now a new directory "src/protocols/", and the plan is for each protocol analyzer to eventually have its own subdirectory in there that contains everything it defines (C++/pac/bif). The infrastructure to make that happen is in place, and two analyzers have been converted to the new model, HTTP and SSL; there's no further HTTP/SSL-specific code anywhere else in the core anymore (I believe :-) Further changes: - -N lists available plugins, -NN lists more details on what these plugins provide (analyzers, bif elements). (The latter does not work for analyzers that haven't been converted yet). - *.bif.bro files now go into scripts/base/bif/; and scripts/base/bif/plugins/ for bif files provided by plugins. - I've factored out the bifcl/binpac CMake magic from src/CMakeLists.txt to cmake/{BifCl,Binpac} - There's a new cmake/BroPlugin that contains magic to allow plugins to have a simple CMakeLists.txt. The hope is that eventually the same CMakeLists.txt can be used for compiling a plugin either statically or dynamically. - bifcl has a new option -c that changes the code it generates so that it can be used with a plugin. TODOs: - "make install" is probably broken. - Broxygen is probably broken for plugin-defined events. - event groups are broken (do we want to keep them?)
122 lines
2.4 KiB
C++
122 lines
2.4 KiB
C++
#include "EventRegistry.h"
|
|
#include "RE.h"
|
|
#include "RemoteSerializer.h"
|
|
|
|
void EventRegistry::Register(EventHandlerPtr handler)
|
|
{
|
|
HashKey key(handler->Name());
|
|
handlers.Insert(&key, handler.Ptr());
|
|
}
|
|
|
|
EventHandler* EventRegistry::Lookup(const char* name)
|
|
{
|
|
HashKey key(name);
|
|
return handlers.Lookup(&key);
|
|
}
|
|
|
|
EventRegistry::string_list* EventRegistry::Match(RE_Matcher* pattern)
|
|
{
|
|
string_list* names = new string_list;
|
|
|
|
IterCookie* c = handlers.InitForIteration();
|
|
|
|
HashKey* k;
|
|
EventHandler* v;
|
|
while ( (v = handlers.NextEntry(k, c)) )
|
|
{
|
|
if ( v->LocalHandler() && pattern->MatchExactly(v->Name()) )
|
|
names->append(v->Name());
|
|
|
|
delete k;
|
|
}
|
|
|
|
return names;
|
|
}
|
|
|
|
EventRegistry::string_list* EventRegistry::UnusedHandlers()
|
|
{
|
|
string_list* names = new string_list;
|
|
|
|
IterCookie* c = handlers.InitForIteration();
|
|
|
|
HashKey* k;
|
|
EventHandler* v;
|
|
while ( (v = handlers.NextEntry(k, c)) )
|
|
{
|
|
if ( v->LocalHandler() && ! v->Used() )
|
|
names->append(v->Name());
|
|
|
|
delete k;
|
|
}
|
|
|
|
return names;
|
|
}
|
|
|
|
EventRegistry::string_list* EventRegistry::UsedHandlers()
|
|
{
|
|
string_list* names = new string_list;
|
|
|
|
IterCookie* c = handlers.InitForIteration();
|
|
|
|
HashKey* k;
|
|
EventHandler* v;
|
|
while ( (v = handlers.NextEntry(k, c)) )
|
|
{
|
|
if ( v->LocalHandler() && v->Used() )
|
|
names->append(v->Name());
|
|
|
|
delete k;
|
|
}
|
|
|
|
return names;
|
|
}
|
|
|
|
void EventRegistry::PrintDebug()
|
|
{
|
|
IterCookie* c = handlers.InitForIteration();
|
|
|
|
HashKey* k;
|
|
EventHandler* v;
|
|
while ( (v = handlers.NextEntry(k, c)) )
|
|
{
|
|
delete k;
|
|
fprintf(stderr, "Registered event %s (%s handler)\n", v->Name(),
|
|
v->LocalHandler()? "local" : "no");
|
|
}
|
|
}
|
|
|
|
void EventRegistry::SetGroup(const char* name, const char* group)
|
|
{
|
|
return; // FIXME. THis triggers the error below for plugin events.
|
|
|
|
EventHandler* eh = Lookup(name);
|
|
if ( ! eh )
|
|
reporter->InternalError("unknown event handler %s in SetGroup()", name);
|
|
|
|
eh->SetGroup(group);
|
|
}
|
|
|
|
void EventRegistry::SetErrorHandler(const char* name)
|
|
{
|
|
EventHandler* eh = Lookup(name);
|
|
if ( ! eh )
|
|
reporter->InternalError("unknown event handler in SetErrorHandler()");
|
|
|
|
eh->SetErrorHandler();
|
|
}
|
|
|
|
void EventRegistry::EnableGroup(const char* group, bool enable)
|
|
{
|
|
IterCookie* c = handlers.InitForIteration();
|
|
|
|
HashKey* k;
|
|
EventHandler* v;
|
|
while ( (v = handlers.NextEntry(k, c)) )
|
|
{
|
|
delete k;
|
|
|
|
if ( v->Group() && strcmp(v->Group(), group) == 0 )
|
|
v->SetEnable(enable);
|
|
}
|
|
}
|
|
|