libc/netdb: Support save the mix of IPv4/IPv6 address into hostent

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I704d38afde14b6d90a7726096fd1f483f96ba237
This commit is contained in:
Xiang Xiao
2020-03-30 15:45:08 +08:00
committed by patacongo
parent 7f2810f73a
commit 8d66a316da
5 changed files with 101 additions and 98 deletions
+2 -2
View File
@@ -287,7 +287,7 @@ int getaddrinfo(FAR const char *hostname, FAR const char *servname,
{
for (i = 0; hp->h_addr_list[i]; i++)
{
if (family != AF_UNSPEC && hp->h_addrtype != family)
if (family != AF_UNSPEC && hp->h_addrtypes[i] != family)
{
/* Filter by protocol family. */
@@ -296,7 +296,7 @@ int getaddrinfo(FAR const char *hostname, FAR const char *servname,
/* REVISIT: filter by socktype and protocol not implemented. */
ai = alloc_ai(hp->h_addrtype, socktype, proto, port,
ai = alloc_ai(hp->h_addrtypes[i], socktype, proto, port,
hp->h_addr_list[i]);
if (ai == NULL)
{