libc/netdb: Change the default max number of host IP to 2 if both IPv4 and Ipv6 enable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I02614cb34647eaa03b476a6755d0667dc8392036
This commit is contained in:
Xiang Xiao 2020-03-29 23:15:18 +08:00 committed by patacongo
parent bd9fbade05
commit eaab17b66a
6 changed files with 22 additions and 21 deletions

View File

@ -18,6 +18,18 @@ config LIBC_GAISTRERROR
of memory. If this option is not selected, gai_strerror() will still exist in
the build but it will not decode error values.
config NETDB_BUFSIZE
int "gethostbyname/gethostbyaddr buffer size"
default 128
config NETDB_MAX_IPADDR
int "Max number of IP addresses per host"
default 2 if NET_IPv4 && NET_IPv6
default 1
---help---
This setting determines the maximum number of IP addresses
stored to the name resolution cache for a given host.
menuconfig NETDB_HOSTFILE
bool "Network host file support"
default n
@ -36,10 +48,6 @@ config NETDB_MAX_ALTNAMES
int "Max number of alternate host names"
default 4
config NETDB_BUFSIZE
int "gethostname() buffer size"
default 128
endif # NETDB_HOSTFILE
menuconfig NETDB_DNSCLIENT
@ -101,13 +109,6 @@ config NETDB_DNSCLIENT_MAXRESPONSE
can be received by the DNS resolver. The default is 96 but may
need to be larger on enterprise networks (perhaps 176).
config NETDB_DNSCLIENT_MAXIP
int "Max number of IP addresses per host"
default 1
---help---
This setting determines the maximum number of IP addresses
stored to the name resolution cache for a given host.
config NETDB_DNSCLIENT_RECV_TIMEOUT
int "DNS receive timeout"
default 30

View File

@ -66,10 +66,6 @@
# define CONFIG_NETDB_DNSCLIENT_MAXRESPONSE 96
#endif
#ifndef CONFIG_NETDB_DNSCLIENT_MAXIP
# define CONFIG_NETDB_DNSCLIENT_MAXIP 1
#endif
#ifndef CONFIG_NETDB_DNSCLIENT_NAMESIZE
# define CONFIG_NETDB_DNSCLIENT_NAMESIZE 32
#endif

View File

@ -79,7 +79,7 @@ struct dns_cache_s
#endif
char name[CONFIG_NETDB_DNSCLIENT_NAMESIZE];
uint8_t naddr; /* How many addresses per name */
union dns_addr_u addr[CONFIG_NETDB_DNSCLIENT_MAXIP]; /* Resolved address */
union dns_addr_u addr[CONFIG_NETDB_MAX_IPADDR]; /* Resolved address */
};
/****************************************************************************
@ -127,7 +127,7 @@ void dns_save_answer(FAR const char *hostname,
int next;
int ndx;
naddr = MIN(naddr, CONFIG_NETDB_DNSCLIENT_MAXIP);
naddr = MIN(naddr, CONFIG_NETDB_MAX_IPADDR);
DEBUGASSERT(naddr >= 1 && naddr <= UCHAR_MAX);
/* Get exclusive access to the DNS cache */

View File

@ -61,7 +61,7 @@
struct hostent_info_s
{
FAR char *hi_addrlist[CONFIG_NETDB_DNSCLIENT_MAXIP + 1];
FAR char *hi_addrlist[CONFIG_NETDB_MAX_IPADDR + 1];
char hi_data[1];
};

View File

@ -66,7 +66,7 @@
struct hostent_info_s
{
FAR char *hi_addrlist[CONFIG_NETDB_DNSCLIENT_MAXIP + 1];
FAR char *hi_addrlist[CONFIG_NETDB_MAX_IPADDR + 1];
char hi_data[1];
};
@ -402,7 +402,7 @@ static int lib_find_answer(FAR const char *name, FAR struct hostent *host,
return ret;
}
DEBUGASSERT(naddr <= CONFIG_NETDB_DNSCLIENT_MAXIP);
DEBUGASSERT(naddr <= CONFIG_NETDB_MAX_IPADDR);
/* Get the address type. */
@ -564,7 +564,7 @@ static int lib_dns_lookup(FAR const char *name, FAR struct hostent *host,
/* We can read more than maximum, limit here. */
naddr = MIN(naddr, CONFIG_NETDB_DNSCLIENT_MAXIP);
naddr = MIN(naddr, CONFIG_NETDB_MAX_IPADDR);
for (i = 0; i < naddr; i++)
{

View File

@ -70,6 +70,10 @@
# define CONFIG_NETDB_BUFSIZE 128
#endif
#ifndef CONFIG_NETDB_MAX_IPADDR
# define CONFIG_NETDB_MAX_IPADDR 1
#endif
/****************************************************************************
* Public Types
****************************************************************************/