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)
{
SCPluginFileType *plugin_data = SCCalloc(1, sizeof(SCPluginFileType));
SCEveFileType *plugin_data = SCCalloc(1, sizeof(SCEveFileType));
if (plugin_data == NULL) {
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);
if (log_filetype == LOGFILE_TYPE_NOTSET) {
#ifdef HAVE_PLUGINS
SCPluginFileType *plugin = SCPluginFindFileType(output_s);
SCEveFileType *plugin = SCPluginFindFileType(output_s);
if (plugin != NULL) {
log_filetype = LOGFILE_TYPE_PLUGIN;
json_ctx->plugin = plugin;

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

@ -43,14 +43,11 @@ typedef struct SCPlugin_ {
typedef SCPlugin *(*SCPluginRegisterFunc)(void);
/**
* Structure used to define a 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
* Structure used to define an Eve output file type plugin.
*/
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;
bool internal;
/* Init Called on first access */
@ -63,11 +60,11 @@ typedef struct SCPluginFileType_ {
int (*ThreadInit)(void *init_data, int thread_id, void **thread_data);
/* ThreadDeinit - Called for each thread using file object */
int (*ThreadDeinit)(void *init_data, void *thread_data);
TAILQ_ENTRY(SCPluginFileType_) entries;
} SCPluginFileType;
TAILQ_ENTRY(SCEveFileType_) entries;
} SCEveFileType;
bool SCPluginRegisterEveFileType(SCPluginFileType *);
bool SCRegisterEveFileType(SCPluginFileType *);
bool SCPluginRegisterEveFileType(SCEveFileType *);
bool SCRegisterEveFileType(SCEveFileType *);
typedef struct SCCapturePlugin_ {
char *name;

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

@ -38,8 +38,7 @@ typedef struct PluginListNode_ {
*/
static TAILQ_HEAD(, PluginListNode_) plugins = TAILQ_HEAD_INITIALIZER(plugins);
static TAILQ_HEAD(, SCPluginFileType_) output_types =
TAILQ_HEAD_INITIALIZER(output_types);
static TAILQ_HEAD(, SCEveFileType_) output_types = TAILQ_HEAD_INITIALIZER(output_types);
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) {
if (strcmp(existing->name, plugin->name) == 0) {
SCLogNotice("EVE file type plugin name conflicts with previously "
@ -167,7 +166,7 @@ bool SCRegisterEveFileType(SCPluginFileType *plugin)
* plugin file type.
*
*/
bool SCPluginRegisterEveFileType(SCPluginFileType *plugin)
bool SCPluginRegisterEveFileType(SCEveFileType *plugin)
{
const char *builtin[] = {
"regular",
@ -191,9 +190,9 @@ bool SCPluginRegisterEveFileType(SCPluginFileType *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) {
if (strcmp(name, plugin->name) == 0) {
return plugin;

@ -23,7 +23,7 @@
void SCInternalLoad(void);
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);
bool RegisterPlugin(SCPlugin *, void *);

Loading…
Cancel
Save