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 #ifndef CONFIG_DNS_CLIENT_H_ 35 #define CONFIG_DNS_CLIENT_H_ 36 37 /** 38 * @addtogroup config-dns-client 39 * 40 * @brief 41 * This module includes configuration variables for the DNS client. 42 * 43 * @{ 44 */ 45 46 #include "config/ip6.h" 47 #include "config/srp_client.h" 48 49 /** 50 * @def OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 51 * 52 * Define to 1 to enable DNS Client support. 53 */ 54 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 55 #define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 0 56 #endif 57 58 /** 59 * @def OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE 60 * 61 * Define to 1 to enable support for NAT64 address translation (from IPv4 to IPv6) during address resolution by DNS 62 * client. 63 */ 64 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE 65 #define OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE 1 66 #endif 67 68 /** 69 * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED 70 * 71 * Specifies the default NAT64 mode, i.e., whether to allow or disallow NAT64 address translation during DNS client 72 * address resolution. This mode is only available when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled. 73 */ 74 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED 75 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED 1 76 #endif 77 78 /** 79 * @def OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 80 * 81 * Define to 1 to enable DNS based Service Discovery (DNS-SD) client. 82 */ 83 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 84 #define OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 1 85 #endif 86 87 /** 88 * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE 89 * 90 * Set to 1 for DNS client to automatically set and update the server IPv6 address in the default config (when it is 91 * not explicitly set by user). 92 * 93 * This feature requires SRP client and its auto-start feature to be also enabled. SRP client will then monitor the 94 * Thread Network Data for DNS/SRP Service entries to select an SRP server. The selected SRP server address is also set 95 * as the DNS server address in the default config. 96 */ 97 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE 98 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE \ 99 (OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE) 100 #endif 101 102 /** 103 * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS 104 * 105 * Specifies the default DNS server IPv6 address. 106 * 107 * It MUST be a C string representation of the server IPv6 address. 108 * 109 * Default value is set to "2001:4860:4860::8888" which is the Google Public DNS IPv6 address. 110 */ 111 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS 112 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS "2001:4860:4860::8888" 113 #endif 114 115 /** 116 * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT 117 * 118 * Specifies the default DNS server port number. 119 */ 120 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT 121 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT 53 122 #endif 123 124 /** 125 * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT 126 * 127 * Specifies the default wait time that DNS client waits for a response from server (in milliseconds). 128 */ 129 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT 130 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT 6000 131 #endif 132 133 /** 134 * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS 135 * 136 * Specifies the default maximum number of DNS query tx attempts with no response before reporting failure. 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 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG 149 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG 1 150 #endif 151 152 /** 153 * @def OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE 154 * 155 * Specifies the default `otDnsServiceMode` to use. The value MUST be from `otDnsServiceMode` enumeration. 156 */ 157 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE 158 #define OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE 159 #endif 160 161 /** 162 * @def OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE 163 * 164 * Enables support for sending DNS Queries over TCP. 165 */ 166 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE 167 #define OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE 0 168 #endif 169 170 /** 171 * @def OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE 172 * 173 * Specifies size of receive and transmit buffers of TCP sockets for DNS query over TCP. 174 */ 175 #ifndef OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE 176 #define OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE 1024 177 #endif 178 179 /** 180 * @} 181 */ 182 183 #endif // CONFIG_DNS_CLIENT_H_ 184