#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config LIBC_NETDB
	bool "netdb support"
	depends on NET_IPv4 || NET_IPv6
	default n

menu "NETDB Support"

config LIBC_GAISTRERROR
	bool "Enable gai_strerror"
	depends on LIBC_NETDB
	default n
	---help---
		The gai_strerror() function shall return a text string describing an error
		value for the getaddrinfo() and getnameinfo(). But it can also require a lot
		of memory. If this option is not selected, gai_strerror() will still exist in
		the build but it will not decode error values.

config LIBC_GAISTRERROR_ERRNUM
	bool "Print unknown error code in gai_strerror()"
	default !LIBC_GAISTRERROR
	---help---
		If this option is selected, then gai_strerror() will print error code
		for unknown errors like "Unknown error 11". Default enabled when
		LIBC_GAISTRERROR is not selected.

config NETDB_BUFSIZE
	int "gethostbyname/gethostbyaddr buffer size"
	depends on LIBC_NETDB
	default 256

config NETDB_MAX_IPADDR
	int "Max number of IP 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
		stored to the name resolution cache for a given host.

menuconfig NETDB_HOSTFILE
	bool "Network host file support"
	default n
	select LIBC_NETDB
	---help---
		Enable network host table look ups via gethostbyname() and
		gethostbyaddr().

if NETDB_HOSTFILE

config NETDB_HOSTCONF_PATH
	string "Path to host configuration file"
	default "/etc/hosts"

config NETDB_MAX_ALTNAMES
	int "Max number of alternate host names"
	default 4

endif # NETDB_HOSTFILE

menuconfig NETDB_DNSCLIENT
	bool "DNS Name resolution"
	default n
	depends on NET && NET_UDP
	select LIBC_NETDB
	select NET_SOCKOPTS
	---help---
		Enable support for the name resolution; Enable network host
		resolution via gethostbyname().

if NETDB_DNSCLIENT

config NETDB_DNSCLIENT_ENTRIES
	int "Number of DNS resolver entries"
	default 0 if DEFAULT_SMALL
	default 8 if !DEFAULT_SMALL
	range 0 255
	---help---
		Number of cached DNS resolver entries.  Default: 8.  Zero disables
		all cached name resolutions.

		Disabling the DNS cache means that each access call to
		gethostbyname() will result in a new DNS network query.  If
		CONFIG_NETDB_DNSCLIENT_ENTRIES is non-zero, then entries will be
		cached and if the name mapping can be found in that cache, the
		network query can be avoid.  Of course, this is only useful if you
		query the same name often and if the IP address of the name is
		stable.  If the IP address can change, then caching DNS address
		might have undesirable side-effects (see help for
		CONFIG_NETDB_DNSCLIENT_LIFESEC).

config NETDB_DNSCLIENT_NAMESIZE
	int "Max size of a cached hostname"
	default PATH_MAX
	---help---
		The size of a hostname string in the DNS resolver cache is fixed.
		This setting provides the maximum size of a hostname.  Names longer
		than this will be aliased!  Default: 32

config NETDB_DNSCLIENT_LIFESEC
	int "Life of a DNS cache entry (seconds)"
	default 3600
	---help---
		Cached entries in the name resolution cache older than this will not
		be used.  Default: 1 hour.  Zero means that entries will not expire.

		Small values of CONFIG_NETDB_DNSCLIENT_LIFESEC may result in more
		network DNS queries; larger values can make a host unreachable for
		the entire duration of the timeout value.  This might happen, for
		example, if the remote host was assigned a different IP address by
		a DHCP server.

config NETDB_DNSCLIENT_MAXRESPONSE
	int "Max response size"
	default 512
	---help---
		This setting determines the maximum size of response message that
		can be received by the DNS resolver.  The default used to be 96,
		which might be enough if you have a control on the DNS servers.
		It may need to be larger on enterprise networks.

config NETDB_DNSCLIENT_RECV_TIMEOUT
	int "DNS receive timeout"
	default 30
	---help---
		This is the timeout value when DNS receives response after
		dns_send_query, unit: seconds

config NETDB_DNSCLIENT_SEND_TIMEOUT
	int "DNS send timeout"
	default NETDB_DNSCLIENT_RECV_TIMEOUT
	---help---
		This is the timeout value when DNS send request on dns_send_query,
		unit: seconds

config NETDB_DNSCLIENT_RETRIES
	int "Number of retries for DNS request"
	default 3
	---help---
		This setting determines how many times resolver retries request
		until failing.

config NETDB_RESOLVCONF
	bool "DNS resolver file support"
	default n
	---help---
		Enable DNS server look ups in resolver file like /etc/resolv.conf.

if NETDB_RESOLVCONF

config NETDB_RESOLVCONF_PATH
	string "Path to host configuration file"
	default "/etc/resolv.conf"

config NETDB_RESOLVCONF_NONSTDPORT
	bool "Non-standard port support"
	default n
	---help---
		By default, the resolv.conf file will hold only records like:

			nameserver xx.xx.xx.xx
			nameserver xxxx:::::::xxxx

		The default port of 53 is always assumed.

		If this option is selected, then OpenBSD style resolv.conf files
		will be supported.  This adds logic for a bracket port notation
		like:

			nameserver [xx.xx.xx.xx]:ppppp
			nameserver [xxxx:::::::xxxx]:ppppp

endif # NETDB_RESOLVCONF

config NETDB_DNSSERVER_NAMESERVERS
	int "Max number of configured nameservers"
	default 1
	depends on !NETDB_RESOLVCONF
	---help---
		This setting determines how many nameservers there can be
		in use concurrently.

choice
	prompt "DNS server address type"
	default NETDB_DNSSERVER_IPv4 if NET_IPv4
	default NETDB_DNSSERVER_IPv6 if !NET_IPv4 && NET_IPv6
	default NETDB_DNSSERVER_NOADDR if !NET_IPv4 && !NET_IPv6
	depends on !NETDB_RESOLVCONF

config NETDB_DNSSERVER_NOADDR
	bool "No default DNS server address"
	---help---
		There is not default DNS nameserver address.  Application must call
		dns_add_nameserver() at runtime to add the DNS server address.

config NETDB_DNSSERVER_IPv4
	bool "IPv4 DNS server address"
	depends on NET_IPv4
	---help---
		An IPv4 default DNS nameserver address will be provided.  Application
		may overwrite this start default server address by calling
		dns_add_nameserver() at runtime.

config NETDB_DNSSERVER_IPv6
	bool "IPv6 DNS server address"
	depends on NET_IPv6
	---help---
		An IPv6 default DNS nameserver address will be provided.  Application
		may overwrite this start default server address by calling
		dns_add_nameserver() at runtime.

endchoice # DNS server address type

config NETDB_DNSSERVER_IPv4ADDR
	hex "Target IPv4 address"
	default 0x0a000001
	depends on NETDB_DNSSERVER_IPv4
	---help---
		Default DNS server IPv4 address in host byte order.  Default value
		10.0.0.1.  This may be changed via dns_add_nameserver().

if NETDB_DNSSERVER_IPv6

config NETDB_DNSSERVER_IPv6ADDR_1
	hex "[0]"
	default 0xfc00
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the first
		of the 8-values.  The default for all eight values is fc00::1.

config NETDB_DNSSERVER_IPv6ADDR_2
	hex "[1]"
	default 0x0000
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the second
		of the 8-values.  The default for all eight values is fc00::1.

config NETDB_DNSSERVER_IPv6ADDR_3
	hex "[2]"
	default 0x0000
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the third
		of the 8-values.  The default for all eight values is fc00::1.

config NETDB_DNSSERVER_IPv6ADDR_4
	hex "[3]"
	default 0x0000
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the fourth
		of the 8-values.  The default for all eight values is fc00::1.

config NETDB_DNSSERVER_IPv6ADDR_5
	hex "[4]"
	default 0x0000
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the fifth
		of the 8-values.  The default for all eight values is fc00::1.

config NETDB_DNSSERVER_IPv6ADDR_6
	hex "[5]"
	default 0x0000
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the sixth
		of the 8-values.  The default for all eight values is fc00::1.

config NETDB_DNSSERVER_IPv6ADDR_7
	hex "[6]"
	default 0x0000
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the seventh
		of the 8-values.  The default for all eight values is fc00::1.

config NETDB_DNSSERVER_IPv6ADDR_8
	hex "[7]"
	default 0x0001
	range 0x0 0xffff
	---help---
		This is the default IP address of the DNS server.  This is a 16-bit
		integer value in host order.  Each of the eight values forming the
		full IPv6 address must be specified individually.  This is the last
		of the 8-values.  The default for all eight values is fc00::1.

endif # NETDB_DNSSERVER_IPv6
endif # NETDB_DNSCLIENT
endmenu # NETDB Support
