mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Merge branch 'topic/jswaro/feature/HookAddToAnalyzer-tcprs-support' of https://github.com/jswaro/bro
Making two changes here: - Renaming the hook to SetupAnalyzerTree. - Reverting the reversal of the script load order. Instead, I'm adding an additional script that Bro looks for to load first, "__preload__.bro". Also extending the plugin docs to cover this. - Increasing plugin API version, as I suppose adding a new virtual function may invalidate binary compatibility. * 'topic/jswaro/feature/HookAddToAnalyzer-tcprs-support' of https://github.com/jswaro/bro: Add hook 'HookAddToAnalyzerTree' to support TCPRS plugin
This commit is contained in:
commit
c91792b762
11 changed files with 94 additions and 15 deletions
|
@ -182,9 +182,17 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
|
|||
add_to_bro_path(scripts);
|
||||
}
|
||||
|
||||
// Load {bif,scripts}/__load__.bro automatically.
|
||||
// First load {scripts}/__preload__.bro automatically.
|
||||
string init = dir + "scripts/__preload__.bro";
|
||||
|
||||
string init = dir + "lib/bif/__load__.bro";
|
||||
if ( is_file(init) )
|
||||
{
|
||||
DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str());
|
||||
scripts_to_load.push_back(init);
|
||||
}
|
||||
|
||||
// Load {bif,scripts}/__load__.bro automatically.
|
||||
init = dir + "lib/bif/__load__.bro";
|
||||
|
||||
if ( is_file(init) )
|
||||
{
|
||||
|
@ -660,6 +668,33 @@ void Manager::HookDrainEvents() const
|
|||
|
||||
}
|
||||
|
||||
void Manager::HookSetupAnalyzerTree(Connection *conn) const
|
||||
{
|
||||
HookArgumentList args;
|
||||
|
||||
if ( HavePluginForHook(META_HOOK_PRE) )
|
||||
{
|
||||
args.push_back(conn);
|
||||
MetaHookPre(HOOK_SETUP_ANALYZER_TREE, args);
|
||||
}
|
||||
|
||||
hook_list *l = hooks[HOOK_SETUP_ANALYZER_TREE];
|
||||
|
||||
if ( l )
|
||||
{
|
||||
for (hook_list::iterator i = l->begin() ; i != l->end(); ++i)
|
||||
{
|
||||
Plugin *p = (*i).second;
|
||||
p->HookSetupAnalyzerTree(conn);
|
||||
}
|
||||
}
|
||||
|
||||
if ( HavePluginForHook(META_HOOK_POST) )
|
||||
{
|
||||
MetaHookPost(HOOK_SETUP_ANALYZER_TREE, args, HookArgument());
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::HookUpdateNetworkTime(double network_time) const
|
||||
{
|
||||
HookArgumentList args;
|
||||
|
|
|
@ -264,6 +264,15 @@ public:
|
|||
*/
|
||||
void HookUpdateNetworkTime(double network_time) const;
|
||||
|
||||
/**
|
||||
* Hook that executes when a connection's initial analyzer tree
|
||||
* has been fully set up. The hook can manipulate the tree at this time,
|
||||
* for example by adding further analyzers.
|
||||
*
|
||||
* @param conn The connection.
|
||||
*/
|
||||
void HookSetupAnalyzerTree(Connection *conn) const;
|
||||
|
||||
/**
|
||||
* Hook that informs plugins that the event queue is being drained.
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,7 @@ const char* plugin::hook_name(HookType h)
|
|||
"DrainEvents",
|
||||
"UpdateNetworkTime",
|
||||
"BroObjDtor",
|
||||
"SetupAnalyzerTree",
|
||||
// MetaHooks
|
||||
"MetaHookPre",
|
||||
"MetaHookPost",
|
||||
|
@ -310,6 +311,10 @@ void Plugin::HookUpdateNetworkTime(double network_time)
|
|||
{
|
||||
}
|
||||
|
||||
void Plugin::HookSetupAnalyzerTree(Connection *conn)
|
||||
{
|
||||
}
|
||||
|
||||
void Plugin::HookBroObjDtor(void* obj)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
// We allow to override this externally for testing purposes.
|
||||
#ifndef BRO_PLUGIN_API_VERSION
|
||||
#define BRO_PLUGIN_API_VERSION 3
|
||||
#define BRO_PLUGIN_API_VERSION 4
|
||||
#endif
|
||||
|
||||
class ODesc;
|
||||
|
@ -39,6 +39,7 @@ enum HookType {
|
|||
HOOK_DRAIN_EVENTS, //< Activates Plugin::HookDrainEvents()
|
||||
HOOK_UPDATE_NETWORK_TIME, //< Activates Plugin::HookUpdateNetworkTime.
|
||||
HOOK_BRO_OBJ_DTOR, //< Activates Plugin::HookBroObjDtor.
|
||||
HOOK_SETUP_ANALYZER_TREE, //< Activates Plugin::HookAddToAnalyzerTree
|
||||
|
||||
// Meta hooks.
|
||||
META_HOOK_PRE, //< Activates Plugin::MetaHookPre().
|
||||
|
@ -636,6 +637,8 @@ protected:
|
|||
*/
|
||||
virtual void HookUpdateNetworkTime(double network_time);
|
||||
|
||||
virtual void HookSetupAnalyzerTree(Connection *conn);
|
||||
|
||||
/**
|
||||
* Hook for destruction of objects registered with
|
||||
* RequestBroObjDtor(). When Bro's reference counting triggers the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue