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]);
641 static int ICMPV6PktTooBigTest01(
void)
643 static uint8_t raw_ipv6[] = {
644 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
645 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
646 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
647 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
648 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
649 0x02, 0x00, 0x5c, 0x7a, 0x00, 0x00, 0x05, 0x00,
650 0x64, 0x14, 0xfd, 0xff, 0x00, 0x00, 0x3b, 0xff,
651 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
652 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
653 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
654 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
663 ipv6src = (uint32_t*) &raw_ipv6[8];
664 ipv6dst = (uint32_t*) &raw_ipv6[24];
668 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
681 for (
int i = 0; i < 4; i++) {
683 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
686 SCLogDebug(
"ICMPV6 IPV6 src and dst properly set");
697 static int ICMPV6TimeExceedTest01(
void)
699 static uint8_t raw_ipv6[] = {
700 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
701 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
702 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
703 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
704 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
705 0x03, 0x00, 0x56, 0x2d, 0x00, 0x00, 0x00, 0x00,
706 0x6d, 0x23, 0xff, 0x3d, 0x00, 0x00, 0x3b, 0xff,
707 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
708 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
709 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
710 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
719 ipv6src = (uint32_t*) &raw_ipv6[8];
720 ipv6dst = (uint32_t*) &raw_ipv6[24];
724 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
737 for (
int i = 0; i < 4; i++) {
739 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
742 SCLogDebug(
"ICMPV6 IPV6 src and dst properly set");
753 static int ICMPV6DestUnreachTest01(
void)
755 static uint8_t raw_ipv6[] = {
756 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
757 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
758 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
759 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
760 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
761 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
762 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
763 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
764 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
765 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
766 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
775 ipv6src = (uint32_t*) &raw_ipv6[8];
776 ipv6dst = (uint32_t*) &raw_ipv6[24];
780 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
793 for (
int i = 0; i < 4; i++) {
795 PacketGetICMPv6EmbIPv6(p)->
s_ip6_dst[i] != ipv6dst[i]);
806 static int ICMPV6EchoReqTest01(
void)
808 static uint8_t raw_ipv6[] = {
809 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
810 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
811 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
812 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
813 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
814 0x80, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
824 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
845 static int ICMPV6EchoRepTest01(
void)
847 static uint8_t raw_ipv6[] = {
848 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
849 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
850 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
851 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
852 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
853 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x00,
854 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
864 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
884 static int ICMPV6ParamProbTest02(
void)
886 static uint8_t raw_ipv6[] = {
887 0x60, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3a, 0xff,
888 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
889 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
890 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
891 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
892 0x04, 0x00, 0xcc, 0x2a, 0x6d, 0x93, 0x0b, 0xdf,
893 0x38, 0x70, 0x12, 0xb7, 0x00, 0x08, 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 0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
908 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
926 static int ICMPV6PktTooBigTest02(
void)
928 static uint8_t raw_ipv6[] = {
929 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
930 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
931 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
932 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
933 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
934 0x02, 0x10, 0x5c, 0x7a, 0x00, 0x00, 0x05, 0x00,
935 0x64, 0x14, 0xfd, 0xff, 0x00, 0x00, 0x3b, 0xff,
936 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
937 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
938 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
939 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
949 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
965 static int ICMPV6TimeExceedTest02(
void)
967 static uint8_t raw_ipv6[] = {
968 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3a, 0xff,
969 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
970 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
971 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
972 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
985 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1001 static int ICMPV6DestUnreachTest02(
void)
1003 static uint8_t raw_ipv6[] = {
1004 0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
1005 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1006 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1007 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1008 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1009 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
1010 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
1011 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1012 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1013 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1014 0x00, 0x00, 0x00, 0x00, 0x00 };
1024 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1040 static int ICMPV6EchoReqTest02(
void)
1042 static uint8_t raw_ipv6[] = {
1043 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
1044 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1045 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1046 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
1047 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1048 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01,
1049 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
1059 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1075 static int ICMPV6EchoRepTest02(
void)
1077 static uint8_t raw_ipv6[] = {
1078 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
1079 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1080 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1081 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
1082 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1083 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x01,
1084 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
1094 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1109 static int ICMPV6PayloadTest01(
void)
1111 static uint8_t raw_ipv6[] = {
1112 0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
1113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1115 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1116 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1117 0x01, 0x00, 0x7b, 0x85, 0x00, 0x00, 0x00, 0x00,
1118 0x60, 0x4b, 0xe8, 0xbd, 0x00, 0x00, 0x3b, 0xff,
1119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1121 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1122 0x00, 0x00, 0x00, 0x00, 0x00 };
1132 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1145 static int ICMPV6RouterSolicitTestKnownCode(
void)
1147 static uint8_t raw_ipv6[] = {
1148 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1149 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1150 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1151 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1153 0x85, 0x00, 0xbe, 0xb0, 0x00, 0x00, 0x00, 0x00
1164 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1176 static int ICMPV6RouterSolicitTestUnknownCode(
void)
1178 static uint8_t raw_ipv6[] = {
1179 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1180 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1181 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1182 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1183 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1184 0x85, 0x01, 0xbe, 0xaf, 0x00, 0x00, 0x00, 0x00
1195 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1207 static int ICMPV6RouterAdvertTestKnownCode(
void)
1209 static uint8_t raw_ipv6[] = {
1210 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1211 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1212 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1213 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1215 0x86, 0x00, 0xbd, 0xb0, 0x00, 0x00, 0x00, 0x00
1226 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1238 static int ICMPV6RouterAdvertTestUnknownCode(
void)
1240 static uint8_t raw_ipv6[] = {
1241 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1242 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1243 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1244 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1246 0x86, 0x01, 0xbd, 0xaf, 0x00, 0x00, 0x00, 0x00
1257 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1269 static int ICMPV6NeighbourSolicitTestKnownCode(
void)
1271 static uint8_t raw_ipv6[] = {
1272 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1273 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1274 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1275 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1277 0x87, 0x00, 0xbc, 0xb0, 0x00, 0x00, 0x00, 0x00
1288 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1300 static int ICMPV6NeighbourSolicitTestUnknownCode(
void)
1302 static uint8_t raw_ipv6[] = {
1303 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1304 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1305 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1306 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1307 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1308 0x87, 0x01, 0xbc, 0xaf, 0x00, 0x00, 0x00, 0x00
1319 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1331 static int ICMPV6NeighbourAdvertTestKnownCode(
void)
1333 static uint8_t raw_ipv6[] = {
1334 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1335 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1336 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1337 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1339 0x88, 0x00, 0xbb, 0xb0, 0x00, 0x00, 0x00, 0x00
1350 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1362 static int ICMPV6NeighbourAdvertTestUnknownCode(
void)
1364 static uint8_t raw_ipv6[] = {
1365 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1366 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1367 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1368 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1370 0x88, 0x01, 0xbb, 0xaf, 0x00, 0x00, 0x00, 0x00
1381 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1393 static int ICMPV6RedirectTestKnownCode(
void)
1395 static uint8_t raw_ipv6[] = {
1396 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1397 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1398 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1399 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1400 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1401 0x89, 0x00, 0xba, 0xb0, 0x00, 0x00, 0x00, 0x00
1412 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1424 static int ICMPV6RedirectTestUnknownCode(
void)
1426 static uint8_t raw_ipv6[] = {
1427 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
1428 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1429 0x02, 0x24, 0x8c, 0xff, 0xfe, 0x0e, 0x31, 0x54,
1430 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1431 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1432 0x89, 0x01, 0xba, 0xaf, 0x00, 0x00, 0x00, 0x00
1443 memset(&ip6h, 0,
sizeof(
IPV6Hdr));
1462 static int ICMPV6CalculateValidChecksumWithFCS(
void)
1467 uint8_t raw_ipv6[] = {
1468 0x33, 0x33, 0x00, 0x00, 0x00, 0x16, 0x00, 0x50,
1469 0x56, 0xa6, 0x6a, 0x7d, 0x86, 0xdd, 0x60, 0x00,
1470 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0xfe, 0x80,
1471 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0x09,
1472 0xad, 0x44, 0x49, 0x38, 0x5f, 0xa9, 0xff, 0x02,
1473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1474 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x3a, 0x00,
1475 0x05, 0x02, 0x00, 0x00, 0x01, 0x00, 0x8f, 0x00,
1476 0x24, 0xe0, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00,
1477 0x00, 0x00, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00,
1478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1479 0x00, 0xfb, 0x1f, 0x34, 0xf6, 0xa4
1481 uint16_t csum = *(((uint16_t *)(raw_ipv6 + 64)));
1494 const ICMPV6Hdr *icmpv6h = PacketGetICMPv6(p);
1495 const IPV6Hdr *ip6h = PacketGetIPv6(p);
1499 FAIL_IF(ICMPV6CalculateChecksum(ip6h->s_ip6_addrs, (uint16_t *)icmpv6h, icmpv6_len) != csum);
1515 ICMPV6CalculateValidChecksumtest01);
1516 UtRegisterTest(
"ICMPV6CalculateInvalidChecksumtest02", ICMPV6CalculateInvalidChecksumtest02);
1518 UtRegisterTest(
"ICMPV6ParamProbTest01 (Valid)", ICMPV6ParamProbTest01);
1519 UtRegisterTest(
"ICMPV6DestUnreachTest01 (Valid)", ICMPV6DestUnreachTest01);
1520 UtRegisterTest(
"ICMPV6PktTooBigTest01 (Valid)", ICMPV6PktTooBigTest01);
1521 UtRegisterTest(
"ICMPV6TimeExceedTest01 (Valid)", ICMPV6TimeExceedTest01);
1522 UtRegisterTest(
"ICMPV6EchoReqTest01 (Valid)", ICMPV6EchoReqTest01);
1523 UtRegisterTest(
"ICMPV6EchoRepTest01 (Valid)", ICMPV6EchoRepTest01);
1525 UtRegisterTest(
"ICMPV6ParamProbTest02 (Invalid)", ICMPV6ParamProbTest02);
1527 ICMPV6DestUnreachTest02);
1528 UtRegisterTest(
"ICMPV6PktTooBigTest02 (Invalid)", ICMPV6PktTooBigTest02);
1529 UtRegisterTest(
"ICMPV6TimeExceedTest02 (Invalid)", ICMPV6TimeExceedTest02);
1530 UtRegisterTest(
"ICMPV6EchoReqTest02 (Invalid)", ICMPV6EchoReqTest02);
1531 UtRegisterTest(
"ICMPV6EchoRepTest02 (Invalid)", ICMPV6EchoRepTest02);
1536 ICMPV6RouterSolicitTestKnownCode);
1538 ICMPV6RouterSolicitTestUnknownCode);
1540 ICMPV6RouterAdvertTestKnownCode);
1542 ICMPV6RouterAdvertTestUnknownCode);
1545 ICMPV6NeighbourSolicitTestKnownCode);
1547 ICMPV6NeighbourSolicitTestUnknownCode);
1549 ICMPV6NeighbourAdvertTestKnownCode);
1551 ICMPV6NeighbourAdvertTestUnknownCode);
1553 UtRegisterTest(
"ICMPV6RedirectTestKnownCode", ICMPV6RedirectTestKnownCode);
1555 ICMPV6RedirectTestUnknownCode);
1557 ICMPV6CalculateValidChecksumWithFCS);