1# Copyright (c) 2016 Intel Corporation
2# SPDX-License-Identifier: Apache-2.0
3
4config DNS_RESOLVER
5	bool "DNS resolver"
6	depends on NET_NATIVE
7	select NET_SOCKETS
8	select NET_SOCKETS_SERVICE
9	select CRC
10	help
11	  This option enables the DNS client side support for Zephyr
12
13if DNS_RESOLVER
14
15config DNS_RESOLVER_AUTO_INIT
16	bool "Automatically initialize the default DNS context"
17	default y
18	help
19	  Automatically initialize the default DNS context so dns_resolve_init
20	  does not need to be manually called.
21
22config MDNS_RESOLVER
23	bool "MDNS support"
24	help
25	  This option enables multicast DNS client side support.
26	  See RFC 6762 for details.
27
28config LLMNR_RESOLVER
29	bool "LLMNR support"
30	help
31	  This option enables link local multicast name resolution client side
32	  support. See RFC 4795 for details. LLMNR is typically used by Windows
33	  hosts. If you enable this option, then the DNS requests are ONLY sent
34	  to LLMNR well known multicast address 224.0.0.252:5355 or
35	  [ff02::1:3]:5355 and other DNS server addresses are ignored.
36
37config DNS_RESOLVER_ADDITIONAL_QUERIES
38	int "Additional DNS queries"
39	range 0 2
40	default 1
41	help
42	  Number of additional DNS queries that the DNS resolver may
43	  generate when the RR ANSWER only contains CNAME(s).
44	  The maximum value of this variable is constrained to avoid
45	  'alias loops'.
46
47config DNS_RESOLVER_AI_MAX_ENTRIES
48	int "Maximum number of IP addresses for DNS name"
49	default 2
50	help
51	  Defines the max number of IP addresses per domain name
52	  resolution the DNS resolver can handle.
53
54
55config DNS_RESOLVER_MAX_SERVERS
56	int "Number of DNS server addresses"
57	range 1 NET_MAX_CONTEXTS
58	default 1
59	help
60	  Max number of DNS servers that we can connect to. Normally one
61	  DNS server is enough. Each connection to DNS server will use one
62	  network context.
63
64config DNS_RESOLVER_MAX_ANSWER_SIZE
65	int "Max length of a DNS answer"
66	range 1 $(UINT16_MAX)
67	default 512
68	help
69	  Max length of the returned DNS answer we can process.
70	  Recommended value by RFC 1035 is 512 bytes.
71
72config DNS_RESOLVER_MAX_QUERY_LEN
73	int "Max length of a DNS query"
74	range 1 $(UINT8_MAX)
75	default $(UINT8_MAX)
76	help
77	  Max length of a DNS query that should be looked up including the
78	  trailing 0. So e.g. "example.com" would have a query len of 12.
79
80config DNS_RESOLVER_MAX_NAME_LEN
81	int "Max length of the resolved DNS name"
82	range 1 $(UINT8_MAX)
83	default 128 if DNS_SD
84	default 46 if NET_IPV6
85	default 20
86	help
87	  Max length of a buffer that is used to store information returned from
88	  DNS server. For example if we query a DNS-SD service, then this value should
89	  be long enough to store the returned string.
90
91config DNS_RESOLVER_MAX_TEXT_LEN
92	int "Max length of the resolved DNS text string in a record"
93	range 1 $(UINT8_MAX)
94	default 255 if DNS_SD
95	default 64
96	help
97	  Max length of a buffer that is used to store text record string
98	  returned from a DNS server.
99
100menuconfig DNS_SERVER_IP_ADDRESSES
101	bool "Set DNS server IP addresses"
102	help
103	  Allow DNS IP addresses to be set in config file for
104	  networking applications.
105
106if DNS_SERVER_IP_ADDRESSES
107
108config DNS_SERVER1
109	string "DNS server 1"
110	help
111	  DNS server IP address 1. The address can be either IPv4 or IPv6
112	  address. An optional port number can be given.
113	  Following syntax is supported:
114	  192.0.2.1
115	  192.0.2.1:5353
116	  2001:db8::1
117	  [2001:db8::1]:5353
118	  It is possible to bind the DNS connection via a certain network
119	  interface by appending "%" and network interface name to the server
120	  address. For example: 192.0.2.1%eth1 would bind the connection socket
121	  to the network interface eth1. This is optional and by default the
122	  resolver connects to server by selecting the output network interface
123	  using normal IP routing.
124	  It is not mandatory to use this Kconfig option at all.
125	  The one calling dns_resolve_init() can use this option or not
126	  to populate the server list. If the DNS server addresses are
127	  set here, then we automatically create default DNS context
128	  for the user.
129
130config DNS_SERVER2
131	string "DNS server 2"
132	help
133	  See help in "DNS server 1" option.
134
135config DNS_SERVER3
136	string "DNS server 3"
137	help
138	  See help in "DNS server 1" option.
139
140config DNS_SERVER4
141	string "DNS server 4"
142	help
143	  See help in "DNS server 1" option.
144
145config DNS_SERVER5
146	string "DNS server 5"
147	help
148	  See help in "DNS server 1" option.
149
150endif # DNS_SERVER_IP_ADDRESSES
151
152config DNS_RECONFIGURE_CLEANUP
153	bool "Cleanup old DNS server entries when reconfiguring"
154	help
155	  If calling dns_resolve_reconfigure() when new DNS servers
156	  are being set, for example if receiving new ones from DHCP server,
157	  remove the old entries before setting up the new ones.
158	  If you have only one network interface, then this can be enabled.
159	  If you have multiple network interfaces, then this should be disabled
160	  because the later configuration update would remove the entries
161	  set by the other network interface configuration.
162	  The previous default in Zephyr 4.1 or earlier was to have this enabled.
163	  The current default in Zephyr 4.2 is to disable this option.
164
165config DNS_NUM_CONCUR_QUERIES
166	int "Number of simultaneous DNS queries per one DNS context"
167	default 1
168	help
169	  This defines how many concurrent DNS queries can be generated using
170	  same DNS context. Normally 1 is a good default value.
171
172module = DNS_RESOLVER
173module-dep = NET_LOG
174module-str = Log level for DNS resolver
175module-help = Enables DNS resolver code to output debug messages.
176source "subsys/net/Kconfig.template.log_config.net"
177
178menuconfig DNS_RESOLVER_CACHE
179	bool "DNS resolver cache"
180	help
181	   This option enables the dns resolver cache. DNS queries
182	   will be cached based on TTL and delivered from cache
183	   whenever possible. This reduces network usage.
184
185if DNS_RESOLVER_CACHE
186
187config DNS_RESOLVER_CACHE_MAX_ENTRIES
188	int "Number of cache entries supported by the dns cache"
189	default 6
190	help
191	  This defines how many entries the DNS cache can hold. If
192	  not enough entries for caching are available the oldest
193	  entry gets replaced. Adjusting this value will affect
194	  RAM usage.
195
196endif # DNS_RESOLVER_CACHE
197
198config DNS_RESOLVER_PACKET_FORWARDING
199	bool "Forwards received DNS packets to application"
200	depends on !DNS_RESOLVER_CACHE
201	help
202	  This allows forwarding of received packets from DNS servers
203	  to applications that register the forwarding callback.
204
205endif # DNS_RESOLVER
206
207config MDNS_RESPONDER
208	bool "mDNS responder"
209	select NET_IPV4_IGMP if NET_IPV4
210	select NET_IPV6_MLD if NET_IPV6
211	select NET_MGMT
212	select NET_MGMT_EVENT
213	select NET_SOCKETS
214	select NET_SOCKETS_SERVICE
215	depends on NET_HOSTNAME_ENABLE
216	help
217	  This option enables the mDNS responder support for Zephyr.
218	  It will listen well-known address ff02::fb and 224.0.0.251.
219	  Currently this only returns IP address information.
220	  You must set CONFIG_NET_HOSTNAME to some meaningful value and
221	  then mDNS will start to respond to <hostname>.local mDNS queries.
222	  See RFC 6762 for more details about mDNS.
223
224if MDNS_RESPONDER
225
226config MDNS_RESOLVER_BUF_SIZE
227	int "Size of the net_buf pool buffers"
228	default 512
229	help
230	  For larger DNS SD TXT records and long service instance names, bigger buffers are necessary
231
232config MDNS_RESPONDER_TTL
233	int "Time-to-Live of returned DNS name"
234	default 600
235	help
236	  DNS answers will use the TTL (in seconds).
237
238config MDNS_RESPONDER_INIT_PRIO
239	int "Startup priority for the mDNS responder init"
240	default 96
241	help
242	  Note that if NET_CONFIG_AUTO_INIT is enabled, then this value
243	  should be bigger than its value.
244
245config MDNS_RESPONDER_PROBE
246	bool "mDNS probing support [EXPERIMENTAL]"
247	select NET_CONNECTION_MANAGER
248	select MDNS_RESOLVER
249	select DNS_RESOLVER
250	select EXPERIMENTAL
251	help
252	  Note that for probing to work, the mDNS and DNS resolver need to
253	  be enabled. The probing is made optional to allow smaller memory
254	  usage.
255
256config MDNS_WORKQ_STACK_SIZE
257	int "mDNS work queue thread stack size"
258	default 1200 if X86
259	default 1024
260	depends on MDNS_RESPONDER_PROBE
261	help
262	  Set the mDNS work queue thread stack size in bytes.
263
264config MDNS_WORKER_PRIO
265	int "Priority of the mDNS work queue"
266	default 2
267	depends on MDNS_RESPONDER_PROBE
268	help
269	  Set the priority of the mDNS worker queue, that handles all
270	  mDNS probing. Value 0 = highest priortity.
271	  When CONFIG_NET_TC_THREAD_COOPERATIVE = y, lowest priority is
272	  CONFIG_NUM_COOP_PRIORITIES-1 else lowest priority is
273	  CONFIG_NUM_PREEMPT_PRIORITIES-1.
274
275config MDNS_RESPONDER_DNS_SD
276	bool "DNS Service Discovery via mDNS"
277	default y
278	depends on DNS_SD
279	help
280	  Selecting this option ensures that the MDNS Responder
281	  processes PTR, SRV, and TXT records according to RFC 6763.
282	  By doing so, Zephyr network services are discoverable
283	  using e.g. 'avahi-browse -t -r _greybus._tcp'.
284
285if MDNS_RESPONDER_DNS_SD
286config MDNS_RESPONDER_DNS_SD_SERVICE_TYPE_ENUMERATION
287	bool "DNS SD Service Type Enumeration"
288	default y
289	help
290	  Selecting this option ensures that the MDNS Responder
291	  performs DNS-SD Service Type Enumeration according to RFC 6763,
292	  Chapter 9. By doing so, Zephyr network services are discoverable
293	  using e.g. 'avahi-browse -t -r _services._dns-sd._udp.local'.
294endif # MDNS_RESPONDER_DNS_SD
295
296module = MDNS_RESPONDER
297module-dep = NET_LOG
298module-str = Log level for mDNS responder
299module-help = Enables mDNS responder code to output debug messages.
300source "subsys/net/Kconfig.template.log_config.net"
301
302config MDNS_RESOLVER_ADDITIONAL_BUF_CTR
303	int "Additional DNS buffers"
304	default 0
305	help
306	  Number of additional buffers available for the mDNS responder.
307
308endif # MDNS_RESPONDER
309
310config LLMNR_RESPONDER
311	bool "LLMNR responder"
312	select NET_IPV4_IGMP if NET_IPV4
313	select NET_IPV6_MLD if NET_IPV6
314	select NET_MGMT
315	select NET_MGMT_EVENT
316	select NET_SOCKETS
317	select NET_SOCKETS_SERVICE
318	depends on NET_HOSTNAME_ENABLE
319	help
320	  This option enables the LLMNR responder support for Zephyr.
321	  It will listen well-known address ff02::1:3 and 224.0.0.252.
322	  Currently this only returns IP address information.
323	  You must set CONFIG_NET_HOSTNAME to some meaningful value and
324	  then LLMNR will start to respond to <hostname> LLMNR queries.
325	  Note that LLMNR queries should only contain single-label names
326	  so there should be NO dot (".") in the name (RFC 4795 ch 3).
327	  Current implementation does not support TCP.
328	  See RFC 4795 for more details about LLMNR.
329
330if LLMNR_RESPONDER
331
332config LLMNR_RESPONDER_TTL
333	int "Time-to-Live of returned DNS name"
334	default 30
335	help
336	  DNS answers will use the TTL (in seconds). A default value is 30
337	  seconds as recommended by RFC 4795 chapter 2.8
338
339config LLMNR_RESPONDER_INIT_PRIO
340	int "Startup priority for the LLMNR responder init"
341	default 96
342	help
343	  Note that if NET_CONFIG_AUTO_INIT is enabled, then this value
344	  should be bigger than its value.
345
346module = LLMNR_RESPONDER
347module-dep = NET_LOG
348module-str = Log level for LLMNR responder
349module-help = Enables LLMNR responder code to output debug messages.
350source "subsys/net/Kconfig.template.log_config.net"
351
352config LLMNR_RESOLVER_ADDITIONAL_BUF_CTR
353	int "Additional DNS buffers"
354	default 0
355	help
356	  Number of additional buffers available for the LLMNR responder.
357
358endif # LLMNR_RESPONDER
359
360config DNS_SD
361	bool "DNS Service Discovery"
362	help
363	  This option enables DNS Service Discovery for Zephyr. It can
364	  be enabled for virtually any network service with only a few
365	  lines of code and works for both Unicast and Multicast DNS.
366	  See RFC 6763 for more details about DNS-SD.
367
368if DNS_SD
369
370module = DNS_SD
371module-dep = NET_LOG
372module-str = Log level for DNS-SD
373module-help = Enables DNS Service Discovery code to output debug messages.
374source "subsys/net/Kconfig.template.log_config.net"
375
376endif # DNS_SD
377
378# Note that we enable the DNS socket dispatcher always if either responder or
379# resolver support is enabled to simplify things. Strictly speaking the
380# dispatcher is really needed for supporting resolver and responder at the same
381# time.
382config DNS_SOCKET_DISPATCHER
383	bool
384	depends on (DNS_RESOLVER || MDNS_RESPONDER)
385	select NET_SOCKETS_SERVICE
386	default y
387	help
388	  A DNS socket dispatcher that allows both the DNS resolver and
389	  mDNS responder to be used at the same time.
390
391if DNS_SOCKET_DISPATCHER
392
393config DNS_RESOLVER_ADDITIONAL_BUF_CTR
394	int "Additional DNS buffers"
395	default 1
396	help
397	  Number of additional buffers available for the DNS resolver.
398	  The DNS resolver requires at least one buffer. This option
399	  enables additional buffers required for multiple concurrent
400	  DNS connections.
401
402module = DNS_SOCKET_DISPATCHER
403module-dep = NET_LOG
404module-str = Log level for DNS socket dispatcher
405module-help = Enables DNS socket dispatcher code to output debug messages.
406source "subsys/net/Kconfig.template.log_config.net"
407
408endif # DNS_SOCKET_DISPATCHER
409