48 #define DETECT_BYTE_EXTRACT_BASE_HEX BaseHex
49 #define DETECT_BYTE_EXTRACT_BASE_DEC BaseDec
50 #define DETECT_BYTE_EXTRACT_BASE_OCT BaseOct
54 #define STRING_MAX_BYTES_TO_EXTRACT_FOR_OCT 23
55 #define STRING_MAX_BYTES_TO_EXTRACT_FOR_DEC 20
56 #define STRING_MAX_BYTES_TO_EXTRACT_FOR_HEX 14
58 #define NO_STRING_MAX_BYTES_TO_EXTRACT 8
62 static void DetectByteExtractRegisterTests(
void);
95 SCDetectByteExtractData *data = (SCDetectByteExtractData *)smd->
ctx;
96 if (data->flags & DETECT_BYTE_EXTRACT_FLAG_RELATIVE) {
97 SCLogDebug(
"relative, working with det_ctx->buffer_offset %"PRIu32
", "
98 "data->offset %"PRIu32
"", det_ctx->
buffer_offset, data->offset);
112 SCLogDebug(
"absolute, data->offset %"PRIu32
"", data->offset);
114 ptr = payload + data->offset;
119 if (ptr < payload || data->nbytes >
len) {
120 SCLogDebug(
"Data not within payload pkt=%p, ptr=%p, len=%"PRIu32
", nbytes=%d",
121 payload, ptr,
len, data->nbytes);
128 if (data->flags & DETECT_BYTE_EXTRACT_FLAG_STRING) {
130 data->nbytes, (
const char *)ptr);
137 SCLogDebug(
"error extracting %d bytes of string data: %d",
138 data->nbytes, extbytes);
145 if (extbytes != data->nbytes) {
146 SCLogDebug(
"error extracting %d bytes of numeric data: %d",
147 data->nbytes, extbytes);
153 val *= data->multiplier_value;
154 if (data->flags & DETECT_BYTE_EXTRACT_FLAG_ALIGN) {
155 if ((val % data->align_value) != 0) {
156 val += data->align_value - (val % data->align_value);
165 SCLogDebug(
"extracted value is %"PRIu64, val);
179 static inline SCDetectByteExtractData *DetectByteExtractParse(
182 SCDetectByteExtractData *bed = SCByteExtractParse(arg);
188 if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_SLICE) {
189 SCLogError(
"byte_extract slice not yet supported; see issue #6831");
192 if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_STRING) {
198 "more than %d bytes in \"string\" extraction",
207 "more than %d bytes in \"string\" extraction",
216 "more than %d bytes in \"string\" extraction",
226 "more than %d bytes in \"non-string\" extraction",
232 if (!(bed->flags & DETECT_BYTE_EXTRACT_FLAG_ENDIAN))
233 bed->endian = BigEndian;
239 DetectByteExtractFree(
de_ctx, bed);
259 SCDetectByteExtractData *data = NULL;
262 data = DetectByteExtractParse(
de_ctx, arg);
270 if (data->flags & DETECT_BYTE_EXTRACT_FLAG_RELATIVE) {
273 }
else if (data->endian == EndianDCE) {
274 if (data->flags & DETECT_BYTE_EXTRACT_FLAG_RELATIVE) {
278 if (prev_pm == NULL) {
292 }
else if (data->flags & DETECT_BYTE_EXTRACT_FLAG_RELATIVE) {
297 if (prev_pm == NULL) {
309 if (data->endian == EndianDCE) {
313 if ((DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING) ==
314 (data->flags & (DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING))) {
316 "A byte_jump keyword with dce holds other invalid modifiers.");
323 if (prev_bed_sm == NULL)
326 data->local_id = ((SCDetectByteExtractData *)prev_bed_sm->
ctx)->local_id + 1;
335 if (!(data->flags & DETECT_BYTE_EXTRACT_FLAG_RELATIVE))
353 DetectByteExtractFree(
de_ctx, data);
364 SCByteExtractFree(ptr);
381 const SCDetectByteExtractData *bed = (
const SCDetectByteExtractData *)sm->
ctx;
382 if (strcmp(bed->name, arg) == 0) {
394 const SCDetectByteExtractData *bed = (
const SCDetectByteExtractData *)sm->
ctx;
395 if (strcmp(bed->name, arg) == 0) {
410 static int g_file_data_buffer_id = 0;
411 static int g_http_uri_buffer_id = 0;
413 static int DetectByteExtractTest01(
void)
417 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one");
421 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 || bed->flags != 0 ||
422 bed->endian != BigEndian || bed->align_value != 0 ||
423 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
430 DetectByteExtractFree(NULL, bed);
434 static int DetectByteExtractTest02(
void)
438 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, relative");
442 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
443 bed->flags != DETECT_BYTE_EXTRACT_FLAG_RELATIVE || bed->endian != BigEndian ||
444 bed->align_value != 0 ||
445 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
452 DetectByteExtractFree(NULL, bed);
456 static int DetectByteExtractTest03(
void)
460 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, multiplier 10");
464 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
465 bed->flags != DETECT_BYTE_EXTRACT_FLAG_MULTIPLIER || bed->endian != BigEndian ||
466 bed->align_value != 0 || bed->multiplier_value != 10) {
473 DetectByteExtractFree(NULL, bed);
477 static int DetectByteExtractTest04(
void)
481 SCDetectByteExtractData *bed =
482 DetectByteExtractParse(NULL,
"4, 2, one, relative, multiplier 10");
486 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
488 (DETECT_BYTE_EXTRACT_FLAG_RELATIVE | DETECT_BYTE_EXTRACT_FLAG_MULTIPLIER) ||
489 bed->endian != BigEndian || bed->align_value != 0 || bed->multiplier_value != 10) {
496 DetectByteExtractFree(NULL, bed);
500 static int DetectByteExtractTest05(
void)
504 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, big");
508 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
509 bed->flags != DETECT_BYTE_EXTRACT_FLAG_ENDIAN || bed->endian != BigEndian ||
510 bed->align_value != 0 ||
511 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
518 DetectByteExtractFree(NULL, bed);
522 static int DetectByteExtractTest06(
void)
526 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, little");
530 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
531 bed->flags != DETECT_BYTE_EXTRACT_FLAG_ENDIAN || bed->endian != LittleEndian ||
532 bed->align_value != 0 ||
533 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
540 DetectByteExtractFree(NULL, bed);
544 static int DetectByteExtractTest07(
void)
548 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, dce");
552 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
553 bed->flags != DETECT_BYTE_EXTRACT_FLAG_ENDIAN || bed->endian != EndianDCE ||
554 bed->align_value != 0 ||
555 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
562 DetectByteExtractFree(NULL, bed);
566 static int DetectByteExtractTest08(
void)
570 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, string, hex");
574 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
575 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING) ||
577 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
584 DetectByteExtractFree(NULL, bed);
588 static int DetectByteExtractTest09(
void)
592 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, string, oct");
596 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
597 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING) ||
599 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
606 DetectByteExtractFree(NULL, bed);
610 static int DetectByteExtractTest10(
void)
614 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, string, dec");
618 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
620 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
627 DetectByteExtractFree(NULL, bed);
631 static int DetectByteExtractTest11(
void)
635 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4");
639 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
640 bed->flags != DETECT_BYTE_EXTRACT_FLAG_ALIGN || bed->endian != BigEndian ||
641 bed->align_value != 4 ||
642 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
649 DetectByteExtractFree(NULL, bed);
653 static int DetectByteExtractTest12(
void)
657 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, relative");
661 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
662 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_ALIGN | DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
663 bed->endian != BigEndian || bed->align_value != 4 ||
664 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
671 DetectByteExtractFree(NULL, bed);
675 static int DetectByteExtractTest13(
void)
679 SCDetectByteExtractData *bed =
680 DetectByteExtractParse(NULL,
"4, 2, one, align 4, relative, big");
684 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
685 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_ALIGN | DETECT_BYTE_EXTRACT_FLAG_ENDIAN |
686 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
687 bed->endian != BigEndian || bed->align_value != 4 ||
688 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
695 DetectByteExtractFree(NULL, bed);
699 static int DetectByteExtractTest14(
void)
703 SCDetectByteExtractData *bed =
704 DetectByteExtractParse(NULL,
"4, 2, one, align 4, relative, dce");
708 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
709 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_ALIGN | DETECT_BYTE_EXTRACT_FLAG_ENDIAN |
710 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
711 bed->endian != EndianDCE || bed->align_value != 4 ||
712 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
719 DetectByteExtractFree(NULL, bed);
723 static int DetectByteExtractTest15(
void)
727 SCDetectByteExtractData *bed =
728 DetectByteExtractParse(NULL,
"4, 2, one, align 4, relative, little");
732 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
733 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_ALIGN | DETECT_BYTE_EXTRACT_FLAG_ENDIAN |
734 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
735 bed->endian != LittleEndian || bed->align_value != 4 ||
736 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
743 DetectByteExtractFree(NULL, bed);
747 static int DetectByteExtractTest16(
void)
751 SCDetectByteExtractData *bed =
752 DetectByteExtractParse(NULL,
"4, 2, one, align 4, relative, little, multiplier 2");
756 if (bed->nbytes != 4 || bed->offset != 2 || strcmp(bed->name,
"one") != 0 ||
757 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_ALIGN | DETECT_BYTE_EXTRACT_FLAG_RELATIVE |
758 DETECT_BYTE_EXTRACT_FLAG_ENDIAN |
759 DETECT_BYTE_EXTRACT_FLAG_MULTIPLIER) ||
760 bed->endian != LittleEndian || bed->align_value != 4 || bed->multiplier_value != 2) {
767 DetectByteExtractFree(NULL, bed);
771 static int DetectByteExtractTest17(
void)
775 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
777 "multiplier 2, string hex");
784 DetectByteExtractFree(NULL, bed);
788 static int DetectByteExtractTest18(
void)
792 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
802 DetectByteExtractFree(NULL, bed);
806 static int DetectByteExtractTest19(
void)
810 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
820 DetectByteExtractFree(NULL, bed);
824 static int DetectByteExtractTest20(
void)
828 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
838 DetectByteExtractFree(NULL, bed);
842 static int DetectByteExtractTest21(
void)
846 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
856 DetectByteExtractFree(NULL, bed);
860 static int DetectByteExtractTest22(
void)
864 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
874 DetectByteExtractFree(NULL, bed);
878 static int DetectByteExtractTest23(
void)
882 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
892 DetectByteExtractFree(NULL, bed);
896 static int DetectByteExtractTest24(
void)
900 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"24, 2, one, align 4, "
909 DetectByteExtractFree(NULL, bed);
913 static int DetectByteExtractTest25(
void)
917 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"9, 2, one, align 4, "
926 DetectByteExtractFree(NULL, bed);
930 static int DetectByteExtractTest26(
void)
934 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
944 DetectByteExtractFree(NULL, bed);
948 static int DetectByteExtractTest27(
void)
952 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, align 4, "
962 DetectByteExtractFree(NULL, bed);
966 static int DetectByteExtractTest28(
void)
970 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"23, 2, one, string, oct");
977 DetectByteExtractFree(NULL, bed);
981 static int DetectByteExtractTest29(
void)
985 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"24, 2, one, string, oct");
992 DetectByteExtractFree(NULL, bed);
996 static int DetectByteExtractTest30(
void)
1000 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"20, 2, one, string, dec");
1007 DetectByteExtractFree(NULL, bed);
1011 static int DetectByteExtractTest31(
void)
1015 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"21, 2, one, string, dec");
1022 DetectByteExtractFree(NULL, bed);
1026 static int DetectByteExtractTest32(
void)
1030 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"14, 2, one, string, hex");
1037 DetectByteExtractFree(NULL, bed);
1041 static int DetectByteExtractTest33(
void)
1045 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"15, 2, one, string, hex");
1052 DetectByteExtractFree(NULL, bed);
1056 static int DetectByteExtractTest34(
void)
1063 SCDetectByteExtractData *bed = NULL;
1071 "(msg:\"Testing bytejump_body\"; "
1073 "byte_extract:4,2,two,relative,string,hex; "
1099 printf(
"one failed\n");
1109 bed = (SCDetectByteExtractData *)sm->
ctx;
1110 if (bed->nbytes != 4 || bed->offset != 2 || strncmp(bed->name,
"two", cd->
content_len) != 0 ||
1111 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_RELATIVE | DETECT_BYTE_EXTRACT_FLAG_BASE |
1112 DETECT_BYTE_EXTRACT_FLAG_STRING) ||
1114 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1128 static int DetectByteExtractTest35(
void)
1136 SCDetectByteExtractData *bed = NULL;
1144 "(msg:\"Testing bytejump_body\"; "
1145 "content:\"one\"; pcre:/asf/; "
1146 "byte_extract:4,0,two,relative,string,hex; "
1172 printf(
"one failed\n");
1193 bed = (SCDetectByteExtractData *)sm->
ctx;
1194 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1195 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_RELATIVE | DETECT_BYTE_EXTRACT_FLAG_BASE |
1196 DETECT_BYTE_EXTRACT_FLAG_STRING) ||
1198 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1212 static int DetectByteExtractTest36(
void)
1219 "content:\"one\"; byte_jump:1,13; "
1220 "byte_extract:4,0,two,relative,string,hex; "
1243 SCDetectByteExtractData *bed = (SCDetectByteExtractData *)sm->
ctx;
1246 FAIL_IF(strcmp(bed->name,
"two") != 0);
1247 FAIL_IF(bed->flags != (DETECT_BYTE_EXTRACT_FLAG_RELATIVE | DETECT_BYTE_EXTRACT_FLAG_BASE |
1248 DETECT_BYTE_EXTRACT_FLAG_STRING));
1250 FAIL_IF(bed->align_value != 0);
1251 FAIL_IF(bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT);
1257 static int DetectByteExtractTest37(
void)
1265 SCDetectByteExtractData *bed = NULL;
1273 "(msg:\"Testing bytejump_body\"; "
1274 "content:\"one\"; uricontent:\"two\"; "
1275 "byte_extract:4,0,two,relative,string,hex; "
1301 printf(
"one failed\n");
1306 if (sm->
next != NULL) {
1325 printf(
"two failed\n");
1335 bed = (SCDetectByteExtractData *)sm->
ctx;
1336 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1337 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_RELATIVE | DETECT_BYTE_EXTRACT_FLAG_BASE |
1338 DETECT_BYTE_EXTRACT_FLAG_STRING) ||
1340 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1354 static int DetectByteExtractTest38(
void)
1362 SCDetectByteExtractData *bed = NULL;
1370 "(msg:\"Testing bytejump_body\"; "
1371 "content:\"one\"; uricontent:\"two\"; "
1372 "byte_extract:4,0,two,string,hex; "
1398 printf(
"one failed\n");
1408 bed = (SCDetectByteExtractData *)sm->
ctx;
1409 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1410 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING) ||
1412 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1430 printf(
"two failed\n");
1435 if (sm->
next != NULL) {
1450 static int DetectByteExtractTest39(
void)
1458 SCDetectByteExtractData *bed = NULL;
1466 "(msg:\"Testing bytejump_body\"; "
1467 "content:\"one\"; content:\"two\"; http_uri; "
1468 "byte_extract:4,0,two,relative,string,hex; "
1494 printf(
"one failed\n");
1499 if (sm->
next != NULL) {
1518 printf(
"two failed\n");
1528 bed = (SCDetectByteExtractData *)sm->
ctx;
1529 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1530 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_RELATIVE | DETECT_BYTE_EXTRACT_FLAG_BASE |
1531 DETECT_BYTE_EXTRACT_FLAG_STRING) ||
1533 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1547 static int DetectByteExtractTest40(
void)
1555 SCDetectByteExtractData *bed = NULL;
1563 "(msg:\"Testing bytejump_body\"; "
1564 "content:\"one\"; content:\"two\"; http_uri; "
1565 "byte_extract:4,0,two,string,hex; "
1591 printf(
"one failed\n");
1601 bed = (SCDetectByteExtractData *)sm->
ctx;
1602 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1603 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
1605 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1623 printf(
"two failed\n");
1628 if (sm->
next != NULL) {
1643 static int DetectByteExtractTest41(
void)
1650 SCDetectByteExtractData *bed = NULL;
1658 "(msg:\"Testing bytejump_body\"; "
1660 "byte_extract:4,0,two,string,hex; "
1661 "byte_extract:4,0,three,string,hex; "
1687 printf(
"one failed\n");
1697 bed = (SCDetectByteExtractData *)sm->
ctx;
1698 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1699 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
1701 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1704 if (bed->local_id != 0) {
1714 bed = (SCDetectByteExtractData *)sm->
ctx;
1715 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"three") != 0 ||
1716 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
1718 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1721 if (bed->local_id != 1) {
1736 static int DetectByteExtractTest42(
void)
1744 SCDetectByteExtractData *bed = NULL;
1752 "(msg:\"Testing bytejump_body\"; "
1754 "byte_extract:4,0,two,string,hex; "
1755 "uricontent: \"three\"; "
1756 "byte_extract:4,0,four,string,hex,relative; "
1757 "byte_extract:4,0,five,string,hex; "
1783 printf(
"one failed\n");
1793 bed = (SCDetectByteExtractData *)sm->
ctx;
1794 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1795 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
1797 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1800 if (bed->local_id != 0) {
1810 bed = (SCDetectByteExtractData *)sm->
ctx;
1811 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"five") != 0 ||
1812 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
1814 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1817 if (bed->local_id != 1) {
1822 if (sm->
next != NULL)
1839 printf(
"two failed\n");
1849 bed = (SCDetectByteExtractData *)sm->
ctx;
1850 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"four") != 0 ||
1851 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_RELATIVE | DETECT_BYTE_EXTRACT_FLAG_BASE |
1852 DETECT_BYTE_EXTRACT_FLAG_STRING) ||
1854 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1857 if (bed->local_id != 0) {
1862 if (sm->
next != NULL)
1875 static int DetectByteExtractTest43(
void)
1882 SCDetectByteExtractData *bed = NULL;
1890 "(msg:\"Testing bytejump_body\"; "
1892 "byte_extract:4,0,two,string,hex; "
1893 "content: \"three\"; offset:two; "
1919 printf(
"one failed\n");
1929 bed = (SCDetectByteExtractData *)sm->
ctx;
1930 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
1931 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING) ||
1933 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
1936 if (bed->local_id != 0) {
1950 cd->
offset != bed->local_id) {
1951 printf(
"three failed\n");
1956 if (sm->
next != NULL)
1969 static int DetectByteExtractTest44(
void)
1976 SCDetectByteExtractData *bed1 = NULL;
1977 SCDetectByteExtractData *bed2 = NULL;
1985 "(msg:\"Testing bytejump_body\"; "
1987 "byte_extract:4,0,two,string,hex; "
1988 "byte_extract:4,0,three,string,hex; "
1989 "content: \"four\"; offset:two; "
1990 "content: \"five\"; offset:three; "
2016 printf(
"one failed\n");
2026 bed1 = (SCDetectByteExtractData *)sm->
ctx;
2027 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
2028 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2030 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2033 if (bed1->local_id != 0) {
2043 bed2 = (SCDetectByteExtractData *)sm->
ctx;
2054 cd->
offset != bed1->local_id) {
2055 printf(
"four failed\n");
2069 cd->
offset != bed2->local_id) {
2070 printf(
"five failed\n");
2075 if (sm->
next != NULL)
2088 static int DetectByteExtractTest45(
void)
2095 SCDetectByteExtractData *bed = NULL;
2103 "(msg:\"Testing bytejump_body\"; "
2105 "byte_extract:4,0,two,string,hex; "
2106 "content: \"three\"; depth:two; "
2132 printf(
"one failed\n");
2142 bed = (SCDetectByteExtractData *)sm->
ctx;
2143 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
2144 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2146 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2149 if (bed->local_id != 0) {
2163 cd->
depth != bed->local_id ||
2165 printf(
"three failed\n");
2170 if (sm->
next != NULL)
2183 static int DetectByteExtractTest46(
void)
2190 SCDetectByteExtractData *bed1 = NULL;
2191 SCDetectByteExtractData *bed2 = NULL;
2199 "(msg:\"Testing bytejump_body\"; "
2201 "byte_extract:4,0,two,string,hex; "
2202 "byte_extract:4,0,three,string,hex; "
2203 "content: \"four\"; depth:two; "
2204 "content: \"five\"; depth:three; "
2230 printf(
"one failed\n");
2240 bed1 = (SCDetectByteExtractData *)sm->
ctx;
2241 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
2242 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2244 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2247 if (bed1->local_id != 0) {
2257 bed2 = (SCDetectByteExtractData *)sm->
ctx;
2268 cd->
depth != bed1->local_id) {
2269 printf(
"four failed\n");
2283 cd->
depth != bed2->local_id) {
2284 printf(
"five failed\n");
2289 if (sm->
next != NULL)
2302 static int DetectByteExtractTest47(
void)
2309 SCDetectByteExtractData *bed = NULL;
2317 "(msg:\"Testing bytejump_body\"; "
2319 "byte_extract:4,0,two,string,hex; "
2320 "content: \"three\"; distance:two; "
2346 printf(
"one failed\n");
2356 bed = (SCDetectByteExtractData *)sm->
ctx;
2357 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
2358 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2360 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2363 if (bed->local_id != 0) {
2380 printf(
"three failed\n");
2385 if (sm->
next != NULL)
2398 static int DetectByteExtractTest48(
void)
2405 SCDetectByteExtractData *bed1 = NULL;
2406 SCDetectByteExtractData *bed2 = NULL;
2414 "(msg:\"Testing bytejump_body\"; "
2416 "byte_extract:4,0,two,string,hex; "
2417 "byte_extract:4,0,three,string,hex; "
2418 "content: \"four\"; distance:two; "
2419 "content: \"five\"; distance:three; "
2445 printf(
"one failed\n");
2455 bed1 = (SCDetectByteExtractData *)sm->
ctx;
2456 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
2457 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2459 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2462 if (bed1->local_id != 0) {
2472 bed2 = (SCDetectByteExtractData *)sm->
ctx;
2487 printf(
"four failed\n");
2504 printf(
"five failed\n");
2509 if (sm->
next != NULL)
2522 static int DetectByteExtractTest49(
void)
2529 SCDetectByteExtractData *bed = NULL;
2537 "(msg:\"Testing bytejump_body\"; "
2539 "byte_extract:4,0,two,string,hex; "
2540 "content: \"three\"; within:two; "
2566 printf(
"one failed\n");
2576 bed = (SCDetectByteExtractData *)sm->
ctx;
2577 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
2578 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2580 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2583 if (bed->local_id != 0) {
2597 cd->
within != bed->local_id ||
2601 printf(
"three failed\n");
2606 if (sm->
next != NULL)
2619 static int DetectByteExtractTest50(
void)
2626 SCDetectByteExtractData *bed1 = NULL;
2627 SCDetectByteExtractData *bed2 = NULL;
2635 "(msg:\"Testing bytejump_body\"; "
2637 "byte_extract:4,0,two,string,hex; "
2638 "byte_extract:4,0,three,string,hex; "
2639 "content: \"four\"; within:two; "
2640 "content: \"five\"; within:three; "
2666 printf(
"one failed\n");
2676 bed1 = (SCDetectByteExtractData *)sm->
ctx;
2677 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
2678 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2680 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2683 if (bed1->local_id != 0) {
2693 bed2 = (SCDetectByteExtractData *)sm->
ctx;
2705 cd->
within != bed1->local_id ||
2709 printf(
"four failed\n");
2723 cd->
within != bed2->local_id ||
2727 printf(
"five failed\n");
2732 if (sm->
next != NULL)
2745 static int DetectByteExtractTest51(
void)
2752 SCDetectByteExtractData *bed = NULL;
2761 "(msg:\"Testing bytejump_body\"; "
2763 "byte_extract:4,0,two,string,hex; "
2764 "byte_test: 2,=,10, two; "
2790 printf(
"one failed\n");
2800 bed = (SCDetectByteExtractData *)sm->
ctx;
2801 if (bed->nbytes != 4 || bed->offset != 0 || strcmp(bed->name,
"two") != 0 ||
2802 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2804 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2807 if (bed->local_id != 0) {
2821 printf(
"three failed\n");
2826 if (sm->
next != NULL)
2839 static int DetectByteExtractTest52(
void)
2846 SCDetectByteExtractData *bed1 = NULL;
2855 "(msg:\"Testing bytejump_body\"; "
2857 "byte_extract:4,0,two,string,hex; "
2858 "byte_extract:4,0,three,string,hex; "
2859 "byte_test: 2,=,two,three; "
2860 "byte_test: 3,=,10,three; "
2886 printf(
"one failed\n");
2896 bed1 = (SCDetectByteExtractData *)sm->
ctx;
2897 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
2898 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
2900 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
2903 if (bed1->local_id != 0) {
2924 printf(
"three failed\n");
2938 printf(
"four failed\n");
2943 if (sm->
next != NULL)
2956 static int DetectByteExtractTest53(
void)
2964 "byte_extract:4,0,two,string,hex; "
2965 "byte_jump: 2,two; "
2978 SCDetectByteExtractData *bed = (SCDetectByteExtractData *)sm->
ctx;
2982 FAIL_IF(strcmp(bed->name,
"two") != 0);
2983 FAIL_IF(bed->flags != (DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING));
2985 FAIL_IF(bed->align_value != 0);
2986 FAIL_IF(bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT);
3002 static int DetectByteExtractTest54(
void)
3009 SCDetectByteExtractData *bed1 = NULL;
3018 "(msg:\"Testing bytejump_body\"; "
3020 "byte_extract:4,0,two,string,hex; "
3021 "byte_extract:4,0,three,string,hex; "
3022 "byte_jump: 2,two; "
3023 "byte_jump: 3,three; "
3049 printf(
"one failed\n");
3059 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3060 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
3061 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
3063 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3066 if (bed1->local_id != 0) {
3084 printf(
"three failed\n");
3096 printf(
"four failed\n");
3101 if (sm->
next != NULL)
3114 static int DetectByteExtractTest55(
void)
3121 SCDetectByteExtractData *bed1 = NULL;
3122 SCDetectByteExtractData *bed2 = NULL;
3130 "(msg:\"Testing byte_extract\"; "
3132 "byte_extract:4,0,two,string,hex; "
3133 "byte_extract:4,0,three,string,hex; "
3134 "byte_extract:4,0,four,string,hex; "
3135 "byte_extract:4,0,five,string,hex; "
3136 "content: \"four\"; within:two; distance:three; "
3159 printf(
"one failed: ");
3167 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3168 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
3169 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
3171 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3174 if (bed1->local_id != 0) {
3182 bed2 = (SCDetectByteExtractData *)sm->
ctx;
3204 cd->
within != bed1->local_id ||
3206 printf(
"four failed: ");
3210 if (sm->
next != NULL) {
3224 static int DetectByteExtractTest56(
void)
3231 SCDetectByteExtractData *bed1 = NULL;
3232 SCDetectByteExtractData *bed2 = NULL;
3240 "(msg:\"Testing bytejump_body\"; "
3241 "uricontent:\"urione\"; "
3243 "byte_extract:4,0,two,string,hex; "
3244 "byte_extract:4,0,three,string,hex; "
3245 "byte_extract:4,0,four,string,hex; "
3246 "byte_extract:4,0,five,string,hex; "
3247 "content: \"four\"; within:two; distance:three; "
3273 printf(
"one failed\n");
3278 if (sm->
next != NULL)
3295 printf(
"one failed\n");
3305 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3306 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
3307 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
3309 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3312 if (bed1->local_id != 0) {
3322 bed2 = (SCDetectByteExtractData *)sm->
ctx;
3347 cd->
within != bed1->local_id ||
3349 printf(
"four failed\n");
3354 if (sm->
next != NULL) {
3368 static int DetectByteExtractTest57(
void)
3375 SCDetectByteExtractData *bed1 = NULL;
3376 SCDetectByteExtractData *bed2 = NULL;
3377 SCDetectByteExtractData *bed3 = NULL;
3378 SCDetectByteExtractData *bed4 = NULL;
3386 "(msg:\"Testing bytejump_body\"; "
3388 "uricontent: \"urione\"; "
3389 "byte_extract:4,0,two,string,hex,relative; "
3390 "byte_extract:4,0,three,string,hex,relative; "
3391 "byte_extract:4,0,four,string,hex,relative; "
3392 "byte_extract:4,0,five,string,hex,relative; "
3393 "uricontent: \"four\"; within:two; distance:three; "
3419 printf(
"one failed\n");
3424 if (sm->
next != NULL)
3441 printf(
"one failed\n");
3451 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3452 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
3453 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE |
3454 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
3456 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3459 if (bed1->local_id != 0) {
3469 bed2 = (SCDetectByteExtractData *)sm->
ctx;
3470 if (bed2->local_id != 1) {
3480 bed3 = (SCDetectByteExtractData *)sm->
ctx;
3481 if (bed3->local_id != 2) {
3491 bed4 = (SCDetectByteExtractData *)sm->
ctx;
3492 if (bed4->local_id != 3) {
3508 cd->
within != bed1->local_id ||
3510 printf(
"four failed\n");
3515 if (sm->
next != NULL) {
3529 static int DetectByteExtractTest58(
void)
3536 SCDetectByteExtractData *bed1 = NULL;
3546 "(msg:\"Testing bytejump_body\"; "
3548 "byte_extract:4,0,two,string,hex; "
3549 "byte_extract:4,0,three,string,hex; "
3550 "byte_jump: 2,two; "
3551 "byte_jump: 3,three; "
3578 printf(
"one failed\n");
3588 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3589 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
3590 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE) ||
3592 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3595 if (bed1->local_id != 0) {
3613 printf(
"three failed\n");
3625 printf(
"four failed\n");
3638 printf(
"isdataat failed\n");
3643 if (sm->
next != NULL)
3656 static int DetectByteExtractTest59(
void)
3664 "byte_extract:4,0,two,string,hex; "
3665 "byte_extract:4,0,three,string,hex; "
3666 "byte_jump: 2,two; "
3667 "byte_jump: 3,three; "
3668 "isdataat: three,relative; "
3690 SCDetectByteExtractData *bed1 = (SCDetectByteExtractData *)sm->
ctx;
3693 FAIL_IF(strcmp(bed1->name,
"two") != 0);
3695 FAIL_IF(bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_BASE | DETECT_BYTE_EXTRACT_FLAG_STRING));
3698 FAIL_IF(bed1->align_value != 0);
3699 FAIL_IF(bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT);
3736 static int DetectByteExtractTest60(
void)
3743 SCDetectByteExtractData *bed1 = NULL;
3752 "(msg:\"Testing bytejump_body\"; "
3754 "byte_extract:4,0,two,string,hex,relative; "
3755 "uricontent: \"three\"; "
3756 "byte_extract:4,0,four,string,hex,relative; "
3783 printf(
"one failed\n");
3793 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3794 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
3795 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE |
3796 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
3798 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3801 if (bed1->local_id != 0) {
3813 isdd->
dataat != bed1->local_id) {
3814 printf(
"isdataat failed\n");
3819 if (sm->
next != NULL)
3834 printf(
"one failed\n");
3844 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3845 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"four") != 0 ||
3846 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE |
3847 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
3849 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3852 if (bed1->local_id != 0) {
3857 if (sm->
next != NULL)
3870 static int DetectByteExtractTest61(
void)
3877 SCDetectByteExtractData *bed1 = NULL;
3886 "(msg:\"Testing bytejump_body\"; "
3888 "byte_extract:4,0,two,string,hex,relative; "
3889 "uricontent: \"three\"; "
3890 "byte_extract:4,0,four,string,hex,relative; "
3891 "isdataat: four, relative; "
3917 printf(
"one failed\n");
3927 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3928 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"two") != 0 ||
3929 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE |
3930 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
3932 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3935 if (bed1->local_id != 0) {
3940 if (sm->
next != NULL)
3955 printf(
"one failed\n");
3965 bed1 = (SCDetectByteExtractData *)sm->
ctx;
3966 if (bed1->nbytes != 4 || bed1->offset != 0 || strcmp(bed1->name,
"four") != 0 ||
3967 bed1->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE |
3968 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
3970 bed1->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
3973 if (bed1->local_id != 0) {
3986 isdd->
dataat != bed1->local_id) {
3987 printf(
"isdataat failed\n");
3992 if (sm->
next != NULL)
4005 static int DetectByteExtractTest62(
void)
4011 SCDetectByteExtractData *bed = NULL;
4019 "(file_data; byte_extract:4,2,two,relative,string,hex; "
4032 bed = (SCDetectByteExtractData *)sm->
ctx;
4033 if (bed->nbytes != 4 || bed->offset != 2 || strncmp(bed->name,
"two", 3) != 0 ||
4034 bed->flags != (DETECT_BYTE_EXTRACT_FLAG_STRING | DETECT_BYTE_EXTRACT_FLAG_BASE |
4035 DETECT_BYTE_EXTRACT_FLAG_RELATIVE) ||
4037 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
4051 static int DetectByteExtractTest63(
void)
4055 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, -2, one");
4059 if (bed->nbytes != 4 || bed->offset != -2 || strcmp(bed->name,
"one") != 0 || bed->flags != 0 ||
4060 bed->endian != BigEndian || bed->align_value != 0 ||
4061 bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
4068 DetectByteExtractFree(NULL, bed);
4072 static int DetectByteExtractTestParseNoBase(
void)
4076 SCDetectByteExtractData *bed = DetectByteExtractParse(NULL,
"4, 2, one, string");
4080 if (bed->nbytes != 4) {
4083 if (bed->offset != 2) {
4086 if (strcmp(bed->name,
"one") != 0) {
4089 if (bed->flags != DETECT_BYTE_EXTRACT_FLAG_STRING) {
4095 if (bed->align_value != 0) {
4098 if (bed->multiplier_value != DETECT_BYTE_EXTRACT_MULTIPLIER_DEFAULT) {
4105 DetectByteExtractFree(NULL, bed);
4109 static void DetectByteExtractRegisterTests(
void)
4114 UtRegisterTest(
"DetectByteExtractTest01", DetectByteExtractTest01);
4115 UtRegisterTest(
"DetectByteExtractTest02", DetectByteExtractTest02);
4116 UtRegisterTest(
"DetectByteExtractTest03", DetectByteExtractTest03);
4117 UtRegisterTest(
"DetectByteExtractTest04", DetectByteExtractTest04);
4118 UtRegisterTest(
"DetectByteExtractTest05", DetectByteExtractTest05);
4119 UtRegisterTest(
"DetectByteExtractTest06", DetectByteExtractTest06);
4120 UtRegisterTest(
"DetectByteExtractTest07", DetectByteExtractTest07);
4121 UtRegisterTest(
"DetectByteExtractTest08", DetectByteExtractTest08);
4122 UtRegisterTest(
"DetectByteExtractTest09", DetectByteExtractTest09);
4123 UtRegisterTest(
"DetectByteExtractTest10", DetectByteExtractTest10);
4124 UtRegisterTest(
"DetectByteExtractTest11", DetectByteExtractTest11);
4125 UtRegisterTest(
"DetectByteExtractTest12", DetectByteExtractTest12);
4126 UtRegisterTest(
"DetectByteExtractTest13", DetectByteExtractTest13);
4127 UtRegisterTest(
"DetectByteExtractTest14", DetectByteExtractTest14);
4128 UtRegisterTest(
"DetectByteExtractTest15", DetectByteExtractTest15);
4129 UtRegisterTest(
"DetectByteExtractTest16", DetectByteExtractTest16);
4130 UtRegisterTest(
"DetectByteExtractTest17", DetectByteExtractTest17);
4131 UtRegisterTest(
"DetectByteExtractTest18", DetectByteExtractTest18);
4132 UtRegisterTest(
"DetectByteExtractTest19", DetectByteExtractTest19);
4133 UtRegisterTest(
"DetectByteExtractTest20", DetectByteExtractTest20);
4134 UtRegisterTest(
"DetectByteExtractTest21", DetectByteExtractTest21);
4135 UtRegisterTest(
"DetectByteExtractTest22", DetectByteExtractTest22);
4136 UtRegisterTest(
"DetectByteExtractTest23", DetectByteExtractTest23);
4137 UtRegisterTest(
"DetectByteExtractTest24", DetectByteExtractTest24);
4138 UtRegisterTest(
"DetectByteExtractTest25", DetectByteExtractTest25);
4139 UtRegisterTest(
"DetectByteExtractTest26", DetectByteExtractTest26);
4140 UtRegisterTest(
"DetectByteExtractTest27", DetectByteExtractTest27);
4141 UtRegisterTest(
"DetectByteExtractTest28", DetectByteExtractTest28);
4142 UtRegisterTest(
"DetectByteExtractTest29", DetectByteExtractTest29);
4143 UtRegisterTest(
"DetectByteExtractTest30", DetectByteExtractTest30);
4144 UtRegisterTest(
"DetectByteExtractTest31", DetectByteExtractTest31);
4145 UtRegisterTest(
"DetectByteExtractTest32", DetectByteExtractTest32);
4146 UtRegisterTest(
"DetectByteExtractTest33", DetectByteExtractTest33);
4147 UtRegisterTest(
"DetectByteExtractTest34", DetectByteExtractTest34);
4148 UtRegisterTest(
"DetectByteExtractTest35", DetectByteExtractTest35);
4149 UtRegisterTest(
"DetectByteExtractTest36", DetectByteExtractTest36);
4150 UtRegisterTest(
"DetectByteExtractTest37", DetectByteExtractTest37);
4151 UtRegisterTest(
"DetectByteExtractTest38", DetectByteExtractTest38);
4152 UtRegisterTest(
"DetectByteExtractTest39", DetectByteExtractTest39);
4153 UtRegisterTest(
"DetectByteExtractTest40", DetectByteExtractTest40);
4154 UtRegisterTest(
"DetectByteExtractTest41", DetectByteExtractTest41);
4155 UtRegisterTest(
"DetectByteExtractTest42", DetectByteExtractTest42);
4157 UtRegisterTest(
"DetectByteExtractTest43", DetectByteExtractTest43);
4158 UtRegisterTest(
"DetectByteExtractTest44", DetectByteExtractTest44);
4160 UtRegisterTest(
"DetectByteExtractTest45", DetectByteExtractTest45);
4161 UtRegisterTest(
"DetectByteExtractTest46", DetectByteExtractTest46);
4163 UtRegisterTest(
"DetectByteExtractTest47", DetectByteExtractTest47);
4164 UtRegisterTest(
"DetectByteExtractTest48", DetectByteExtractTest48);
4166 UtRegisterTest(
"DetectByteExtractTest49", DetectByteExtractTest49);
4167 UtRegisterTest(
"DetectByteExtractTest50", DetectByteExtractTest50);
4169 UtRegisterTest(
"DetectByteExtractTest51", DetectByteExtractTest51);
4170 UtRegisterTest(
"DetectByteExtractTest52", DetectByteExtractTest52);
4172 UtRegisterTest(
"DetectByteExtractTest53", DetectByteExtractTest53);
4173 UtRegisterTest(
"DetectByteExtractTest54", DetectByteExtractTest54);
4175 UtRegisterTest(
"DetectByteExtractTest55", DetectByteExtractTest55);
4176 UtRegisterTest(
"DetectByteExtractTest56", DetectByteExtractTest56);
4177 UtRegisterTest(
"DetectByteExtractTest57", DetectByteExtractTest57);
4179 UtRegisterTest(
"DetectByteExtractTest58", DetectByteExtractTest58);
4180 UtRegisterTest(
"DetectByteExtractTest59", DetectByteExtractTest59);
4181 UtRegisterTest(
"DetectByteExtractTest60", DetectByteExtractTest60);
4182 UtRegisterTest(
"DetectByteExtractTest61", DetectByteExtractTest61);
4183 UtRegisterTest(
"DetectByteExtractTest62", DetectByteExtractTest62);
4184 UtRegisterTest(
"DetectByteExtractTest63", DetectByteExtractTest63);
4187 DetectByteExtractTestParseNoBase);