#include "util-action.h"
#include "util-magic.h"
#include "util-signal.h"
+#include "util-spm.h"
#include "util-var-name.h"
}
de_ctx->mpm_matcher = PatternMatchDefaultMatcher();
+ de_ctx->spm_matcher = SinglePatternMatchDefaultMatcher();
DetectEngineCtxLoadConf(de_ctx);
SigGroupHeadHashInit(de_ctx);
ThresholdCtx ths_ctx;
uint16_t mpm_matcher; /**< mpm matcher this ctx uses */
+ uint16_t spm_matcher; /**< spm matcher this ctx uses */
/* Config options */
#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)
#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);