No more space is needed.
memset(&alpd_ctx, 0, sizeof(alpd_ctx));
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
uint8_t mpm_matcher = PatternMatchDefaultMatcher();
alpd_ctx.spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
const char *teststring = "abc\\:def";
const char *teststringparsed = "abc:def";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
const char *teststring = "abc\\;def";
const char *teststringparsed = "abc;def";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
const char *teststring = "abc\\\"def";
const char *teststringparsed = "abc\"def";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
const char *teststring = "abc\\\\def";
const char *teststringparsed = "abc\\def";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
DetectContentData *cd = NULL;
const char *teststring = "abc\\def";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
const char *teststring = "a|42|c|44|e|46|";
const char *teststringparsed = "abcdef";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
DetectContentData *cd = NULL;
const char *teststring = "";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
DetectContentData *cd = NULL;
const char *teststring = "";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
DetectContentData *cd = NULL;
const char *teststring = "boo";
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
}
teststring[idx++] = '\0';
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
}
teststring[idx++] = '\0';
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
}
teststring[idx++] = '\0';
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
}
teststring[idx++] = '\0';
- uint16_t spm_matcher = SinglePatternMatchDefaultMatcher();
+ uint8_t spm_matcher = SinglePatternMatchDefaultMatcher();
SpmGlobalThreadCtx *spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
FAIL_IF(spm_global_thread_ctx == NULL);
uint8_t flags; /**< only DE_QUIET */
uint8_t mpm_matcher; /**< mpm matcher this ctx uses */
- uint16_t spm_matcher; /**< spm matcher this ctx uses */
+ uint8_t spm_matcher; /**< spm matcher this ctx uses */
/* maximum recursion depth for content inspection */
int inspection_recursion_limit;
* \brief Returns the single pattern matcher algorithm to be used, based on the
* spm-algo setting in yaml.
*/
-uint16_t SinglePatternMatchDefaultMatcher(void)
+uint8_t SinglePatternMatchDefaultMatcher(void)
{
const char *spm_algo;
if ((ConfGet("spm-algo", &spm_algo)) == 1) {
if (strcmp("auto", spm_algo) == 0) {
goto default_matcher;
}
- for (uint16_t i = 0; i < SPM_TABLE_SIZE; i++) {
+ for (uint8_t i = 0; i < SPM_TABLE_SIZE; i++) {
if (spm_table[i].name == NULL) {
continue;
}
#endif
}
-SpmGlobalThreadCtx *SpmInitGlobalThreadCtx(uint16_t matcher)
+SpmGlobalThreadCtx *SpmInitGlobalThreadCtx(uint8_t matcher)
{
BUG_ON(spm_table[matcher].InitGlobalThreadCtx == NULL);
return spm_table[matcher].InitGlobalThreadCtx();
if (global_thread_ctx == NULL) {
return;
}
- uint16_t matcher = global_thread_ctx->matcher;
+ uint8_t matcher = global_thread_ctx->matcher;
spm_table[matcher].DestroyGlobalThreadCtx(global_thread_ctx);
}
if (global_thread_ctx == NULL) {
return NULL;
}
- uint16_t matcher = global_thread_ctx->matcher;
+ uint8_t matcher = global_thread_ctx->matcher;
BUG_ON(spm_table[matcher].MakeThreadCtx == NULL);
return spm_table[matcher].MakeThreadCtx(global_thread_ctx);
}
if (thread_ctx == NULL) {
return;
}
- uint16_t matcher = thread_ctx->matcher;
+ uint8_t matcher = thread_ctx->matcher;
BUG_ON(spm_table[matcher].DestroyThreadCtx == NULL);
spm_table[matcher].DestroyThreadCtx(thread_ctx);
}
SpmGlobalThreadCtx *global_thread_ctx)
{
BUG_ON(global_thread_ctx == NULL);
- uint16_t matcher = global_thread_ctx->matcher;
+ uint8_t matcher = global_thread_ctx->matcher;
BUG_ON(spm_table[matcher].InitCtx == NULL);
return spm_table[matcher].InitCtx(needle, needle_len, nocase,
global_thread_ctx);
if (ctx == NULL) {
return;
}
- uint16_t matcher = ctx->matcher;
+ uint8_t matcher = ctx->matcher;
BUG_ON(spm_table[matcher].DestroyCtx == NULL);
spm_table[matcher].DestroyCtx(ctx);
}
uint8_t *SpmScan(const SpmCtx *ctx, SpmThreadCtx *thread_ctx,
const uint8_t *haystack, uint32_t haystack_len)
{
- uint16_t matcher = ctx->matcher;
+ uint8_t matcher = ctx->matcher;
return spm_table[matcher].Scan(ctx, thread_ctx, haystack, haystack_len);
}
} SpmTestData;
/* Helper function to conduct a search with a particular SPM matcher. */
-static int SpmTestSearch(const SpmTestData *d, uint16_t matcher)
+static int SpmTestSearch(const SpmTestData *d, uint8_t matcher)
{
int ret = 1;
SpmGlobalThreadCtx *global_thread_ctx = NULL;
int ret = 1;
- uint16_t matcher;
+ uint8_t matcher;
for (matcher = 0; matcher < SPM_TABLE_SIZE; matcher++) {
const SpmTableElmt *m = &spm_table[matcher];
if (m->name == NULL) {
int ret = 1;
- uint16_t matcher;
+ uint8_t matcher;
for (matcher = 0; matcher < SPM_TABLE_SIZE; matcher++) {
const SpmTableElmt *m = &spm_table[matcher];
if (m->name == NULL) {
SPM_TABLE_SIZE
};
-uint16_t SinglePatternMatchDefaultMatcher(void);
+uint8_t SinglePatternMatchDefaultMatcher(void);
/** Structure holding an immutable "built" SPM matcher (such as the Boyer-Moore
* tables, Hyperscan database etc) that is passed to the Scan call. */
typedef struct SpmCtx_ {
- uint16_t matcher;
+ uint8_t matcher;
void *ctx;
} SpmCtx;
/** Structure holding a global prototype for per-thread scratch space, passed
* to each InitCtx call. */
typedef struct SpmGlobalThreadCtx_ {
- uint16_t matcher;
+ uint8_t matcher;
void *ctx;
} SpmGlobalThreadCtx;
/** Structure holding some mutable per-thread space for use by a matcher at
* scan time. Constructed from SpmGlobalThreadCtx by the MakeThreadCtx call. */
typedef struct SpmThreadCtx_ {
- uint16_t matcher;
+ uint8_t matcher;
void *ctx;
} SpmThreadCtx;
void SpmTableSetup(void);
-SpmGlobalThreadCtx *SpmInitGlobalThreadCtx(uint16_t matcher);
+SpmGlobalThreadCtx *SpmInitGlobalThreadCtx(uint8_t matcher);
void SpmDestroyGlobalThreadCtx(SpmGlobalThreadCtx *g_thread_ctx);