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)
491 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
492 int32_t temp_state = ctx->
goto_table[0][ascii_code];
493 if (temp_state != 0) {
494 SCACEnqueue(q, temp_state);
499 while (!SCACStateQueueIsEmpty(q)) {
501 r_state = SCACDequeue(q);
502 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
503 int32_t temp_state = ctx->
goto_table[r_state][ascii_code];
506 SCACEnqueue(q, temp_state);
512 SCACClubOutputStates(temp_state, ctx->
failure_table[temp_state],
527 static inline void SCACCreateDeltaTable(
MpmCtx *mpm_ctx)
533 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);
572 if (!(ctx->
state_count < 32767) || construct_both_16_and_32_state_tables) {
588 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
592 SCACEnqueue(q, temp_state);
595 while (!SCACStateQueueIsEmpty(q)) {
596 r_state = SCACDequeue(q);
598 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
599 int32_t temp_state = ctx->
goto_table[r_state][ascii_code];
601 SCACEnqueue(q, temp_state);
615 static inline void SCACClubOutputStatePresenceWithDeltaTable(
MpmCtx *mpm_ctx)
620 uint32_t temp_state = 0;
622 if ((ctx->
state_count < 32767) || construct_both_16_and_32_state_tables) {
623 for (state = 0; state < ctx->
state_count; state++) {
624 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
632 if (!(ctx->
state_count < 32767) || construct_both_16_and_32_state_tables) {
633 for (state = 0; state < ctx->
state_count; state++) {
634 for (ascii_code = 0; ascii_code < 256; ascii_code++) {
645 static inline void SCACInsertCaseSensitiveEntriesForPatterns(
MpmCtx *mpm_ctx)
651 for (state = 0; state < ctx->
state_count; state++) {
667 static void SCACPrintDeltaTable(
MpmCtx *mpm_ctx)
672 printf(
"##############Delta Table##############\n");
675 for (j = 0; j < 256; j++) {
676 if (SCACGetDelta(i, j, mpm_ctx) != 0) {
677 printf(
" %c -> %d\n", j, SCACGetDelta(i, j, mpm_ctx));
691 static void SCACPrepareStateTable(
MpmCtx *mpm_ctx)
696 SCACInitNewState(mpm_ctx);
698 SCACDetermineLevel1Gap(mpm_ctx);
701 SCACCreateGotoTable(mpm_ctx);
703 SCACCreateFailureTable(mpm_ctx);
705 SCACCreateDeltaTable(mpm_ctx);
707 SCACClubOutputStatePresenceWithDeltaTable(mpm_ctx);
710 SCACInsertCaseSensitiveEntriesForPatterns(mpm_ctx);
713 SCACShrinkState(ctx);
716 SCACPrintDeltaTable(mpm_ctx);
738 SCLogDebug(
"no patterns supplied to this mpm_ctx");
752 uint32_t i = 0, p = 0;
755 while(node != NULL) {
800 SCACPrepareStateTable(mpm_ctx);
804 if (ctx->
parray[i] != NULL) {
834 if (mpm_thread_ctx->
ctx == NULL) {
851 if (mpm_ctx->
ctx != NULL)
855 if (mpm_ctx->
ctx == NULL) {
887 if (mpm_thread_ctx->
ctx != NULL) {
889 mpm_thread_ctx->
ctx = NULL;
915 if (ctx->
parray != NULL) {
918 if (ctx->
parray[i] != NULL) {
947 uint32_t state_count;
948 for (state_count = 0; state_count < ctx->
state_count; state_count++) {
958 for (i = 0; i < (mpm_ctx->
max_pat_id + 1); i++) {
1004 for (i = 0; i < buflen; i++) {
1005 state = state_table_u16[state & 0x7FFF][
u8_tolower(buf[i])];
1006 if (state & 0x8000) {
1010 for (k = 0; k < no_of_entries; k++) {
1024 if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
1027 bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
1038 if (bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
1041 bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
1055 for (i = 0; i < buflen; i++) {
1056 state = state_table_u32[state & 0x00FFFFFF][
u8_tolower(buf[i])];
1057 if (state & 0xFF000000) {
1061 for (k = 0; k < no_of_entries; k++) {
1063 uint32_t lower_pid = pids[k] & 0x0000FFFF;
1075 if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
1078 bitarray[(lower_pid) / 8] |= (1 << ((lower_pid) % 8));
1089 if (bitarray[pids[k] / 8] & (1 << (pids[k] % 8))) {
1092 bitarray[pids[k] / 8] |= (1 << (pids[k] % 8));
1125 uint16_t
offset, uint16_t depth, uint32_t pid,
1150 uint16_t
offset, uint16_t depth, uint32_t pid,
1159 #ifdef SC_AC_COUNTERS
1161 printf(
"AC Thread Search stats (ctx %p)\n", ctx);
1162 printf(
"Total calls: %" PRIu32
"\n", ctx->
total_calls);
1173 printf(
"MPM AC Information:\n");
1174 printf(
"Memory allocs: %" PRIu32
"\n", mpm_ctx->
memory_cnt);
1175 printf(
"Memory alloced: %" PRIu32
"\n", mpm_ctx->
memory_size);
1176 printf(
" Sizeof:\n");
1177 printf(
" MpmCtx %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmCtx));
1178 printf(
" SCACCtx: %" PRIuMAX
"\n", (uintmax_t)
sizeof(
SCACCtx));
1179 printf(
" MpmPattern %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmPattern));
1180 printf(
" MpmPattern %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmPattern));
1181 printf(
"Unique Patterns: %" PRIu32
"\n", mpm_ctx->
pattern_cnt);
1182 printf(
"Smallest: %" PRIu32
"\n", mpm_ctx->
minlen);
1183 printf(
"Largest: %" PRIu32
"\n", mpm_ctx->
maxlen);
1184 printf(
"Total states in the state table: %" PRIu32
"\n", ctx->
state_count);
1219 static int SCACTest01(
void)
1226 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1237 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1239 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1240 (uint8_t *)buf, strlen(buf));
1245 printf(
"1 != %" PRIu32
" ",cnt);
1253 static int SCACTest02(
void)
1260 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1271 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1272 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1273 (uint8_t *)buf, strlen(buf));
1278 printf(
"0 != %" PRIu32
" ",cnt);
1286 static int SCACTest03(
void)
1293 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1308 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1309 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1310 (uint8_t *)buf, strlen(buf));
1315 printf(
"3 != %" PRIu32
" ",cnt);
1323 static int SCACTest04(
void)
1330 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1342 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1343 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1344 (uint8_t *)buf, strlen(buf));
1349 printf(
"1 != %" PRIu32
" ",cnt);
1357 static int SCACTest05(
void)
1364 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1376 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1377 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1378 (uint8_t *)buf, strlen(buf));
1383 printf(
"3 != %" PRIu32
" ",cnt);
1391 static int SCACTest06(
void)
1398 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1408 const char *buf =
"abcd";
1409 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1410 (uint8_t *)buf, strlen(buf));
1415 printf(
"1 != %" PRIu32
" ",cnt);
1423 static int SCACTest07(
void)
1430 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1444 MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"AAAAAAAAAA", 10, 0, 0, 4, 0, 0);
1446 MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
1453 const char *buf =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1454 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1455 (uint8_t *)buf, strlen(buf));
1460 printf(
"135 != %" PRIu32
" ",cnt);
1468 static int SCACTest08(
void)
1475 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1486 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1492 printf(
"0 != %" PRIu32
" ",cnt);
1500 static int SCACTest09(
void)
1507 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1518 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1519 (uint8_t *)
"ab", 2);
1524 printf(
"1 != %" PRIu32
" ",cnt);
1532 static int SCACTest10(
void)
1539 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1550 const char *buf =
"01234567890123456789012345678901234567890123456789"
1551 "01234567890123456789012345678901234567890123456789"
1553 "01234567890123456789012345678901234567890123456789"
1554 "01234567890123456789012345678901234567890123456789";
1555 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1556 (uint8_t *)buf, strlen(buf));
1561 printf(
"1 != %" PRIu32
" ",cnt);
1569 static int SCACTest11(
void)
1576 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1581 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"he", 2, 0, 0, 1, 0, 0) == -1)
1583 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"she", 3, 0, 0, 2, 0, 0) == -1)
1585 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"his", 3, 0, 0, 3, 0, 0) == -1)
1587 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"hers", 4, 0, 0, 4, 0, 0) == -1)
1596 const char *buf =
"he";
1597 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1600 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1603 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1606 result &= (
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf,
1616 static int SCACTest12(
void)
1623 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1636 const char *buf =
"abcdefghijklmnopqrstuvwxyz";
1637 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1638 (uint8_t *)buf, strlen(buf));
1643 printf(
"2 != %" PRIu32
" ",cnt);
1651 static int SCACTest13(
void)
1658 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1664 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCD";
1665 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1670 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCD";
1671 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1672 (uint8_t *)buf, strlen(buf));
1677 printf(
"1 != %" PRIu32
" ",cnt);
1685 static int SCACTest14(
void)
1692 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1698 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCDE";
1699 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1704 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCDE";
1705 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1706 (uint8_t *)buf, strlen(buf));
1711 printf(
"1 != %" PRIu32
" ",cnt);
1719 static int SCACTest15(
void)
1726 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1732 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCDEF";
1733 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1738 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCDEF";
1739 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1740 (uint8_t *)buf, strlen(buf));
1745 printf(
"1 != %" PRIu32
" ",cnt);
1753 static int SCACTest16(
void)
1760 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1766 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABC";
1767 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1772 const char *buf =
"abcdefghijklmnopqrstuvwxyzABC";
1773 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1774 (uint8_t *)buf, strlen(buf));
1779 printf(
"1 != %" PRIu32
" ",cnt);
1787 static int SCACTest17(
void)
1794 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1800 const char pat[] =
"abcdefghijklmnopqrstuvwxyzAB";
1801 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1806 const char *buf =
"abcdefghijklmnopqrstuvwxyzAB";
1807 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1808 (uint8_t *)buf, strlen(buf));
1813 printf(
"1 != %" PRIu32
" ",cnt);
1821 static int SCACTest18(
void)
1828 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1834 const char pat[] =
"abcde"
1840 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1845 const char *buf =
"abcde""fghij""klmno""pqrst""uvwxy""z";
1846 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1847 (uint8_t *)buf, strlen(buf));
1852 printf(
"1 != %" PRIu32
" ",cnt);
1860 static int SCACTest19(
void)
1867 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1873 const char pat[] =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1874 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1879 const char *buf =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1880 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1881 (uint8_t *)buf, strlen(buf));
1886 printf(
"1 != %" PRIu32
" ",cnt);
1894 static int SCACTest20(
void)
1901 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1907 const char pat[] =
"AAAAA"
1914 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1919 const char *buf =
"AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
1920 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1921 (uint8_t *)buf, strlen(buf));
1926 printf(
"1 != %" PRIu32
" ",cnt);
1934 static int SCACTest21(
void)
1941 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1952 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1953 (uint8_t *)
"AA", 2);
1958 printf(
"1 != %" PRIu32
" ",cnt);
1966 static int SCACTest22(
void)
1973 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1986 const char *buf =
"abcdefghijklmnopqrstuvwxyz";
1987 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
1988 (uint8_t *)buf, strlen(buf));
1993 printf(
"2 != %" PRIu32
" ",cnt);
2001 static int SCACTest23(
void)
2008 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2019 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2020 (uint8_t *)
"aa", 2);
2025 printf(
"1 != %" PRIu32
" ",cnt);
2033 static int SCACTest24(
void)
2040 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2051 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2052 (uint8_t *)
"aa", 2);
2057 printf(
"1 != %" PRIu32
" ",cnt);
2065 static int SCACTest25(
void)
2072 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2084 const char *buf =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
2085 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2086 (uint8_t *)buf, strlen(buf));
2091 printf(
"3 != %" PRIu32
" ",cnt);
2099 static int SCACTest26(
void)
2106 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2117 const char *buf =
"works";
2118 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2119 (uint8_t *)buf, strlen(buf));
2124 printf(
"3 != %" PRIu32
" ",cnt);
2132 static int SCACTest27(
void)
2139 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
2150 const char *buf =
"tone";
2151 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2152 (uint8_t *)buf, strlen(buf));
2157 printf(
"0 != %" PRIu32
" ",cnt);
2165 static int SCACTest28(
void)
2172 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
2183 const char *buf =
"tONE";
2184 uint32_t cnt =
SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq,
2185 (uint8_t *)buf, strlen(buf));
2190 printf(
"0 != %" PRIu32
" ",cnt);
2198 static int SCACTest29(
void)
2200 uint8_t buf[] =
"onetwothreefourfivesixseveneightnine";
2201 uint16_t buflen =
sizeof(buf) - 1;
2207 memset(&th_v, 0,
sizeof(th_v));
2217 "(content:\"onetwothreefourfivesixseveneightnine\"; sid:1;)");
2221 "(content:\"onetwothreefourfivesixseveneightnine\"; fast_pattern:3,3; sid:2;)");
2230 printf(
"if (PacketAlertCheck(p, 1) != 1) failure\n");
2234 printf(
"if (PacketAlertCheck(p, 1) != 2) failure\n");