40 #if defined(DEBUG) || defined(UNITTESTS)
41 static inline const IPV6Hdr *PacketGetICMPv6EmbIPv6(
const Packet *p)
44 const uint8_t *start = (
const uint8_t *)PacketGetICMPv6(p);
59 static void DecodePartialIPV6(
Packet *p, uint8_t *partial_packet, uint16_t
len )
71 if(((icmp6_ip6h->s_ip6_vfc & 0xf0) >> 4) != 6)
73 SCLogDebug(
"ICMPv6 contains Unknown IPV6 version "
74 "ICMPV6_IPV6_UNKNOWN_VER");
80 const uint8_t *icmpv6_ptr = (
const uint8_t *)p->
l4.
hdrs.
icmpv6h;
86 switch (icmp6_ip6h->s_ip6_nxt) {
95 "%" PRIu16
" dport %" PRIu16
"",
99 "header Didn't fit in the packet!");
113 "%" PRIu16
" dport %" PRIu16
"",
117 "header Didn't fit in the packet!");
135 PrintInet(AF_INET6, (
const void *)PacketGetICMPv6EmbIPv6(p)->
s_ip6_src, s,
sizeof(s));
136 PrintInet(AF_INET6, (
const void *)PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst, d,
sizeof(d));
137 SCLogDebug(
"ICMPv6 embedding IPV6 %s->%s - CLASS: %" PRIu32
" FLOW: "
138 "%" PRIu32
" NH: %" PRIu32
" PLEN: %" PRIu32
" HLIM: %" PRIu32,
149 #define CASE_CODE(t,r) case (t): return r; case (r): return t;
180 const uint8_t *pkt, uint32_t
len)
182 const IPV6Hdr *ip6h = PacketGetIPv6(p);
192 ICMPV6Hdr *icmpv6h = PacketSetICMPv6(p, pkt);
193 p->
proto = IPPROTO_ICMPV6;
195 const uint8_t code = p->
icmp_s.code = icmpv6h->
code;
202 p->
icmp_d.type = (uint8_t)ctype;
354 if (code > 2 && code != 255) {
444 if (code > 3 && code < 128) {
481 }
else if (
type >= 100 &&
type < 102) {
483 }
else if (
type >= 102 &&
type < 127) {
485 }
else if (
type >= 160 &&
type < 200) {
487 }
else if (
type >= 200 &&
type < 202) {
489 }
else if (
type >= 202) {
503 p->
payload = (uint8_t *)pkt + 4;
512 SCLogDebug(
"Unknown Code, ICMPV6_UNKNOWN_CODE");
515 SCLogDebug(
"Unknown Type, ICMPV6_UNKNOWN_TYPE");
527 static int ICMPV6CalculateValidChecksumtest01(
void)
531 uint8_t raw_ipv6[] = {
532 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60,
533 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00,
534 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe,
535 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60,
536 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe,
537 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
538 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00,
539 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00,
540 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe,
541 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
542 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
543 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
544 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
545 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01,
546 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed,
549 csum = *( ((uint16_t *)(raw_ipv6 + 56)));
551 FAIL_IF(csum != ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
552 (uint16_t *)(raw_ipv6 + 54), 68));
556 static int ICMPV6CalculateInvalidChecksumtest02(
void)
560 uint8_t raw_ipv6[] = {
561 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60,
562 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00,
563 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe,
564 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60,
565 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe,
566 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
567 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00,
568 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00,
569 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe,
570 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
571 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
572 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
573 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
574 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01,
575 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed,
578 csum = *( ((uint16_t *)(raw_ipv6 + 56)));
580 FAIL_IF(csum == ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
581 (uint16_t *)(raw_ipv6 + 54), 68));
589 static int ICMPV6ParamProbTest01(
void)
591 static uint8_t raw_ipv6[] = {
592 0x60, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3a, 0xff,
593 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
594 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
595 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
596 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
597 0x04, 0x00, 0xcc, 0x2a, 0x6d, 0x93, 0x0b, 0xdf,
598 0x69, 0x70, 0x12, 0xb7, 0x00, 0x08, 0x3a, 0xff,
599 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
600 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
601 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
602 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
603 0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
612 ipv6src = (uint32_t*) &raw_ipv6[8];
613 ipv6dst = (uint32_t*) &raw_ipv6[24];
617 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
629 for (
int i = 0; i < 4; i++) {
631 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
644 static int ICMPV6PktTooBigTest01(
void)
646 static uint8_t raw_ipv6[] = {
647 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
648 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
649 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
650 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
651 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
652 0x02, 0x00, 0x5c, 0x7a, 0x00, 0x00, 0x05, 0x00,
653 0x64, 0x14, 0xfd, 0xff, 0x00, 0x00, 0x3b, 0xff,
654 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
655 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
656 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
657 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
666 ipv6src = (uint32_t*) &raw_ipv6[8];
667 ipv6dst = (uint32_t*) &raw_ipv6[24];
671 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
684 for (
int i = 0; i < 4; i++) {
686 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
689 SCLogDebug(
"ICMPV6 IPV6 src and dst properly set");
701 static int ICMPV6TimeExceedTest01(
void)
703 static uint8_t raw_ipv6[] = {
704 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
705 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
706 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
707 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
708 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
709 0x03, 0x00, 0x56, 0x2d, 0x00, 0x00, 0x00, 0x00,
710 0x6d, 0x23, 0xff, 0x3d, 0x00, 0x00, 0x3b, 0xff,
711 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
712 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
713 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
714 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
723 ipv6src = (uint32_t*) &raw_ipv6[8];
724 ipv6dst = (uint32_t*) &raw_ipv6[24];
728 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
741 for (
int i = 0; i < 4; i++) {
743 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
746 SCLogDebug(
"ICMPV6 IPV6 src and dst properly set");
758 static int ICMPV6DestUnreachTest01(
void)
760 static uint8_t raw_ipv6[] = {
761 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
762 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
763 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
764 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
765 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
766 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
767 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
768 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
769 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
770 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
771 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
780 ipv6src = (uint32_t*) &raw_ipv6[8];
781 ipv6dst = (uint32_t*) &raw_ipv6[24];
785 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
798 for (
int i = 0; i < 4; i++) {
800 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
812 static int ICMPV6EchoReqTest01(
void)
814 static uint8_t raw_ipv6[] = {
815 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
816 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
817 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
818 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
819 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
820 0x80, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
830 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
852 static int ICMPV6EchoRepTest01(
void)
854 static uint8_t raw_ipv6[] = {
855 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
856 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
857 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
858 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
859 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
860 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x00,
861 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
871 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
892 static int ICMPV6ParamProbTest02(
void)
894 static uint8_t raw_ipv6[] = {
895 0x60, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3a, 0xff,
896 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
897 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
898 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
899 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
900 0x04, 0x00, 0xcc, 0x2a, 0x6d, 0x93, 0x0b, 0xdf,
901 0x38, 0x70, 0x12, 0xb7, 0x00, 0x08, 0x3a, 0xff,
902 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
903 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
904 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
905 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
906 0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
916 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
935 static int ICMPV6PktTooBigTest02(
void)
937 static uint8_t raw_ipv6[] = {
938 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
939 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
940 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
941 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
942 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
943 0x02, 0x10, 0x5c, 0x7a, 0x00, 0x00, 0x05, 0x00,
944 0x64, 0x14, 0xfd, 0xff, 0x00, 0x00, 0x3b, 0xff,
945 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
946 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
947 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
948 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
958 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
975 static int ICMPV6TimeExceedTest02(
void)
977 static uint8_t raw_ipv6[] = {
978 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3a, 0xff,
979 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
980 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
981 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
982 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
995 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1012 static int ICMPV6DestUnreachTest02(
void)
1014 static uint8_t raw_ipv6[] = {
1015 0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
1016 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1017 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1018 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1019 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1020 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
1021 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
1022 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1023 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1024 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1025 0x00, 0x00, 0x00, 0x00, 0x00 };
1035 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1052 static int ICMPV6EchoReqTest02(
void)
1054 static uint8_t raw_ipv6[] = {
1055 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
1056 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1057 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1058 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
1059 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1060 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01,
1061 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
1071 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1088 static int ICMPV6EchoRepTest02(
void)
1090 static uint8_t raw_ipv6[] = {
1091 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
1092 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1093 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1094 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
1095 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1096 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x01,
1097 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
1107 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1123 static int ICMPV6PayloadTest01(
void)
1125 static uint8_t raw_ipv6[] = {
1126 0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
1127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1129 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1130 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1131 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
1132 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
1133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1135 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1136 0x00, 0x00, 0x00, 0x00, 0x00 };
1146 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1160 static int ICMPV6RouterSolicitTestKnownCode(
void)
1162 static uint8_t raw_ipv6[] = {
1163 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1164 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1165 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1166 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1168 0x85, 0x00, 0xbe, 0xb0, 0x00, 0x00, 0x00, 0x00
1179 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1192 static int ICMPV6RouterSolicitTestUnknownCode(
void)
1194 static uint8_t raw_ipv6[] = {
1195 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1196 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1197 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1198 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1200 0x85, 0x01, 0xbe, 0xaf, 0x00, 0x00, 0x00, 0x00
1211 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1224 static int ICMPV6RouterAdvertTestKnownCode(
void)
1226 static uint8_t raw_ipv6[] = {
1227 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1228 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1229 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1230 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1232 0x86, 0x00, 0xbd, 0xb0, 0x00, 0x00, 0x00, 0x00
1243 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1256 static int ICMPV6RouterAdvertTestUnknownCode(
void)
1258 static uint8_t raw_ipv6[] = {
1259 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1260 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1261 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1262 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1264 0x86, 0x01, 0xbd, 0xaf, 0x00, 0x00, 0x00, 0x00
1275 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1288 static int ICMPV6NeighbourSolicitTestKnownCode(
void)
1290 static uint8_t raw_ipv6[] = {
1291 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1292 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1293 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1294 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1296 0x87, 0x00, 0xbc, 0xb0, 0x00, 0x00, 0x00, 0x00
1307 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1320 static int ICMPV6NeighbourSolicitTestUnknownCode(
void)
1322 static uint8_t raw_ipv6[] = {
1323 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1324 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1325 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1326 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1328 0x87, 0x01, 0xbc, 0xaf, 0x00, 0x00, 0x00, 0x00
1339 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1352 static int ICMPV6NeighbourAdvertTestKnownCode(
void)
1354 static uint8_t raw_ipv6[] = {
1355 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1356 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1357 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1358 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1360 0x88, 0x00, 0xbb, 0xb0, 0x00, 0x00, 0x00, 0x00
1371 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1384 static int ICMPV6NeighbourAdvertTestUnknownCode(
void)
1386 static uint8_t raw_ipv6[] = {
1387 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1388 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1389 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1390 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1391 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1392 0x88, 0x01, 0xbb, 0xaf, 0x00, 0x00, 0x00, 0x00
1403 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1416 static int ICMPV6RedirectTestKnownCode(
void)
1418 static uint8_t raw_ipv6[] = {
1419 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1420 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1421 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1422 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1423 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1424 0x89, 0x00, 0xba, 0xb0, 0x00, 0x00, 0x00, 0x00
1435 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1448 static int ICMPV6RedirectTestUnknownCode(
void)
1450 static uint8_t raw_ipv6[] = {
1451 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1452 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1453 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1454 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1455 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1456 0x89, 0x01, 0xba, 0xaf, 0x00, 0x00, 0x00, 0x00
1467 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1487 static int ICMPV6CalculateValidChecksumWithFCS(
void)
1492 uint8_t raw_ipv6[] = {
1493 0x33, 0x33, 0x00, 0x00, 0x00, 0x16, 0x00, 0x50,
1494 0x56, 0xa6, 0x6a, 0x7d, 0x86, 0xdd, 0x60, 0x00,
1495 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0xfe, 0x80,
1496 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0x09,
1497 0xad, 0x44, 0x49, 0x38, 0x5f, 0xa9, 0xff, 0x02,
1498 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1499 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x3a, 0x00,
1500 0x05, 0x02, 0x00, 0x00, 0x01, 0x00, 0x8f, 0x00,
1501 0x24, 0xe0, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00,
1502 0x00, 0x00, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00,
1503 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1504 0x00, 0xfb, 0x1f, 0x34, 0xf6, 0xa4
1506 uint16_t csum = *(((uint16_t *)(raw_ipv6 + 64)));
1519 const ICMPV6Hdr *icmpv6h = PacketGetICMPv6(p);
1520 const IPV6Hdr *ip6h = PacketGetIPv6(p);
1524 FAIL_IF(ICMPV6CalculateChecksum(ip6h->s_ip6_addrs, (uint16_t *)icmpv6h, icmpv6_len) != csum);
1541 ICMPV6CalculateValidChecksumtest01);
1542 UtRegisterTest(
"ICMPV6CalculateInvalidChecksumtest02", ICMPV6CalculateInvalidChecksumtest02);
1544 UtRegisterTest(
"ICMPV6ParamProbTest01 (Valid)", ICMPV6ParamProbTest01);
1545 UtRegisterTest(
"ICMPV6DestUnreachTest01 (Valid)", ICMPV6DestUnreachTest01);
1546 UtRegisterTest(
"ICMPV6PktTooBigTest01 (Valid)", ICMPV6PktTooBigTest01);
1547 UtRegisterTest(
"ICMPV6TimeExceedTest01 (Valid)", ICMPV6TimeExceedTest01);
1548 UtRegisterTest(
"ICMPV6EchoReqTest01 (Valid)", ICMPV6EchoReqTest01);
1549 UtRegisterTest(
"ICMPV6EchoRepTest01 (Valid)", ICMPV6EchoRepTest01);
1551 UtRegisterTest(
"ICMPV6ParamProbTest02 (Invalid)", ICMPV6ParamProbTest02);
1553 ICMPV6DestUnreachTest02);
1554 UtRegisterTest(
"ICMPV6PktTooBigTest02 (Invalid)", ICMPV6PktTooBigTest02);
1555 UtRegisterTest(
"ICMPV6TimeExceedTest02 (Invalid)", ICMPV6TimeExceedTest02);
1556 UtRegisterTest(
"ICMPV6EchoReqTest02 (Invalid)", ICMPV6EchoReqTest02);
1557 UtRegisterTest(
"ICMPV6EchoRepTest02 (Invalid)", ICMPV6EchoRepTest02);
1562 ICMPV6RouterSolicitTestKnownCode);
1564 ICMPV6RouterSolicitTestUnknownCode);
1566 ICMPV6RouterAdvertTestKnownCode);
1568 ICMPV6RouterAdvertTestUnknownCode);
1571 ICMPV6NeighbourSolicitTestKnownCode);
1573 ICMPV6NeighbourSolicitTestUnknownCode);
1575 ICMPV6NeighbourAdvertTestKnownCode);
1577 ICMPV6NeighbourAdvertTestUnknownCode);
1579 UtRegisterTest(
"ICMPV6RedirectTestKnownCode", ICMPV6RedirectTestKnownCode);
1581 ICMPV6RedirectTestUnknownCode);
1583 ICMPV6CalculateValidChecksumWithFCS);