diff --git a/boards/arm/tiva/lm3s6965-ek/configs/qemu-flat/defconfig b/boards/arm/tiva/lm3s6965-ek/configs/qemu-flat/defconfig index 5443a0484d864..490f0f9c681ab 100644 --- a/boards/arm/tiva/lm3s6965-ek/configs/qemu-flat/defconfig +++ b/boards/arm/tiva/lm3s6965-ek/configs/qemu-flat/defconfig @@ -44,7 +44,6 @@ CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y CONFIG_NETDB_DNSCLIENT_NAMESIZE=64 CONFIG_NETDB_DNSSERVER_NOADDR=y -CONFIG_NETDB_MAX_IPADDR=2 CONFIG_NETINIT_DHCPC=y CONFIG_NETINIT_NOMAC=y CONFIG_NETUTILS_NETCAT=y diff --git a/boards/arm/tiva/lm3s6965-ek/configs/qemu-nxflat/defconfig b/boards/arm/tiva/lm3s6965-ek/configs/qemu-nxflat/defconfig index 8a387b7da2517..508340f149780 100644 --- a/boards/arm/tiva/lm3s6965-ek/configs/qemu-nxflat/defconfig +++ b/boards/arm/tiva/lm3s6965-ek/configs/qemu-nxflat/defconfig @@ -25,7 +25,6 @@ CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y CONFIG_NETDB_DNSCLIENT_NAMESIZE=64 CONFIG_NETDB_DNSSERVER_NOADDR=y -CONFIG_NETDB_MAX_IPADDR=2 CONFIG_NETUTILS_NETCAT=y CONFIG_NETUTILS_TELNETD=y CONFIG_NETUTILS_TFTPC=y diff --git a/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig b/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig index 3b157590f2770..32ca54f0ccfcb 100644 --- a/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig +++ b/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig @@ -47,7 +47,6 @@ CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y CONFIG_NETDB_DNSCLIENT_NAMESIZE=64 CONFIG_NETDB_DNSSERVER_NOADDR=y -CONFIG_NETDB_MAX_IPADDR=2 CONFIG_NETINIT_DHCPC=y CONFIG_NETINIT_NOMAC=y CONFIG_NETUTILS_NETCAT=y diff --git a/boards/sim/sim/sim/configs/matter/defconfig b/boards/sim/sim/sim/configs/matter/defconfig index 04635b4d24f1e..63a2557185417 100644 --- a/boards/sim/sim/sim/configs/matter/defconfig +++ b/boards/sim/sim/sim/configs/matter/defconfig @@ -58,7 +58,6 @@ CONFIG_MATTER=y CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d -CONFIG_NETDB_MAX_IPADDR=1 CONFIG_NETDEV_HPWORK_THREAD=y CONFIG_NETINIT_IPADDR=0x0a000102 CONFIG_NETLINK_ROUTE=y diff --git a/boards/sim/sim/sim/configs/usbdev/defconfig b/boards/sim/sim/sim/configs/usbdev/defconfig index 76f0e07598a0c..6e56a1f7d36ed 100644 --- a/boards/sim/sim/sim/configs/usbdev/defconfig +++ b/boards/sim/sim/sim/configs/usbdev/defconfig @@ -45,7 +45,6 @@ CONFIG_LIBUV=y CONFIG_NETDB_DNSCLIENT=y CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=1024 CONFIG_NETDB_DNSSERVER_IPv4ADDR=0xDF050505 -CONFIG_NETDB_MAX_IPADDR=1 CONFIG_NETDEV_PHY_IOCTL=y CONFIG_NETDOWN_NOTIFIER=y CONFIG_NETINIT_DRIPADDR=0x0a000101 diff --git a/libs/libc/netdb/Kconfig b/libs/libc/netdb/Kconfig index a8cffa7759f14..9161a72b048da 100644 --- a/libs/libc/netdb/Kconfig +++ b/libs/libc/netdb/Kconfig @@ -33,15 +33,30 @@ config NETDB_BUFSIZE depends on LIBC_NETDB default 256 -config NETDB_MAX_IPADDR - int "Max number of IP addresses per host" +if NET_IPv4 + +config NETDB_MAX_IPv4ADDR + int "Max number of IPv4 addresses per host" depends on LIBC_NETDB - default 2 if NET_IPv4 && NET_IPv6 default 1 ---help--- - This setting determines the maximum number of IP addresses + This setting determines the maximum number of IPv4 addresses stored to the name resolution cache for a given host. +endif # NET_IPv4 + +if NET_IPv6 + +config NETDB_MAX_IPv6ADDR + int "Max number of IPv6 addresses per host" + depends on LIBC_NETDB + default 1 + ---help--- + This setting determines the maximum number of IPv6 addresses + stored to the name resolution cache for a given host. + +endif # NET_IPv6 + menuconfig NETDB_HOSTFILE bool "Network host file support" default n diff --git a/libs/libc/netdb/lib_dnscache.c b/libs/libc/netdb/lib_dnscache.c index bb1ee03aa15d6..1260185103959 100644 --- a/libs/libc/netdb/lib_dnscache.c +++ b/libs/libc/netdb/lib_dnscache.c @@ -32,6 +32,7 @@ #include #include "netdb/lib_dns.h" +#include "netdb/lib_netdb.h" #if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0 diff --git a/libs/libc/netdb/lib_dnsquery.c b/libs/libc/netdb/lib_dnsquery.c index ba414f4c53f66..a01e79db7901b 100644 --- a/libs/libc/netdb/lib_dnsquery.c +++ b/libs/libc/netdb/lib_dnsquery.c @@ -669,7 +669,8 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr, /* Obtain the IPv6 response */ ret = dns_recv_response(sd, &query->addr[next], - *query->naddr - next, &qdata->qinfo, + CONFIG_NETDB_MAX_IPv6ADDR, + &qdata->qinfo, &query->ttl, qdata->buffer); if (ret >= 0) { @@ -718,7 +719,8 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr, } ret = dns_recv_response(sd, &query->addr[next], - *query->naddr - next, &qdata->qinfo, + CONFIG_NETDB_MAX_IPv4ADDR, + &qdata->qinfo, &query->ttl, qdata->buffer); if (ret >= 0) { diff --git a/libs/libc/netdb/lib_netdb.h b/libs/libc/netdb/lib_netdb.h index 72dcf91ec4d2b..b4d4a0a60ecf7 100644 --- a/libs/libc/netdb/lib_netdb.h +++ b/libs/libc/netdb/lib_netdb.h @@ -56,10 +56,17 @@ # define CONFIG_NETDB_BUFSIZE 128 #endif -#ifndef CONFIG_NETDB_MAX_IPADDR -# define CONFIG_NETDB_MAX_IPADDR 1 +#ifndef CONFIG_NETDB_MAX_IPv4ADDR +# define CONFIG_NETDB_MAX_IPv4ADDR 1 #endif +#ifndef CONFIG_NETDB_MAX_IPv6ADDR +# define CONFIG_NETDB_MAX_IPv6ADDR 1 +#endif + +#define CONFIG_NETDB_MAX_IPADDR (CONFIG_NETDB_MAX_IPv4ADDR + \ + CONFIG_NETDB_MAX_IPv6ADDR) + /**************************************************************************** * Public Types ****************************************************************************/