]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-tx: use void * instead of OutputCtx
authorJason Ish <jason.ish@oisf.net>
Wed, 28 Aug 2024 23:17:50 +0000 (17:17 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 31 Aug 2024 08:53:59 +0000 (10:53 +0200)
Using OutputCtx results in the low level output-tx packet logger being
aware of Suricata's higher level loggers that use OutputCtx, for the
low level logger this is purely opaque data that may not be an
OutputCtx for custom loggers.

Ticket: #7227

src/output-tx.c
src/output-tx.h

index 06c8c98c735764d630b07a43865f17ae0b5def47..ca1e55441c6850cab6b1f5a2108cc74fd9883d03 100644 (file)
@@ -49,7 +49,7 @@ typedef struct OutputTxLogger_ {
     AppProto alproto;
     TxLogger LogFunc;
     TxLoggerCondition LogCondition;
-    OutputCtx *output_ctx;
+    void *initdata;
     struct OutputTxLogger_ *next;
     const char *name;
     LoggerId logger_id;
@@ -63,13 +63,10 @@ typedef struct OutputTxLogger_ {
 
 static OutputTxLogger **list = NULL;
 
-int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto,
-                           TxLogger LogFunc,
-                           OutputCtx *output_ctx, int tc_log_progress,
-                           int ts_log_progress, TxLoggerCondition LogCondition,
-                           ThreadInitFunc ThreadInit,
-                           ThreadDeinitFunc ThreadDeinit,
-                           void (*ThreadExitPrintStats)(ThreadVars *, void *))
+int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, TxLogger LogFunc,
+        void *initdata, int tc_log_progress, int ts_log_progress, TxLoggerCondition LogCondition,
+        ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
+        void (*ThreadExitPrintStats)(ThreadVars *, void *))
 {
     if (list == NULL) {
         list = SCCalloc(ALPROTO_MAX, sizeof(OutputTxLogger *));
@@ -91,7 +88,7 @@ int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto,
     op->alproto = alproto;
     op->LogFunc = LogFunc;
     op->LogCondition = LogCondition;
-    op->output_ctx = output_ctx;
+    op->initdata = initdata;
     op->name = name;
     op->logger_id = id;
     op->ThreadInit = ThreadInit;
@@ -560,7 +557,7 @@ static TmEcode OutputTxLogThreadInit(ThreadVars *tv, const void *_initdata, void
         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 cf7ffe7ff71d3d0c3deea78f725e6ebfcc77df5f..85c2f229de72956b9a70a44be32853f4f3f1ed54 100644 (file)
@@ -38,12 +38,9 @@ typedef int (*TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f
 typedef bool (*TxLoggerCondition)(
         ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id);
 
-int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto,
-        TxLogger LogFunc,
-        OutputCtx *, int tc_log_progress, int ts_log_progress,
-        TxLoggerCondition LogCondition,
-        ThreadInitFunc, ThreadDeinitFunc,
-        void (*ThreadExitPrintStats)(ThreadVars *, void *));
+int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, TxLogger LogFunc,
+        void *, int tc_log_progress, int ts_log_progress, TxLoggerCondition LogCondition,
+        ThreadInitFunc, ThreadDeinitFunc, void (*ThreadExitPrintStats)(ThreadVars *, void *));
 
 void OutputTxLoggerRegister (void);