getaddrinfo: add AI_NUMERICHOST flag handle
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
parent
431e31b6b2
commit
4de3387eb2
4 changed files with 10 additions and 6 deletions
|
|
@ -306,10 +306,8 @@ int getaddrinfo(FAR const char *hostname, FAR const char *servname,
|
|||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
/* REVISIT: no check for AI_NUMERICHOST flag. */
|
||||
|
||||
gethostentbyname_r(hostname, &host,
|
||||
hostbuffer, CONFIG_NETDB_BUFSIZE, &ret);
|
||||
hostbuffer, CONFIG_NETDB_BUFSIZE, &ret, flags);
|
||||
if (ret != OK)
|
||||
{
|
||||
lib_free(hostbuffer);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ int gethostbyname2_r(FAR const char *name, int type,
|
|||
|
||||
*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 (convert_hostent(&tmp, type, host))
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ errorout_with_herrnocode:
|
|||
|
||||
int gethostentbyname_r(FAR const char *name,
|
||||
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);
|
||||
|
||||
|
|
@ -735,6 +735,12 @@ int gethostentbyname_r(FAR const char *name,
|
|||
|
||||
return OK;
|
||||
}
|
||||
else if ((flags & AI_NUMERICHOST) != 0)
|
||||
{
|
||||
*h_errnop = EAI_NONAME;
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET_LOOPBACK
|
||||
/* 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,
|
||||
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
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue