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:
Robin Sommer 2015-08-10 14:44:39 -07:00
commit c91792b762
11 changed files with 94 additions and 15 deletions

View file

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