]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/prefilter: minor function ptr cleanup
authorVictor Julien <vjulien@oisf.net>
Mon, 29 Apr 2024 18:48:32 +0000 (20:48 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 18 Jun 2024 19:09:00 +0000 (21:09 +0200)
Use a typedef'd function pointer for packet Prefilter callbacks to make
the code consistent with the other callbacks.

src/detect-engine-prefilter.c
src/detect-engine-prefilter.h
src/detect.h

index 3c06e7a01c448d15e5afce5a8ac096d70b6e1642..7d593bcfe8463f9fdc00d4ad5645158821354115 100644 (file)
@@ -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;
index fc61c47f3ccd359aa4ec6a9939f691cd046057a4..2a8bdf765ee3a442885b0704f545c08f24467c87 100644 (file)
@@ -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);
index eb90872c800d3c3ffd3797c4f18c8a4363f9526e..d0eb931fb5fca8cbb802b4feb6eb4ac3c62ebfef 100644 (file)
@@ -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;