]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-packet: use void * instead of OutputCtx * for initdata
authorJason Ish <jason.ish@oisf.net>
Mon, 26 Aug 2024 21:54:53 +0000 (15:54 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 31 Aug 2024 08:53:59 +0000 (10:53 +0200)
The use of OutputCtx as the data type for initdata was leaking Eve
submodule logic into the low level packet logger. Instead use void *,
as the packet logging module is not concerned with the type of data
here.

Also document this initdata parameter.

Ticket: #7227

src/output-packet.c
src/output-packet.h

index 98ccf7b6b08157794503a0fbcaf6e1bad9a0d8cf..96d2e426c9d2dd61ee8306fe6f4735b4fcb456a5 100644 (file)
@@ -41,7 +41,8 @@ typedef struct OutputPacketLoggerThreadData_ {
 typedef struct OutputPacketLogger_ {
     PacketLogger LogFunc;
     PacketLogCondition ConditionFunc;
-    OutputCtx *output_ctx;
+    /** Data that will be passed to the ThreadInit callback. */
+    void *initdata;
     struct OutputPacketLogger_ *next;
     const char *name;
     LoggerId logger_id;
@@ -52,11 +53,9 @@ typedef struct OutputPacketLogger_ {
 
 static OutputPacketLogger *list = NULL;
 
-int OutputRegisterPacketLogger(LoggerId logger_id, const char *name,
-    PacketLogger LogFunc, PacketLogCondition ConditionFunc,
-    OutputCtx *output_ctx, ThreadInitFunc ThreadInit,
-    ThreadDeinitFunc ThreadDeinit,
-    ThreadExitPrintStatsFunc ThreadExitPrintStats)
+int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogger LogFunc,
+        PacketLogCondition ConditionFunc, void *initdata, ThreadInitFunc ThreadInit,
+        ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
 {
     OutputPacketLogger *op = SCCalloc(1, sizeof(*op));
     if (op == NULL)
@@ -64,7 +63,7 @@ int OutputRegisterPacketLogger(LoggerId logger_id, const char *name,
 
     op->LogFunc = LogFunc;
     op->ConditionFunc = ConditionFunc;
-    op->output_ctx = output_ctx;
+    op->initdata = initdata;
     op->name = name;
     op->ThreadInit = ThreadInit;
     op->ThreadDeinit = ThreadDeinit;
@@ -137,7 +136,7 @@ static TmEcode OutputPacketLogThreadInit(ThreadVars *tv, const void *initdata, v
     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);
 
index 4e8d2a65fdfd3cd7c20597e79f7a36748ff66fd5..ce11535f71a7e7ffa83d103c332f6fb68c975ef8 100644 (file)
@@ -34,9 +34,9 @@ typedef int (*PacketLogger)(ThreadVars *, void *thread_data, const Packet *);
  */
 typedef bool (*PacketLogCondition)(ThreadVars *, void *thread_data, const Packet *);
 
-int OutputRegisterPacketLogger(LoggerId logger_id, const char *name,
-    PacketLogger LogFunc, PacketLogCondition ConditionFunc, OutputCtx *,
-    ThreadInitFunc, ThreadDeinitFunc, ThreadExitPrintStatsFunc);
+int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogger LogFunc,
+        PacketLogCondition ConditionFunc, void *initdata, ThreadInitFunc, ThreadDeinitFunc,
+        ThreadExitPrintStatsFunc);
 
 void OutputPacketLoggerRegister(void);