]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-icmp6.c
change make check to work with POSIX shell
[tcpdump] / print-icmp6.c
index 63f336b9fe81dfd79bbba56258c219e09d273992..5cef0efabd5fe78fd0ef92b218eb518f24fcf597 100644 (file)
 #include "udp.h"
 #include "ah.h"
 
+static const char icmp6_tstr[] = " [|icmp6]";
+static const char rpl_tstr[] = " [|rpl]";
+static const char mldv2_tstr[] = " [|mldv2]";
+
 /*     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 $  */
 
@@ -284,13 +288,13 @@ struct nd_opt_hdr {               /* Neighbor discovery option header */
 #define ND_OPT_DNSSL                   31
 
 struct nd_opt_prefix_info {    /* prefix information */
-       uint8_t         nd_opt_pi_type;
-       uint8_t         nd_opt_pi_len;
-       uint8_t         nd_opt_pi_prefix_len;
-       uint8_t         nd_opt_pi_flags_reserved;
-       uint8_t         nd_opt_pi_valid_time[4];
-       uint8_t         nd_opt_pi_preferred_time[4];
-       uint8_t         nd_opt_pi_reserved2[4];
+       nd_uint8_t              nd_opt_pi_type;
+       nd_uint8_t              nd_opt_pi_len;
+       nd_uint8_t              nd_opt_pi_prefix_len;
+       nd_uint8_t              nd_opt_pi_flags_reserved;
+       nd_uint32_t             nd_opt_pi_valid_time;
+       nd_uint32_t             nd_opt_pi_preferred_time;
+       nd_uint32_t             nd_opt_pi_reserved2;
        struct in6_addr nd_opt_pi_prefix;
 };
 
@@ -683,10 +687,11 @@ rpl_dio_printopt(netdissect_options *ndo,
                 }
                 opt = (const struct rpl_dio_genoption *)(((const char *)opt) + optlen);
                 length -= optlen;
+                ND_TCHECK(opt->rpl_dio_len);
         }
         return;
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 }
 
@@ -715,7 +720,7 @@ rpl_dio_print(netdissect_options *ndo,
         }
        return;
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 }
 
@@ -756,7 +761,7 @@ rpl_dao_print(netdissect_options *ndo,
        return;
 
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 
 tooshort:
@@ -800,7 +805,7 @@ rpl_daoack_print(netdissect_options *ndo,
        return;
 
 trunc:
-       ND_PRINT((ndo," [|dao-truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 
 tooshort:
@@ -859,7 +864,7 @@ rpl_print(netdissect_options *ndo,
 
 #if 0
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 #endif
 
@@ -1034,7 +1039,7 @@ icmp6_print(netdissect_options *ndo,
                        p = (const struct nd_router_advert *)dp;
                        ND_TCHECK(p->nd_ra_retransmit);
                        ND_PRINT((ndo,"\n\thop limit %u, Flags [%s]" \
-                                  ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
+                                  ", pref %s, router lifetime %us, reachable time %ums, retrans timer %ums",
                                   (u_int)p->nd_ra_curhoplimit,
                                   bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
                                   get_rtpref(p->nd_ra_flags_reserved),
@@ -1131,6 +1136,7 @@ icmp6_print(netdissect_options *ndo,
                if (ndo->ndo_vflag) {
                        ND_TCHECK(dp->icmp6_data16[0]);
                        ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
+                       ND_TCHECK(dp->icmp6_data16[1]);
                        if (dp->icmp6_data16[1] & 0xc0)
                                ND_PRINT((ndo," "));
                        if (dp->icmp6_data16[1] & 0x80)
@@ -1156,7 +1162,7 @@ icmp6_print(netdissect_options *ndo,
                 ND_PRINT((ndo,", length %u", length));
        return;
 trunc:
-       ND_PRINT((ndo, "[|icmp6]"));
+       ND_PRINT((ndo, "%s", icmp6_tstr));
 }
 
 static const struct udphdr *
@@ -1380,8 +1386,8 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
        }
        return;
 
- trunc:
-       ND_PRINT((ndo, "[ndp opt]"));
+trunc:
+       ND_PRINT((ndo, "%s", icmp6_tstr));
        return;
 #undef ECHECK
 }
@@ -1456,7 +1462,7 @@ mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
     }
     return;
 trunc:
-    ND_PRINT((ndo,"[|icmp6]"));
+    ND_PRINT((ndo, "%s", mldv2_tstr));
     return;
 }
 
@@ -1522,7 +1528,7 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
     ND_PRINT((ndo,"]"));
     return;
 trunc:
-    ND_PRINT((ndo,"[|icmp6]"));
+    ND_PRINT((ndo, "%s", mldv2_tstr));
     return;
 }
 
@@ -1698,6 +1704,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
 
                needcomma = 0;
 
+               ND_TCHECK2(*dp, sizeof(*ni6));
                ni6 = (const struct icmp6_nodeinfo *)dp;
                ND_PRINT((ndo," node information reply"));
                ND_PRINT((ndo," ("));   /*)*/
@@ -1752,6 +1759,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                ND_PRINT((ndo,", "));
                        ND_PRINT((ndo,"DNS name"));
                        cp = (const u_char *)(ni6 + 1) + 4;
+                       ND_TCHECK(cp[0]);
                        if (cp[0] == ep - cp - 1) {
                                /* icmp-name-lookup-03, pascal string */
                                if (ndo->ndo_vflag)
@@ -1807,7 +1815,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
        return;
 
 trunc:
-       ND_PRINT((ndo, "[|icmp6]"));
+       ND_PRINT((ndo, "%s", icmp6_tstr));
 }
 
 static void
@@ -1942,7 +1950,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
        return;
 
 trunc:
-       ND_PRINT((ndo,"[|icmp6]"));
+       ND_PRINT((ndo, "%s", icmp6_tstr));
 }
 
 /*