Go to the documentation of this file.
44 #ifdef BUILD_HYPERSCAN
74 if (item->
sm_list == sm_list && item->
name != NULL && strcmp(item->
name, name) == 0) {
123 if (mpm_ctx == i->mpm_ctx_ts || mpm_ctx == i->mpm_ctx_tc) {
137 memset(mpm_ctx, 0,
sizeof(
MpmCtx));
139 }
else if (
id < -1) {
149 return (direction == 0) ? i->mpm_ctx_ts : i->mpm_ctx_tc;
208 #ifdef BUILD_HYPERSCAN
209 # define DEFAULT_MPM MPM_HS
210 # define DEFAULT_MPM_AC MPM_AC
212 # define DEFAULT_MPM MPM_AC
223 #ifdef BUILD_HYPERSCAN
224 #ifdef HAVE_HS_VALID_PLATFORM
227 if (hs_valid_platform() != HS_SUCCESS) {
228 SCLogInfo(
"SSSE3 support not detected, disabling Hyperscan for "
242 uint16_t
offset, uint16_t depth,
251 uint16_t
offset, uint16_t depth,
270 static inline uint32_t MpmInitHashRaw(uint8_t *pat, uint16_t patlen)
272 uint32_t hash = patlen * pat[0];
292 uint8_t *pat, uint16_t patlen,
293 uint16_t
offset, uint16_t depth,
294 uint8_t
flags, uint32_t pid)
296 uint32_t hash = MpmInitHashRaw(pat, patlen);
303 for ( ; t != NULL; t = t->
next) {
351 if (p != NULL && p->
cs != NULL && p->
cs != p->
ci) {
357 if (p != NULL && p->
ci != NULL) {
377 static inline uint32_t MpmInitHash(
MpmPattern *p)
388 uint32_t hash = MpmInitHash(p);
428 uint16_t
offset, uint16_t depth, uint32_t pid,
431 SCLogDebug(
"Adding pattern for ctx %p, patlen %"PRIu16
" and pid %" PRIu32,
432 mpm_ctx, patlen, pid);
443 MpmPattern *p = MpmInitHashLookup(mpm_ctx, pat, patlen,
449 p = MpmAllocPattern(mpm_ctx);
472 memcpy_tolower(p->
ci, pat, patlen);
479 if (memcmp(p->
ci, pat, p->
len) == 0) {
488 memcpy(p->
cs, pat, patlen);
493 if (MpmInitHashAdd(mpm_ctx, p) != 0)
505 SCLogDebug(
"%p: alas, no depth for us", mpm_ctx);
509 if (mpm_ctx->
maxlen < patlen)
512 if (mpm_ctx->
minlen == 0) {
515 if (mpm_ctx->
minlen > patlen)
535 if (p->
sids[x] == sid) {
574 if (
mpm_table[i].RegisterUnittests != NULL) {
580 "unittest registration function.",
mpm_table[i].name);
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
@ SC_ERR_INVALID_ARGUMENTS
void(* InitCtx)(struct MpmCtx_ *)
void MpmInitCtx(MpmCtx *mpm_ctx, uint8_t matcher)
int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *name, const int sm_list)
Register a new Mpm Context.
struct MpmPattern_ MpmPattern
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
MpmCtxFactoryItem * items
#define MPMCTX_FLAGS_GLOBAL
#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
void MpmACBSRegister(void)
Register the aho-corasick mpm.
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
#define FatalError(x,...)
void(* DestroyCtx)(struct MpmCtx_ *)
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
#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)
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)