ConfNode *plugin_conf = ConfNodeLookupChild(conf,
json_ctx->plugin->name);
void *plugin_data = NULL;
- if (json_ctx->plugin->Open(plugin_conf, &plugin_data) < 0) {
+ if (json_ctx->plugin->Init(plugin_conf, false, &plugin_data) < 0) {
LogFileFreeCtx(json_ctx->file_ctx);
SCFree(json_ctx);
SCFree(output_ctx);
-/* Copyright (C) 2020 Open Information Security Foundation
+/* Copyright (C) 2020-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* 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
*/
typedef struct SCPluginFileType_ {
char *name;
- int (*Open)(ConfNode *conf, void **data);
- int (*Write)(const char *buffer, int buffer_len, void *ctx);
- void (*Close)(void *ctx);
+ /* Init Called on first access */
+ int (*Init)(ConfNode *conf, bool threaded, void **init_data);
+ /* Write - Called on each write to the object */
+ int (*Write)(const char *buffer, int buffer_len, void *init_data, void *thread_data);
+ /* Close - Called on final close */
+ void (*Deinit)(void *init_data);
+ /* ThreadInit - Called for each thread using file object*/
+ 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;
typedef struct SCCapturePlugin_ {
char *name;
void (*Init)(const char *args, int plugin_slot, int receive_slot, int decode_slot);
+ int (*ThreadInit)(void *ctx, int thread_id, void **thread_ctx);
+ int (*ThreadDeinit)(void *ctx, void *thread_ctx);
const char *(*GetDefaultMode)(void);
TAILQ_ENTRY(SCCapturePlugin_) entries;
} SCCapturePlugin;
SCFree(lf_ctx->threads);
} else {
if (lf_ctx->type == LOGFILE_TYPE_PLUGIN) {
- if (lf_ctx->plugin->Close != NULL) {
- lf_ctx->plugin->Close(lf_ctx->plugin_data);
+ if (lf_ctx->plugin->Deinit != NULL) {
+ lf_ctx->plugin->Deinit(lf_ctx->plugin_data);
}
} else if (lf_ctx->fp != NULL) {
lf_ctx->Close(lf_ctx);
#endif
else if (file_ctx->type == LOGFILE_TYPE_PLUGIN) {
file_ctx->plugin->Write((const char *)MEMBUFFER_BUFFER(buffer),
- MEMBUFFER_OFFSET(buffer), file_ctx->plugin_data);
+ MEMBUFFER_OFFSET(buffer), file_ctx->plugin_data, NULL);
}
return 0;