Upgrade upstream version to 2.82
[platform/upstream/dnsmasq.git] / src / config.h
1 /* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
2
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; version 2 dated June, 1991, or
6    (at your option) version 3 dated 29 June, 2007.
7  
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12      
13    You should have received a copy of the GNU General Public License
14    along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #define VERSION "2.82"
18
19 #define FTABSIZ 150 /* max number of outstanding requests (default) */
20 #define MAX_PROCS 20 /* max no children for TCP requests */
21 #define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */
22 #define TCP_MAX_QUERIES 100 /* Maximum number of queries per incoming TCP connection */
23 #define TCP_BACKLOG 32  /* kernel backlog limit for TCP connections */
24 #define EDNS_PKTSZ 4096 /* default max EDNS.0 UDP packet from RFC5625 */
25 #define SAFE_PKTSZ 1280 /* "go anywhere" UDP packet size */
26 #define KEYBLOCK_LEN 40 /* choose to minimise fragmentation when storing DNSSEC keys */
27 #define DNSSEC_WORK 50 /* Max number of queries to validate one question */
28 #define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
29 #define FORWARD_TEST 50 /* try all servers every 50 queries */
30 #define FORWARD_TIME 20 /* or 20 seconds */
31 #define UDP_TEST_TIME 60 /* How often to reset our idea of max packet size. */
32 #define SERVERS_LOGGED 30 /* Only log this many servers when logging state */
33 #define LOCALS_LOGGED 8 /* Only log this many local addresses when logging state */
34 #define RANDOM_SOCKS 64 /* max simultaneous random ports */
35 #define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
36 #define CACHESIZ 150 /* default cache size */
37 #define TTL_FLOOR_LIMIT 3600 /* don't allow --min-cache-ttl to raise TTL above this under any circumstances */
38 #define MAXLEASES 1000 /* maximum number of DHCP leases */
39 #define PING_WAIT 3 /* wait for ping address-in-use test */
40 #define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */
41 #define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
42 #define DHCP_PACKET_MAX 16384 /* hard limit on DHCP packet size */
43 #define SMALLDNAME 50 /* most domain names are smaller than this */
44 #define CNAME_CHAIN 10 /* chains longer than this atr dropped for loop protection */
45 #define DNSSEC_MIN_TTL 60 /* DNSKEY and DS records in cache last at least this long */
46 #define HOSTSFILE "/etc/hosts"
47 #define ETHERSFILE "/etc/ethers"
48 #define DEFLEASE 3600 /* default DHCPv4 lease time, one hour */
49 #define DEFLEASE6 (3600*24) /* default lease time for DHCPv6. One day. */
50 #define CHUSER "nobody"
51 #define CHGRP "dip"
52 #define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
53 #define LOG_MAX 5 /* log-queue length */
54 #define RANDFILE "/dev/urandom"
55 #define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */
56 #define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
57 #define DNSMASQ_UBUS_NAME "dnsmasq" /* Default - may be overridden by config */
58 #define AUTH_TTL 600 /* default TTL for auth DNS */
59 #define SOA_REFRESH 1200 /* SOA refresh default */
60 #define SOA_RETRY 180 /* SOA retry default */
61 #define SOA_EXPIRY 1209600 /* SOA expiry default */
62 #define LOOP_TEST_DOMAIN "test" /* domain for loop testing, "test" is reserved by RFC 2606 and won't therefore clash */
63 #define LOOP_TEST_TYPE T_TXT
64  
65 /* compile-time options: uncomment below to enable or do eg.
66    make COPTS=-DHAVE_BROKEN_RTC
67
68 HAVE_BROKEN_RTC
69    define this on embedded systems which don't have an RTC
70    which keeps time over reboots. Causes dnsmasq to use uptime
71    for timing, and keep lease lengths rather than expiry times
72    in its leases file. This also make dnsmasq "flash disk friendly".
73    Normally, dnsmasq tries very hard to keep the on-disk leases file
74    up-to-date: rewriting it after every renewal.  When HAVE_BROKEN_RTC 
75    is in effect, the lease file is only written when a new lease is 
76    created, or an old one destroyed. (Because those are the only times 
77    it changes.) This vastly reduces the number of file writes, and makes
78    it viable to keep the lease file on a flash filesystem.
79    NOTE: when enabling or disabling this, be sure to delete any old
80    leases file, otherwise dnsmasq may get very confused.
81
82 HAVE_TFTP
83    define this to get dnsmasq's built-in TFTP server.
84
85 HAVE_DHCP
86    define this to get dnsmasq's DHCPv4 server.
87
88 HAVE_DHCP6
89    define this to get dnsmasq's DHCPv6 server. (implies HAVE_DHCP).
90
91 HAVE_SCRIPT
92    define this to get the ability to call scripts on lease-change.
93
94 HAVE_LUASCRIPT
95    define this to get the ability to call Lua script on lease-change. (implies HAVE_SCRIPT) 
96
97 HAVE_DBUS
98    define this if you want to link against libdbus, and have dnsmasq
99    support some methods to allow (re)configuration of the upstream DNS 
100    servers via DBus.
101
102 HAVE_UBUS
103    define this if you want to link against libubus
104
105 HAVE_IDN
106    define this if you want international domain name 2003 support.
107    
108 HAVE_LIBIDN2
109    define this if you want international domain name 2008 support.
110
111 HAVE_CONNTRACK
112    define this to include code which propagates conntrack marks from
113    incoming DNS queries to the corresponding upstream queries. This adds
114    a build-dependency on libnetfilter_conntrack, but the resulting binary will
115    still run happily on a kernel without conntrack support.
116
117 HAVE_IPSET
118     define this to include the ability to selectively add resolved ip addresses
119     to given ipsets.
120
121 HAVE_AUTH
122    define this to include the facility to act as an authoritative DNS
123    server for one or more zones.
124
125 HAVE_DNSSEC
126    include DNSSEC validator.
127
128 HAVE_DUMPFILE
129    include code to dump packets to a libpcap-format file for debugging.
130
131 HAVE_LOOP
132    include functionality to probe for and remove DNS forwarding loops.
133
134 HAVE_INOTIFY
135    use the Linux inotify facility to efficiently re-read configuration files.
136
137 NO_ID
138    Don't report *.bind CHAOS info to clients, forward such requests upstream instead.
139 NO_TFTP
140 NO_DHCP
141 NO_DHCP6
142 NO_SCRIPT
143 NO_LARGEFILE
144 NO_AUTH
145 NO_DUMPFILE
146 NO_INOTIFY
147    these are available to explicitly disable compile time options which would 
148    otherwise be enabled automatically or which are enabled  by default 
149    in the distributed source tree. Building dnsmasq
150    with something like "make COPTS=-DNO_SCRIPT" will do the trick.
151 NO_GMP
152    Don't use and link against libgmp, Useful if nettle is built with --enable-mini-gmp.
153
154 LEASEFILE
155 CONFFILE
156 RESOLVFILE
157    the default locations of these files are determined below, but may be overridden 
158    in a build command line using COPTS.
159
160 */
161
162 /* Defining this builds a binary which handles time differently and works better on a system without a 
163    stable RTC (it uses uptime, not epoch time) and writes the DHCP leases file less often to avoid flash wear. 
164 */
165
166 /* #define HAVE_BROKEN_RTC */
167
168 /* The default set of options to build. Built with these options, dnsmasq
169    has no library dependencies other than libc */
170
171 #define HAVE_DHCP
172 #define HAVE_DHCP6 
173 #define HAVE_TFTP
174 #define HAVE_SCRIPT
175 #define HAVE_AUTH
176 #define HAVE_IPSET 
177 #define HAVE_LOOP
178 #define HAVE_DUMPFILE
179
180 /* Build options which require external libraries.
181    
182    Defining HAVE_<opt>_STATIC as _well_ as HAVE_<opt> will link the library statically.
183
184    You can use "make COPTS=-DHAVE_<opt>" instead of editing these.
185 */
186
187 /* #define HAVE_LUASCRIPT */
188 #define HAVE_DBUS
189 /* #define HAVE_IDN */
190 /* #define HAVE_LIBIDN2 */
191 /* #define HAVE_CONNTRACK */
192 /* #define HAVE_DNSSEC */
193
194
195 /* Default locations for important system files. */
196
197 #ifndef LEASEFILE
198 #   if defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
199 #      define LEASEFILE "/var/db/dnsmasq.leases"
200 #   elif defined(__sun__) || defined (__sun)
201 #      define LEASEFILE "/var/cache/dnsmasq.leases"
202 #   elif defined(__ANDROID__)
203 #      define LEASEFILE "/data/misc/dhcp/dnsmasq.leases"
204 #   else
205 #      define LEASEFILE "/var/lib/misc/dnsmasq.leases"
206 #   endif
207 #endif
208
209 #ifndef CONFFILE
210 #   if defined(__FreeBSD__)
211 #      define CONFFILE "/usr/local/etc/dnsmasq.conf"
212 #   else
213 #      define CONFFILE "/etc/dnsmasq.conf"
214 #   endif
215 #endif
216
217 #ifndef RESOLVFILE
218 #   if defined(__uClinux__)
219 #      define RESOLVFILE "/etc/config/resolv.conf"
220 #   else
221 #      define RESOLVFILE "/etc/resolv.conf"
222 #   endif
223 #endif
224
225 #ifndef RUNFILE
226 #   if defined(__ANDROID__)
227 #      define RUNFILE "/data/dnsmasq.pid"
228 #    else
229 #      define RUNFILE "/var/run/dnsmasq.pid"
230 #    endif
231 #endif
232
233 /* platform dependent options: these are determined automatically below
234
235 HAVE_LINUX_NETWORK
236 HAVE_BSD_NETWORK
237 HAVE_SOLARIS_NETWORK
238    define exactly one of these to alter interaction with kernel networking.
239
240 HAVE_GETOPT_LONG
241    defined when GNU-style getopt_long available. 
242
243 HAVE_SOCKADDR_SA_LEN
244    defined if struct sockaddr has sa_len field (*BSD) 
245 */
246
247 #if defined(__UCLIBC__)
248 #define HAVE_LINUX_NETWORK
249 #if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
250    ((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
251 #    define HAVE_GETOPT_LONG
252 #endif
253 #undef HAVE_SOCKADDR_SA_LEN
254 #if defined(__UCLIBC_HAS_IPV6__)
255 #  ifndef IPV6_V6ONLY
256 #    define IPV6_V6ONLY 26
257 #  endif
258 #endif
259
260 /* This is for glibc 2.x */
261 #elif defined(__linux__)
262 #define HAVE_LINUX_NETWORK
263 #define HAVE_GETOPT_LONG
264 #undef HAVE_SOCKADDR_SA_LEN
265
266 #elif defined(__FreeBSD__) || \
267       defined(__OpenBSD__) || \
268       defined(__DragonFly__) || \
269       defined(__FreeBSD_kernel__)
270 #define HAVE_BSD_NETWORK
271 /* Later versions of FreeBSD have getopt_long() */
272 #if defined(optional_argument) && defined(required_argument)
273 #   define HAVE_GETOPT_LONG
274 #endif
275 #define HAVE_SOCKADDR_SA_LEN
276
277 #elif defined(__APPLE__)
278 #define HAVE_BSD_NETWORK
279 #define HAVE_GETOPT_LONG
280 #define HAVE_SOCKADDR_SA_LEN
281 #define NO_IPSET
282 /* Define before sys/socket.h is included so we get socklen_t */
283 #define _BSD_SOCKLEN_T_
284 /* Select the RFC_3542 version of the IPv6 socket API. 
285    Define before netinet6/in6.h is included. */
286 #define __APPLE_USE_RFC_3542
287 /* Required for Mojave. */
288 #ifndef SOL_TCP
289 #  define SOL_TCP IPPROTO_TCP
290 #endif
291 #define NO_IPSET
292
293 #elif defined(__NetBSD__)
294 #define HAVE_BSD_NETWORK
295 #define HAVE_GETOPT_LONG
296 #define HAVE_SOCKADDR_SA_LEN
297
298 #elif defined(__sun) || defined(__sun__)
299 #define HAVE_SOLARIS_NETWORK
300 #define HAVE_GETOPT_LONG
301 #undef HAVE_SOCKADDR_SA_LEN
302 #define ETHER_ADDR_LEN 6 
303  
304 #endif
305
306 /* rules to implement compile-time option dependencies and 
307    the NO_XXX flags */
308
309 #ifdef NO_TFTP
310 #undef HAVE_TFTP
311 #endif
312
313 #ifdef NO_DHCP
314 #undef HAVE_DHCP
315 #undef HAVE_DHCP6
316 #endif
317
318 #if defined(NO_DHCP6)
319 #undef HAVE_DHCP6
320 #endif
321
322 /* DHCP6 needs DHCP too */
323 #ifdef HAVE_DHCP6
324 #define HAVE_DHCP
325 #endif
326
327 #if defined(NO_SCRIPT)
328 #undef HAVE_SCRIPT
329 #undef HAVE_LUASCRIPT
330 #endif
331
332 /* Must HAVE_SCRIPT to HAVE_LUASCRIPT */
333 #ifdef HAVE_LUASCRIPT
334 #define HAVE_SCRIPT
335 #endif
336
337 #ifdef NO_AUTH
338 #undef HAVE_AUTH
339 #endif
340
341 #if defined(NO_IPSET)
342 #undef HAVE_IPSET
343 #endif
344
345 #ifdef NO_LOOP
346 #undef HAVE_LOOP
347 #endif
348
349 #ifdef NO_DUMPFILE
350 #undef HAVE_DUMPFILE
351 #endif
352
353 #if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
354 #define HAVE_INOTIFY
355 #endif
356
357 /* Define a string indicating which options are in use.
358    DNSMASQ_COMPILE_OPTS is only defined in dnsmasq.c */
359
360 #ifdef DNSMASQ_COMPILE_OPTS
361
362 static char *compile_opts = 
363 "IPv6 "
364 #ifndef HAVE_GETOPT_LONG
365 "no-"
366 #endif
367 "GNU-getopt "
368 #ifdef HAVE_BROKEN_RTC
369 "no-RTC "
370 #endif
371 #ifndef HAVE_DBUS
372 "no-"
373 #endif
374 "DBus "
375 #ifndef HAVE_UBUS
376 "no-"
377 #endif
378 "UBus "
379 #ifndef LOCALEDIR
380 "no-"
381 #endif
382 "i18n "
383 #if defined(HAVE_LIBIDN2)
384 "IDN2 "
385 #else
386  #if !defined(HAVE_IDN)
387 "no-"
388  #endif 
389 "IDN " 
390 #endif
391 #ifndef HAVE_DHCP
392 "no-"
393 #endif
394 "DHCP "
395 #if defined(HAVE_DHCP)
396 #  if !defined (HAVE_DHCP6)
397      "no-"
398 #  endif  
399      "DHCPv6 "
400 #endif
401 #if !defined(HAVE_SCRIPT)
402      "no-scripts "
403 #else
404 #  if !defined(HAVE_LUASCRIPT)
405      "no-"
406 #  endif
407      "Lua "
408 #endif
409 #ifndef HAVE_TFTP
410 "no-"
411 #endif
412 "TFTP "
413 #ifndef HAVE_CONNTRACK
414 "no-"
415 #endif
416 "conntrack "
417 #ifndef HAVE_IPSET
418 "no-"
419 #endif
420 "ipset "
421 #ifndef HAVE_AUTH
422 "no-"
423 #endif
424 "auth "
425 #ifndef HAVE_DNSSEC
426 "no-"
427 #endif
428 "DNSSEC "
429 #ifdef NO_ID
430 "no-ID "
431 #endif
432 #ifndef HAVE_LOOP
433 "no-"
434 #endif
435 "loop-detect "
436 #ifndef HAVE_INOTIFY
437 "no-"
438 #endif
439 "inotify "
440 #ifndef HAVE_DUMPFILE
441 "no-"
442 #endif
443 "dumpfile";
444
445 #endif
446
447
448