86 #if __BYTE_ORDER == __LITTLE_ENDIAN
91 MpmCtx *,
const uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t,
SigIntId, uint8_t);
100 static void SCACTileRegisterTests(
void);
105 const uint8_t *buf, uint32_t buflen);
108 const uint8_t *buf, uint32_t buflen);
111 const uint8_t *buf, uint32_t buflen);
114 const uint8_t *buf, uint32_t buflen);
117 const uint8_t *buf, uint32_t buflen);
120 const uint8_t *buf, uint32_t buflen);
123 const uint8_t *buf, uint32_t buflen);
127 const uint8_t *buf, uint32_t buflen);
130 const uint8_t *buf, uint32_t buflen);
133 const uint8_t *buf, uint32_t buflen);
136 const uint8_t *buf, uint32_t buflen);
139 const uint8_t *buf, uint32_t buflen);
142 const uint8_t *buf, uint32_t buflen);
145 static void SCACTileDestroyInitCtx(
MpmCtx *mpm_ctx);
149 #define SC_AC_TILE_FAIL (-1)
157 static void SCACTileGetConfig(
void)
170 for (
int i = 0; i < p->
len; i++) {
171 ctx->alpha_hist[p->
ci[i]]++;
183 for (
int i = 0; i < 256; i++) {
185 if (i >=
'A' && i <=
'Z') {
186 ctx->alpha_hist[i -
'A' +
'a'] +=
ctx->alpha_hist[i];
187 ctx->alpha_hist[i] = 0;
189 if (
ctx->alpha_hist[i]) {
190 ctx->alphabet_size++;
192 ctx->translate_table[i] = (uint8_t)
ctx->alphabet_size;
194 ctx->translate_table[i] = 0;
197 for (
int i =
'A'; i <=
'Z'; i++)
198 ctx->translate_table[i] =
ctx->translate_table[i -
'A' +
'a'];
205 ctx->alphabet_size += 1;
206 if (
ctx->alphabet_size <= 8) {
207 ctx->alphabet_storage = 8;
208 }
else if (
ctx->alphabet_size <= 16) {
209 ctx->alphabet_storage = 16;
210 }
else if (
ctx->alphabet_size <= 32) {
211 ctx->alphabet_storage = 32;
212 }
else if (
ctx->alphabet_size <= 64) {
213 ctx->alphabet_storage = 64;
214 }
else if (
ctx->alphabet_size <= 128) {
215 ctx->alphabet_storage = 128;
217 ctx->alphabet_storage = 256;
220 static void SCACTileReallocOutputTable(
SCACTileCtx *
ctx,
int new_state_count)
228 ctx->output_table = NULL;
231 ctx->output_table = ptmp;
234 static void SCACTileReallocState(
SCACTileCtx *
ctx,
int new_state_count)
237 size_t size =
ctx->allocated_state_count *
sizeof(int32_t) * 256;
241 ctx->goto_table = NULL;
244 ctx->goto_table = ptmp;
246 SCACTileReallocOutputTable(
ctx, new_state_count);
257 static inline int SCACTileInitNewState(
MpmCtx *mpm_ctx)
264 if (
ctx->allocated_state_count <
ctx->state_count + 1) {
265 if (
ctx->allocated_state_count == 0)
266 ctx->allocated_state_count = 256;
268 ctx->allocated_state_count *= 2;
270 SCACTileReallocState(
ctx,
ctx->allocated_state_count);
274 for (aa = 0; aa <
ctx->alphabet_size; aa++) {
278 memset(
ctx->output_table +
ctx->state_count, 0,
281 return ctx->state_count++;
302 for (i = 0; i < output_state->no_of_entries; i++) {
303 if (output_state->patterns[i] == pindex)
309 output_state->no_of_entries++;
313 SCFree(output_state->patterns);
314 output_state->patterns = NULL;
317 output_state->patterns = ptmp;
319 output_state->patterns[output_state->no_of_entries - 1] = pindex;
332 static void SCACTileEnter(uint8_t *pattern, uint16_t pattern_len,
339 int32_t newstate = 0;
346 for (i = 0; i < pattern_len; i++) {
347 tc =
ctx->translate_table[pattern[i]];
350 state =
ctx->goto_table[state][tc];
355 for (p = i; p < pattern_len; p++) {
356 newstate = SCACTileInitNewState(mpm_ctx);
357 tc =
ctx->translate_table[pattern[p]];
358 ctx->goto_table[state][tc] = newstate;
364 SCACTileSetOutputState(state, pindex, mpm_ctx);
373 static void SCACTileCreateGotoTable(
MpmCtx *mpm_ctx)
382 SCACTileEnter(
ctx->parray[i]->ci,
ctx->parray[i]->len,
387 for (aa = 0; aa <
ctx->alphabet_size; aa++) {
389 ctx->goto_table[0][aa] = 0;
403 static void SCACTileClubOutputStates(int32_t dst_state,
417 for (i = 0; i < output_src_state->no_of_entries; i++) {
418 for (j = 0; j < output_dst_state->no_of_entries; j++) {
419 if (output_src_state->patterns[i] == output_dst_state->patterns[j]) {
423 if (j == output_dst_state->no_of_entries) {
424 output_dst_state->no_of_entries++;
426 ptmp =
SCRealloc(output_dst_state->patterns,
427 (output_dst_state->no_of_entries *
sizeof(uint32_t)));
429 SCFree(output_dst_state->patterns);
430 output_dst_state->patterns = NULL;
433 output_dst_state->patterns = ptmp;
435 output_dst_state->patterns[output_dst_state->no_of_entries - 1] =
436 output_src_state->patterns[i];
447 static void SCACTileCreateFailureTable(
MpmCtx *mpm_ctx)
461 if (
ctx->failure_table == NULL) {
468 for (aa = 0; aa <
ctx->alphabet_size; aa++) {
469 int32_t temp_state =
ctx->goto_table[0][aa];
470 if (temp_state != 0) {
471 SCACEnqueue(q, temp_state);
472 ctx->failure_table[temp_state] = 0;
476 while (!SCACStateQueueIsEmpty(q)) {
478 r_state = SCACDequeue(q);
479 for (aa = 0; aa <
ctx->alphabet_size; aa++) {
480 int32_t temp_state =
ctx->goto_table[r_state][aa];
483 SCACEnqueue(q, temp_state);
484 state =
ctx->failure_table[r_state];
487 state =
ctx->failure_table[state];
488 ctx->failure_table[temp_state] =
ctx->goto_table[state][aa];
489 SCACTileClubOutputStates(temp_state,
ctx->failure_table[temp_state],
499 static void SCACTileSetState1Byte(
SCACTileCtx *
ctx,
int state,
int aa,
500 int next_state,
int outputs)
502 uint8_t *state_table = (uint8_t*)
ctx->state_table;
504 uint8_t encoded_next_state = (uint8_t)next_state;
511 encoded_next_state |= (1 << 7);
513 state_table[state *
ctx->alphabet_storage + aa] = encoded_next_state;
519 static void SCACTileSetState2Bytes(
SCACTileCtx *
ctx,
int state,
int aa,
520 int next_state,
int outputs)
522 uint16_t *state_table = (uint16_t*)
ctx->state_table;
524 uint16_t encoded_next_state = (uint16_t)next_state;
531 encoded_next_state |= (1 << 15);
533 state_table[state *
ctx->alphabet_storage + aa] = encoded_next_state;
539 static void SCACTileSetState4Bytes(
SCACTileCtx *
ctx,
int state,
int aa,
540 int next_state,
int outputs)
542 uint32_t *state_table = (uint32_t*)
ctx->state_table;
543 uint32_t encoded_next_state = next_state;
550 encoded_next_state |= (1UL << 31);
552 state_table[state *
ctx->alphabet_storage + aa] = encoded_next_state;
561 static inline void SCACTileCreateDeltaTable(
MpmCtx *mpm_ctx)
569 if (
ctx->state_count < 32767) {
570 if (
ctx->state_count < 128) {
571 ctx->bytes_per_state = 1;
572 ctx->SetNextState = SCACTileSetState1Byte;
574 switch(
ctx->alphabet_storage) {
595 ctx->bytes_per_state = 2;
596 ctx->SetNextState = SCACTileSetState2Bytes;
598 switch(
ctx->alphabet_storage) {
621 ctx->bytes_per_state = 4;
622 ctx->SetNextState = SCACTileSetState4Bytes;
624 ctx->alphabet_storage = 256;
629 for (aa = 0; aa <
ctx->alphabet_size; aa++) {
630 int temp_state =
ctx->goto_table[0][aa];
632 SCACEnqueue(q, temp_state);
635 while (!SCACStateQueueIsEmpty(q)) {
636 r_state = SCACDequeue(q);
638 for (aa = 0; aa <
ctx->alphabet_size; aa++) {
639 int temp_state =
ctx->goto_table[r_state][aa];
641 SCACEnqueue(q, temp_state);
643 int f_state =
ctx->failure_table[r_state];
644 ctx->goto_table[r_state][aa] =
ctx->goto_table[f_state][aa];
651 static void SCACTileClubOutputStatePresenceWithDeltaTable(
MpmCtx *mpm_ctx)
660 int size =
ctx->state_count *
ctx->bytes_per_state *
ctx->alphabet_storage;
661 void *state_table =
SCCalloc(1, size);
662 if (
unlikely(state_table == NULL)) {
665 ctx->state_table = state_table;
670 SCLogDebug(
"Delta Table size %d, alphabet: %d, %d-byte states: %d",
671 size,
ctx->alphabet_size,
ctx->bytes_per_state,
ctx->state_count);
677 for (state = 0; state <
ctx->state_count; state++) {
678 for (aa = 0; aa <
ctx->alphabet_size; aa++) {
679 int next_state =
ctx->goto_table[state][aa];
680 int next_state_outputs =
ctx->output_table[next_state].no_of_entries;
681 ctx->SetNextState(
ctx, state, aa, next_state, next_state_outputs);
686 static inline void SCACTileInsertCaseSensitiveEntriesForPatterns(
MpmCtx *mpm_ctx)
694 for (state = 0; state <
ctx->state_count; state++) {
695 if (
ctx->output_table[state].no_of_entries == 0)
698 for (k = 0; k <
ctx->output_table[state].no_of_entries; k++) {
699 if (
ctx->pattern_list[
ctx->output_table[state].patterns[k]].cs != NULL) {
701 ctx->output_table[state].patterns[k] &= 0x0FFFFFFF;
702 ctx->output_table[state].patterns[k] |= (uint32_t)1 << 31;
709 static void SCACTilePrintDeltaTable(
MpmCtx *mpm_ctx)
716 printf(
"##############Delta Table##############\n");
717 for (i = 0; i <
ctx->state_count; i++) {
719 for (j = 0; j <
ctx->alphabet_size; j++) {
720 if (SCACTileGetDelta(i, j, mpm_ctx) != 0) {
721 printf(
" %c -> %d\n", j, SCACTileGetDelta(i, j, mpm_ctx));
733 static void SCACTilePrepareStateTable(
MpmCtx *mpm_ctx)
739 SCACTileInitTranslateTable(
ctx);
742 SCACTileInitNewState(mpm_ctx);
745 SCACTileCreateGotoTable(mpm_ctx);
747 SCACTileCreateFailureTable(mpm_ctx);
749 SCACTileCreateDeltaTable(mpm_ctx);
751 SCACTileClubOutputStatePresenceWithDeltaTable(mpm_ctx);
754 SCACTileInsertCaseSensitiveEntriesForPatterns(mpm_ctx);
757 SCACTilePrintDeltaTable(mpm_ctx);
762 ctx->goto_table = NULL;
764 ctx->failure_table = NULL;
775 static void SCACTilePrepareSearch(
MpmCtx *mpm_ctx)
781 SCACTileReallocOutputTable(
ctx,
ctx->state_count);
788 ctx->state_table = NULL;
793 ctx->output_table = NULL;
797 ctx->pattern_list = NULL;
804 SCACTileDestroyInitCtx(mpm_ctx);
818 SCLogDebug(
"no patterns supplied to this mpm_ctx");
823 SCLogDebug(
"no patterns supplied to this mpm_ctx");
829 if (
ctx->parray == NULL)
833 uint32_t i = 0, p = 0;
836 while(node != NULL) {
839 ctx->parray[p++] = node;
840 SCACTileHistogramAlphabet(
ctx, node);
854 size_t string_space_needed = 0;
858 uint32_t space = ((
ctx->parray[i]->len + 7) / 8) * 8;
859 string_space_needed += space;
864 size_t mem_size = string_space_needed + pattern_list_size;
865 void *mem_block =
SCCalloc(1, mem_size);
866 if (mem_block == NULL) {
872 ctx->pattern_list = mem_block;
873 uint8_t *string_space = mem_block + pattern_list_size;
878 uint16_t
len =
ctx->parray[i]->len;
879 uint32_t space = ((
len + 7) / 8) * 8;
880 memcpy(string_space,
ctx->parray[i]->original_pat,
len);
881 ctx->pattern_list[i].cs = string_space;
882 ctx->pattern_list[i].patlen =
len;
883 string_space += space;
885 ctx->pattern_list[i].offset =
ctx->parray[i]->offset;
886 ctx->pattern_list[i].depth =
ctx->parray[i]->depth;
887 ctx->pattern_list[i].pid =
ctx->parray[i]->id;
890 ctx->pattern_list[i].sids_size =
ctx->parray[i]->sids_size;
891 ctx->pattern_list[i].sids =
ctx->parray[i]->sids;
892 ctx->parray[i]->sids = NULL;
893 ctx->parray[i]->sids_size = 0;
897 SCACTilePrepareStateTable(mpm_ctx);
900 SCACTilePrepareSearch(mpm_ctx);
915 if (mpm_ctx->
ctx != NULL)
920 if (mpm_ctx->
ctx == NULL) {
949 static void SCACTileDestroyInitCtx(
MpmCtx *mpm_ctx)
962 if (
ctx->parray != NULL) {
965 if (
ctx->parray[i] != NULL) {
974 if (
ctx->state_table != NULL) {
979 ctx->bytes_per_state *
ctx->alphabet_storage);
982 if (
ctx->output_table != NULL) {
984 for (state = 0; state <
ctx->state_count; state++) {
985 if (
ctx->output_table[state].patterns != NULL) {
986 SCFree(
ctx->output_table[state].patterns);
992 if (
ctx->pattern_list != NULL) {
995 if (
ctx->pattern_list[i].cs != NULL)
997 if (
ctx->pattern_list[i].sids != NULL)
1017 if (search_ctx == NULL)
1021 SCACTileDestroyInitCtx(mpm_ctx);
1037 for (state = 0; state < search_ctx->
state_count; state++) {
1046 mpm_ctx->
ctx = NULL;
1056 #define SCHECK(x) ((x) > 0)
1057 #define BUF_TYPE int32_t
1059 #define BYTE0(x) (((x) & 0x000000ff) >> 0)
1060 #define BYTE1(x) (((x) & 0x0000ff00) >> 8)
1061 #define BYTE2(x) (((x) & 0x00ff0000) >> 16)
1062 #define BYTE3(x) (((x) & 0xff000000) >> 24)
1063 #define EXTRA 4 // need 4 extra bytes to avoid OOB reads
1066 const uint8_t *buf, uint32_t buflen,
1067 uint16_t state,
int i,
int matches,
1068 uint8_t *mpm_bitarray)
1071 const uint8_t *buf_offset = buf + i + 1;
1072 uint32_t no_of_entries =
ctx->output_table[state].no_of_entries;
1076 for (k = 0; k < no_of_entries; k++) {
1078 if (mpm_bitarray[pindex / 8] & (1 << (pindex % 8))) {
1088 if (patterns[k] >> 31) {
1089 const uint16_t patlen = pat->
patlen;
1090 if (
SCMemcmp(pat->
cs, buf_offset - patlen, patlen) != 0) {
1096 mpm_bitarray[pindex / 8] |= (1 << (pindex % 8));
1101 PrefilterAddSids(pmq, pattern_list[pindex].sids,
1102 pattern_list[pindex].sids_size);
1130 return search_ctx->
Search(search_ctx, mpm_thread_ctx, pmq, buf, buflen);
1136 const uint8_t *buf, uint32_t buflen)
1141 uint8_t mpm_bitarray[
ctx->mpm_bitarray_size];
1142 memset(mpm_bitarray, 0,
ctx->mpm_bitarray_size);
1144 const uint8_t* restrict xlate =
ctx->translate_table;
1145 register int state = 0;
1146 int32_t (*state_table_u32)[256] =
ctx->state_table;
1147 for (i = 0; i < buflen; i++) {
1148 state = state_table_u32[state & 0x00FFFFFF][xlate[buf[i]]];
1151 matches = CheckMatch(
ctx, pmq, buf, buflen, (uint16_t)state, i, matches, mpm_bitarray);
1163 #define SINDEX_INTERNAL(y, x, log_mult, width) \
1164 ((1<<log_mult) * (x & ((1<<width) - 1)))
1167 #define STYPE int16_t
1168 #define SLOAD(x) *(STYPE * restrict)(x)
1170 #define FUNC_NAME SCACTileSearchSmall256
1172 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 8, 15)
1178 #define FUNC_NAME SCACTileSearchSmall128
1180 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 7, 15)
1186 #define FUNC_NAME SCACTileSearchSmall64
1188 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 6, 15)
1194 #define FUNC_NAME SCACTileSearchSmall32
1196 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 5, 15)
1202 #define FUNC_NAME SCACTileSearchSmall16
1204 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 4, 15)
1210 #define FUNC_NAME SCACTileSearchSmall8
1212 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 3, 15)
1220 #define STYPE int8_t
1224 #define FUNC_NAME SCACTileSearchTiny256
1226 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 8, 7)
1232 #define FUNC_NAME SCACTileSearchTiny128
1234 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 7, 7)
1240 #define FUNC_NAME SCACTileSearchTiny64
1242 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 6, 7)
1248 #define FUNC_NAME SCACTileSearchTiny32
1250 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 5, 7)
1256 #define FUNC_NAME SCACTileSearchTiny16
1258 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 4, 7)
1264 #define FUNC_NAME SCACTileSearchTiny8
1266 #define SINDEX(y,x) SINDEX_INTERNAL(y, x, 3, 7)
1313 uint16_t
offset, uint16_t depth, uint32_t pid,
1325 printf(
"MPM AC Information:\n");
1326 printf(
"Memory allocs: %" PRIu32
"\n", mpm_ctx->
memory_cnt);
1327 printf(
"Memory alloced: %" PRIu32
"\n", mpm_ctx->
memory_size);
1328 printf(
" Sizeof:\n");
1329 printf(
" MpmCtx %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmCtx));
1330 printf(
" SCACTileCtx: %" PRIuMAX
"\n", (uintmax_t)
sizeof(
SCACTileCtx));
1331 printf(
" MpmPattern %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmPattern));
1332 printf(
" MpmPattern %" PRIuMAX
"\n", (uintmax_t)
sizeof(
MpmPattern));
1333 printf(
"Unique Patterns: %" PRIu32
"\n", mpm_ctx->
pattern_cnt);
1334 printf(
"Smallest: %" PRIu32
"\n", mpm_ctx->
minlen);
1335 printf(
"Largest: %" PRIu32
"\n", mpm_ctx->
maxlen);
1336 printf(
"Total states in the state table: %u\n",
ctx->state_count);
1372 static int SCACTileTest01(
void)
1379 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1389 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1392 (uint8_t *)buf, strlen(buf));
1397 printf(
"1 != %" PRIu32
" ",
cnt);
1404 static int SCACTileTest02(
void)
1411 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1421 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1423 (uint8_t *)buf, strlen(buf));
1428 printf(
"0 != %" PRIu32
" ",
cnt);
1435 static int SCACTileTest03(
void)
1442 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1456 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1458 (uint8_t *)buf, strlen(buf));
1463 printf(
"3 != %" PRIu32
" ",
cnt);
1470 static int SCACTileTest04(
void)
1477 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1488 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1490 (uint8_t *)buf, strlen(buf));
1495 printf(
"1 != %" PRIu32
" ",
cnt);
1502 static int SCACTileTest05(
void)
1509 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1520 const char *buf =
"abcdefghjiklmnopqrstuvwxyz";
1522 (uint8_t *)buf, strlen(buf));
1527 printf(
"3 != %" PRIu32
" ",
cnt);
1534 static int SCACTileTest06(
void)
1541 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1550 const char *buf =
"abcd";
1552 (uint8_t *)buf, strlen(buf));
1557 printf(
"1 != %" PRIu32
" ",
cnt);
1564 static int SCACTileTest07(
void)
1570 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1583 MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"AAAAAAAAAA", 10, 0, 0, 4, 0, 0);
1585 MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
1592 const char *buf =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1594 (uint8_t *)buf, strlen(buf));
1602 static int SCACTileTest08(
void)
1609 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1625 printf(
"0 != %" PRIu32
" ",
cnt);
1632 static int SCACTileTest09(
void)
1639 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1650 (uint8_t *)
"ab", 2);
1655 printf(
"1 != %" PRIu32
" ",
cnt);
1662 static int SCACTileTest10(
void)
1669 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1679 const char *buf =
"01234567890123456789012345678901234567890123456789"
1680 "01234567890123456789012345678901234567890123456789"
1682 "01234567890123456789012345678901234567890123456789"
1683 "01234567890123456789012345678901234567890123456789";
1685 (uint8_t *)buf, strlen(buf));
1690 printf(
"1 != %" PRIu32
" ",
cnt);
1697 static int SCACTileTest11(
void)
1704 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
1708 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"he", 2, 0, 0, 1, 0, 0) == -1)
1710 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"she", 3, 0, 0, 2, 0, 0) == -1)
1712 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"his", 3, 0, 0, 3, 0, 0) == -1)
1714 if (
MpmAddPatternCS(&mpm_ctx, (uint8_t *)
"hers", 4, 0, 0, 4, 0, 0) == -1)
1723 const char *buf =
"he";
1742 static int SCACTileTest12(
void)
1749 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1761 const char *buf =
"abcdefghijklmnopqrstuvwxyz";
1763 (uint8_t *)buf, strlen(buf));
1768 printf(
"2 != %" PRIu32
" ",
cnt);
1775 static int SCACTileTest13(
void)
1782 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1787 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCD";
1788 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1793 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCD";
1795 (uint8_t *)buf, strlen(buf));
1800 printf(
"1 != %" PRIu32
" ",
cnt);
1807 static int SCACTileTest14(
void)
1814 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1819 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCDE";
1820 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1825 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCDE";
1827 (uint8_t *)buf, strlen(buf));
1832 printf(
"1 != %" PRIu32
" ",
cnt);
1839 static int SCACTileTest15(
void)
1846 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1851 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABCDEF";
1852 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1857 const char *buf =
"abcdefghijklmnopqrstuvwxyzABCDEF";
1859 (uint8_t *)buf, strlen(buf));
1864 printf(
"1 != %" PRIu32
" ",
cnt);
1871 static int SCACTileTest16(
void)
1878 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1883 const char pat[] =
"abcdefghijklmnopqrstuvwxyzABC";
1884 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1889 const char *buf =
"abcdefghijklmnopqrstuvwxyzABC";
1891 (uint8_t *)buf, strlen(buf));
1896 printf(
"1 != %" PRIu32
" ",
cnt);
1903 static int SCACTileTest17(
void)
1910 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1915 const char pat[] =
"abcdefghijklmnopqrstuvwxyzAB";
1916 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1921 const char *buf =
"abcdefghijklmnopqrstuvwxyzAB";
1923 (uint8_t *)buf, strlen(buf));
1928 printf(
"1 != %" PRIu32
" ",
cnt);
1935 static int SCACTileTest18(
void)
1942 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1947 const char pat[] =
"abcde"
1953 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1958 const char *buf =
"abcde""fghij""klmno""pqrst""uvwxy""z";
1960 (uint8_t *)buf, strlen(buf));
1965 printf(
"1 != %" PRIu32
" ",
cnt);
1972 static int SCACTileTest19(
void)
1979 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
1984 const char pat[] =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1985 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
1990 const char *buf =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1992 (uint8_t *)buf, strlen(buf));
1997 printf(
"1 != %" PRIu32
" ",
cnt);
2004 static int SCACTileTest20(
void)
2011 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2016 const char pat[] =
"AAAAA"
2023 MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat,
sizeof(pat) - 1, 0, 0, 0, 0, 0);
2028 const char *buf =
"AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA";
2030 (uint8_t *)buf, strlen(buf));
2035 printf(
"1 != %" PRIu32
" ",
cnt);
2042 static int SCACTileTest21(
void)
2049 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2060 (uint8_t *)
"AA", 2);
2065 printf(
"1 != %" PRIu32
" ",
cnt);
2072 static int SCACTileTest22(
void)
2079 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2091 const char *buf =
"abcdefghijklmnopqrstuvwxyz";
2093 (uint8_t *)buf, strlen(buf));
2098 printf(
"2 != %" PRIu32
" ",
cnt);
2105 static int SCACTileTest23(
void)
2112 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2123 (uint8_t *)
"aa", 2);
2128 printf(
"1 != %" PRIu32
" ",
cnt);
2135 static int SCACTileTest24(
void)
2142 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2153 (uint8_t *)
"aa", 2);
2158 printf(
"1 != %" PRIu32
" ",
cnt);
2165 static int SCACTileTest25(
void)
2172 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2183 const char *buf =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
2185 (uint8_t *)buf, strlen(buf));
2190 printf(
"3 != %" PRIu32
" ",
cnt);
2197 static int SCACTileTest26(
void)
2204 memset(&mpm_ctx, 0x00,
sizeof(
MpmCtx));
2214 const char *buf =
"works";
2216 (uint8_t *)buf, strlen(buf));
2221 printf(
"3 != %" PRIu32
" ",
cnt);
2228 static int SCACTileTest27(
void)
2235 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
2245 const char *buf =
"tone";
2247 (uint8_t *)buf, strlen(buf));
2252 printf(
"0 != %" PRIu32
" ",
cnt);
2259 static int SCACTileTest28(
void)
2266 memset(&mpm_ctx, 0,
sizeof(
MpmCtx));
2276 const char *buf =
"tONE";
2278 (uint8_t *)buf, strlen(buf));
2283 printf(
"0 != %" PRIu32
" ",
cnt);
2290 static int SCACTileTest29(
void)
2292 uint8_t buf[] =
"onetwothreefourfivesixseveneightnine";
2293 uint16_t buflen =
sizeof(buf) - 1;
2299 memset(&th_v, 0,
sizeof(th_v));
2309 "(content:\"onetwothreefourfivesixseveneightnine\"; sid:1;)");
2313 "(content:\"onetwothreefourfivesixseveneightnine\"; fast_pattern:3,3; sid:2;)");
2322 printf(
"if (PacketAlertCheck(p, 1) != 1) failure\n");
2326 printf(
"if (PacketAlertCheck(p, 1) != 2) failure\n");
2344 void SCACTileRegisterTests(
void)