mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Redoing the plugin versioning.
We now explicitly mark plugins as static vs dynamic (though we don't have the latter yet) instead of piggy-backing that on the version. Also, versions are now ignored for static plugins.
This commit is contained in:
parent
433c85540c
commit
cf9d65932c
3 changed files with 46 additions and 18 deletions
|
@ -10,19 +10,12 @@
|
||||||
|
|
||||||
#include "analyzer/Component.h"
|
#include "analyzer/Component.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Place-holder API version for plugins compiled in statically.
|
|
||||||
*/
|
|
||||||
#define BRO_PLUGIN_VERSION_BUILTIN -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current plugin API version. Plugins that won't match this version will
|
* The current plugin API version. Plugins that won't match this version will
|
||||||
* be rejected.
|
* be rejected.
|
||||||
*/
|
*/
|
||||||
#define BRO_PLUGIN_API_VERSION 1
|
#define BRO_PLUGIN_API_VERSION 1
|
||||||
|
|
||||||
#define _BRO_PLUGIN_VERSION_DEFAULT -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the definition of a new plugin.
|
* Starts the definition of a new plugin.
|
||||||
*
|
*
|
||||||
|
@ -40,8 +33,12 @@
|
||||||
void InitPreScript() \
|
void InitPreScript() \
|
||||||
{ \
|
{ \
|
||||||
SetName(#_ns "::" #_name); \
|
SetName(#_ns "::" #_name); \
|
||||||
SetVersion(_BRO_PLUGIN_VERSION_DEFAULT);\
|
SetVersion(-1);\
|
||||||
SetAPIVersion(BRO_PLUGIN_API_VERSION);
|
SetAPIVersion(BRO_PLUGIN_API_VERSION);\
|
||||||
|
SetDynamicPlugin(false);
|
||||||
|
// TODO: The SetDynamicPlugin() call is currently hardcoded to false. Change
|
||||||
|
// once we have dynamic plugins as well.
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the definition of a plugin.
|
* Ends the definition of a plugin.
|
||||||
|
|
|
@ -46,6 +46,7 @@ Plugin::Plugin()
|
||||||
// These will be reset by the BRO_PLUGIN_* macros.
|
// These will be reset by the BRO_PLUGIN_* macros.
|
||||||
version = -9999;
|
version = -9999;
|
||||||
api_version = -9999;
|
api_version = -9999;
|
||||||
|
dynamic = false;
|
||||||
|
|
||||||
Manager::RegisterPlugin(this);
|
Manager::RegisterPlugin(this);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,7 @@ void Plugin::SetDescription(const char* arg_description)
|
||||||
|
|
||||||
int Plugin::Version()
|
int Plugin::Version()
|
||||||
{
|
{
|
||||||
return version;
|
return dynamic ? version : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugin::SetVersion(int arg_version)
|
void Plugin::SetVersion(int arg_version)
|
||||||
|
@ -93,11 +94,21 @@ int Plugin::APIVersion()
|
||||||
return api_version;
|
return api_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Plugin::DynamicPlugin()
|
||||||
|
{
|
||||||
|
return dynamic;
|
||||||
|
}
|
||||||
|
|
||||||
void Plugin::SetAPIVersion(int arg_version)
|
void Plugin::SetAPIVersion(int arg_version)
|
||||||
{
|
{
|
||||||
api_version = arg_version;
|
api_version = arg_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plugin::SetDynamicPlugin(bool arg_dynamic)
|
||||||
|
{
|
||||||
|
dynamic = arg_dynamic;
|
||||||
|
}
|
||||||
|
|
||||||
void Plugin::InitPreScript()
|
void Plugin::InitPreScript()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -166,12 +177,16 @@ void Plugin::Describe(ODesc* d)
|
||||||
d->Add(description);
|
d->Add(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( version != BRO_PLUGIN_VERSION_BUILTIN )
|
if ( dynamic )
|
||||||
{
|
{
|
||||||
d->Add(" (version ");
|
if ( version > 0 )
|
||||||
d->Add(version);
|
{
|
||||||
|
d->Add(" (version ");
|
||||||
d->Add(")");
|
d->Add(version);
|
||||||
|
d->Add(")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
d->Add(" (version not set)");
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -110,15 +110,23 @@ public:
|
||||||
const char* Description();
|
const char* Description();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the version of the plugin.
|
* Returns the version of the plugin. Version are only meaningful for
|
||||||
|
* dynamically compiled plugins; for statically compiled ones, this
|
||||||
|
* will always return 0.
|
||||||
*/
|
*/
|
||||||
int Version();
|
int Version();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this is a dynamically linked in plugin.
|
||||||
|
*/
|
||||||
|
bool DynamicPlugin();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the internal API version that this plugin relies on. Only
|
* Returns the internal API version that this plugin relies on. Only
|
||||||
* plugins that match Bro's BRO_PLUGIN_API_VERSION may be used. For
|
* plugins that match Bro's current API version may be used. For
|
||||||
* statically compiled plugins this is automatically the case, but
|
* statically compiled plugins this is automatically the case, but
|
||||||
* dynamically loaded plugins could later cause a mismatch.
|
* dynamically loaded plugins may cause a mismatch if they were
|
||||||
|
* compiled for a different Bro version.
|
||||||
*/
|
*/
|
||||||
int APIVersion();
|
int APIVersion();
|
||||||
|
|
||||||
|
@ -197,6 +205,13 @@ protected:
|
||||||
*/
|
*/
|
||||||
void SetAPIVersion(int version);
|
void SetAPIVersion(int version);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks the plugin as statically or dynamically linked.
|
||||||
|
*
|
||||||
|
* @param dynamic True if this is a dynamically linked plugin.
|
||||||
|
*/
|
||||||
|
void SetDynamicPlugin(bool dynamic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes ownership.
|
* Takes ownership.
|
||||||
*/
|
*/
|
||||||
|
@ -225,6 +240,7 @@ private:
|
||||||
const char* description;
|
const char* description;
|
||||||
int version;
|
int version;
|
||||||
int api_version;
|
int api_version;
|
||||||
|
bool dynamic;
|
||||||
|
|
||||||
component_list components;
|
component_list components;
|
||||||
bif_item_list bif_items;
|
bif_item_list bif_items;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue