You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/17 07:52:13 UTC

[incubator-nuttx] branch master updated: dns_recv_response: Fix IPv6 address in an ninfo()

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 4666b39  dns_recv_response: Fix IPv6 address in an ninfo()
4666b39 is described below

commit 4666b39f9c753ba0a3677506ac1218e645b5ab8b
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 17 14:34:04 2021 +0900

    dns_recv_response: Fix IPv6 address in an ninfo()
---
 libs/libc/netdb/lib_dnsquery.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libs/libc/netdb/lib_dnsquery.c b/libs/libc/netdb/lib_dnsquery.c
index 97d9b3f..45c9843 100644
--- a/libs/libc/netdb/lib_dnsquery.c
+++ b/libs/libc/netdb/lib_dnsquery.c
@@ -518,10 +518,14 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
           nameptr += 10 + 16;
 
           ninfo("IPv6 address: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
-                ntohs(ans->u.ipv6.s6_addr[7]), ntohs(ans->u.ipv6.s6_addr[6]),
-                ntohs(ans->u.ipv6.s6_addr[5]), ntohs(ans->u.ipv6.s6_addr[4]),
-                ntohs(ans->u.ipv6.s6_addr[3]), ntohs(ans->u.ipv6.s6_addr[2]),
-                ntohs(ans->u.ipv6.s6_addr[1]), ntohs(*ans->u.ipv6.s6_addr));
+                ntohs(ans->u.ipv6.s6_addr16[0]),
+                ntohs(ans->u.ipv6.s6_addr16[1]),
+                ntohs(ans->u.ipv6.s6_addr16[2]),
+                ntohs(ans->u.ipv6.s6_addr16[3]),
+                ntohs(ans->u.ipv6.s6_addr16[4]),
+                ntohs(ans->u.ipv6.s6_addr16[5]),
+                ntohs(ans->u.ipv6.s6_addr16[6]),
+                ntohs(ans->u.ipv6.s6_addr16[7]));
 
           inaddr                  = &addr[naddr_read].ipv6;
           inaddr->sin6_family     = AF_INET6;