]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-icmp6.c
CHANGES: Add a change backported to 4.99
[tcpdump] / print-icmp6.c
index 0178a3558213fc6373070aacebc1bb9898f06636..5ab6a46e770aaebea5c1bb18fe1504b30ecdcc32 100644 (file)
@@ -21,9 +21,7 @@
 
 /* \summary: IPv6 Internet Control Message Protocol (ICMPv6) printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
 
 #include "ip6.h"
 #include "ipproto.h"
+#include "icmp.h"
 
 #include "udp.h"
 #include "ah.h"
 
-/*     NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp   */
+/*     NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp   */
 /*     $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $  */
 
 /*
@@ -94,6 +93,8 @@ struct icmp6_hdr {
 #define icmp6_id       icmp6_data16[0]         /* echo request/reply */
 #define icmp6_seq      icmp6_data16[1]         /* echo request/reply */
 #define icmp6_maxdelay icmp6_data16[0]         /* mcast group membership */
+#define icmp6_xseq     icmp6_data8[2]          /* extended echo request/reply */
+#define icmp6_xinfo    icmp6_data8[3]          /* extended echo request/reply */
 
 #define ICMP6_DST_UNREACH              1       /* dest unreachable, codes: */
 #define ICMP6_PACKET_TOO_BIG           2       /* packet too big */
@@ -103,7 +104,7 @@ struct icmp6_hdr {
 #define ICMP6_ECHO_REQUEST             128     /* echo service */
 #define ICMP6_ECHO_REPLY               129     /* echo reply */
 #define ICMP6_MEMBERSHIP_QUERY         130     /* group membership query */
-#define MLD6_LISTENER_QUERY            130     /* multicast listener query */
+#define MLD6_LISTENER_QUERY            130     /* multicast listener query */
 #define ICMP6_MEMBERSHIP_REPORT                131     /* group membership report */
 #define MLD6_LISTENER_REPORT           131     /* multicast listener report */
 #define ICMP6_MEMBERSHIP_REDUCTION     132     /* group membership termination */
@@ -132,6 +133,8 @@ struct icmp6_hdr {
 #define ICMP6_HADISCOV_REPLY           145
 #define ICMP6_MOBILEPREFIX_SOLICIT     146
 #define ICMP6_MOBILEPREFIX_ADVERT      147
+#define        ICMP6_EXTENDED_ECHO_REQUEST     160     /* extended echo request */
+#define        ICMP6_EXTENDED_ECHO_REPLY       161     /* extended echo reply */
 
 #define MLD6_MTRACE_RESP               200     /* mtrace response(to sender) */
 #define MLD6_MTRACE                    201     /* mtrace messages */
@@ -145,10 +148,10 @@ struct icmp6_hdr {
 #define ICMP6_DST_UNREACH_ADDR         3       /* address unreachable */
 #define ICMP6_DST_UNREACH_NOPORT       4       /* port unreachable */
 
-#define ICMP6_TIME_EXCEED_TRANSIT      0       /* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_TRANSIT      0       /* ttl==0 in transit */
 #define ICMP6_TIME_EXCEED_REASSEMBLY   1       /* ttl==0 in reass */
 
-#define ICMP6_PARAMPROB_HEADER                 0       /* erroneous header field */
+#define ICMP6_PARAMPROB_HEADER         0       /* erroneous header field */
 #define ICMP6_PARAMPROB_NEXTHEADER     1       /* unrecognized next header */
 #define ICMP6_PARAMPROB_OPTION         2       /* unrecognized option */
 #define ICMP6_PARAMPROB_FRAGHDRCHAIN   3       /* incomplete header chain */
@@ -193,7 +196,7 @@ struct mld6_hdr {
  */
 
 struct nd_router_solicit {     /* router solicitation */
-       struct icmp6_hdr        nd_rs_hdr;
+       struct icmp6_hdr        nd_rs_hdr;
        /* could be followed by options */
 };
 
@@ -394,18 +397,13 @@ struct icmp6_nodeinfo {
 #define NI_QTYPE_NODEADDR      3 /* Node Addresses */
 #define NI_QTYPE_IPV4ADDR      4 /* IPv4 Addresses */
 
-/* network endian */
-#define NI_SUPTYPE_FLAG_COMPRESS       ((uint16_t)htons(0x1))
-#define NI_FQDN_FLAG_VALIDTTL          ((uint16_t)htons(0x1))
-
-/* network endian */
-#define NI_NODEADDR_FLAG_TRUNCATE      ((uint16_t)htons(0x1))
-#define NI_NODEADDR_FLAG_ALL           ((uint16_t)htons(0x2))
-#define NI_NODEADDR_FLAG_COMPAT                ((uint16_t)htons(0x4))
-#define NI_NODEADDR_FLAG_LINKLOCAL     ((uint16_t)htons(0x8))
-#define NI_NODEADDR_FLAG_SITELOCAL     ((uint16_t)htons(0x10))
-#define NI_NODEADDR_FLAG_GLOBAL                ((uint16_t)htons(0x20))
-#define NI_NODEADDR_FLAG_ANYCAST       ((uint16_t)htons(0x40)) /* just experimental. not in spec */
+#define NI_NODEADDR_FLAG_TRUNCATE      0x0001
+#define NI_NODEADDR_FLAG_ALL           0x0002
+#define NI_NODEADDR_FLAG_COMPAT                0x0004
+#define NI_NODEADDR_FLAG_LINKLOCAL     0x0008
+#define NI_NODEADDR_FLAG_SITELOCAL     0x0010
+#define NI_NODEADDR_FLAG_GLOBAL                0x0020
+#define NI_NODEADDR_FLAG_ANYCAST       0x0040 /* just experimental. not in spec */
 
 struct ni_reply_fqdn {
        nd_uint32_t ni_fqdn_ttl;        /* TTL */
@@ -432,7 +430,7 @@ struct icmp6_router_renum { /* router renumbering header */
 #define rr_type                rr_hdr.icmp6_type
 #define rr_code                rr_hdr.icmp6_code
 #define rr_cksum       rr_hdr.icmp6_cksum
-#define rr_seqnum      rr_hdr.icmp6_data32[0]
+#define rr_seqnum      rr_hdr.icmp6_data32[0]
 
 struct rr_pco_match {          /* match prefix part */
        nd_uint8_t              rpm_code;
@@ -490,10 +488,6 @@ static void dnsname_print(netdissect_options *ndo, const u_char *, const u_char
 static void icmp6_nodeinfo_print(netdissect_options *ndo, u_int, const u_char *, const u_char *);
 static void icmp6_rrenum_print(netdissect_options *ndo, const u_char *, const u_char *);
 
-#ifndef abs
-#define abs(a) ((0 < (a)) ? (a) : -(a))
-#endif
-
 /*
  * DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
  */
@@ -535,7 +529,7 @@ struct nd_rpl_security {
 #endif
 };
 
-/* section 6.2.1, DODAG Information Solication (DIS_IS) */
+/* section 6.2.1, DODAG Information Solicitation (DIS_IS) */
 struct nd_rpl_dis_is {
     nd_uint8_t rpl_dis_flags;
     nd_uint8_t rpl_dis_reserved;
@@ -677,6 +671,8 @@ static const struct tok icmp6_type_values[] = {
     { MLD6_MTRACE, "mtrace message"},
     { MLD6_MTRACE_RESP, "mtrace response"},
     { ND_RPL_MESSAGE,   "RPL"},
+    { ICMP6_EXTENDED_ECHO_REQUEST, "extended echo request"},
+    { ICMP6_EXTENDED_ECHO_REPLY, "extended echo reply"},
     { 0,       NULL }
 };
 
@@ -711,7 +707,6 @@ static const struct tok icmp6_nd_na_flag_values[] = {
     { 0,       NULL }
 };
 
-
 static const struct tok icmp6_opt_values[] = {
    { ND_OPT_SOURCE_LINKADDR, "source link-address"},
    { ND_OPT_TARGET_LINKADDR, "destination link-address"},
@@ -816,21 +811,20 @@ rpl_printopts(netdissect_options *ndo, const uint8_t *opts, u_int length)
 
        while (length != 0) {
                opt = (const struct rpl_genoption *)opts;
-               ND_TCHECK_1(opt->rpl_dio_type);
                dio_type = GET_U_1(opt->rpl_dio_type);
                if (dio_type == RPL_OPT_PAD1) {
                         optlen = 1;
                         ND_PRINT(" opt:pad1");
                 } else {
-                       if (length < RPL_GENOPTION_LEN)
-                               goto trunc;
+                       if (length < RPL_GENOPTION_LEN)
+                               goto trunc;
                        optlen = GET_U_1(opt->rpl_dio_len)+RPL_GENOPTION_LEN;
                         ND_PRINT(" opt:%s len:%u ",
                                   tok2str(rpl_subopt_values, "subopt:%u", dio_type),
                                   optlen);
                         ND_TCHECK_LEN(opt, optlen);
                         if (length < optlen)
-                               goto trunc;
+                               goto trunc;
                         if (ndo->ndo_vflag > 2) {
                                 hex_print(ndo,
                                           " ",
@@ -844,7 +838,6 @@ rpl_printopts(netdissect_options *ndo, const uint8_t *opts, u_int length)
         return;
 trunc:
        nd_print_trunc(ndo);
-       return;
 }
 
 static void
@@ -852,28 +845,25 @@ rpl_dio_print(netdissect_options *ndo,
               const u_char *bp, u_int length)
 {
         const struct nd_rpl_dio *dio = (const struct nd_rpl_dio *)bp;
-        const char *dagid_str;
-
-        ND_TCHECK_SIZE(dio);
-        dagid_str = ip6addr_string (ndo, dio->rpl_dagid);
 
+        ND_ICHECK_ZU(length, <, sizeof(struct nd_rpl_dio));
         ND_PRINT(" [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
-                  dagid_str,
+                  GET_IP6ADDR_STRING(dio->rpl_dagid),
                   GET_U_1(dio->rpl_dtsn),
                   GET_U_1(dio->rpl_instanceid),
                   GET_BE_U_2(dio->rpl_dagrank),
                   RPL_DIO_GROUNDED(GET_U_1(dio->rpl_mopprf)) ? "grounded,":"",
-                  tok2str(rpl_mop_values, "mop%u", RPL_DIO_MOP(GET_U_1(dio->rpl_mopprf))),
+                  tok2str(rpl_mop_values, "mop%u",
+                          RPL_DIO_MOP(GET_U_1(dio->rpl_mopprf))),
                   RPL_DIO_PRF(GET_U_1(dio->rpl_mopprf)));
 
         if(ndo->ndo_vflag > 1) {
                 rpl_printopts(ndo, bp + sizeof(struct nd_rpl_dio),
                               length - sizeof(struct nd_rpl_dio));
         }
-       return;
-trunc:
-       nd_print_trunc(ndo);
-       return;
+        return;
+invalid:
+        nd_print_invalid(ndo);
 }
 
 static void
@@ -884,23 +874,19 @@ rpl_dao_print(netdissect_options *ndo,
         const char *dagid_str = "<elided>";
         uint8_t rpl_flags;
 
-        ND_TCHECK_SIZE(dao);
-        if (length < ND_RPL_DAO_MIN_LEN)
-               goto tooshort;
+        ND_ICHECK_U(length, <, ND_RPL_DAO_MIN_LEN);
 
         bp += ND_RPL_DAO_MIN_LEN;
         length -= ND_RPL_DAO_MIN_LEN;
         rpl_flags = GET_U_1(dao->rpl_flags);
         if(RPL_DAO_D(rpl_flags)) {
-                ND_TCHECK_LEN(dao->rpl_dagid, DAGID_LEN);
-                if (length < DAGID_LEN)
-                       goto tooshort;
-                dagid_str = ip6addr_string (ndo, dao->rpl_dagid);
+                ND_ICHECK_U(length, <, DAGID_LEN);
+                dagid_str = GET_IP6ADDR_STRING(dao->rpl_dagid);
                 bp += DAGID_LEN;
                 length -= DAGID_LEN;
         }
 
-        ND_PRINT(" [dagid:%s,seq:%u,instance:%u%s%s,%02x]",
+        ND_PRINT(" [dagid:%s,seq:%u,instance:%u%s%s,flags:%02x]",
                   dagid_str,
                   GET_U_1(dao->rpl_daoseq),
                   GET_U_1(dao->rpl_instanceid),
@@ -911,15 +897,9 @@ rpl_dao_print(netdissect_options *ndo,
         if(ndo->ndo_vflag > 1) {
                 rpl_printopts(ndo, bp, length);
         }
-       return;
-
-trunc:
-       nd_print_trunc(ndo);
-       return;
-
-tooshort:
-       ND_PRINT(" [|length too short]");
-       return;
+        return;
+invalid:
+        nd_print_invalid(ndo);
 }
 
 static void
@@ -929,17 +909,13 @@ rpl_daoack_print(netdissect_options *ndo,
         const struct nd_rpl_daoack *daoack = (const struct nd_rpl_daoack *)bp;
         const char *dagid_str = "<elided>";
 
-        ND_TCHECK_LEN(daoack, ND_RPL_DAOACK_MIN_LEN);
-        if (length < ND_RPL_DAOACK_MIN_LEN)
-               goto tooshort;
+        ND_ICHECK_U(length, <, ND_RPL_DAOACK_MIN_LEN);
 
         bp += ND_RPL_DAOACK_MIN_LEN;
         length -= ND_RPL_DAOACK_MIN_LEN;
         if(RPL_DAOACK_D(GET_U_1(daoack->rpl_flags))) {
-                ND_TCHECK_LEN(daoack->rpl_dagid, DAGID_LEN);
-                if (length < DAGID_LEN)
-                       goto tooshort;
-                dagid_str = ip6addr_string (ndo, daoack->rpl_dagid);
+                ND_ICHECK_U(length, <, DAGID_LEN);
+                dagid_str = GET_IP6ADDR_STRING(daoack->rpl_dagid);
                 bp += DAGID_LEN;
                 length -= DAGID_LEN;
         }
@@ -954,15 +930,9 @@ rpl_daoack_print(netdissect_options *ndo,
         if(ndo->ndo_vflag > 1) {
                 rpl_printopts(ndo, bp, length);
         }
-       return;
-
-trunc:
-       nd_print_trunc(ndo);
-       return;
-
-tooshort:
-       ND_PRINT(" [|dao-length too short]");
-       return;
+        return;
+invalid:
+        nd_print_invalid(ndo);
 }
 
 static void
@@ -1022,7 +992,6 @@ trunc:
 
 }
 
-
 void
 icmp6_print(netdissect_options *ndo,
             const u_char *bp, u_int length, const u_char *bp2, int fragmented)
@@ -1052,7 +1021,6 @@ icmp6_print(netdissect_options *ndo,
                uint16_t sum, udp_sum;
 
                if (ND_TTEST_LEN(bp, length)) {
-                       ND_TCHECK_2(dp->icmp6_cksum);
                        udp_sum = GET_BE_U_2(dp->icmp6_cksum);
                        sum = icmp6_cksum(ndo, ip, dp, length);
                        if (sum != 0)
@@ -1064,7 +1032,6 @@ icmp6_print(netdissect_options *ndo,
                }
        }
 
-       ND_TCHECK_1(dp->icmp6_type);
        icmp6_type = GET_U_1(dp->icmp6_type);
        ND_PRINT("ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",icmp6_type));
 
@@ -1078,24 +1045,22 @@ icmp6_print(netdissect_options *ndo,
                       icmp6_type == ICMP6_MOBILEPREFIX_ADVERT ))
                 ND_PRINT(", length %u", length);
 
-       ND_TCHECK_1(dp->icmp6_code);
        icmp6_code = GET_U_1(dp->icmp6_code);
 
        switch (icmp6_type) {
        case ICMP6_DST_UNREACH:
-               ND_TCHECK_16(oip->ip6_dst);
                 ND_PRINT(", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",icmp6_code));
                switch (icmp6_code) {
 
                case ICMP6_DST_UNREACH_NOROUTE: /* fall through */
                case ICMP6_DST_UNREACH_ADMIN:
                case ICMP6_DST_UNREACH_ADDR:
-                        ND_PRINT(" %s",ip6addr_string(ndo, oip->ip6_dst));
+                        ND_PRINT(" %s",GET_IP6ADDR_STRING(oip->ip6_dst));
                         break;
                case ICMP6_DST_UNREACH_BEYONDSCOPE:
                        ND_PRINT(" %s, source address %s",
-                              ip6addr_string(ndo, oip->ip6_dst),
-                                  ip6addr_string(ndo, oip->ip6_src));
+                              GET_IP6ADDR_STRING(oip->ip6_dst),
+                                  GET_IP6ADDR_STRING(oip->ip6_src));
                        break;
                case ICMP6_DST_UNREACH_NOPORT:
                        if ((ouh = get_upperlayer(ndo, (const u_char *)oip, &prot))
@@ -1106,17 +1071,17 @@ icmp6_print(netdissect_options *ndo,
                        switch (prot) {
                        case IPPROTO_TCP:
                                ND_PRINT(", %s tcp port %s",
-                                       ip6addr_string(ndo, oip->ip6_dst),
+                                       GET_IP6ADDR_STRING(oip->ip6_dst),
                                           tcpport_string(ndo, dport));
                                break;
                        case IPPROTO_UDP:
                                ND_PRINT(", %s udp port %s",
-                                       ip6addr_string(ndo, oip->ip6_dst),
+                                       GET_IP6ADDR_STRING(oip->ip6_dst),
                                           udpport_string(ndo, dport));
                                break;
                        default:
                                ND_PRINT(", %s protocol %u port %u unreachable",
-                                       ip6addr_string(ndo, oip->ip6_dst),
+                                       GET_IP6ADDR_STRING(oip->ip6_dst),
                                           prot, dport);
                                break;
                        }
@@ -1130,15 +1095,13 @@ icmp6_print(netdissect_options *ndo,
                }
                break;
        case ICMP6_PACKET_TOO_BIG:
-               ND_TCHECK_4(dp->icmp6_mtu);
                ND_PRINT(", mtu %u", GET_BE_U_4(dp->icmp6_mtu));
                break;
        case ICMP6_TIME_EXCEEDED:
-               ND_TCHECK_16(oip->ip6_dst);
                switch (icmp6_code) {
                case ICMP6_TIME_EXCEED_TRANSIT:
                        ND_PRINT(" for %s",
-                                  ip6addr_string(ndo, oip->ip6_dst));
+                                  GET_IP6ADDR_STRING(oip->ip6_dst));
                        break;
                case ICMP6_TIME_EXCEED_REASSEMBLY:
                        ND_PRINT(" (reassembly)");
@@ -1175,8 +1138,6 @@ icmp6_print(netdissect_options *ndo,
                break;
        case ICMP6_ECHO_REQUEST:
        case ICMP6_ECHO_REPLY:
-                /* The check below covers both icmp6_id and icmp6_seq. */
-                ND_TCHECK_2(dp->icmp6_seq);
                 ND_PRINT(", id %u, seq %u", GET_BE_U_2(dp->icmp6_id),
                         GET_BE_U_2(dp->icmp6_seq));
                break;
@@ -1210,7 +1171,6 @@ icmp6_print(netdissect_options *ndo,
                        const struct nd_router_advert *p;
 
                        p = (const struct nd_router_advert *)dp;
-                       ND_TCHECK_4(p->nd_ra_retransmit);
                        ND_PRINT("\n\thop limit %u, Flags [%s]"
                                   ", pref %s, router lifetime %us, reachable time %ums, retrans timer %ums",
                                   GET_U_1(p->nd_ra_curhoplimit),
@@ -1229,8 +1189,7 @@ icmp6_print(netdissect_options *ndo,
            {
                const struct nd_neighbor_solicit *p;
                p = (const struct nd_neighbor_solicit *)dp;
-               ND_TCHECK_16(p->nd_ns_target);
-               ND_PRINT(", who has %s", ip6addr_string(ndo, p->nd_ns_target));
+               ND_PRINT(", who has %s", GET_IP6ADDR_STRING(p->nd_ns_target));
                if (ndo->ndo_vflag) {
 #define NDSOLLEN 24
                        if (icmp6_opt_print(ndo, (const u_char *)dp + NDSOLLEN,
@@ -1244,9 +1203,8 @@ icmp6_print(netdissect_options *ndo,
                const struct nd_neighbor_advert *p;
 
                p = (const struct nd_neighbor_advert *)dp;
-               ND_TCHECK_16(p->nd_na_target);
                ND_PRINT(", tgt is %s",
-                          ip6addr_string(ndo, p->nd_na_target));
+                          GET_IP6ADDR_STRING(p->nd_na_target));
                if (ndo->ndo_vflag) {
                         ND_PRINT(", Flags [%s]",
                                   bittok2str(icmp6_nd_na_flag_values,
@@ -1265,10 +1223,8 @@ icmp6_print(netdissect_options *ndo,
                const struct nd_redirect *p;
 
                p = (const struct nd_redirect *)dp;
-               ND_TCHECK_16(p->nd_rd_dst);
-               ND_PRINT(", %s", ip6addr_string(ndo, p->nd_rd_dst));
-               ND_TCHECK_16(p->nd_rd_target);
-               ND_PRINT(" to %s", ip6addr_string(ndo, p->nd_rd_target));
+               ND_PRINT(", %s", GET_IP6ADDR_STRING(p->nd_rd_dst));
+               ND_PRINT(" to %s", GET_IP6ADDR_STRING(p->nd_rd_target));
 #define REDIRECTLEN 40
                if (ndo->ndo_vflag) {
                        if (icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN,
@@ -1293,7 +1249,6 @@ icmp6_print(netdissect_options *ndo,
                break;
        case ICMP6_MOBILEPREFIX_SOLICIT: /* fall through */
        case ICMP6_HADISCOV_REQUEST:
-                ND_TCHECK_2(dp->icmp6_data16[0]);
                 ND_PRINT(", id 0x%04x", GET_BE_U_2(dp->icmp6_data16[0]));
                 break;
        case ICMP6_HADISCOV_REPLY:
@@ -1301,14 +1256,13 @@ icmp6_print(netdissect_options *ndo,
                        const u_char *cp;
                        const u_char *p;
 
-                       ND_TCHECK_2(dp->icmp6_data16[0]);
                        ND_PRINT(", id 0x%04x",
                                 GET_BE_U_2(dp->icmp6_data16[0]));
-                       cp = (const u_char *)dp + length;
+                       cp = (const u_char *)dp +
+                               ND_MIN(length, ND_BYTES_AVAILABLE_AFTER(dp));
                        p = (const u_char *)(dp + 1);
                        while (p < cp) {
-                               ND_TCHECK_16(p);
-                               ND_PRINT(", %s", ip6addr_string(ndo, p));
+                               ND_PRINT(", %s", GET_IP6ADDR_STRING(p));
                                p += 16;
                        }
                }
@@ -1317,10 +1271,8 @@ icmp6_print(netdissect_options *ndo,
                if (ndo->ndo_vflag) {
                        uint16_t flags;
 
-                       ND_TCHECK_2(dp->icmp6_data16[0]);
                        ND_PRINT(", id 0x%04x",
                                 GET_BE_U_2(dp->icmp6_data16[0]));
-                       ND_TCHECK_2(dp->icmp6_data16[1]);
                        flags = GET_BE_U_2(dp->icmp6_data16[1]);
                        if (flags & 0xc000)
                                ND_PRINT(" ");
@@ -1338,6 +1290,17 @@ icmp6_print(netdissect_options *ndo,
                 /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
                 rpl_print(ndo, icmp6_code, dp->icmp6_data, length-sizeof(struct icmp6_hdr)+4);
                 break;
+       case ICMP6_EXTENDED_ECHO_REQUEST:
+       case ICMP6_EXTENDED_ECHO_REPLY:
+               ND_PRINT(", id %u, seq %u", GET_BE_U_2(dp->icmp6_id),
+                       GET_U_1(dp->icmp6_xseq));
+               // The content of the message is the same as ICMP, so use the
+               // function defined in print-icmp.c
+               if (ndo->ndo_vflag) {
+                       uint8_t xinfo = GET_U_1(dp->icmp6_xinfo);
+                       print_icmp_rfc8335(ndo, xinfo, icmp6_type == ICMP6_EXTENDED_ECHO_REQUEST, icmp6_code, dp->icmp6_data + 4);
+               }
+               break;
        default:
                 ND_PRINT(", length %u", length);
                 if (ndo->ndo_vflag <= 1)
@@ -1382,8 +1345,7 @@ get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
                        if (ND_TTEST_2(uh->uh_dport)) {
                                *prot = nh;
                                return(uh);
-                       }
-                       else
+                       } else
                                return(NULL);
                        /* NOTREACHED */
 
@@ -1429,7 +1391,8 @@ static int
 icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
 {
        const struct nd_opt_hdr *op;
-       uint8_t opt_type, opt_len;
+       uint8_t opt_type;
+       u_int opt_len;
        const struct nd_opt_prefix_info *opp;
        const struct nd_opt_mtu *opm;
        const struct nd_opt_rdnss *oprd;
@@ -1476,9 +1439,8 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
                        break;
                case ND_OPT_PREFIX_INFORMATION:
                        opp = (const struct nd_opt_prefix_info *)op;
-                       ND_TCHECK_16(opp->nd_opt_pi_prefix);
                         ND_PRINT("%s/%u%s, Flags [%s], valid time %s",
-                                  ip6addr_string(ndo, opp->nd_opt_pi_prefix),
+                                  GET_IP6ADDR_STRING(opp->nd_opt_pi_prefix),
                                   GET_U_1(opp->nd_opt_pi_prefix_len),
                                   (opt_len != 4) ? "badlen" : "",
                                   bittok2str(icmp6_opt_pi_flag_values, "none", GET_U_1(opp->nd_opt_pi_flags_reserved)),
@@ -1492,7 +1454,6 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
                        break;
                case ND_OPT_MTU:
                        opm = (const struct nd_opt_mtu *)op;
-                       ND_TCHECK_4(opm->nd_opt_mtu_mtu);
                        ND_PRINT(" %u%s",
                                GET_BE_U_4(opm->nd_opt_mtu_mtu),
                                (opt_len != 1) ? "bad option length" : "" );
@@ -1503,9 +1464,8 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
                        ND_PRINT(" lifetime %us,",
                                   GET_BE_U_4(oprd->nd_opt_rdnss_lifetime));
                        for (i = 0; i < l; i++) {
-                               ND_TCHECK_16(oprd->nd_opt_rdnss_addr[i]);
                                ND_PRINT(" addr: %s",
-                                          ip6addr_string(ndo, oprd->nd_opt_rdnss_addr[i]));
+                                          GET_IP6ADDR_STRING(oprd->nd_opt_rdnss_addr[i]));
                        }
                        break;
                case ND_OPT_DNSSL:
@@ -1513,8 +1473,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
                        ND_PRINT(" lifetime %us, domain(s):",
                                   GET_BE_U_4(opds->nd_opt_dnssl_lifetime));
                        domp = cp + 8; /* domain names, variable-sized, RFC1035-encoded */
-                       while (domp < cp + (opt_len << 3) && GET_U_1(domp) != '\0')
-                       {
+                       while (domp < cp + (opt_len << 3) && GET_U_1(domp) != '\0') {
                                ND_PRINT(" ");
                                if ((domp = fqdn_print(ndo, domp, bp)) == NULL)
                                        goto trunc;
@@ -1522,13 +1481,11 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
                        break;
                case ND_OPT_ADVINTERVAL:
                        opa = (const struct nd_opt_advinterval *)op;
-                       ND_TCHECK_4(opa->nd_opt_adv_interval);
                        ND_PRINT(" %ums",
                                 GET_BE_U_4(opa->nd_opt_adv_interval));
                        break;
                 case ND_OPT_HOMEAGENT_INFO:
                        oph = (const struct nd_opt_homeagent_info *)op;
-                       ND_TCHECK_2(oph->nd_opt_hai_lifetime);
                        ND_PRINT(" preference %u, lifetime %u",
                                   GET_BE_U_2(oph->nd_opt_hai_preference),
                                   GET_BE_U_2(oph->nd_opt_hai_lifetime));
@@ -1541,17 +1498,15 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
                        case 1:
                                break;
                        case 2:
-                               ND_TCHECK_8(opri + 1);
-                               memcpy(&in6, opri + 1, 8);
+                               GET_CPY_BYTES(&in6, opri + 1, 8);
                                break;
                        case 3:
-                               ND_TCHECK_16(opri + 1);
-                               memcpy(&in6, opri + 1, 16);
+                               GET_CPY_BYTES(&in6, opri + 1, 16);
                                break;
                        default:
                                goto trunc;
                        }
-                       ND_PRINT(" %s/%u", ip6addr_string(ndo, (const u_char *)&in6),
+                       ND_PRINT(" %s/%u", ip6addr_string(ndo, (const u_char *)&in6), /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
                                   GET_U_1(opri->nd_opt_rti_prefixlen));
                        ND_PRINT(", pref=%s",
                                 get_rtpref(GET_U_1(opri->nd_opt_rti_flags)));
@@ -1591,7 +1546,7 @@ mld6_print(netdissect_options *ndo, const u_char *bp)
                return;
 
        ND_PRINT("max resp delay: %u ", GET_BE_U_2(mp->mld6_maxdelay));
-       ND_PRINT("addr: %s", ip6addr_string(ndo, mp->mld6_addr));
+       ND_PRINT("addr: %s", GET_IP6ADDR_STRING(mp->mld6_addr));
 }
 
 static void
@@ -1607,7 +1562,6 @@ mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
             return;
     }
 
-    ND_TCHECK_2(icp->icmp6_data16[1]);
     ngroups = GET_BE_U_2(icp->icmp6_data16[1]);
     ND_PRINT(", %u group record(s)", ngroups);
     if (ndo->ndo_vflag > 0) {
@@ -1619,8 +1573,7 @@ mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
                     ND_PRINT(" [invalid number of groups]");
                     return;
            }
-            ND_TCHECK_LEN(bp + 4 + group, sizeof(nd_ipv6));
-            ND_PRINT(" [gaddr %s", ip6addr_string(ndo, bp + group + 4));
+            ND_PRINT(" [gaddr %s", GET_IP6ADDR_STRING(bp + group + 4));
            ND_PRINT(" %s", tok2str(mldv2report2str, " [v2-report-#%u]",
                                          GET_U_1(bp + group)));
             nsrcs = GET_BE_U_2(bp + group + 2);
@@ -1635,9 +1588,7 @@ mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
                /* Print the sources */
                     ND_PRINT(" {");
                 for (j = 0; j < nsrcs; j++) {
-                    ND_TCHECK_LEN(bp + group + 20 + (j * sizeof(nd_ipv6)),
-                                  sizeof(nd_ipv6));
-                   ND_PRINT(" %s", ip6addr_string(ndo, bp + group + 20 + (j * sizeof(nd_ipv6))));
+                   ND_PRINT(" %s", GET_IP6ADDR_STRING(bp + group + 20 + (j * sizeof(nd_ipv6))));
                }
                 ND_PRINT(" }");
             }
@@ -1646,10 +1597,6 @@ mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
            ND_PRINT("]");
         }
     }
-    return;
-trunc:
-    nd_print_trunc(ndo);
-    return;
 }
 
 static void
@@ -1666,7 +1613,6 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
         ND_PRINT(" [invalid len %u]", len);
        return;
     }
-    ND_TCHECK_2(icp->icmp6_data16[0]);
     mrc = GET_BE_U_2(icp->icmp6_data16[0]);
     if (mrc < 32768) {
        mrt = mrc;
@@ -1676,11 +1622,9 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
     if (ndo->ndo_vflag) {
             ND_PRINT(" [max resp delay=%u]", mrt);
     }
-    ND_TCHECK_LEN(bp + 8, sizeof(nd_ipv6));
-    ND_PRINT(" [gaddr %s", ip6addr_string(ndo, bp + 8));
+    ND_PRINT(" [gaddr %s", GET_IP6ADDR_STRING(bp + 8));
 
     if (ndo->ndo_vflag) {
-        ND_TCHECK_1(bp + 25);
        if (GET_U_1(bp + 24) & 0x08) {
                ND_PRINT(" sflag");
        }
@@ -1696,7 +1640,6 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
        ND_PRINT(" qqi=%u", qqi);
     }
 
-    ND_TCHECK_2(bp + 26);
     nsrcs = GET_BE_U_2(bp + 26);
     if (nsrcs > 0) {
        if (len < 28 + nsrcs * sizeof(nd_ipv6))
@@ -1704,19 +1647,13 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
        else if (ndo->ndo_vflag > 1) {
            ND_PRINT(" {");
            for (i = 0; i < nsrcs; i++) {
-               ND_TCHECK_LEN(bp + 28 + (i * sizeof(nd_ipv6)),
-                              sizeof(nd_ipv6));
-               ND_PRINT(" %s", ip6addr_string(ndo, bp + 28 + (i * sizeof(nd_ipv6))));
+               ND_PRINT(" %s", GET_IP6ADDR_STRING(bp + 28 + (i * sizeof(nd_ipv6))));
            }
            ND_PRINT(" }");
        } else
                 ND_PRINT(", %u source(s)", nsrcs);
     }
     ND_PRINT("]");
-    return;
-trunc:
-    nd_print_trunc(ndo);
-    return;
 }
 
 static void
@@ -1825,7 +1762,6 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                        break;
                }
 
-
                /* XXX backward compat, icmp-name-lookup-03 */
                if (siz == sizeof(*ni6)) {
                        ND_PRINT(", 03 draft");
@@ -1845,7 +1781,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                break;
                        }
                        ND_PRINT(", subject=%s",
-                                  ip6addr_string(ndo, cp));
+                                  GET_IP6ADDR_STRING(cp));
                        break;
                case ICMP6_NI_SUBJ_FQDN:
                        ND_PRINT(", subject=DNS name");
@@ -1872,7 +1808,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                break;
                        }
                        ND_PRINT(", subject=%s",
-                                  ipaddr_string(ndo, cp));
+                                  GET_IPADDR_STRING(cp));
                        break;
                default:
                        ND_PRINT(", unknown subject");
@@ -1944,7 +1880,6 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                ND_PRINT(", ");
                        ND_PRINT("DNS name");
                        cp = (const u_char *)(ni6 + 1) + 4;
-                       ND_TCHECK_1(cp);
                        if (GET_U_1(cp) == ep - cp - 1) {
                                /* icmp-name-lookup-03, pascal string */
                                if (ndo->ndo_vflag)
@@ -1970,7 +1905,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                if (i + sizeof(uint32_t) + sizeof(nd_ipv6) > siz)
                                        break;
                                ND_PRINT(" %s(%u)",
-                                   ip6addr_string(ndo, bp + i + sizeof(uint32_t)),
+                                   GET_IP6ADDR_STRING(bp + i + sizeof(uint32_t)),
                                    GET_BE_U_4(bp + i));
                                i += sizeof(uint32_t) + sizeof(nd_ipv6);
                        }
@@ -2021,16 +1956,16 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
        ND_TCHECK_4(rr6->rr_reserved);
        switch (GET_U_1(rr6->rr_code)) {
        case ICMP6_ROUTER_RENUMBERING_COMMAND:
-               ND_PRINT("router renum: command");
+               ND_PRINT(", command");
                break;
        case ICMP6_ROUTER_RENUMBERING_RESULT:
-               ND_PRINT("router renum: result");
+               ND_PRINT(", result");
                break;
        case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
-               ND_PRINT("router renum: sequence number reset");
+               ND_PRINT(", sequence number reset");
                break;
        default:
-               ND_PRINT("router renum: code-#%u", GET_U_1(rr6->rr_code));
+               ND_PRINT(", code-#%u", GET_U_1(rr6->rr_code));
                break;
        }