memset(alpd_tctx, 0, sizeof(*alpd_tctx));
/* Get the max pat id for all the mpm ctxs. */
- if (PmqSetup(&alpd_tctx->pmq, max_pat_id) < 0)
+ if (PmqSetup(&alpd_tctx->pmq) < 0)
goto error;
for (i = 0; i < FLOW_PROTO_DEFAULT; i++) {
if (unlikely(pmq == NULL)) {
exit(EXIT_FAILURE);
}
- PmqSetup(pmq,
- sizeof(smtp_reply_map)/sizeof(SCEnumCharMap) - 2);
+ PmqSetup(pmq);
return pmq;
}
PatternMatchThreadPrepare(&det_ctx->mtcs, de_ctx->mpm_matcher);
PatternMatchThreadPrepare(&det_ctx->mtcu, de_ctx->mpm_matcher);
- PmqSetup(&det_ctx->pmq, de_ctx->max_fp_id);
+ PmqSetup(&det_ctx->pmq);
for (i = 0; i < DETECT_SMSG_PMQ_NUM; i++) {
- PmqSetup(&det_ctx->smsg_pmq[i], de_ctx->max_fp_id);
+ PmqSetup(&det_ctx->smsg_pmq[i]);
}
/* sized to the max of our sgh settings. A max setting of 0 implies that all
;
} else {
bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
- pmq->pattern_id_bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
- MpmAddPid(pmq, lower_pid);
MpmAddSids(pmq, pid_pat_list[lower_pid].sids, pid_pat_list[lower_pid].sids_size);
}
matches++;
;
} else {
bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
- pmq->pattern_id_bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
-
- MpmAddPid(pmq, pids[k]);
MpmAddSids(pmq, pid_pat_list[pids[k]].sids, pid_pat_list[pids[k]].sids_size);
}
matches++;
;
} else {
bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
- pmq->pattern_id_bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
-
- MpmAddPid(pmq, lower_pid);
MpmAddSids(pmq, pid_pat_list[lower_pid].sids, pid_pat_list[lower_pid].sids_size);
}
matches++;
;
} else {
bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
- pmq->pattern_id_bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
-
- MpmAddPid(pmq, pids[k]);
MpmAddSids(pmq, pid_pat_list[pids[k]].sids, pid_pat_list[pids[k]].sids_size);
}
matches++;
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcde", 4, 0, 0, 1, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghj", 4, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdegh", 6, 0, 0, 1, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghjxyz", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghJikl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
30, 0, 0, 5, 0, 0);
- PmqSetup(&pmq, 6);
+ PmqSetup(&pmq);
/* total matches: 135 */
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
goto end;
if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"hers", 4, 0, 0, 4, 0, 0) == -1)
goto end;
- PmqSetup(&pmq, 5);
+ PmqSetup(&pmq);
if (SCACBSPreparePatterns(&mpm_ctx) == -1)
goto end;
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"vwxyz", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCD";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDE";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABC";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzAB";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 */
char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 */
char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghiJkl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdef", 5, 0, 0, 1, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"cdefg", 5, 0, 0, 3, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"defgh", 5, 0, 0, 4, 0, 0);
- PmqSetup(&pmq, 4);
+ PmqSetup(&pmq);
SCACBSPreparePatterns(&mpm_ctx);
const uint8_t *buf_offset = buf + i + 1; // Lift out of loop
uint32_t no_of_entries = ctx->output_table[state].no_of_entries;
MpmPatternIndex *patterns = ctx->output_table[state].patterns;
- uint8_t *pmq_bitarray = pmq->pattern_id_bitarray;
uint32_t k;
for (k = 0; k < no_of_entries; k++) {
matches++;
continue;
}
- uint32_t pid = pattern_list[pindex].pid;
/* Double check case-sensitve match now. */
if (patterns[k] >> 31) {
uint16_t patlen = pattern_list[pindex].patlen;
/* New match found */
mpm_bitarray[pindex / 8] |= (1 << (pindex % 8));
- if ((pmq_bitarray[pid / 8] & (1 << (pid % 8))) == 0) {
- pmq_bitarray[(pid) / 8] |= (1 << ((pid) % 8));
- MpmAddPid(pmq, pid);
- }
-
/* Always add the Signature IDs, since they could be different in the current MPM
* than in a previous MPM on the same PMQ when finding the same pattern.
*/
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcde", 4, 0, 0, 1, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghj", 4, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdegh", 6, 0, 0, 1, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghjxyz", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghJikl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
30, 0, 0, 5, 0, 0);
- PmqSetup(&pmq, 6);
+ PmqSetup(&pmq);
/* total matches: 135 */
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
goto end;
if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"hers", 4, 0, 0, 4, 0, 0) == -1)
goto end;
- PmqSetup(&pmq, 5);
+ PmqSetup(&pmq);
if (SCACTilePreparePatterns(&mpm_ctx) == -1)
goto end;
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"vwxyz", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCD";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDE";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABC";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzAB";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 */
char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 */
char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghiJkl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACTilePreparePatterns(&mpm_ctx);
if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
;
} else {
- pmq->pattern_id_bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
- MpmAddPid(pmq, lower_pid);
MpmAddSids(pmq, pid_pat_list[lower_pid].sids, pid_pat_list[lower_pid].sids_size);
}
matches++;
if (bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
;
} else {
- pmq->pattern_id_bitarray[(pids[k]) / 8] |= (1 << ((pids[k]) % 8));
bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
- MpmAddPid(pmq, pids[k]);
MpmAddSids(pmq, pid_pat_list[pids[k]].sids, pid_pat_list[pids[k]].sids_size);
}
matches++;
if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
;
} else {
- pmq->pattern_id_bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
- MpmAddPid(pmq, lower_pid);
MpmAddSids(pmq, pid_pat_list[lower_pid].sids, pid_pat_list[lower_pid].sids_size);
}
matches++;
if (bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
;
} else {
- pmq->pattern_id_bitarray[(pids[k]) / 8] |= (1 << ((pids[k]) % 8));
bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
- MpmAddPid(pmq, pids[k]);
MpmAddSids(pmq, pid_pat_list[pids[k]].sids, pid_pat_list[pids[k]].sids_size);
}
matches++;
SCACOutputTable *output_table = ctx->output_table;
SCACPatternList *pid_pat_list = ctx->pid_pat_list;
+ uint8_t bitarray[ctx->pattern_id_bitarray_size];
+ memset(bitarray, 0, ctx->pattern_id_bitarray_size);
+
for (u = 0; u < cuda_matches; u += 2) {
uint32_t offset = results[u];
uint32_t state = results[u + 1];
/* inside loop */
continue;
}
- if (pmq->pattern_id_bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
+ if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
;
} else {
- pmq->pattern_id_bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
+ bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
+ MpmAddSids(pmq, pid_pat_list[lower_pid].sids, pid_pat_list[lower_pid].sids_size);
}
matches++;
} else {
- if (pmq->pattern_id_bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
+ if (bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
;
} else {
- pmq->pattern_id_bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
+ bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
+ MpmAddSids(pmq, pid_pat_list[pids[k]].sids, pid_pat_list[pids[k]].sids_size);
}
matches++;
}
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcde", 4, 0, 0, 1, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghj", 4, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdegh", 6, 0, 0, 1, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghjxyz", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghJikl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
30, 0, 0, 5, 0, 0);
- PmqSetup(&pmq, 6);
+ PmqSetup(&pmq);
/* total matches: 135 */
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
goto end;
if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"hers", 4, 0, 0, 4, 0, 0) == -1)
goto end;
- PmqSetup(&pmq, 5);
+ PmqSetup(&pmq);
if (SCACPreparePatterns(&mpm_ctx) == -1)
goto end;
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"vwxyz", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCD";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDE";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABC";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzAB";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 match */
char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 */
char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 */
char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 1 */
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghiJkl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCACPreparePatterns(&mpm_ctx);
" (pat id=%" PRIu32 ")",
cctx->match_count, (uint32_t)id, (uintmax_t)to, pat->id);
- pmq->pattern_id_bitarray[pat->id / 8] |= (1 << (pat->id % 8));
- MpmAddPid(pmq, pat->id);
MpmAddSids(pmq, pat->sids, pat->sids_size);
cctx->match_count++;
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcde", 4, 0, 0, 1, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghj", 4, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdegh", 6, 0, 0, 1, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"fghjxyz", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghJikl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmInitCtx(&mpm_ctx, MPM_HS);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 30,
0, 0, 5, 0, 0);
- PmqSetup(&pmq, 6);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
goto end;
if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"hers", 4, 0, 0, 4, 0, 0) == -1)
goto end;
- PmqSetup(&pmq, 5);
+ PmqSetup(&pmq);
if (SCHSPreparePatterns(&mpm_ctx) == -1)
goto end;
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"vwxyz", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCD";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDE";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzABC";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
char *pat = "abcdefghijklmnopqrstuvwxyzAB";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
"uvwxy"
"z";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
"AAAAA"
"AA";
MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"fghiJkl", 7, 0, 0, 2, 0, 0);
- PmqSetup(&pmq, 3);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
- PmqSetup(&pmq, 2);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
- PmqSetup(&pmq, 1);
+ PmqSetup(&pmq);
SCHSPreparePatterns(&mpm_ctx);
SCHSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
* \brief Setup a pmq
*
* \param pmq Pattern matcher queue to be initialized
- * \param maxid Max sig id to be matched on
- * \param patmaxid Max pattern id to be matched on
*
* \retval -1 error
* \retval 0 ok
*/
-int PmqSetup(PatternMatcherQueue *pmq, uint32_t patmaxid)
+int PmqSetup(PatternMatcherQueue *pmq)
{
SCEnter();
- SCLogDebug("patmaxid %u", patmaxid);
if (pmq == NULL) {
SCReturnInt(-1);
memset(pmq, 0, sizeof(PatternMatcherQueue));
- if (patmaxid > 0) {
- pmq->pattern_id_array_size = 32; /* Intial size, TODO Make this configure option */
- pmq->pattern_id_array_cnt = 0;
-
- pmq->pattern_id_array = SCCalloc(pmq->pattern_id_array_size, sizeof(uint32_t));
- if (pmq->pattern_id_array == NULL) {
- SCReturnInt(-1);
- }
-
- /* lookup bitarray */
- pmq->pattern_id_bitarray_size = (patmaxid / 8) + 1;
-
- pmq->pattern_id_bitarray = SCMalloc(pmq->pattern_id_bitarray_size);
- if (pmq->pattern_id_bitarray == NULL) {
- SCReturnInt(-1);
- }
- memset(pmq->pattern_id_bitarray, 0, pmq->pattern_id_bitarray_size);
-
- SCLogDebug("pmq->pattern_id_array %p, pmq->pattern_id_bitarray %p",
- pmq->pattern_id_array, pmq->pattern_id_bitarray);
-
- pmq->rule_id_array_size = 128; /* Initial size, TODO: Make configure option. */
- pmq->rule_id_array_cnt = 0;
+ pmq->rule_id_array_size = 128; /* Initial size, TODO: Make configure option. */
+ pmq->rule_id_array_cnt = 0;
- size_t bytes = pmq->rule_id_array_size * sizeof(SigIntId);
- pmq->rule_id_array = (SigIntId*)SCMalloc(bytes);
- if (pmq->rule_id_array == NULL) {
- pmq->rule_id_array_size = 0;
- SCReturnInt(-1);
- }
- // Don't need to zero memory since it is always written first.
+ size_t bytes = pmq->rule_id_array_size * sizeof(SigIntId);
+ pmq->rule_id_array = (SigIntId*)SCMalloc(bytes);
+ if (pmq->rule_id_array == NULL) {
+ pmq->rule_id_array_size = 0;
+ SCReturnInt(-1);
}
+ // Don't need to zero memory since it is always written first.
SCReturnInt(0);
}
return new_size;
}
-/** \brief Increase the size of the Pattern rule ID array.
- *
- * \param pmq storage for match results
- * \param new_size number of Signature IDs needing to be stored.
- *
- * \return 0 on failure.
- */
-int
-MpmAddPidResize(PatternMatcherQueue *pmq, uint32_t new_size)
-{
- /* Need to make the array bigger. Double the size needed to
- * also handle the case that sids_size might still be
- * larger than the old size.
- */
- new_size = new_size * 2;
- uint32_t *new_array = (uint32_t*)SCRealloc(pmq->pattern_id_array,
- new_size * sizeof(uint32_t));
- if (unlikely(new_array == NULL)) {
- // Failed to allocate 2x, so try 1x.
- new_size = new_size / 2;
- new_array = (uint32_t*)SCRealloc(pmq->pattern_id_array,
- new_size * sizeof(uint32_t));
- if (unlikely(new_array == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to realloc PatternMatchQueue"
- " pattern ID array. Some new Pattern ID matches were lost.");
- return 0;
- }
- }
- pmq->pattern_id_array = new_array;
- pmq->pattern_id_array_size = new_size;
-
- return new_size;
-}
-
/**
* \brief Merge two pmq's bitarrays
*
*/
void PmqMerge(PatternMatcherQueue *src, PatternMatcherQueue *dst)
{
- uint32_t u;
-
- if (src->pattern_id_array_cnt == 0)
+ if (src->rule_id_array_cnt == 0)
return;
- for (u = 0; u < src->pattern_id_bitarray_size && u < dst->pattern_id_bitarray_size; u++) {
- dst->pattern_id_bitarray[u] |= src->pattern_id_bitarray[u];
- }
-
- /** \todo now set merged flag? */
-
if (src->rule_id_array && dst->rule_id_array) {
MpmAddSids(dst, src->rule_id_array, src->rule_id_array_cnt);
}
if (pmq == NULL)
return;
- memset(pmq->pattern_id_bitarray, 0, pmq->pattern_id_bitarray_size);
-
- pmq->pattern_id_array_cnt = 0;
-
pmq->rule_id_array_cnt = 0;
/* TODO: Realloc the rule id array smaller at some size? */
}
{
if (pmq == NULL)
return;
-
- if (pmq->pattern_id_array != NULL) {
- SCFree(pmq->pattern_id_array);
- pmq->pattern_id_array = NULL;
- }
-
- if (pmq->pattern_id_bitarray != NULL) {
- SCFree(pmq->pattern_id_bitarray);
- pmq->pattern_id_bitarray = NULL;
- }
-
if (pmq->rule_id_array != NULL) {
SCFree(pmq->rule_id_array);
pmq->rule_id_array = NULL;
}
-
- pmq->pattern_id_array_cnt = 0;
- pmq->pattern_id_array_size = 0;
}
/** \brief Cleanup and free a Pmq
* thread has this and passes a pointer to it to the pattern matcher.
* The actual pattern matcher will fill the structure. */
typedef struct PatternMatcherQueue_ {
- uint32_t *pattern_id_array; /** array with pattern id's that had a
- pattern match. These will be inspected
- futher by the detection engine. */
- uint32_t pattern_id_array_cnt; /**< Number currently stored */
- uint32_t pattern_id_array_size; /**< Allocated size in bytes */
-
- uint8_t *pattern_id_bitarray; /** bitarray with pattern id matches */
- uint32_t pattern_id_bitarray_size; /**< size in bytes */
-
/* used for storing rule id's */
+
/* Array of rule IDs found. */
SigIntId *rule_id_array;
/* Number of rule IDs in the array. */
void MpmFactoryDeRegisterAllMpmCtxProfiles(struct DetectEngineCtx_ *);
int32_t MpmFactoryIsMpmCtxAvailable(const struct DetectEngineCtx_ *, const MpmCtx *);
-int PmqSetup(PatternMatcherQueue *, uint32_t);
+int PmqSetup(PatternMatcherQueue *);
void PmqMerge(PatternMatcherQueue *src, PatternMatcherQueue *dst);
void PmqReset(PatternMatcherQueue *);
void PmqCleanup(PatternMatcherQueue *);
} while (ptr != end);
pmq->rule_id_array_cnt += sids_size;
}
-
-/* Resize Pattern ID array. Only called from MpmAddPid(). */
-int MpmAddPidResize(PatternMatcherQueue *pmq, uint32_t new_size);
-
-static inline void
-MpmAddPid(PatternMatcherQueue *pmq, uint32_t patid)
-{
- uint32_t new_size = pmq->pattern_id_array_cnt + 1;
- if (new_size > pmq->pattern_id_array_size) {
- if (MpmAddPidResize(pmq, new_size) == 0)
- return;
- }
- pmq->pattern_id_array[pmq->pattern_id_array_cnt] = patid;
- pmq->pattern_id_array_cnt = new_size;
- SCLogDebug("pattern_id_array_cnt %u", pmq->pattern_id_array_cnt);
-}
#endif /* __UTIL_MPM_H__ */