From: Victor Julien Date: Mon, 29 Apr 2024 18:48:32 +0000 (+0200) Subject: detect/prefilter: minor function ptr cleanup X-Git-Tag: suricata-8.0.0-beta1~1146 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c2960169c8376fcafd81f62c32eda0054c26a63;p=thirdparty%2Fsuricata.git 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. --- 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;