]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-tx: rename and document transaction logger registration
authorJason Ish <jason.ish@oisf.net>
Thu, 29 Aug 2024 22:55:57 +0000 (16:55 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 31 Aug 2024 08:53:59 +0000 (10:53 +0200)
Rename OutputRegisterTxLogger to SCOutputRegisterTxLogger to make it
part of the public API as well as document.

Ticket: #7227

doc/userguide/devguide/extending/output/index.rst
src/output-tx.c
src/output-tx.h
src/runmodes.c

index cb6315e88ff01a8d0610bd4c458725b51a973dd1..c401b3c4e7bbd2c4863e1bb4793b94292577858f 100644 (file)
@@ -46,3 +46,19 @@ function:
    :language: c
    :start-at: /** \brief Register a flow logger
    :end-at: );
+
+Transaction Logging
+~~~~~~~~~~~~~~~~~~~
+
+Transaction logger can be registered with the
+``SCOutputRegisterTxLogger`` function:
+
+.. attention:: Transaction loggers cannot be registered from a plugin
+               at this time, see
+               https://redmine.openinfosecfoundation.org/issues/7236
+               for more information.
+
+.. literalinclude:: ../../../../../src/output-tx.h
+   :language: c
+   :start-at: /** \brief Register a transaction logger
+   :end-at: );
index 30fee3c37061c5b9e169cbf379980d5c9b9c522f..3a870529c1b867b00ad18a43c86d74651c982215 100644 (file)
@@ -62,7 +62,7 @@ typedef struct OutputTxLogger_ {
 
 static OutputTxLogger **list = NULL;
 
-int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, TxLogger LogFunc,
+int SCOutputRegisterTxLogger(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)
 {
index 86fe437b3223c76cc2231b98348b48614be7187e..8bf52d4c5780a95ef500c8136889edf4eacc13f8 100644 (file)
 #include "decode.h"
 #include "flow.h"
 
-/** tx logger function pointer type */
+/** \brief Transaction logger function pointer type. */
 typedef int (*TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id);
 
-/** tx logger condition function pointer type,
- *  must return true for tx that should be logged
+/** \brief Transaction logger condition function pointer type.
+ *
+ * If a TxLoggerCondition is provided to the registration function,
+ * the logger function will only be called if this return true.
  */
 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,
+/** \brief Register a transaction logger.
+ *
+ * \param logger_id An ID used to distinguish this logger from others
+ *     while profiling. For transaction logging this is only used for
+ *     some internal state tracking.
+ *
+ * \param name An informational name for this logger. Used for
+ *     debugging.
+ *
+ * \param alproto The application layer protocol this logger is for,
+ *     for example ALPROTO_DNS.
+ *
+ * \param LogFunc A pointer to the logging function.
+ *
+ * \param initdata Initialization data that will be provided to the
+ *     ThreadInit callback.
+ *
+ * \param tc_log_progress The to_client progress state required for
+ *     the log function to be called.
+ *
+ * \param ts_log_progress The to_server progress state required for
+ *     the log function to be called.
+ *
+ * \param LogCondition A pointer to a function that will be called
+ *     before the log function to test if the log function should be
+ *     called.
+ *
+ * \param ThreadInitFunc Callback a thread initialization function,
+ *     initdata will be provided.
+ *
+ * \param ThreadDeinitFunc Callback to a thread de-initialization
+ *     function for cleanup.
+ */
+int SCOutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, TxLogger LogFunc,
         void *, int tc_log_progress, int ts_log_progress, TxLoggerCondition LogCondition,
         ThreadInitFunc, ThreadDeinitFunc);
 
+/** Internal function: private API. */
 void OutputTxLoggerRegister (void);
 
+/** Internal function: private API. */
 void OutputTxShutdown(void);
 
 #endif /* SURICATA_OUTPUT_TX_H */
index 034e0e35a7cef68dfcce1bdb99a001bb7a5f15ab..048747b074c6e77b9e6b88d6e1cd2827079ba0e1 100644 (file)
@@ -622,8 +622,8 @@ static void SetupOutput(
                 module->PacketConditionFunc, output_ctx, module->ThreadInit, module->ThreadDeinit);
     } else if (module->TxLogFunc) {
         SCLogDebug("%s is a tx logger", module->name);
-        OutputRegisterTxLogger(module->logger_id, module->name, module->alproto, module->TxLogFunc,
-                output_ctx, module->tc_log_progress, module->ts_log_progress,
+        SCOutputRegisterTxLogger(module->logger_id, module->name, module->alproto,
+                module->TxLogFunc, output_ctx, module->tc_log_progress, module->ts_log_progress,
                 module->TxLogCondition, module->ThreadInit, module->ThreadDeinit);
         /* Not used with wild card loggers */
         if (module->alproto != ALPROTO_UNKNOWN) {