]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: pass de_ctx around as const
authorVictor Julien <vjulien@oisf.net>
Fri, 16 May 2025 14:19:33 +0000 (16:19 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 10 Jun 2025 06:36:36 +0000 (08:36 +0200)
src/detect-engine-alert.c
src/detect-engine-alert.h
src/detect-engine-tag.c
src/detect-engine-tag.h
src/detect.c

index 50b97fb7f47b5b53c6782fd1d56cb0a0af30cee9..e7f1f847c3cc26493c332a9f996ce44102cb5c86 100644 (file)
@@ -504,7 +504,7 @@ static inline void PacketAlertFinalizeProcessQueue(
  * \param det_ctx detection engine thread context
  * \param p pointer to the packet
  */
-void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
+void PacketAlertFinalize(const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
 {
     SCEnter();
 
index 9fcd33996ceeccfbbcb9e1c341ea47a114eeb4f9..1a8c8b81c3aecd42b8cbf0b22e2774dc1cc29ecb 100644 (file)
@@ -32,7 +32,7 @@ void AlertQueueInit(DetectEngineThreadCtx *det_ctx);
 void AlertQueueFree(DetectEngineThreadCtx *det_ctx);
 void AlertQueueAppend(DetectEngineThreadCtx *det_ctx, const Signature *s, Packet *p, uint64_t tx_id,
         uint8_t alert_flags);
-void PacketAlertFinalize(DetectEngineCtx *, DetectEngineThreadCtx *, Packet *);
+void PacketAlertFinalize(const DetectEngineCtx *, DetectEngineThreadCtx *, Packet *);
 #ifdef UNITTESTS
 int PacketAlertCheck(Packet *, uint32_t);
 #endif
index cef785d98b1b81c77721bbe0c97a0183ef48b48e..2cf61abae6435a7d817da26e524bfd2a000ee581 100644 (file)
@@ -520,8 +520,7 @@ static Host *GetLockedDstHost(Packet *p)
  * \param p packet
  *
  */
-void TagHandlePacket(DetectEngineCtx *de_ctx,
-                     DetectEngineThreadCtx *det_ctx, Packet *p)
+void TagHandlePacket(const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
 {
     SCEnter();
 
index 64f11f316c48be99fccd3c6e8e2fe86be8de94ea..d54493e8c4e31939e7c0e4be7e49cadc22372e07 100644 (file)
@@ -44,7 +44,7 @@
 int TagHashAddTag(DetectTagDataEntry *, Packet *);
 int TagFlowAdd(Packet *, DetectTagDataEntry *);
 
-void TagHandlePacket(DetectEngineCtx *, DetectEngineThreadCtx *, Packet *);
+void TagHandlePacket(const DetectEngineCtx *, DetectEngineThreadCtx *, Packet *);
 
 void TagInitCtx(void);
 void TagDestroyCtx(void);
index 93537aac1166da8724d4fcc2c25b196c2eb41f7b..571e03a9d8acb8bc7490df8e28d76edb683fb6f8 100644 (file)
@@ -80,19 +80,18 @@ static void DetectRunInspectIPOnly(ThreadVars *tv, const DetectEngineCtx *de_ctx
         DetectEngineThreadCtx *det_ctx, Flow * const pflow, Packet * const p);
 static inline void DetectRunGetRuleGroup(const DetectEngineCtx *de_ctx,
         Packet * const p, Flow * const pflow, DetectRunScratchpad *scratch);
-static inline void DetectRunPrefilterPkt(ThreadVars *tv,
-        DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p,
-        DetectRunScratchpad *scratch);
-static inline uint8_t DetectRulePacketRules(ThreadVars *const tv, DetectEngineCtx *const de_ctx,
-        DetectEngineThreadCtx *const det_ctx, Packet *const p, Flow *const pflow,
-        const DetectRunScratchpad *scratch);
+static inline void DetectRunPrefilterPkt(ThreadVars *tv, const DetectEngineCtx *de_ctx,
+        DetectEngineThreadCtx *det_ctx, Packet *p, DetectRunScratchpad *scratch);
+static inline uint8_t DetectRulePacketRules(ThreadVars *const tv,
+        const DetectEngineCtx *const de_ctx, DetectEngineThreadCtx *const det_ctx, Packet *const p,
+        Flow *const pflow, const DetectRunScratchpad *scratch);
 static void DetectRunTx(ThreadVars *tv, DetectEngineCtx *de_ctx,
         DetectEngineThreadCtx *det_ctx, Packet *p,
         Flow *f, DetectRunScratchpad *scratch);
 static void DetectRunFrames(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
         Packet *p, Flow *f, DetectRunScratchpad *scratch);
-static inline void DetectRunPostRules(ThreadVars *tv, DetectEngineCtx *de_ctx,
-        DetectEngineThreadCtx *det_ctx, Packet * const p, Flow * const pflow,
+static inline void DetectRunPostRules(ThreadVars *tv, const DetectEngineCtx *de_ctx,
+        DetectEngineThreadCtx *det_ctx, Packet *const p, Flow *const pflow,
         DetectRunScratchpad *scratch);
 static void DetectRunCleanup(DetectEngineThreadCtx *det_ctx,
         Packet *p, Flow * const pflow);
@@ -276,7 +275,8 @@ const SigGroupHead *SigMatchSignaturesGetSgh(const DetectEngineCtx *de_ctx,
     SCReturnPtr(sgh, "SigGroupHead");
 }
 
-static inline void DetectPrefilterCopyDeDup(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx)
+static inline void DetectPrefilterCopyDeDup(
+        const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx)
 {
     SigIntId *pf_ptr = det_ctx->pmq.rule_id_array;
     uint32_t final_cnt = det_ctx->pmq.rule_id_array_cnt;
@@ -542,13 +542,8 @@ static inline bool DetectRunInspectRuleHeader(const Packet *p, const Flow *f, co
 /** \internal
  *  \brief run packet/stream prefilter engines
  */
-static inline void DetectRunPrefilterPkt(
-    ThreadVars *tv,
-    DetectEngineCtx *de_ctx,
-    DetectEngineThreadCtx *det_ctx,
-    Packet *p,
-    DetectRunScratchpad *scratch
-)
+static inline void DetectRunPrefilterPkt(ThreadVars *tv, const DetectEngineCtx *de_ctx,
+        DetectEngineThreadCtx *det_ctx, Packet *p, DetectRunScratchpad *scratch)
 {
     /* create our prefilter mask */
     PacketCreateMask(p, &p->sig_mask, scratch->alproto, scratch->app_decoder_events);
@@ -608,9 +603,9 @@ static int SortHelper(const void *a, const void *b)
     return sa->iid > sb->iid ? 1 : -1;
 }
 
-static inline uint8_t DetectRulePacketRules(ThreadVars *const tv, DetectEngineCtx *const de_ctx,
-        DetectEngineThreadCtx *const det_ctx, Packet *const p, Flow *const pflow,
-        const DetectRunScratchpad *scratch)
+static inline uint8_t DetectRulePacketRules(ThreadVars *const tv,
+        const DetectEngineCtx *const de_ctx, DetectEngineThreadCtx *const det_ctx, Packet *const p,
+        Flow *const pflow, const DetectRunScratchpad *scratch)
 {
     uint8_t action = 0;
     bool fw_verdict = false;
@@ -966,13 +961,9 @@ static DetectRunScratchpad DetectRunSetup(
     return pad;
 }
 
-static inline void DetectRunPostRules(
-    ThreadVars *tv,
-    DetectEngineCtx *de_ctx,
-    DetectEngineThreadCtx *det_ctx,
-    Packet * const p,
-    Flow * const pflow,
-    DetectRunScratchpad *scratch)
+static inline void DetectRunPostRules(ThreadVars *tv, const DetectEngineCtx *de_ctx,
+        DetectEngineThreadCtx *det_ctx, Packet *const p, Flow *const pflow,
+        DetectRunScratchpad *scratch)
 {
     /* so now let's iterate the alerts and remove the ones after a pass rule
      * matched (if any). This is done inside PacketAlertFinalize() */