]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
make mpm ctx container de_ctx specific. Also introduce global variable in mpm_ctx...
authorAnoop Saldanha <poonaatsoc@gmail.com>
Fri, 22 Jun 2012 12:20:15 +0000 (17:50 +0530)
committerVictor Julien <victor@inliniac.net>
Tue, 26 Jun 2012 07:36:10 +0000 (09:36 +0200)
src/detect-engine-mpm.c
src/detect.c
src/detect.h
src/suricata.c
src/util-mpm.c
src/util-mpm.h

index a7ec1fb29799bd5dc16184f3b3a814be8f40cc71..aeddc04b450c6d92fe67fdd9fe6283434e05f254 100644 (file)
@@ -787,7 +787,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         SCLogDebug("destroying mpm_ctx %p (sh %p)",
                    sh->mpm_proto_tcp_ctx_ts, sh);
         if (sh->mpm_proto_tcp_ctx_ts != NULL &&
-            !MpmFactoryIsMpmCtxAvailable(sh->mpm_proto_tcp_ctx_ts)) {
+            !sh->mpm_proto_tcp_ctx_ts->global) {
             mpm_table[sh->mpm_proto_tcp_ctx_ts->mpm_type].
                 DestroyCtx(sh->mpm_proto_tcp_ctx_ts);
             SCFree(sh->mpm_proto_tcp_ctx_ts);
@@ -798,7 +798,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         SCLogDebug("destroying mpm_ctx %p (sh %p)",
                    sh->mpm_proto_tcp_ctx_tc, sh);
         if (sh->mpm_proto_tcp_ctx_tc != NULL &&
-            !MpmFactoryIsMpmCtxAvailable(sh->mpm_proto_tcp_ctx_tc)) {
+            !sh->mpm_proto_tcp_ctx_tc->global) {
             mpm_table[sh->mpm_proto_tcp_ctx_tc->mpm_type].
                 DestroyCtx(sh->mpm_proto_tcp_ctx_tc);
             SCFree(sh->mpm_proto_tcp_ctx_tc);
@@ -809,7 +809,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         SCLogDebug("destroying mpm_ctx %p (sh %p)",
                    sh->mpm_proto_udp_ctx_ts, sh);
         if (sh->mpm_proto_udp_ctx_ts != NULL &&
-            !MpmFactoryIsMpmCtxAvailable(sh->mpm_proto_udp_ctx_ts)) {
+            !sh->mpm_proto_udp_ctx_ts->global) {
             mpm_table[sh->mpm_proto_udp_ctx_ts->mpm_type].
                 DestroyCtx(sh->mpm_proto_udp_ctx_ts);
             SCFree(sh->mpm_proto_udp_ctx_ts);
@@ -820,7 +820,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         SCLogDebug("destroying mpm_ctx %p (sh %p)",
                    sh->mpm_proto_udp_ctx_tc, sh);
         if (sh->mpm_proto_udp_ctx_tc != NULL &&
-            !MpmFactoryIsMpmCtxAvailable(sh->mpm_proto_udp_ctx_tc)) {
+            !sh->mpm_proto_udp_ctx_tc->global) {
             mpm_table[sh->mpm_proto_udp_ctx_tc->mpm_type].
                 DestroyCtx(sh->mpm_proto_udp_ctx_tc);
             SCFree(sh->mpm_proto_udp_ctx_tc);
@@ -831,7 +831,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         SCLogDebug("destroying mpm_ctx %p (sh %p)",
                    sh->mpm_proto_other_ctx, sh);
         if (sh->mpm_proto_other_ctx != NULL &&
-            !MpmFactoryIsMpmCtxAvailable(sh->mpm_proto_other_ctx)) {
+            !sh->mpm_proto_other_ctx->global) {
             mpm_table[sh->mpm_proto_other_ctx->mpm_type].
                 DestroyCtx(sh->mpm_proto_other_ctx);
             SCFree(sh->mpm_proto_other_ctx);
@@ -845,7 +845,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         !(sh->flags & SIG_GROUP_HEAD_MPM_URI_COPY)) {
         if (sh->mpm_uri_ctx_ts != NULL) {
             SCLogDebug("destroying mpm_uri_ctx %p (sh %p)", sh->mpm_uri_ctx_ts, sh);
-            if (!MpmFactoryIsMpmCtxAvailable(sh->mpm_uri_ctx_ts)) {
+            if (!sh->mpm_uri_ctx_ts->global) {
                 mpm_table[sh->mpm_uri_ctx_ts->mpm_type].DestroyCtx(sh->mpm_uri_ctx_ts);
                 SCFree(sh->mpm_uri_ctx_ts);
             }
@@ -854,7 +854,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         }
         if (sh->mpm_uri_ctx_tc != NULL) {
             SCLogDebug("destroying mpm_uri_ctx %p (sh %p)", sh->mpm_uri_ctx_tc, sh);
-            if (!MpmFactoryIsMpmCtxAvailable(sh->mpm_uri_ctx_tc)) {
+            if (!sh->mpm_uri_ctx_tc->global) {
                 mpm_table[sh->mpm_uri_ctx_tc->mpm_type].DestroyCtx(sh->mpm_uri_ctx_tc);
                 SCFree(sh->mpm_uri_ctx_tc);
             }
@@ -868,7 +868,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         !(sh->flags & SIG_GROUP_HEAD_MPM_STREAM_COPY)) {
         if (sh->mpm_stream_ctx_ts != NULL) {
             SCLogDebug("destroying mpm_stream_ctx %p (sh %p)", sh->mpm_stream_ctx_ts, sh);
-            if (!MpmFactoryIsMpmCtxAvailable(sh->mpm_stream_ctx_ts)) {
+            if (!sh->mpm_stream_ctx_ts->global) {
                 mpm_table[sh->mpm_stream_ctx_ts->mpm_type].DestroyCtx(sh->mpm_stream_ctx_ts);
                 SCFree(sh->mpm_stream_ctx_ts);
             }
@@ -877,7 +877,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
         }
         if (sh->mpm_stream_ctx_tc != NULL) {
             SCLogDebug("destroying mpm_stream_ctx %p (sh %p)", sh->mpm_stream_ctx_tc, sh);
-            if (!MpmFactoryIsMpmCtxAvailable(sh->mpm_stream_ctx_tc)) {
+            if (!sh->mpm_stream_ctx_tc->global) {
                 mpm_table[sh->mpm_stream_ctx_tc->mpm_type].DestroyCtx(sh->mpm_stream_ctx_tc);
                 SCFree(sh->mpm_stream_ctx_tc);
             }
@@ -1766,11 +1766,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
     /* intialize contexes */
     if (has_co_packet) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_proto_tcp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_tcp_packet, 0);
-            sh->mpm_proto_tcp_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_tcp_packet, 1);
+            sh->mpm_proto_tcp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_tcp_packet, 0);
+            sh->mpm_proto_tcp_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_tcp_packet, 1);
         } else {
-            sh->mpm_proto_tcp_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_proto_tcp_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_proto_tcp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_proto_tcp_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_proto_tcp_ctx_ts == NULL || sh->mpm_proto_tcp_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_proto_tcp_ctx == NULL. This should never happen");
@@ -1785,11 +1785,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 #endif
 
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_proto_udp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_udp_packet, 0);
-            sh->mpm_proto_udp_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_udp_packet, 1);
+            sh->mpm_proto_udp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_udp_packet, 0);
+            sh->mpm_proto_udp_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_udp_packet, 1);
         } else {
-            sh->mpm_proto_udp_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_proto_udp_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_proto_udp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_proto_udp_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_proto_udp_ctx_ts == NULL || sh->mpm_proto_udp_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_proto_udp_ctx == NULL. This should never happen");
@@ -1805,10 +1805,10 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
             sh->mpm_proto_other_ctx =
-                MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_other_packet, 0);
+                MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_other_packet, 0);
         } else {
             sh->mpm_proto_other_ctx =
-                MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+                MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
         }
         if (sh->mpm_proto_other_ctx == NULL) {
             SCLogDebug("sh->mpm_proto_other_ctx == NULL. This should never happen");
@@ -1823,11 +1823,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_stream) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_stream_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_stream, 0);
-            sh->mpm_stream_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_stream, 1);
+            sh->mpm_stream_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 0);
+            sh->mpm_stream_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 1);
         } else {
-            sh->mpm_stream_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_stream_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_stream_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_stream_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_stream_ctx_tc == NULL || sh->mpm_stream_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_stream_ctx == NULL. This should never happen");
@@ -1845,11 +1845,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_uri) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_uri_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_uri, 0);
-            sh->mpm_uri_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_uri, 1);
+            sh->mpm_uri_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_uri, 0);
+            sh->mpm_uri_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_uri, 1);
         } else {
-            sh->mpm_uri_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_uri_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_uri_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_uri_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_uri_ctx_ts == NULL || sh->mpm_uri_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_uri_ctx == NULL. This should never happen");
@@ -1867,11 +1867,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hcbd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hcbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcbd, 0);
-            sh->mpm_hcbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcbd, 1);
+            sh->mpm_hcbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcbd, 0);
+            sh->mpm_hcbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcbd, 1);
         } else {
-            sh->mpm_hcbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hcbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hcbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hcbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hcbd_ctx_ts == NULL || sh->mpm_hcbd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hcbd_ctx == NULL. This should never happen");
@@ -1889,11 +1889,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hsbd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hsbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsbd, 0);
-            sh->mpm_hsbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsbd, 1);
+            sh->mpm_hsbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsbd, 0);
+            sh->mpm_hsbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsbd, 1);
         } else {
-            sh->mpm_hsbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hsbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hsbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hsbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hsbd_ctx_ts == NULL || sh->mpm_hsbd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hsbd_ctx == NULL. This should never happen");
@@ -1911,11 +1911,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hhd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hhd, 0);
-            sh->mpm_hhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hhd, 1);
+            sh->mpm_hhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hhd, 0);
+            sh->mpm_hhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hhd, 1);
         } else {
-            sh->mpm_hhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hhd_ctx_ts == NULL || sh->mpm_hhd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hhd_ctx == NULL. This should never happen");
@@ -1933,11 +1933,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hrhd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hrhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrhd, 0);
-            sh->mpm_hrhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrhd, 1);
+            sh->mpm_hrhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrhd, 0);
+            sh->mpm_hrhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrhd, 1);
         } else {
-            sh->mpm_hrhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hrhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hrhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hrhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hrhd_ctx_ts == NULL || sh->mpm_hrhd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hrhd_ctx == NULL. This should never happen");
@@ -1955,11 +1955,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hmd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hmd, 0);
-            sh->mpm_hmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hmd, 1);
+            sh->mpm_hmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hmd, 0);
+            sh->mpm_hmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hmd, 1);
         } else {
-            sh->mpm_hmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hmd_ctx_ts == NULL || sh->mpm_hmd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hmd_ctx == NULL. This should never happen");
@@ -1977,11 +1977,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hcd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hcd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcd, 0);
-            sh->mpm_hcd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcd, 1);
+            sh->mpm_hcd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcd, 0);
+            sh->mpm_hcd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcd, 1);
         } else {
-            sh->mpm_hcd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hcd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hcd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hcd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hcd_ctx_ts == NULL || sh->mpm_hcd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hcd_ctx == NULL. This should never happen");
@@ -1999,11 +1999,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hrud) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hrud_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrud, 0);
-            sh->mpm_hrud_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrud, 1);
+            sh->mpm_hrud_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrud, 0);
+            sh->mpm_hrud_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrud, 1);
         } else {
-            sh->mpm_hrud_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hrud_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hrud_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hrud_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hrud_ctx_ts == NULL || sh->mpm_hrud_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hrud_ctx == NULL. This should never happen");
@@ -2021,11 +2021,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hsmd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hsmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsmd, 0);
-            sh->mpm_hsmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsmd, 1);
+            sh->mpm_hsmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsmd, 0);
+            sh->mpm_hsmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsmd, 1);
         } else {
-            sh->mpm_hsmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hsmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hsmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hsmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hsmd_ctx_ts == NULL || sh->mpm_hsmd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hsmd_ctx == NULL. This should never happen");
@@ -2043,11 +2043,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_hscd) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_hscd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hscd, 0);
-            sh->mpm_hscd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hscd, 1);
+            sh->mpm_hscd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hscd, 0);
+            sh->mpm_hscd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hscd, 1);
         } else {
-            sh->mpm_hscd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_hscd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_hscd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_hscd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_hscd_ctx_ts == NULL || sh->mpm_hscd_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_hscd_ctx == NULL. This should never happen");
@@ -2065,11 +2065,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
     if (has_co_huad) {
         if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-            sh->mpm_huad_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_huad, 0);
-            sh->mpm_huad_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_huad, 1);
+            sh->mpm_huad_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_huad, 0);
+            sh->mpm_huad_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_huad, 1);
         } else {
-            sh->mpm_huad_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
-            sh->mpm_huad_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
+            sh->mpm_huad_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
+            sh->mpm_huad_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1);
         }
         if (sh->mpm_huad_ctx_ts == NULL || sh->mpm_huad_ctx_tc == NULL) {
             SCLogDebug("sh->mpm_huad_ctx == NULL. This should never happen");
@@ -2104,7 +2104,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
         //if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
          if (sh->mpm_proto_tcp_ctx_ts != NULL) {
              if (sh->mpm_proto_tcp_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_proto_tcp_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_tcp_ctx_ts);
                  sh->mpm_proto_tcp_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2117,7 +2117,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_proto_tcp_ctx_tc != NULL) {
              if (sh->mpm_proto_tcp_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_proto_tcp_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_tcp_ctx_tc);
                  sh->mpm_proto_tcp_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2131,7 +2131,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_proto_udp_ctx_ts != NULL) {
              if (sh->mpm_proto_udp_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_proto_udp_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_udp_ctx_ts);
                  sh->mpm_proto_udp_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2144,7 +2144,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_proto_udp_ctx_tc != NULL) {
              if (sh->mpm_proto_udp_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_proto_udp_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_udp_ctx_tc);
                  sh->mpm_proto_udp_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2158,7 +2158,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_proto_other_ctx != NULL) {
              if (sh->mpm_proto_other_ctx->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_proto_other_ctx);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_other_ctx);
                  sh->mpm_proto_other_ctx = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2172,7 +2172,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_stream_ctx_ts != NULL) {
              if (sh->mpm_stream_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_stream_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_stream_ctx_ts);
                  sh->mpm_stream_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2183,7 +2183,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_stream_ctx_tc != NULL) {
              if (sh->mpm_stream_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_stream_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_stream_ctx_tc);
                  sh->mpm_stream_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2195,7 +2195,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_uri_ctx_ts != NULL) {
              if (sh->mpm_uri_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_uri_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_uri_ctx_ts);
                  sh->mpm_uri_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2206,7 +2206,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_uri_ctx_tc != NULL) {
              if (sh->mpm_uri_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_uri_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_uri_ctx_tc);
                  sh->mpm_uri_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2218,7 +2218,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_hcbd_ctx_ts != NULL) {
              if (sh->mpm_hcbd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hcbd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcbd_ctx_ts);
                  sh->mpm_hcbd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2229,7 +2229,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hcbd_ctx_tc != NULL) {
              if (sh->mpm_hcbd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hcbd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcbd_ctx_tc);
                  sh->mpm_hcbd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2241,7 +2241,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_hsbd_ctx_ts != NULL) {
              if (sh->mpm_hsbd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hsbd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hsbd_ctx_ts);
                  sh->mpm_hsbd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2252,7 +2252,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hsbd_ctx_tc != NULL) {
              if (sh->mpm_hsbd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hsbd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hsbd_ctx_tc);
                  sh->mpm_hsbd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2264,7 +2264,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_hhd_ctx_ts != NULL) {
              if (sh->mpm_hhd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hhd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hhd_ctx_ts);
                  sh->mpm_hhd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2275,7 +2275,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hhd_ctx_tc != NULL) {
              if (sh->mpm_hhd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hhd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hhd_ctx_tc);
                  sh->mpm_hhd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2287,7 +2287,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_hrhd_ctx_ts != NULL) {
              if (sh->mpm_hrhd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hrhd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrhd_ctx_ts);
                  sh->mpm_hrhd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2298,7 +2298,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hrhd_ctx_tc != NULL) {
              if (sh->mpm_hrhd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hrhd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrhd_ctx_tc);
                  sh->mpm_hrhd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2310,7 +2310,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_hmd_ctx_ts != NULL) {
              if (sh->mpm_hmd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hmd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hmd_ctx_ts);
                  sh->mpm_hmd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2321,7 +2321,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hmd_ctx_tc != NULL) {
              if (sh->mpm_hmd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hmd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hmd_ctx_tc);
                  sh->mpm_hmd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2333,7 +2333,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_hcd_ctx_ts != NULL) {
              if (sh->mpm_hcd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hcd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcd_ctx_ts);
                  sh->mpm_hcd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2344,7 +2344,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hcd_ctx_tc != NULL) {
              if (sh->mpm_hcd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hcd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcd_ctx_tc);
                  sh->mpm_hcd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2356,7 +2356,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
 
          if (sh->mpm_hrud_ctx_ts != NULL) {
              if (sh->mpm_hrud_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hrud_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrud_ctx_ts);
                  sh->mpm_hrud_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2367,7 +2367,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hrud_ctx_tc != NULL) {
              if (sh->mpm_hrud_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hrud_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrud_ctx_tc);
                  sh->mpm_hrud_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2378,7 +2378,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hsmd_ctx_ts != NULL) {
              if (sh->mpm_hsmd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hsmd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hsmd_ctx_ts);
                  sh->mpm_hsmd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2389,7 +2389,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hsmd_ctx_tc != NULL) {
              if (sh->mpm_hsmd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hsmd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hsmd_ctx_tc);
                  sh->mpm_hsmd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2400,7 +2400,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hscd_ctx_ts != NULL) {
              if (sh->mpm_hscd_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hscd_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hscd_ctx_ts);
                  sh->mpm_hscd_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2411,7 +2411,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_hscd_ctx_tc != NULL) {
              if (sh->mpm_hscd_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_hscd_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hscd_ctx_tc);
                  sh->mpm_hscd_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2422,7 +2422,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_huad_ctx_ts != NULL) {
              if (sh->mpm_huad_ctx_ts->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_huad_ctx_ts);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_huad_ctx_ts);
                  sh->mpm_huad_ctx_ts = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2433,7 +2433,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
          if (sh->mpm_huad_ctx_tc != NULL) {
              if (sh->mpm_huad_ctx_tc->pattern_cnt == 0) {
-                 MpmFactoryReClaimMpmCtx(sh->mpm_huad_ctx_tc);
+                 MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_huad_ctx_tc);
                  sh->mpm_huad_ctx_tc = NULL;
              } else {
                  if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) {
@@ -2444,61 +2444,61 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
          }
         //} /* if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) */
     } else {
-        MpmFactoryReClaimMpmCtx(sh->mpm_proto_other_ctx);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_other_ctx);
         sh->mpm_proto_other_ctx = NULL;
 
-        MpmFactoryReClaimMpmCtx(sh->mpm_proto_tcp_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_tcp_ctx_ts);
         sh->mpm_proto_tcp_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_proto_udp_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_udp_ctx_ts);
         sh->mpm_proto_udp_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_stream_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_stream_ctx_ts);
         sh->mpm_stream_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_uri_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_uri_ctx_ts);
         sh->mpm_uri_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hcbd_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcbd_ctx_ts);
         sh->mpm_hcbd_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hhd_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hhd_ctx_ts);
         sh->mpm_hhd_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hrhd_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrhd_ctx_ts);
         sh->mpm_hrhd_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hmd_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hmd_ctx_ts);
         sh->mpm_hmd_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hcd_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcd_ctx_ts);
         sh->mpm_hcd_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hrud_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrud_ctx_ts);
         sh->mpm_hrud_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hsmd_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hsmd_ctx_ts);
         sh->mpm_hsmd_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hscd_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hscd_ctx_ts);
         sh->mpm_hscd_ctx_ts = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_huad_ctx_ts);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_huad_ctx_ts);
         sh->mpm_huad_ctx_ts = NULL;
 
-        MpmFactoryReClaimMpmCtx(sh->mpm_proto_tcp_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_tcp_ctx_tc);
         sh->mpm_proto_tcp_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_proto_udp_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_udp_ctx_tc);
         sh->mpm_proto_udp_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_stream_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_stream_ctx_tc);
         sh->mpm_stream_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_uri_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_uri_ctx_tc);
         sh->mpm_uri_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hcbd_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcbd_ctx_tc);
         sh->mpm_hcbd_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hhd_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hhd_ctx_tc);
         sh->mpm_hhd_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hrhd_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrhd_ctx_tc);
         sh->mpm_hrhd_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hmd_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hmd_ctx_tc);
         sh->mpm_hmd_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hcd_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hcd_ctx_tc);
         sh->mpm_hcd_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hrud_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hrud_ctx_tc);
         sh->mpm_hrud_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hsmd_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hsmd_ctx_tc);
         sh->mpm_hsmd_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_hscd_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_hscd_ctx_tc);
         sh->mpm_hscd_ctx_tc = NULL;
-        MpmFactoryReClaimMpmCtx(sh->mpm_huad_ctx_tc);
+        MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_huad_ctx_tc);
         sh->mpm_huad_ctx_tc = NULL;
     }
 
index bcef172e9634aba65b2f0564a4883324088db928..fbd597a344f51850f7f6c270139accceba276149 100644 (file)
@@ -2349,49 +2349,49 @@ static int SignatureCreateMask(Signature *s) {
 static void SigInitStandardMpmFactoryContexts(DetectEngineCtx *de_ctx)
 {
     de_ctx->sgh_mpm_context_proto_tcp_packet =
-        MpmFactoryRegisterMpmCtxProfile("packet_proto_tcp",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_tcp",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_proto_udp_packet =
-        MpmFactoryRegisterMpmCtxProfile("packet_proto_udp",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_udp",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_proto_other_packet =
-        MpmFactoryRegisterMpmCtxProfile("packet_proto_other",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "packet_proto_other",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_uri =
-        MpmFactoryRegisterMpmCtxProfile("uri",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "uri",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_stream =
-        MpmFactoryRegisterMpmCtxProfile("stream",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "stream",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hcbd =
-        MpmFactoryRegisterMpmCtxProfile("hcbd",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hcbd",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hhd =
-        MpmFactoryRegisterMpmCtxProfile("hhd",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hhd",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hrhd =
-        MpmFactoryRegisterMpmCtxProfile("hrhd",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hrhd",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hmd =
-        MpmFactoryRegisterMpmCtxProfile("hmd",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hmd",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hcd =
-        MpmFactoryRegisterMpmCtxProfile("hcd",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hcd",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hrud =
-        MpmFactoryRegisterMpmCtxProfile("hrud",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hrud",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hsmd =
-        MpmFactoryRegisterMpmCtxProfile("hsmd",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hsmd",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_hscd =
-        MpmFactoryRegisterMpmCtxProfile("hscd",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "hscd",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_huad =
-        MpmFactoryRegisterMpmCtxProfile("huad",
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "huad",
                                         MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
     de_ctx->sgh_mpm_context_app_proto_detect =
-        MpmFactoryRegisterMpmCtxProfile("app_proto_detect", 0);
+        MpmFactoryRegisterMpmCtxProfile(de_ctx, "app_proto_detect", 0);
 
     return;
 }
@@ -4320,143 +4320,143 @@ int SigGroupBuild (DetectEngineCtx *de_ctx) {
 
     if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
         MpmCtx *mpm_ctx = NULL;
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_tcp_packet, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_tcp_packet, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_tcp_packet, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_tcp_packet, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("packet- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_udp_packet, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_udp_packet, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_udp_packet, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_udp_packet, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("packet- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_proto_other_packet, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_other_packet, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("packet- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_uri, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_uri, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_uri, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_uri, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("uri- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcbd, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcbd, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcbd, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcbd, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hcbd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hhd, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hhd, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hhd, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hhd, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hhd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrhd, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrhd, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrhd, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrhd, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hrhd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hmd, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hmd, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hmd, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hmd, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hmd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcd, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcd, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcd, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcd, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hcd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrud, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrud, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrud, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrud, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hrud- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_stream, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_stream, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("stream- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsmd, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsmd, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hsmd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsmd, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsmd, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hsmd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hscd, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hscd, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hscd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hscd, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hscd, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("hscd- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_huad, 0);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_huad, 0);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
         //printf("huad- %d\n", mpm_ctx->pattern_cnt);
 
-        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_huad, 1);
+        mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_huad, 1);
         if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
             mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
         }
index 8239a30265584c96ecde3bc1f2d39558668e7df4..652f07156fb73a15aeef61fa963cc57feb74e61e 100644 (file)
@@ -623,6 +623,8 @@ typedef struct DetectEngineCtx_ {
      *  id sharing and id tracking. */
     MpmPatternIdStore *mpm_pattern_id_store;
 
+    MpmCtxFactoryContainer *mpm_ctx_factory_container;
+
     /* maximum recursion depth for content inspection */
     int inspection_recursion_limit;
 
index d21d035e9b46fbd8c21d5947956fb4c7b141d629..d4e270c333db71c0b15a0c35dcf81f917b2bb61e 100644 (file)
@@ -1904,7 +1904,7 @@ int main(int argc, char **argv)
 
     SigCleanSignatures(de_ctx);
     if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
-        MpmFactoryDeRegisterAllMpmCtxProfiles();
+        MpmFactoryDeRegisterAllMpmCtxProfiles(de_ctx);
     }
     DetectEngineCtxFree(de_ctx);
     AlpProtoDestroy();
index 35934aa19b5991e6809581c2212a978d7f6e1d2f..8da0bc702eaea5b18c059fcf750231a2c4ac28b1 100644 (file)
@@ -48,8 +48,6 @@
 #include "queue.h"
 #include "util-unittest.h"
 
-MpmCtxFactoryContainer *mpm_ctx_factory_container = NULL;
-
 /**
  * \brief Register a new Mpm Context.
  *
@@ -57,16 +55,16 @@ MpmCtxFactoryContainer *mpm_ctx_factory_container = NULL;
  *
  * \retval id Return the id created for the new MpmCtx profile.
  */
-int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
+int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *name, uint8_t flags)
 {
     /* the very first entry */
-    if (mpm_ctx_factory_container == NULL) {
-        mpm_ctx_factory_container = SCMalloc(sizeof(MpmCtxFactoryContainer));
-        if (mpm_ctx_factory_container == NULL) {
+    if (de_ctx->mpm_ctx_factory_container == NULL) {
+        de_ctx->mpm_ctx_factory_container = SCMalloc(sizeof(MpmCtxFactoryContainer));
+        if (de_ctx->mpm_ctx_factory_container == NULL) {
             SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
-        memset(mpm_ctx_factory_container, 0, sizeof(MpmCtxFactoryContainer));
+        memset(de_ctx->mpm_ctx_factory_container, 0, sizeof(MpmCtxFactoryContainer));
 
         MpmCtxFactoryItem *item = SCMalloc(sizeof(MpmCtxFactoryItem));
         if (item == NULL) {
@@ -87,6 +85,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
             exit(EXIT_FAILURE);
         }
         memset(item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
+        item[0].mpm_ctx_ts->global = 1;
 
         /* toclient */
         item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
@@ -95,6 +94,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
             exit(EXIT_FAILURE);
         }
         memset(item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
+        item[0].mpm_ctx_tc->global = 1;
 
         /* our id starts from 0 always.  Helps us with the ctx retrieval from
          * the array */
@@ -104,15 +104,15 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
         item[0].flags = flags;
 
         /* store the newly created item */
-        mpm_ctx_factory_container->items = item;
-        mpm_ctx_factory_container->no_of_items++;
+        de_ctx->mpm_ctx_factory_container->items = item;
+        de_ctx->mpm_ctx_factory_container->no_of_items++;
 
         /* the first id is always 0 */
         return item[0].id;
     } else {
         int i;
-        MpmCtxFactoryItem *items = mpm_ctx_factory_container->items;
-        for (i = 0; i < mpm_ctx_factory_container->no_of_items; i++) {
+        MpmCtxFactoryItem *items = de_ctx->mpm_ctx_factory_container->items;
+        for (i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) {
             if (items[i].name != NULL && strcmp(items[i].name, name) == 0) {
                 /* looks like we have this mpm_ctx freed */
                 if (items[i].mpm_ctx_ts == NULL) {
@@ -122,6 +122,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
                         exit(EXIT_FAILURE);
                     }
                     memset(items[i].mpm_ctx_ts, 0, sizeof(MpmCtx));
+                    items[i].mpm_ctx_ts->global = 1;
                 }
                 if (items[i].mpm_ctx_tc == NULL) {
                     items[i].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
@@ -130,6 +131,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
                         exit(EXIT_FAILURE);
                     }
                     memset(items[i].mpm_ctx_tc, 0, sizeof(MpmCtx));
+                    items[i].mpm_ctx_tc->global = 1;
                 }
                 items[i].flags = flags;
                 return items[i].id;
@@ -138,15 +140,15 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
 
         /* let's make the new entry */
         items = SCRealloc(items,
-                          (mpm_ctx_factory_container->no_of_items + 1) * sizeof(MpmCtxFactoryItem));
+                          (de_ctx->mpm_ctx_factory_container->no_of_items + 1) * sizeof(MpmCtxFactoryItem));
         if (items == NULL) {
             SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
             exit(EXIT_FAILURE);
         }
 
-        mpm_ctx_factory_container->items = items;
+        de_ctx->mpm_ctx_factory_container->items = items;
 
-        MpmCtxFactoryItem *new_item = &items[mpm_ctx_factory_container->no_of_items];
+        MpmCtxFactoryItem *new_item = &items[de_ctx->mpm_ctx_factory_container->no_of_items];
         new_item[0].name = SCStrdup(name);
         if (new_item[0].name == NULL) {
             SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@@ -160,6 +162,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
             exit(EXIT_FAILURE);
         }
         memset(new_item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
+        new_item[0].mpm_ctx_ts->global = 1;
 
         /* toclient */
         new_item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
@@ -168,28 +171,29 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
             exit(EXIT_FAILURE);
         }
         memset(new_item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
+        new_item[0].mpm_ctx_tc->global = 1;
 
-        new_item[0].id = mpm_ctx_factory_container->no_of_items;
+        new_item[0].id = de_ctx->mpm_ctx_factory_container->no_of_items;
         new_item[0].flags = flags;
-        mpm_ctx_factory_container->no_of_items++;
+        de_ctx->mpm_ctx_factory_container->no_of_items++;
 
         /* the newly created id */
         return new_item[0].id;
     }
 }
 
-int32_t MpmFactoryIsMpmCtxAvailable(MpmCtx *mpm_ctx)
+int32_t MpmFactoryIsMpmCtxAvailable(DetectEngineCtx *de_ctx, MpmCtx *mpm_ctx)
 {
     if (mpm_ctx == NULL)
         return 0;
 
-    if (mpm_ctx_factory_container == NULL) {
+    if (de_ctx->mpm_ctx_factory_container == NULL) {
         return 0;
     } else {
         int i;
-        for (i = 0; i < mpm_ctx_factory_container->no_of_items; i++) {
-            if (mpm_ctx == mpm_ctx_factory_container->items[i].mpm_ctx_ts ||
-                mpm_ctx == mpm_ctx_factory_container->items[i].mpm_ctx_tc) {
+        for (i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) {
+            if (mpm_ctx == de_ctx->mpm_ctx_factory_container->items[i].mpm_ctx_ts ||
+                mpm_ctx == de_ctx->mpm_ctx_factory_container->items[i].mpm_ctx_tc) {
                 return 1;
             }
         }
@@ -197,7 +201,7 @@ int32_t MpmFactoryIsMpmCtxAvailable(MpmCtx *mpm_ctx)
     }
 }
 
-MpmCtx *MpmFactoryGetMpmCtxForProfile(int32_t id, int direction)
+MpmCtx *MpmFactoryGetMpmCtxForProfile(DetectEngineCtx *de_ctx, int32_t id, int direction)
 {
     if (id == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
         MpmCtx *mpm_ctx = SCMalloc(sizeof(MpmCtx));
@@ -210,35 +214,35 @@ MpmCtx *MpmFactoryGetMpmCtxForProfile(int32_t id, int direction)
     } else if (id < -1) {
         SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid argument - %d\n", id);
         return NULL;
-    } else if (id >= mpm_ctx_factory_container->no_of_items) {
+    } else if (id >= de_ctx->mpm_ctx_factory_container->no_of_items) {
         /* this id does not exist */
         return NULL;
     } else {
         return (direction == 0) ?
-            mpm_ctx_factory_container->items[id].mpm_ctx_ts :
-            mpm_ctx_factory_container->items[id].mpm_ctx_tc;
+            de_ctx->mpm_ctx_factory_container->items[id].mpm_ctx_ts :
+            de_ctx->mpm_ctx_factory_container->items[id].mpm_ctx_tc;
     }
 }
 
-void MpmFactoryReClaimMpmCtx(MpmCtx *mpm_ctx)
+void MpmFactoryReClaimMpmCtx(DetectEngineCtx *de_ctx, MpmCtx *mpm_ctx)
 {
     if (mpm_ctx == NULL)
         return;
 
-    if (!MpmFactoryIsMpmCtxAvailable(mpm_ctx))
+    if (!MpmFactoryIsMpmCtxAvailable(de_ctx, mpm_ctx))
         SCFree(mpm_ctx);
 
     return;
 }
 
-void MpmFactoryDeRegisterAllMpmCtxProfiles(void)
+void MpmFactoryDeRegisterAllMpmCtxProfiles(DetectEngineCtx *de_ctx)
 {
-    if (mpm_ctx_factory_container == NULL)
+    if (de_ctx->mpm_ctx_factory_container == NULL)
         return;
 
     int i = 0;
-    MpmCtxFactoryItem *items = mpm_ctx_factory_container->items;
-    for (i = 0; i < mpm_ctx_factory_container->no_of_items; i++) {
+    MpmCtxFactoryItem *items = de_ctx->mpm_ctx_factory_container->items;
+    for (i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) {
         if (items[i].name != NULL)
             SCFree(items[i].name);
         if (items[i].mpm_ctx_ts != NULL)
@@ -247,9 +251,9 @@ void MpmFactoryDeRegisterAllMpmCtxProfiles(void)
             SCFree(items[i].mpm_ctx_tc);
     }
 
-    SCFree(mpm_ctx_factory_container->items);
-    SCFree(mpm_ctx_factory_container);
-    mpm_ctx_factory_container = NULL;
+    SCFree(de_ctx->mpm_ctx_factory_container->items);
+    SCFree(de_ctx->mpm_ctx_factory_container);
+    de_ctx->mpm_ctx_factory_container = NULL;
 
     return;
 }
index 7732b3ca52f89c208b3fb5e1f5aeb282ddb78951..3981e9b91e230eae5e61f34cc0f6ccf22d07a5bc 100644 (file)
@@ -111,6 +111,10 @@ typedef struct MpmCtx_ {
     void *ctx;
     uint16_t mpm_type;
 
+    /* used uint16_t here to avoiding using a pad.  You can use a uint8_t
+     * here as well */
+    uint16_t global;
+
     uint32_t pattern_cnt;       /* unique patterns */
 
     uint16_t minlen;
@@ -182,11 +186,13 @@ typedef struct MpmTableElmt_ {
 
 MpmTableElmt mpm_table[MPM_TABLE_SIZE];
 
-int32_t MpmFactoryRegisterMpmCtxProfile(const char *, uint8_t);
-void MpmFactoryReClaimMpmCtx(MpmCtx *);
-MpmCtx *MpmFactoryGetMpmCtxForProfile(int32_t, int);
-void MpmFactoryDeRegisterAllMpmCtxProfiles(void);
-int32_t MpmFactoryIsMpmCtxAvailable(MpmCtx *);
+struct DetectEngineCtx_;
+
+int32_t MpmFactoryRegisterMpmCtxProfile(struct DetectEngineCtx_ *, const char *, uint8_t);
+void MpmFactoryReClaimMpmCtx(struct DetectEngineCtx_ *, MpmCtx *);
+MpmCtx *MpmFactoryGetMpmCtxForProfile(struct DetectEngineCtx_ *, int32_t, int);
+void MpmFactoryDeRegisterAllMpmCtxProfiles(struct DetectEngineCtx_ *);
+int32_t MpmFactoryIsMpmCtxAvailable(struct DetectEngineCtx_ *, MpmCtx *);
 
 /* macros decides if cuda is enabled for the platform or not */
 #ifdef __SC_CUDA_SUPPORT__