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))) {
306 for (i = 0; i <
len; i++) {
326 SCLogDebug(
"IPV4OPT %" PRIu8
" len 1 @ %d/%d",
327 *pkt, (
len - plen), (
len - 1));
331 SCLogDebug(
"IPV4OPT %" PRIu8
" len 1 @ %d/%d",
332 *pkt, (
len - plen), (
len - 1));
353 IPV4Opt opt = {*pkt, *(pkt+1), plen > 2 ? (pkt + 2) : NULL };
371 }
else if (IPV4OptValidateTimestamp(p, &opt) == 0) {
380 }
else if (IPV4OptValidateRoute(p, &opt) == 0) {
389 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
398 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
407 }
else if (IPV4OptValidateRoute(p, &opt) == 0) {
416 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
425 }
else if (IPV4OptValidateCIPSO(p, &opt) == 0) {
434 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
443 }
else if (IPV4OptValidateRoute(p, &opt) == 0) {
452 }
else if (IPV4OptValidateGeneric(p, &opt) == 0) {
458 SCLogDebug(
"IPV4OPT <unknown> (%" PRIu8
") len %" PRIu8,
473 static const IPV4Hdr *DecodeIPV4Packet(
Packet *p,
const uint8_t *pkt, uint16_t
len)
486 const IPV4Hdr *ip4h = PacketSetIPV4(p, pkt);
509 if (ip_opt_len > 0) {
511 memset(&opts, 0x00,
sizeof(opts));
512 if (DecodeIPV4Options(p, pkt +
IPV4_HEADER_LEN, ip_opt_len, &opts) < 0) {
521 const uint8_t *pkt, uint16_t
len)
527 if (!PacketIncreaseCheckLayers(p)) {
531 const IPV4Hdr *ip4h = DecodeIPV4Packet(p, pkt,
len);
557 SCLogDebug(
"IPV4 %s->%s PROTO: %" PRIu32
" OFFSET: %" PRIu32
" RF: %" PRIu8
" DF: %" PRIu8
558 " MF: %" PRIu8
" ID: %" PRIu32
"",
618 static int DecodeIPV4OptionsNONETest01(
void)
620 uint8_t raw_opts[] = { };
625 memset(&opts, 0x00,
sizeof(opts));
626 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
634 static int DecodeIPV4OptionsEOLTest01(
void)
636 uint8_t raw_opts[] = {
642 memset(&opts, 0x00,
sizeof(opts));
643 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
650 static int DecodeIPV4OptionsNOPTest01(
void)
652 uint8_t raw_opts[] = {
658 memset(&opts, 0x00,
sizeof(opts));
659 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
666 static int DecodeIPV4OptionsRRTest01(
void)
668 uint8_t raw_opts[] = {
669 IPV4_OPT_RR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
670 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
671 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
672 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
673 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
679 memset(&opts, 0x00,
sizeof(opts));
680 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
688 static int DecodeIPV4OptionsRRTest02(
void)
690 uint8_t raw_opts[] = {
691 IPV4_OPT_RR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
692 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
693 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
694 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
695 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
701 memset(&opts, 0x00,
sizeof(opts));
702 FAIL_IF(DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts) != -1);
710 static int DecodeIPV4OptionsRRTest03(
void)
712 uint8_t raw_opts[] = {
713 IPV4_OPT_RR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
714 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
715 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
716 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
717 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
723 memset(&opts, 0x00,
sizeof(opts));
724 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
732 static int DecodeIPV4OptionsRRTest04(
void)
734 uint8_t raw_opts[] = {
735 IPV4_OPT_RR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
736 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
737 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
738 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
739 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
745 memset(&opts, 0x00,
sizeof(opts));
746 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
754 static int DecodeIPV4OptionsQSTest01(
void)
756 uint8_t raw_opts[] = {
757 IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
763 memset(&opts, 0x00,
sizeof(opts));
764 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
772 static int DecodeIPV4OptionsQSTest02(
void)
774 uint8_t raw_opts[] = {
775 IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
781 memset(&opts, 0x00,
sizeof(opts));
782 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
790 static int DecodeIPV4OptionsTSTest01(
void)
792 uint8_t raw_opts[] = {
793 IPV4_OPT_TS, 0x24, 0x0d, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
794 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
795 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
796 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
797 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
803 memset(&opts, 0x00,
sizeof(opts));
804 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
812 static int DecodeIPV4OptionsTSTest02(
void)
814 uint8_t raw_opts[] = {
815 IPV4_OPT_TS, 0x24, 0x04, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
816 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
817 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
818 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
819 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
825 memset(&opts, 0x00,
sizeof(opts));
826 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
834 static int DecodeIPV4OptionsTSTest03(
void)
836 uint8_t raw_opts[] = {
837 IPV4_OPT_TS, 0x24, 0xff, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
838 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
839 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
840 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
841 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
847 memset(&opts, 0x00,
sizeof(opts));
848 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
856 static int DecodeIPV4OptionsTSTest04(
void)
858 uint8_t raw_opts[] = {
859 IPV4_OPT_TS, 0x24, 0x0a, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
860 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
861 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
862 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
863 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
869 memset(&opts, 0x00,
sizeof(opts));
870 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
878 static int DecodeIPV4OptionsSECTest01(
void)
880 uint8_t raw_opts[] = {
882 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
888 memset(&opts, 0x00,
sizeof(opts));
889 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
897 static int DecodeIPV4OptionsSECTest02(
void)
899 uint8_t raw_opts[] = {
IPV4_OPT_SEC, 0x02, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
900 0x00, 0x00, 0x00, 0x00, 0x00 };
905 memset(&opts, 0x00,
sizeof(opts));
906 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
914 static int DecodeIPV4OptionsESECTest01(
void)
916 uint8_t raw_opts[] = {
IPV4_OPT_ESEC, 0x0b, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
917 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
922 memset(&opts, 0x00,
sizeof(opts));
923 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
931 static int DecodeIPV4OptionsESECTest02(
void)
933 uint8_t raw_opts[] = {
IPV4_OPT_ESEC, 0x02, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
934 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
939 memset(&opts, 0x00,
sizeof(opts));
940 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
948 static int DecodeIPV4OptionsLSRRTest01(
void)
950 uint8_t raw_opts[] = {
952 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
953 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
954 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
955 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
961 memset(&opts, 0x00,
sizeof(opts));
962 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
970 static int DecodeIPV4OptionsLSRRTest02(
void)
972 uint8_t raw_opts[] = {
974 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
975 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
976 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
977 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
983 memset(&opts, 0x00,
sizeof(opts));
984 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
992 static int DecodeIPV4OptionsLSRRTest03(
void)
994 uint8_t raw_opts[] = {
996 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
997 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
998 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
999 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1005 memset(&opts, 0x00,
sizeof(opts));
1006 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1014 static int DecodeIPV4OptionsLSRRTest04(
void)
1016 uint8_t raw_opts[] = {
1018 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1019 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1020 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1021 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1027 memset(&opts, 0x00,
sizeof(opts));
1028 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1036 static int DecodeIPV4OptionsCIPSOTest01(
void)
1038 uint8_t raw_opts[] = {
1040 0x00, 0x03, 0x00, 0xef, 0x00, 0xef, 0x00, 0x06,
1041 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
1047 memset(&opts, 0x00,
sizeof(opts));
1048 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1056 static int DecodeIPV4OptionsSIDTest01(
void)
1058 uint8_t raw_opts[] = {
1065 memset(&opts, 0x00,
sizeof(opts));
1066 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1074 static int DecodeIPV4OptionsSIDTest02(
void)
1076 uint8_t raw_opts[] = {
1083 memset(&opts, 0x00,
sizeof(opts));
1084 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1092 static int DecodeIPV4OptionsSSRRTest01(
void)
1094 uint8_t raw_opts[] = {
1096 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1097 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1098 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1099 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1105 memset(&opts, 0x00,
sizeof(opts));
1106 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1114 static int DecodeIPV4OptionsSSRRTest02(
void)
1116 uint8_t raw_opts[] = {
1118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1127 memset(&opts, 0x00,
sizeof(opts));
1128 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1136 static int DecodeIPV4OptionsSSRRTest03(
void)
1138 uint8_t raw_opts[] = {
1140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1149 memset(&opts, 0x00,
sizeof(opts));
1150 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1158 static int DecodeIPV4OptionsSSRRTest04(
void)
1160 uint8_t raw_opts[] = {
1162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1164 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1171 memset(&opts, 0x00,
sizeof(opts));
1172 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1180 static int DecodeIPV4OptionsRTRALTTest01(
void)
1182 uint8_t raw_opts[] = {
1189 memset(&opts, 0x00,
sizeof(opts));
1190 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1198 static int DecodeIPV4OptionsRTRALTTest02(
void)
1200 uint8_t raw_opts[] = {
1207 memset(&opts, 0x00,
sizeof(opts));
1208 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1215 static int IPV4CalculateValidChecksumtest01(
void)
1219 uint8_t raw_ipv4[] = {
1220 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1221 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1222 0xc0, 0xa8, 0x01, 0x03};
1224 csum = *( ((uint16_t *)raw_ipv4) + 5);
1226 FAIL_IF(IPV4Checksum((uint16_t *)raw_ipv4,
sizeof(raw_ipv4), csum) != 0);
1230 static int IPV4CalculateInvalidChecksumtest02(
void)
1234 uint8_t raw_ipv4[] = {
1235 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1236 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1237 0xc0, 0xa8, 0x01, 0x07};
1239 csum = *( ((uint16_t *)raw_ipv4) + 5);
1241 FAIL_IF(IPV4Checksum((uint16_t *)raw_ipv4,
sizeof(raw_ipv4), csum) == 0);
1248 static int DecodeIPV4DefragTest01(
void)
1251 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1252 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1253 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1254 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1255 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1259 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1260 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1261 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x01, 0x40, 0x06,
1262 0x9a, 0xc7, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1263 0xe1, 0x0c, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1267 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1268 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1269 0x00, 0x18, 0xe9, 0xef, 0x00, 0x02, 0x40, 0x06,
1270 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1271 0xe1, 0x0c, 0xb1, 0xa3, 0x00, 0x00
1273 uint8_t tunnel_pkt[] = {
1274 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1275 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1276 0x00, 0x28, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1277 0xba, 0xbc, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1278 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1279 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1280 0x80, 0x00, 0xb1, 0xa3, 0x00, 0x00
1331 static int DecodeIPV4DefragTest02(
void)
1334 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1335 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1336 0x00, 0x24, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1337 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1340 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1341 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1345 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1346 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1347 0x00, 0x2c, 0xe9, 0xef, 0x20, 0x02, 0x40, 0x06,
1348 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1351 0xb1, 0xa3, 0x00, 0x10, 0x5b, 0xa3, 0x81, 0x5e,
1352 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1353 0xb1, 0xa3, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04
1356 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1357 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1358 0x00, 0x16, 0xe9, 0xef, 0x00, 0x05, 0x40, 0x06,
1359 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1365 uint8_t tunnel_pkt[] = {
1366 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1367 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1368 0x00, 0x3e, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1369 0xba, 0xae, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1371 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3, 0x81, 0x5e,
1372 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1373 0xb1, 0xa3, 0x00, 0x10, 0x5b, 0xa3, 0x81, 0x5e,
1374 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1375 0xb1, 0xa3, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04,
1427 static int DecodeIPV4DefragTest03(
void)
1430 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1431 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1432 0x00, 0x28, 0xe9, 0xee, 0x00, 0x00, 0x40, 0x06,
1433 0xba, 0xbd, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1434 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1435 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02,
1436 0x80, 0x00, 0x0c, 0xee, 0x00, 0x00
1439 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1440 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1441 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1442 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1443 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1447 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1448 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1449 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x01, 0x40, 0x06,
1450 0x9a, 0xc7, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1451 0xe1, 0x0c, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1455 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1456 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1457 0x00, 0x18, 0xe9, 0xef, 0x00, 0x02, 0x40, 0x06,
1458 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1459 0xe1, 0x0c, 0xb1, 0xa3, 0x00, 0x00
1461 uint8_t tunnel_pkt[] = {
1462 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1463 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1464 0x00, 0x28, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1465 0xba, 0xbc, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1466 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1467 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1468 0x80, 0x00, 0xb1, 0xa3, 0x00, 0x00
1526 static int DecodeEthernetTestIPv4Opt(
void)
1528 uint8_t raw_eth[] = {
1529 0xae, 0x71, 0x00, 0x00, 0x00, 0x4b, 0x06, 0x90, 0x61, 0x02, 0x00, 0xcd, 0x88, 0x64, 0x11, 0x00,
1530 0x15, 0x00, 0x80, 0x64, 0x00, 0x21, 0x4c, 0x00, 0x00, 0x30, 0x42, 0xd6, 0xff, 0xff, 0xbd, 0x2f,
1531 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1532 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1533 0x01, 0x44, 0x05, 0x22, 0x02, 0x01
1558 UtRegisterTest(
"DecodeIPV4OptionsNONETest01", DecodeIPV4OptionsNONETest01);
1559 UtRegisterTest(
"DecodeIPV4OptionsEOLTest01", DecodeIPV4OptionsEOLTest01);
1560 UtRegisterTest(
"DecodeIPV4OptionsNOPTest01", DecodeIPV4OptionsNOPTest01);
1561 UtRegisterTest(
"DecodeIPV4OptionsRRTest01", DecodeIPV4OptionsRRTest01);
1562 UtRegisterTest(
"DecodeIPV4OptionsRRTest02", DecodeIPV4OptionsRRTest02);
1563 UtRegisterTest(
"DecodeIPV4OptionsRRTest03", DecodeIPV4OptionsRRTest03);
1564 UtRegisterTest(
"DecodeIPV4OptionsRRTest04", DecodeIPV4OptionsRRTest04);
1565 UtRegisterTest(
"DecodeIPV4OptionsQSTest01", DecodeIPV4OptionsQSTest01);
1566 UtRegisterTest(
"DecodeIPV4OptionsQSTest02", DecodeIPV4OptionsQSTest02);
1567 UtRegisterTest(
"DecodeIPV4OptionsTSTest01", DecodeIPV4OptionsTSTest01);
1568 UtRegisterTest(
"DecodeIPV4OptionsTSTest02", DecodeIPV4OptionsTSTest02);
1569 UtRegisterTest(
"DecodeIPV4OptionsTSTest03", DecodeIPV4OptionsTSTest03);
1570 UtRegisterTest(
"DecodeIPV4OptionsTSTest04", DecodeIPV4OptionsTSTest04);
1571 UtRegisterTest(
"DecodeIPV4OptionsSECTest01", DecodeIPV4OptionsSECTest01);
1572 UtRegisterTest(
"DecodeIPV4OptionsSECTest02", DecodeIPV4OptionsSECTest02);
1573 UtRegisterTest(
"DecodeIPV4OptionsESECTest01", DecodeIPV4OptionsESECTest01);
1574 UtRegisterTest(
"DecodeIPV4OptionsESECTest02", DecodeIPV4OptionsESECTest02);
1575 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest01", DecodeIPV4OptionsLSRRTest01);
1576 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest02", DecodeIPV4OptionsLSRRTest02);
1577 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest03", DecodeIPV4OptionsLSRRTest03);
1578 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest04", DecodeIPV4OptionsLSRRTest04);
1580 DecodeIPV4OptionsCIPSOTest01);
1581 UtRegisterTest(
"DecodeIPV4OptionsSIDTest01", DecodeIPV4OptionsSIDTest01);
1582 UtRegisterTest(
"DecodeIPV4OptionsSIDTest02", DecodeIPV4OptionsSIDTest02);
1583 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest01", DecodeIPV4OptionsSSRRTest01);
1584 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest02", DecodeIPV4OptionsSSRRTest02);
1585 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest03", DecodeIPV4OptionsSSRRTest03);
1586 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest04", DecodeIPV4OptionsSSRRTest04);
1588 DecodeIPV4OptionsRTRALTTest01);
1590 DecodeIPV4OptionsRTRALTTest02);
1592 IPV4CalculateValidChecksumtest01);
1594 IPV4CalculateInvalidChecksumtest02);
1595 UtRegisterTest(
"DecodeIPV4DefragTest01", DecodeIPV4DefragTest01);
1596 UtRegisterTest(
"DecodeIPV4DefragTest02", DecodeIPV4DefragTest02);
1597 UtRegisterTest(
"DecodeIPV4DefragTest03", DecodeIPV4DefragTest03);
1598 UtRegisterTest(
"DecodeEthernetTestIPv4Opt", DecodeEthernetTestIPv4Opt);