From 4c2960169c8376fcafd81f62c32eda0054c26a63 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 29 Apr 2024 20:48:32 +0200 Subject: [PATCH] detect/prefilter: minor function ptr cleanup Use a typedef'd function pointer for packet Prefilter callbacks to make the code consistent with the other callbacks. --- src/detect-engine-prefilter.c | 10 +++------- src/detect-engine-prefilter.h | 10 +++------- src/detect.h | 5 +++-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/detect-engine-prefilter.c b/src/detect-engine-prefilter.c index 3c06e7a01c..7d593bcfe8 100644 --- a/src/detect-engine-prefilter.c +++ b/src/detect-engine-prefilter.c @@ -199,10 +199,8 @@ void Prefilter(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, SCReturn; } -int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, - void (*PrefilterFunc)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx), - void *pectx, void (*FreeFunc)(void *pectx), - const char *name) +int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, + void *pectx, void (*FreeFunc)(void *pectx), const char *name) { if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL) return -1; @@ -234,9 +232,7 @@ int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, } int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, - void (*PrefilterFunc)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx), - void *pectx, void (*FreeFunc)(void *pectx), - const char *name) + PrefilterPktFn PrefilterFunc, void *pectx, void (*FreeFunc)(void *pectx), const char *name) { if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL) return -1; diff --git a/src/detect-engine-prefilter.h b/src/detect-engine-prefilter.h index fc61c47f3c..2a8bdf765e 100644 --- a/src/detect-engine-prefilter.h +++ b/src/detect-engine-prefilter.h @@ -50,14 +50,10 @@ typedef struct PrefilterStore_ { void Prefilter(DetectEngineThreadCtx *, const SigGroupHead *, Packet *p, const uint8_t flags); -int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, - void (*Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx), - void *pectx, void (*FreeFunc)(void *pectx), - const char *name); +int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, + void *pectx, void (*FreeFunc)(void *pectx), const char *name); int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, - void (*Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx), - void *pectx, void (*FreeFunc)(void *pectx), - const char *name); + PrefilterPktFn PrefilterFunc, void *pectx, void (*FreeFunc)(void *pectx), const char *name); int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterTxFn PrefilterTxFunc, const AppProto alproto, const int tx_min_progress, void *pectx, void (*FreeFunc)(void *pectx), const char *name); diff --git a/src/detect.h b/src/detect.h index eb90872c80..d0eb931fb5 100644 --- a/src/detect.h +++ b/src/detect.h @@ -1375,6 +1375,7 @@ typedef struct MpmStore_ { } MpmStore; +typedef void (*PrefilterPktFn)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx); typedef void (*PrefilterFrameFn)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, const struct Frames *frames, const struct Frame *frame); @@ -1397,7 +1398,7 @@ typedef struct PrefilterEngineList_ { * for other engines. */ void *pectx; - void (*Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx); + PrefilterPktFn Prefilter; PrefilterTxFn PrefilterTx; PrefilterFrameFn PrefilterFrame; @@ -1429,7 +1430,7 @@ typedef struct PrefilterEngine_ { void *pectx; union { - void (*Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx); + PrefilterPktFn Prefilter; PrefilterTxFn PrefilterTx; PrefilterFrameFn PrefilterFrame; } cb; -- 2.47.2