2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>, Deutsche Flugsicherung GmbH
4 * Subject to the GPL, version 2.
6 * ICMPv6 described in RFC4443, RFC2710, RFC4861, RFC2894,
7 * RFC4620, RFC3122, RFC3810, RFC3775, RFC3971, RFC4065
9 * Look also for an good overview:
10 * http://www.iana.org/assignments/icmpv6-parameters
16 #include <netinet/in.h>
17 #include <arpa/inet.h>
18 #include <asm/byteorder.h>
25 #define icmpv6_code_range_valid(code, sarr) ((size_t) (code) < array_size((sarr)))
27 struct icmpv6_general_hdr
{
33 /* for type 0x01 and 0x03 */
34 struct icmpv6_type_1_3
{
36 uint8_t invoking_pkt
[0];
39 struct icmpv6_type_2
{
41 uint8_t invoking_pkt
[0];
44 struct icmpv6_type_4
{
46 uint8_t invoking_pkt
[0];
49 struct icmpv6_type_128_129
{
56 struct icmpv6_type_130_131_132
{
59 struct in6_addr ipv6_addr
;
63 struct icmpv6_type_130_mldv2
{
67 struct in6_addr ipv6_addr
[0];
70 /* Neighbor Discovery msg */
71 struct icmpv6_type_133_141_142
{
76 struct icmpv6_type_134
{
77 uint8_t cur_hop_limit
;
79 uint16_t router_lifetime
;
80 uint32_t reachable_time
;
81 uint32_t retrans_timer
;
85 struct icmpv6_type_135
{
87 struct in6_addr ipv6_addr
;
91 struct icmpv6_type_136
{
93 struct in6_addr ipv6_addr
;
97 struct icmpv6_type_137
{
99 struct in6_addr ipv6_targ_addr
;
100 struct in6_addr ipv6_dest_addr
;
104 struct icmpv6_neighb_disc_ops_general
{
110 struct icmpv6_neighb_disc_ops_type_1_2
{
111 uint8_t link_lay_addr
[0];
114 struct icmpv6_neighb_disc_ops_type_3
{
117 uint32_t valid_lifetime
;
118 uint32_t preferred_lifetime
;
120 struct in6_addr prefix
;
123 struct icmpv6_neighb_disc_ops_type_4
{
126 uint8_t ip_hdr_data
[0];
129 struct icmpv6_neighb_disc_ops_type_5
{
134 struct icmpv6_neighb_disc_ops_type_9_10
{
137 uint8_t ip_hdr_data
[0];
140 struct icmpv6_neighb_disc_ops_type_15
{
147 struct icmpv6_neighb_disc_ops_type_16
{
154 struct icmpv6_neighb_disc_ops_type_17
{
160 struct icmpv6_neighb_disc_ops_type_17_1
{
162 struct in6_addr ipv6_addr
;
165 struct icmpv6_neighb_disc_ops_type_17_2
{
166 struct in6_addr ipv6_addr
;
169 struct icmpv6_neighb_disc_ops_type_19
{
173 /* end Neighbor Discovery msg */
175 struct icmpv6_type_138
{
183 /* Node Information Queries */
184 struct icmpv6_type_139_140
{
190 /* end Node Information Queries */
193 struct icmpv6_type_143
{
199 struct icmpv6_mldv2_addr_rec
{
201 uint8_t aux_data_len
;
203 struct in6_addr multic_addr
;
204 struct in6_addr src_addr
[0];
206 /* end MLDv2 report */
208 /* ICMP Mobility Support */
209 struct icmpv6_type_144_146
{
214 struct icmpv6_type_145
{
217 struct in6_addr home_agent_addr
[0];
220 struct icmpv6_type_147
{
225 /* end ICMP Mobility Support */
227 /* SEcure Neighbor Discovery */
228 struct icmpv6_type_148
{
234 struct icmpv6_type_149
{
241 /* end SEcure Neighbor Discovery */
243 struct icmpv6_type_150
{
245 uint32_t subtype_res
;
247 #if defined(__LITTLE_ENDIAN_BITFIELD)
250 #elif defined(__BIG_ENDIAN_BITFIELD)
254 # error "Please fix <asm/byteorder.h>"
261 /* Multicast Router Discovery */
262 struct icmpv6_type_151
{
267 struct icmpv6_type_152
{
271 struct icmpv6_type_153
{
274 /* end Multicast Router Discovery */
276 struct icmpv6_type_154
{
283 static int8_t print_ipv6_addr_list(struct pkt_buff
*pkt
, uint8_t nr_addr
)
285 char address
[INET6_ADDRSTRLEN
];
286 struct in6_addr
*addr
;
289 addr
= (struct in6_addr
*) pkt_pull(pkt
, sizeof(*addr
));
293 tprintf("\n\t Address: %s",
294 inet_ntop(AF_INET6
, addr
, address
,
301 static const char *icmpv6_mcast_rec_types
[] = {
304 "CHANGE_TO_INCLUDE_MODE",
305 "CHANGE_TO_EXCLUDE_MODE",
310 static int8_t dissect_icmpv6_mcast_rec(struct pkt_buff
*pkt
,
313 uint16_t nr_src
, aux_data_len_bytes
;
314 char address
[INET6_ADDRSTRLEN
];
315 struct icmpv6_mldv2_addr_rec
*addr_rec
;
318 addr_rec
= (struct icmpv6_mldv2_addr_rec
*)
319 pkt_pull(pkt
,sizeof(*addr_rec
));
320 if (addr_rec
== NULL
)
322 aux_data_len_bytes
= addr_rec
->aux_data_len
* 4;
323 nr_src
= ntohs(addr_rec
->nr_src
);
325 tprintf(", Rec Type %s (%u)",
326 icmpv6_code_range_valid(addr_rec
->rec_type
- 1,
327 icmpv6_mcast_rec_types
) ?
328 icmpv6_mcast_rec_types
[addr_rec
->rec_type
- 1]
329 : "Unknown", addr_rec
->rec_type
);
330 if (aux_data_len_bytes
> pkt_len(pkt
)) {
331 tprintf(", Aux Data Len (%u, %u bytes) %s",
332 addr_rec
->aux_data_len
,
334 colorize_start_full(black
, red
) "invalid"
338 tprintf(", Aux Data Len (%u, %u bytes)",addr_rec
->aux_data_len
,
340 tprintf(", Nr. of Sources (%u)",nr_src
);
341 tprintf(", Address: %s",
342 inet_ntop(AF_INET6
, &addr_rec
->multic_addr
,
343 address
, sizeof(address
)));
345 if(!print_ipv6_addr_list(pkt
, nr_src
))
348 if (aux_data_len_bytes
> pkt_len(pkt
)) {
349 tprintf("\nAux Data Len %s",
350 colorize_start_full(black
, red
) "invalid"
355 tprintf(", Aux Data: ");
356 while (aux_data_len_bytes
--) {
357 uint8_t *data
= pkt_pull(pkt
, 1);
360 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
365 tprintf("%x", *data
);
372 static int8_t dissect_neighb_disc_ops_1(struct pkt_buff
*pkt
,
375 struct icmpv6_neighb_disc_ops_type_1_2
*icmp_neighb_disc_1
;
377 icmp_neighb_disc_1
= (struct icmpv6_neighb_disc_ops_type_1_2
*)
378 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_1
));
379 if (icmp_neighb_disc_1
== NULL
)
381 len
-= sizeof(*icmp_neighb_disc_1
);
385 tprintf("Address 0x");
388 uint8_t *data
= pkt_pull(pkt
, 1);
391 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
396 tprintf("%x", *data
);
402 static int8_t dissect_neighb_disc_ops_2(struct pkt_buff
*pkt
,
405 return dissect_neighb_disc_ops_1(pkt
, len
);
408 static int8_t dissect_neighb_disc_ops_3(struct pkt_buff
*pkt
,
411 char address
[INET6_ADDRSTRLEN
];
412 struct icmpv6_neighb_disc_ops_type_3
*icmp_neighb_disc_3
;
414 icmp_neighb_disc_3
= (struct icmpv6_neighb_disc_ops_type_3
*)
415 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_3
));
416 if (icmp_neighb_disc_3
== NULL
)
418 len
-= sizeof(*icmp_neighb_disc_3
);
422 tprintf("Prefix Len (%u) ",icmp_neighb_disc_3
->prefix_len
);
423 tprintf("L (%u) A (%u) Res1 (0x%x) ",icmp_neighb_disc_3
->l_a_res1
>> 7,
424 (icmp_neighb_disc_3
->l_a_res1
>> 7) & 0x1,
425 icmp_neighb_disc_3
->l_a_res1
& 0x3F);
426 tprintf("Valid Lifetime (%us) ",
427 ntohl(icmp_neighb_disc_3
->valid_lifetime
));
428 tprintf("Preferred Lifetime (%us) ",
429 ntohl(icmp_neighb_disc_3
->preferred_lifetime
));
430 tprintf("Reserved2 (0x%x) ",
431 ntohl(icmp_neighb_disc_3
->res2
));
432 tprintf("Prefix: %s ",
433 inet_ntop(AF_INET6
,&icmp_neighb_disc_3
->prefix
,
434 address
, sizeof(address
)));
439 static int8_t dissect_neighb_disc_ops_4(struct pkt_buff
*pkt
,
442 struct icmpv6_neighb_disc_ops_type_4
*icmp_neighb_disc_4
;
444 icmp_neighb_disc_4
= (struct icmpv6_neighb_disc_ops_type_4
*)
445 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_4
));
446 if (icmp_neighb_disc_4
== NULL
)
448 len
-= sizeof(*icmp_neighb_disc_4
);
452 tprintf("Reserved 1 (0x%x) ", ntohs(icmp_neighb_disc_4
->res1
));
453 tprintf("Reserved 2 (0x%x) ", ntohl(icmp_neighb_disc_4
->res2
));
454 tprintf("IP header + data ");
457 uint8_t *data
= pkt_pull(pkt
, 1);
460 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
465 tprintf("%x", *data
);
471 static int8_t dissect_neighb_disc_ops_5(struct pkt_buff
*pkt
,
474 struct icmpv6_neighb_disc_ops_type_5
*icmp_neighb_disc_5
;
476 icmp_neighb_disc_5
= (struct icmpv6_neighb_disc_ops_type_5
*)
477 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_5
));
478 if (icmp_neighb_disc_5
== NULL
)
480 len
-= sizeof(*icmp_neighb_disc_5
);
484 tprintf("Reserved (0x%x) ", ntohs(icmp_neighb_disc_5
->res1
));
485 tprintf("MTU (%u)", ntohl(icmp_neighb_disc_5
->MTU
));
490 static int8_t dissect_neighb_disc_ops_9(struct pkt_buff
*pkt
,
493 struct icmpv6_neighb_disc_ops_type_9_10
*icmp_neighb_disc_9
;
495 icmp_neighb_disc_9
= (struct icmpv6_neighb_disc_ops_type_9_10
*)
496 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_9
));
497 if (icmp_neighb_disc_9
== NULL
)
499 len
-= sizeof(*icmp_neighb_disc_9
);
503 tprintf("Reserved 1 (0x%x) ", ntohs(icmp_neighb_disc_9
->res1
));
504 tprintf("Reserved 2 (0x%x) ", ntohl(icmp_neighb_disc_9
->res2
));
506 return print_ipv6_addr_list(pkt
, len
/ sizeof(struct in6_addr
));
509 static int8_t dissect_neighb_disc_ops_10(struct pkt_buff
*pkt
,
512 return dissect_neighb_disc_ops_9(pkt
, len
);
515 static const char *icmpv6_neighb_disc_ops_15_name
[] = {
516 "DER Encoded X.501 Name",
520 static int8_t dissect_neighb_disc_ops_15(struct pkt_buff
*pkt
,
525 struct icmpv6_neighb_disc_ops_type_15
*icmp_neighb_disc_15
;
527 icmp_neighb_disc_15
= (struct icmpv6_neighb_disc_ops_type_15
*)
528 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_15
));
529 if (icmp_neighb_disc_15
== NULL
)
531 len
-= sizeof(*icmp_neighb_disc_15
);
534 pad_len
= icmp_neighb_disc_15
->pad_len
;
536 tprintf("Name Type %s (%u) ",
537 icmpv6_code_range_valid(icmp_neighb_disc_15
->name_type
- 1,
538 icmpv6_neighb_disc_ops_15_name
) ?
539 icmpv6_neighb_disc_ops_15_name
[
540 icmp_neighb_disc_15
->name_type
- 1] : "Unknown",
541 icmp_neighb_disc_15
->name_type
);
542 if (pad_len
> (size_t) len
) {
543 tprintf("Pad Len (%zu, invalid)\n%s", pad_len
,
544 colorize_start_full(black
, red
)
545 "Skip Option" colorize_end());
550 tprintf("Pad Len (%zu) ", pad_len
);
552 name_len
= len
- pad_len
;
556 uint8_t *data
= pkt_pull(pkt
, 1);
559 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
564 tprintf("%c", *data
);
568 tprintf("Padding (");
571 uint8_t *data
= pkt_pull(pkt
, 1);
574 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
579 tprintf("%x", *data
);
586 static const char *icmpv6_neighb_disc_ops_16_cert
[] = {
587 "X.509v3 Certificate",
590 static int8_t dissect_neighb_disc_ops_16(struct pkt_buff
*pkt
,
593 struct icmpv6_neighb_disc_ops_type_16
*icmp_neighb_disc_16
;
595 icmp_neighb_disc_16
= (struct icmpv6_neighb_disc_ops_type_16
*)
596 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_16
));
597 if (icmp_neighb_disc_16
== NULL
)
599 len
-= sizeof(*icmp_neighb_disc_16
);
603 tprintf("Cert Type %s (%u) ",
604 icmpv6_code_range_valid(icmp_neighb_disc_16
->cert_type
- 1,
605 icmpv6_neighb_disc_ops_16_cert
) ?
606 icmpv6_neighb_disc_ops_16_cert
[
607 icmp_neighb_disc_16
->cert_type
- 1] : "Unknown",
608 icmp_neighb_disc_16
->cert_type
);
609 tprintf("Res (0x%x) ", icmp_neighb_disc_16
->res
);
611 tprintf("Certificate + Padding (");
613 uint8_t *data
= pkt_pull(pkt
, 1);
616 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
621 tprintf("%x", *data
);
628 static const char *icmpv6_neighb_disc_ops_17_codes
[] = {
629 "Old Care-of Address",
630 "New Care-of Address",
635 static int8_t dissect_neighb_disc_ops_17(struct pkt_buff
*pkt
,
638 char address
[INET6_ADDRSTRLEN
];
639 struct icmpv6_neighb_disc_ops_type_17
*icmp_neighb_disc_17
;
641 icmp_neighb_disc_17
= (struct icmpv6_neighb_disc_ops_type_17
*)
642 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_17
));
643 if (icmp_neighb_disc_17
== NULL
)
645 len
-= sizeof(*icmp_neighb_disc_17
);
649 tprintf("Opt Code %s (%u) ",
650 icmpv6_code_range_valid(icmp_neighb_disc_17
->opt_code
- 1,
651 icmpv6_neighb_disc_ops_17_codes
) ?
652 icmpv6_neighb_disc_ops_17_codes
[
653 icmp_neighb_disc_17
->opt_code
- 1] : "Unknown",
654 icmp_neighb_disc_17
->opt_code
);
655 tprintf("Prefix Len (%u) ", icmp_neighb_disc_17
->prefix_len
);
657 if (len
== sizeof(struct icmpv6_neighb_disc_ops_type_17_1
)) {
658 struct icmpv6_neighb_disc_ops_type_17_1
659 *icmp_neighb_disc_17_1
;
661 icmp_neighb_disc_17_1
=
662 (struct icmpv6_neighb_disc_ops_type_17_1
*)
663 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_17_1
));
664 if (icmp_neighb_disc_17_1
== NULL
)
666 len
-= sizeof(*icmp_neighb_disc_17_1
);
670 tprintf("Res (0x%x) ",icmp_neighb_disc_17_1
->res
);
672 inet_ntop(AF_INET6
,&icmp_neighb_disc_17_1
->ipv6_addr
,
673 address
, sizeof(address
)));
675 else if (len
== sizeof(struct icmpv6_neighb_disc_ops_type_17_2
)) {
676 struct icmpv6_neighb_disc_ops_type_17_2
677 *icmp_neighb_disc_17_2
;
679 icmp_neighb_disc_17_2
=
680 (struct icmpv6_neighb_disc_ops_type_17_2
*)
681 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_17_2
));
682 if (icmp_neighb_disc_17_2
== NULL
)
684 len
-= sizeof(*icmp_neighb_disc_17_2
);
689 inet_ntop(AF_INET6
,&icmp_neighb_disc_17_2
->ipv6_addr
,
690 address
, sizeof(address
)));
693 tprintf("%s (", colorize_start_full(black
, red
)
694 "Error Wrong Length. Skip Option" colorize_end());
696 uint8_t *data
= pkt_pull(pkt
, 1);
699 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
704 tprintf("%x", *data
);
712 static const char *icmpv6_neighb_disc_ops_19_codes
[] = {
713 "Wildcard requesting resolution for all nearby access points",
714 "Link-Layer Address of the New Access Point",
715 "Link-Layer Address of the MN",
716 "Link-Layer Address of the NAR",
717 "Link-Layer Address of the source of RtSolPr or PrRtAdv \
719 "The access point identified by the LLA belongs to the \
720 current interface of the router",
721 "No prefix information available for the access point \
722 identified by the LLA",
723 "No fast handover support available for the access point \
724 identified by the LLA",
727 static int8_t dissect_neighb_disc_ops_19(struct pkt_buff
*pkt
,
730 struct icmpv6_neighb_disc_ops_type_19
*icmp_neighb_disc_19
;
732 icmp_neighb_disc_19
= (struct icmpv6_neighb_disc_ops_type_19
*)
733 pkt_pull(pkt
,sizeof(*icmp_neighb_disc_19
));
734 if (icmp_neighb_disc_19
== NULL
)
736 len
-= sizeof(*icmp_neighb_disc_19
);
740 tprintf("Opt Code %s (%u) ",
741 icmpv6_code_range_valid(icmp_neighb_disc_19
->opt_code
,
742 icmpv6_neighb_disc_ops_19_codes
) ?
743 icmpv6_neighb_disc_ops_19_codes
[
744 icmp_neighb_disc_19
->opt_code
] : "Unknown",
745 icmp_neighb_disc_19
->opt_code
);
749 uint8_t *data
= pkt_pull(pkt
, 1);
752 tprintf("%sINVALID%s", colorize_start_full(black
, red
),
757 tprintf("%x", *data
);
764 static inline char *icmpv6_neighb_disc_ops(uint8_t code
) {
766 case 1: return "Source Link-Layer Address";
767 case 2: return "Target Link-Layer Address";
768 case 3: return "Prefix Information";
769 case 4: return "Redirected Header";
770 case 5: return "MTU";
771 case 6: return "NBMA Shortcut Limit Option";
772 case 7: return "Advertisement Interval Option";
773 case 8: return "Home Agent Information Option";
774 case 9: return "Source Address List";
775 case 10: return "Target Address List";
776 case 11: return "CGA option";
777 case 12: return "RSA Signature option";
778 case 13: return "Timestamp option";
779 case 14: return "Nonce option";
780 case 15: return "Trust Anchor option";
781 case 16: return "Certificate option";
782 case 17: return "IP Address/Prefix Option";
783 case 18: return "New Router Prefix Information Option";
784 case 19: return "Link-layer Address Option";
785 case 20: return "Neighbor Advertisement Acknowledgment Option";
787 case 23: return "Prefix Information";
788 case 24: return "Redirected Header";
789 case 25: return "MTU";
790 case 26: return "NBMA Shortcut Limit Option";
791 case 27: return "Advertisement Interval Option";
792 case 28: return "Home Agent Information Option";
793 case 29: return "Source Address List";
794 case 30: return "Target Address List";
795 case 31: return "DNS Search List Option";
796 case 32: return "Proxy Signature (PS)";
798 case 138: return "CARD Request option";
799 case 139: return "CARD Reply option";
801 case 253: return "RFC3692-style Experiment 1";
802 case 254: return "RFC3692-style Experiment 2";
808 static int8_t dissect_neighb_disc_ops(struct pkt_buff
*pkt
)
811 uint16_t ops_total_len
;
812 ssize_t ops_payl_len
;
813 struct icmpv6_neighb_disc_ops_general
*icmp_neighb_disc
;
815 while(pkt_len(pkt
)) {
816 icmp_neighb_disc
= (struct icmpv6_neighb_disc_ops_general
*)
817 pkt_pull(pkt
,sizeof(*icmp_neighb_disc
));
818 if (icmp_neighb_disc
== NULL
)
821 ops_total_len
= icmp_neighb_disc
->len
* 8;
822 pad_bytes
= (size_t) (ops_total_len
% 8);
823 ops_payl_len
= ops_total_len
- sizeof(*icmp_neighb_disc
) -
826 tprintf("\n\tOption %s (%u) ",
827 icmpv6_neighb_disc_ops(icmp_neighb_disc
->type
) ?
828 icmpv6_neighb_disc_ops(icmp_neighb_disc
->type
)
829 : "Type Unknown", icmp_neighb_disc
->type
);
830 if (ops_payl_len
> pkt_len(pkt
) || ops_payl_len
< 0) {
831 tprintf("Length (%u, %u bytes, %s%s%s) ",
832 icmp_neighb_disc
->len
,
834 colorize_start_full(black
, red
),
835 "invalid", colorize_end());
839 tprintf("Length (%u, %u bytes) ",icmp_neighb_disc
->len
,
842 switch (icmp_neighb_disc
->type
) {
844 if (!dissect_neighb_disc_ops_1(pkt
, ops_payl_len
))
848 if (!dissect_neighb_disc_ops_2(pkt
, ops_payl_len
))
852 if (!dissect_neighb_disc_ops_3(pkt
, ops_payl_len
))
856 if (!dissect_neighb_disc_ops_4(pkt
, ops_payl_len
))
860 if (!dissect_neighb_disc_ops_5(pkt
, ops_payl_len
))
863 /* Type 9 and 10 defined in
864 * http://tools.ietf.org/html/rfc3122#section-3.1
867 if (!dissect_neighb_disc_ops_9(pkt
, ops_payl_len
))
871 if (!dissect_neighb_disc_ops_10(pkt
, ops_payl_len
))
874 /* Type 15 and 16 defined in
875 * http://tools.ietf.org/html/rfc3971#section-6.4.3
876 * http://tools.ietf.org/html/rfc3971#section-6.4.4
879 if (!dissect_neighb_disc_ops_15(pkt
, ops_payl_len
))
883 if (!dissect_neighb_disc_ops_16(pkt
, ops_payl_len
))
886 /* Type 17 and 19 defined in
887 * http://tools.ietf.org/html/rfc5568#section-6.4
890 if (!dissect_neighb_disc_ops_17(pkt
, ops_payl_len
))
894 if (!dissect_neighb_disc_ops_19(pkt
, ops_payl_len
))
898 pkt_pull(pkt
, ops_payl_len
);
901 /* Skip Padding Bytes */
902 if (pad_bytes
> pkt_len(pkt
)) {
903 tprintf(" %s",colorize_start_full(black
, red
)
904 "Invalid Padding" colorize_end());
907 pkt_pull(pkt
, pad_bytes
);
913 static const char *icmpv6_type_1_codes
[] = {
914 "No route to destination",
915 "Communication with destination administratively prohibited",
916 "Beyond scope of source address",
917 "Address unreachable",
919 "Source address failed ingress/egress policy",
920 "Reject route to destination",
921 "Error in Source Routing Header",
924 static int8_t dissect_icmpv6_type1(struct pkt_buff
*pkt
)
926 struct icmpv6_type_1_3
*icmp_1
;
928 icmp_1
= (struct icmpv6_type_1_3
*) pkt_pull(pkt
,sizeof(*icmp_1
));
932 tprintf(", Unused (0x%x)",ntohl(icmp_1
->unused
));
933 tprintf(" Payload include as much of invoking packet");
938 static int8_t dissect_icmpv6_type2(struct pkt_buff
*pkt
)
940 struct icmpv6_type_2
*icmp_2
;
942 icmp_2
= (struct icmpv6_type_2
*) pkt_pull(pkt
,sizeof(*icmp_2
));
946 tprintf(", MTU (0x%x)",ntohl(icmp_2
->MTU
));
947 tprintf(" Payload include as much of invoking packet");
952 static const char *icmpv6_type_3_codes
[] = {
953 "Hop limit exceeded in transit",
954 "Fragment reassembly time exceeded",
957 static int8_t dissect_icmpv6_type3(struct pkt_buff
*pkt
)
959 struct icmpv6_type_1_3
*icmp_3
;
961 icmp_3
= (struct icmpv6_type_1_3
*) pkt_pull(pkt
,sizeof(*icmp_3
));
965 tprintf(", Unused (0x%x)",ntohl(icmp_3
->unused
));
966 tprintf(" Payload include as much of invoking packet");
971 static const char *icmpv6_type_4_codes
[] = {
972 "Erroneous header field encountered",
973 "Unrecognized Next Header type encountered",
974 "Unrecognized IPv6 option encountered",
977 static int8_t dissect_icmpv6_type4(struct pkt_buff
*pkt
)
979 struct icmpv6_type_4
*icmp_4
;
981 icmp_4
= (struct icmpv6_type_4
*) pkt_pull(pkt
,sizeof(*icmp_4
));
985 tprintf(", Pointer (0x%x)",ntohl(icmp_4
->pointer
));
986 tprintf(" Payload include as much of invoking packet");
991 static int8_t dissect_icmpv6_type128(struct pkt_buff
*pkt
)
993 struct icmpv6_type_128_129
*icmp_128
;
995 icmp_128
= (struct icmpv6_type_128_129
*)
996 pkt_pull(pkt
,sizeof(*icmp_128
));
997 if (icmp_128
== NULL
)
1000 tprintf(", ID (0x%x)",ntohs(icmp_128
->id
));
1001 tprintf(", Seq. Nr. (%u)",ntohs(icmp_128
->sn
));
1002 tprintf(" Payload include Data");
1007 static int8_t dissect_icmpv6_type129(struct pkt_buff
*pkt
)
1009 struct icmpv6_type_128_129
*icmp_129
;
1011 icmp_129
= (struct icmpv6_type_128_129
*)
1012 pkt_pull(pkt
,sizeof(*icmp_129
));
1013 if (icmp_129
== NULL
)
1016 tprintf(", ID (0x%x)",ntohs(icmp_129
->id
));
1017 tprintf(", Seq. Nr. (%u)",ntohs(icmp_129
->sn
));
1018 tprintf(" Payload include Data");
1023 static int8_t dissect_icmpv6_type130(struct pkt_buff
*pkt
)
1025 char address
[INET6_ADDRSTRLEN
];
1026 uint16_t nr_src
, maxrespdel
;
1027 uint8_t switch_mldv2
= 0;
1028 struct icmpv6_type_130_131_132
*icmp_130
;
1030 icmp_130
= (struct icmpv6_type_130_131_132
*)
1031 pkt_pull(pkt
,sizeof(*icmp_130
));
1032 if (icmp_130
== NULL
)
1034 maxrespdel
= ntohs(icmp_130
->maxrespdel
);
1036 if(pkt_len(pkt
) >= sizeof(struct icmpv6_type_130_mldv2
))
1040 tprintf(", MLDv2, Max Resp Delay (%ums)", maxrespdel
>> 15 ?
1041 (((maxrespdel
& 0xFFF) | 0x1000) <<
1042 (((maxrespdel
>> 12) & 0x3) + 3)) : maxrespdel
);
1044 tprintf(", Max Resp Delay (%ums)",maxrespdel
);
1045 tprintf(", Res (0x%x)",ntohs(icmp_130
->res
));
1046 tprintf(", Address: %s",
1047 inet_ntop(AF_INET6
, &icmp_130
->ipv6_addr
,
1048 address
, sizeof(address
)));
1051 struct icmpv6_type_130_mldv2
*icmp_130_mldv2
;
1053 icmp_130_mldv2
= (struct icmpv6_type_130_mldv2
*)
1054 pkt_pull(pkt
,sizeof(*icmp_130_mldv2
));
1055 if (icmp_130_mldv2
== NULL
)
1058 nr_src
= ntohs(icmp_130_mldv2
->nr_src
);
1060 tprintf(", Resv (0x%x)",icmp_130_mldv2
->resv_S_QRV
>> 4);
1061 tprintf(", S (%u)",(icmp_130_mldv2
->resv_S_QRV
>> 3) & 0x1);
1062 tprintf(", QRV (0x%x)",icmp_130_mldv2
->resv_S_QRV
& 0x3);
1063 tprintf(", QQIC (%u)",icmp_130_mldv2
->QQIC
);
1064 tprintf(", Nr Src (%u)",nr_src
);
1066 return print_ipv6_addr_list(pkt
, nr_src
);
1072 static int8_t dissect_icmpv6_type131(struct pkt_buff
*pkt
)
1074 char address
[INET6_ADDRSTRLEN
];
1075 struct icmpv6_type_130_131_132
*icmp_131
;
1077 icmp_131
= (struct icmpv6_type_130_131_132
*)
1078 pkt_pull(pkt
,sizeof(*icmp_131
));
1079 if (icmp_131
== NULL
)
1082 tprintf(", Max Resp Delay (%ums)",ntohs(icmp_131
->maxrespdel
));
1083 tprintf(", Res (0x%x)",ntohs(icmp_131
->res
));
1084 tprintf(", Address: %s",
1085 inet_ntop(AF_INET6
, &icmp_131
->ipv6_addr
,
1086 address
, sizeof(address
)));
1091 static inline int8_t dissect_icmpv6_type132(struct pkt_buff
*pkt
)
1093 return dissect_icmpv6_type131(pkt
);
1096 static int8_t dissect_icmpv6_type133(struct pkt_buff
*pkt
)
1098 struct icmpv6_type_133_141_142
*icmp_133
;
1100 icmp_133
= (struct icmpv6_type_133_141_142
*)
1101 pkt_pull(pkt
,sizeof(*icmp_133
));
1102 if (icmp_133
== NULL
)
1105 tprintf(", Reserved (0x%x)",ntohl(icmp_133
->res
));
1107 return dissect_neighb_disc_ops(pkt
);
1110 static int8_t dissect_icmpv6_type134(struct pkt_buff
*pkt
)
1112 struct icmpv6_type_134
*icmp_134
;
1114 icmp_134
= (struct icmpv6_type_134
*)
1115 pkt_pull(pkt
,sizeof(*icmp_134
));
1116 if (icmp_134
== NULL
)
1119 tprintf(", Cur Hop Limit (%u)",icmp_134
->cur_hop_limit
);
1120 tprintf(", M (%u) O (%u)",icmp_134
->m_o_res
>> 7,
1121 (icmp_134
->m_o_res
>> 6) & 0x1);
1122 tprintf(", Router Lifetime (%us)",ntohs(icmp_134
->router_lifetime
));
1123 tprintf(", Reachable Time (%ums)",ntohl(icmp_134
->reachable_time
));
1124 tprintf(", Retrans Timer (%ums)",ntohl(icmp_134
->retrans_timer
));
1126 return dissect_neighb_disc_ops(pkt
);
1129 static int8_t dissect_icmpv6_type135(struct pkt_buff
*pkt
)
1131 char address
[INET6_ADDRSTRLEN
];
1132 struct icmpv6_type_135
*icmp_135
;
1134 icmp_135
= (struct icmpv6_type_135
*)
1135 pkt_pull(pkt
,sizeof(*icmp_135
));
1136 if (icmp_135
== NULL
)
1139 tprintf(", Reserved (0x%x)",ntohl(icmp_135
->res
));
1140 tprintf(", Target Address: %s",
1141 inet_ntop(AF_INET6
, &icmp_135
->ipv6_addr
,
1142 address
, sizeof(address
)));
1144 return dissect_neighb_disc_ops(pkt
);
1147 static int8_t dissect_icmpv6_type136(struct pkt_buff
*pkt
)
1149 char address
[INET6_ADDRSTRLEN
];
1151 struct icmpv6_type_136
*icmp_136
;
1153 icmp_136
= (struct icmpv6_type_136
*)
1154 pkt_pull(pkt
,sizeof(*icmp_136
));
1155 if (icmp_136
== NULL
)
1157 r_s_o_res
= ntohl(icmp_136
->r_s_o_res
);
1159 tprintf(", R (%u) S (%u) O (%u) Reserved (0x%x)", r_s_o_res
>> 31,
1160 (r_s_o_res
>> 30) & 0x1, (r_s_o_res
>> 29) & 0x1,
1161 r_s_o_res
& 0x1FFFFFFF);
1162 tprintf(", Target Address: %s",
1163 inet_ntop(AF_INET6
, &icmp_136
->ipv6_addr
,
1164 address
, sizeof(address
)));
1166 return dissect_neighb_disc_ops(pkt
);
1169 static int8_t dissect_icmpv6_type137(struct pkt_buff
*pkt
)
1171 char address
[INET6_ADDRSTRLEN
];
1172 struct icmpv6_type_137
*icmp_137
;
1174 icmp_137
= (struct icmpv6_type_137
*)
1175 pkt_pull(pkt
,sizeof(*icmp_137
));
1176 if (icmp_137
== NULL
)
1179 tprintf(", Reserved (0x%x)",icmp_137
->res
);
1180 tprintf(", Target Address: %s",
1181 inet_ntop(AF_INET6
, &icmp_137
->ipv6_targ_addr
,
1182 address
, sizeof(address
)));
1183 tprintf(", Dest Address: %s",
1184 inet_ntop(AF_INET6
, &icmp_137
->ipv6_dest_addr
,
1185 address
, sizeof(address
)));
1187 return dissect_neighb_disc_ops(pkt
);
1190 static void dissect_icmpv6_rr_body(struct pkt_buff
*pkt
)
1193 * Upgrade Dissector for Message Body
1194 * from http://tools.ietf.org/html/rfc2894#section-3.2
1197 tprintf(" Message Body recognized");
1200 static inline char *icmpv6_type_138_codes(uint8_t code
) {
1202 case 1: return "Router Renumbering Command";
1203 case 2: return "Router Renumbering Result";
1204 case 255: return "Sequence Number Reset";
1210 static int8_t dissect_icmpv6_type138(struct pkt_buff
*pkt
)
1212 struct icmpv6_type_138
*icmp_138
;
1214 icmp_138
= (struct icmpv6_type_138
*)
1215 pkt_pull(pkt
,sizeof(*icmp_138
));
1216 if (icmp_138
== NULL
)
1219 tprintf(", Sequence Nr. (%u)",ntohl(icmp_138
->seq_nr
));
1220 tprintf(", Segment Nr. (%u)",icmp_138
->seg_nr
);
1221 tprintf(", T (%u) R (%u) A (%u) S (%u) P (%u) Res \
1222 (0x%x) ",icmp_138
->flags
>> 7, (icmp_138
->flags
>> 6) & 1,
1223 (icmp_138
->flags
>> 5) & 1, (icmp_138
->flags
>> 4) & 1,
1224 (icmp_138
->flags
>> 3) & 1, icmp_138
->flags
& 7);
1225 tprintf(", Max Delay (%ums)", ntohs(icmp_138
->maxdelay
));
1226 tprintf(", Res (0x%x)", ntohl(icmp_138
->res
));
1228 dissect_icmpv6_rr_body(pkt
);
1233 static void dissect_icmpv6_node_inf_data(struct pkt_buff
*pkt
)
1236 * Upgrade Dissector for Data field
1237 * http://tools.ietf.org/html/rfc4620#section-4
1240 tprintf(" Data recognized");
1243 static const char *icmpv6_node_inf_qtypes
[] = {
1251 static const char *icmpv6_type_139_codes
[] = {
1252 "Data contains IPv6 Address",
1253 "Data contains Name or nothing",
1254 "Data contains IPv4 Address",
1257 static int8_t dissect_icmpv6_type139(struct pkt_buff
*pkt
)
1259 const char *qtype_name
= "Unknown";
1261 struct icmpv6_type_139_140
*icmp_139
;
1263 icmp_139
= (struct icmpv6_type_139_140
*)
1264 pkt_pull(pkt
,sizeof(*icmp_139
));
1265 if (icmp_139
== NULL
)
1268 qtype_nr
= ntohs(icmp_139
->qtype
);
1269 if (icmpv6_code_range_valid(qtype_nr
, icmpv6_node_inf_qtypes
))
1270 qtype_name
= icmpv6_node_inf_qtypes
[qtype_nr
];
1272 tprintf(", Qtype %s (%u)", qtype_name
, qtype_nr
);
1273 tprintf(", Flags (0x%x)", ntohs(icmp_139
->flags
));
1274 tprintf(", Nonce (0x%"PRIx64
")", ntohll(icmp_139
->nonce
));
1276 dissect_icmpv6_node_inf_data(pkt
);
1281 static char *icmpv6_type_140_codes
[] = {
1283 "Responder refuses answer",
1284 "Qtype is unknown to the Responder",
1287 static inline int8_t dissect_icmpv6_type140(struct pkt_buff
*pkt
)
1289 return dissect_icmpv6_type139(pkt
);
1292 static inline int8_t dissect_icmpv6_type141(struct pkt_buff
*pkt
)
1294 return dissect_icmpv6_type133(pkt
);
1297 static inline int8_t dissect_icmpv6_type142(struct pkt_buff
*pkt
)
1299 return dissect_icmpv6_type133(pkt
);
1302 static int8_t dissect_icmpv6_type143(struct pkt_buff
*pkt
)
1305 struct icmpv6_type_143
*icmp_143
;
1307 icmp_143
= (struct icmpv6_type_143
*)
1308 pkt_pull(pkt
,sizeof(*icmp_143
));
1309 if (icmp_143
== NULL
)
1311 nr_rec
= ntohs(icmp_143
->nr_rec
);
1313 tprintf(", Res (0x%x)",ntohs(icmp_143
->res
));
1314 tprintf(", Nr. Mcast Addr Records (%u)",nr_rec
);
1316 return dissect_icmpv6_mcast_rec(pkt
, nr_rec
);
1319 static int8_t dissect_icmpv6_type144(struct pkt_buff
*pkt
)
1321 struct icmpv6_type_144_146
*icmp_144
;
1323 icmp_144
= (struct icmpv6_type_144_146
*)
1324 pkt_pull(pkt
,sizeof(*icmp_144
));
1325 if (icmp_144
== NULL
)
1328 tprintf(", ID (%u)",ntohs(icmp_144
->id
));
1329 tprintf(", Res (0x%x)",ntohs(icmp_144
->res
));
1334 static int8_t dissect_icmpv6_type145(struct pkt_buff
*pkt
)
1336 struct icmpv6_type_145
*icmp_145
;
1338 icmp_145
= (struct icmpv6_type_145
*)
1339 pkt_pull(pkt
,sizeof(*icmp_145
));
1340 if (icmp_145
== NULL
)
1343 tprintf(", ID (%u)",ntohs(icmp_145
->id
));
1344 tprintf(", Res (0x%x)",ntohs(icmp_145
->res
));
1346 return print_ipv6_addr_list(pkt
, pkt_len(pkt
) /
1347 sizeof(struct in6_addr
));
1350 static inline int8_t dissect_icmpv6_type146(struct pkt_buff
*pkt
)
1352 return dissect_icmpv6_type144(pkt
);
1355 static int8_t dissect_icmpv6_type147(struct pkt_buff
*pkt
)
1358 struct icmpv6_type_147
*icmp_147
;
1360 icmp_147
= (struct icmpv6_type_147
*)
1361 pkt_pull(pkt
,sizeof(*icmp_147
));
1362 if (icmp_147
== NULL
)
1364 m_o_res
= ntohs(icmp_147
->m_o_res
);
1366 tprintf(", ID (%u)",ntohs(icmp_147
->id
));
1367 tprintf(", M (%u) O (%u) Res (0x%x)",m_o_res
>> 15,
1368 (m_o_res
>> 14) & 1, m_o_res
& 0x3FFF);
1370 return dissect_neighb_disc_ops(pkt
);
1373 static int8_t dissect_icmpv6_type148(struct pkt_buff
*pkt
)
1375 struct icmpv6_type_148
*icmp_148
;
1377 icmp_148
= (struct icmpv6_type_148
*)
1378 pkt_pull(pkt
,sizeof(*icmp_148
));
1379 if (icmp_148
== NULL
)
1382 tprintf(", ID (%u)",ntohs(icmp_148
->id
));
1383 tprintf(", Component (%u)",ntohs(icmp_148
->comp
));
1385 return dissect_neighb_disc_ops(pkt
);
1388 static int8_t dissect_icmpv6_type149(struct pkt_buff
*pkt
)
1390 struct icmpv6_type_149
*icmp_149
;
1392 icmp_149
= (struct icmpv6_type_149
*)
1393 pkt_pull(pkt
,sizeof(*icmp_149
));
1394 if (icmp_149
== NULL
)
1397 tprintf(", ID (%u)",ntohs(icmp_149
->id
));
1398 tprintf(", All Components (%u)",ntohs(icmp_149
->all_comp
));
1399 tprintf(", Component (%u)",ntohs(icmp_149
->comp
));
1400 tprintf(", Res (0x%x)",ntohs(icmp_149
->res
));
1402 return dissect_neighb_disc_ops(pkt
);
1405 static int8_t dissect_icmpv6_type150(struct pkt_buff
*pkt
)
1407 struct icmpv6_type_150
*icmp_150
;
1409 icmp_150
= (struct icmpv6_type_150
*)
1410 pkt_pull(pkt
,sizeof(*icmp_150
));
1411 if (icmp_150
== NULL
)
1414 tprintf(", Subtype (%u)",icmp_150
->subtype
);
1415 tprintf(", Res (0x%x)",icmp_150
->res
);
1416 tprintf(", Options in Payload");
1421 static int8_t dissect_icmpv6_type151(struct pkt_buff
*pkt
)
1423 struct icmpv6_type_151
*icmp_151
;
1425 icmp_151
= (struct icmpv6_type_151
*)
1426 pkt_pull(pkt
,sizeof(*icmp_151
));
1427 if (icmp_151
== NULL
)
1430 tprintf(", Query Interval (%us)",ntohs(icmp_151
->query_intv
));
1431 tprintf(", Robustness Variable (%u)",ntohs(icmp_151
->rob_var
));
1436 static int8_t dissect_icmpv6_type152(struct pkt_buff
*pkt
)
1438 struct icmpv6_type_152
*icmp_152
;
1440 icmp_152
= (struct icmpv6_type_152
*)
1441 pkt_pull(pkt
,sizeof(*icmp_152
));
1442 if (icmp_152
== NULL
)
1448 static int8_t dissect_icmpv6_type153(struct pkt_buff
*pkt
)
1450 struct icmpv6_type_153
*icmp_153
;
1452 icmp_153
= (struct icmpv6_type_153
*)
1453 pkt_pull(pkt
,sizeof(*icmp_153
));
1454 if (icmp_153
== NULL
)
1460 static int8_t dissect_icmpv6_type154(struct pkt_buff
*pkt
)
1462 struct icmpv6_type_154
*icmp_154
;
1464 icmp_154
= (struct icmpv6_type_154
*)
1465 pkt_pull(pkt
,sizeof(*icmp_154
));
1466 if (icmp_154
== NULL
)
1469 tprintf(", Subtype (%u)",icmp_154
->subtype
);
1470 tprintf(", Res (0x%x)",icmp_154
->res
);
1471 tprintf(", ID (%u)",ntohs(icmp_154
->id
));
1473 return dissect_neighb_disc_ops(pkt
);
1476 static inline char *icmpv6_type_155_codes(uint8_t code
) {
1478 case 0x00: return "DODAG Information Solicitation";
1479 case 0x01: return "DODAG Information Object";
1480 case 0x02: return "Destination Advertisement Object";
1481 case 0x03: return "Destination Advertisement Object Acknowledgment";
1482 case 0x80: return "Secure DODAG Information Solicitation";
1483 case 0x81: return "Secure DODAG Information Object";
1484 case 0x82: return "Secure Destination Advertisement Object";
1485 case 0x83: return "Secure Destination Advertisement Object Acknowledgment";
1486 case 0x8A: return "Consistency Check";
1492 static void icmpv6_process(struct icmpv6_general_hdr
*icmp
, const char **type
,
1493 const char **code
, int8_t (**optional
)(struct pkt_buff
*pkt
))
1495 *type
= "Unknown Type";
1496 *code
= "Unknown Code";
1498 switch (icmp
->h_type
) {
1500 *type
= "Destination Unreachable";
1501 if (icmpv6_code_range_valid(icmp
->h_code
, icmpv6_type_1_codes
))
1502 *code
= icmpv6_type_1_codes
[icmp
->h_code
];
1503 *optional
= dissect_icmpv6_type1
;
1506 *type
= "Packet Too Big";
1507 *optional
= dissect_icmpv6_type2
;
1510 *type
= "Time Exceeded";
1511 if (icmpv6_code_range_valid(icmp
->h_code
, icmpv6_type_3_codes
))
1512 *code
= icmpv6_type_3_codes
[icmp
->h_code
];
1513 *optional
= dissect_icmpv6_type3
;
1516 *type
= "Parameter Problem";
1517 if (icmpv6_code_range_valid(icmp
->h_code
, icmpv6_type_4_codes
))
1518 *code
= icmpv6_type_4_codes
[icmp
->h_code
];
1519 *optional
= dissect_icmpv6_type4
;
1522 *type
= "Private experimation";
1525 *type
= "Private experimation";
1528 *type
= "Reserved for expansion of ICMPv6 error messages";
1531 *type
= "Echo Request";
1532 *optional
= dissect_icmpv6_type128
;
1535 *type
= "Echo Reply";
1536 *optional
= dissect_icmpv6_type129
;
1539 *type
= "Multicast Listener Query";
1540 *optional
= dissect_icmpv6_type130
;
1543 *type
= "Multicast Listener Report";
1544 *optional
= dissect_icmpv6_type131
;
1547 *type
= "Multicast Listener Done";
1548 *optional
= dissect_icmpv6_type132
;
1551 *type
= "Router Solicitation";
1552 *optional
= dissect_icmpv6_type133
;
1555 *type
= "Router Advertisement";
1556 *optional
= dissect_icmpv6_type134
;
1559 *type
= "Neighbor Solicitation";
1560 *optional
= dissect_icmpv6_type135
;
1563 *type
= "Neighbor Advertisement";
1564 *optional
= dissect_icmpv6_type136
;
1567 *type
= "Redirect Message";
1568 *optional
= dissect_icmpv6_type137
;
1571 *type
= "Router Renumbering";
1572 if(icmpv6_type_138_codes(icmp
->h_code
))
1573 *code
= icmpv6_type_138_codes(icmp
->h_code
);
1574 *optional
= dissect_icmpv6_type138
;
1577 *type
= "ICMP Node Information Query";
1578 if (icmpv6_code_range_valid(icmp
->h_code
,
1579 icmpv6_type_139_codes
))
1580 *code
= icmpv6_type_139_codes
[icmp
->h_code
];
1581 *optional
= dissect_icmpv6_type139
;
1584 *type
= "ICMP Node Information Response";
1585 if (icmpv6_code_range_valid(icmp
->h_code
,
1586 icmpv6_type_140_codes
))
1587 *code
= icmpv6_type_140_codes
[icmp
->h_code
];
1588 *optional
= dissect_icmpv6_type140
;
1591 *type
= "Inverse Neighbor Discovery Solicitation Message";
1592 *optional
= dissect_icmpv6_type141
;
1595 *type
= "Inverse Neighbor Discovery Advertisement Message";
1596 *optional
= dissect_icmpv6_type142
;
1599 *type
= "Multicast Listener Report v2";
1600 *optional
= dissect_icmpv6_type143
;
1603 *type
= "Home Agent Address Discovery Request Message";
1604 *optional
= dissect_icmpv6_type144
;
1607 *type
= "Home Agent Address Discovery Reply Message";
1608 *optional
= dissect_icmpv6_type145
;
1611 *type
= "Mobile Prefix Solicitation";
1612 *optional
= dissect_icmpv6_type146
;
1615 *type
= "Mobile Prefix Advertisement";
1616 *optional
= dissect_icmpv6_type147
;
1619 *type
= "Certification Path Solicitation";
1620 *optional
= dissect_icmpv6_type148
;
1623 *type
= "Certification Path Advertisement";
1624 *optional
= dissect_icmpv6_type149
;
1627 *type
= "ICMP messages utilized by experimental mobility "
1628 "protocols such as Seamoby";
1629 *optional
= dissect_icmpv6_type150
;
1632 *type
= "Multicast Router Advertisement";
1633 *code
= "Ad. Interval";
1634 *optional
= dissect_icmpv6_type151
;
1637 *type
= "Multicast Router Solicitation";
1639 *optional
= dissect_icmpv6_type152
;
1642 *type
= "Multicast Router Termination";
1644 *optional
= dissect_icmpv6_type153
;
1647 *type
= "FMIPv6 Messages";
1648 *optional
= dissect_icmpv6_type154
;
1651 *type
= "RPL Control Message";
1652 if(icmpv6_type_155_codes(icmp
->h_code
))
1653 *code
= icmpv6_type_155_codes(icmp
->h_code
);
1656 *type
= "Private experimation";
1659 *type
= "Private experimation";
1662 *type
= "Reserved for expansion of ICMPv6 error messages";
1667 static void icmpv6(struct pkt_buff
*pkt
)
1669 const char *type
= NULL
, *code
= NULL
;
1670 int8_t (*optional
)(struct pkt_buff
*pkt
) = NULL
;
1671 struct icmpv6_general_hdr
*icmp
=
1672 (struct icmpv6_general_hdr
*) pkt_pull(pkt
, sizeof(*icmp
));
1677 icmpv6_process(icmp
, &type
, &code
, &optional
);
1679 tprintf(" [ ICMPv6 ");
1680 tprintf("%s (%u), ", type
, icmp
->h_type
);
1681 tprintf("%s (%u), ", code
, icmp
->h_code
);
1682 tprintf("Chks (0x%x)", ntohs(icmp
->h_chksum
));
1684 if (!((*optional
) (pkt
)))
1685 tprintf("\n%s%s%s", colorize_start_full(black
, red
),
1686 "Failed to dissect Message", colorize_end());
1690 static void icmpv6_less(struct pkt_buff
*pkt
)
1692 struct icmpv6_general_hdr
*icmp
=
1693 (struct icmpv6_general_hdr
*) pkt_pull(pkt
, sizeof(*icmp
));
1698 tprintf(" ICMPv6 Type (%u) Code (%u)", icmp
->h_type
, icmp
->h_code
);
1701 struct protocol icmpv6_ops
= {
1703 .print_full
= icmpv6
,
1704 .print_less
= icmpv6_less
,