#define SGH_DIRECTION_TS(sgh) ((sgh)->init->direction & SIG_FLAG_TOSERVER)
#define SGH_DIRECTION_TC(sgh) ((sgh)->init->direction & SIG_FLAG_TOCLIENT)
-SigMatch *RetrieveFPForSig(Signature *s)
+void RetrieveFPForSig(Signature *s)
{
if (s->mpm_sm != NULL)
- return s->mpm_sm;
-
+ return;
SigMatch *mpm_sm = NULL, *sm = NULL;
int nn_sm_list[DETECT_SM_LIST_MAX];
int count_n_sm_list = 0;
int list_id;
+ /* inspect rule to see if we have the fast_pattern keyword to
+ * force using a sig, otherwise keep stats about the patterns */
for (list_id = 0; list_id < DETECT_SM_LIST_MAX; list_id++) {
if (!FastPatternSupportEnabledForSigMatchList(list_id))
continue;
continue;
DetectContentData *cd = (DetectContentData *)sm->ctx;
- if ((cd->flags & DETECT_CONTENT_FAST_PATTERN))
- return sm;
+
+ /* fast_pattern set in rule, so using this pattern */
+ if ((cd->flags & DETECT_CONTENT_FAST_PATTERN)) {
+ s->mpm_sm = sm;
+ return;
+ }
+
if (cd->flags & DETECT_CONTENT_NEGATED) {
n_sm_list[list_id] = 1;
count_n_sm_list++;
nn_sm_list[list_id] = 1;
count_nn_sm_list++;
}
- } /* for */
- } /* for */
+ }
+ }
+ /* prefer normal not-negated over negated */
int *curr_sm_list = NULL;
int skip_negated_content = 1;
if (count_nn_sm_list > 0) {
curr_sm_list = n_sm_list;
skip_negated_content = 0;
} else {
- return NULL;
+ return;
}
int final_sm_list[DETECT_SM_LIST_MAX];
while (tmp != NULL) {
for (priority = tmp->priority;
tmp != NULL && priority == tmp->priority;
- tmp = tmp->next) {
-
+ tmp = tmp->next)
+ {
if (curr_sm_list[tmp->list_id] == 0)
continue;
final_sm_list[count_final_sm_list++] = tmp->list_id;
} else {
SCLogDebug("sticking with mpm_sm");
}
- } /* else - if */
- } /* for */
- } /* for */
+ }
+ }
+ }
- return mpm_sm;
+ s->mpm_sm = mpm_sm;
+ return;
}
/** \internal
* true size, since duplicates are removed below, but counted here.
*/
for (s = de_ctx->sig_list; s != NULL; s = s->next) {
- s->mpm_sm = RetrieveFPForSig(s);
+ RetrieveFPForSig(s);
if (s->mpm_sm != NULL) {
DetectContentData *cd = (DetectContentData *)s->mpm_sm->ctx;
struct_total_size += sizeof(DetectFPAndItsId);
sig = DetectEngineAppendSig(de_ctx, line);
if (sig != NULL) {
if (rule_engine_analysis_set || fp_engine_analysis_set) {
- sig->mpm_sm = RetrieveFPForSig(sig);
+ RetrieveFPForSig(sig);
if (fp_engine_analysis_set) {
EngineAnalysisFP(sig, line);
}