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 #include "config/srp_client.h"
39 
40 /**
41  * @def OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
42  *
43  * Define to 1 to enable DNS Client support.
44  *
45  */
46 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
47 #define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 0
48 #endif
49 
50 /**
51  * @def OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE
52  *
53  * Define to 1 to enable support for NAT64 address translation (from IPv4 to IPv6) during address resolution by DNS
54  * client.
55  *
56  */
57 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE
58 #define OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE 1
59 #endif
60 
61 /**
62  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED
63  *
64  * Specifies the default NAT64 mode, i.e., whether to allow or disallow NAT64 address translation during DNS client
65  * address resolution. This mode is only available when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled.
66  *
67  */
68 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED
69 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED 1
70 #endif
71 
72 /**
73  * @def OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE
74  *
75  * Define to 1 to enable DNS based Service Discovery (DNS-SD) client.
76  *
77  */
78 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE
79 #define OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 1
80 #endif
81 
82 /**
83  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE
84  *
85  * Set to 1 for DNS client to automatically set and update the server IPv6 address in the default config (when it is
86  * not explicitly set by user).
87  *
88  * This feature requires SRP client and its auto-start feature to be also enabled. SRP client will then monitor the
89  * Thread Network Data for DNS/SRP Service entries to select an SRP server. The selected SRP server address is also set
90  * as the DNS server address in the default config.
91  *
92  */
93 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE
94 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE \
95     (OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE)
96 #endif
97 
98 /**
99  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS
100  *
101  * Specifies the default DNS server IPv6 address.
102  *
103  * It MUST be a C string representation of the server IPv6 address.
104  *
105  * Default value is set to "2001:4860:4860::8888" which is the Google Public DNS IPv6 address.
106  *
107  */
108 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS
109 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS "2001:4860:4860::8888"
110 #endif
111 
112 /**
113  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT
114  *
115  * Specifies the default DNS server port number.
116  *
117  */
118 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT
119 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT 53
120 #endif
121 
122 /**
123  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT
124  *
125  * Specifies the default wait time that DNS client waits for a response from server (in milliseconds).
126  *
127  */
128 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT
129 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT 6000
130 #endif
131 
132 /**
133  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS
134  *
135  * Specifies the default maximum number of DNS query tx attempts with no response before reporting failure.
136  *
137  */
138 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS
139 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS 3
140 #endif
141 
142 /**
143  * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NO_RECURSION_FLAG
144  *
145  * Specifies the default "recursion desired" flag (indicates whether the server can resolve the query recursively or
146  * not).
147  *
148  */
149 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG
150 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG 1
151 #endif
152 
153 #endif // CONFIG_DNS_CLIENT_H_
154