plugins: rename SCPLuginFileType to SCEveFileType

With internal code using the plugin API to register an Eve
filetype, the name plugin no longer makes sense. This is
part of my idea that internal plugins aren't plugins at all,
and the plugin interface should be an abstraction over
internal APIs.

Along that idea, this is the start of a refactor of the plugin
file types to be internal, where the plugin API is just an external
interface to that internal API.
pull/6395/head
Jason Ish 4 years ago committed by Victor Julien
parent f221c344ed
commit 784a080201

@ -98,7 +98,7 @@ static void SyslogDeInit(void *init_data)
void SyslogInitialize(void) void SyslogInitialize(void)
{ {
SCPluginFileType *plugin_data = SCCalloc(1, sizeof(SCPluginFileType)); SCEveFileType *plugin_data = SCCalloc(1, sizeof(SCEveFileType));
if (plugin_data == NULL) { if (plugin_data == NULL) {
FatalError(SC_ERR_MEM_ALLOC, "Unable to allocate memory for eve output %s", OUTPUT_NAME); FatalError(SC_ERR_MEM_ALLOC, "Unable to allocate memory for eve output %s", OUTPUT_NAME);

@ -1133,7 +1133,7 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf)
enum LogFileType log_filetype = FileTypeFromConf(output_s); enum LogFileType log_filetype = FileTypeFromConf(output_s);
if (log_filetype == LOGFILE_TYPE_NOTSET) { if (log_filetype == LOGFILE_TYPE_NOTSET) {
#ifdef HAVE_PLUGINS #ifdef HAVE_PLUGINS
SCPluginFileType *plugin = SCPluginFindFileType(output_s); SCEveFileType *plugin = SCPluginFindFileType(output_s);
if (plugin != NULL) { if (plugin != NULL) {
log_filetype = LOGFILE_TYPE_PLUGIN; log_filetype = LOGFILE_TYPE_PLUGIN;
json_ctx->plugin = plugin; json_ctx->plugin = plugin;

@ -83,7 +83,7 @@ typedef struct OutputJsonCtx_ {
enum LogFileType json_out; enum LogFileType json_out;
OutputJsonCommonSettings cfg; OutputJsonCommonSettings cfg;
HttpXFFCfg *xff_cfg; HttpXFFCfg *xff_cfg;
SCPluginFileType *plugin; SCEveFileType *plugin;
} OutputJsonCtx; } OutputJsonCtx;
typedef struct OutputJsonThreadCtx_ { typedef struct OutputJsonThreadCtx_ {

@ -43,14 +43,11 @@ typedef struct SCPlugin_ {
typedef SCPlugin *(*SCPluginRegisterFunc)(void); typedef SCPlugin *(*SCPluginRegisterFunc)(void);
/** /**
* Structure used to define a file type plugin. * Structure used to define an Eve output file type plugin.
*
* Currently only used by the Eve output type.
*
* name -- The plugin name. This name is used to identify the plugin: eve-log.filetype and in the
* plugins: section
*/ */
typedef struct SCPluginFileType_ { typedef struct SCEveFileType_ {
/* The name of the output, used to specify the output in the filetype section
* of the eve-log configuration. */
const char *name; const char *name;
bool internal; bool internal;
/* Init Called on first access */ /* Init Called on first access */
@ -63,11 +60,11 @@ typedef struct SCPluginFileType_ {
int (*ThreadInit)(void *init_data, int thread_id, void **thread_data); int (*ThreadInit)(void *init_data, int thread_id, void **thread_data);
/* ThreadDeinit - Called for each thread using file object */ /* ThreadDeinit - Called for each thread using file object */
int (*ThreadDeinit)(void *init_data, void *thread_data); int (*ThreadDeinit)(void *init_data, void *thread_data);
TAILQ_ENTRY(SCPluginFileType_) entries; TAILQ_ENTRY(SCEveFileType_) entries;
} SCPluginFileType; } SCEveFileType;
bool SCPluginRegisterEveFileType(SCPluginFileType *); bool SCPluginRegisterEveFileType(SCEveFileType *);
bool SCRegisterEveFileType(SCPluginFileType *); bool SCRegisterEveFileType(SCEveFileType *);
typedef struct SCCapturePlugin_ { typedef struct SCCapturePlugin_ {
char *name; char *name;

@ -55,7 +55,7 @@ typedef struct LogThreadedFileCtx_ {
} LogThreadedFileCtx; } LogThreadedFileCtx;
typedef struct LogFilePluginCtx_ { typedef struct LogFilePluginCtx_ {
SCPluginFileType *plugin; SCEveFileType *plugin;
void *init_data; void *init_data;
void *thread_data; void *thread_data;
} LogFilePluginCtx; } LogFilePluginCtx;

@ -38,8 +38,7 @@ typedef struct PluginListNode_ {
*/ */
static TAILQ_HEAD(, PluginListNode_) plugins = TAILQ_HEAD_INITIALIZER(plugins); static TAILQ_HEAD(, PluginListNode_) plugins = TAILQ_HEAD_INITIALIZER(plugins);
static TAILQ_HEAD(, SCPluginFileType_) output_types = static TAILQ_HEAD(, SCEveFileType_) output_types = TAILQ_HEAD_INITIALIZER(output_types);
TAILQ_HEAD_INITIALIZER(output_types);
static TAILQ_HEAD(, SCCapturePlugin_) capture_plugins = TAILQ_HEAD_INITIALIZER(capture_plugins); static TAILQ_HEAD(, SCCapturePlugin_) capture_plugins = TAILQ_HEAD_INITIALIZER(capture_plugins);
@ -142,9 +141,9 @@ void SCPluginsLoad(const char *capture_plugin_name, const char *capture_plugin_a
} }
} }
bool SCRegisterEveFileType(SCPluginFileType *plugin) bool SCRegisterEveFileType(SCEveFileType *plugin)
{ {
SCPluginFileType *existing = NULL; SCEveFileType *existing = NULL;
TAILQ_FOREACH (existing, &output_types, entries) { TAILQ_FOREACH (existing, &output_types, entries) {
if (strcmp(existing->name, plugin->name) == 0) { if (strcmp(existing->name, plugin->name) == 0) {
SCLogNotice("EVE file type plugin name conflicts with previously " SCLogNotice("EVE file type plugin name conflicts with previously "
@ -167,7 +166,7 @@ bool SCRegisterEveFileType(SCPluginFileType *plugin)
* plugin file type. * plugin file type.
* *
*/ */
bool SCPluginRegisterEveFileType(SCPluginFileType *plugin) bool SCPluginRegisterEveFileType(SCEveFileType *plugin)
{ {
const char *builtin[] = { const char *builtin[] = {
"regular", "regular",
@ -191,9 +190,9 @@ bool SCPluginRegisterEveFileType(SCPluginFileType *plugin)
return SCRegisterEveFileType(plugin); return SCRegisterEveFileType(plugin);
} }
SCPluginFileType *SCPluginFindFileType(const char *name) SCEveFileType *SCPluginFindFileType(const char *name)
{ {
SCPluginFileType *plugin = NULL; SCEveFileType *plugin = NULL;
TAILQ_FOREACH(plugin, &output_types, entries) { TAILQ_FOREACH(plugin, &output_types, entries) {
if (strcmp(name, plugin->name) == 0) { if (strcmp(name, plugin->name) == 0) {
return plugin; return plugin;

@ -23,7 +23,7 @@
void SCInternalLoad(void); void SCInternalLoad(void);
void SCPluginsLoad(const char *capture_plugin_name, const char *capture_plugin_args); void SCPluginsLoad(const char *capture_plugin_name, const char *capture_plugin_args);
SCPluginFileType *SCPluginFindFileType(const char *name); SCEveFileType *SCPluginFindFileType(const char *name);
SCCapturePlugin *SCPluginFindCaptureByName(const char *name); SCCapturePlugin *SCPluginFindCaptureByName(const char *name);
bool RegisterPlugin(SCPlugin *, void *); bool RegisterPlugin(SCPlugin *, void *);

Loading…
Cancel
Save