From: Jason Ish Date: Tue, 27 Aug 2024 22:41:34 +0000 (-0600) Subject: output-flow: rename register function and document X-Git-Tag: suricata-8.0.0-beta1~919 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2779ac91694067cc40ac2a84ff63c707e732e28;p=thirdparty%2Fsuricata.git output-flow: rename register function and document Rename OutputRegisterFlowLogger to SCOutputRegisterFlowLogger and document in the header file. Mark other functions in the header file as part of the internal API. Ticket: #7227 --- diff --git a/examples/plugins/c-custom-loggers/custom-logger.c b/examples/plugins/c-custom-loggers/custom-logger.c index ba4274639d..fbebbd5e98 100644 --- a/examples/plugins/c-custom-loggers/custom-logger.c +++ b/examples/plugins/c-custom-loggers/custom-logger.c @@ -94,7 +94,7 @@ static void Init(void) { SCOutputRegisterPacketLogger(LOGGER_USER, "custom-packet-logger", CustomPacketLogger, CustomPacketLoggerCondition, NULL, ThreadInit, ThreadDeinit); - OutputRegisterFlowLogger( + SCOutputRegisterFlowLogger( "custom-flow-logger", CustomFlowLogger, NULL, ThreadInit, ThreadDeinit); } diff --git a/src/output-flow.c b/src/output-flow.c index ae309777ab..b6d7bc3cdc 100644 --- a/src/output-flow.c +++ b/src/output-flow.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2022 Open Information Security Foundation +/* Copyright (C) 2007-2024 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -55,15 +55,7 @@ typedef struct OutputFlowLogger_ { static OutputFlowLogger *list = NULL; -/** - * \brief Register a new low-level flow logger. - * - * \param name The name of this logger. Its only used for debugging, - * so choose something unique. - * - * \retval 0 on success, -1 on failure. - */ -int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata, +int SCOutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit) { OutputFlowLogger *op = SCCalloc(1, sizeof(*op)); diff --git a/src/output-flow.h b/src/output-flow.h index 906921b002..d91e044ae9 100644 --- a/src/output-flow.h +++ b/src/output-flow.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2022 Open Information Security Foundation +/* Copyright (C) 2007-2024 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -30,16 +30,37 @@ #include "tm-modules.h" #include "flow.h" -/** flow logger function pointer type */ +/** + * \brief Flow logger function pointer type. + */ typedef int (*FlowLogger)(ThreadVars *, void *thread_data, Flow *f); -int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata, +/** + * \brief Register a flow logger. + * + * \param name An informational name for this logger. Used only for + * debugging. + * \param LogFunc A function that will be called to log each flow. + * \param initdata A pointer to initialization data that will be + * passed the ThreadInit. + * \param ThreadInit Thread initialization callback. + * \param ThreadDeinit Thread de-initialization callback. + * + * \retval 0 on success, -1 on failure. + */ +int SCOutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit); +/** Internal function: private API. */ void OutputFlowShutdown(void); +/** Internal function: private API. */ TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f); + +/** Internal function: private API. */ TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void **data); + +/** Internal function: private API. */ TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data); #endif /* SURICATA_OUTPUT_FLOW_H */ diff --git a/src/runmodes.c b/src/runmodes.c index e2d88bfbb4..f092e4066e 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -600,8 +600,8 @@ static void SetupOutput( { /* flow logger doesn't run in the packet path */ if (module->FlowLogFunc) { - OutputRegisterFlowLogger(module->name, module->FlowLogFunc, output_ctx, module->ThreadInit, - module->ThreadDeinit); + SCOutputRegisterFlowLogger(module->name, module->FlowLogFunc, output_ctx, + module->ThreadInit, module->ThreadDeinit); return; } /* stats logger doesn't run in the packet path */