mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
getaddrinfo: add AI_NUMERICHOST flag handle
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
@@ -306,10 +306,8 @@ int getaddrinfo(FAR const char *hostname, FAR const char *servname,
|
|||||||
return EAI_MEMORY;
|
return EAI_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* REVISIT: no check for AI_NUMERICHOST flag. */
|
|
||||||
|
|
||||||
gethostentbyname_r(hostname, &host,
|
gethostentbyname_r(hostname, &host,
|
||||||
hostbuffer, CONFIG_NETDB_BUFSIZE, &ret);
|
hostbuffer, CONFIG_NETDB_BUFSIZE, &ret, flags);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
lib_free(hostbuffer);
|
lib_free(hostbuffer);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ int gethostbyname2_r(FAR const char *name, int type,
|
|||||||
|
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
|
|
||||||
ret = gethostentbyname_r(name, &tmp, buf, buflen, h_errnop);
|
ret = gethostentbyname_r(name, &tmp, buf, buflen, h_errnop, 0);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
if (convert_hostent(&tmp, type, host))
|
if (convert_hostent(&tmp, type, host))
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ errorout_with_herrnocode:
|
|||||||
|
|
||||||
int gethostentbyname_r(FAR const char *name,
|
int gethostentbyname_r(FAR const char *name,
|
||||||
FAR struct hostent_s *host, FAR char *buf,
|
FAR struct hostent_s *host, FAR char *buf,
|
||||||
size_t buflen, FAR int *h_errnop)
|
size_t buflen, FAR int *h_errnop, int flags)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(name != NULL && host != NULL && buf != NULL);
|
DEBUGASSERT(name != NULL && host != NULL && buf != NULL);
|
||||||
|
|
||||||
@@ -735,6 +735,12 @@ int gethostentbyname_r(FAR const char *name,
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
else if ((flags & AI_NUMERICHOST) != 0)
|
||||||
|
{
|
||||||
|
*h_errnop = EAI_NONAME;
|
||||||
|
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NET_LOOPBACK
|
#ifdef CONFIG_NET_LOOPBACK
|
||||||
/* Check for the local loopback host name */
|
/* Check for the local loopback host name */
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ ssize_t parse_hostfile(FAR FILE *stream, FAR struct hostent_s *host,
|
|||||||
|
|
||||||
int gethostentbyname_r(FAR const char *name,
|
int gethostentbyname_r(FAR const char *name,
|
||||||
FAR struct hostent_s *host, FAR char *buf,
|
FAR struct hostent_s *host, FAR char *buf,
|
||||||
size_t buflen, FAR int *h_errnop);
|
size_t buflen, FAR int *h_errnop, int flags);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user