output-packet: use void * instead of OutputCtx * for initdata

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
pull/11689/head
Jason Ish 6 months ago committed by Victor Julien
parent e5ac439226
commit 203ddb2709

@ -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);

@ -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);

Loading…
Cancel
Save