getaddrinfo: add AI_NUMERICHOST flag handle

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2023-01-11 17:24:47 +08:00
committed by Xiang Xiao
parent 431e31b6b2
commit 4de3387eb2
4 changed files with 10 additions and 6 deletions
+1 -3
View File
@@ -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);
+1 -1
View File
@@ -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))
+7 -1
View File
@@ -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 */
+1 -1
View File
@@ -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