]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ICMPv6: Modernize RPL DAO parsing
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 6 Feb 2022 19:36:37 +0000 (20:36 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 6 Feb 2022 19:39:58 +0000 (20:39 +0100)
Use GET_IP6ADDR_STRING(), ND_ICHECK_U() and nd_print_invalid().
Remove the redundant ND_TCHECK*() instances and the trunc label.
Fix indentation.

print-icmp6.c

index 78c3dbe84fd636ad080e42e3726663763b99a1cf..f88d71f48da506a48e251b446bf0d47d1debd908 100644 (file)
@@ -879,18 +879,14 @@ 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;
         }
@@ -906,14 +902,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;
+invalid:
+        nd_print_invalid(ndo);
 }
 
 static void