]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/sigorder: remove data structs from global namespace
authorVictor Julien <vjulien@oisf.net>
Wed, 30 Oct 2024 08:06:19 +0000 (09:06 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 28 Nov 2024 13:59:20 +0000 (14:59 +0100)
Rename types enum to reflect it is not using a radix tree anymore.

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

index 28bfd71569dcae4f12d3ca1f8cda0456907fe311..4a4ad1de9cd0b9b990c8ae840692fa0835565b67 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2024 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
 #define DETECT_XBITS_TYPE_SET_READ 3
 #define DETECT_XBITS_TYPE_SET      4
 
+/**
+ * \brief Different kinds of helper data that can be used by the signature
+ *        ordering module.  Used by the "user" field in SCSigSignatureWrapper
+ */
+typedef enum {
+    DETECT_SIGORDER_FLOWBITS,
+    DETECT_SIGORDER_FLOWVAR,
+    DETECT_SIGORDER_PKTVAR,
+    DETECT_SIGORDER_FLOWINT,
+    DETECT_SIGORDER_HOSTBITS,
+    DETECT_SIGORDER_IPPAIRBITS,
+    DETECT_SIGORDER_MAX
+} DetectSigorderUserDataType;
+
+/**
+ * \brief Signature wrapper used by signature ordering module while ordering
+ *        signatures
+ */
+typedef struct SCSigSignatureWrapper_ {
+    /* the wrapped signature */
+    Signature *sig;
+
+    /* user data that is to be associated with this sigwrapper */
+    int user[DETECT_SIGORDER_MAX];
+
+    struct SCSigSignatureWrapper_ *next;
+} SCSigSignatureWrapper;
+
+/**
+ * \brief Structure holding the signature ordering function used by the
+ *        signature ordering module
+ */
+typedef struct SCSigOrderFunc_ {
+    /* Pointer to the Signature Ordering function */
+    int (*SWCompare)(SCSigSignatureWrapper *sw1, SCSigSignatureWrapper *sw2);
+
+    struct SCSigOrderFunc_ *next;
+} SCSigOrderFunc;
 
 /**
  * \brief Registers a keyword-based, signature ordering function
@@ -439,7 +477,7 @@ static inline int SCSigGetXbitsType(Signature *sig, enum VarTypes type)
  */
 static inline void SCSigProcessUserDataForFlowbits(SCSigSignatureWrapper *sw)
 {
-    sw->user[SC_RADIX_USER_DATA_FLOWBITS] = SCSigGetFlowbitsType(sw->sig);
+    sw->user[DETECT_SIGORDER_FLOWBITS] = SCSigGetFlowbitsType(sw->sig);
 }
 
 /**
@@ -451,12 +489,12 @@ static inline void SCSigProcessUserDataForFlowbits(SCSigSignatureWrapper *sw)
  */
 static inline void SCSigProcessUserDataForFlowvar(SCSigSignatureWrapper *sw)
 {
-    sw->user[SC_RADIX_USER_DATA_FLOWVAR] = SCSigGetFlowvarType(sw->sig);
+    sw->user[DETECT_SIGORDER_FLOWVAR] = SCSigGetFlowvarType(sw->sig);
 }
 
 static inline void SCSigProcessUserDataForFlowint(SCSigSignatureWrapper *sw)
 {
-    sw->user[SC_RADIX_USER_DATA_FLOWINT] = SCSigGetFlowintType(sw->sig);
+    sw->user[DETECT_SIGORDER_FLOWINT] = SCSigGetFlowintType(sw->sig);
 }
 
 /**
@@ -468,7 +506,7 @@ static inline void SCSigProcessUserDataForFlowint(SCSigSignatureWrapper *sw)
  */
 static inline void SCSigProcessUserDataForPktvar(SCSigSignatureWrapper *sw)
 {
-    sw->user[SC_RADIX_USER_DATA_PKTVAR] = SCSigGetPktvarType(sw->sig);
+    sw->user[DETECT_SIGORDER_PKTVAR] = SCSigGetPktvarType(sw->sig);
 }
 
 /**
@@ -480,7 +518,7 @@ static inline void SCSigProcessUserDataForPktvar(SCSigSignatureWrapper *sw)
  */
 static inline void SCSigProcessUserDataForHostbits(SCSigSignatureWrapper *sw)
 {
-    sw->user[SC_RADIX_USER_DATA_HOSTBITS] = SCSigGetXbitsType(sw->sig, VAR_TYPE_HOST_BIT);
+    sw->user[DETECT_SIGORDER_HOSTBITS] = SCSigGetXbitsType(sw->sig, VAR_TYPE_HOST_BIT);
 }
 
 /**
@@ -492,7 +530,7 @@ static inline void SCSigProcessUserDataForHostbits(SCSigSignatureWrapper *sw)
  */
 static inline void SCSigProcessUserDataForIPPairbits(SCSigSignatureWrapper *sw)
 {
-    sw->user[SC_RADIX_USER_DATA_IPPAIRBITS] = SCSigGetXbitsType(sw->sig, VAR_TYPE_IPPAIR_BIT);
+    sw->user[DETECT_SIGORDER_IPPAIRBITS] = SCSigGetXbitsType(sw->sig, VAR_TYPE_IPPAIR_BIT);
 }
 
 /* Return 1 if sw1 comes before sw2 in the final list. */
@@ -609,8 +647,7 @@ static int SCSigOrderByActionCompare(SCSigSignatureWrapper *sw1,
 static int SCSigOrderByFlowbitsCompare(SCSigSignatureWrapper *sw1,
                                        SCSigSignatureWrapper *sw2)
 {
-    return sw1->user[SC_RADIX_USER_DATA_FLOWBITS] -
-        sw2->user[SC_RADIX_USER_DATA_FLOWBITS];
+    return sw1->user[DETECT_SIGORDER_FLOWBITS] - sw2->user[DETECT_SIGORDER_FLOWBITS];
 }
 
 /**
@@ -623,8 +660,7 @@ static int SCSigOrderByFlowbitsCompare(SCSigSignatureWrapper *sw1,
 static int SCSigOrderByFlowvarCompare(SCSigSignatureWrapper *sw1,
                                       SCSigSignatureWrapper *sw2)
 {
-    return sw1->user[SC_RADIX_USER_DATA_FLOWVAR] -
-        sw2->user[SC_RADIX_USER_DATA_FLOWVAR];
+    return sw1->user[DETECT_SIGORDER_FLOWVAR] - sw2->user[DETECT_SIGORDER_FLOWVAR];
 }
 
 /**
@@ -637,15 +673,13 @@ static int SCSigOrderByFlowvarCompare(SCSigSignatureWrapper *sw1,
 static int SCSigOrderByPktvarCompare(SCSigSignatureWrapper *sw1,
                                      SCSigSignatureWrapper *sw2)
 {
-    return sw1->user[SC_RADIX_USER_DATA_PKTVAR] -
-        sw2->user[SC_RADIX_USER_DATA_PKTVAR];
+    return sw1->user[DETECT_SIGORDER_PKTVAR] - sw2->user[DETECT_SIGORDER_PKTVAR];
 }
 
 static int SCSigOrderByFlowintCompare(SCSigSignatureWrapper *sw1,
                                       SCSigSignatureWrapper *sw2)
 {
-    return sw1->user[SC_RADIX_USER_DATA_FLOWINT] -
-        sw2->user[SC_RADIX_USER_DATA_FLOWINT];
+    return sw1->user[DETECT_SIGORDER_FLOWINT] - sw2->user[DETECT_SIGORDER_FLOWINT];
 }
 
 /**
@@ -658,8 +692,7 @@ static int SCSigOrderByFlowintCompare(SCSigSignatureWrapper *sw1,
 static int SCSigOrderByHostbitsCompare(SCSigSignatureWrapper *sw1,
                                        SCSigSignatureWrapper *sw2)
 {
-    return sw1->user[SC_RADIX_USER_DATA_HOSTBITS] -
-        sw2->user[SC_RADIX_USER_DATA_HOSTBITS];
+    return sw1->user[DETECT_SIGORDER_HOSTBITS] - sw2->user[DETECT_SIGORDER_HOSTBITS];
 }
 
 /**
@@ -672,8 +705,7 @@ static int SCSigOrderByHostbitsCompare(SCSigSignatureWrapper *sw1,
 static int SCSigOrderByIPPairbitsCompare(SCSigSignatureWrapper *sw1,
                                          SCSigSignatureWrapper *sw2)
 {
-    return sw1->user[SC_RADIX_USER_DATA_IPPAIRBITS] -
-        sw2->user[SC_RADIX_USER_DATA_IPPAIRBITS];
+    return sw1->user[DETECT_SIGORDER_IPPAIRBITS] - sw2->user[DETECT_SIGORDER_IPPAIRBITS];
 }
 
 /**
index d45a4e443ff9a4a62300057fa53243da10e0167d..d859846c629e5327549f12147dd34490eba619b0 100644 (file)
 #ifndef SURICATA_DETECT_ENGINE_SIGORDER_H
 #define SURICATA_DETECT_ENGINE_SIGORDER_H
 
-/**
- * \brief Different kinds of helper data that can be used by the signature
- *        ordering module.  Used by the "user" field in SCSigSignatureWrapper
- */
-typedef enum{
-    SC_RADIX_USER_DATA_FLOWBITS,
-    SC_RADIX_USER_DATA_FLOWVAR,
-    SC_RADIX_USER_DATA_PKTVAR,
-    SC_RADIX_USER_DATA_FLOWINT,
-    SC_RADIX_USER_DATA_HOSTBITS,
-    SC_RADIX_USER_DATA_IPPAIRBITS,
-    SC_RADIX_USER_DATA_MAX
-} SCRadixUserDataType;
-
-/**
- * \brief Signature wrapper used by signature ordering module while ordering
- *        signatures
- */
-typedef struct SCSigSignatureWrapper_ {
-    /* the wrapped signature */
-    Signature *sig;
-
-    /* user data that is to be associated with this sigwrapper */
-    int user[SC_RADIX_USER_DATA_MAX];
-
-    struct SCSigSignatureWrapper_ *next;
-} SCSigSignatureWrapper;
-
-/**
- * \brief Structure holding the signature ordering function used by the
- *        signature ordering module
- */
-typedef struct SCSigOrderFunc_ {
-    /* Pointer to the Signature Ordering function */
-    int (*SWCompare)(SCSigSignatureWrapper *sw1, SCSigSignatureWrapper *sw2);
-
-    struct SCSigOrderFunc_ *next;
-} SCSigOrderFunc;
-
 void SCSigOrderSignatures(DetectEngineCtx *);
 void SCSigRegisterSignatureOrderingFuncs(DetectEngineCtx *);
 void SCSigRegisterSignatureOrderingTests(void);
index d71764fa7d084177d66289d39611eeb9c85c096d..4c22f509a3f3edc48b97798623cdaf0a75c396da 100644 (file)
@@ -53,9 +53,8 @@
 // tx_id value to use when there is no transaction
 #define PACKET_ALERT_NOTX UINT64_MAX
 
-/* forward declarations for the structures from detect-engine-sigorder.h */
+/* forward declaration for sigorder logic in detect-engine-sigorder.[ch] */
 struct SCSigOrderFunc_;
-struct SCSigSignatureWrapper_;
 
 /* Forward declarations for structures from Rust. */
 typedef struct SCDetectRequiresStatus SCDetectRequiresStatus;