1 /*
2  *  Copyright (c) 2019, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * @file
31  *   This file includes compile-time configurations for the DNS Client.
32  *
33  */
34 
35 #ifndef CONFIG_DNS_CLIENT_H_
36 #define CONFIG_DNS_CLIENT_H_
37 
38 /**
39  * @addtogroup config-dns-client
40  *
41  * @brief
42  *   This module includes configuration variables for the DNS client.
43  *
44  * @{
45  *
46  */
47 
48 #include "config/ip6.h"
49 #include "config/srp_client.h"
50 
51 /**
52  * @def OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
53  *
54  * Define to 1 to enable DNS Client support.
55  *
56  */
57 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
58 #define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 0
59 #endif
60 
61 /**
62  * @def OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE
63  *
64  * Define to 1 to enable support for NAT64 address translation (from IPv4 to IPv6) during address resolution by DNS
65  * client.
66  *
67  */
68 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE
69 #define OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE 1
70 #endif
71 
72 /**
73  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED
74  *
75  * Specifies the default NAT64 mode, i.e., whether to allow or disallow NAT64 address translation during DNS client
76  * address resolution. This mode is only available when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled.
77  *
78  */
79 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED
80 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED 1
81 #endif
82 
83 /**
84  * @def OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE
85  *
86  * Define to 1 to enable DNS based Service Discovery (DNS-SD) client.
87  *
88  */
89 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE
90 #define OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 1
91 #endif
92 
93 /**
94  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE
95  *
96  * Set to 1 for DNS client to automatically set and update the server IPv6 address in the default config (when it is
97  * not explicitly set by user).
98  *
99  * This feature requires SRP client and its auto-start feature to be also enabled. SRP client will then monitor the
100  * Thread Network Data for DNS/SRP Service entries to select an SRP server. The selected SRP server address is also set
101  * as the DNS server address in the default config.
102  *
103  */
104 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE
105 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE \
106     (OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE)
107 #endif
108 
109 /**
110  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS
111  *
112  * Specifies the default DNS server IPv6 address.
113  *
114  * It MUST be a C string representation of the server IPv6 address.
115  *
116  * Default value is set to "2001:4860:4860::8888" which is the Google Public DNS IPv6 address.
117  *
118  */
119 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS
120 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS "2001:4860:4860::8888"
121 #endif
122 
123 /**
124  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT
125  *
126  * Specifies the default DNS server port number.
127  *
128  */
129 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT
130 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT 53
131 #endif
132 
133 /**
134  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT
135  *
136  * Specifies the default wait time that DNS client waits for a response from server (in milliseconds).
137  *
138  */
139 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT
140 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT 6000
141 #endif
142 
143 /**
144  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS
145  *
146  * Specifies the default maximum number of DNS query tx attempts with no response before reporting failure.
147  *
148  */
149 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS
150 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS 3
151 #endif
152 
153 /**
154  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NO_RECURSION_FLAG
155  *
156  * Specifies the default "recursion desired" flag (indicates whether the server can resolve the query recursively or
157  * not).
158  *
159  */
160 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG
161 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG 1
162 #endif
163 
164 /**
165  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE
166  *
167  * Specifies the default `otDnsServiceMode` to use. The value MUST be from `otDnsServiceMode` enumeration.
168  *
169  */
170 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE
171 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE
172 #endif
173 
174 /**
175  * @def OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE
176  *
177  * Enables support for sending DNS Queries over TCP.
178  *
179  */
180 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE
181 #define OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE 0
182 #endif
183 
184 /**
185  * @def OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE
186  *
187  * Specifies size of receive and transmit buffers of TCP sockets for DNS query over TCP.
188  *
189  */
190 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE
191 #define OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE 1024
192 #endif
193 
194 /**
195  * @}
196  *
197  */
198 
199 #endif // CONFIG_DNS_CLIENT_H_
200