From: Jason Ish Date: Mon, 26 Aug 2024 21:45:07 +0000 (-0600) Subject: output-flow: use void * instead of OutputCtx * for initdata X-Git-Tag: suricata-8.0.0-beta1~929 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0506043dea21adcadd5e396d00298f676cb51d4c;p=thirdparty%2Fsuricata.git output-flow: use void * instead of OutputCtx * for initdata The use of OutputCtx as the data type for initdata was leaking Eve submodule logic into the low level flow logger. Instead use void *, as the flow logging module is not concerned with the type of data here. Also document this initdata parameter. Ticket: #7227 --- diff --git a/src/output-flow.c b/src/output-flow.c index 47c8b31f30..5d7a08c883 100644 --- a/src/output-flow.c +++ b/src/output-flow.c @@ -40,7 +40,10 @@ typedef struct OutputFlowLoggerThreadData_ { * log module (e.g. http.log) with different output ctx'. */ typedef struct OutputFlowLogger_ { FlowLogger LogFunc; - OutputCtx *output_ctx; + + /** Data that will be passed to the ThreadInit callback. */ + void *initdata; + struct OutputFlowLogger_ *next; /** A name for this logger, used for debugging only. */ @@ -61,17 +64,16 @@ static OutputFlowLogger *list = NULL; * * \retval 0 on success, -1 on failure. */ -int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, - OutputCtx *output_ctx, ThreadInitFunc ThreadInit, - ThreadDeinitFunc ThreadDeinit, - ThreadExitPrintStatsFunc ThreadExitPrintStats) +int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata, + ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, + ThreadExitPrintStatsFunc ThreadExitPrintStats) { OutputFlowLogger *op = SCCalloc(1, sizeof(*op)); if (op == NULL) return -1; op->LogFunc = LogFunc; - op->output_ctx = output_ctx; + op->initdata = initdata; op->name = name; op->ThreadInit = ThreadInit; op->ThreadDeinit = ThreadDeinit; @@ -145,7 +147,7 @@ TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void **data) while (logger) { if (logger->ThreadInit) { void *retptr = NULL; - if (logger->ThreadInit(tv, (void *)logger->output_ctx, &retptr) == TM_ECODE_OK) { + if (logger->ThreadInit(tv, (void *)logger->initdata, &retptr) == TM_ECODE_OK) { OutputLoggerThreadStore *ts = SCCalloc(1, sizeof(*ts)); /* todo */ BUG_ON(ts == NULL); diff --git a/src/output-flow.h b/src/output-flow.h index 86e0e00de0..c3dd3335cb 100644 --- a/src/output-flow.h +++ b/src/output-flow.h @@ -31,9 +31,9 @@ /** flow logger function pointer type */ typedef int (*FlowLogger)(ThreadVars *, void *thread_data, Flow *f); -int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, - OutputCtx *, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, - ThreadExitPrintStatsFunc ThreadExitPrintStats); +int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata, + ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, + ThreadExitPrintStatsFunc ThreadExitPrintStats); void OutputFlowShutdown(void);