81 #define SC_AC_FAIL (-1)
83 #define STATE_QUEUE_CONTAINER_SIZE 65536
85 #define AC_CASE_MASK 0x80000000
86 #define AC_PID_MASK 0x7FFFFFFF
87 #define AC_CASE_BIT 31
89 static int construct_both_16_and_32_state_tables = 0;
106 static void SCACGetConfig(
void)
126 static inline size_t SCACCheckSafeSizetMult(
size_t a,
size_t b)
129 if (b > 0 && a > SIZE_MAX / b) {
130 SCLogError(
"%" PRIuMAX
" * %" PRIuMAX
" > %" PRIuMAX
131 " would overflow size_t calculating buffer size",
132 (uintmax_t)a, (uintmax_t)b, (uintmax_t)SIZE_MAX);
146 static inline int SCACReallocState(
SCACCtx *ctx, uint32_t cnt)
163 size_t oldsize = SCACCheckSafeSizetMult((
size_t) ctx->
state_count,
166 SCLogDebug(
"oldsize %"PRIuMAX
" size %"PRIuMAX
" cnt %d ctx->state_count %u",
167 (uintmax_t) oldsize, (uintmax_t) size, cnt, ctx->
state_count);
179 memset(((uint8_t *)ctx->
output_table + oldsize), 0, (size - oldsize));
196 static void SCACShrinkState(
SCACCtx *ctx)
204 SCLogDebug(
"oldsize %d newsize %d ctx->allocated_state_count %u "
205 "ctx->state_count %u: shrink by %d bytes", oldsize,
218 static inline int SCACInitNewState(
MpmCtx *mpm_ctx)
240 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
255 static void SCACSetOutputState(int32_t state, uint32_t pid,
MpmCtx *mpm_ctx)
262 for (i = 0; i < output_state->no_of_entries; i++) {
263 if (output_state->pids[i] == pid)
269 output_state->no_of_entries *
sizeof(uint32_t));
271 SCFree(output_state->pids);
272 output_state->pids = NULL;
275 output_state->pids = ptmp;
277 output_state->pids[output_state->no_of_entries - 1] = pid;
292 static inline void SCACEnter(uint8_t *pattern, uint16_t pattern_len, uint32_t pid,
297 int32_t newstate = 0;
303 for (i = 0; i < pattern_len; i++) {
313 for (p = i; p < pattern_len; p++) {
314 newstate = SCACInitNewState(mpm_ctx);
315 ctx->
goto_table[state][pattern[p]] = newstate;
321 SCACSetOutputState(state, pid, mpm_ctx);
332 static inline void SCACCreateGotoTable(
MpmCtx *mpm_ctx)
344 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
353 static inline void SCACDetermineLevel1Gap(
MpmCtx *mpm_ctx)
359 memset(map, 0,
sizeof(map));
364 for (u = 0; u < 256; u++) {
367 int32_t newstate = SCACInitNewState(mpm_ctx);
374 static inline int SCACStateQueueIsEmpty(
StateQueue *q)
382 static inline void SCACEnqueue(
StateQueue *q, int32_t state)
387 for (i = q->
bot; i < q->top; i++) {
388 if (q->
store[i] == state)
398 FatalError(
"Just ran out of space in the queue. Please file a bug report on this");
404 static inline int32_t SCACDequeue(
StateQueue *q)
410 FatalError(
"StateQueue behaving weirdly. Please file a bug report on this");
425 static inline void SCACClubOutputStates(int32_t dst_state, int32_t src_state,
436 for (i = 0; i < output_src_state->no_of_entries; i++) {
437 for (j = 0; j < output_dst_state->no_of_entries; j++) {
438 if (output_src_state->pids[i] == output_dst_state->pids[j]) {
442 if (j == output_dst_state->no_of_entries) {
446 (output_dst_state->no_of_entries *
sizeof(uint32_t)));
448 SCFree(output_dst_state->pids);
449 output_dst_state->pids = NULL;
452 output_dst_state->pids = ptmp;
454 output_dst_state->pids[output_dst_state->no_of_entries - 1] =
455 output_src_state->pids[i];
468 static inline void SCACCreateFailureTable(
MpmCtx *mpm_ctx)
489 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
490 int32_t temp_state = ctx->
goto_table[0][ascii_code];
491 if (temp_state != 0) {
492 SCACEnqueue(&q, temp_state);
497 while (!SCACStateQueueIsEmpty(&q)) {
499 r_state = SCACDequeue(&q);
500 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
501 int32_t temp_state = ctx->
goto_table[r_state][ascii_code];
504 SCACEnqueue(&q, temp_state);
510 SCACClubOutputStates(temp_state, ctx->
failure_table[temp_state],
524 static inline void SCACCreateDeltaTable(
MpmCtx *mpm_ctx)
530 if ((ctx->
state_count < 32767) || construct_both_16_and_32_state_tables) {
546 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
551 SCACEnqueue(&q, temp_state);
554 while (!SCACStateQueueIsEmpty(&q)) {
555 r_state = SCACDequeue(&q);
557 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
558 int32_t temp_state = ctx->
goto_table[r_state][ascii_code];
560 SCACEnqueue(&q, temp_state);
571 if (!(ctx->
state_count < 32767) || construct_both_16_and_32_state_tables) {
590 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
594 SCACEnqueue(&q, temp_state);
597 while (!SCACStateQueueIsEmpty(&q)) {
598 r_state = SCACDequeue(&q);
600 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
601 int32_t temp_state = ctx->
goto_table[r_state][ascii_code];
603 SCACEnqueue(&q, temp_state);
616 static inline void SCACClubOutputStatePresenceWithDeltaTable(
MpmCtx *mpm_ctx)
621 uint32_t temp_state = 0;
623 if ((ctx->
state_count < 32767) || construct_both_16_and_32_state_tables) {
624 for (state = 0; state < ctx->
state_count; state++) {
625 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
633 if (!(ctx->
state_count < 32767) || construct_both_16_and_32_state_tables) {
634 for (state = 0; state < ctx->
state_count; state++) {
635 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
646 static inline void SCACInsertCaseSensitiveEntriesForPatterns(
MpmCtx *mpm_ctx)
652 for (state = 0; state < ctx->
state_count; state++) {
668 static void SCACPrintDeltaTable(
MpmCtx *mpm_ctx)
673 printf(
"##############Delta Table##############\n");
676 for (j = 0; j < 256; j++) {
677 if (SCACGetDelta(i, j, mpm_ctx) != 0) {
678 printf(
" %c -> %d\n", j, SCACGetDelta(i, j, mpm_ctx));
692 static void SCACPrepareStateTable(
MpmCtx *mpm_ctx)
697 SCACInitNewState(mpm_ctx);
699 SCACDetermineLevel1Gap(mpm_ctx);
702 SCACCreateGotoTable(mpm_ctx);
704 SCACCreateFailureTable(mpm_ctx);
706 SCACCreateDeltaTable(mpm_ctx);
708 SCACClubOutputStatePresenceWithDeltaTable(mpm_ctx);
711 SCACInsertCaseSensitiveEntriesForPatterns(mpm_ctx);
714 SCACShrinkState(ctx);
717 SCACPrintDeltaTable(mpm_ctx);
739 SCLogDebug(
"no patterns supplied to this mpm_ctx");
753 uint32_t i = 0, p = 0;
756 while(node != NULL) {
801 SCACPrepareStateTable(mpm_ctx);
805 if (ctx->
parray[i] != NULL) {
835 if (mpm_thread_ctx->
ctx == NULL) {
852 if (mpm_ctx->
ctx != NULL)
856 if (mpm_ctx->
ctx == NULL) {
888 if (mpm_thread_ctx->
ctx != NULL) {
890 mpm_thread_ctx->
ctx = NULL;
916 if (ctx->
parray != NULL) {
919 if (ctx->
parray[i] != NULL) {
948 uint32_t state_count;
949 for (state_count = 0; state_count < ctx->
state_count; state_count++) {
959 for (i = 0; i < (mpm_ctx->
max_pat_id + 1); i++) {
1005 for (i = 0; i < buflen; i++) {
1006 state = state_table_u16[state & 0x7FFF][
u8_tolower(buf[i])];
1007 if (state & 0x8000) {
1011 for (k = 0; k < no_of_entries; k++) {
1025 if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
1028 bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
1039 if (bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
1042 bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
1056 for (i = 0; i < buflen; i++) {
1057 state = state_table_u32[state & 0x00FFFFFF][
u8_tolower(buf[i])];
1058 if (state & 0xFF000000) {
1062 for (k = 0; k < no_of_entries; k++) {
1064 uint32_t lower_pid = pids[k] & 0x0000FFFF;
1076 if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
1079 bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
1090 if (bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
1093 bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
1126 uint16_t
offset, uint16_t depth, uint32_t pid,
1151 uint16_t
offset, uint16_t depth, uint32_t pid,
1160 #ifdef SC_AC_COUNTERS
1162 printf(
"AC Thread Search stats (ctx %p)\n", ctx);
1163 printf(
"Total calls: %" PRIu32
"\n", ctx->
total_calls);
1174 printf(
"MPM AC Information:\n");
1175 printf(
"Memory allocs: %" PRIu32
"\n", mpm_ctx->
memory_cnt);
1176 printf(
"Memory alloced: %" PRIu32
"\n", mpm_ctx->
memory_size);
1177 printf(
" Sizeof:\n");
1178 printf(
" MpmCtx %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmCtx));
1179 printf(
" SCACCtx: %" PRIuMAX
"\n", (uintmax_t)
sizeof(
SCACCtx));
1180 printf(
" MpmPattern %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmPattern));
1181 printf(
" MpmPattern %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmPattern));
1182 printf(
"Unique Patterns: %" PRIu32
"\n", mpm_ctx->
pattern_cnt);
1183 printf(
"Smallest: %" PRIu32
"\n", mpm_ctx->
minlen);
1184 printf(
"Largest: %" PRIu32
"\n", mpm_ctx->
maxlen);
1185 printf(
"Total states in the state table: %" PRIu32
"\n", ctx->
state_count);
1220 static int SCACTest01(
void)
1227 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1238 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1240 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1241 (uint8_t *)buf, strlen(buf));
1246 printf(
"1 != %" PRIu32
" ",cnt);
1254 static int SCACTest02(
void)
1261 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1272 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1273 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1274 (uint8_t *)buf, strlen(buf));
1279 printf(
"0 != %" PRIu32
" ",cnt);
1287 static int SCACTest03(
void)
1294 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1309 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1310 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1311 (uint8_t *)buf, strlen(buf));
1316 printf(
"3 != %" PRIu32
" ",cnt);
1324 static int SCACTest04(
void)
1331 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1343 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1344 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1345 (uint8_t *)buf, strlen(buf));
1350 printf(
"1 != %" PRIu32
" ",cnt);
1358 static int SCACTest05(
void)
1365 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1377 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1378 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1379 (uint8_t *)buf, strlen(buf));
1384 printf(
"3 != %" PRIu32
" ",cnt);
1392 static int SCACTest06(
void)
1399 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1409 const char *buf =
"abcd";
1410 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1411 (uint8_t *)buf, strlen(buf));
1416 printf(
"1 != %" PRIu32
" ",cnt);
1424 static int SCACTest07(
void)
1431 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1445 MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"AAAAAAAAAA", 10, 0, 0, 4, 0, 0);
1447 MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
1454 const char *buf =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1455 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1456 (uint8_t *)buf, strlen(buf));
1461 printf(
"135 != %" PRIu32
" ",cnt);
1469 static int SCACTest08(
void)
1476 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1487 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1493 printf(
"0 != %" PRIu32
" ",cnt);
1501 static int SCACTest09(
void)
1508 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1519 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1520 (uint8_t *)
"ab", 2);
1525 printf(
"1 != %" PRIu32
" ",cnt);
1533 static int SCACTest10(
void)
1540 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1551 const char *buf =
"01234567890123456789012345678901234567890123456789"
1552 "01234567890123456789012345678901234567890123456789"
1554 "01234567890123456789012345678901234567890123456789"
1555 "01234567890123456789012345678901234567890123456789";
1556 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1557 (uint8_t *)buf, strlen(buf));
1562 printf(
"1 != %" PRIu32
" ",cnt);
1570 static int SCACTest11(
void)
1577 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1582 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"he", 2, 0, 0, 1, 0, 0) == -1)
1584 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"she", 3, 0, 0, 2, 0, 0) == -1)
1586 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"his", 3, 0, 0, 3, 0, 0) == -1)
1588 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"hers", 4, 0, 0, 4, 0, 0) == -1)
1597 const char *buf =
"he";
1598 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1601 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1604 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1607 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1617 static int SCACTest12(
void)
1624 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1637 const char *buf =
"abcdefghijklmnopqrstuvwxyz";
1638 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1639 (uint8_t *)buf, strlen(buf));
1644 printf(
"2 != %" PRIu32
" ",cnt);
1652 static int SCACTest13(
void)
1659 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1665 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCD";
1666 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1671 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCD";
1672 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1673 (uint8_t *)buf, strlen(buf));
1678 printf(
"1 != %" PRIu32
" ",cnt);
1686 static int SCACTest14(
void)
1693 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1699 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCDE";
1700 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1705 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCDE";
1706 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1707 (uint8_t *)buf, strlen(buf));
1712 printf(
"1 != %" PRIu32
" ",cnt);
1720 static int SCACTest15(
void)
1727 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1733 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCDEF";
1734 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1739 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCDEF";
1740 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1741 (uint8_t *)buf, strlen(buf));
1746 printf(
"1 != %" PRIu32
" ",cnt);
1754 static int SCACTest16(
void)
1761 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1767 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABC";
1768 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1773 const char *buf =
"abcdefghijklmnopqrstuvwxyzABC";
1774 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1775 (uint8_t *)buf, strlen(buf));
1780 printf(
"1 != %" PRIu32
" ",cnt);
1788 static int SCACTest17(
void)
1795 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1801 const char pat[] =
"abcdefghijklmnopqrstuvwxyzAB";
1802 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1807 const char *buf =
"abcdefghijklmnopqrstuvwxyzAB";
1808 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1809 (uint8_t *)buf, strlen(buf));
1814 printf(
"1 != %" PRIu32
" ",cnt);
1822 static int SCACTest18(
void)
1829 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1835 const char pat[] =
"abcde"
1841 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1846 const char *buf =
"abcde""fghij""klmno""pqrst""uvwxy""z";
1847 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1848 (uint8_t *)buf, strlen(buf));
1853 printf(
"1 != %" PRIu32
" ",cnt);
1861 static int SCACTest19(
void)
1868 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1874 const char pat[] =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1875 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1880 const char *buf =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1881 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1882 (uint8_t *)buf, strlen(buf));
1887 printf(
"1 != %" PRIu32
" ",cnt);
1895 static int SCACTest20(
void)
1902 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1908 const char pat[] =
"AAAAA"
1915 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1920 const char *buf =
"AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
1921 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1922 (uint8_t *)buf, strlen(buf));
1927 printf(
"1 != %" PRIu32
" ",cnt);
1935 static int SCACTest21(
void)
1942 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1953 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1954 (uint8_t *)
"AA", 2);
1959 printf(
"1 != %" PRIu32
" ",cnt);
1967 static int SCACTest22(
void)
1974 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1987 const char *buf =
"abcdefghijklmnopqrstuvwxyz";
1988 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1989 (uint8_t *)buf, strlen(buf));
1994 printf(
"2 != %" PRIu32
" ",cnt);
2002 static int SCACTest23(
void)
2009 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2020 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2021 (uint8_t *)
"aa", 2);
2026 printf(
"1 != %" PRIu32
" ",cnt);
2034 static int SCACTest24(
void)
2041 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2052 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2053 (uint8_t *)
"aa", 2);
2058 printf(
"1 != %" PRIu32
" ",cnt);
2066 static int SCACTest25(
void)
2073 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2085 const char *buf =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
2086 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2087 (uint8_t *)buf, strlen(buf));
2092 printf(
"3 != %" PRIu32
" ",cnt);
2100 static int SCACTest26(
void)
2107 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2118 const char *buf =
"works";
2119 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2120 (uint8_t *)buf, strlen(buf));
2125 printf(
"3 != %" PRIu32
" ",cnt);
2133 static int SCACTest27(
void)
2140 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
2151 const char *buf =
"tone";
2152 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2153 (uint8_t *)buf, strlen(buf));
2158 printf(
"0 != %" PRIu32
" ",cnt);
2166 static int SCACTest28(
void)
2173 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
2184 const char *buf =
"tONE";
2185 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2186 (uint8_t *)buf, strlen(buf));
2191 printf(
"0 != %" PRIu32
" ",cnt);
2199 static int SCACTest29(
void)
2201 uint8_t buf[] =
"onetwothreefourfivesixseveneightnine";
2202 uint16_t buflen =
sizeof(buf) - 1;
2208 memset(&th_v, 0,
sizeof(th_v));
2218 "(content:\"onetwothreefourfivesixseveneightnine\"; sid:1;)");
2222 "(content:\"onetwothreefourfivesixseveneightnine\"; fast_pattern:3,3; sid:2;)");
2231 printf(
"if (PacketAlertCheck(p, 1) != 1) failure\n");
2235 printf(
"if (PacketAlertCheck(p, 1) != 2) failure\n");