Go to the documentation of this file.
43 #ifdef BUILD_HYPERSCAN
124 if (mpm_ctx == i->mpm_ctx_ts || mpm_ctx == i->mpm_ctx_tc) {
139 }
else if (
id < -1) {
149 return (direction == 0) ? i->mpm_ctx_ts : i->mpm_ctx_tc;
197 if (
mpm_table[matcher].InitThreadCtx != NULL) {
204 if (
mpm_table[matcher].DestroyThreadCtx != NULL) {
217 #ifdef BUILD_HYPERSCAN
218 # define DEFAULT_MPM MPM_HS
219 # define DEFAULT_MPM_AC MPM_AC
221 # define DEFAULT_MPM MPM_AC
231 #ifdef BUILD_HYPERSCAN
232 #ifdef HAVE_HS_VALID_PLATFORM
235 if (hs_valid_platform() != HS_SUCCESS) {
236 SCLogInfo(
"SSSE3 support not detected, disabling Hyperscan for "
250 uint16_t
offset, uint16_t depth,
259 uint16_t
offset, uint16_t depth,
278 static inline uint32_t MpmInitHashRaw(uint8_t *pat, uint16_t patlen)
280 uint32_t hash = patlen * pat[0];
300 uint8_t *pat, uint16_t patlen,
301 uint16_t
offset, uint16_t depth,
302 uint8_t
flags, uint32_t pid)
304 uint32_t hash = MpmInitHashRaw(pat, patlen);
306 if (
ctx->init_hash == NULL) {
311 for ( ; t != NULL; t = t->
next) {
361 if (p->
cs != NULL && p->
cs != p->
ci) {
379 if (p->
sids != NULL) {
388 static inline uint32_t MpmInitHash(
MpmPattern *p)
399 uint32_t hash = MpmInitHash(p);
401 if (
ctx->init_hash == NULL) {
405 if (
ctx->init_hash[hash] == NULL) {
406 ctx->init_hash[hash] = p;
439 uint16_t
offset, uint16_t depth, uint32_t pid,
442 SCLogDebug(
"Adding pattern for ctx %p, patlen %"PRIu16
" and pid %" PRIu32,
443 mpm_ctx, patlen, pid);
454 MpmPattern *p = MpmInitHashLookup(mpm_ctx, pat, patlen,
460 p = MpmAllocPattern(mpm_ctx);
483 memcpy_tolower(p->
ci, pat, patlen);
490 if (memcmp(p->
ci, pat, p->
len) == 0) {
499 memcpy(p->
cs, pat, patlen);
504 if (MpmInitHashAdd(mpm_ctx, p) != 0)
516 SCLogDebug(
"%p: alas, no depth for us", mpm_ctx);
520 if (mpm_ctx->
maxlen < patlen)
523 if (mpm_ctx->
minlen == 0) {
526 if (mpm_ctx->
minlen > patlen)
546 if (p->
sids[x] == sid) {
585 if (
mpm_table[i].RegisterUnittests != NULL) {
591 "unittest registration function.",
void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t matcher)
void(* InitThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *)
void MpmFactoryDeRegisterAllMpmCtxProfiles(DetectEngineCtx *de_ctx)
void MpmFreePattern(MpmCtx *mpm_ctx, MpmPattern *p)
void MpmFactoryReClaimMpmCtx(const DetectEngineCtx *de_ctx, MpmCtx *mpm_ctx)
struct HtpBodyChunk_ * next
void MpmRegisterTests(void)
main detection engine ctx
int(* AddPatternNocase)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t)
int(* AddPattern)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t)
uint8_t mpm_default_matcher
MpmCtxFactoryContainer * mpm_ctx_factory_container
void(* InitCtx)(struct MpmCtx_ *)
void MpmInitCtx(MpmCtx *mpm_ctx, uint8_t matcher)
struct MpmPattern_ MpmPattern
void MpmDestroyThreadCtx(MpmThreadCtx *mpm_thread_ctx, const uint16_t matcher)
int32_t MpmFactoryIsMpmCtxAvailable(const DetectEngineCtx *de_ctx, const MpmCtx *mpm_ctx)
struct MpmPattern_ * next
MpmCtx * MpmFactoryGetMpmCtxForProfile(const DetectEngineCtx *de_ctx, int32_t id, int direction)
#define MPM_PATTERN_CTX_OWNS_ID
#define SCLogWarning(...)
Macro used to log WARNING messages.
MpmCtxFactoryItem * items
#define MPMCTX_FLAGS_GLOBAL
int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *name, const int sm_list, const AppProto alproto)
Register a new Mpm Context.
#define MPM_INIT_HASH_SIZE
int MpmAddPatternCS(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
#define MPMCTX_FLAGS_NODEPTH
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void MpmACTileRegister(void)
Register the aho-corasick mpm 'ks' originally developed by Ken Steele for Tilera Tile-Gx processor.
#define ENGINE_SGH_MPM_FACTORY_CONTEXT_START_ID_RANGE
struct MpmCtxFactoryItem * next
#define SCRealloc(ptr, sz)
#define MPM_PATTERN_FLAG_NOCASE
#define SCLogError(...)
Macro used to log ERROR messages.
void(* DestroyCtx)(struct MpmCtx_ *)
#define MPM_CTX_FACTORY_UNIQUE_CONTEXT
void MpmACRegister(void)
Register the aho-corasick mpm.
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
int MpmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
void(* DestroyThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *)
int MpmAddPatternCI(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
void(* RegisterUnittests)(void)