]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-filedata: use void *initdata instead of OutputCtx
authorJason Ish <jason.ish@oisf.net>
Fri, 30 Aug 2024 14:58:58 +0000 (08:58 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 31 Aug 2024 08:53:59 +0000 (10:53 +0200)
Avoids leaking a higher level abstraction into a low level logger.

Ticket: #7227

src/output-filedata.c
src/output-filedata.h

index e3b038d7af87a31df1a76bdebe65e0042fd652ea..ae6164b8e2021c3f3cceb1955051d68574a35506 100644 (file)
@@ -41,7 +41,7 @@ bool g_filedata_logger_enabled = false;
  * log module (e.g. http.log) with different output ctx'. */
 typedef struct OutputFiledataLogger_ {
     FiledataLogger LogFunc;
-    OutputCtx *output_ctx;
+    void *initdata;
     struct OutputFiledataLogger_ *next;
     const char *name;
     LoggerId logger_id;
@@ -52,14 +52,14 @@ typedef struct OutputFiledataLogger_ {
 static OutputFiledataLogger *list = NULL;
 
 int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc,
-        OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
+        void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
 {
     OutputFiledataLogger *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->logger_id = id;
     op->ThreadInit = ThreadInit;
@@ -218,7 +218,7 @@ TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, OutputFiledataLoggerThreadDa
     while (logger) {
         if (logger->ThreadInit) {
             void *retptr = NULL;
-            if (logger->ThreadInit(tv, (void *)logger->output_ctx, &retptr) == TM_ECODE_OK) {
+            if (logger->ThreadInit(tv, logger->initdata, &retptr) == TM_ECODE_OK) {
                 OutputLoggerThreadStore *ts = SCCalloc(1, sizeof(*ts));
                 /* todo */ BUG_ON(ts == NULL);
 
index 0fb034a9a4912a1c33970f4e47398c8c8f65c2ef..cb0cbcd9594b07878683e02c119415858e618c6f 100644 (file)
@@ -49,8 +49,8 @@ void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Pa
 typedef int (*FiledataLogger)(ThreadVars *, void *thread_data, const Packet *, File *, void *tx,
         const uint64_t tx_id, const uint8_t *, uint32_t, uint8_t, uint8_t dir);
 
-int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc, OutputCtx *,
-        ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit);
+int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc,
+        void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit);
 
 void OutputFiledataLoggerRegister(void);