Go to the documentation of this file.
24 #ifndef SURICATA_UTIL_SPM_H
25 #define SURICATA_UTIL_SPM_H
65 SpmCtx *(*InitCtx)(
const uint8_t *needle, uint16_t needle_len,
int nocase,
69 const uint8_t *haystack, uint32_t haystack_len);
90 const uint8_t *haystack, uint32_t haystack_len);
94 const uint8_t *text, uint32_t textlen,
const uint8_t *needle, uint16_t needlelen);
95 uint8_t *
BoyerMooreSearch(
const uint8_t *text, uint32_t textlen,
const uint8_t *needle, uint16_t needlelen);
96 uint8_t *
BoyerMooreNocaseSearch(
const uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen);
99 #define SpmSearch(text, textlen, needle, needlelen) ({\
101 if (needlelen < 4 && textlen < 512) \
102 mfound = BasicSearch(text, textlen, needle, needlelen); \
103 else if (needlelen < 4) \
104 mfound = BasicSearch(text, textlen, needle, needlelen); \
106 mfound = BoyerMooreSearch(text, textlen, needle, needlelen); \
110 #define SpmNocaseSearch(text, textlen, needle, needlelen) ({\
112 if (needlelen < 4 && textlen < 512) \
113 mfound = BasicSearchNocase(text, textlen, needle, needlelen); \
114 else if (needlelen < 4) \
115 mfound = BasicSearchNocase(text, textlen, needle, needlelen); \
117 mfound = BoyerMooreNocaseSearch(text, textlen, needle, needlelen); \
struct SpmGlobalThreadCtx_ SpmGlobalThreadCtx
SpmCtx * SpmInitCtx(const uint8_t *needle, uint16_t needle_len, int nocase, SpmGlobalThreadCtx *g_thread_ctx)
uint8_t * SpmScan(const SpmCtx *ctx, SpmThreadCtx *thread_ctx, const uint8_t *haystack, uint32_t haystack_len)
uint8_t SinglePatternMatchDefaultMatcher(void)
Returns the single pattern matcher algorithm to be used, based on the spm-algo setting in yaml.
uint8_t * BoyerMooreNocaseSearch(const uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
Search a pattern in the text using Boyer Moore nocase algorithm (build a bad character shifts array a...
uint8_t * BoyerMooreSearch(const uint8_t *text, uint32_t textlen, const uint8_t *needle, uint16_t needlelen)
Search a pattern in the text using Boyer Moore algorithm (build a bad character shifts array and good...
uint8_t * Bs2bmSearch(const uint8_t *text, uint32_t textlen, const uint8_t *needle, uint16_t needlelen)
Search a pattern in the text using the Bs2Bm algorithm (build a bad characters array)
void SpmDestroyGlobalThreadCtx(SpmGlobalThreadCtx *g_thread_ctx)
SpmThreadCtx * SpmMakeThreadCtx(const SpmGlobalThreadCtx *g_thread_ctx)
void SpmDestroyCtx(SpmCtx *ctx)
SpmTableElmt spm_table[SPM_TABLE_SIZE]
void(* DestroyCtx)(SpmCtx *)
struct SpmTableElmt_ SpmTableElmt
SpmGlobalThreadCtx * SpmInitGlobalThreadCtx(uint8_t matcher)
void SpmDestroyThreadCtx(SpmThreadCtx *thread_ctx)
void UtilSpmSearchRegistertests(void)
struct SpmThreadCtx_ SpmThreadCtx
void(* DestroyThreadCtx)(SpmThreadCtx *thread_ctx)
void(* DestroyGlobalThreadCtx)(SpmGlobalThreadCtx *g_thread_ctx)