]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: cleanup built-in list id's
authorVictor Julien <victor@inliniac.net>
Mon, 12 Dec 2016 11:20:46 +0000 (12:20 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 16 Feb 2017 09:35:40 +0000 (10:35 +0100)
src/detect-engine.c
src/detect-parse.c
src/detect.c
src/detect.h

index b0941fe8427b3557d5e82ea1384cdffd4e8f54df..8fc6fb766c6c3f5bf97e087757200d01a88f24d4 100644 (file)
@@ -161,7 +161,7 @@ int DetectEngineAppInspectionEngine2Signature(Signature *s)
 
     /* convert lists to SigMatchData arrays */
     int i = 0;
-    for (i = DETECT_SM_LIST_BUILTIN_MAX; i < nlists; i++) {
+    for (i = DETECT_SM_LIST_DYNAMIC_START; i < nlists; i++) {
         if (s->init_data->smlists[i] == NULL)
             continue;
 
@@ -267,7 +267,7 @@ void DetectEngineAppInspectionEngineSignatureFree(Signature *s)
 #include "util-hash-lookup3.h"
 
 static HashListTable *g_buffer_type_hash = NULL;
-static int g_buffer_type_id = DETECT_SM_LIST_MAX; // past DETECT_SM_LIST_NOTSET
+static int g_buffer_type_id = DETECT_SM_LIST_DYNAMIC_START;
 static int g_buffer_type_reg_closed = 0;
 
 typedef struct DetectBufferType_ {
@@ -515,6 +515,7 @@ void DetectBufferTypeFinalizeRegistration(void)
     g_buffer_type_map = SCCalloc(size, sizeof(DetectBufferType *));
     BUG_ON(!g_buffer_type_map);
 
+    SCLogDebug("DETECT_SM_LIST_DYNAMIC_START %u", DETECT_SM_LIST_DYNAMIC_START);
     HashListTableBucket *b = HashListTableGetListHead(g_buffer_type_hash);
     while (b) {
         DetectBufferType *map = HashListTableGetListData(b);
@@ -2816,11 +2817,8 @@ const char *DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type)
         case DETECT_SM_LIST_THRESHOLD:
             return "threshold";
 
-        case DETECT_SM_LIST_BUILTIN_MAX:
         case DETECT_SM_LIST_MAX:
             return "max (internal)";
-        case DETECT_SM_LIST_NOTSET:
-            return "not set (internal)";
     }
     return "error";
 }
index 5f59ba6b14c771de3d4c99716f490ecaf606557c..64aaff96e53a9adadb691fa3e42921d81ec20fa5 100644 (file)
@@ -148,7 +148,6 @@ const char *DetectListToHumanString(int list)
         CASE_CODE_STRING(DETECT_SM_LIST_SUPPRESS, "suppress");
         CASE_CODE_STRING(DETECT_SM_LIST_THRESHOLD, "threshold");
         CASE_CODE_STRING(DETECT_SM_LIST_MAX, "max (internal)");
-        CASE_CODE_STRING(DETECT_SM_LIST_NOTSET, "not set (internal)");
     }
 #undef CASE_CODE_STRING
     return "unknown";
@@ -167,7 +166,6 @@ const char *DetectListToString(int list)
         CASE_CODE(DETECT_SM_LIST_SUPPRESS);
         CASE_CODE(DETECT_SM_LIST_THRESHOLD);
         CASE_CODE(DETECT_SM_LIST_MAX);
-        CASE_CODE(DETECT_SM_LIST_NOTSET);
     }
     return "unknown";
 }
@@ -1117,7 +1115,7 @@ static void SigMatchFreeArrays(Signature *s, int ctxs)
 {
     if (s != NULL) {
         int type;
-        for (type = 0; type < DETECT_SM_LIST_BUILTIN_MAX; type++) {
+        for (type = 0; type < DETECT_SM_LIST_MAX; type++) {
             if (s->sm_arrays[type] != NULL) {
                 if (ctxs) {
                     SigMatchData *smd = s->sm_arrays[type];
index 62de800c0a5d0d5d2c180b1e478af09f9dfb25ad..cb21cbf9e3b856d1a105f06587005b2419f6063e 100644 (file)
@@ -3780,8 +3780,9 @@ static int SigMatchPrepare(DetectEngineCtx *de_ctx)
         /* set up inspect engines */
         DetectEngineAppInspectionEngine2Signature(s);
 
+        /* built-ins */
         int type;
-        for (type = 0; type < DETECT_SM_LIST_BUILTIN_MAX; type++) {
+        for (type = 0; type < DETECT_SM_LIST_MAX; type++) {
             SigMatch *sm = s->init_data->smlists[type];
             s->sm_arrays[type] = SigMatchList2DataArray(sm);
         }
index e7f6a5765d449774b6abd3e0f45a2b6f63a27666..8b752e4b0397b06bcd0d49fdbe814422bcf5d0b2 100644 (file)
@@ -108,17 +108,17 @@ enum DetectSigmatchListEnum {
     DETECT_SM_LIST_SUPPRESS,
     DETECT_SM_LIST_THRESHOLD,
 
-    /* used for Signature->list, which indicates which list
-     * we're adding keywords to in cases of sticky buffers like
-     * file_data */
-    DETECT_SM_LIST_NOTSET,
-
-    DETECT_SM_LIST_BUILTIN_MAX,
-
     DETECT_SM_LIST_MAX,
 
+    /* start of dynamically registered lists */
+    DETECT_SM_LIST_DYNAMIC_START = DETECT_SM_LIST_MAX,
 };
 
+/* used for Signature->list, which indicates which list
+ * we're adding keywords to in cases of sticky buffers like
+ * file_data */
+#define DETECT_SM_LIST_NOTSET INT_MAX
+
 /* a is ... than b */
 enum {
     ADDRESS_ER = -1, /**< error e.g. compare ipv4 and ipv6 */
@@ -446,7 +446,7 @@ typedef struct Signature_ {
 
     /* Matching structures for the built-ins. The others are in
      * their inspect engines. */
-    SigMatchData *sm_arrays[DETECT_SM_LIST_BUILTIN_MAX];
+    SigMatchData *sm_arrays[DETECT_SM_LIST_MAX];
 
     /* memory is still owned by the sm_lists/sm_arrays entry */
     const struct DetectFilestoreData_ *filestore_ctx;