make mpm ctx container de_ctx specific. Also introduce global variable in mpm_ctx. this is a workaround for cleaning non global mpm_ctx's since we now don't supply the de_ctx around the detection engine API

remotes/origin/HEAD
Anoop Saldanha 13 years ago committed by Victor Julien
parent 7acf5ad38e
commit f4ce9011d2

@ -787,7 +787,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
SCLogDebug("destroying mpm_ctx %p (sh %p)", SCLogDebug("destroying mpm_ctx %p (sh %p)",
sh->mpm_proto_tcp_ctx_ts, sh); sh->mpm_proto_tcp_ctx_ts, sh);
if (sh->mpm_proto_tcp_ctx_ts != NULL && 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]. mpm_table[sh->mpm_proto_tcp_ctx_ts->mpm_type].
DestroyCtx(sh->mpm_proto_tcp_ctx_ts); DestroyCtx(sh->mpm_proto_tcp_ctx_ts);
SCFree(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)", SCLogDebug("destroying mpm_ctx %p (sh %p)",
sh->mpm_proto_tcp_ctx_tc, sh); sh->mpm_proto_tcp_ctx_tc, sh);
if (sh->mpm_proto_tcp_ctx_tc != NULL && 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]. mpm_table[sh->mpm_proto_tcp_ctx_tc->mpm_type].
DestroyCtx(sh->mpm_proto_tcp_ctx_tc); DestroyCtx(sh->mpm_proto_tcp_ctx_tc);
SCFree(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)", SCLogDebug("destroying mpm_ctx %p (sh %p)",
sh->mpm_proto_udp_ctx_ts, sh); sh->mpm_proto_udp_ctx_ts, sh);
if (sh->mpm_proto_udp_ctx_ts != NULL && 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]. mpm_table[sh->mpm_proto_udp_ctx_ts->mpm_type].
DestroyCtx(sh->mpm_proto_udp_ctx_ts); DestroyCtx(sh->mpm_proto_udp_ctx_ts);
SCFree(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)", SCLogDebug("destroying mpm_ctx %p (sh %p)",
sh->mpm_proto_udp_ctx_tc, sh); sh->mpm_proto_udp_ctx_tc, sh);
if (sh->mpm_proto_udp_ctx_tc != NULL && 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]. mpm_table[sh->mpm_proto_udp_ctx_tc->mpm_type].
DestroyCtx(sh->mpm_proto_udp_ctx_tc); DestroyCtx(sh->mpm_proto_udp_ctx_tc);
SCFree(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)", SCLogDebug("destroying mpm_ctx %p (sh %p)",
sh->mpm_proto_other_ctx, sh); sh->mpm_proto_other_ctx, sh);
if (sh->mpm_proto_other_ctx != NULL && 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]. mpm_table[sh->mpm_proto_other_ctx->mpm_type].
DestroyCtx(sh->mpm_proto_other_ctx); DestroyCtx(sh->mpm_proto_other_ctx);
SCFree(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)) { !(sh->flags & SIG_GROUP_HEAD_MPM_URI_COPY)) {
if (sh->mpm_uri_ctx_ts != NULL) { if (sh->mpm_uri_ctx_ts != NULL) {
SCLogDebug("destroying mpm_uri_ctx %p (sh %p)", sh->mpm_uri_ctx_ts, sh); 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); mpm_table[sh->mpm_uri_ctx_ts->mpm_type].DestroyCtx(sh->mpm_uri_ctx_ts);
SCFree(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) { if (sh->mpm_uri_ctx_tc != NULL) {
SCLogDebug("destroying mpm_uri_ctx %p (sh %p)", sh->mpm_uri_ctx_tc, sh); 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); mpm_table[sh->mpm_uri_ctx_tc->mpm_type].DestroyCtx(sh->mpm_uri_ctx_tc);
SCFree(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)) { !(sh->flags & SIG_GROUP_HEAD_MPM_STREAM_COPY)) {
if (sh->mpm_stream_ctx_ts != NULL) { if (sh->mpm_stream_ctx_ts != NULL) {
SCLogDebug("destroying mpm_stream_ctx %p (sh %p)", sh->mpm_stream_ctx_ts, sh); 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); mpm_table[sh->mpm_stream_ctx_ts->mpm_type].DestroyCtx(sh->mpm_stream_ctx_ts);
SCFree(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) { if (sh->mpm_stream_ctx_tc != NULL) {
SCLogDebug("destroying mpm_stream_ctx %p (sh %p)", sh->mpm_stream_ctx_tc, sh); 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); mpm_table[sh->mpm_stream_ctx_tc->mpm_type].DestroyCtx(sh->mpm_stream_ctx_tc);
SCFree(sh->mpm_stream_ctx_tc); SCFree(sh->mpm_stream_ctx_tc);
} }
@ -1766,11 +1766,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
/* intialize contexes */ /* intialize contexes */
if (has_co_packet) { if (has_co_packet) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, 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_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_tcp_packet, 1);
} else { } else {
sh->mpm_proto_tcp_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_proto_tcp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_proto_tcp_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { 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"); SCLogDebug("sh->mpm_proto_tcp_ctx == NULL. This should never happen");
@ -1785,11 +1785,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
#endif #endif
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, 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_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_udp_packet, 1);
} else { } else {
sh->mpm_proto_udp_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_proto_udp_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_proto_udp_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { 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"); 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) { if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
sh->mpm_proto_other_ctx = 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 { } else {
sh->mpm_proto_other_ctx = 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) { if (sh->mpm_proto_other_ctx == NULL) {
SCLogDebug("sh->mpm_proto_other_ctx == NULL. This should never happen"); 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 (has_co_stream) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 0);
sh->mpm_stream_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_stream, 1); sh->mpm_stream_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 1);
} else { } else {
sh->mpm_stream_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_stream_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_stream_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_stream_ctx_tc == NULL || sh->mpm_stream_ctx_tc == NULL) {
SCLogDebug("sh->mpm_stream_ctx == NULL. This should never happen"); 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 (has_co_uri) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_uri, 0);
sh->mpm_uri_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_uri, 1); sh->mpm_uri_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_uri, 1);
} else { } else {
sh->mpm_uri_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_uri_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_uri_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_uri_ctx_ts == NULL || sh->mpm_uri_ctx_tc == NULL) {
SCLogDebug("sh->mpm_uri_ctx == NULL. This should never happen"); 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 (has_co_hcbd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcbd, 0);
sh->mpm_hcbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcbd, 1); sh->mpm_hcbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcbd, 1);
} else { } else {
sh->mpm_hcbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hcbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hcbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hcbd_ctx_ts == NULL || sh->mpm_hcbd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hcbd_ctx == NULL. This should never happen"); 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 (has_co_hsbd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsbd, 0);
sh->mpm_hsbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsbd, 1); sh->mpm_hsbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsbd, 1);
} else { } else {
sh->mpm_hsbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hsbd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hsbd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hsbd_ctx_ts == NULL || sh->mpm_hsbd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hsbd_ctx == NULL. This should never happen"); 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 (has_co_hhd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hhd, 0);
sh->mpm_hhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hhd, 1); sh->mpm_hhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hhd, 1);
} else { } else {
sh->mpm_hhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hhd_ctx_ts == NULL || sh->mpm_hhd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hhd_ctx == NULL. This should never happen"); 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 (has_co_hrhd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrhd, 0);
sh->mpm_hrhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrhd, 1); sh->mpm_hrhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrhd, 1);
} else { } else {
sh->mpm_hrhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hrhd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hrhd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hrhd_ctx_ts == NULL || sh->mpm_hrhd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hrhd_ctx == NULL. This should never happen"); 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 (has_co_hmd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hmd, 0);
sh->mpm_hmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hmd, 1); sh->mpm_hmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hmd, 1);
} else { } else {
sh->mpm_hmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hmd_ctx_ts == NULL || sh->mpm_hmd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hmd_ctx == NULL. This should never happen"); 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 (has_co_hcd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcd, 0);
sh->mpm_hcd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hcd, 1); sh->mpm_hcd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hcd, 1);
} else { } else {
sh->mpm_hcd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hcd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hcd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hcd_ctx_ts == NULL || sh->mpm_hcd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hcd_ctx == NULL. This should never happen"); 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 (has_co_hrud) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrud, 0);
sh->mpm_hrud_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hrud, 1); sh->mpm_hrud_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hrud, 1);
} else { } else {
sh->mpm_hrud_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hrud_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hrud_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hrud_ctx_ts == NULL || sh->mpm_hrud_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hrud_ctx == NULL. This should never happen"); 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 (has_co_hsmd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsmd, 0);
sh->mpm_hsmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hsmd, 1); sh->mpm_hsmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hsmd, 1);
} else { } else {
sh->mpm_hsmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hsmd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hsmd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hsmd_ctx_ts == NULL || sh->mpm_hsmd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hsmd_ctx == NULL. This should never happen"); 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 (has_co_hscd) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hscd, 0);
sh->mpm_hscd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_hscd, 1); sh->mpm_hscd_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_hscd, 1);
} else { } else {
sh->mpm_hscd_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_hscd_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_hscd_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_hscd_ctx_ts == NULL || sh->mpm_hscd_ctx_tc == NULL) {
SCLogDebug("sh->mpm_hscd_ctx == NULL. This should never happen"); 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 (has_co_huad) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { 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_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_huad, 0);
sh->mpm_huad_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx->sgh_mpm_context_huad, 1); sh->mpm_huad_ctx_tc = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_huad, 1);
} else { } else {
sh->mpm_huad_ctx_ts = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0); sh->mpm_huad_ctx_ts = MpmFactoryGetMpmCtxForProfile(de_ctx, MPM_CTX_FACTORY_UNIQUE_CONTEXT, 0);
sh->mpm_huad_ctx_tc = MpmFactoryGetMpmCtxForProfile(MPM_CTX_FACTORY_UNIQUE_CONTEXT, 1); 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) { if (sh->mpm_huad_ctx_ts == NULL || sh->mpm_huad_ctx_tc == NULL) {
SCLogDebug("sh->mpm_huad_ctx == NULL. This should never happen"); 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 (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 != NULL) {
if (sh->mpm_proto_tcp_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_proto_tcp_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_proto_tcp_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_proto_tcp_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_proto_udp_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_proto_udp_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_proto_udp_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_proto_udp_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_proto_other_ctx->pattern_cnt == 0) { 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; sh->mpm_proto_other_ctx = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_stream_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_stream_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_stream_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_stream_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_uri_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_uri_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_uri_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_uri_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hcbd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hcbd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hcbd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hcbd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hsbd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hsbd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hsbd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hsbd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hhd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hhd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hhd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hhd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hrhd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hrhd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hrhd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hrhd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hmd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hmd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hmd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hmd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hcd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hcd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hcd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hcd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hrud_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hrud_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hrud_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hrud_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hsmd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hsmd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hsmd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hsmd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hscd_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_hscd_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_hscd_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_hscd_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_huad_ctx_ts->pattern_cnt == 0) { 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; sh->mpm_huad_ctx_ts = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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 != NULL) {
if (sh->mpm_huad_ctx_tc->pattern_cnt == 0) { 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; sh->mpm_huad_ctx_tc = NULL;
} else { } else {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) { 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) */ //} /* if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL) */
} else { } else {
MpmFactoryReClaimMpmCtx(sh->mpm_proto_other_ctx); MpmFactoryReClaimMpmCtx(de_ctx, sh->mpm_proto_other_ctx);
sh->mpm_proto_other_ctx = NULL; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; sh->mpm_huad_ctx_tc = NULL;
} }

@ -2349,49 +2349,49 @@ static int SignatureCreateMask(Signature *s) {
static void SigInitStandardMpmFactoryContexts(DetectEngineCtx *de_ctx) static void SigInitStandardMpmFactoryContexts(DetectEngineCtx *de_ctx)
{ {
de_ctx->sgh_mpm_context_proto_tcp_packet = 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); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_proto_udp_packet = 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); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_proto_other_packet = 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); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_uri = de_ctx->sgh_mpm_context_uri =
MpmFactoryRegisterMpmCtxProfile("uri", MpmFactoryRegisterMpmCtxProfile(de_ctx, "uri",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_stream = de_ctx->sgh_mpm_context_stream =
MpmFactoryRegisterMpmCtxProfile("stream", MpmFactoryRegisterMpmCtxProfile(de_ctx, "stream",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hcbd = de_ctx->sgh_mpm_context_hcbd =
MpmFactoryRegisterMpmCtxProfile("hcbd", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hcbd",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hhd = de_ctx->sgh_mpm_context_hhd =
MpmFactoryRegisterMpmCtxProfile("hhd", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hhd",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hrhd = de_ctx->sgh_mpm_context_hrhd =
MpmFactoryRegisterMpmCtxProfile("hrhd", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hrhd",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hmd = de_ctx->sgh_mpm_context_hmd =
MpmFactoryRegisterMpmCtxProfile("hmd", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hmd",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hcd = de_ctx->sgh_mpm_context_hcd =
MpmFactoryRegisterMpmCtxProfile("hcd", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hcd",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hrud = de_ctx->sgh_mpm_context_hrud =
MpmFactoryRegisterMpmCtxProfile("hrud", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hrud",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hsmd = de_ctx->sgh_mpm_context_hsmd =
MpmFactoryRegisterMpmCtxProfile("hsmd", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hsmd",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_hscd = de_ctx->sgh_mpm_context_hscd =
MpmFactoryRegisterMpmCtxProfile("hscd", MpmFactoryRegisterMpmCtxProfile(de_ctx, "hscd",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_huad = de_ctx->sgh_mpm_context_huad =
MpmFactoryRegisterMpmCtxProfile("huad", MpmFactoryRegisterMpmCtxProfile(de_ctx, "huad",
MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD); MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD);
de_ctx->sgh_mpm_context_app_proto_detect = de_ctx->sgh_mpm_context_app_proto_detect =
MpmFactoryRegisterMpmCtxProfile("app_proto_detect", 0); MpmFactoryRegisterMpmCtxProfile(de_ctx, "app_proto_detect", 0);
return; return;
} }
@ -4320,143 +4320,143 @@ int SigGroupBuild (DetectEngineCtx *de_ctx) {
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
MpmCtx *mpm_ctx = NULL; 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("packet- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("packet- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("packet- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("uri- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hcbd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hhd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hrhd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hmd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hcd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hrud- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); 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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("stream- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hsmd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hsmd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hscd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("hscd- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }
//printf("huad- %d\n", mpm_ctx->pattern_cnt); //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) { if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx); mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
} }

@ -623,6 +623,8 @@ typedef struct DetectEngineCtx_ {
* id sharing and id tracking. */ * id sharing and id tracking. */
MpmPatternIdStore *mpm_pattern_id_store; MpmPatternIdStore *mpm_pattern_id_store;
MpmCtxFactoryContainer *mpm_ctx_factory_container;
/* maximum recursion depth for content inspection */ /* maximum recursion depth for content inspection */
int inspection_recursion_limit; int inspection_recursion_limit;

@ -1904,7 +1904,7 @@ int main(int argc, char **argv)
SigCleanSignatures(de_ctx); SigCleanSignatures(de_ctx);
if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) { if (de_ctx->sgh_mpm_context == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE) {
MpmFactoryDeRegisterAllMpmCtxProfiles(); MpmFactoryDeRegisterAllMpmCtxProfiles(de_ctx);
} }
DetectEngineCtxFree(de_ctx); DetectEngineCtxFree(de_ctx);
AlpProtoDestroy(); AlpProtoDestroy();

@ -48,8 +48,6 @@
#include "queue.h" #include "queue.h"
#include "util-unittest.h" #include "util-unittest.h"
MpmCtxFactoryContainer *mpm_ctx_factory_container = NULL;
/** /**
* \brief Register a new Mpm Context. * \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. * \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 */ /* the very first entry */
if (mpm_ctx_factory_container == NULL) { if (de_ctx->mpm_ctx_factory_container == NULL) {
mpm_ctx_factory_container = SCMalloc(sizeof(MpmCtxFactoryContainer)); de_ctx->mpm_ctx_factory_container = SCMalloc(sizeof(MpmCtxFactoryContainer));
if (mpm_ctx_factory_container == NULL) { if (de_ctx->mpm_ctx_factory_container == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE); 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)); MpmCtxFactoryItem *item = SCMalloc(sizeof(MpmCtxFactoryItem));
if (item == NULL) { if (item == NULL) {
@ -87,6 +85,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(item[0].mpm_ctx_ts, 0, sizeof(MpmCtx)); memset(item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
item[0].mpm_ctx_ts->global = 1;
/* toclient */ /* toclient */
item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx)); item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
@ -95,6 +94,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(item[0].mpm_ctx_tc, 0, sizeof(MpmCtx)); 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 /* our id starts from 0 always. Helps us with the ctx retrieval from
* the array */ * the array */
@ -104,15 +104,15 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
item[0].flags = flags; item[0].flags = flags;
/* store the newly created item */ /* store the newly created item */
mpm_ctx_factory_container->items = item; de_ctx->mpm_ctx_factory_container->items = item;
mpm_ctx_factory_container->no_of_items++; de_ctx->mpm_ctx_factory_container->no_of_items++;
/* the first id is always 0 */ /* the first id is always 0 */
return item[0].id; return item[0].id;
} else { } else {
int i; int i;
MpmCtxFactoryItem *items = mpm_ctx_factory_container->items; MpmCtxFactoryItem *items = de_ctx->mpm_ctx_factory_container->items;
for (i = 0; i < mpm_ctx_factory_container->no_of_items; i++) { 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) { if (items[i].name != NULL && strcmp(items[i].name, name) == 0) {
/* looks like we have this mpm_ctx freed */ /* looks like we have this mpm_ctx freed */
if (items[i].mpm_ctx_ts == NULL) { if (items[i].mpm_ctx_ts == NULL) {
@ -122,6 +122,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(items[i].mpm_ctx_ts, 0, sizeof(MpmCtx)); memset(items[i].mpm_ctx_ts, 0, sizeof(MpmCtx));
items[i].mpm_ctx_ts->global = 1;
} }
if (items[i].mpm_ctx_tc == NULL) { if (items[i].mpm_ctx_tc == NULL) {
items[i].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx)); items[i].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
@ -130,6 +131,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(items[i].mpm_ctx_tc, 0, sizeof(MpmCtx)); memset(items[i].mpm_ctx_tc, 0, sizeof(MpmCtx));
items[i].mpm_ctx_tc->global = 1;
} }
items[i].flags = flags; items[i].flags = flags;
return items[i].id; return items[i].id;
@ -138,15 +140,15 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
/* let's make the new entry */ /* let's make the new entry */
items = SCRealloc(items, 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) { if (items == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE); 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); new_item[0].name = SCStrdup(name);
if (new_item[0].name == NULL) { if (new_item[0].name == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -160,6 +162,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(const char *name, uint8_t flags)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(new_item[0].mpm_ctx_ts, 0, sizeof(MpmCtx)); memset(new_item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
new_item[0].mpm_ctx_ts->global = 1;
/* toclient */ /* toclient */
new_item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx)); 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); exit(EXIT_FAILURE);
} }
memset(new_item[0].mpm_ctx_tc, 0, sizeof(MpmCtx)); 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; 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 */ /* the newly created id */
return new_item[0].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) if (mpm_ctx == NULL)
return 0; return 0;
if (mpm_ctx_factory_container == NULL) { if (de_ctx->mpm_ctx_factory_container == NULL) {
return 0; return 0;
} else { } else {
int i; int i;
for (i = 0; i < mpm_ctx_factory_container->no_of_items; i++) { for (i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) {
if (mpm_ctx == mpm_ctx_factory_container->items[i].mpm_ctx_ts || if (mpm_ctx == de_ctx->mpm_ctx_factory_container->items[i].mpm_ctx_ts ||
mpm_ctx == mpm_ctx_factory_container->items[i].mpm_ctx_tc) { mpm_ctx == de_ctx->mpm_ctx_factory_container->items[i].mpm_ctx_tc) {
return 1; 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) { if (id == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
MpmCtx *mpm_ctx = SCMalloc(sizeof(MpmCtx)); MpmCtx *mpm_ctx = SCMalloc(sizeof(MpmCtx));
@ -210,35 +214,35 @@ MpmCtx *MpmFactoryGetMpmCtxForProfile(int32_t id, int direction)
} else if (id < -1) { } else if (id < -1) {
SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid argument - %d\n", id); SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid argument - %d\n", id);
return NULL; 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 */ /* this id does not exist */
return NULL; return NULL;
} else { } else {
return (direction == 0) ? return (direction == 0) ?
mpm_ctx_factory_container->items[id].mpm_ctx_ts : de_ctx->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_tc;
} }
} }
void MpmFactoryReClaimMpmCtx(MpmCtx *mpm_ctx) void MpmFactoryReClaimMpmCtx(DetectEngineCtx *de_ctx, MpmCtx *mpm_ctx)
{ {
if (mpm_ctx == NULL) if (mpm_ctx == NULL)
return; return;
if (!MpmFactoryIsMpmCtxAvailable(mpm_ctx)) if (!MpmFactoryIsMpmCtxAvailable(de_ctx, mpm_ctx))
SCFree(mpm_ctx); SCFree(mpm_ctx);
return; return;
} }
void MpmFactoryDeRegisterAllMpmCtxProfiles(void) void MpmFactoryDeRegisterAllMpmCtxProfiles(DetectEngineCtx *de_ctx)
{ {
if (mpm_ctx_factory_container == NULL) if (de_ctx->mpm_ctx_factory_container == NULL)
return; return;
int i = 0; int i = 0;
MpmCtxFactoryItem *items = mpm_ctx_factory_container->items; MpmCtxFactoryItem *items = de_ctx->mpm_ctx_factory_container->items;
for (i = 0; i < mpm_ctx_factory_container->no_of_items; i++) { for (i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) {
if (items[i].name != NULL) if (items[i].name != NULL)
SCFree(items[i].name); SCFree(items[i].name);
if (items[i].mpm_ctx_ts != NULL) if (items[i].mpm_ctx_ts != NULL)
@ -247,9 +251,9 @@ void MpmFactoryDeRegisterAllMpmCtxProfiles(void)
SCFree(items[i].mpm_ctx_tc); SCFree(items[i].mpm_ctx_tc);
} }
SCFree(mpm_ctx_factory_container->items); SCFree(de_ctx->mpm_ctx_factory_container->items);
SCFree(mpm_ctx_factory_container); SCFree(de_ctx->mpm_ctx_factory_container);
mpm_ctx_factory_container = NULL; de_ctx->mpm_ctx_factory_container = NULL;
return; return;
} }

@ -111,6 +111,10 @@ typedef struct MpmCtx_ {
void *ctx; void *ctx;
uint16_t mpm_type; 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 */ uint32_t pattern_cnt; /* unique patterns */
uint16_t minlen; uint16_t minlen;
@ -182,11 +186,13 @@ typedef struct MpmTableElmt_ {
MpmTableElmt mpm_table[MPM_TABLE_SIZE]; MpmTableElmt mpm_table[MPM_TABLE_SIZE];
int32_t MpmFactoryRegisterMpmCtxProfile(const char *, uint8_t); struct DetectEngineCtx_;
void MpmFactoryReClaimMpmCtx(MpmCtx *);
MpmCtx *MpmFactoryGetMpmCtxForProfile(int32_t, int); int32_t MpmFactoryRegisterMpmCtxProfile(struct DetectEngineCtx_ *, const char *, uint8_t);
void MpmFactoryDeRegisterAllMpmCtxProfiles(void); void MpmFactoryReClaimMpmCtx(struct DetectEngineCtx_ *, MpmCtx *);
int32_t MpmFactoryIsMpmCtxAvailable(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 */ /* macros decides if cuda is enabled for the platform or not */
#ifdef __SC_CUDA_SUPPORT__ #ifdef __SC_CUDA_SUPPORT__

Loading…
Cancel
Save