install -d "$(DESTDIR)$(e_rundir)"
install -m 770 -d "$(DESTDIR)$(e_localstatedir)"
install -m 770 -d "$(DESTDIR)$(e_datadir)"
+ install -m 660 -d "$(DESTDIR)$(e_sghcachedir)"
install-rules:
if INSTALL_SURICATA_UPDATE
e_sysconfdir="${e_winbase}\\\\"
e_defaultruledir="$e_winbase\\\\rules\\\\"
+ e_sghcachedir="$e_winbase\\\\cache\\\\sgh\\\\"
e_magic_file="$e_winbase\\\\magic.mgc"
e_logdir="$e_winbase\\\\log"
e_logfilesdir="$e_logdir\\\\files"
EXPAND_VARIABLE(sysconfdir, e_sysconfdir, "/suricata/")
EXPAND_VARIABLE(localstatedir, e_localstatedir, "/run/suricata")
EXPAND_VARIABLE(datadir, e_datarulesdir, "/suricata/rules")
+ EXPAND_VARIABLE(localstatedir, e_sghcachedir, "/lib/suricata/cache/sgh")
EXPAND_VARIABLE(localstatedir, e_datadir, "/lib/suricata/data")
EXPAND_VARIABLE(localstatedir, e_defaultruledir, "/lib/suricata/rules")
AC_SUBST(e_sysconfdir)
AC_DEFINE_UNQUOTED([CONFIG_DIR],["$e_sysconfdir"],[Our CONFIG_DIR])
AC_SUBST(e_localstatedir)
+AC_SUBST(e_sghcachedir)
+AC_DEFINE_UNQUOTED([SGH_CACHE_DIR],["$e_sghcachedir"],[Directory path for signature group head cache])
AC_SUBST(e_datadir)
AC_DEFINE_UNQUOTED([DATA_DIR],["$e_datadir"],[Our DATA_DIR])
AC_SUBST(e_magic_file)
int ret = 0;
MpmCtx *mpm_ctx = &ctx->mpm_ctx;
- if (mpm_table[mpm_ctx->mpm_type].Prepare(mpm_ctx) < 0)
+ if (mpm_table[mpm_ctx->mpm_type].Prepare(NULL, mpm_ctx) < 0)
goto error;
goto end;
MpmInitCtx(ftp_mpm_ctx, FTP_MPM);
SCFTPSetMpmState(ftp_mpm_ctx);
- mpm_table[FTP_MPM].Prepare(ftp_mpm_ctx);
-
+ mpm_table[FTP_MPM].Prepare(NULL, ftp_mpm_ctx);
}
static void FTPFreeMpmState(void)
i /* pattern id */, i /* rule id */ , 0 /* no flags */);
}
- mpm_table[SMTP_MPM].Prepare(smtp_mpm_ctx);
+ mpm_table[SMTP_MPM].Prepare(NULL, smtp_mpm_ctx);
}
static void SMTPFreeMpmState(void)
#include "tm-threads.h"
#include "queue.h"
+#include "detect-engine.h"
#include "detect-engine-loader.h"
#include "detect-engine-build.h"
#include "detect-engine-analyzer.h"
ret = 0;
+ if (mpm_table[de_ctx->mpm_matcher].CacheRuleset != NULL) {
+ mpm_table[de_ctx->mpm_matcher].CacheRuleset(de_ctx->mpm_cfg);
+ }
+
end:
gettimeofday(&de_ctx->last_reload, NULL);
if (SCRunmodeGet() == RUNMODE_ENGINE_ANALYSIS) {
MpmCtx *mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, am->sgh_mpm_context, dir);
if (mpm_ctx != NULL) {
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
}
}
SCLogDebug("%s: %d mpm_Ctx %p", am->name, r, mpm_ctx);
if (mpm_ctx != NULL) {
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
SCLogDebug("%s: %d", am->name, r);
}
}
MpmCtx *mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, am->sgh_mpm_context, 0);
if (mpm_ctx != NULL) {
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
SCLogDebug("%s: %d", am->name, r);
}
}
if (de_ctx->sgh_mpm_context_proto_tcp_packet != MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_tcp_packet, 0);
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_tcp_packet, 1);
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
}
if (de_ctx->sgh_mpm_context_proto_udp_packet != MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_udp_packet, 0);
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_udp_packet, 1);
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
}
if (de_ctx->sgh_mpm_context_proto_other_packet != MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_proto_other_packet, 0);
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
}
if (de_ctx->sgh_mpm_context_stream != MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 0);
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
mpm_ctx = MpmFactoryGetMpmCtxForProfile(de_ctx, de_ctx->sgh_mpm_context_stream, 1);
if (mpm_table[de_ctx->mpm_matcher].Prepare != NULL) {
- r |= mpm_table[de_ctx->mpm_matcher].Prepare(mpm_ctx);
+ r |= mpm_table[de_ctx->mpm_matcher].Prepare(de_ctx->mpm_cfg, mpm_ctx);
}
}
MpmInitCtx(ms->mpm_ctx, de_ctx->mpm_matcher);
+ if (de_ctx->mpm_cfg && de_ctx->mpm_cfg->cache_dir_path)
+ ms->mpm_ctx->flags |= MPMCTX_FLAGS_CACHE_TO_DISK;
+
const bool mpm_supports_endswith =
(mpm_table[de_ctx->mpm_matcher].feature_flags & MPM_FEATURE_FLAG_ENDSWITH) != 0;
} else {
if (ms->sgh_mpm_context == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
if (mpm_table[ms->mpm_ctx->mpm_type].Prepare != NULL) {
- mpm_table[ms->mpm_ctx->mpm_type].Prepare(ms->mpm_ctx);
+ mpm_table[ms->mpm_ctx->mpm_type].Prepare(de_ctx->mpm_cfg, ms->mpm_ctx);
}
}
}
return -1;
}
+bool DetectEngineMpmCachingEnabled(void)
+{
+ const char *strval = NULL;
+ if (ConfGet("detect.sgh-mpm-caching", &strval) != 1)
+ return false;
+
+ int sgh_mpm_caching = 0;
+ (void)ConfGetBool("detect.sgh-mpm-caching", &sgh_mpm_caching);
+ return (bool)sgh_mpm_caching;
+}
+
+const char *DetectEngineMpmCachingGetPath(void)
+{
+ if (DetectEngineMpmCachingEnabled() == false) {
+ return NULL;
+ }
+
+ char yamlpath[] = "detect.sgh-mpm-caching-path";
+ const char *strval = NULL;
+ ConfGet(yamlpath, &strval);
+
+ if (strval != NULL) {
+ return strval;
+ }
+
+ static bool notified = false;
+ if (!notified) {
+ SCLogInfo("%s has no path specified, using %s", yamlpath, SGH_CACHE_DIR);
+ notified = true;
+ }
+ return SGH_CACHE_DIR;
+}
+
static DetectEngineCtx *DetectEngineCtxInitReal(
enum DetectEngineType type, const char *prefix, uint32_t tenant_id)
{
mpm_table[de_ctx->mpm_matcher].name,
spm_table[de_ctx->spm_matcher].name);
+ if (mpm_table[de_ctx->mpm_matcher].ConfigInit) {
+ de_ctx->mpm_cfg = mpm_table[de_ctx->mpm_matcher].ConfigInit();
+ if (de_ctx->mpm_cfg == NULL) {
+ goto error;
+ }
+ }
+ if (DetectEngineMpmCachingEnabled() && mpm_table[de_ctx->mpm_matcher].ConfigCacheDirSet) {
+ mpm_table[de_ctx->mpm_matcher].ConfigCacheDirSet(
+ de_ctx->mpm_cfg, DetectEngineMpmCachingGetPath());
+ }
+
de_ctx->spm_global_thread_ctx = SpmInitGlobalThreadCtx(de_ctx->spm_matcher);
if (de_ctx->spm_global_thread_ctx == NULL) {
SCLogDebug("Unable to alloc SpmGlobalThreadCtx.");
SCProfilingPrefilterDestroyCtx(de_ctx);
#endif
+ if (mpm_table[de_ctx->mpm_matcher].ConfigDeinit) {
+ mpm_table[de_ctx->mpm_matcher].ConfigDeinit(&de_ctx->mpm_cfg);
+ }
/* Normally the hashes are freed elsewhere, but
* to be sure look at them again here.
*/
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **);
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *);
+bool DetectEngineMpmCachingEnabled(void);
+const char *DetectEngineMpmCachingGetPath(void);
/* faster as a macro than a inline function on my box -- VJ */
#define DetectEngineGetMaxSigId(de_ctx) ((de_ctx)->signum)
void DetectEngineResetMaxSigId(DetectEngineCtx *);
bool failure_fatal;
uint8_t flags; /**< only DE_QUIET */
uint8_t mpm_matcher; /**< mpm matcher this ctx uses */
+ MpmConfig *mpm_cfg;
uint8_t spm_matcher; /**< spm matcher this ctx uses */
uint32_t tenant_id;
uint32_t, SigIntId, uint8_t);
int SCACTileAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
-int SCACTilePreparePatterns(MpmCtx *mpm_ctx);
+int SCACTilePreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx);
uint32_t SCACTileSearch(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
PrefilterRuleStore *pmq, const uint8_t *buf,
uint32_t buflen);
/**
* \brief Process the patterns added to the mpm, and create the internal tables.
*
+ * \param mpm_conf Pointer to the generic MPM matcher configuration
* \param mpm_ctx Pointer to the mpm context.
*/
-int SCACTilePreparePatterns(MpmCtx *mpm_ctx)
+int SCACTilePreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx)
{
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
mpm_table[MPM_AC_KS].name = "ac-ks";
mpm_table[MPM_AC_KS].InitCtx = SCACTileInitCtx;
mpm_table[MPM_AC_KS].DestroyCtx = SCACTileDestroyCtx;
+ mpm_table[MPM_AC_KS].ConfigInit = NULL;
+ mpm_table[MPM_AC_KS].ConfigDeinit = NULL;
+ mpm_table[MPM_AC_KS].ConfigCacheDirSet = NULL;
mpm_table[MPM_AC_KS].AddPattern = SCACTileAddPatternCS;
mpm_table[MPM_AC_KS].AddPatternNocase = SCACTileAddPatternCI;
mpm_table[MPM_AC_KS].Prepare = SCACTilePreparePatterns;
+ mpm_table[MPM_AC_KS].CacheRuleset = NULL;
mpm_table[MPM_AC_KS].Search = SCACTileSearch;
mpm_table[MPM_AC_KS].PrintCtx = SCACTilePrintInfo;
#ifdef UNITTESTS
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghj", 4, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghjxyz", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghJikl", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcd";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
PmqSetup(&pmq);
/* total matches: 135: 6 unique */
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"a", 1);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"ab", 2);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "01234567890123456789012345678901234567890123456789"
"01234567890123456789012345678901234567890123456789"
goto end;
PmqSetup(&pmq);
- if (SCACTilePreparePatterns(&mpm_ctx) == -1)
+ if (SCACTilePreparePatterns(NULL, &mpm_ctx) == -1)
goto end;
result = 1;
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"vwxyz", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyz";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCD";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCDE";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABC";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzAB";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"AA", 2);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyz";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"aa", 2);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"aa", 2);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghiJkl", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "works";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "tone";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACTilePreparePatterns(&mpm_ctx);
+ SCACTilePreparePatterns(NULL, &mpm_ctx);
const char *buf = "tONE";
uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
uint32_t, SigIntId, uint8_t);
int SCACAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
-int SCACPreparePatterns(MpmCtx *mpm_ctx);
+int SCACPreparePatterns(MpmConfig *, MpmCtx *mpm_ctx);
uint32_t SCACSearch(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
PrefilterRuleStore *pmq, const uint8_t *buf, uint32_t buflen);
void SCACPrintInfo(MpmCtx *mpm_ctx);
/**
* \brief Process the patterns added to the mpm, and create the internal tables.
*
+ * \param mpm_conf Pointer to the generic MPM matcher configuration
* \param mpm_ctx Pointer to the mpm context.
*/
-int SCACPreparePatterns(MpmCtx *mpm_ctx)
+int SCACPreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx)
{
SCACCtx *ctx = (SCACCtx *)mpm_ctx->ctx;
mpm_table[MPM_AC].name = "ac";
mpm_table[MPM_AC].InitCtx = SCACInitCtx;
mpm_table[MPM_AC].DestroyCtx = SCACDestroyCtx;
+ mpm_table[MPM_AC].ConfigInit = NULL;
+ mpm_table[MPM_AC].ConfigDeinit = NULL;
+ mpm_table[MPM_AC].ConfigCacheDirSet = NULL;
mpm_table[MPM_AC].AddPattern = SCACAddPatternCS;
mpm_table[MPM_AC].AddPatternNocase = SCACAddPatternCI;
mpm_table[MPM_AC].Prepare = SCACPreparePatterns;
+ mpm_table[MPM_AC].CacheRuleset = NULL;
mpm_table[MPM_AC].Search = SCACSearch;
mpm_table[MPM_AC].PrintCtx = SCACPrintInfo;
#ifdef UNITTESTS
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghj", 4, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghjxyz", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghJikl", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcd";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
PmqSetup(&pmq);
/* total matches: 135: unique matches: 6 */
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"a", 1);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"ab", 2);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "01234567890123456789012345678901234567890123456789"
"01234567890123456789012345678901234567890123456789"
goto end;
PmqSetup(&pmq);
- if (SCACPreparePatterns(&mpm_ctx) == -1)
+ if (SCACPreparePatterns(NULL, &mpm_ctx) == -1)
goto end;
result = 1;
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"vwxyz", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyz";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCD";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCDE";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABC";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzAB";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"AA", 2);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyz";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"aa", 2);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
(uint8_t *)"aa", 2);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghiJkl", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "works";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "tone";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf = "tONE";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"xyz", 3, 0, 0, 0, 0, MPM_PATTERN_FLAG_ENDSWITH);
PmqSetup(&pmq);
- SCACPreparePatterns(&mpm_ctx);
+ SCACPreparePatterns(NULL, &mpm_ctx);
const char *buf1 = "abcdefghijklmnopqrstuvwxyz";
uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf1, strlen(buf1));
uint32_t, SigIntId, uint8_t);
int SCHSAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
-int SCHSPreparePatterns(MpmCtx *mpm_ctx);
+int SCHSPreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx);
uint32_t SCHSSearch(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
PrefilterRuleStore *pmq, const uint8_t *buf, const uint32_t buflen);
void SCHSPrintInfo(MpmCtx *mpm_ctx);
/**
* \brief Process the patterns added to the mpm, and create the internal tables.
*
+ * \param mpm_conf Pointer to the generic MPM matcher configuration
* \param mpm_ctx Pointer to the mpm context.
*/
-int SCHSPreparePatterns(MpmCtx *mpm_ctx)
+int SCHSPreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx)
{
SCHSCtx *ctx = (SCHSCtx *)mpm_ctx->ctx;
mpm_table[MPM_HS].InitThreadCtx = SCHSInitThreadCtx;
mpm_table[MPM_HS].DestroyCtx = SCHSDestroyCtx;
mpm_table[MPM_HS].DestroyThreadCtx = SCHSDestroyThreadCtx;
+ mpm_table[MPM_HS].ConfigInit = NULL;
+ mpm_table[MPM_HS].ConfigDeinit = NULL;
+ mpm_table[MPM_HS].ConfigCacheDirSet = NULL;
mpm_table[MPM_HS].AddPattern = SCHSAddPatternCS;
mpm_table[MPM_HS].AddPatternNocase = SCHSAddPatternCI;
mpm_table[MPM_HS].Prepare = SCHSPreparePatterns;
+ mpm_table[MPM_HS].CacheRuleset = NULL;
mpm_table[MPM_HS].Search = SCHSSearch;
mpm_table[MPM_HS].PrintCtx = SCHSPrintInfo;
mpm_table[MPM_HS].PrintThreadCtx = SCHSPrintSearchStats;
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghj", 4, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghjxyz", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghJikl", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghjiklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcd";
0, 0, 5, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
uint32_t cnt =
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
uint32_t cnt =
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "01234567890123456789012345678901234567890123456789"
goto end;
PmqSetup(&pmq);
- if (SCHSPreparePatterns(&mpm_ctx) == -1)
+ if (SCHSPreparePatterns(NULL, &mpm_ctx) == -1)
goto end;
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"vwxyz", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCD";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCDE";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzABC";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyzAB";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcde"
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, sizeof(pat) - 1, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "AAAAA"
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
uint32_t cnt =
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "abcdefghijklmnopqrstuvwxyz";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
uint32_t cnt =
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
uint32_t cnt =
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghiJkl", 7, 0, 0, 2, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "works";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "tone";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
- SCHSPreparePatterns(&mpm_ctx);
+ SCHSPreparePatterns(NULL, &mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
const char *buf = "tONE";
* one per sgh. */
#define MPMCTX_FLAGS_GLOBAL BIT_U8(0)
#define MPMCTX_FLAGS_NODEPTH BIT_U8(1)
+#define MPMCTX_FLAGS_CACHE_TO_DISK BIT_U8(2)
+
+typedef struct MpmConfig_ {
+ const char *cache_dir_path;
+} MpmConfig;
typedef struct MpmCtx_ {
void *ctx;
void (*DestroyCtx)(struct MpmCtx_ *);
void (*DestroyThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *);
+ MpmConfig *(*ConfigInit)(void);
+ void (*ConfigDeinit)(MpmConfig **);
+ void (*ConfigCacheDirSet)(MpmConfig *, const char *dir_path);
+
/** function pointers for adding patterns to the mpm ctx.
*
* \param mpm_ctx Mpm context to add the pattern to
*/
int (*AddPattern)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t);
int (*AddPatternNocase)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t);
- int (*Prepare)(struct MpmCtx_ *);
+ int (*Prepare)(MpmConfig *, struct MpmCtx_ *);
+ int (*CacheRuleset)(MpmConfig *);
/** \retval cnt number of patterns that matches: once per pattern max. */
uint32_t (*Search)(const struct MpmCtx_ *, struct MpmThreadCtx_ *, PrefilterRuleStore *, const uint8_t *, uint32_t);
void (*PrintCtx)(struct MpmCtx_ *);
toclient-groups: 3
toserver-groups: 25
sgh-mpm-context: auto
+ # Cache MPM contexts to the disk to avoid rule compilation at the startup.
+ # Cache files are created in the standard library directory.
+ sgh-mpm-caching: yes
+ sgh-mpm-caching-path: @e_sghcachedir@
# inspection-recursion-limit: 3000
# maximum number of times a tx will get logged for rules without app-layer keywords
# stream-tx-log-limit: 4