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
"",
627 static int DecodeIPV4OptionsNONETest01(
void)
629 uint8_t raw_opts[] = { };
634 memset(&opts, 0x00,
sizeof(opts));
635 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
643 static int DecodeIPV4OptionsEOLTest01(
void)
645 uint8_t raw_opts[] = {
651 memset(&opts, 0x00,
sizeof(opts));
652 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
659 static int DecodeIPV4OptionsNOPTest01(
void)
661 uint8_t raw_opts[] = {
667 memset(&opts, 0x00,
sizeof(opts));
668 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
675 static int DecodeIPV4OptionsRRTest01(
void)
677 uint8_t raw_opts[] = {
678 IPV4_OPT_RR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
679 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
680 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
681 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
682 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
688 memset(&opts, 0x00,
sizeof(opts));
689 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
697 static int DecodeIPV4OptionsRRTest02(
void)
699 uint8_t raw_opts[] = {
700 IPV4_OPT_RR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
701 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
702 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
703 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
704 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
710 memset(&opts, 0x00,
sizeof(opts));
711 FAIL_IF(DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts) != -1);
719 static int DecodeIPV4OptionsRRTest03(
void)
721 uint8_t raw_opts[] = {
722 IPV4_OPT_RR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
723 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
724 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
725 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
726 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
732 memset(&opts, 0x00,
sizeof(opts));
733 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
741 static int DecodeIPV4OptionsRRTest04(
void)
743 uint8_t raw_opts[] = {
744 IPV4_OPT_RR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
745 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
746 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
747 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
748 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
754 memset(&opts, 0x00,
sizeof(opts));
755 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
763 static int DecodeIPV4OptionsQSTest01(
void)
765 uint8_t raw_opts[] = {
766 IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
772 memset(&opts, 0x00,
sizeof(opts));
773 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
781 static int DecodeIPV4OptionsQSTest02(
void)
783 uint8_t raw_opts[] = {
784 IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
790 memset(&opts, 0x00,
sizeof(opts));
791 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
799 static int DecodeIPV4OptionsTSTest01(
void)
801 uint8_t raw_opts[] = {
802 IPV4_OPT_TS, 0x24, 0x0d, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
803 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
804 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
805 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
806 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
812 memset(&opts, 0x00,
sizeof(opts));
813 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
821 static int DecodeIPV4OptionsTSTest02(
void)
823 uint8_t raw_opts[] = {
824 IPV4_OPT_TS, 0x24, 0x04, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
825 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
826 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
827 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
828 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
834 memset(&opts, 0x00,
sizeof(opts));
835 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
843 static int DecodeIPV4OptionsTSTest03(
void)
845 uint8_t raw_opts[] = {
846 IPV4_OPT_TS, 0x24, 0xff, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
847 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
848 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
849 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
850 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
856 memset(&opts, 0x00,
sizeof(opts));
857 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
865 static int DecodeIPV4OptionsTSTest04(
void)
867 uint8_t raw_opts[] = {
868 IPV4_OPT_TS, 0x24, 0x0a, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
869 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
870 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
871 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
872 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
878 memset(&opts, 0x00,
sizeof(opts));
879 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
887 static int DecodeIPV4OptionsSECTest01(
void)
889 uint8_t raw_opts[] = {
891 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
897 memset(&opts, 0x00,
sizeof(opts));
898 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
906 static int DecodeIPV4OptionsSECTest02(
void)
908 uint8_t raw_opts[] = {
IPV4_OPT_SEC, 0x02, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
909 0x00, 0x00, 0x00, 0x00, 0x00 };
914 memset(&opts, 0x00,
sizeof(opts));
915 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
923 static int DecodeIPV4OptionsESECTest01(
void)
925 uint8_t raw_opts[] = {
IPV4_OPT_ESEC, 0x0b, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
926 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
931 memset(&opts, 0x00,
sizeof(opts));
932 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
940 static int DecodeIPV4OptionsESECTest02(
void)
942 uint8_t raw_opts[] = {
IPV4_OPT_ESEC, 0x02, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
943 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
948 memset(&opts, 0x00,
sizeof(opts));
949 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
957 static int DecodeIPV4OptionsLSRRTest01(
void)
959 uint8_t raw_opts[] = {
961 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
962 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
963 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
964 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
970 memset(&opts, 0x00,
sizeof(opts));
971 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
979 static int DecodeIPV4OptionsLSRRTest02(
void)
981 uint8_t raw_opts[] = {
983 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
984 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
985 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
986 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
992 memset(&opts, 0x00,
sizeof(opts));
993 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1001 static int DecodeIPV4OptionsLSRRTest03(
void)
1003 uint8_t raw_opts[] = {
1005 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1006 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1007 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1008 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1014 memset(&opts, 0x00,
sizeof(opts));
1015 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1023 static int DecodeIPV4OptionsLSRRTest04(
void)
1025 uint8_t raw_opts[] = {
1027 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1028 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1029 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1030 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1036 memset(&opts, 0x00,
sizeof(opts));
1037 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1045 static int DecodeIPV4OptionsCIPSOTest01(
void)
1047 uint8_t raw_opts[] = {
1049 0x00, 0x03, 0x00, 0xef, 0x00, 0xef, 0x00, 0x06,
1050 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
1056 memset(&opts, 0x00,
sizeof(opts));
1057 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1065 static int DecodeIPV4OptionsSIDTest01(
void)
1067 uint8_t raw_opts[] = {
1074 memset(&opts, 0x00,
sizeof(opts));
1075 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1083 static int DecodeIPV4OptionsSIDTest02(
void)
1085 uint8_t raw_opts[] = {
1092 memset(&opts, 0x00,
sizeof(opts));
1093 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1101 static int DecodeIPV4OptionsSSRRTest01(
void)
1103 uint8_t raw_opts[] = {
1105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1114 memset(&opts, 0x00,
sizeof(opts));
1115 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1123 static int DecodeIPV4OptionsSSRRTest02(
void)
1125 uint8_t raw_opts[] = {
1127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1129 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1130 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1136 memset(&opts, 0x00,
sizeof(opts));
1137 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1145 static int DecodeIPV4OptionsSSRRTest03(
void)
1147 uint8_t raw_opts[] = {
1149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1158 memset(&opts, 0x00,
sizeof(opts));
1159 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1167 static int DecodeIPV4OptionsSSRRTest04(
void)
1169 uint8_t raw_opts[] = {
1171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1180 memset(&opts, 0x00,
sizeof(opts));
1181 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1189 static int DecodeIPV4OptionsRTRALTTest01(
void)
1191 uint8_t raw_opts[] = {
1198 memset(&opts, 0x00,
sizeof(opts));
1199 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1207 static int DecodeIPV4OptionsRTRALTTest02(
void)
1209 uint8_t raw_opts[] = {
1216 memset(&opts, 0x00,
sizeof(opts));
1217 DecodeIPV4Options(p, raw_opts,
sizeof(raw_opts), &opts);
1224 static int IPV4CalculateValidChecksumtest01(
void)
1228 uint8_t raw_ipv4[] = {
1229 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1230 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1231 0xc0, 0xa8, 0x01, 0x03};
1233 csum = *( ((uint16_t *)raw_ipv4) + 5);
1235 FAIL_IF(IPV4Checksum((uint16_t *)raw_ipv4,
sizeof(raw_ipv4), csum) != 0);
1239 static int IPV4CalculateInvalidChecksumtest02(
void)
1243 uint8_t raw_ipv4[] = {
1244 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1245 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1246 0xc0, 0xa8, 0x01, 0x07};
1248 csum = *( ((uint16_t *)raw_ipv4) + 5);
1250 FAIL_IF(IPV4Checksum((uint16_t *)raw_ipv4,
sizeof(raw_ipv4), csum) == 0);
1257 static int DecodeIPV4DefragTest01(
void)
1260 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1261 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1262 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1263 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1264 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1268 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1269 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1270 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x01, 0x40, 0x06,
1271 0x9a, 0xc7, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1272 0xe1, 0x0c, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1276 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1277 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1278 0x00, 0x18, 0xe9, 0xef, 0x00, 0x02, 0x40, 0x06,
1279 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1280 0xe1, 0x0c, 0xb1, 0xa3, 0x00, 0x00
1282 uint8_t tunnel_pkt[] = {
1283 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1284 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1285 0x00, 0x28, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1286 0xba, 0xbc, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1287 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1288 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1289 0x80, 0x00, 0xb1, 0xa3, 0x00, 0x00
1340 static int DecodeIPV4DefragTest02(
void)
1343 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1344 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1345 0x00, 0x24, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1346 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1349 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1350 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1354 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1355 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1356 0x00, 0x2c, 0xe9, 0xef, 0x20, 0x02, 0x40, 0x06,
1357 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1360 0xb1, 0xa3, 0x00, 0x10, 0x5b, 0xa3, 0x81, 0x5e,
1361 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1362 0xb1, 0xa3, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04
1365 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1366 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1367 0x00, 0x16, 0xe9, 0xef, 0x00, 0x05, 0x40, 0x06,
1368 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1374 uint8_t tunnel_pkt[] = {
1375 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1376 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1377 0x00, 0x3e, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1378 0xba, 0xae, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1380 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3, 0x81, 0x5e,
1381 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1382 0xb1, 0xa3, 0x00, 0x10, 0x5b, 0xa3, 0x81, 0x5e,
1383 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10, 0x80, 0x00,
1384 0xb1, 0xa3, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04,
1436 static int DecodeIPV4DefragTest03(
void)
1439 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1440 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1441 0x00, 0x28, 0xe9, 0xee, 0x00, 0x00, 0x40, 0x06,
1442 0xba, 0xbd, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1443 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1444 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02,
1445 0x80, 0x00, 0x0c, 0xee, 0x00, 0x00
1448 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1449 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1450 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x00, 0x40, 0x06,
1451 0x9a, 0xc8, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1452 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1456 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1457 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1458 0x00, 0x1c, 0xe9, 0xef, 0x20, 0x01, 0x40, 0x06,
1459 0x9a, 0xc7, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1460 0xe1, 0x0c, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1464 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1465 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1466 0x00, 0x18, 0xe9, 0xef, 0x00, 0x02, 0x40, 0x06,
1467 0xba, 0xca, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1468 0xe1, 0x0c, 0xb1, 0xa3, 0x00, 0x00
1470 uint8_t tunnel_pkt[] = {
1471 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
1472 0x01, 0xa3, 0xa2, 0x2f, 0x08, 0x00, 0x45, 0x00,
1473 0x00, 0x28, 0xe9, 0xef, 0x00, 0x00, 0x40, 0x06,
1474 0xba, 0xbc, 0x0a, 0x00, 0xe1, 0x17, 0x0a, 0x00,
1475 0xe1, 0x0c, 0x6e, 0x12, 0x01, 0xbd, 0x5b, 0xa3,
1476 0x81, 0x5e, 0xac, 0xb0, 0xae, 0x8a, 0x50, 0x10,
1477 0x80, 0x00, 0xb1, 0xa3, 0x00, 0x00
1535 static int DecodeEthernetTestIPv4Opt(
void)
1537 uint8_t raw_eth[] = {
1538 0xae, 0x71, 0x00, 0x00, 0x00, 0x4b, 0x06, 0x90, 0x61, 0x02, 0x00, 0xcd, 0x88, 0x64, 0x11, 0x00,
1539 0x15, 0x00, 0x80, 0x64, 0x00, 0x21, 0x4c, 0x00, 0x00, 0x30, 0x42, 0xd6, 0xff, 0xff, 0xbd, 0x2f,
1540 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1541 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1542 0x01, 0x44, 0x05, 0x22, 0x02, 0x01
1567 UtRegisterTest(
"DecodeIPV4OptionsNONETest01", DecodeIPV4OptionsNONETest01);
1568 UtRegisterTest(
"DecodeIPV4OptionsEOLTest01", DecodeIPV4OptionsEOLTest01);
1569 UtRegisterTest(
"DecodeIPV4OptionsNOPTest01", DecodeIPV4OptionsNOPTest01);
1570 UtRegisterTest(
"DecodeIPV4OptionsRRTest01", DecodeIPV4OptionsRRTest01);
1571 UtRegisterTest(
"DecodeIPV4OptionsRRTest02", DecodeIPV4OptionsRRTest02);
1572 UtRegisterTest(
"DecodeIPV4OptionsRRTest03", DecodeIPV4OptionsRRTest03);
1573 UtRegisterTest(
"DecodeIPV4OptionsRRTest04", DecodeIPV4OptionsRRTest04);
1574 UtRegisterTest(
"DecodeIPV4OptionsQSTest01", DecodeIPV4OptionsQSTest01);
1575 UtRegisterTest(
"DecodeIPV4OptionsQSTest02", DecodeIPV4OptionsQSTest02);
1576 UtRegisterTest(
"DecodeIPV4OptionsTSTest01", DecodeIPV4OptionsTSTest01);
1577 UtRegisterTest(
"DecodeIPV4OptionsTSTest02", DecodeIPV4OptionsTSTest02);
1578 UtRegisterTest(
"DecodeIPV4OptionsTSTest03", DecodeIPV4OptionsTSTest03);
1579 UtRegisterTest(
"DecodeIPV4OptionsTSTest04", DecodeIPV4OptionsTSTest04);
1580 UtRegisterTest(
"DecodeIPV4OptionsSECTest01", DecodeIPV4OptionsSECTest01);
1581 UtRegisterTest(
"DecodeIPV4OptionsSECTest02", DecodeIPV4OptionsSECTest02);
1582 UtRegisterTest(
"DecodeIPV4OptionsESECTest01", DecodeIPV4OptionsESECTest01);
1583 UtRegisterTest(
"DecodeIPV4OptionsESECTest02", DecodeIPV4OptionsESECTest02);
1584 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest01", DecodeIPV4OptionsLSRRTest01);
1585 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest02", DecodeIPV4OptionsLSRRTest02);
1586 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest03", DecodeIPV4OptionsLSRRTest03);
1587 UtRegisterTest(
"DecodeIPV4OptionsLSRRTest04", DecodeIPV4OptionsLSRRTest04);
1589 DecodeIPV4OptionsCIPSOTest01);
1590 UtRegisterTest(
"DecodeIPV4OptionsSIDTest01", DecodeIPV4OptionsSIDTest01);
1591 UtRegisterTest(
"DecodeIPV4OptionsSIDTest02", DecodeIPV4OptionsSIDTest02);
1592 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest01", DecodeIPV4OptionsSSRRTest01);
1593 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest02", DecodeIPV4OptionsSSRRTest02);
1594 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest03", DecodeIPV4OptionsSSRRTest03);
1595 UtRegisterTest(
"DecodeIPV4OptionsSSRRTest04", DecodeIPV4OptionsSSRRTest04);
1597 DecodeIPV4OptionsRTRALTTest01);
1599 DecodeIPV4OptionsRTRALTTest02);
1601 IPV4CalculateValidChecksumtest01);
1603 IPV4CalculateInvalidChecksumtest02);
1604 UtRegisterTest(
"DecodeIPV4DefragTest01", DecodeIPV4DefragTest01);
1605 UtRegisterTest(
"DecodeIPV4DefragTest02", DecodeIPV4DefragTest02);
1606 UtRegisterTest(
"DecodeIPV4DefragTest03", DecodeIPV4DefragTest03);
1607 UtRegisterTest(
"DecodeEthernetTestIPv4Opt", DecodeEthernetTestIPv4Opt);