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,
147 #define CASE_CODE(t,r) case (t): return r; case (r): return t;
178 const uint8_t *pkt, uint32_t
len)
180 const IPV6Hdr *ip6h = PacketGetIPv6(p);
190 ICMPV6Hdr *icmpv6h = PacketSetICMPv6(p, pkt);
191 p->
proto = IPPROTO_ICMPV6;
193 const uint8_t code = p->
icmp_s.code = icmpv6h->
code;
200 p->
icmp_d.type = (uint8_t)ctype;
352 if (code > 2 && code != 255) {
442 if (code > 3 && code < 128) {
479 }
else if (
type >= 100 &&
type < 102) {
481 }
else if (
type >= 102 &&
type < 127) {
483 }
else if (
type >= 160 &&
type < 200) {
485 }
else if (
type >= 200 &&
type < 202) {
487 }
else if (
type >= 202) {
501 p->
payload = (uint8_t *)pkt + 4;
510 SCLogDebug(
"Unknown Code, ICMPV6_UNKNOWN_CODE");
513 SCLogDebug(
"Unknown Type, ICMPV6_UNKNOWN_TYPE");
525 static int ICMPV6CalculateValidChecksumtest01(
void)
529 uint8_t raw_ipv6[] = {
530 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60,
531 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00,
532 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe,
533 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60,
534 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe,
535 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
536 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00,
537 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00,
538 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe,
539 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
540 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
541 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
542 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
543 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01,
544 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed,
547 csum = *( ((uint16_t *)(raw_ipv6 + 56)));
549 FAIL_IF(csum != ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
550 (uint16_t *)(raw_ipv6 + 54), 68));
554 static int ICMPV6CalculateInvalidChecksumtest02(
void)
558 uint8_t raw_ipv6[] = {
559 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60,
560 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00,
561 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe,
562 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60,
563 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe,
564 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
565 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00,
566 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00,
567 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe,
568 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
569 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
570 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
571 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
572 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01,
573 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed,
576 csum = *( ((uint16_t *)(raw_ipv6 + 56)));
578 FAIL_IF(csum == ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
579 (uint16_t *)(raw_ipv6 + 54), 68));
587 static int ICMPV6ParamProbTest01(
void)
589 static uint8_t raw_ipv6[] = {
590 0x60, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3a, 0xff,
591 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
592 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
593 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
594 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
595 0x04, 0x00, 0xcc, 0x2a, 0x6d, 0x93, 0x0b, 0xdf,
596 0x69, 0x70, 0x12, 0xb7, 0x00, 0x08, 0x3a, 0xff,
597 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
598 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
599 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
600 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
601 0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
610 ipv6src = (uint32_t*) &raw_ipv6[8];
611 ipv6dst = (uint32_t*) &raw_ipv6[24];
615 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
627 for (
int i = 0; i < 4; i++) {
629 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
642 static int ICMPV6PktTooBigTest01(
void)
644 static uint8_t raw_ipv6[] = {
645 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
646 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
647 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
648 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
649 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
650 0x02, 0x00, 0x5c, 0x7a, 0x00, 0x00, 0x05, 0x00,
651 0x64, 0x14, 0xfd, 0xff, 0x00, 0x00, 0x3b, 0xff,
652 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
653 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
654 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
655 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
664 ipv6src = (uint32_t*) &raw_ipv6[8];
665 ipv6dst = (uint32_t*) &raw_ipv6[24];
669 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
682 for (
int i = 0; i < 4; i++) {
684 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
687 SCLogDebug(
"ICMPV6 IPV6 src and dst properly set");
699 static int ICMPV6TimeExceedTest01(
void)
701 static uint8_t raw_ipv6[] = {
702 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
703 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
704 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
705 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
706 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
707 0x03, 0x00, 0x56, 0x2d, 0x00, 0x00, 0x00, 0x00,
708 0x6d, 0x23, 0xff, 0x3d, 0x00, 0x00, 0x3b, 0xff,
709 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
710 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
711 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
712 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
721 ipv6src = (uint32_t*) &raw_ipv6[8];
722 ipv6dst = (uint32_t*) &raw_ipv6[24];
726 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
739 for (
int i = 0; i < 4; i++) {
741 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
744 SCLogDebug(
"ICMPV6 IPV6 src and dst properly set");
756 static int ICMPV6DestUnreachTest01(
void)
758 static uint8_t raw_ipv6[] = {
759 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
760 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
761 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
762 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
763 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
764 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
765 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
766 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
767 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
768 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
769 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
778 ipv6src = (uint32_t*) &raw_ipv6[8];
779 ipv6dst = (uint32_t*) &raw_ipv6[24];
783 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
796 for (
int i = 0; i < 4; i++) {
798 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
810 static int ICMPV6EchoReqTest01(
void)
812 static uint8_t raw_ipv6[] = {
813 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
814 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
815 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
816 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
817 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
818 0x80, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
828 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
850 static int ICMPV6EchoRepTest01(
void)
852 static uint8_t raw_ipv6[] = {
853 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
854 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
855 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
856 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
857 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
858 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x00,
859 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
869 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
890 static int ICMPV6ParamProbTest02(
void)
892 static uint8_t raw_ipv6[] = {
893 0x60, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3a, 0xff,
894 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
895 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
896 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
897 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
898 0x04, 0x00, 0xcc, 0x2a, 0x6d, 0x93, 0x0b, 0xdf,
899 0x38, 0x70, 0x12, 0xb7, 0x00, 0x08, 0x3a, 0xff,
900 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
901 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
902 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
903 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
904 0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
914 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
933 static int ICMPV6PktTooBigTest02(
void)
935 static uint8_t raw_ipv6[] = {
936 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
937 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
938 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
939 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
940 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
941 0x02, 0x10, 0x5c, 0x7a, 0x00, 0x00, 0x05, 0x00,
942 0x64, 0x14, 0xfd, 0xff, 0x00, 0x00, 0x3b, 0xff,
943 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
944 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
945 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
946 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
956 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
973 static int ICMPV6TimeExceedTest02(
void)
975 static uint8_t raw_ipv6[] = {
976 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3a, 0xff,
977 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
978 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
979 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
980 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
993 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1010 static int ICMPV6DestUnreachTest02(
void)
1012 static uint8_t raw_ipv6[] = {
1013 0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
1014 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1015 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1016 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1017 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1018 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
1019 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
1020 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1021 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1022 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1023 0x00, 0x00, 0x00, 0x00, 0x00 };
1033 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1050 static int ICMPV6EchoReqTest02(
void)
1052 static uint8_t raw_ipv6[] = {
1053 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
1054 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1055 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1056 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
1057 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1058 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01,
1059 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
1069 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1086 static int ICMPV6EchoRepTest02(
void)
1088 static uint8_t raw_ipv6[] = {
1089 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
1090 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1091 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1092 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
1093 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1094 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x01,
1095 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
1105 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1121 static int ICMPV6PayloadTest01(
void)
1123 static uint8_t raw_ipv6[] = {
1124 0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
1125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1127 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1129 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
1130 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
1131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1133 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1134 0x00, 0x00, 0x00, 0x00, 0x00 };
1144 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1158 static int ICMPV6RouterSolicitTestKnownCode(
void)
1160 static uint8_t raw_ipv6[] = {
1161 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1162 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1163 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1164 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1166 0x85, 0x00, 0xbe, 0xb0, 0x00, 0x00, 0x00, 0x00
1177 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1190 static int ICMPV6RouterSolicitTestUnknownCode(
void)
1192 static uint8_t raw_ipv6[] = {
1193 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1194 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1195 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1196 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1198 0x85, 0x01, 0xbe, 0xaf, 0x00, 0x00, 0x00, 0x00
1209 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1222 static int ICMPV6RouterAdvertTestKnownCode(
void)
1224 static uint8_t raw_ipv6[] = {
1225 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1226 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1227 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1228 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1230 0x86, 0x00, 0xbd, 0xb0, 0x00, 0x00, 0x00, 0x00
1241 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1254 static int ICMPV6RouterAdvertTestUnknownCode(
void)
1256 static uint8_t raw_ipv6[] = {
1257 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1258 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1259 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1260 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1262 0x86, 0x01, 0xbd, 0xaf, 0x00, 0x00, 0x00, 0x00
1273 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1286 static int ICMPV6NeighbourSolicitTestKnownCode(
void)
1288 static uint8_t raw_ipv6[] = {
1289 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1290 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1291 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1292 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1294 0x87, 0x00, 0xbc, 0xb0, 0x00, 0x00, 0x00, 0x00
1305 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1318 static int ICMPV6NeighbourSolicitTestUnknownCode(
void)
1320 static uint8_t raw_ipv6[] = {
1321 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1322 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1323 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1324 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1325 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1326 0x87, 0x01, 0xbc, 0xaf, 0x00, 0x00, 0x00, 0x00
1337 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1350 static int ICMPV6NeighbourAdvertTestKnownCode(
void)
1352 static uint8_t raw_ipv6[] = {
1353 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1354 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1355 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1356 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1358 0x88, 0x00, 0xbb, 0xb0, 0x00, 0x00, 0x00, 0x00
1369 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1382 static int ICMPV6NeighbourAdvertTestUnknownCode(
void)
1384 static uint8_t raw_ipv6[] = {
1385 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1386 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1387 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1388 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1390 0x88, 0x01, 0xbb, 0xaf, 0x00, 0x00, 0x00, 0x00
1401 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1414 static int ICMPV6RedirectTestKnownCode(
void)
1416 static uint8_t raw_ipv6[] = {
1417 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1418 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1419 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1420 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1421 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1422 0x89, 0x00, 0xba, 0xb0, 0x00, 0x00, 0x00, 0x00
1433 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1446 static int ICMPV6RedirectTestUnknownCode(
void)
1448 static uint8_t raw_ipv6[] = {
1449 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1450 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1451 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1452 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1453 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1454 0x89, 0x01, 0xba, 0xaf, 0x00, 0x00, 0x00, 0x00
1465 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1485 static int ICMPV6CalculateValidChecksumWithFCS(
void)
1490 uint8_t raw_ipv6[] = {
1491 0x33, 0x33, 0x00, 0x00, 0x00, 0x16, 0x00, 0x50,
1492 0x56, 0xa6, 0x6a, 0x7d, 0x86, 0xdd, 0x60, 0x00,
1493 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0xfe, 0x80,
1494 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0x09,
1495 0xad, 0x44, 0x49, 0x38, 0x5f, 0xa9, 0xff, 0x02,
1496 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1497 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x3a, 0x00,
1498 0x05, 0x02, 0x00, 0x00, 0x01, 0x00, 0x8f, 0x00,
1499 0x24, 0xe0, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00,
1500 0x00, 0x00, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00,
1501 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1502 0x00, 0xfb, 0x1f, 0x34, 0xf6, 0xa4
1504 uint16_t csum = *(((uint16_t *)(raw_ipv6 + 64)));
1517 const ICMPV6Hdr *icmpv6h = PacketGetICMPv6(p);
1518 const IPV6Hdr *ip6h = PacketGetIPv6(p);
1522 FAIL_IF(ICMPV6CalculateChecksum(ip6h->s_ip6_addrs, (uint16_t *)icmpv6h, icmpv6_len) != csum);
1539 ICMPV6CalculateValidChecksumtest01);
1540 UtRegisterTest(
"ICMPV6CalculateInvalidChecksumtest02", ICMPV6CalculateInvalidChecksumtest02);
1542 UtRegisterTest(
"ICMPV6ParamProbTest01 (Valid)", ICMPV6ParamProbTest01);
1543 UtRegisterTest(
"ICMPV6DestUnreachTest01 (Valid)", ICMPV6DestUnreachTest01);
1544 UtRegisterTest(
"ICMPV6PktTooBigTest01 (Valid)", ICMPV6PktTooBigTest01);
1545 UtRegisterTest(
"ICMPV6TimeExceedTest01 (Valid)", ICMPV6TimeExceedTest01);
1546 UtRegisterTest(
"ICMPV6EchoReqTest01 (Valid)", ICMPV6EchoReqTest01);
1547 UtRegisterTest(
"ICMPV6EchoRepTest01 (Valid)", ICMPV6EchoRepTest01);
1549 UtRegisterTest(
"ICMPV6ParamProbTest02 (Invalid)", ICMPV6ParamProbTest02);
1551 ICMPV6DestUnreachTest02);
1552 UtRegisterTest(
"ICMPV6PktTooBigTest02 (Invalid)", ICMPV6PktTooBigTest02);
1553 UtRegisterTest(
"ICMPV6TimeExceedTest02 (Invalid)", ICMPV6TimeExceedTest02);
1554 UtRegisterTest(
"ICMPV6EchoReqTest02 (Invalid)", ICMPV6EchoReqTest02);
1555 UtRegisterTest(
"ICMPV6EchoRepTest02 (Invalid)", ICMPV6EchoRepTest02);
1560 ICMPV6RouterSolicitTestKnownCode);
1562 ICMPV6RouterSolicitTestUnknownCode);
1564 ICMPV6RouterAdvertTestKnownCode);
1566 ICMPV6RouterAdvertTestUnknownCode);
1569 ICMPV6NeighbourSolicitTestKnownCode);
1571 ICMPV6NeighbourSolicitTestUnknownCode);
1573 ICMPV6NeighbourAdvertTestKnownCode);
1575 ICMPV6NeighbourAdvertTestUnknownCode);
1577 UtRegisterTest(
"ICMPV6RedirectTestKnownCode", ICMPV6RedirectTestKnownCode);
1579 ICMPV6RedirectTestUnknownCode);
1581 ICMPV6CalculateValidChecksumWithFCS);