|
|
|
@ -44,6 +44,27 @@ static TAILQ_HEAD(, SCPluginFileType_) output_types =
|
|
|
|
|
|
|
|
|
|
static TAILQ_HEAD(, SCCapturePlugin_) capture_plugins = TAILQ_HEAD_INITIALIZER(capture_plugins);
|
|
|
|
|
|
|
|
|
|
bool RegisterPlugin(SCPlugin *plugin, void *lib)
|
|
|
|
|
{
|
|
|
|
|
BUG_ON(plugin->name == NULL);
|
|
|
|
|
BUG_ON(plugin->author == NULL);
|
|
|
|
|
BUG_ON(plugin->license == NULL);
|
|
|
|
|
BUG_ON(plugin->Init == NULL);
|
|
|
|
|
|
|
|
|
|
PluginListNode *node = SCCalloc(1, sizeof(*node));
|
|
|
|
|
if (node == NULL) {
|
|
|
|
|
SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for plugin");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
node->plugin = plugin;
|
|
|
|
|
node->lib = lib;
|
|
|
|
|
TAILQ_INSERT_TAIL(&plugins, node, entries);
|
|
|
|
|
SCLogNotice("Initializing plugin %s; author=%s; license=%s", plugin->name, plugin->author,
|
|
|
|
|
plugin->license);
|
|
|
|
|
(*plugin->Init)();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void InitPlugin(char *path)
|
|
|
|
|
{
|
|
|
|
|
void *lib = dlopen(path, RTLD_NOW);
|
|
|
|
@ -58,30 +79,12 @@ static void InitPlugin(char *path)
|
|
|
|
|
dlclose(lib);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SCPlugin *plugin = (*plugin_register)();
|
|
|
|
|
if (plugin == NULL) {
|
|
|
|
|
SCLogError(SC_ERR_PLUGIN, "Plugin registration failed: %s", path);
|
|
|
|
|
dlclose(lib);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BUG_ON(plugin->name == NULL);
|
|
|
|
|
BUG_ON(plugin->author == NULL);
|
|
|
|
|
BUG_ON(plugin->license == NULL);
|
|
|
|
|
BUG_ON(plugin->Init == NULL);
|
|
|
|
|
|
|
|
|
|
PluginListNode *node = SCCalloc(1, sizeof(*node));
|
|
|
|
|
if (node == NULL) {
|
|
|
|
|
SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocated memory for plugin");
|
|
|
|
|
if (!RegisterPlugin(plugin_register(), lib)) {
|
|
|
|
|
SCLogError(SC_ERR_PLUGIN, "Plugin registration failed: %s", path);
|
|
|
|
|
dlclose(lib);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
node->plugin = plugin;
|
|
|
|
|
node->lib = lib;
|
|
|
|
|
TAILQ_INSERT_TAIL(&plugins, node, entries);
|
|
|
|
|
SCLogNotice("Initializing plugin %s; author=%s; license=%s", plugin->name, plugin->author,
|
|
|
|
|
plugin->license);
|
|
|
|
|
(*plugin->Init)();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -139,6 +142,23 @@ void SCPluginsLoad(const char *capture_plugin_name, const char *capture_plugin_a
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SCRegisterEveFileType(SCPluginFileType *plugin)
|
|
|
|
|
{
|
|
|
|
|
SCPluginFileType *existing = NULL;
|
|
|
|
|
TAILQ_FOREACH (existing, &output_types, entries) {
|
|
|
|
|
if (strcmp(existing->name, plugin->name) == 0) {
|
|
|
|
|
SCLogNotice("EVE file type plugin name conflicts with previously "
|
|
|
|
|
"registered plugin: %s",
|
|
|
|
|
plugin->name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SCLogDebug("Registering EVE file type plugin %s", plugin->name);
|
|
|
|
|
TAILQ_INSERT_TAIL(&output_types, plugin, entries);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Register an Eve/JSON file type plugin.
|
|
|
|
|
*
|
|
|
|
|