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

Ticket: #7227

src/output-streaming.c
src/output-streaming.h

index 2c24a8c3d7a6ae81f4b430459e5471611ab10962..a2e3067b081c1adbc0a6f22333c415f0bebe37eb 100644 (file)
@@ -49,7 +49,7 @@ typedef struct OutputStreamingLoggerThreadData_ {
  * log module (e.g. http.log) with different output ctx'. */
 typedef struct OutputStreamingLogger_ {
     StreamingLogger LogFunc;
-    OutputCtx *output_ctx;
+    void *initdata;
     struct OutputStreamingLogger_ *next;
     const char *name;
     LoggerId logger_id;
@@ -61,7 +61,7 @@ typedef struct OutputStreamingLogger_ {
 static OutputStreamingLogger *list = NULL;
 
 int OutputRegisterStreamingLogger(LoggerId id, const char *name, StreamingLogger LogFunc,
-        OutputCtx *output_ctx, enum OutputStreamingType type, ThreadInitFunc ThreadInit,
+        void *initdata, enum OutputStreamingType type, ThreadInitFunc ThreadInit,
         ThreadDeinitFunc ThreadDeinit)
 {
     OutputStreamingLogger *op = SCCalloc(1, sizeof(*op));
@@ -69,7 +69,7 @@ int OutputRegisterStreamingLogger(LoggerId id, const char *name, StreamingLogger
         return -1;
 
     op->LogFunc = LogFunc;
-    op->output_ctx = output_ctx;
+    op->initdata = initdata;
     op->name = name;
     op->logger_id = id;
     op->type = type;
@@ -372,7 +372,7 @@ static TmEcode OutputStreamingLogThreadInit(ThreadVars *tv, const void *initdata
     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 40633e02b4a1a79bb2edaf54ff188d526dcea7d5..1af4058fe4bb30b1192a78bb5a6a11058b4370a8 100644 (file)
@@ -43,7 +43,7 @@ typedef int (*StreamingLogger)(ThreadVars *, void *thread_data,
         uint64_t tx_id, uint8_t flags);
 
 int OutputRegisterStreamingLogger(LoggerId id, const char *name, StreamingLogger LogFunc,
-        OutputCtx *, enum OutputStreamingType, ThreadInitFunc ThreadInit,
+        void *initdata, enum OutputStreamingType, ThreadInitFunc ThreadInit,
         ThreadDeinitFunc ThreadDeinit);
 
 void OutputStreamingLoggerRegister (void);