Found problems in b2gm and b2gc, so those are removed.
int i = 0;
int matches = 0;
- uint8_t bitarray[pmq->pattern_id_array_size];
- memset(&bitarray, 0, pmq->pattern_id_array_size);
+ uint8_t bitarray[pmq->pattern_id_bitarray_size];
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
uint8_t* restrict xlate = ctx->translate_table;
STYPE *state_table = (STYPE*)ctx->state_table;
SCACTilePatternList *pid_pat_list = ctx->pid_pat_list;
- uint8_t bitarray[pmq->pattern_id_array_size];
- memset(&bitarray, 0, pmq->pattern_id_array_size);
+ uint8_t bitarray[pmq->pattern_id_bitarray_size];
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
uint8_t* restrict xlate = ctx->translate_table;
register int state = 0;
/* \todo Change it for stateful MPM. Supply the state using mpm_thread_ctx */
SCACPatternList *pid_pat_list = ctx->pid_pat_list;
- uint8_t bitarray[pmq->pattern_id_array_size];
- memset(&bitarray, 0, pmq->pattern_id_array_size);
+ uint8_t bitarray[pmq->pattern_id_bitarray_size];
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
if (ctx->state_count < 32767) {
register SC_AC_STATE_TYPE_U16 state = 0;
mpm_ctx->memory_size -= p->len;
}
+ if (p && p->sids) {
+ SCFree(p->sids);
+ mpm_ctx->memory_cnt--;
+ mpm_ctx->memory_size -= p->sids_size * sizeof(uint32_t);
+ }
+
if (p) {
SCFree(p);
mpm_ctx->memory_cnt--;
}
}
+ p->sids_size = 1;
+ p->sids = SCMalloc(p->sids_size * sizeof(uint32_t));
+ BUG_ON(p->sids == NULL);
+ p->sids[0] = sid;
+ mpm_ctx->memory_cnt++;
+ mpm_ctx->memory_size += sizeof(uint32_t);
+
//printf("B2gAddPattern: ci \""); prt(p->ci,p->len);
//printf("\" cs \""); prt(p->cs,p->len);
//printf("\"\n");
if (mpm_ctx->maxlen < patlen) mpm_ctx->maxlen = patlen;
if (mpm_ctx->minlen == 0) mpm_ctx->minlen = patlen;
else if (mpm_ctx->minlen > patlen) mpm_ctx->minlen = patlen;
+ } else {
+ /* Multiple sids for the same pid, so keep an array of sids. */
+
+ /* TODO figure out how we can be called multiple times for the
+ * same CTX with the same sid */
+ int found = 0;
+ uint32_t x = 0;
+ for (x = 0; x < p->sids_size; x++) {
+ if (p->sids[x] == sid) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ uint32_t *sids = SCRealloc(p->sids, (sizeof(uint32_t) * (p->sids_size + 1)));
+ BUG_ON(sids == NULL);
+ p->sids = sids;
+ p->sids[p->sids_size] = sid;
+ p->sids_size++;
+ mpm_ctx->memory_size += sizeof(uint32_t);
+ }
}
return 0;
hi->id = ctx->parray[i]->id;
hi->ci = ctx->parray[i]->ci;
hi->cs = ctx->parray[i]->cs;
+ hi->sids = ctx->parray[i]->sids;
+ hi->sids_size = ctx->parray[i]->sids_size;
} else {
B2gPattern *hi = B2gAllocHashItem(mpm_ctx);
hi->id = ctx->parray[i]->id;
hi->ci = ctx->parray[i]->ci;
hi->cs = ctx->parray[i]->cs;
+ hi->sids = ctx->parray[i]->sids;
+ hi->sids_size = ctx->parray[i]->sids_size;
/* Append this HashItem to the list */
B2gPattern *thi = &ctx->hash1[idx8];
hi->id = ctx->parray[i]->id;
hi->ci = ctx->parray[i]->ci;
hi->cs = ctx->parray[i]->cs;
+ hi->sids = ctx->parray[i]->sids;
+ hi->sids_size = ctx->parray[i]->sids_size;
+
ctx->hash[idx] = hi;
} else {
B2gPattern *hi = B2gAllocHashItem(mpm_ctx);
hi->id = ctx->parray[i]->id;
hi->ci = ctx->parray[i]->ci;
hi->cs = ctx->parray[i]->cs;
+ hi->sids = ctx->parray[i]->sids;
+ hi->sids_size = ctx->parray[i]->sids_size;
+
if (ctx->parray[i]->len < ctx->pminlen[idx])
ctx->pminlen[idx] = ctx->parray[i]->len;
if (buflen < ctx->m)
return 0;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (pos <= (uint32_t)(buflen - B2G_Q + 1)) {
uint16_t h = B2G_HASH16(u8_tolower(buf[pos - 1]),u8_tolower(buf[pos]));
d = ctx->B2G[h];
#endif
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id,
+ bitarray, thi->sids, thi->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
#endif
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id,
+ bitarray, thi->sids, thi->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
if (buflen < ctx->m)
return 0;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (pos <= (buflen - ctx->m)) {
j = ctx->m - 1;
d = ~0;
if (SCMemcmpLowercase(thi->ci, buf+pos, thi->len) == 0) {
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id,
+ bitarray, thi->sids, thi->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
if (SCMemcmp(thi->cs, buf+pos, thi->len) == 0) {
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id,
+ bitarray, thi->sids, thi->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
//printf("BUF "); prt(buf,buflen); printf("\n");
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
uint8_t h8 = u8_tolower(*buf);
hi = &ctx->hash1[h8];
if (p->flags & MPM_PATTERN_FLAG_NOCASE) {
if (h8 == p->ci[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id,
+ bitarray, thi->sids, thi->sids_size);
}
} else {
if (*buf == p->cs[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id,
+ bitarray, thi->sids, thi->sids_size);
}
}
}
if (h8 == p->ci[0] && u8_tolower(*(buf+1)) == p->ci[1]) {
//printf("CI Exact match: "); prt(p->ci, p->len); printf(" in buf "); prt(buf, p->len);printf(" (B2gSearch1)\n");
// for (em = p->em; em; em = em->next) {
- if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id))
- cnt++;
+ if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size))
+ cnt++;
// }
}
} else {
if (*buf == p->cs[0] && *(buf+1) == p->cs[1]) {
//printf("CS Exact match: "); prt(p->cs, p->len); printf(" in buf "); prt(buf, p->len);printf(" (B2gSearch1)\n");
// for (em = p->em; em; em = em->next) {
- if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id))
+ if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size))
cnt++;
// }
}
//printf("BUF "); prt(buf,buflen); printf("\n");
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
uint8_t h = u8_tolower(*buf);
hi = &ctx->hash1[h];
if (thi->flags & MPM_PATTERN_FLAG_NOCASE) {
if (u8_tolower(*buf) == thi->ci[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id, bitarray, thi->sids, thi->sids_size);
}
} else {
if (*buf == thi->cs[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, thi->id, bitarray, thi->sids, thi->sids_size);
}
}
}
uint8_t *original_pat;
uint8_t *ci; /* case INsensitive */
uint8_t *cs; /* case sensitive */
+
+ /* sid(s) for this pattern */
+ uint32_t sids_size;
+ uint32_t *sids;
+
struct B2gPattern_ *next;
} B2gPattern;
mpm_ctx->memory_size -= p->len;
}
+ if (p && p->sids) {
+ SCFree(p->sids);
+ mpm_ctx->memory_cnt--;
+ mpm_ctx->memory_size -= p->sids_size * sizeof(uint32_t);
+ }
+
if (p) {
SCFree(p);
mpm_ctx->memory_cnt--;
//printf("\" cs \""); prt(p->cs,p->len);
//printf("\" prefix_ci %" PRIu32 ", prefix_cs %" PRIu32 "\n", p->prefix_ci, p->prefix_cs);
+ p->sids_size = 1;
+ p->sids = SCMalloc(p->sids_size * sizeof(uint32_t));
+ BUG_ON(p->sids == NULL);
+ p->sids[0] = sid;
+ mpm_ctx->memory_cnt++;
+ mpm_ctx->memory_size += sizeof(uint32_t);
+
/* put in the pattern hash */
B3gInitHashAdd(ctx, p);
if (mpm_ctx->maxlen < patlen) mpm_ctx->maxlen = patlen;
if (mpm_ctx->minlen == 0) mpm_ctx->minlen = patlen;
else if (mpm_ctx->minlen > patlen) mpm_ctx->minlen = patlen;
+ } else {
+ /* Multiple sids for the same pid, so keep an array of sids. */
+
+ /* TODO figure out how we can be called multiple times for the
+ * same CTX with the same sid */
+ int found = 0;
+ uint32_t x = 0;
+ for (x = 0; x < p->sids_size; x++) {
+ if (p->sids[x] == sid) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ uint32_t *sids = SCRealloc(p->sids, (sizeof(uint32_t) * (p->sids_size + 1)));
+ BUG_ON(sids == NULL);
+ p->sids = sids;
+ p->sids[p->sids_size] = sid;
+ p->sids_size++;
+ mpm_ctx->memory_size += sizeof(uint32_t);
+ }
}
return 0;
if (buflen < ctx->m)
return 0;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (pos <= (uint32_t)(buflen - B3G_Q + 1)) {
uint16_t h = B3G_HASH(u8_tolower(buf[pos - 1]), u8_tolower(buf[pos]),u8_tolower(buf[pos + 1]));
d = ctx->B3G[h];
if (memcmp_lowercase(p->ci, buf+j, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
if (memcmp(p->cs, buf+j, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
if (buflen < ctx->m)
return 0;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (pos <= (buflen - ctx->m)) {
j = ctx->m - 2;
d = ~0;
if (memcmp_lowercase(p->ci, buf+pos, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
if (memcmp(p->cs, buf+pos, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ matches += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
//printf("BUF "); prt(buf,buflen); printf("\n");
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
uint8_t h8 = u8_tolower(*buf);
hi = &ctx->hash1[h8];
if (p->flags & MPM_PATTERN_FLAG_NOCASE) {
if (h8 == p->ci[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
} else {
if (*buf == p->cs[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
}
}
if (p->flags & MPM_PATTERN_FLAG_NOCASE) {
if (h8 == p->ci[0] && u8_tolower(*(buf+1)) == p->ci[1]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
} else {
if (*buf == p->cs[0] && *(buf+1) == p->cs[1]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
}
}
//printf("BUF "); prt(buf,buflen); printf("\n");
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
uint16_t h = u8_tolower(*buf) << b3g_hash_shift | u8_tolower(*(buf+1));
hi = ctx->hash2[h];
if (p->flags & MPM_PATTERN_FLAG_NOCASE) {
if (u8_tolower(*buf) == p->ci[0] && u8_tolower(*(buf+1)) == p->ci[1]) {
//printf("CI Exact match: "); prt(p->ci, p->len); printf(" in buf "); prt(buf, p->len);printf(" (B3gSearch1)\n");
- if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id))
+ if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size))
cnt++;
}
} else {
if (*buf == p->cs[0] && *(buf+1) == p->cs[1]) {
//printf("CS Exact match: "); prt(p->cs, p->len); printf(" in buf "); prt(buf, p->len);printf(" (B3gSearch1)\n");
- if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id))
+ if (MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size))
cnt++;
}
}
//printf("BUF "); prt(buf,buflen); printf("\n");
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
uint8_t h = u8_tolower(*buf);
hi = &ctx->hash1[h];
if (p->flags & MPM_PATTERN_FLAG_NOCASE) {
if (u8_tolower(*buf) == p->ci[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
} else {
if (*buf == p->cs[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
}
}
uint8_t *cs; /* case sensitive */
uint8_t *ci; /* case INsensitive */
uint16_t len;
- struct B3gPattern_ *next;
uint8_t flags;
uint32_t id;
+
+ /* sid(s) for this pattern */
+ uint32_t sids_size;
+ uint32_t *sids;
+
+ struct B3gPattern_ *next;
+
} B3gPattern;
typedef struct B3gHashItem_ {
mpm_ctx->memory_size -= p->len;
}
+ if (p && p->sids) {
+ SCFree(p->sids);
+ mpm_ctx->memory_cnt--;
+ mpm_ctx->memory_size -= p->sids_size * sizeof(uint32_t);
+ }
+
if (p) {
SCFree(p);
mpm_ctx->memory_cnt--;
if (mpm_ctx->maxlen < patlen) mpm_ctx->maxlen = patlen;
if (mpm_ctx->minlen == 0) mpm_ctx->minlen = patlen;
else if (mpm_ctx->minlen > patlen) mpm_ctx->minlen = patlen;
+
+ p->sids_size = 1;
+ p->sids = SCMalloc(p->sids_size * sizeof(uint32_t));
+ BUG_ON(p->sids == NULL);
+ p->sids[0] = sid;
+ mpm_ctx->memory_cnt++;
+ mpm_ctx->memory_size += sizeof(uint32_t);
+
+ } else {
+ /* TODO figure out how we can be called multiple times for the same CTX with the same sid */
+
+ int found = 0;
+ uint32_t x = 0;
+ for (x = 0; x < p->sids_size; x++) {
+ if (p->sids[x] == sid) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ uint32_t *sids = SCRealloc(p->sids, (sizeof(uint32_t) * (p->sids_size + 1)));
+ BUG_ON(sids == NULL);
+ p->sids = sids;
+ p->sids[p->sids_size] = sid;
+ p->sids_size++;
+ mpm_ctx->memory_size += sizeof(uint32_t);
+ }
}
return 0;
buf+=(sl-1);
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
h = HASH9(wm_tolower(*buf),(wm_tolower(*(buf-1))));
shift = ctx->shifttable[h];
//printf("CI Exact match: "); prt(p->ci, p->len); printf("\n");
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
//printf("CS Exact match: "); prt(p->cs, p->len); printf("\n");
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
buf+=(sl-1);
//buf++;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
//h = (wm_tolower(*buf)<<8)+(wm_tolower(*(buf-1)));
h = HASH12(wm_tolower(*buf),(wm_tolower(*(buf-1))));
//printf("CI Exact match: "); prt(p->ci, p->len); printf("\n");
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
//printf("CS Exact match: "); prt(p->cs, p->len); printf("\n");
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
buf+=(sl-1);
//buf++;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
//h = (wm_tolower(*buf)<<8)+(wm_tolower(*(buf-1)));
h = HASH14(wm_tolower(*buf),(wm_tolower(*(buf-1))));
if (memcmp_lowercase(p->ci, buf-sl+1, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
if (memcmp(p->cs, buf-sl+1, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
buf+=(sl-1);
//buf++;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
//h = (wm_tolower(*buf)<<8)+(wm_tolower(*(buf-1)));
h = HASH15(wm_tolower(*buf),(wm_tolower(*(buf-1))));
//printf("CI Exact match: "); prt(p->ci, p->len); printf("\n");
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
//printf("CS Exact match: "); prt(p->cs, p->len); printf("\n");
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
buf+=(sl-1);
//buf++;
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
while (buf <= bufend) {
//h = (wm_tolower(*buf)<<8)+(wm_tolower(*(buf-1)));
h = HASH16(wm_tolower(*buf),(wm_tolower(*(buf-1))));
if (memcmp_lowercase(p->ci, buf-sl+1, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
if (memcmp(p->cs, buf-sl+1, p->len) == 0) {
COUNT(tctx->stat_loop_match++);
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
} else {
COUNT(tctx->stat_loop_no_match++);
}
//printf("BUF "); prt(buf,buflen); printf("\n");
+ uint8_t *bitarray = NULL;
+ if (pmq) {
+ bitarray = alloca(pmq->pattern_id_bitarray_size);
+ memset(bitarray, 0, pmq->pattern_id_bitarray_size);
+ }
+
if (mpm_ctx->minlen == 1) {
while (buf <= bufend) {
uint8_t h = wm_tolower(*buf);
if (p->flags & MPM_PATTERN_FLAG_NOCASE) {
if (wm_tolower(*buf) == p->ci[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
} else {
if (*buf == p->cs[0]) {
- cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id);
+ cnt += MpmVerifyMatch(mpm_thread_ctx, pmq, p->id, bitarray, p->sids, p->sids_size);
}
}
}
uint16_t prefix_cs;
uint8_t flags;
uint32_t id; /* global pattern id */
+
+ /* sid(s) for this pattern */
+ uint32_t sids_size;
+ uint32_t *sids;
+
} WmPattern;
typedef struct WmHashItem_ {
#include "util-mpm-wumanber.h"
#include "util-mpm-b2g.h"
#include "util-mpm-b3g.h"
-#include "util-mpm-b2gc.h"
-#include "util-mpm-b2gm.h"
#include "util-mpm-ac.h"
#include "util-mpm-ac-gfbs.h"
#include "util-mpm-ac-bs.h"
* \retval 1 (new) match
*/
int
-MpmVerifyMatch(MpmThreadCtx *thread_ctx, PatternMatcherQueue *pmq, uint32_t patid)
+MpmVerifyMatch(MpmThreadCtx *thread_ctx, PatternMatcherQueue *pmq, uint32_t patid,
+ uint8_t *bitarray, uint32_t *sids, uint32_t sids_size)
{
SCEnter();
if (pmq != NULL && pmq->pattern_id_bitarray != NULL) {
SCLogDebug("using pattern id arrays, storing %"PRIu32, patid);
- if (!(pmq->pattern_id_bitarray[(patid / 8)] & (1<<(patid % 8)))) {
+ if ((bitarray[(patid / 8)] & (1<<(patid % 8))) == 0) {
+ bitarray[(patid / 8)] |= (1<<(patid % 8));
/* flag this pattern id as being added now */
pmq->pattern_id_bitarray[(patid / 8)] |= (1<<(patid % 8));
/* append the pattern_id to the array with matches */
pmq->pattern_id_array[pmq->pattern_id_array_cnt] = patid;
pmq->pattern_id_array_cnt++;
SCLogDebug("pattern_id_array_cnt %u", pmq->pattern_id_array_cnt);
+
+ SCLogDebug("Adding %u sids", sids_size);
+ // Add SIDs for this pattern
+ uint32_t x;
+ for (x = 0; x < sids_size; x++) {
+ pmq->rule_id_array[pmq->rule_id_array_cnt++] = sids[x];
+ }
+
}
}
MpmWuManberRegister();
MpmB2gRegister();
MpmB3gRegister();
- MpmB2gcRegister();
- MpmB2gmRegister();
MpmACRegister();
MpmACBSRegister();
MpmACGfbsRegister();
void MpmTableSetup(void);
void MpmRegisterTests(void);
-int MpmVerifyMatch(MpmThreadCtx *, PatternMatcherQueue *, uint32_t);
+int MpmVerifyMatch(MpmThreadCtx *, PatternMatcherQueue *, uint32_t,
+ uint8_t *bitarray, uint32_t *sids, uint32_t sid_size);
void MpmInitCtx(MpmCtx *mpm_ctx, uint16_t matcher);
void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t, uint32_t);
uint32_t MpmGetHashSize(const char *);