]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: pass SigMatchData to inspect functions
authorVictor Julien <victor@inliniac.net>
Sat, 15 Oct 2016 20:37:07 +0000 (22:37 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 16 Feb 2017 09:35:37 +0000 (10:35 +0100)
67 files changed:
src/detect-app-layer-event.c
src/detect-base64-data.c
src/detect-base64-decode.c
src/detect-base64-decode.h
src/detect-byte-extract.c
src/detect-byte-extract.h
src/detect-dnp3.c
src/detect-engine-content-inspection.c
src/detect-engine-content-inspection.h
src/detect-engine-dcepayload.c
src/detect-engine-dns.c
src/detect-engine-dns.h
src/detect-engine-enip.c
src/detect-engine-enip.h
src/detect-engine-file.c
src/detect-engine-file.h
src/detect-engine-filedata-smtp.c
src/detect-engine-filedata-smtp.h
src/detect-engine-hcbd.c
src/detect-engine-hcbd.h
src/detect-engine-hcd.c
src/detect-engine-hcd.h
src/detect-engine-hhd.c
src/detect-engine-hhd.h
src/detect-engine-hhhd.c
src/detect-engine-hhhd.h
src/detect-engine-hmd.c
src/detect-engine-hmd.h
src/detect-engine-hrhd.c
src/detect-engine-hrhd.h
src/detect-engine-hrhhd.c
src/detect-engine-hrhhd.h
src/detect-engine-hrud.c
src/detect-engine-hrud.h
src/detect-engine-hsbd.c
src/detect-engine-hsbd.h
src/detect-engine-hscd.c
src/detect-engine-hscd.h
src/detect-engine-hsmd.c
src/detect-engine-hsmd.h
src/detect-engine-hua.c
src/detect-engine-hua.h
src/detect-engine-modbus.c
src/detect-engine-modbus.h
src/detect-engine-payload.c
src/detect-engine-state.c
src/detect-engine-template.c
src/detect-engine-template.h
src/detect-engine-tls.c
src/detect-engine-tls.h
src/detect-engine-uri.c
src/detect-engine-uri.h
src/detect-engine.c
src/detect-fileext.c
src/detect-filemagic.c
src/detect-filename.c
src/detect-filesize.c
src/detect-filestore.c
src/detect-http-request-line.c
src/detect-http-response-line.c
src/detect-lua.c
src/detect-lua.h
src/detect-pcre.c
src/detect-pcre.h
src/detect.h
src/util-detect-file-hash.c
src/util-detect-file-hash.h

index 38504c14b67a2f68dbc4eb95beede363b40c27d6..3e95fb57e07e905ed1f2cc6e39029c31a45de8cc 100644 (file)
@@ -57,7 +57,7 @@ static void DetectAppLayerEventRegisterTests(void);
 static void DetectAppLayerEventFree(void *);
 static int DetectEngineAptEventInspect(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate,
         void *tx, uint64_t tx_id);
 
@@ -88,7 +88,7 @@ void DetectAppLayerEventRegister(void)
 
 static int DetectEngineAptEventInspect(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate,
         void *tx, uint64_t tx_id)
 {
@@ -102,15 +102,20 @@ static int DetectEngineAptEventInspect(ThreadVars *tv,
     if (decoder_events == NULL)
         goto end;
 
-    for ( ; sm != NULL; sm = sm->next) {
-        aled = (DetectAppLayerEventData *)sm->ctx;
+    while (1) {
+        aled = (DetectAppLayerEventData *)smd->ctx;
         KEYWORD_PROFILING_START;
+
         if (AppLayerDecoderEventsIsEventSet(decoder_events, aled->event_id)) {
-            KEYWORD_PROFILING_END(det_ctx, sm->type, 1);
+            KEYWORD_PROFILING_END(det_ctx, smd->type, 1);
+
+            if (smd->is_last)
+                break;
+            smd++;
             continue;
         }
 
-        KEYWORD_PROFILING_END(det_ctx, sm->type, 0);
+        KEYWORD_PROFILING_END(det_ctx, smd->type, 0);
         goto end;
     }
 
index ce54f1d661fc2449c5067874f5681a8047eb9b9d..d90d0925134c6f9b015110fff9e3ec121fb03fd2 100644 (file)
@@ -75,7 +75,7 @@ int DetectBase64DataDoMatch(DetectEngineCtx *de_ctx,
 {
     if (det_ctx->base64_decoded_len) {
         return DetectEngineContentInspection(de_ctx, det_ctx, s,
-            s->sm_lists[DETECT_SM_LIST_BASE64_DATA], f, det_ctx->base64_decoded,
+            s->sm_arrays[DETECT_SM_LIST_BASE64_DATA], f, det_ctx->base64_decoded,
             det_ctx->base64_decoded_len, 0,
             DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, NULL);
     }
index 251a89f9cdfd3cfbd77e8bc3f0b0b95b72a6b615..638e76203e46f307eac7bb2079eb645e57a6e402 100644 (file)
@@ -55,9 +55,9 @@ void DetectBase64DecodeRegister(void)
 }
 
 int DetectBase64DecodeDoMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
-    const SigMatch *sm, uint8_t *payload, uint32_t payload_len)
+    const SigMatchData *smd, uint8_t *payload, uint32_t payload_len)
 {
-    DetectBase64Decode *data = (DetectBase64Decode *)sm->ctx;
+    DetectBase64Decode *data = (DetectBase64Decode *)smd->ctx;
     int decode_len;
 
 #if 0
index e2f602313dadd94dddb908db71edeece829e28bc..4ae19cd93d6b9177d9c7ace7f3c4f98bc2f68bc0 100644 (file)
@@ -27,7 +27,7 @@ typedef struct DetectBase64Decode_ {
 } DetectBase64Decode;
 
 void DetectBase64DecodeRegister(void);
-int DetectBase64DecodeDoMatch(DetectEngineThreadCtx *,
-    const Signature *, const SigMatch *, uint8_t *, uint32_t);
+int DetectBase64DecodeDoMatch(DetectEngineThreadCtx *, const Signature *,
+    const SigMatchData *, uint8_t *, uint32_t);
 
 #endif /* __DETECT_BASE64_DECODE_H__ */
index 24b577bc84be65436fc445656637ba06be7c4e60..db379031b35cdd5594a5dbf48b5f37a0e2c8c5e0 100644 (file)
@@ -110,12 +110,12 @@ void DetectByteExtractRegister(void)
     DetectSetupParseRegexes(PARSE_REGEX, &parse_regex, &parse_regex_study);
 }
 
-int DetectByteExtractDoMatch(DetectEngineThreadCtx *det_ctx, const SigMatch *sm,
+int DetectByteExtractDoMatch(DetectEngineThreadCtx *det_ctx, const SigMatchData *smd,
                              const Signature *s, uint8_t *payload,
                              uint16_t payload_len, uint64_t *value,
                              uint8_t endian)
 {
-    DetectByteExtractData *data = (DetectByteExtractData *)sm->ctx;
+    DetectByteExtractData *data = (DetectByteExtractData *)smd->ctx;
     uint8_t *ptr = NULL;
     int32_t len = 0;
     uint64_t val = 0;
index 799d35627be208d87f728a5c5860cb69ea0caae7..be3641bf270aea2c085b14aedc654cdb492a795d 100644 (file)
@@ -62,7 +62,7 @@ typedef struct DetectByteExtractData_ {
 void DetectByteExtractRegister(void);
 
 SigMatch *DetectByteExtractRetrieveSMVar(const char *, const Signature *);
-int DetectByteExtractDoMatch(DetectEngineThreadCtx *, const SigMatch *, const Signature *,
+int DetectByteExtractDoMatch(DetectEngineThreadCtx *, const SigMatchData *, const Signature *,
                              uint8_t *, uint16_t, uint64_t *, uint8_t);
 
 #endif /* __DETECT_BYTEEXTRACT_H__ */
index 92922e8f05bec6c20621b9476c0e94b5eaa9f13d..b2b945d0bcd2fbad66c239c119179302dbbb5104 100644 (file)
@@ -139,7 +139,7 @@ static char *TrimString(char *str)
 }
 
 static int DetectEngineInspectDNP3Data(ThreadVars *tv, DetectEngineCtx *de_ctx,
-    DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatch *sm,
+    DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd,
     Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     SCEnter();
@@ -150,12 +150,12 @@ static int DetectEngineInspectDNP3Data(ThreadVars *tv, DetectEngineCtx *de_ctx,
     /* Content match - should probably be put into its own file. */
     if (flags & STREAM_TOSERVER && tx->request_buffer != NULL) {
         r = DetectEngineContentInspection(de_ctx, det_ctx, s,
-            s->sm_lists[DETECT_SM_LIST_DNP3_DATA_MATCH], f, tx->request_buffer,
+            s->sm_arrays[DETECT_SM_LIST_DNP3_DATA_MATCH], f, tx->request_buffer,
             tx->request_buffer_len, 0, 0, NULL);
     }
     else if (flags & STREAM_TOCLIENT && tx->response_buffer != NULL) {
         r = DetectEngineContentInspection(de_ctx, det_ctx, s,
-            s->sm_lists[DETECT_SM_LIST_DNP3_DATA_MATCH], f, tx->response_buffer,
+            s->sm_arrays[DETECT_SM_LIST_DNP3_DATA_MATCH], f, tx->response_buffer,
             tx->response_buffer_len, 0, 0, NULL);
     }
 
@@ -163,7 +163,7 @@ static int DetectEngineInspectDNP3Data(ThreadVars *tv, DetectEngineCtx *de_ctx,
 }
 
 static int DetectEngineInspectDNP3(ThreadVars *tv, DetectEngineCtx *de_ctx,
-    DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatch *sm,
+    DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd,
     Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     return DetectEngineInspectGenericList(tv, de_ctx, det_ctx, s, f, flags,
index 95f4fc7fdb437fde436832e63250d9aee988c605..e7f83da7c175f6536743f9135d2d779beb230853 100644 (file)
@@ -99,7 +99,7 @@
  *  \retval 1 match
  */
 int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-                                  const Signature *s, const SigMatch *sm,
+                                  const Signature *s, const SigMatchData *smd,
                                   Flow *f,
                                   uint8_t *buffer, uint32_t buffer_len,
                                   uint32_t stream_start_offset,
@@ -112,19 +112,19 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
 
     if (det_ctx->inspection_recursion_counter == de_ctx->inspection_recursion_limit) {
         det_ctx->discontinue_matching = 1;
-        KEYWORD_PROFILING_END(det_ctx, sm->type, 0);
+        KEYWORD_PROFILING_END(det_ctx, smd->type, 0);
         SCReturnInt(0);
     }
 
-    if (sm == NULL || buffer_len == 0) {
-        KEYWORD_PROFILING_END(det_ctx, sm->type, 0);
+    if (smd == NULL || buffer_len == 0) {
+        KEYWORD_PROFILING_END(det_ctx, smd->type, 0);
         SCReturnInt(0);
     }
 
     /* \todo unify this which is phase 2 of payload inspection unification */
-    if (sm->type == DETECT_CONTENT) {
+    if (smd->type == DETECT_CONTENT) {
 
-        DetectContentData *cd = (DetectContentData *)sm->ctx;
+        DetectContentData *cd = (DetectContentData *)smd->ctx;
         SCLogDebug("inspecting content %"PRIu32" buffer_len %"PRIu32, cd->id, buffer_len);
 
         /* we might have already have this content matched by the mpm.
@@ -318,17 +318,18 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
                 /* bail out if we have no next match. Technically this is an
                  * error, as the current cd has the DETECT_CONTENT_RELATIVE_NEXT
                  * flag set. */
-                if (sm->next == NULL) {
+                if (smd->is_last) {
                     goto no_match;
                 }
 
                 SCLogDebug("content %"PRIu32, cd->id);
-                KEYWORD_PROFILING_END(det_ctx, sm->type, 1);
+                KEYWORD_PROFILING_END(det_ctx, smd->type, 1);
 
                 /* see if the next buffer keywords match. If not, we will
                  * search for another occurence of this content and see
                  * if the others match then until we run out of matches */
-                int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm->next, f, buffer, buffer_len, stream_start_offset, inspection_mode, data);
+                int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd+1,
+                        f, buffer, buffer_len, stream_start_offset, inspection_mode, data);
                 if (r == 1) {
                     SCReturnInt(1);
                 }
@@ -343,10 +344,10 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
 
         } while(1);
 
-    } else if (sm->type == DETECT_ISDATAAT) {
+    } else if (smd->type == DETECT_ISDATAAT) {
         SCLogDebug("inspecting isdataat");
 
-        DetectIsdataatData *id = (DetectIsdataatData *)sm->ctx;
+        DetectIsdataatData *id = (DetectIsdataatData *)smd->ctx;
         if (id->flags & ISDATAAT_RELATIVE) {
             if (det_ctx->buffer_offset + id->dataat > buffer_len) {
                 SCLogDebug("det_ctx->buffer_offset + id->dataat %"PRIu32" > %"PRIu32, det_ctx->buffer_offset + id->dataat, buffer_len);
@@ -373,9 +374,9 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
             }
         }
 
-    } else if (sm->type == DETECT_PCRE) {
+    } else if (smd->type == DETECT_PCRE) {
         SCLogDebug("inspecting pcre");
-        DetectPcreData *pe = (DetectPcreData *)sm->ctx;
+        DetectPcreData *pe = (DetectPcreData *)smd->ctx;
         uint32_t prev_buffer_offset = det_ctx->buffer_offset;
         uint32_t prev_offset = 0;
         int r = 0;
@@ -385,7 +386,7 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
             Packet *p = NULL;
             if (inspection_mode == DETECT_ENGINE_CONTENT_INSPECTION_MODE_PAYLOAD)
                 p = (Packet *)data;
-            r = DetectPcrePayloadMatch(det_ctx, s, sm, p, f,
+            r = DetectPcrePayloadMatch(det_ctx, s, smd, p, f,
                                        buffer, buffer_len);
             if (r == 0) {
                 goto no_match;
@@ -395,7 +396,7 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
                 SCLogDebug("no relative match coming up, so this is a match");
                 goto match;
             }
-            KEYWORD_PROFILING_END(det_ctx, sm->type, 1);
+            KEYWORD_PROFILING_END(det_ctx, smd->type, 1);
 
             /* save it, in case we need to do a pcre match once again */
             prev_offset = det_ctx->pcre_match_start_offset;
@@ -403,8 +404,8 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
             /* see if the next payload keywords match. If not, we will
              * search for another occurence of this pcre and see
              * if the others match, until we run out of matches */
-            r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm->next,
-                                              f, buffer, buffer_len, stream_start_offset, inspection_mode, data);
+            r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd+1,
+                    f, buffer, buffer_len, stream_start_offset, inspection_mode, data);
             if (r == 1) {
                 SCReturnInt(1);
             }
@@ -416,8 +417,8 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
             det_ctx->pcre_match_start_offset = prev_offset;
         } while (1);
 
-    } else if (sm->type == DETECT_BYTETEST) {
-        DetectBytetestData *btd = (DetectBytetestData *)sm->ctx;
+    } else if (smd->type == DETECT_BYTETEST) {
+        DetectBytetestData *btd = (DetectBytetestData *)smd->ctx;
         uint8_t flags = btd->flags;
         int32_t offset = btd->offset;
         uint64_t value = btd->value;
@@ -438,15 +439,15 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
                       DETECT_BYTETEST_LITTLE: 0);
         }
 
-        if (DetectBytetestDoMatch(det_ctx, s, sm->ctx, buffer, buffer_len, flags,
+        if (DetectBytetestDoMatch(det_ctx, s, smd->ctx, buffer, buffer_len, flags,
                                   offset, value) != 1) {
             goto no_match;
         }
 
         goto match;
 
-    } else if (sm->type == DETECT_BYTEJUMP) {
-        DetectBytejumpData *bjd = (DetectBytejumpData *)sm->ctx;
+    } else if (smd->type == DETECT_BYTEJUMP) {
+        DetectBytejumpData *bjd = (DetectBytejumpData *)smd->ctx;
         uint8_t flags = bjd->flags;
         int32_t offset = bjd->offset;
 
@@ -464,16 +465,16 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
                       DETECT_BYTEJUMP_LITTLE: 0);
         }
 
-        if (DetectBytejumpDoMatch(det_ctx, s, sm->ctx, buffer, buffer_len,
+        if (DetectBytejumpDoMatch(det_ctx, s, smd->ctx, buffer, buffer_len,
                                   flags, offset) != 1) {
             goto no_match;
         }
 
         goto match;
 
-    } else if (sm->type == DETECT_BYTE_EXTRACT) {
+    } else if (smd->type == DETECT_BYTE_EXTRACT) {
 
-        DetectByteExtractData *bed = (DetectByteExtractData *)sm->ctx;
+        DetectByteExtractData *bed = (DetectByteExtractData *)smd->ctx;
         uint8_t endian = bed->endian;
 
         /* if we have dce enabled we will have to use the endianness
@@ -488,7 +489,7 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
                        DETECT_BYTE_EXTRACT_ENDIAN_LITTLE : DETECT_BYTE_EXTRACT_ENDIAN_BIG);
         }
 
-        if (DetectByteExtractDoMatch(det_ctx, sm, s, buffer,
+        if (DetectByteExtractDoMatch(det_ctx, smd, s, buffer,
                                      buffer_len,
                                      &det_ctx->bj_values[bed->local_id],
                                      endian) != 1) {
@@ -498,11 +499,11 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
         goto match;
 
         /* we should never get here, but bail out just in case */
-    } else if (sm->type == DETECT_AL_URILEN) {
+    } else if (smd->type == DETECT_AL_URILEN) {
         SCLogDebug("inspecting uri len");
 
         int r = 0;
-        DetectUrilenData *urilend = (DetectUrilenData *) sm->ctx;
+        DetectUrilenData *urilend = (DetectUrilenData *) smd->ctx;
 
         switch (urilend->mode) {
             case DETECT_URILEN_EQ:
@@ -534,10 +535,10 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
         goto no_match;
 #ifdef HAVE_LUA
     }
-    else if (sm->type == DETECT_LUA) {
+    else if (smd->type == DETECT_LUA) {
         SCLogDebug("lua starting");
 
-        if (DetectLuaMatchBuffer(det_ctx, s, sm, buffer, buffer_len,
+        if (DetectLuaMatchBuffer(det_ctx, s, smd, buffer, buffer_len,
                     det_ctx->buffer_offset, f) != 1)
         {
             SCLogDebug("lua no_match");
@@ -546,10 +547,10 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
         SCLogDebug("lua match");
         goto match;
 #endif /* HAVE_LUA */
-    } else if (sm->type == DETECT_BASE64_DECODE) {
-        if (DetectBase64DecodeDoMatch(det_ctx, s, sm, buffer, buffer_len)) {
+    } else if (smd->type == DETECT_BASE64_DECODE) {
+        if (DetectBase64DecodeDoMatch(det_ctx, s, smd, buffer, buffer_len)) {
             if (s->sm_arrays[DETECT_SM_LIST_BASE64_DATA] != NULL) {
-                KEYWORD_PROFILING_END(det_ctx, sm->type, 1);
+                KEYWORD_PROFILING_END(det_ctx, smd->type, 1);
                 if (DetectBase64DataDoMatch(de_ctx, det_ctx, s, f)) {
                     /* Base64 is a terminal list. */
                     goto final_match;
@@ -557,25 +558,26 @@ int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx
             }
         }
     } else {
-        SCLogDebug("sm->type %u", sm->type);
+        SCLogDebug("sm->type %u", smd->type);
 #ifdef DEBUG
         BUG_ON(1);
 #endif
     }
 
 no_match:
-    KEYWORD_PROFILING_END(det_ctx, sm->type, 0);
+    KEYWORD_PROFILING_END(det_ctx, smd->type, 0);
     SCReturnInt(0);
 
 match:
     /* this sigmatch matched, inspect the next one. If it was the last,
      * the buffer portion of the signature matched. */
-    if (sm->next != NULL) {
-        KEYWORD_PROFILING_END(det_ctx, sm->type, 1);
-        int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm->next, f, buffer, buffer_len, stream_start_offset, inspection_mode, data);
+    if (!smd->is_last) {
+        KEYWORD_PROFILING_END(det_ctx, smd->type, 1);
+        int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd+1,
+                f, buffer, buffer_len, stream_start_offset, inspection_mode, data);
         SCReturnInt(r);
     }
 final_match:
-    KEYWORD_PROFILING_END(det_ctx, sm->type, 1);
+    KEYWORD_PROFILING_END(det_ctx, smd->type, 1);
     SCReturnInt(1);
 }
index 8ae5d76a458c173e0eb96e54c4af811b8580a346..b3436f73661777ddaa716a9deff70cf06920e067 100644 (file)
@@ -34,7 +34,7 @@ enum {
 };
 
 int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-                                  const Signature *s, const SigMatch *sm,
+                                  const Signature *s, const SigMatchData *smd,
                                   Flow *f,
                                   uint8_t *buffer, uint32_t buffer_len,
                                   uint32_t stream_start_offset,
index ad0d1929a5198ce1a51859dff139139f9f6191ea..780b85aadae497f593590a88216f5de8f5f7d8e0 100644 (file)
@@ -85,7 +85,7 @@ int DetectEngineInspectDcePayload(DetectEngineCtx *de_ctx,
         det_ctx->discontinue_matching = 0;
         det_ctx->inspection_recursion_counter = 0;
 
-        r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_lists[DETECT_SM_LIST_DMATCH],
+        r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_arrays[DETECT_SM_LIST_DMATCH],
                                           f,
                                           dce_stub_data,
                                           dce_stub_data_len,
@@ -108,7 +108,7 @@ int DetectEngineInspectDcePayload(DetectEngineCtx *de_ctx,
         det_ctx->discontinue_matching = 0;
         det_ctx->inspection_recursion_counter = 0;
 
-        r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_lists[DETECT_SM_LIST_DMATCH],
+        r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_arrays[DETECT_SM_LIST_DMATCH],
                                           f,
                                           dce_stub_data,
                                           dce_stub_data_len,
index 7269b378ea061808e1925a509fea18e7bf91191f..d243ba025504287238279aae68de1277054cc413 100644 (file)
@@ -62,7 +62,7 @@
  */
 int DetectEngineInspectDnsQueryName(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate,
         void *txv, uint64_t tx_id)
 {
@@ -86,7 +86,7 @@ int DetectEngineInspectDnsQueryName(ThreadVars *tv,
         //PrintRawDataFp(stdout, buffer, buffer_len);
 
         r = DetectEngineContentInspection(de_ctx, det_ctx,
-                s, sm,
+                s, smd,
                 f, buffer, buffer_len, 0,
                 DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, NULL);
         if (r == 1)
index be25eb3ac1ccc13480bada9b3777100d248f03d7..ed7ef51df730ed669920ba7c388dd46ca73f7888 100644 (file)
@@ -27,15 +27,15 @@ int PrefilterTxDnsQueryRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectDnsQueryName(ThreadVars *,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *,
-        const Signature *, const SigMatch *sm,
+        const Signature *, const SigMatchData *smd,
         Flow *, uint8_t, void *, void *, uint64_t);
 int DetectEngineInspectDnsRequest(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 int DetectEngineInspectDnsResponse(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 
 #endif /* __DETECT_ENGINE_DNS_H__ */
index 720a318ac5116c9a538e57aca6c597f024aa6051..8d873196172cb4f39ca79b4e11b5bada812a0b99 100644 (file)
@@ -219,14 +219,14 @@ int CIPServiceMatch(ENIPTransaction *enip_data,
  */
 int DetectEngineInspectCIP(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm, Flow *f, uint8_t flags,
+        const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags,
         void *alstate, void *txv, uint64_t tx_id)
 {
     SCEnter();
 
 
     ENIPTransaction *tx = (ENIPTransaction *) txv;
-    DetectCipServiceData *cipserviced = (DetectCipServiceData *) sm->ctx;
+    DetectCipServiceData *cipserviced = (DetectCipServiceData *) smd->ctx;
 
     if (cipserviced == NULL)
     {
@@ -259,13 +259,13 @@ int DetectEngineInspectCIP(ThreadVars *tv,
 
 int DetectEngineInspectENIP(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     SCEnter();
 
     ENIPTransaction *tx = (ENIPTransaction *) txv;
-    DetectEnipCommandData *enipcmdd = (DetectEnipCommandData *) sm->ctx;
+    DetectEnipCommandData *enipcmdd = (DetectEnipCommandData *) smd->ctx;
 
     if (enipcmdd == NULL)
     {
index eb55917d2c7548f6872a022b93451df9bec7c7dc..23864201d2f1ce20ec0dd6243a8e9705eacf5d6a 100644 (file)
 
 int DetectEngineInspectCIP(ThreadVars *,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *,
-        const Signature *, const SigMatch *sm,
+        const Signature *, const SigMatchData *smd,
         Flow *, uint8_t, void *, void *, uint64_t);
 
 int DetectEngineInspectENIP(ThreadVars *,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *,
-        const Signature *, const SigMatch *sm,
+        const Signature *, const SigMatchData *smd,
         Flow *, uint8_t, void *, void *, uint64_t);
 
 void DetectEngineInspectENIPRegisterTests(void);
index f2f847a65ff37a3c2bf3d4991183cb75cd021f3a..7ffb355740a8c498a3d278326c400005f2f3f531 100644 (file)
@@ -74,9 +74,9 @@
  *  \note flow is not locked at this time
  */
 static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
-        Flow *f, Signature *s, const SigMatch *smi, uint8_t flags, FileContainer *ffc)
+        Flow *f, Signature *s, const SigMatchData *smd,
+        uint8_t flags, FileContainer *ffc)
 {
-    const SigMatch *sm = NULL;
     int r = 0;
     int match = 0;
     int store_r = 0;
@@ -148,22 +148,25 @@ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
             }
 
             /* run the file match functions. */
-            for (sm = smi; sm != NULL; sm = sm->next) {
-                SCLogDebug("sm %p, sm->next %p", sm, sm->next);
+            while (1) {
+                SCLogDebug("smd %p", smd);
 
-                if (sigmatch_table[sm->type].FileMatch != NULL) {
+                if (sigmatch_table[smd->type].FileMatch != NULL) {
                     KEYWORD_PROFILING_START;
-                    match = sigmatch_table[sm->type].
-                        FileMatch(tv, det_ctx, f, flags, file, s, sm);
-                    KEYWORD_PROFILING_END(det_ctx, sm->type, (match > 0));
+                    match = sigmatch_table[smd->type].
+                        FileMatch(tv, det_ctx, f, flags, file, s, smd);
+                    KEYWORD_PROFILING_END(det_ctx, smd->type, (match > 0));
                     if (match == 0) {
                         r = DETECT_ENGINE_INSPECT_SIG_CANT_MATCH;
                         break;
-                    } else if (sm->next == NULL) {
+                    } else if (smd->is_last) {
                         r = DETECT_ENGINE_INSPECT_SIG_MATCH;
                         break;
                     }
                 }
+                if (smd->is_last)
+                    break;
+                smd++;
             }
 
             /* continue inspection for other files as we may want to store
@@ -183,16 +186,15 @@ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
     } else {
         /* if we have a filestore sm with a scope > file (so tx, ssn) we
          * run it here */
-        sm = smi;
-        if (sm != NULL && sm->next == NULL && sm->type == DETECT_FILESTORE &&
-                sm->ctx != NULL)
+        if (smd != NULL && smd->is_last && smd->type == DETECT_FILESTORE &&
+                smd->ctx != NULL)
         {
-            DetectFilestoreData *fd = (DetectFilestoreData *)sm->ctx;
+            DetectFilestoreData *fd = (DetectFilestoreData *)smd->ctx;
             if (fd->scope > FILESTORE_SCOPE_DEFAULT) {
                 KEYWORD_PROFILING_START;
-                match = sigmatch_table[sm->type].
-                    FileMatch(tv, det_ctx, f, flags, /* no file */NULL, s, sm);
-                KEYWORD_PROFILING_END(det_ctx, sm->type, (match > 0));
+                match = sigmatch_table[smd->type].
+                    FileMatch(tv, det_ctx, f, flags, /* no file */NULL, s, smd);
+                KEYWORD_PROFILING_END(det_ctx, smd->type, (match > 0));
 
                 if (match == 1) {
                     r = DETECT_ENGINE_INSPECT_SIG_MATCH;
@@ -230,7 +232,7 @@ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
  */
 int DetectFileInspectHttp(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
 {
     int r = DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
@@ -242,7 +244,7 @@ int DetectFileInspectHttp(ThreadVars *tv,
     else
         ffc = htp_state->files_ts;
 
-    int match = DetectFileInspect(tv, det_ctx, f, s, sm, flags, ffc);
+    int match = DetectFileInspect(tv, det_ctx, f, s, smd, flags, ffc);
     if (match == DETECT_ENGINE_INSPECT_SIG_MATCH) {
         r = DETECT_ENGINE_INSPECT_SIG_MATCH;
     } else if (match == DETECT_ENGINE_INSPECT_SIG_CANT_MATCH) {
@@ -275,7 +277,7 @@ int DetectFileInspectHttp(ThreadVars *tv,
  */
 int DetectFileInspectSmtp(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
 {
     SCEnter();
@@ -294,7 +296,7 @@ int DetectFileInspectSmtp(ThreadVars *tv,
     else
         goto end;
 
-    int match = DetectFileInspect(tv, det_ctx, f, s, sm, flags, ffc);
+    int match = DetectFileInspect(tv, det_ctx, f, s, smd, flags, ffc);
     if (match == DETECT_ENGINE_INSPECT_SIG_MATCH) {
         r = DETECT_ENGINE_INSPECT_SIG_MATCH;
     } else if (match == DETECT_ENGINE_INSPECT_SIG_CANT_MATCH) {
index f7ea8405f18fc3fb09f7240902a91a7f0c11c199..180b2edd293ea0daf6b5f45498b414fbdf630017 100644 (file)
 
 int DetectFileInspectHttp(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 int DetectFileInspectSmtp(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 #endif /* __DETECT_ENGINE_FILE_H__ */
index 6b1049cdbaf46a152bf9a36d0cbfc35852001d15..60f24d62e9229a48e6612a0fc5fcb89f1a5ba82a 100644 (file)
@@ -175,7 +175,7 @@ end:
 
 int DetectEngineInspectSMTPFiledata(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
 {
     SMTPState *smtp_state = (SMTPState *)alstate;
@@ -201,7 +201,7 @@ int DetectEngineInspectSMTPFiledata(ThreadVars *tv,
         det_ctx->buffer_offset = 0;
         det_ctx->discontinue_matching = 0;
         det_ctx->inspection_recursion_counter = 0;
-        match = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+        match = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                               f,
                                               (uint8_t *)buffer,
                                               buffer_len,
index f9c55e3222efd1b9654c9ec89694bed4ea9ea731..a6f3fc4fa88d34dbb43d6ef914a17fb1c70eeb7c 100644 (file)
@@ -29,7 +29,7 @@ int PrefilterTxSmtpFiledataRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectSMTPFiledata(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineCleanSMTPBuffers(DetectEngineThreadCtx *det_ctx);
index 34b0bd7d00877ae4d94f477e9f09159ede6310ea..eb00951bfc9abae70f8d4b25c3ce85e6b13fa9fc 100644 (file)
@@ -258,7 +258,7 @@ int PrefilterTxHttpRequestBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
 
 int DetectEngineInspectHttpClientBody(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
 {
     HtpState *htp_state = (HtpState *)alstate;
@@ -276,7 +276,7 @@ int DetectEngineInspectHttpClientBody(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)buffer,
                                           buffer_len,
index 2cdc3e77f9ba07eddba5359e511d650d8245bbb7..c3c91a76a35bea1b069e71edb057793251bea9d7 100644 (file)
@@ -31,7 +31,7 @@ int PrefilterTxHttpRequestBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpClientBody(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineCleanHCBDBuffers(DetectEngineThreadCtx *);
index c6243f7adfaf09afa44859e9677abcf3b6b38200..8f06cda19247a50219e6f717876cd43dc2b8199b 100644 (file)
@@ -167,7 +167,7 @@ int PrefilterTxResponseCookieRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpCookie(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -191,7 +191,7 @@ int DetectEngineInspectHttpCookie(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)bstr_ptr(h->value),
                                           bstr_len(h->value),
index 621d722801fe8afbe62b9d56b6a4ea0a239540a7..bdf9c498d4e92bae7999d840a665f8ba3c0e2e36 100644 (file)
@@ -30,7 +30,7 @@ int PrefilterTxResponseCookieRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpCookie(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpCookieRegisterTests(void);
index 3554e2a476d42f69bd94cab24b84badaf7e1d60d..d17ccafd77fc6b373c6acaf5be223bdc443946ef 100644 (file)
@@ -383,7 +383,7 @@ int PrefilterTxHttpResponseHeadersRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
 
 int DetectEngineInspectHttpHeader(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
 {
     HtpState *htp_state = (HtpState *)alstate;
@@ -399,7 +399,7 @@ int DetectEngineInspectHttpHeader(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           buffer,
                                           buffer_len,
index 41e6c5252f660582cd0d920eca2ceb2d7b7cdde5..f8e06e12a7017c7a1562fc77666c0a3206c9a2a5 100644 (file)
@@ -30,7 +30,7 @@ int PrefilterTxHttpResponseHeadersRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpHeader(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineCleanHHDBuffers(DetectEngineThreadCtx *det_ctx);
index 198d975173dbbb5b46d3ca3acb6fb28374bd9b7b..f884d7a85a1e54534f27a4d1d873f26362ec4014 100644 (file)
@@ -116,7 +116,7 @@ int PrefilterTxHostnameRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpHH(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -130,7 +130,7 @@ int DetectEngineInspectHttpHH(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           hname, hname_len,
                                           0,
index 04c2cf0be8dcc2520dc9bb6cc3bf267ddf35fc23..39e16493a33c46735fd4bd860790748e434e49d4 100644 (file)
@@ -29,7 +29,7 @@ int PrefilterTxHostnameRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpHH(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpHHRegisterTests(void);
index 35cdc5969d05d5bbe7b04904993cd23108724c24..27dcb16567c7776794a96d5f97b20273fddb433c 100644 (file)
@@ -113,7 +113,7 @@ int PrefilterTxMethodRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpMethod(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -127,7 +127,7 @@ int DetectEngineInspectHttpMethod(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)bstr_ptr(tx->request_method),
                                           bstr_len(tx->request_method),
index 71f2009b6401deb8b71c71969d440c5442f59b0d..d3fe192f58ea4e2712e2d63be179fba5b1f99dbd 100644 (file)
@@ -27,7 +27,7 @@
 
 int DetectEngineInspectHttpMethod(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 int PrefilterTxMethodRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
index 50626399e4f6be2de512175bdc213e92db2500fe..9cdfbf2385a21d8401188b9f707e4226823d8167 100644 (file)
@@ -164,7 +164,7 @@ int PrefilterTxResponseHeadersRawRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpRawHeader(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     HtpTxUserData *tx_ud = NULL;
@@ -195,7 +195,7 @@ int DetectEngineInspectHttpRawHeader(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           headers_raw,
                                           headers_raw_len,
index b6deda862753805ef1936c76a60bc2870c2433a1..132ca642ba44eee3f08817df7925eaf82f3c9820 100644 (file)
@@ -30,7 +30,7 @@ int PrefilterTxResponseHeadersRawRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpRawHeader(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpRawHeaderRegisterTests(void);
index 8b335cfcf97c1b04ea0ae12138aa8574a574f55f..455b98c76737073800f95fa78ed81bf3cf8ba8ce 100644 (file)
@@ -128,7 +128,7 @@ int PrefilterTxHostnameRawRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpHRH(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     uint8_t *hname;
@@ -153,7 +153,7 @@ int DetectEngineInspectHttpHRH(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           hname, hname_len,
                                           0,
index e45b8b3bf501ea7bfb76b91d6b3c277135fcc48e..4523cbc4253a589dfd99831b29a273c7c0a63138 100644 (file)
@@ -29,7 +29,7 @@ int PrefilterTxHostnameRawRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpHRH(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpHRHRegisterTests(void);
index e5a40b50b2fa28717eb9233e34723dcec1d096d8..e41c4fdff3ea27db8ee1d9fa482e391d96bff4df 100644 (file)
@@ -113,7 +113,7 @@ int PrefilterTxRawUriRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpRawUri(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -129,7 +129,7 @@ int DetectEngineInspectHttpRawUri(ThreadVars *tv,
     det_ctx->inspection_recursion_counter = 0;
     /* Inspect all the uricontents fetched on each
      * transaction at the app layer */
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)bstr_ptr(tx->request_uri),
                                           bstr_len(tx->request_uri),
index 10137d6d2bfebfe644b600f2d0d5bfe8dd8afdf4..2d41f69650ccaaed8068aa2dd44bfafe24e4bf53 100644 (file)
@@ -30,7 +30,7 @@ int PrefilterTxRawUriRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpRawUri(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpRawUriRegisterTests(void);
index 7f40e6ea28b866c3ac2a258590499d913736bab1..58727dca013844f268afab27436cf01708e41039 100644 (file)
@@ -263,7 +263,7 @@ int PrefilterTxHttpResponseBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
 
 int DetectEngineInspectHttpServerBody(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
 {
     HtpState *htp_state = (HtpState *)alstate;
@@ -281,7 +281,7 @@ int DetectEngineInspectHttpServerBody(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)buffer,
                                           buffer_len,
index 7126aabb2ca016424efdd4dd64db3c84d6c7f09e..1187f936ef4841b4d7398d1ed5cf56d96d63be3e 100644 (file)
@@ -31,7 +31,7 @@ int PrefilterTxHttpResponseBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpServerBody(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate,
         void *tx, uint64_t tx_id);
 
index 0e73d73aa4f54db0d8b337d747ac645e8a74dd85..8a563235b167344e64faa40b6c9cd2f2e76d80a4 100644 (file)
@@ -112,7 +112,7 @@ int PrefilterTxHttpStatCodeRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpStatCode(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -126,7 +126,7 @@ int DetectEngineInspectHttpStatCode(ThreadVars *tv,
     det_ctx->discontinue_matching = 0;
     det_ctx->buffer_offset = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)bstr_ptr(tx->response_status),
                                           bstr_len(tx->response_status),
index bdcc0cfc0cd3c64ed7e07aa6185a5e2c46947290..d2e4d2fff870773be811417416feb876e23c3347 100644 (file)
@@ -29,7 +29,7 @@ int PrefilterTxHttpStatCodeRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpStatCode(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpStatCodeRegisterTests(void);
index 22e38487d9c5a9038ba091e01f7c9340155ce0f2..cb52c03535a337be26d2b7257264def5a8fb29e0 100644 (file)
@@ -112,7 +112,7 @@ int PrefilterTxHttpStatMsgRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpStatMsg(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -126,7 +126,7 @@ int DetectEngineInspectHttpStatMsg(ThreadVars *tv,
     det_ctx->discontinue_matching = 0;
     det_ctx->buffer_offset = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)bstr_ptr(tx->response_message),
                                           bstr_len(tx->response_message),
index fd48176ecef053db818ae4e7d1195b9e7583a5b7..36eee9024f49b9c25d0ea8d5c8a1b886816ae042 100644 (file)
@@ -29,7 +29,7 @@ int PrefilterTxHttpStatMsgRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpStatMsg(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpStatMsgRegisterTests(void);
index d2cbbcea7b3b828b188348093cd6d9676f2c9b5e..2511767c944e7771146a57d3a4f15a3e74a36d80 100644 (file)
@@ -121,7 +121,7 @@ int PrefilterTxUARegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpUA(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -135,7 +135,7 @@ int DetectEngineInspectHttpUA(ThreadVars *tv,
     det_ctx->buffer_offset = 0;
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           (uint8_t *)bstr_ptr(h->value),
                                           bstr_len(h->value),
index fba2d88458328499d0d1d8dd65feaabe988292b9..40c85887c7febd3e8239368fa58ce0a24080cb82 100644 (file)
@@ -29,7 +29,7 @@ int PrefilterTxUARegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpUA(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void DetectEngineHttpUARegisterTests(void);
index 38a0b6876fa8f442a1c025dabb5e293f066455bf..9e1f8537c4dd21d01bf4c39814749af7632ffa7d 100644 (file)
@@ -200,7 +200,7 @@ int DetectEngineInspectModbus(ThreadVars            *tv,
                               DetectEngineCtx       *de_ctx,
                               DetectEngineThreadCtx *det_ctx,
                               const Signature       *s,
-                              const SigMatch        *sm,
+                              const SigMatchData    *smd,
                               Flow                  *f,
                               uint8_t               flags,
                               void                  *alstate,
@@ -209,7 +209,7 @@ int DetectEngineInspectModbus(ThreadVars            *tv,
 {
     SCEnter();
     ModbusTransaction   *tx = (ModbusTransaction *)txv;
-    DetectModbus        *modbus = (DetectModbus *) sm->ctx;
+    DetectModbus        *modbus = (DetectModbus *) smd->ctx;
 
     int ret = 0;
 
index 66a174c76049768fe6a36a7631c239dca982b473..4ffe45ca681110438b203baefb3eb5e983a137dc 100644 (file)
@@ -35,7 +35,7 @@
 
 int DetectEngineInspectModbus(ThreadVars *,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *,
-        const Signature *, const SigMatch *,
+        const Signature *, const SigMatchData *,
         Flow *, uint8_t, void *, void *, uint64_t);
 
 void DetectEngineInspectModbusRegisterTests(void);
index c7f4bba8af60cd42ff47824851d2c40618a979dc..0699a85feddad8dd8e22184d0516b6338b2d159d 100644 (file)
@@ -143,7 +143,7 @@ int DetectEngineInspectPacketPayload(DetectEngineCtx *de_ctx,
     det_ctx->inspection_recursion_counter = 0;
     det_ctx->replist = NULL;
 
-    r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_lists[DETECT_SM_LIST_PMATCH],
+    r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_arrays[DETECT_SM_LIST_PMATCH],
                                       f, p->payload, p->payload_len, 0,
                                       DETECT_ENGINE_CONTENT_INSPECTION_MODE_PAYLOAD, p);
     if (r == 1) {
@@ -184,7 +184,7 @@ int DetectEngineInspectStreamPayload(DetectEngineCtx *de_ctx,
     det_ctx->discontinue_matching = 0;
     det_ctx->inspection_recursion_counter = 0;
 
-    r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_lists[DETECT_SM_LIST_PMATCH],
+    r = DetectEngineContentInspection(de_ctx, det_ctx, s, s->sm_arrays[DETECT_SM_LIST_PMATCH],
                                       f, payload, payload_len, 0,
                                       DETECT_ENGINE_CONTENT_INSPECTION_MODE_STREAM, NULL);
     if (r == 1) {
index 82a40228e1ef195ce3df1c2688c9ccc87a60c7dc..c9053602a0857858051799d0b3e8993ecde302b0 100644 (file)
@@ -534,7 +534,7 @@ int DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
                 if (direction == engine->dir) {
                     KEYWORD_PROFILING_SET_LIST(det_ctx, engine->sm_list);
                     int match = engine->Callback(tv, de_ctx, det_ctx,
-                            s, engine->sm, f, flags, alstate, tx, tx_id);
+                            s, engine->smd, f, flags, alstate, tx, tx_id);
                     SCLogDebug("engine %p match %d", engine, match);
                     if (match == DETECT_ENGINE_INSPECT_SIG_MATCH) {
                         inspect_flags |= BIT_U32(engine->id);
@@ -859,7 +859,7 @@ static int DoInspectItem(ThreadVars *tv,
             SCLogDebug("inspect_flags %x", inspect_flags);
             KEYWORD_PROFILING_SET_LIST(det_ctx, engine->sm_list);
             int match = engine->Callback(tv, de_ctx, det_ctx,
-                    s, engine->sm,
+                    s, engine->smd,
                     f, flags, alstate, inspect_tx, inspect_tx_id);
             if (match == DETECT_ENGINE_INSPECT_SIG_MATCH) {
                 inspect_flags |= BIT_U32(engine->id);
index 422a8a3d1e09c7b9519046fcdd00fb0eb7926fc8..c7d751a15154b462e1fbbcdb62e40f42b89f47cc 100644 (file)
 
 int DetectEngineInspectTemplateBuffer(ThreadVars *tv,
     DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-    Signature *s, const SigMatch *sm,
+    Signature *s, const SigMatchData *smd,
     Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     TemplateTransaction *tx = (TemplateTransaction *)txv;
     int ret = 0;
 
     if (flags & STREAM_TOSERVER && tx->request_buffer != NULL) {
-        ret = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+        ret = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
             f, tx->request_buffer, tx->request_buffer_len, 0,
             DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, NULL);
     }
     else if (flags & STREAM_TOCLIENT && tx->response_buffer != NULL) {
-        ret = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+        ret = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
             f, tx->response_buffer, tx->response_buffer_len, 0,
             DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, NULL);
     }
index 60bf5d47863f2c04ec4241f4a2047bcfdf7b0996..fb836f0702cb340cde8943dc34dc70ee611df139 100644 (file)
@@ -26,7 +26,7 @@
 
 int DetectEngineInspectTemplateBuffer(ThreadVars *,
         DetectEngineCtx *, DetectEngineThreadCtx *,
-        const Signature *, const SigMatch *,
+        const Signature *, const SigMatchData *,
         Flow *, uint8_t, void *, void *tx, uint64_t tx_id);
 
 #endif /* __DETECT_TEMPLATE_ENGINE_H__ */
index 3e5b458d2e822777815e52f23ab6e868bf70b9bd..43db1f42ad3774b336d030d51be683aff1b7b330 100644 (file)
@@ -99,7 +99,7 @@ int PrefilterTxTlsSniRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectTlsSni(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     uint8_t *buffer;
@@ -114,7 +114,7 @@ int DetectEngineInspectTlsSni(ThreadVars *tv,
     buffer = (uint8_t *)ssl_state->client_connp.sni;
     buffer_len = strlen(ssl_state->client_connp.sni);
 
-    cnt = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    cnt = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
             f, buffer, buffer_len, 0,
             DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, NULL);
 
@@ -174,7 +174,7 @@ int PrefilterTxTlsIssuerRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectTlsIssuer(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     uint8_t *buffer;
@@ -189,7 +189,7 @@ int DetectEngineInspectTlsIssuer(ThreadVars *tv,
     buffer = (uint8_t *)ssl_state->server_connp.cert0_issuerdn;
     buffer_len = strlen(ssl_state->server_connp.cert0_issuerdn);
 
-    cnt = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    cnt = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
             f, buffer, buffer_len, 0,
             DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, NULL);
 
@@ -249,7 +249,7 @@ int PrefilterTxTlsSubjectRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectTlsSubject(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     uint8_t *buffer;
@@ -264,7 +264,7 @@ int DetectEngineInspectTlsSubject(ThreadVars *tv,
     buffer = (uint8_t *)ssl_state->server_connp.cert0_subject;
     buffer_len = strlen(ssl_state->server_connp.cert0_subject);
 
-    cnt = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    cnt = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
             f, buffer, buffer_len, 0,
             DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, NULL);
 
@@ -273,7 +273,7 @@ int DetectEngineInspectTlsSubject(ThreadVars *tv,
 
 int DetectEngineInspectTlsValidity(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate,
         void *txv, uint64_t tx_id)
 {
index 4172b4a043917e6116277610ee0b1ae8a3b2539e..573e62d17434aa7cb9a695e5ccb64a7b0d7b41cc 100644 (file)
@@ -29,23 +29,23 @@ int PrefilterTxTlsSubjectRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectTlsSni(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 
 int DetectEngineInspectTlsIssuer(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 
 int DetectEngineInspectTlsSubject(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags,
         void *alstate, void *txv, uint64_t tx_id);
 
 int DetectEngineInspectTlsValidity(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 
 #endif /* __DETECT_ENGINE_TLS_H__ */
index 6bc28adfeb47f126c68281ec080ea0a3e92fa119..e6684cff7370424f732e65985a0b1ee8b18f9f87 100644 (file)
@@ -106,7 +106,7 @@ int PrefilterTxUriRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
  */
 int DetectEngineInspectHttpUri(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        Signature *s, const SigMatch *sm,
+        Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     HtpTxUserData *tx_ud = htp_tx_get_user_data(txv);
@@ -129,7 +129,7 @@ int DetectEngineInspectHttpUri(ThreadVars *tv,
 
     /* Inspect all the uricontents fetched on each
      * transaction at the app layer */
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           bstr_ptr(tx_ud->request_uri_normalized),
                                           bstr_len(tx_ud->request_uri_normalized),
index 4760dd184de746148f7f8e7cc24fc7155007aec0..fa18960bdbdcf0b8633fa885e496189c09d7ac09 100644 (file)
@@ -28,7 +28,7 @@ int PrefilterTxUriRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 
 int DetectEngineInspectHttpUri(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id);
 
 void UriRegisterTests(void);
index b1d4a24cfb46106e1e5ac100eabf5e20ff8817bf..a5ccbf79f95c26e0f5b66794a8acf6155a263b60 100644 (file)
@@ -208,9 +208,7 @@ int DetectEngineAppInspectionEngine2Signature(Signature *s)
 
             case DETECT_SM_LIST_TEMPLATE_BUFFER_MATCH:
 
-                new_engine->sm = s->sm_lists[new_engine->sm_list];
-                s->sm_lists[new_engine->sm_list] = NULL;
-                s->sm_lists_tail[new_engine->sm_list] = NULL;
+                new_engine->smd = s->sm_arrays[new_engine->sm_list];
                 lists_used[t->sm_list] = 1;
                 break;
             default:
@@ -239,8 +237,7 @@ next:
     int i;
     for (i = 0; i < DETECT_SM_LIST_MAX; i++) {
         if (lists_used[i]) {
-            s->sm_lists[i] = NULL;
-            s->sm_lists_tail[i] = NULL;
+            s->sm_arrays[i] = NULL;
         }
     }
 
@@ -258,13 +255,13 @@ next:
  */
 void DetectEngineAppInspectionEngineSignatureFree(Signature *s)
 {
-    SigMatch *ptrs[DETECT_SM_LIST_MAX] = { NULL };
+    SigMatchData *ptrs[DETECT_SM_LIST_MAX] = { NULL };
 
     DetectEngineAppInspectionEngine *ie = s->app_inspect;
     while (ie) {
         DetectEngineAppInspectionEngine *next = ie->next;
-        BUG_ON(ptrs[ie->sm_list] != NULL && ptrs[ie->sm_list] != ie->sm);
-        ptrs[ie->sm_list] = ie->sm;
+        BUG_ON(ptrs[ie->sm_list] != NULL && ptrs[ie->sm_list] != ie->smd);
+        ptrs[ie->sm_list] = ie->smd;
         SCFree(ie);
         ie = next;
     }
@@ -272,12 +269,7 @@ void DetectEngineAppInspectionEngineSignatureFree(Signature *s)
     int i;
     for (i = 0; i < DETECT_SM_LIST_MAX; i++)
     {
-        SigMatch *sm = ptrs[i];
-        while (sm != NULL) {
-            SigMatch *nsm = sm->next;
-            SigMatchFree(sm);
-            sm = nsm;
-        }
+        SCFree(ptrs[i]);
     }
 }
 
index fc052e07691889d8f547c683d6870012e58d5f95..f9a08dacf3748a96cb568e47110f325bb169c542 100644 (file)
@@ -52,7 +52,7 @@
 #include "detect-fileext.h"
 
 static int DetectFileextMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *,
-        uint8_t, File *, const Signature *, const SigMatch *);
+        uint8_t, File *, const Signature *, const SigMatchData *);
 static int DetectFileextSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFileextRegisterTests(void);
 static void DetectFileextFree(void *);
@@ -89,7 +89,7 @@ void DetectFileextRegister(void)
  * \retval 1 match
  */
 static int DetectFileextMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatch *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
 {
     SCEnter();
     int ret = 0;
index a64e1d180bb000f61373738a461de0f8956c09ee..b70e4c820d713bdf046a84d7fefa7d5766ba6a83 100644 (file)
@@ -76,7 +76,7 @@ void DetectFilemagicRegister(void)
 #else /* HAVE_MAGIC */
 
 static int DetectFilemagicMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *,
-        uint8_t, File *, const Signature *, const SigMatch *);
+        uint8_t, File *, const Signature *, const SigMatchData *);
 static int DetectFilemagicSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilemagicRegisterTests(void);
 static void DetectFilemagicFree(void *);
@@ -176,7 +176,7 @@ int FilemagicThreadLookup(magic_t *ctx, File *file)
  * \retval 1 match
  */
 static int DetectFilemagicMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatch *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
 {
     SCEnter();
     int ret = 0;
index 34722fb77f44ccbb75022ed4f09ba732f6de4b4e..e751d2b4faed04f4c4fc66bf8ef26fdd07e8e2cc 100644 (file)
@@ -53,7 +53,7 @@
 #include "app-layer-parser.h"
 
 static int DetectFilenameMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *,
-        uint8_t, File *, const Signature *, const SigMatch *);
+        uint8_t, File *, const Signature *, const SigMatchData *);
 static int DetectFilenameSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilenameRegisterTests(void);
 static void DetectFilenameFree(void *);
@@ -101,7 +101,7 @@ void DetectFilenameRegister(void)
  * \retval 1 match
  */
 static int DetectFilenameMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatch *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
 {
     SCEnter();
     int ret = 0;
index b26c7a8fc66f55cf05e52d73e1b633bb597fcab3..1b12221b84411e636a4574680da3a7618d6392ea 100644 (file)
@@ -49,7 +49,7 @@ static pcre_extra *parse_regex_study;
 
 /*prototypes*/
 static int DetectFilesizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f,
-                       uint8_t flags, File *file, const Signature *s, const SigMatch *m);
+        uint8_t flags, File *file, const Signature *s, const SigMatchData *m);
 static int DetectFilesizeSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilesizeFree (void *);
 static void DetectFilesizeRegisterTests (void);
@@ -87,7 +87,7 @@ void DetectFilesizeRegister(void)
  * \retval 1 match
  */
 static int DetectFilesizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f,
-        uint8_t flags, File *file, const Signature *s, const SigMatch *m)
+        uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
 {
     SCEnter();
 
index 4104fc694d478294616602cab3910fdf94485d93..de11089092cc89348767b8ce6e130d61f007e597 100644 (file)
@@ -60,7 +60,7 @@ static pcre *parse_regex;
 static pcre_extra *parse_regex_study;
 
 static int DetectFilestoreMatch (ThreadVars *, DetectEngineThreadCtx *,
-        Flow *, uint8_t, File *, const Signature *, const SigMatch *);
+        Flow *, uint8_t, File *, const Signature *, const SigMatchData *);
 static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilestoreFree(void *);
 static void DetectFilestoreRegisterTests(void);
@@ -247,7 +247,7 @@ int DetectFilestorePostMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack
  *       needs to be put behind a api.
  */
 static int DetectFilestoreMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f,
-        uint8_t flags, File *file, const Signature *s, const SigMatch *m)
+        uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
 {
     uint16_t file_id = 0;
 
index 8561f3fb5d8953a3de57a6010af80f61ca98534a..8fabe28ff0285b96fdbf83754b6a3835bcd76858 100644 (file)
@@ -66,7 +66,7 @@ void DetectHttpRequestLineFree(void *);
 static int PrefilterTxHttpRequestLineRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 static int DetectEngineInspectHttpRequestLine(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 
 /**
@@ -172,7 +172,7 @@ static int PrefilterTxHttpRequestLineRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx
  */
 static int DetectEngineInspectHttpRequestLine(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -191,7 +191,7 @@ static int DetectEngineInspectHttpRequestLine(ThreadVars *tv,
     /* Inspect all the uricontents fetched on each
      * transaction at the app layer */
     int r = DetectEngineContentInspection(de_ctx, det_ctx,
-                                          s, sm,
+                                          s, smd,
                                           f,
                                           bstr_ptr(tx->request_line),
                                           bstr_len(tx->request_line),
index 5dff95ec1999d7fa046f9c956d87a124eeef235d..125771a8e614f136ec3326d403fd6da602fb6040 100644 (file)
@@ -66,7 +66,7 @@ void DetectHttpResponseLineFree(void *);
 static int PrefilterTxHttpResponseLineRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx);
 static int DetectEngineInspectHttpResponseLine(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 
 /**
@@ -172,7 +172,7 @@ static int PrefilterTxHttpResponseLineRegister(SigGroupHead *sgh, MpmCtx *mpm_ct
  */
 int DetectEngineInspectHttpResponseLine(ThreadVars *tv,
         DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
     htp_tx_t *tx = (htp_tx_t *)txv;
@@ -194,7 +194,7 @@ int DetectEngineInspectHttpResponseLine(ThreadVars *tv,
 #endif
 
     /* run the inspection against the buffer */
-    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, sm,
+    int r = DetectEngineContentInspection(de_ctx, det_ctx, s, smd,
                                           f,
                                           bstr_ptr(tx->response_line),
                                           bstr_len(tx->response_line),
index 27351bfe4a30ae6410ea9888eb236494ea49cb94..d51746cefff6e5b4847f37c383f36b60520bbba7 100644 (file)
@@ -186,7 +186,7 @@ void LuaDumpStack(lua_State *state)
 }
 
 int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         uint8_t *buffer, uint32_t buffer_len, uint32_t offset,
         Flow *f)
 {
@@ -196,7 +196,7 @@ int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx,
     if (buffer == NULL || buffer_len == 0)
         SCReturnInt(0);
 
-    DetectLuaData *lua = (DetectLuaData *)sm->ctx;
+    DetectLuaData *lua = (DetectLuaData *)smd->ctx;
     if (lua == NULL)
         SCReturnInt(0);
 
index 18298aa20359e798ed6dd7a032b6f042ed2c36c3..16e451e9109099534c4b8cb67c4942dcafeb4cef 100644 (file)
@@ -56,7 +56,7 @@ typedef struct DetectLuaData {
 /* prototypes */
 void DetectLuaRegister (void);
 int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatch *sm,
+        const Signature *s, const SigMatchData *smd,
         uint8_t *buffer, uint32_t buffer_len, uint32_t offset,
         Flow *f);
 
index b8430149158fd1243b661270354a5e1f43c90075..a1177a5928d99ddfc0bf13d207c89cbdc47e093a 100644 (file)
@@ -172,8 +172,8 @@ void DetectPcreRegister (void)
  * \retval  0 No match.
  */
 int DetectPcrePayloadMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
-                           const SigMatch *sm, Packet *p, Flow *f, uint8_t *payload,
-                           uint32_t payload_len)
+                           const SigMatchData *smd, Packet *p, Flow *f,
+                           uint8_t *payload, uint32_t payload_len)
 {
     SCEnter();
 #define MAX_SUBSTRINGS 30
@@ -183,7 +183,7 @@ int DetectPcrePayloadMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
     uint16_t len = 0;
     uint16_t capture_len = 0;
 
-    DetectPcreData *pe = (DetectPcreData *)sm->ctx;
+    DetectPcreData *pe = (DetectPcreData *)smd->ctx;
 
     if (pe->flags & DETECT_PCRE_RELATIVE) {
         ptr = payload + det_ctx->buffer_offset;
index 52e6394b595e5b196284d5f95c0dea2bd3874971..50b93b052833105e68340fc110d50e2a25f6d7c3 100644 (file)
@@ -44,8 +44,11 @@ typedef struct DetectPcreData_ {
 } DetectPcreData;
 
 /* prototypes */
-int DetectPcrePayloadMatch(DetectEngineThreadCtx *, const Signature *,
-        const SigMatch *, Packet *, Flow *, uint8_t *, uint32_t);
+
+int DetectPcrePayloadMatch(DetectEngineThreadCtx *,
+        const Signature *, const SigMatchData *,
+        Packet *, Flow *, uint8_t *, uint32_t);
+
 int DetectPcrePacketPayloadMatch(DetectEngineThreadCtx *, Packet *, Signature *, SigMatch *);
 int DetectPcrePayloadDoMatch(DetectEngineThreadCtx *, Signature *, SigMatch *,
                              Packet *, uint8_t *, uint16_t);
index a9617a6b0392b20dfcfd5c76d504df5c02e8cc6a..f091a89451d3cb3c6d199fb372b91cee982ae89a 100644 (file)
@@ -377,7 +377,7 @@ struct DetectEngineThreadCtx_;// DetectEngineThreadCtx;
 
 typedef int (*InspectEngineFuncPtr)(ThreadVars *tv,
         struct DetectEngineCtx_ *de_ctx, struct DetectEngineThreadCtx_ *det_ctx,
-        const struct Signature_ *sig, const SigMatch *sm_list,
+        const struct Signature_ *sig, const SigMatchData *smd,
         Flow *f, uint8_t flags, void *alstate,
         void *tx, uint64_t tx_id);
 
@@ -395,7 +395,7 @@ typedef struct DetectEngineAppInspectionEngine_ {
      */
     InspectEngineFuncPtr Callback;
 
-    SigMatch *sm;
+    SigMatchData *smd;
 
     struct DetectEngineAppInspectionEngine_ *next;
 } DetectEngineAppInspectionEngine;
@@ -955,7 +955,6 @@ typedef struct DetectEngineThreadCtx_ {
 } DetectEngineThreadCtx;
 
 /** \brief element in sigmatch type table.
- *  \note FileMatch pointer below takes a locked flow, AppLayerMatch an unlocked flow
  */
 typedef struct SigTableElmt_ {
     /** Packet match function pointer */
@@ -973,7 +972,7 @@ typedef struct SigTableElmt_ {
     int (*FileMatch)(ThreadVars *,  /**< thread local vars */
         DetectEngineThreadCtx *,
         Flow *,                     /**< *LOCKED* flow */
-        uint8_t flags, File *, const Signature *, const SigMatch *);
+        uint8_t flags, File *, const Signature *, const SigMatchData *);
 
     /** keyword setup function pointer */
     int (*Setup)(DetectEngineCtx *, Signature *, char *);
index 8bee60c42308d64d002c1b543254b5fa2e7e7698..aff4302f41bee5d17755523915c71092533b8aa5 100644 (file)
@@ -147,7 +147,7 @@ static int HashMatchHashTable(ROHashTable *hash_table, uint8_t *hash,
  * \retval 1 match
  */
 int DetectFileHashMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatch *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
 {
     SCEnter();
     int ret = 0;
index c247fb5aa38720849039d225855bd7cb05b4946b..ee0b37de61cf7e70b79e4df618adffd28de4abfe 100644 (file)
@@ -38,7 +38,7 @@ int ReadHashString(uint8_t *, char *, char *, int, uint16_t);
 int LoadHashTable(ROHashTable *, char *, char *, int, uint32_t);
 
 int DetectFileHashMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t,
-        File *, const Signature *, const SigMatch *);
+        File *, const Signature *, const SigMatchData *);
 int DetectFileHashSetup(DetectEngineCtx *, Signature *, char *, uint32_t);
 void DetectFileHashFree(void *);