]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-icmp6.c
Fix spaces
[tcpdump] / print-icmp6.c
index 9bbd5c81f5d38a812db6b96f719eed06edf96d95..ce56999589600764c5ace843ca09091793269c2b 100644 (file)
@@ -1033,11 +1033,17 @@ icmp6_print(netdissect_options *ndo,
        const u_char *ep;
        u_int prot;
 
+       ndo->ndo_protocol = "icmp6";
        dp = (const struct icmp6_hdr *)bp;
        ip = (const struct ip6_hdr *)bp2;
        oip = (const struct ip6_hdr *)(dp + 1);
        /* 'ep' points to the end of available data. */
        ep = ndo->ndo_snapend;
+       if (length == 0) {
+               ND_PRINT("ICMP6, length 0");
+               ND_PRINT("%s", istr);
+               return;
+       }
 
        if (ndo->ndo_vflag && !fragmented) {
                uint16_t sum, udp_sum;
@@ -1193,7 +1199,7 @@ icmp6_print(netdissect_options *ndo,
                        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 %us, retrans time %us",
+                                  ", pref %s, router lifetime %us, reachable time %ums, retrans timer %ums",
                                   EXTRACT_U_1(p->nd_ra_curhoplimit),
                                   bittok2str(icmp6_opt_ra_flag_values,"none",EXTRACT_U_1(p->nd_ra_flags_reserved)),
                                   get_rtpref(EXTRACT_U_1(p->nd_ra_flags_reserved)),
@@ -1416,8 +1422,6 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
        size_t l;
        u_int i;
 
-#define ECHECK(var) if ((const u_char *)&(var) > ep - sizeof(var)) return
-
        cp = bp;
        /* 'ep' points to the end of available data. */
        ep = ndo->ndo_snapend;
@@ -1425,7 +1429,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
        while (cp < ep) {
                op = (const struct nd_opt_hdr *)cp;
 
-               ECHECK(op->nd_opt_len);
+               ND_TCHECK_1(op->nd_opt_len);
                if (resid <= 0)
                        return;
                opt_type = EXTRACT_U_1(op->nd_opt_type);
@@ -1491,7 +1495,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
                        while (domp < cp + (opt_len << 3) && EXTRACT_U_1(domp) != '\0')
                        {
                                ND_PRINT(" ");
-                               if ((domp = ns_nprint (ndo, domp, bp)) == NULL)
+                               if ((domp = ns_nprint(ndo, domp, bp)) == NULL)
                                        goto trunc;
                        }
                        break;
@@ -1550,7 +1554,6 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
  trunc:
        ND_PRINT("[ndp opt]");
        return;
-#undef ECHECK
 }
 
 static void
@@ -1710,7 +1713,7 @@ dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
                                break;
                        }
                        while (i-- && cp < ep) {
-                               safeputchar(ndo, EXTRACT_U_1(cp));
+                               fn_print_char(ndo, EXTRACT_U_1(cp));
                                cp++;
                        }
                        if (cp + 1 < ep && EXTRACT_U_1(cp))
@@ -1831,7 +1834,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                cp++;
                                ND_PRINT(", \"");
                                while (cp < ep) {
-                                       safeputchar(ndo, EXTRACT_U_1(cp));
+                                       fn_print_char(ndo, EXTRACT_U_1(cp));
                                        cp++;
                                }
                                ND_PRINT("\"");
@@ -1929,7 +1932,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                cp++;
                                ND_PRINT(", \"");
                                while (cp < ep) {
-                                       safeputchar(ndo, EXTRACT_U_1(cp));
+                                       fn_print_char(ndo, EXTRACT_U_1(cp));
                                        cp++;
                                }
                                ND_PRINT("\"");
@@ -2115,10 +2118,3 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
 trunc:
        ND_PRINT("[|icmp6]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */