spm: add SinglePatternMatchDefaultMatcher

Allows selecting SPM algorithm with the 'spm-algo' value in the YAML
config file.
pull/2086/head
Justin Viiret 10 years ago committed by Victor Julien
parent d84dc02bd7
commit ce408c4d10

@ -84,6 +84,7 @@
#include "util-action.h"
#include "util-magic.h"
#include "util-signal.h"
#include "util-spm.h"
#include "util-var-name.h"
@ -829,6 +830,7 @@ static DetectEngineCtx *DetectEngineCtxInitReal(int minimal, const char *prefix)
}
de_ctx->mpm_matcher = PatternMatchDefaultMatcher();
de_ctx->spm_matcher = SinglePatternMatchDefaultMatcher();
DetectEngineCtxLoadConf(de_ctx);
SigGroupHeadHashInit(de_ctx);

@ -587,6 +587,7 @@ typedef struct DetectEngineCtx_ {
ThresholdCtx ths_ctx;
uint16_t mpm_matcher; /**< mpm matcher this ctx uses */
uint16_t spm_matcher; /**< spm matcher this ctx uses */
/* Config options */

@ -47,12 +47,34 @@
#include "suricata.h"
#include "util-unittest.h"
#include "conf.h"
#include "util-spm.h"
#include "util-spm-bs.h"
#include "util-spm-bs2bm.h"
#include "util-spm-bm.h"
#include "util-clock.h"
/**
* \brief Returns the single pattern matcher algorithm to be used, based on the
* spm-algo setting in yaml.
*/
uint16_t SinglePatternMatchDefaultMatcher(void) {
char *spm_algo;
if ((ConfGet("spm-algo", &spm_algo)) == 1) {
if (strcmp("bm", spm_algo) == 0) {
return SPM_BM;
}
SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
"Invalid spm algo supplied "
"in the yaml conf file: \"%s\"",
spm_algo);
exit(EXIT_FAILURE);
}
return SPM_BM; /* default to Boyer-Moore */
}
/**
* Wrappers for building context and searching (Bs2Bm and boyermoore)

@ -28,6 +28,13 @@
#include "util-spm-bs2bm.h"
#include "util-spm-bm.h"
enum {
SPM_BM, /* Boyer-Moore */
/* Other SPM matchers will go here. */
};
uint16_t SinglePatternMatchDefaultMatcher(void);
/** Default algorithm to use: Boyer Moore */
uint8_t *Bs2bmSearch(const uint8_t *text, uint32_t textlen, const uint8_t *needle, uint16_t needlelen);
uint8_t *Bs2bmNocaseSearch(const uint8_t *text, uint32_t textlen, const uint8_t *needle, uint16_t needlelen);

Loading…
Cancel
Save