diff --git a/libs/libc/netdb/Kconfig b/libs/libc/netdb/Kconfig index aeee1e725c8..718349f3cbb 100644 --- a/libs/libc/netdb/Kconfig +++ b/libs/libc/netdb/Kconfig @@ -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 diff --git a/libs/libc/netdb/lib_dns.h b/libs/libc/netdb/lib_dns.h index e712a667b1b..f58cc564202 100644 --- a/libs/libc/netdb/lib_dns.h +++ b/libs/libc/netdb/lib_dns.h @@ -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 diff --git a/libs/libc/netdb/lib_dnscache.c b/libs/libc/netdb/lib_dnscache.c index 7ba1ef290bf..e11ceb3b8e7 100644 --- a/libs/libc/netdb/lib_dnscache.c +++ b/libs/libc/netdb/lib_dnscache.c @@ -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 */ diff --git a/libs/libc/netdb/lib_gethostbyaddrr.c b/libs/libc/netdb/lib_gethostbyaddrr.c index 49fd791878f..7fea8b6dd18 100644 --- a/libs/libc/netdb/lib_gethostbyaddrr.c +++ b/libs/libc/netdb/lib_gethostbyaddrr.c @@ -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]; }; diff --git a/libs/libc/netdb/lib_gethostbynamer.c b/libs/libc/netdb/lib_gethostbynamer.c index cf82b5891cd..2b4ec7849b1 100644 --- a/libs/libc/netdb/lib_gethostbynamer.c +++ b/libs/libc/netdb/lib_gethostbynamer.c @@ -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++) { diff --git a/libs/libc/netdb/lib_netdb.h b/libs/libc/netdb/lib_netdb.h index 41d2285b432..f29e4d64afe 100644 --- a/libs/libc/netdb/lib_netdb.h +++ b/libs/libc/netdb/lib_netdb.h @@ -70,6 +70,10 @@ # define CONFIG_NETDB_BUFSIZE 128 #endif +#ifndef CONFIG_NETDB_MAX_IPADDR +# define CONFIG_NETDB_MAX_IPADDR 1 +#endif + /**************************************************************************** * Public Types ****************************************************************************/