2015-07-08 22:33:23 +02:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libc/netdb/lib_gethostbyaddrr.c
|
2015-07-08 22:33:23 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2015-07-08 22:33:23 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-07-08 22:33:23 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2015-07-08 22:33:23 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
2015-08-24 19:29:54 +02:00
|
|
|
#include <nuttx/net/loopback.h>
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2015-07-10 20:11:40 +02:00
|
|
|
#include "netdb/lib_netdb.h"
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
#ifdef CONFIG_LIBC_NETDB
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2019-06-30 23:12:34 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* This is the layout of the caller provided memory area */
|
|
|
|
|
|
|
|
struct hostent_info_s
|
|
|
|
{
|
2020-03-31 20:21:04 +02:00
|
|
|
int hi_addrtypes[CONFIG_NETDB_MAX_IPADDR];
|
|
|
|
int hi_lengths[CONFIG_NETDB_MAX_IPADDR];
|
2020-03-29 17:15:18 +02:00
|
|
|
FAR char *hi_addrlist[CONFIG_NETDB_MAX_IPADDR + 1];
|
2020-03-30 09:45:08 +02:00
|
|
|
char hi_data[1];
|
2019-06-30 23:12:34 +02:00
|
|
|
};
|
|
|
|
|
2015-07-08 22:33:23 +02:00
|
|
|
/****************************************************************************
|
2015-08-24 18:08:26 +02:00
|
|
|
* Private Functions
|
2015-07-08 22:33:23 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-08-24 18:08:26 +02:00
|
|
|
* Name: lib_lo_ipv4match
|
2015-07-08 22:33:23 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2015-08-24 18:08:26 +02:00
|
|
|
* Check if the address is the reserved IPv4 address for the local
|
|
|
|
* loopback device.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* addr - The address of the host to find.
|
|
|
|
* len - The length of the address
|
|
|
|
* type - The type of the address
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* True if the address is the IPv4 local loopback address.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
#if defined(CONFIG_NET_LOOPBACK) && defined(CONFIG_NET_IPv4)
|
2015-08-24 18:08:26 +02:00
|
|
|
static bool lib_lo_ipv4match(FAR const void *addr, socklen_t len, int type)
|
|
|
|
{
|
|
|
|
FAR struct in_addr *ipv4addr;
|
|
|
|
|
|
|
|
if (type == AF_INET && len >= sizeof(struct in_addr))
|
|
|
|
{
|
|
|
|
ipv4addr = (FAR struct in_addr *)addr;
|
2019-03-11 04:44:57 +01:00
|
|
|
return net_ipv4addr_maskcmp(ipv4addr->s_addr,
|
|
|
|
g_lo_ipv4addr,
|
2020-03-29 12:31:45 +02:00
|
|
|
g_lo_ipv4mask);
|
2015-08-24 18:08:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: lib_lo_ipv6match
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Check if the address is the reserved IPv6 address for the local
|
|
|
|
* loopback device.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* addr - The address of the host to find.
|
|
|
|
* len - The length of the address
|
|
|
|
* type - The type of the address
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* True if the address is the IPv4 local loopback address.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
#if defined(CONFIG_NET_LOOPBACK) && defined(CONFIG_NET_IPv6)
|
2015-08-24 18:08:26 +02:00
|
|
|
static bool lib_lo_ipv6match(FAR const void *addr, socklen_t len, int type)
|
|
|
|
{
|
2020-03-29 12:31:45 +02:00
|
|
|
FAR struct in6_addr *ipv6addr;
|
2015-08-24 18:08:26 +02:00
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
if (type == AF_INET6 && len >= sizeof(struct in6_addr))
|
2015-08-24 18:08:26 +02:00
|
|
|
{
|
2020-03-29 12:31:45 +02:00
|
|
|
ipv6addr = (FAR struct in6_addr *)addr;
|
|
|
|
return net_ipv6addr_maskcmp(ipv6addr->s6_addr16,
|
|
|
|
g_lo_ipv6addr,
|
|
|
|
g_lo_ipv6mask);
|
2015-08-24 18:08:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: lib_localhost
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Check if the address is the reserved address for the local loopback
|
|
|
|
* device.
|
2015-07-08 22:33:23 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* addr - The address of the host to find.
|
|
|
|
* len - The length of the address
|
|
|
|
* type - The type of the address
|
|
|
|
* host - Caller provided location to return the host data.
|
|
|
|
* buf - Caller provided buffer to hold string data associated with the
|
|
|
|
* host data.
|
|
|
|
* buflen - The size of the caller-provided buffer
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2020-03-29 12:31:45 +02:00
|
|
|
* Zero (OK) is returned on success, -1 (ERROR) is returned on a failure.
|
2015-07-08 22:33:23 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-08-24 21:49:12 +02:00
|
|
|
#ifdef CONFIG_NET_LOOPBACK
|
2015-08-24 18:08:26 +02:00
|
|
|
static int lib_localhost(FAR const void *addr, socklen_t len, int type,
|
2020-03-31 20:21:04 +02:00
|
|
|
FAR struct hostent_s *host, FAR char *buf,
|
2020-03-29 12:31:45 +02:00
|
|
|
size_t buflen)
|
2015-07-08 22:33:23 +02:00
|
|
|
{
|
2015-08-24 18:08:26 +02:00
|
|
|
FAR struct hostent_info_s *info;
|
2015-08-24 19:29:54 +02:00
|
|
|
FAR char *dest;
|
2015-08-24 18:08:26 +02:00
|
|
|
int namelen;
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2020-03-30 09:45:08 +02:00
|
|
|
/* Make sure that space remains to hold the hostent structure */
|
|
|
|
|
|
|
|
if (buflen <= sizeof(struct hostent_info_s))
|
|
|
|
{
|
|
|
|
return -ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = (FAR struct hostent_info_s *)buf;
|
|
|
|
dest = info->hi_data;
|
|
|
|
buflen -= (sizeof(struct hostent_info_s) - 1);
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
memset(host, 0, sizeof(struct hostent_s));
|
2020-03-30 09:45:08 +02:00
|
|
|
memset(info, 0, sizeof(struct hostent_info_s));
|
|
|
|
|
|
|
|
host->h_addrtypes = info->hi_addrtypes;
|
|
|
|
host->h_lengths = info->hi_lengths;
|
|
|
|
host->h_addr_list = info->hi_addrlist;
|
2019-06-30 23:12:34 +02:00
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
#ifdef CONFIG_NET_IPv4
|
2015-08-24 18:08:26 +02:00
|
|
|
if (lib_lo_ipv4match(addr, len, type))
|
|
|
|
{
|
2020-03-30 09:45:08 +02:00
|
|
|
/* Save the IPv4 address */
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
host->h_lengths[0] = sizeof(struct in_addr);
|
|
|
|
host->h_addr_list[0] = (FAR char *)&g_lo_ipv4addr;
|
|
|
|
host->h_addrtypes[0] = AF_INET;
|
2020-03-30 09:45:08 +02:00
|
|
|
goto out_copyname;
|
2015-08-24 18:08:26 +02:00
|
|
|
}
|
2020-03-29 12:31:45 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-11 04:44:57 +01:00
|
|
|
#ifdef CONFIG_NET_IPv6
|
2020-03-29 12:31:45 +02:00
|
|
|
if (lib_lo_ipv6match(addr, len, type))
|
2015-08-24 18:08:26 +02:00
|
|
|
{
|
2020-03-30 09:45:08 +02:00
|
|
|
/* Save the IPv6 address */
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
host->h_lengths[0] = sizeof(struct in6_addr);
|
|
|
|
host->h_addr_list[0] = (FAR char *)&g_lo_ipv6addr;
|
|
|
|
host->h_addrtypes[0] = AF_INET6;
|
2020-03-30 09:45:08 +02:00
|
|
|
goto out_copyname;
|
2015-08-24 18:08:26 +02:00
|
|
|
}
|
2019-03-11 04:44:57 +01:00
|
|
|
#endif
|
2015-08-24 18:08:26 +02:00
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
/* Return 1 meaning that we have no errors but no match either */
|
|
|
|
|
|
|
|
return 1;
|
2015-08-24 18:08:26 +02:00
|
|
|
|
2020-03-30 09:45:08 +02:00
|
|
|
out_copyname:
|
2015-08-24 18:08:26 +02:00
|
|
|
|
2015-10-12 15:45:02 +02:00
|
|
|
/* And copy localhost host name */
|
2015-08-24 18:08:26 +02:00
|
|
|
|
2015-10-12 15:45:02 +02:00
|
|
|
namelen = strlen(g_lo_hostname);
|
2020-03-29 12:31:45 +02:00
|
|
|
if (namelen + 1 > buflen)
|
2015-10-12 15:45:02 +02:00
|
|
|
{
|
2020-03-29 12:31:45 +02:00
|
|
|
return -ERANGE;
|
2015-08-24 18:08:26 +02:00
|
|
|
}
|
|
|
|
|
2015-10-12 15:45:02 +02:00
|
|
|
strncpy(dest, g_lo_hostname, buflen);
|
2019-06-30 23:12:34 +02:00
|
|
|
host->h_name = dest;
|
|
|
|
|
2015-10-12 15:45:02 +02:00
|
|
|
return 0;
|
2015-08-24 18:08:26 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: lib_hostfile_lookup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Try to look-up the host name from the network host file
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* addr - The address of the host to find.
|
|
|
|
* len - The length of the address
|
|
|
|
* type - The type of the address
|
|
|
|
* host - Caller provided location to return the host data.
|
|
|
|
* buf - Caller provided buffer to hold string data associated with the
|
|
|
|
* host data.
|
|
|
|
* buflen - The size of the caller-provided buffer
|
|
|
|
* h_errnop - There h_errno value returned in the event of a failure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success, -1 (ERROR) is returned on a failure
|
|
|
|
* with the returned h_errno value provided the reason for the failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
#ifdef CONFIG_NETDB_HOSTFILE
|
2015-08-24 18:08:26 +02:00
|
|
|
int lib_hostfile_lookup(FAR const void *addr, socklen_t len, int type,
|
2020-03-31 20:21:04 +02:00
|
|
|
FAR struct hostent_s *host, FAR char *buf,
|
|
|
|
size_t buflen, FAR int *h_errnop)
|
2015-08-24 18:08:26 +02:00
|
|
|
{
|
|
|
|
FAR FILE *stream;
|
|
|
|
int herrnocode;
|
|
|
|
int nread;
|
|
|
|
|
2015-07-08 22:33:23 +02:00
|
|
|
/* Search the hosts file for a match */
|
|
|
|
|
|
|
|
stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r");
|
|
|
|
if (stream == NULL)
|
|
|
|
{
|
2021-02-15 09:08:51 +01:00
|
|
|
int errcode = -get_errno();
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2016-06-11 23:50:49 +02:00
|
|
|
nerr("ERROR: Failed to open the hosts file %s: %d\n",
|
2015-07-08 22:33:23 +02:00
|
|
|
CONFIG_NETDB_HOSTCONF_PATH, errcode);
|
|
|
|
UNUSED(errcode);
|
|
|
|
|
|
|
|
herrnocode = NO_RECOVERY;
|
|
|
|
goto errorout_with_herrnocode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop reading entries from the hosts file until a match is found or
|
|
|
|
* until we hit the end-of-file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Read the next entry from the hosts file */
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
nread = parse_hostfile(stream, host, buf, buflen);
|
2015-07-08 22:33:23 +02:00
|
|
|
if (nread < 0)
|
|
|
|
{
|
|
|
|
/* Possible errors:
|
|
|
|
* ERANGE - Buffer not big enough
|
|
|
|
* ESPIPE - End of file (or possibly a read error).
|
|
|
|
* EAGAIN - Error parsing the line (E.g., missing hostname)
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (nread == -ESPIPE)
|
|
|
|
{
|
|
|
|
nread = 0;
|
|
|
|
}
|
|
|
|
else if (nread != -EAGAIN)
|
|
|
|
{
|
|
|
|
herrnocode = NO_RECOVERY;
|
|
|
|
goto errorout_with_stream;
|
|
|
|
}
|
|
|
|
}
|
2020-03-31 20:21:04 +02:00
|
|
|
else if (len == host->h_lengths[0] && type == host->h_addrtypes[0])
|
2015-07-08 22:33:23 +02:00
|
|
|
{
|
|
|
|
/* We successfully read the entry and the type and size of the
|
|
|
|
* address is good. Now compare the addresses:
|
|
|
|
*/
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
FAR char *hostaddr = host->h_addr_list[0];
|
2015-07-08 22:33:23 +02:00
|
|
|
if (hostaddr != NULL)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
ninfo("Comparing addresses...\n");
|
2015-07-08 22:33:23 +02:00
|
|
|
if (memcmp(addr, hostaddr, len) == 0)
|
|
|
|
{
|
2019-06-30 23:12:34 +02:00
|
|
|
/* We have a match */
|
2015-07-08 22:33:23 +02:00
|
|
|
|
|
|
|
fclose(stream);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (nread != 0);
|
|
|
|
|
|
|
|
/* We get here when the end of the hosts file is encountered without
|
|
|
|
* finding the hostname.
|
|
|
|
*/
|
|
|
|
|
|
|
|
herrnocode = HOST_NOT_FOUND;
|
|
|
|
|
|
|
|
errorout_with_stream:
|
|
|
|
fclose(stream);
|
|
|
|
|
|
|
|
errorout_with_herrnocode:
|
|
|
|
if (h_errnop)
|
|
|
|
{
|
|
|
|
*h_errnop = herrnocode;
|
|
|
|
}
|
|
|
|
|
2015-10-04 23:04:00 +02:00
|
|
|
return ERROR;
|
2015-07-08 22:33:23 +02:00
|
|
|
}
|
2020-03-29 12:31:45 +02:00
|
|
|
#endif
|
2015-07-08 22:33:23 +02:00
|
|
|
|
2015-08-24 18:08:26 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: gethostbyaddr_r
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The gethostbyaddr_r() function returns a structure of type hostent for
|
|
|
|
* the given host address addr of length len and address type type. Valid
|
|
|
|
* address types are AF_INET and AF_INET6. The host address argument is a
|
|
|
|
* pointer to a struct of a type depending on the address type, for example
|
|
|
|
* a struct in_addr * for address type AF_INET.
|
|
|
|
*
|
2019-06-30 23:12:34 +02:00
|
|
|
* gethostbyaddr_r() is *not* POSIX but is similar to a Glibc extension and
|
|
|
|
* is used internally by NuttX to implement the POSIX gethostbyaddr().
|
2015-08-24 18:08:26 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* addr - The address of the host to find.
|
|
|
|
* len - The length of the address
|
|
|
|
* type - The type of the address
|
|
|
|
* host - Caller provided location to return the host data.
|
|
|
|
* buf - Caller provided buffer to hold string data associated with the
|
|
|
|
* host data.
|
|
|
|
* buflen - The size of the caller-provided buffer
|
2020-03-31 20:21:04 +02:00
|
|
|
* result - There host entry returned in the event of a success.
|
2015-08-24 18:08:26 +02:00
|
|
|
* h_errnop - There h_errno value returned in the event of a failure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success, -1 (ERROR) is returned on a failure
|
|
|
|
* with the returned h_errno value provided the reason for the failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int gethostbyaddr_r(FAR const void *addr, socklen_t len, int type,
|
|
|
|
FAR struct hostent *host, FAR char *buf,
|
2020-03-31 20:21:04 +02:00
|
|
|
size_t buflen, FAR struct hostent **result,
|
|
|
|
FAR int *h_errnop)
|
2015-08-24 18:08:26 +02:00
|
|
|
{
|
2020-04-02 06:32:13 +02:00
|
|
|
#if defined(CONFIG_NET_LOOPBACK) || defined(CONFIG_NETDB_HOSTFILE)
|
2020-03-31 20:21:04 +02:00
|
|
|
struct hostent_s tmp;
|
2020-04-02 06:32:13 +02:00
|
|
|
#endif
|
2020-03-31 20:21:04 +02:00
|
|
|
int ret;
|
|
|
|
|
2015-08-24 18:08:26 +02:00
|
|
|
DEBUGASSERT(addr != NULL && host != NULL && buf != NULL);
|
|
|
|
DEBUGASSERT(type == AF_INET || type == AF_INET6);
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
/* Linux man page says result must be NULL in case of failure. */
|
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
2015-08-24 18:08:26 +02:00
|
|
|
/* Make sure that the h_errno has a non-error code */
|
|
|
|
|
|
|
|
if (h_errnop)
|
|
|
|
{
|
|
|
|
*h_errnop = 0;
|
|
|
|
}
|
|
|
|
|
2015-08-24 21:49:12 +02:00
|
|
|
#ifdef CONFIG_NET_LOOPBACK
|
2015-08-24 18:08:26 +02:00
|
|
|
/* Check for the local loopback address */
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
ret = lib_localhost(addr, len, type, &tmp, buf, buflen);
|
|
|
|
if (ret == OK)
|
2015-08-24 18:08:26 +02:00
|
|
|
{
|
|
|
|
/* Yes.. we are done */
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
convert_hostent(&tmp, AF_UNSPEC, host);
|
|
|
|
*result = host;
|
2015-08-24 18:08:26 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-24 23:41:45 +02:00
|
|
|
/* TODO:
|
|
|
|
*
|
|
|
|
* 1. Look in the DNS cache to see if we have the address mapping already
|
|
|
|
* in place. If not,
|
|
|
|
* 2. Perform a reverse DNS lookup. And if that fails as well, then
|
|
|
|
* finally
|
|
|
|
* 3. Search the hosts file for a match.
|
|
|
|
*/
|
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
#ifdef CONFIG_NETDB_HOSTFILE
|
2015-08-24 18:08:26 +02:00
|
|
|
/* Search the hosts file for a match */
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
ret = lib_hostfile_lookup(addr, len, type, &tmp, buf, buflen, h_errnop);
|
|
|
|
if (ret == OK)
|
|
|
|
{
|
|
|
|
convert_hostent(&tmp, AF_UNSPEC, host);
|
|
|
|
*result = host;
|
|
|
|
return OK;
|
|
|
|
}
|
2020-03-29 12:31:45 +02:00
|
|
|
#else
|
|
|
|
/* The host file file is not supported. The host address mapping was not
|
|
|
|
* found from any lookup heuristic
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (h_errnop)
|
|
|
|
{
|
|
|
|
*h_errnop = HOST_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
ret = ERROR;
|
2020-03-29 12:31:45 +02:00
|
|
|
#endif
|
2020-03-31 20:21:04 +02:00
|
|
|
|
|
|
|
return ret;
|
2015-08-24 18:08:26 +02:00
|
|
|
}
|
|
|
|
|
2020-03-29 12:31:45 +02:00
|
|
|
#endif /* CONFIG_LIBC_NETDB */
|