}
temp_dp = temp_dp->next;
}
- DetectPortCleanupList(head);
+ DetectPortCleanupList(NULL,head);
SCReturn;
}
} else {
SCLogDebug("proto group %d sgh %p is a copy", p, sgh_ts[p]);
- SigGroupHeadFree(sgh_ts[p]);
+ SigGroupHeadFree(de_ctx, sgh_ts[p]);
sgh_ts[p] = lookup_sgh;
de_ctx->gh_reuse++;
} else {
SCLogDebug("proto group %d sgh %p is a copy", p, sgh_tc[p]);
- SigGroupHeadFree(sgh_tc[p]);
+ SigGroupHeadFree(de_ctx, sgh_tc[p]);
sgh_tc[p] = lookup_sgh;
de_ctx->gh_reuse++;
} else {
SCLogDebug("port group %p sgh %p is a copy", iter, iter->sh);
- SigGroupHeadFree(iter->sh);
+ SigGroupHeadFree(de_ctx, iter->sh);
iter->sh = lookup_sgh;
iter->flags |= PORT_SIGGROUPHEAD_COPY;
/* when a group's sigs are added to the joingr, we can free it */
gr->next = NULL;
- DetectPortFree(gr);
+ DetectPortFree(de_ctx, gr);
gr = NULL;
/* append */
SCLogDebug("cleaning up signature grouping structure...");
}
if (de_ctx->decoder_event_sgh)
- SigGroupHeadFree(de_ctx->decoder_event_sgh);
+ SigGroupHeadFree(de_ctx, de_ctx->decoder_event_sgh);
de_ctx->decoder_event_sgh = NULL;
int f;
}
/* free lookup lists */
- DetectPortCleanupList(de_ctx->flow_gh[f].tcp);
+ DetectPortCleanupList(de_ctx, de_ctx->flow_gh[f].tcp);
de_ctx->flow_gh[f].tcp = NULL;
- DetectPortCleanupList(de_ctx->flow_gh[f].udp);
+ DetectPortCleanupList(de_ctx, de_ctx->flow_gh[f].udp);
de_ctx->flow_gh[f].udp = NULL;
}
continue;
SCLogDebug("sgh %p", sgh);
- SigGroupHeadFree(sgh);
+ SigGroupHeadFree(de_ctx, sgh);
}
SCFree(de_ctx->sgh_array);
de_ctx->sgh_array = NULL;
*
* \param dp Pointer to the DetectPort that has to be freed.
*/
-void DetectPortFree(DetectPort *dp)
+void DetectPortFree(const DetectEngineCtx *de_ctx, DetectPort *dp)
{
if (dp == NULL)
return;
/* only free the head if we have the original */
if (dp->sh != NULL && !(dp->flags & PORT_SIGGROUPHEAD_COPY)) {
- SigGroupHeadFree(dp->sh);
+ SigGroupHeadFree(de_ctx, dp->sh);
}
dp->sh = NULL;
*
* \param head Pointer to the DetectPort list head
*/
-void DetectPortCleanupList (DetectPort *head)
+void DetectPortCleanupList (const DetectEngineCtx *de_ctx, DetectPort *head)
{
if (head == NULL)
return;
for (cur = head; cur != NULL; ) {
next = cur->next;
cur->next = NULL;
- DetectPortFree(cur);
+ DetectPortFree(de_ctx, cur);
cur = next;
}
}
/* exact overlap/match */
if (cur != new) {
SigGroupHeadCopySigs(de_ctx, new->sh, &cur->sh);
- DetectPortFree(new);
+ DetectPortFree(de_ctx, new);
return 0;
}
return 1;
}
if (tmp != NULL) {
- DetectPortFree(tmp);
+ DetectPortFree(de_ctx, tmp);
}
return 0;
error:
if (tmp != NULL)
- DetectPortFree(tmp);
+ DetectPortFree(de_ctx, tmp);
return -1;
}
* \retval 0 on success
* \retval -1 on error
*/
-static int DetectPortParseInsertString(DetectPort **head, const char *s)
+static int DetectPortParseInsertString(const DetectEngineCtx *de_ctx,
+ DetectPort **head, const char *s)
{
DetectPort *ad = NULL, *ad_any = NULL;
int r = 0;
error:
SCLogError(SC_ERR_PORT_PARSE_INSERT_STRING,"DetectPortParseInsertString error");
if (ad != NULL)
- DetectPortCleanupList(ad);
+ DetectPortCleanupList(de_ctx, ad);
if (ad_any != NULL)
- DetectPortCleanupList(ad_any);
+ DetectPortCleanupList(de_ctx, ad_any);
return -1;
}
SCLogDebug("Parsed port from DetectPortParseDo - %s", address);
if (negate == 0 && n_set == 0) {
- r = DetectPortParseInsertString(head, address);
+ r = DetectPortParseInsertString(de_ctx, head, address);
} else {
- r = DetectPortParseInsertString(nhead, address);
+ r = DetectPortParseInsertString(de_ctx, nhead, address);
}
if (r == -1)
goto error;
d_set = 0;
} else {
if (!((negate + n_set) % 2)) {
- r = DetectPortParseInsertString(head,address);
+ r = DetectPortParseInsertString(de_ctx, head,address);
} else {
- r = DetectPortParseInsertString(nhead,address);
+ r = DetectPortParseInsertString(de_ctx, nhead,address);
}
if (r == -1)
goto error;
* \retval 0 on success
* \retval -1 on error
*/
-static int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead)
+static int DetectPortParseMergeNotPorts(const DetectEngineCtx *de_ctx,
+ DetectPort **head, DetectPort **nhead)
{
DetectPort *ad = NULL;
DetectPort *ag, *ag2;
*/
if (*head == NULL && *nhead != NULL) {
SCLogDebug("inserting 0:65535 into head");
- r = DetectPortParseInsertString(head,"0:65535");
+ r = DetectPortParseInsertString(de_ctx, head,"0:65535");
if (r < 0) {
goto error;
}
}
/** store the next ptr and remove the group */
DetectPort *next_ag2 = ag2->next;
- DetectPortFree(ag2);
+ DetectPortFree(de_ctx,ag2);
ag2 = next_ag2;
} else {
ag2 = ag2->next;
return 0;
error:
if (ad != NULL)
- DetectPortFree(ad);
+ DetectPortFree(de_ctx, ad);
return -1;
}
"Port var \"%s\" probably has a sequence(something "
"in brackets) value set without any quotes. Please "
"quote it using \"..\".", seq_node->name);
- DetectPortCleanupList(gh);
+ DetectPortCleanupList(NULL, gh);
goto error;
}
CleanVariableResolveList(&var_list);
if (r < 0) {
- DetectPortCleanupList(gh);
+ DetectPortCleanupList(NULL, gh);
SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
"failed to parse port var \"%s\" with value \"%s\". "
"Please check it's syntax", seq_node->name, seq_node->val);
"with it's value \"%s\". Port space range is NIL. "
"Probably have a !any or a port range that supplies "
"a NULL address range", seq_node->name, seq_node->val);
- DetectPortCleanupList(gh);
- DetectPortCleanupList(ghn);
+ DetectPortCleanupList(NULL, gh);
+ DetectPortCleanupList(NULL, ghn);
goto error;
}
if (gh != NULL)
- DetectPortCleanupList(gh);
+ DetectPortCleanupList(NULL, gh);
if (ghn != NULL)
- DetectPortCleanupList(ghn);
+ DetectPortCleanupList(NULL, ghn);
}
return 0;
SCLogDebug("head %p %p, nhead %p", head, *head, nhead);
/* merge the 'not' address groups */
- if (DetectPortParseMergeNotPorts(head, &nhead) < 0)
+ if (DetectPortParseMergeNotPorts(de_ctx, head, &nhead) < 0)
goto error;
/* free the temp negate head */
- DetectPortCleanupList(nhead);
+ DetectPortCleanupList(de_ctx, nhead);
return 0;
error:
- DetectPortCleanupList(nhead);
+ DetectPortCleanupList(de_ctx, nhead);
return -1;
}
error:
if (dp != NULL)
- DetectPortCleanupList(dp);
+ DetectPortCleanupList(NULL, dp);
return NULL;
}
static void DetectPortHashFreeFunc(void *ptr)
{
DetectPort *p = ptr;
- DetectPortFree(p);
+ DetectPortFree(NULL, p);
}
/**
int r = DetectPortParse(NULL,&dd,"80");
if (r == 0) {
- DetectPortFree(dd);
+ DetectPortFree(NULL, dd);
return 1;
}
result = 1;
}
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
return result;
}
result = 1;
}
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
return result;
}
int r = DetectPortParse(NULL,&dd,"!80:81");
if (r == 0) {
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
return 1;
}
if (dd->next->port != 82 || dd->next->port2 != 65535)
goto end;
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
result = 1;
end:
return result;
end:
if (copy != NULL)
- DetectPortCleanupList(copy);
+ DetectPortCleanupList(NULL, copy);
if (dd != NULL)
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
return result;
}
if (dd->next->port != 903 || dd->next->port2 != 65535)
goto end;
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
result = 1;
end:
return result;
if (r == 0)
goto end;
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
result = 1;
end:
return result;
if (dd->port != 1024 || dd->port2 != 0xffff)
goto end;
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
result = 1;
end:
return result;
goto end;
}
- DetectPortFree(dd);
+ DetectPortFree(NULL, dd);
end:
return result;
goto end;
}
- DetectPortFree(dd);
+ DetectPortFree(NULL, dd);
end:
return result;
goto end;
}
- DetectPortFree(dd);
+ DetectPortFree(NULL, dd);
result = 1 ;
end:
goto end;
}
- DetectPortFree(dd);
+ DetectPortFree(NULL, dd);
end:
return result;
DetectPort *dd = NULL;
int result = 0;
- int r = DetectPortParseInsertString(&dd, "0:100");
+ int r = DetectPortParseInsertString(NULL, &dd, "0:100");
if (r != 0)
goto end;
- r = DetectPortParseInsertString(&dd, "1000:65535");
+ r = DetectPortParseInsertString(NULL, &dd, "1000:65535");
if (r != 0 || dd->next == NULL)
goto end;
result &= (dd->next->port == 1000) ? 1 : 0;
result &= (dd->next->port2 == 65535) ? 1 : 0;
- DetectPortFree(dd);
+ DetectPortFree(NULL, dd);
end:
return result;
result &= (dd->next->port == 3001) ? 1 : 0;
result &= (dd->next->port2 == 65535) ? 1 : 0;
- DetectPortFree(dd);
+ DetectPortFree(NULL, dd);
end:
return result;
end:
if (copy != NULL)
- DetectPortCleanupList(copy);
+ DetectPortCleanupList(NULL, copy);
if (dd != NULL)
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
return result;
}
result = 1;
end:
if (dp1 != NULL)
- DetectPortFree(dp1);
+ DetectPortFree(NULL, dp1);
if (head != NULL)
- DetectPortFree(head);
+ DetectPortFree(NULL, head);
return result;
}
goto end;
/* Merge Nots */
- r = DetectPortParseMergeNotPorts(&head, &dp1);
+ r = DetectPortParseMergeNotPorts(NULL, &head, &dp1);
if (r != 0 || head->next != NULL)
goto end;
goto end;
/* Merge Nots */
- r = DetectPortParseMergeNotPorts(&head, &dp2);
+ r = DetectPortParseMergeNotPorts(NULL, &head, &dp2);
if (r != 0 || head->next != NULL)
goto end;
end:
if (dp1 != NULL)
- DetectPortFree(dp1);
+ DetectPortFree(NULL, dp1);
if (dp2 != NULL)
- DetectPortFree(dp2);
+ DetectPortFree(NULL, dp2);
if (head != NULL)
- DetectPortFree(head);
+ DetectPortFree(NULL, head);
return result;
}
end:
if (dp1 != NULL)
- DetectPortFree(dp1);
+ DetectPortFree(NULL, dp1);
if (dp2 != NULL)
- DetectPortFree(dp2);
+ DetectPortFree(NULL, dp2);
if (dp3 != NULL)
- DetectPortFree(dp3);
+ DetectPortFree(NULL, dp3);
return result;
}
result = 1;
end:
if (dp1 != NULL)
- DetectPortFree(dp1);
+ DetectPortFree(NULL, dp1);
if (dp2 != NULL)
- DetectPortFree(dp2);
+ DetectPortFree(NULL, dp2);
return result;
}
result = 1;
end:
if (dp1 != NULL)
- DetectPortFree(dp1);
+ DetectPortFree(NULL, dp1);
if (dp2 != NULL)
- DetectPortFree(dp2);
+ DetectPortFree(NULL, dp2);
return result;
}
result = 1;
end:
if (dp1 != NULL)
- DetectPortFree(dp1);
+ DetectPortFree(NULL, dp1);
if (dp2 != NULL)
- DetectPortFree(dp2);
+ DetectPortFree(NULL, dp2);
return result;
}
FAIL_IF_NOT_NULL(DetectPortLookupGroup(dd, 2));
FAIL_IF_NULL(DetectPortLookupGroup(dd, 80));
- DetectPortCleanupList(dd);
+ DetectPortCleanupList(NULL, dd);
PASS;
}
DetectPort *DetectPortCopySingle(DetectEngineCtx *, DetectPort *);
int DetectPortInsertCopy(DetectEngineCtx *,DetectPort **, DetectPort *);
int DetectPortInsert(DetectEngineCtx *,DetectPort **, DetectPort *);
-void DetectPortCleanupList (DetectPort *head);
+void DetectPortCleanupList (const DetectEngineCtx *de_ctx, DetectPort *head);
DetectPort *DetectPortLookupGroup(DetectPort *dp, uint16_t port);
void DetectPortPrint(DetectPort *);
void DetectPortPrintList(DetectPort *head);
int DetectPortCmp(DetectPort *, DetectPort *);
-void DetectPortFree(DetectPort *);
+void DetectPortFree(const DetectEngineCtx *de_ctx, DetectPort *);
int DetectPortTestConfVars(void);
static int PrefilterStoreGetId(DetectEngineCtx *de_ctx,
const char *name, void (*FreeFunc)(void *));
-static const PrefilterStore *PrefilterStoreGetStore(const uint32_t id);
+static const PrefilterStore *PrefilterStoreGetStore(const DetectEngineCtx *de_ctx,
+ const uint32_t id);
static inline void QuickSortSigIntId(SigIntId *sids, uint32_t n)
{
}
}
-static void PrefilterFreeEngines(PrefilterEngine *list)
+static void PrefilterFreeEngines(const DetectEngineCtx *de_ctx, PrefilterEngine *list)
{
PrefilterEngine *t = list;
while (1) {
- const PrefilterStore *s = PrefilterStoreGetStore(t->gid);
+ const PrefilterStore *s = PrefilterStoreGetStore(de_ctx, t->gid);
if (s && s->FreeFunc && t->pectx) {
s->FreeFunc(t->pectx);
}
SCFreeAligned(list);
}
-void PrefilterCleanupRuleGroup(SigGroupHead *sgh)
+void PrefilterCleanupRuleGroup(const DetectEngineCtx *de_ctx, SigGroupHead *sgh)
{
if (sgh->pkt_engines) {
- PrefilterFreeEngines(sgh->pkt_engines);
+ PrefilterFreeEngines(de_ctx, sgh->pkt_engines);
sgh->pkt_engines = NULL;
}
if (sgh->payload_engines) {
- PrefilterFreeEngines(sgh->payload_engines);
+ PrefilterFreeEngines(de_ctx, sgh->payload_engines);
sgh->payload_engines = NULL;
}
if (sgh->tx_engines) {
- PrefilterFreeEngines(sgh->tx_engines);
+ PrefilterFreeEngines(de_ctx, sgh->tx_engines);
sgh->tx_engines = NULL;
}
}
SCFree(ptr);
}
-static SCMutex g_prefilter_mutex = SCMUTEX_INITIALIZER;
-uint32_t g_prefilter_id = 0;
-HashListTable *g_prefilter_hash_table = NULL;
-
-static void PrefilterDeinit(void)
+void PrefilterDeinit(DetectEngineCtx *de_ctx)
{
- SCMutexLock(&g_prefilter_mutex);
- BUG_ON(g_prefilter_hash_table == NULL);
- HashListTableFree(g_prefilter_hash_table);
- SCMutexUnlock(&g_prefilter_mutex);
+ if (de_ctx->prefilter_hash_table != NULL) {
+ HashListTableFree(de_ctx->prefilter_hash_table);
+ }
}
-static void PrefilterInit(void)
+void PrefilterInit(DetectEngineCtx *de_ctx)
{
- SCMutexLock(&g_prefilter_mutex);
- BUG_ON(g_prefilter_hash_table != NULL);
+ BUG_ON(de_ctx->prefilter_hash_table != NULL);
- g_prefilter_hash_table = HashListTableInit(256,
+ de_ctx->prefilter_hash_table = HashListTableInit(256,
PrefilterStoreHashFunc,
PrefilterStoreCompareFunc,
PrefilterStoreFreeFunc);
- BUG_ON(g_prefilter_hash_table == NULL);
- atexit(PrefilterDeinit);
- SCMutexUnlock(&g_prefilter_mutex);
+ BUG_ON(de_ctx->prefilter_hash_table == NULL);
}
static int PrefilterStoreGetId(DetectEngineCtx *de_ctx,
{
PrefilterStore ctx = { name, FreeFunc, 0 };
- if (g_prefilter_hash_table == NULL) {
- PrefilterInit();
- }
+ BUG_ON(de_ctx->prefilter_hash_table == NULL);
SCLogDebug("looking up %s", name);
- SCMutexLock(&g_prefilter_mutex);
- PrefilterStore *rctx = HashListTableLookup(g_prefilter_hash_table, (void *)&ctx, 0);
+ PrefilterStore *rctx = HashListTableLookup(de_ctx->prefilter_hash_table, (void *)&ctx, 0);
if (rctx != NULL) {
- SCMutexUnlock(&g_prefilter_mutex);
return rctx->id;
}
PrefilterStore *actx = SCCalloc(1, sizeof(*actx));
if (actx == NULL) {
- SCMutexUnlock(&g_prefilter_mutex);
return -1;
}
actx->name = name;
actx->FreeFunc = FreeFunc;
- actx->id = g_prefilter_id++;
+ actx->id = de_ctx->prefilter_id++;
SCLogDebug("prefilter engine %s has profile id %u", actx->name, actx->id);
- int ret = HashListTableAdd(g_prefilter_hash_table, actx, 0);
+ int ret = HashListTableAdd(de_ctx->prefilter_hash_table, actx, 0);
if (ret != 0) {
- SCMutexUnlock(&g_prefilter_mutex);
SCFree(actx);
return -1;
}
int r = actx->id;
- SCMutexUnlock(&g_prefilter_mutex);
return r;
}
/** \warning slow */
-static const PrefilterStore *PrefilterStoreGetStore(const uint32_t id)
+static const PrefilterStore *PrefilterStoreGetStore(const DetectEngineCtx *de_ctx,
+ const uint32_t id)
{
+
const PrefilterStore *store = NULL;
- SCMutexLock(&g_prefilter_mutex);
- if (g_prefilter_hash_table != NULL) {
- HashListTableBucket *hb = HashListTableGetListHead(g_prefilter_hash_table);
+ if (de_ctx->prefilter_hash_table != NULL) {
+ HashListTableBucket *hb = HashListTableGetListHead(de_ctx->prefilter_hash_table);
for ( ; hb != NULL; hb = HashListTableGetListNext(hb)) {
PrefilterStore *ctx = HashListTableGetListData(hb);
if (ctx->id == id) {
}
}
}
- SCMutexUnlock(&g_prefilter_mutex);
return store;
}
#ifdef PROFILING
-/** \warning slow */
const char *PrefilterStoreGetName(const uint32_t id)
{
- const char *name = NULL;
- SCMutexLock(&g_prefilter_mutex);
- if (g_prefilter_hash_table != NULL) {
- HashListTableBucket *hb = HashListTableGetListHead(g_prefilter_hash_table);
- for ( ; hb != NULL; hb = HashListTableGetListNext(hb)) {
- PrefilterStore *ctx = HashListTableGetListData(hb);
- if (ctx->id == id) {
- name = ctx->name;
- break;
- }
- }
- }
- SCMutexUnlock(&g_prefilter_mutex);
- return name;
+ return NULL;
}
#endif
void PrefilterFreeEnginesList(PrefilterEngineList *list);
void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
-void PrefilterCleanupRuleGroup(SigGroupHead *sgh);
+void PrefilterCleanupRuleGroup(const DetectEngineCtx *de_ctx, SigGroupHead *sgh);
#ifdef PROFILING
const char *PrefilterStoreGetName(const uint32_t id);
#endif
+void PrefilterInit(DetectEngineCtx *de_ctx);
+void PrefilterDeinit(DetectEngineCtx *de_ctx);
+
int PrefilterGenericMpmRegister(DetectEngineCtx *de_ctx,
SigGroupHead *sgh, MpmCtx *mpm_ctx,
const DetectMpmAppLayerRegistery *mpm_reg, int list_id);
return sgh;
error:
- SigGroupHeadFree(sgh);
+ SigGroupHeadFree(de_ctx, sgh);
return NULL;
}
*
* \param sgh Pointer to the SigGroupHead that has to be freed.
*/
-void SigGroupHeadFree(SigGroupHead *sgh)
+void SigGroupHeadFree(const DetectEngineCtx *de_ctx, SigGroupHead *sgh)
{
if (sgh == NULL)
return;
sgh->init = NULL;
}
- PrefilterCleanupRuleGroup(sgh);
+ PrefilterCleanupRuleGroup(de_ctx, sgh);
SCFree(sgh);
return;
result &= (SigGroupHeadContainsSigId(de_ctx, sh, 4) == 0);
result &= (SigGroupHeadContainsSigId(de_ctx, sh, 5) == 1);
- SigGroupHeadFree(sh);
+ SigGroupHeadFree(de_ctx, sh);
end:
SigCleanSignatures(de_ctx);
result &= (SigGroupHeadContainsSigId(de_ctx, sh, 4) == 0);
result &= (SigGroupHeadContainsSigId(de_ctx, sh, 5) == 0);
- SigGroupHeadFree(sh);
+ SigGroupHeadFree(de_ctx, sh);
end:
SigCleanSignatures(de_ctx);
result &= (SigGroupHeadContainsSigId(de_ctx, dst_sh, 4) == 0);
result &= (SigGroupHeadContainsSigId(de_ctx, dst_sh, 5) == 1);
- SigGroupHeadFree(src_sh);
- SigGroupHeadFree(dst_sh);
+ SigGroupHeadFree(de_ctx, src_sh);
+ SigGroupHeadFree(de_ctx, dst_sh);
end:
SigCleanSignatures(de_ctx);
result &= (sh->match_array[1] == de_ctx->sig_list->next->next);
result &= (sh->match_array[2] == de_ctx->sig_list->next->next->next->next);
- SigGroupHeadFree(sh);
+ SigGroupHeadFree(de_ctx, sh);
end:
SigCleanSignatures(de_ctx);
int SigGroupHeadClearSigs(SigGroupHead *);
int SigGroupHeadCopySigs(DetectEngineCtx *, SigGroupHead *, SigGroupHead **);
-void SigGroupHeadFree(SigGroupHead *);
+void SigGroupHeadFree(const DetectEngineCtx *de_ctx, SigGroupHead *);
void SigGroupHeadFreeMpmArrays(DetectEngineCtx *);
#include "detect-engine-siggroup.h"
#include "detect-engine-address.h"
#include "detect-engine-port.h"
+#include "detect-engine-prefilter.h"
#include "detect-engine-mpm.h"
#include "detect-engine-iponly.h"
#include "detect-engine-tag.h"
}
de_ctx->buffer_type_id = g_buffer_type_id;
+ PrefilterInit(de_ctx);
DetectMpmInitializeAppMpms(de_ctx);
DetectAppLayerInspectEngineCopyListToDetectCtx(de_ctx);
}
SCFree(mlist);
mlist = next;
}
+ PrefilterDeinit(de_ctx);
}
}
SCClassConfDeInitContext(de_ctx);
SCRConfDeInitContext(de_ctx);
- DetectBufferTypeFreeDetectEngine(de_ctx);
SigGroupCleanup(de_ctx);
#endif
}
- DetectPortCleanupList(de_ctx->tcp_whitelist);
- DetectPortCleanupList(de_ctx->udp_whitelist);
+ DetectPortCleanupList(de_ctx, de_ctx->tcp_whitelist);
+ DetectPortCleanupList(de_ctx, de_ctx->udp_whitelist);
+ DetectBufferTypeFreeDetectEngine(de_ctx);
/* freed our var name hash */
VarNameStoreFree(de_ctx->version);
if (x->port != x->port2) {
SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "'%s' is not a valid value "
"for detect.grouping.tcp-whitelist: only single ports allowed", ports);
- DetectPortCleanupList(de_ctx->tcp_whitelist);
+ DetectPortCleanupList(de_ctx, de_ctx->tcp_whitelist);
de_ctx->tcp_whitelist = NULL;
break;
}
if (x->port != x->port2) {
SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "'%s' is not a valid value "
"for detect.grouping.udp-whitelist: only single ports allowed", ports);
- DetectPortCleanupList(de_ctx->udp_whitelist);
+ DetectPortCleanupList(de_ctx, de_ctx->udp_whitelist);
de_ctx->udp_whitelist = NULL;
break;
}
}
if (s->sp != NULL) {
- DetectPortCleanupList(s->sp);
+ DetectPortCleanupList(NULL, s->sp);
}
if (s->dp != NULL) {
- DetectPortCleanupList(s->dp);
+ DetectPortCleanupList(NULL, s->dp);
}
if (s->msg != NULL)
}
end:
- if (port != NULL) DetectPortCleanupList(port);
- if (sig != NULL) SigFree(sig);
- if (de_ctx != NULL) DetectEngineCtxFree(de_ctx);
+ if (port != NULL)
+ DetectPortCleanupList(de_ctx, port);
+ if (sig != NULL)
+ SigFree(sig);
+ if (de_ctx != NULL)
+ DetectEngineCtxFree(de_ctx);
return result;
}
DetectMpmAppLayerRegistery *app_mpms_list;
uint32_t app_mpms_list_cnt;
+ uint32_t prefilter_id;
+ HashListTable *prefilter_hash_table;
+
/** table with mpms and their registration function
* \todo we only need this at init, so perhaps this
* can move to a DetectEngineCtx 'init' struct */
#ifdef PROFILING
-extern uint32_t g_prefilter_id;
-extern HashListTable *g_prefilter_hash_table;
-
typedef struct SCProfilePrefilterData_ {
uint64_t called;
uint64_t total;
SCProfilingPrefilterUpdateCounter(DetectEngineThreadCtx *det_ctx, int id, uint64_t ticks)
{
if (det_ctx != NULL && det_ctx->prefilter_perf_data != NULL &&
- id < (int)g_prefilter_id)
+ id < (int)det_ctx->de_ctx->prefilter_id)
{
SCProfilePrefilterData *p = &det_ctx->prefilter_perf_data[id];
if (ctx == NULL)
return;
- const uint32_t size = g_prefilter_id;
+ const uint32_t size = det_ctx->de_ctx->prefilter_id;
SCProfilePrefilterData *a = SCMalloc(sizeof(SCProfilePrefilterData) * size);
if (a != NULL) {
det_ctx->prefilter_perf_data == NULL)
return;
- for (uint32_t i = 0; i < g_prefilter_id; i++) {
+ for (uint32_t i = 0; i < de_ctx->prefilter_id; i++) {
de_ctx->profile_prefilter_ctx->data[i].called += det_ctx->prefilter_perf_data[i].called;
de_ctx->profile_prefilter_ctx->data[i].total += det_ctx->prefilter_perf_data[i].total;
if (det_ctx->prefilter_perf_data[i].max > de_ctx->profile_prefilter_ctx->data[i].max)
if (profiling_prefilter_enabled == 0)
return;
- const uint32_t size = g_prefilter_id;
- if (g_prefilter_id == 0)
+ const uint32_t size = de_ctx->prefilter_id;
+ if (size == 0)
return;
de_ctx->profile_prefilter_ctx = SCProfilingPrefilterInitCtx();
BUG_ON(de_ctx->profile_prefilter_ctx->data == NULL);
memset(de_ctx->profile_prefilter_ctx->data, 0x00, sizeof(SCProfilePrefilterData) * size);
- HashListTableBucket *hb = HashListTableGetListHead(g_prefilter_hash_table);
+ HashListTableBucket *hb = HashListTableGetListHead(de_ctx->prefilter_hash_table);
for ( ; hb != NULL; hb = HashListTableGetListNext(hb)) {
PrefilterStore *ctx = HashListTableGetListData(hb);
de_ctx->profile_prefilter_ctx->data[ctx->id].name = ctx->name;