]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-icmp6.c
CHANGES: Add a change backported to 4.99
[tcpdump] / print-icmp6.c
index ae2596aca37fd0d6a9acd517a2cabd88c8e57dd3..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"
 
@@ -37,6 +35,7 @@
 
 #include "ip6.h"
 #include "ipproto.h"
+#include "icmp.h"
 
 #include "udp.h"
 #include "ah.h"
@@ -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 */
@@ -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 */
@@ -526,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;
@@ -668,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 }
 };
 
@@ -1253,7 +1258,8 @@ icmp6_print(netdissect_options *ndo,
 
                        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_PRINT(", %s", GET_IP6ADDR_STRING(p));
@@ -1284,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)