49 static int IPV4OptValidateGeneric(
Packet *p,
const IPV4Opt *o)
116 if (
unlikely((ptr < 4) || (ptr % 4) || (ptr > o->
len + 1))) {
131 static int IPV4OptValidateTimestamp(
Packet *p,
const IPV4Opt *o)
155 flag = *(o->
data + 1) & 0x0f;
158 rec_size = ((flag == 1) || (flag == 3)) ? 8 : 4;
164 if (
unlikely(((ptr - 5) % rec_size) || (ptr > o->
len + 1))) {
301 for (i = 0; i <
len; i++) {
321 SCLogDebug(
"IPV4OPT %" PRIu8
" len 1 @ %d/%d",
322 *pkt, (
len - plen), (
len - 1));
326 SCLogDebug(
"IPV4OPT %" PRIu8
" len 1 @ %d/%d",
327 *pkt, (
len - plen), (
len - 1));
348 IPV4Opt opt = {*pkt, *(pkt+1), plen > 2 ? (pkt + 2) : NULL };
366 }
else if (IPV4OptValidateTimestamp(p, &opt) == 0) {
375 }
else if (IPV4OptValidateRoute(p, &opt) == 0) {
384 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
393 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
402 }
else if (IPV4OptValidateRoute(p, &opt) == 0) {
411 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
420 }
else if (IPV4OptValidateCIPSO(p, &opt) == 0) {
429 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
438 }
else if (IPV4OptValidateRoute(p, &opt) == 0) {
447 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
453 SCLogDebug(
"IPV4OPT <unknown> (%" PRIu8
") len %" PRIu8,
468 static const IPV4Hdr *DecodeIPV4Packet(
Packet *p,
const uint8_t *pkt, uint16_t
len)
481 const IPV4Hdr *ip4h = PacketSetIPV4(p, pkt);
504 if (ip_opt_len > 0) {
506 memset(&opts, 0x00,
sizeof(opts));
507 if (DecodeIPV4Options(p, pkt +
IPV4_HEADER_LEN, ip_opt_len, &opts) < 0) {
516 const uint8_t *pkt, uint16_t
len)
522 if (!PacketIncreaseCheckLayers(p)) {
526 const IPV4Hdr *ip4h = DecodeIPV4Packet(p, pkt,
len);
552 SCLogDebug(
"IPV4 %s->%s PROTO: %" PRIu32
" OFFSET: %" PRIu32
" RF: %" PRIu8
" DF: %" PRIu8
553 " MF: %" PRIu8
" ID: %" PRIu32
"",
632 static int DecodeIPV4OptionsNONETest01(
void)
634 uint8_t raw_opts[] = { };
639 memset(&opts, 0x00,
sizeof(opts));
640 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
648 static int DecodeIPV4OptionsEOLTest01(
void)
650 uint8_t raw_opts[] = {
656 memset(&opts, 0x00,
sizeof(opts));
657 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
664 static int DecodeIPV4OptionsNOPTest01(
void)
666 uint8_t raw_opts[] = {
672 memset(&opts, 0x00,
sizeof(opts));
673 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
680 static int DecodeIPV4OptionsRRTest01(
void)
682 uint8_t raw_opts[] = {
683 IPV4_OPT_RR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
684 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
685 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
686 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
687 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
693 memset(&opts, 0x00,
sizeof(opts));
694 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
702 static int DecodeIPV4OptionsRRTest02(
void)
704 uint8_t raw_opts[] = {
705 IPV4_OPT_RR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
706 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
707 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
708 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
709 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
715 memset(&opts, 0x00,
sizeof(opts));
716 FAIL_IF(DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts) != -1);
724 static int DecodeIPV4OptionsRRTest03(
void)
726 uint8_t raw_opts[] = {
727 IPV4_OPT_RR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
728 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
729 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
730 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
731 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
737 memset(&opts, 0x00,
sizeof(opts));
738 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
746 static int DecodeIPV4OptionsRRTest04(
void)
748 uint8_t raw_opts[] = {
749 IPV4_OPT_RR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
750 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
751 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
752 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
753 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
759 memset(&opts, 0x00,
sizeof(opts));
760 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
768 static int DecodeIPV4OptionsQSTest01(
void)
770 uint8_t raw_opts[] = {
771 IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
777 memset(&opts, 0x00,
sizeof(opts));
778 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
786 static int DecodeIPV4OptionsQSTest02(
void)
788 uint8_t raw_opts[] = {
789 IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
795 memset(&opts, 0x00,
sizeof(opts));
796 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
804 static int DecodeIPV4OptionsTSTest01(
void)
806 uint8_t raw_opts[] = {
807 IPV4_OPT_TS, 0x24, 0x0d, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
808 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
809 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
810 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
811 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
817 memset(&opts, 0x00,
sizeof(opts));
818 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
826 static int DecodeIPV4OptionsTSTest02(
void)
828 uint8_t raw_opts[] = {
829 IPV4_OPT_TS, 0x24, 0x04, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
830 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
831 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
832 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
833 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
839 memset(&opts, 0x00,
sizeof(opts));
840 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
848 static int DecodeIPV4OptionsTSTest03(
void)
850 uint8_t raw_opts[] = {
851 IPV4_OPT_TS, 0x24, 0xff, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
852 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
853 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
854 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
855 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
861 memset(&opts, 0x00,
sizeof(opts));
862 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
870 static int DecodeIPV4OptionsTSTest04(
void)
872 uint8_t raw_opts[] = {
873 IPV4_OPT_TS, 0x24, 0x0a, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
874 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
875 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
876 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
877 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
883 memset(&opts, 0x00,
sizeof(opts));
884 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
892 static int DecodeIPV4OptionsSECTest01(
void)
894 uint8_t raw_opts[] = {
896 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
902 memset(&opts, 0x00,
sizeof(opts));
903 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
911 static int DecodeIPV4OptionsSECTest02(
void)
913 uint8_t raw_opts[] = {
IPV4_OPT_SEC, 0x02, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
914 0x00, 0x00, 0x00, 0x00, 0x00 };
919 memset(&opts, 0x00,
sizeof(opts));
920 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
928 static int DecodeIPV4OptionsESECTest01(
void)
930 uint8_t raw_opts[] = {
IPV4_OPT_ESEC, 0x0b, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
931 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
936 memset(&opts, 0x00,
sizeof(opts));
937 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
945 static int DecodeIPV4OptionsESECTest02(
void)
947 uint8_t raw_opts[] = {
IPV4_OPT_ESEC, 0x02, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
948 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
953 memset(&opts, 0x00,
sizeof(opts));
954 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
962 static int DecodeIPV4OptionsLSRRTest01(
void)
964 uint8_t raw_opts[] = {
966 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
967 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
968 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
969 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
975 memset(&opts, 0x00,
sizeof(opts));
976 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
984 static int DecodeIPV4OptionsLSRRTest02(
void)
986 uint8_t raw_opts[] = {
988 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
989 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
990 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
991 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
997 memset(&opts, 0x00,
sizeof(opts));
998 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1006 static int DecodeIPV4OptionsLSRRTest03(
void)
1008 uint8_t raw_opts[] = {
1010 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1011 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1012 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1013 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1019 memset(&opts, 0x00,
sizeof(opts));
1020 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1028 static int DecodeIPV4OptionsLSRRTest04(
void)
1030 uint8_t raw_opts[] = {
1032 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1033 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1034 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1035 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1041 memset(&opts, 0x00,
sizeof(opts));
1042 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1050 static int DecodeIPV4OptionsCIPSOTest01(
void)
1052 uint8_t raw_opts[] = {
1054 0x00, 0x03, 0x00, 0xef, 0x00, 0xef, 0x00, 0x06,
1055 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
1061 memset(&opts, 0x00,
sizeof(opts));
1062 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1070 static int DecodeIPV4OptionsSIDTest01(
void)
1072 uint8_t raw_opts[] = {
1079 memset(&opts, 0x00,
sizeof(opts));
1080 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1088 static int DecodeIPV4OptionsSIDTest02(
void)
1090 uint8_t raw_opts[] = {
1097 memset(&opts, 0x00,
sizeof(opts));
1098 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1106 static int DecodeIPV4OptionsSSRRTest01(
void)
1108 uint8_t raw_opts[] = {
1110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1119 memset(&opts, 0x00,
sizeof(opts));
1120 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1128 static int DecodeIPV4OptionsSSRRTest02(
void)
1130 uint8_t raw_opts[] = {
1132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1141 memset(&opts, 0x00,
sizeof(opts));
1142 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1150 static int DecodeIPV4OptionsSSRRTest03(
void)
1152 uint8_t raw_opts[] = {
1154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1163 memset(&opts, 0x00,
sizeof(opts));
1164 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1172 static int DecodeIPV4OptionsSSRRTest04(
void)
1174 uint8_t raw_opts[] = {
1176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1185 memset(&opts, 0x00,
sizeof(opts));
1186 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1194 static int DecodeIPV4OptionsRTRALTTest01(
void)
1196 uint8_t raw_opts[] = {
1203 memset(&opts, 0x00,
sizeof(opts));
1204 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1212 static int DecodeIPV4OptionsRTRALTTest02(
void)
1214 uint8_t raw_opts[] = {
1221 memset(&opts, 0x00,
sizeof(opts));
1222 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1229 static int IPV4CalculateValidChecksumtest01(
void)
1233 uint8_t raw_ipv4[] = {
1234 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1235 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1236 0xc0, 0xa8, 0x01, 0x03};
1238 csum = *( ((uint16_t *)raw_ipv4) + 5);
1240 FAIL_IF(IPV4Checksum((uint16_t *)raw_ipv4,
sizeof(raw_ipv4), csum) != 0);
1244 static int IPV4CalculateInvalidChecksumtest02(
void)
1248 uint8_t raw_ipv4[] = {
1249 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1250 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1251 0xc0, 0xa8, 0x01, 0x07};
1253 csum = *( ((uint16_t *)raw_ipv4) + 5);
1255 FAIL_IF(IPV4Checksum((uint16_t *)raw_ipv4,
sizeof(raw_ipv4), csum) == 0);
1262 static int DecodeIPV4DefragTest01(
void)
1265 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1266 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1267 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1268 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1269 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1273 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1274 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1275 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x01, 0x40, 0x06,
1276 0x9a, 0xc7, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1277 0xe1, 0x0c, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1281 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1282 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1283 0x00, 0x18, 0xe9, 0xef, 0x00, 0x02, 0x40, 0x06,
1284 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1285 0xe1, 0x0c, 0xb1, 0xa3, 0x00, 0x00
1287 uint8_t tunnel_pkt[] = {
1288 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1289 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1290 0x00, 0x28, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1291 0xba, 0xbc, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1292 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1293 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1294 0x80, 0x00, 0xb1, 0xa3, 0x00, 0x00
1345 static int DecodeIPV4DefragTest02(
void)
1348 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1349 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1350 0x00, 0x24, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1351 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1354 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1355 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1359 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1360 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1361 0x00, 0x2c, 0xe9, 0xef, 0x20, 0x02, 0x40, 0x06,
1362 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1365 0xb1, 0xa3, 0x00, 0x10, 0x5b, 0xa3, 0x81, 0x5e,
1366 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1367 0xb1, 0xa3, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04
1370 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1371 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1372 0x00, 0x16, 0xe9, 0xef, 0x00, 0x05, 0x40, 0x06,
1373 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1379 uint8_t tunnel_pkt[] = {
1380 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1381 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1382 0x00, 0x3e, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1383 0xba, 0xae, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1385 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3, 0x81, 0x5e,
1386 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1387 0xb1, 0xa3, 0x00, 0x10, 0x5b, 0xa3, 0x81, 0x5e,
1388 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1389 0xb1, 0xa3, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04,
1441 static int DecodeIPV4DefragTest03(
void)
1444 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1445 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1446 0x00, 0x28, 0xe9, 0xee, 0x00, 0x00, 0x40, 0x06,
1447 0xba, 0xbd, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1448 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1449 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02,
1450 0x80, 0x00, 0x0c, 0xee, 0x00, 0x00
1453 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1454 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1455 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1456 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1457 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1461 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1462 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1463 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x01, 0x40, 0x06,
1464 0x9a, 0xc7, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1465 0xe1, 0x0c, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1469 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1470 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1471 0x00, 0x18, 0xe9, 0xef, 0x00, 0x02, 0x40, 0x06,
1472 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1473 0xe1, 0x0c, 0xb1, 0xa3, 0x00, 0x00
1475 uint8_t tunnel_pkt[] = {
1476 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1477 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1478 0x00, 0x28, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1479 0xba, 0xbc, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1480 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1481 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1482 0x80, 0x00, 0xb1, 0xa3, 0x00, 0x00
1540 static int DecodeEthernetTestIPv4Opt(
void)
1542 uint8_t raw_eth[] = {
1543 0xae, 0x71, 0x00, 0x00, 0x00, 0x4b, 0x06, 0x90, 0x61, 0x02, 0x00, 0xcd, 0x88, 0x64, 0x11, 0x00,
1544 0x15, 0x00, 0x80, 0x64, 0x00, 0x21, 0x4c, 0x00, 0x00, 0x30, 0x42, 0xd6, 0xff, 0xff, 0xbd, 0x2f,
1545 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1546 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1547 0x01, 0x44, 0x05, 0x22, 0x02, 0x01
1572 UtRegisterTest(
"DecodeIPV4OptionsNONETest01", DecodeIPV4OptionsNONETest01);
1573 UtRegisterTest(
"DecodeIPV4OptionsEOLTest01", DecodeIPV4OptionsEOLTest01);
1574 UtRegisterTest(
"DecodeIPV4OptionsNOPTest01", DecodeIPV4OptionsNOPTest01);
1575 UtRegisterTest(
"DecodeIPV4OptionsRRTest01", DecodeIPV4OptionsRRTest01);
1576 UtRegisterTest(
"DecodeIPV4OptionsRRTest02", DecodeIPV4OptionsRRTest02);
1577 UtRegisterTest(
"DecodeIPV4OptionsRRTest03", DecodeIPV4OptionsRRTest03);
1578 UtRegisterTest(
"DecodeIPV4OptionsRRTest04", DecodeIPV4OptionsRRTest04);
1579 UtRegisterTest(
"DecodeIPV4OptionsQSTest01", DecodeIPV4OptionsQSTest01);
1580 UtRegisterTest(
"DecodeIPV4OptionsQSTest02", DecodeIPV4OptionsQSTest02);
1581 UtRegisterTest(
"DecodeIPV4OptionsTSTest01", DecodeIPV4OptionsTSTest01);
1582 UtRegisterTest(
"DecodeIPV4OptionsTSTest02", DecodeIPV4OptionsTSTest02);
1583 UtRegisterTest(
"DecodeIPV4OptionsTSTest03", DecodeIPV4OptionsTSTest03);
1584 UtRegisterTest(
"DecodeIPV4OptionsTSTest04", DecodeIPV4OptionsTSTest04);
1585 UtRegisterTest(
"DecodeIPV4OptionsSECTest01", DecodeIPV4OptionsSECTest01);
1586 UtRegisterTest(
"DecodeIPV4OptionsSECTest02", DecodeIPV4OptionsSECTest02);
1587 UtRegisterTest(
"DecodeIPV4OptionsESECTest01", DecodeIPV4OptionsESECTest01);
1588 UtRegisterTest(
"DecodeIPV4OptionsESECTest02", DecodeIPV4OptionsESECTest02);
1589 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest01", DecodeIPV4OptionsLSRRTest01);
1590 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest02", DecodeIPV4OptionsLSRRTest02);
1591 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest03", DecodeIPV4OptionsLSRRTest03);
1592 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest04", DecodeIPV4OptionsLSRRTest04);
1594 DecodeIPV4OptionsCIPSOTest01);
1595 UtRegisterTest(
"DecodeIPV4OptionsSIDTest01", DecodeIPV4OptionsSIDTest01);
1596 UtRegisterTest(
"DecodeIPV4OptionsSIDTest02", DecodeIPV4OptionsSIDTest02);
1597 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest01", DecodeIPV4OptionsSSRRTest01);
1598 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest02", DecodeIPV4OptionsSSRRTest02);
1599 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest03", DecodeIPV4OptionsSSRRTest03);
1600 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest04", DecodeIPV4OptionsSSRRTest04);
1602 DecodeIPV4OptionsRTRALTTest01);
1604 DecodeIPV4OptionsRTRALTTest02);
1606 IPV4CalculateValidChecksumtest01);
1608 IPV4CalculateInvalidChecksumtest02);
1609 UtRegisterTest(
"DecodeIPV4DefragTest01", DecodeIPV4DefragTest01);
1610 UtRegisterTest(
"DecodeIPV4DefragTest02", DecodeIPV4DefragTest02);
1611 UtRegisterTest(
"DecodeIPV4DefragTest03", DecodeIPV4DefragTest03);
1612 UtRegisterTest(
"DecodeEthernetTestIPv4Opt", DecodeEthernetTestIPv4Opt);