From 500270d47d09559d5b2bae7d4a0fdb156931a009 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Sun, 6 Feb 2022 20:36:37 +0100 Subject: ICMPv6: Modernize RPL DAO parsing 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 | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'print-icmp6.c') diff --git a/print-icmp6.c b/print-icmp6.c index 78c3dbe8..f88d71f4 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -879,18 +879,14 @@ rpl_dao_print(netdissect_options *ndo, const char *dagid_str = ""; 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 -- cgit v1.2.1