From 0a673d78dc6456a25424272cf9bbb169e49e2174 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 9 Nov 2018 14:10:18 -0600 Subject: [PATCH] net/neighbor/neighbor_dumpentry.c: Simplify neighbor_dumpentry() implementation --- net/neighbor/neighbor_dumpentry.c | 32 ++++++++----------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/net/neighbor/neighbor_dumpentry.c b/net/neighbor/neighbor_dumpentry.c index 68de6e4241..12221fb526 100644 --- a/net/neighbor/neighbor_dumpentry.c +++ b/net/neighbor/neighbor_dumpentry.c @@ -65,10 +65,11 @@ * ******************************************************************************/ -static void neighbor_dump_address(FAR const uint8_t *buffer, unsigned int buflen) +static void neighbor_dump_address(FAR const void *buf, unsigned int buflen) { char outbuf[16*3 + 9]; /* 6-byte header header + 16 hex bytes + * 2 space separator + NUL termination */ + FAR const uint8_t *buffer = buf; FAR char *ptr; unsigned int i; unsigned int j; @@ -78,11 +79,11 @@ static void neighbor_dump_address(FAR const uint8_t *buffer, unsigned int buflen { if (i == 0) { - ninfo(" at: "); + sprintf(outbuf, " at: "); } else { - ninfo(" "); + sprintf(outbuf, " "); } maxj = 16; @@ -91,7 +92,7 @@ static void neighbor_dump_address(FAR const uint8_t *buffer, unsigned int buflen maxj = buflen - i; } - ptr = outbuf; + ptr = outbuf + 6; for (j = 0; j < maxj; j++) { if (j == 8) @@ -105,7 +106,7 @@ static void neighbor_dump_address(FAR const uint8_t *buffer, unsigned int buflen } *ptr = '\0'; - wlinfo(" %s\n", ptr); + ninfo("%s\n", ptr); } } @@ -138,25 +139,8 @@ void neighbor_dumpentry(FAR const char *msg, ntohs(neighbor->ne_ipaddr[4]), ntohs(neighbor->ne_ipaddr[5]), ntohs(neighbor->ne_ipaddr[6]), ntohs(neighbor->ne_ipaddr[7])); -#ifdef CONFIG_NET_ETHERNET -#ifdef CONFIG_NET_6LOWPAN - if (neighbor->ne_addr.na_lltype == NET_LL_ETHERNET) -#endif - { - neighbor_dump_address(neighbor->ne_addr.u.na_ethernet.ether_addr_octet, - neighbor->ne_addr.na_llsize); - } -#endif - -#ifdef CONFIG_NET_6LOWPAN -#ifdef CONFIG_NET_ETHERNET - else -#endif - { - neighbor_dump_address(neighbor->ne_addr.u.na_sixlowpan.nm_addr, - neighbor->ne_addr.na_llsize); - } -#endif /* CONFIG_NET_6LOWPAN */ + neighbor_dump_address(&neighbor->ne_addr.u, + neighbor->ne_addr.na_llsize); } /****************************************************************************