Update to 2.79
[platform/upstream/dnsmasq.git] / src / config.h
1 /* dnsmasq is Copyright (c) 2000-2018 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.79"
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 HOSTSFILE "/etc/hosts"
46 #define ETHERSFILE "/etc/ethers"
47 #define DEFLEASE 3600 /* default lease time, 1 hour */
48 #define CHUSER "nobody"
49 #define CHGRP "dip"
50 #define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
51 #define LOG_MAX 5 /* log-queue length */
52 #define RANDFILE "/dev/urandom"
53 #define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */
54 #define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
55 #define AUTH_TTL 600 /* default TTL for auth DNS */
56 #define SOA_REFRESH 1200 /* SOA refresh default */
57 #define SOA_RETRY 180 /* SOA retry default */
58 #define SOA_EXPIRY 1209600 /* SOA expiry default */
59 #define LOOP_TEST_DOMAIN "test" /* domain for loop testing, "test" is reserved by RFC 2606 and won't therefore clash */
60 #define LOOP_TEST_TYPE T_TXT
61  
62 /* compile-time options: uncomment below to enable or do eg.
63    make COPTS=-DHAVE_BROKEN_RTC
64
65 HAVE_BROKEN_RTC
66    define this on embedded systems which don't have an RTC
67    which keeps time over reboots. Causes dnsmasq to use uptime
68    for timing, and keep lease lengths rather than expiry times
69    in its leases file. This also make dnsmasq "flash disk friendly".
70    Normally, dnsmasq tries very hard to keep the on-disk leases file
71    up-to-date: rewriting it after every renewal.  When HAVE_BROKEN_RTC 
72    is in effect, the lease file is only written when a new lease is 
73    created, or an old one destroyed. (Because those are the only times 
74    it changes.) This vastly reduces the number of file writes, and makes
75    it viable to keep the lease file on a flash filesystem.
76    NOTE: when enabling or disabling this, be sure to delete any old
77    leases file, otherwise dnsmasq may get very confused.
78
79 HAVE_TFTP
80    define this to get dnsmasq's built-in TFTP server.
81
82 HAVE_DHCP
83    define this to get dnsmasq's DHCPv4 server.
84
85 HAVE_DHCP6
86    define this to get dnsmasq's DHCPv6 server. (implies HAVE_DHCP).
87
88 HAVE_SCRIPT
89    define this to get the ability to call scripts on lease-change.
90
91 HAVE_LUASCRIPT
92    define this to get the ability to call Lua script on lease-change. (implies HAVE_SCRIPT) 
93
94 HAVE_DBUS
95    define this if you want to link against libdbus, and have dnsmasq
96    support some methods to allow (re)configuration of the upstream DNS 
97    servers via DBus.
98
99 HAVE_IDN
100    define this if you want international domain name 2003 support.
101    
102 HAVE_LIBIDN2
103    define this if you want international domain name 2008 support.
104
105 HAVE_CONNTRACK
106    define this to include code which propagates conntrack marks from
107    incoming DNS queries to the corresponding upstream queries. This adds
108    a build-dependency on libnetfilter_conntrack, but the resulting binary will
109    still run happily on a kernel without conntrack support.
110
111 HAVE_IPSET
112     define this to include the ability to selectively add resolved ip addresses
113     to given ipsets.
114
115 HAVE_AUTH
116    define this to include the facility to act as an authoritative DNS
117    server for one or more zones.
118
119 HAVE_DNSSEC
120    include DNSSEC validator.
121
122 HAVE_LOOP
123    include functionality to probe for and remove DNS forwarding loops.
124
125 HAVE_INOTIFY
126    use the Linux inotify facility to efficiently re-read configuration files.
127
128 NO_ID
129    Don't report *.bind CHAOS info to clients, forward such requests upstream instead.
130 NO_IPV6
131 NO_TFTP
132 NO_DHCP
133 NO_DHCP6
134 NO_SCRIPT
135 NO_LARGEFILE
136 NO_AUTH
137 NO_INOTIFY
138    these are available to explicitly disable compile time options which would 
139    otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or 
140    which are enabled  by default in the distributed source tree. Building dnsmasq
141    with something like "make COPTS=-DNO_SCRIPT" will do the trick.
142 NO_GMP
143    Don't use and link against libgmp, Useful if nettle is built with --enable-mini-gmp.
144
145 LEASEFILE
146 CONFFILE
147 RESOLVFILE
148    the default locations of these files are determined below, but may be overridden 
149    in a build command line using COPTS.
150
151 */
152
153 /* Defining this builds a binary which handles time differently and works better on a system without a 
154    stable RTC (it uses uptime, not epoch time) and writes the DHCP leases file less often to avoid flash wear. 
155 */
156
157 /* #define HAVE_BROKEN_RTC */
158
159 /* The default set of options to build. Built with these options, dnsmasq
160    has no library dependencies other than libc */
161
162 #define HAVE_DHCP
163 #define HAVE_DHCP6 
164 #define HAVE_TFTP
165 #define HAVE_SCRIPT
166 #define HAVE_AUTH
167 #define HAVE_IPSET 
168 #define HAVE_LOOP
169
170 /* Build options which require external libraries.
171    
172    Defining HAVE_<opt>_STATIC as _well_ as HAVE_<opt> will link the library statically.
173
174    You can use "make COPTS=-DHAVE_<opt>" instead of editing these.
175 */
176
177 /* #define HAVE_LUASCRIPT */
178 #define HAVE_DBUS
179 /* #define HAVE_IDN */
180 /* #define HAVE_LIBIDN2 */
181 /* #define HAVE_CONNTRACK */
182 /* #define HAVE_DNSSEC */
183
184
185 /* Default locations for important system files. */
186
187 #ifndef LEASEFILE
188 #   if defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
189 #      define LEASEFILE "/var/db/dnsmasq.leases"
190 #   elif defined(__sun__) || defined (__sun)
191 #      define LEASEFILE "/var/cache/dnsmasq.leases"
192 #   elif defined(__ANDROID__)
193 #      define LEASEFILE "/data/misc/dhcp/dnsmasq.leases"
194 #   else
195 #      define LEASEFILE "/var/lib/misc/dnsmasq.leases"
196 #   endif
197 #endif
198
199 #ifndef CONFFILE
200 #   if defined(__FreeBSD__)
201 #      define CONFFILE "/usr/local/etc/dnsmasq.conf"
202 #   else
203 #      define CONFFILE "/etc/dnsmasq.conf"
204 #   endif
205 #endif
206
207 #ifndef RESOLVFILE
208 #   if defined(__uClinux__)
209 #      define RESOLVFILE "/etc/config/resolv.conf"
210 #   else
211 #      define RESOLVFILE "/etc/resolv.conf"
212 #   endif
213 #endif
214
215 #ifndef RUNFILE
216 #   if defined(__ANDROID__)
217 #      define RUNFILE "/data/dnsmasq.pid"
218 #    else
219 #      define RUNFILE "/var/run/dnsmasq.pid"
220 #    endif
221 #endif
222
223 /* platform dependent options: these are determined automatically below
224
225 HAVE_LINUX_NETWORK
226 HAVE_BSD_NETWORK
227 HAVE_SOLARIS_NETWORK
228    define exactly one of these to alter interaction with kernel networking.
229
230 HAVE_GETOPT_LONG
231    defined when GNU-style getopt_long available. 
232
233 HAVE_SOCKADDR_SA_LEN
234    defined if struct sockaddr has sa_len field (*BSD) 
235 */
236
237 /* Must precede __linux__ since uClinux defines __linux__ too. */
238 #if defined(__uClinux__)
239 #define HAVE_LINUX_NETWORK
240 #define HAVE_GETOPT_LONG
241 #undef HAVE_SOCKADDR_SA_LEN
242 /* Never use fork() on uClinux. Note that this is subtly different from the
243    --keep-in-foreground option, since it also  suppresses forking new 
244    processes for TCP connections and disables the call-a-script on leasechange
245    system. It's intended for use on MMU-less kernels. */
246 #define NO_FORK
247
248 #elif defined(__UCLIBC__)
249 #define HAVE_LINUX_NETWORK
250 #if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
251    ((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
252 #    define HAVE_GETOPT_LONG
253 #endif
254 #undef HAVE_SOCKADDR_SA_LEN
255 #if !defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
256 #  define NO_FORK
257 #endif
258 #if defined(__UCLIBC_HAS_IPV6__)
259 #  ifndef IPV6_V6ONLY
260 #    define IPV6_V6ONLY 26
261 #  endif
262 #endif
263
264 /* This is for glibc 2.x */
265 #elif defined(__linux__)
266 #define HAVE_LINUX_NETWORK
267 #define HAVE_GETOPT_LONG
268 #undef HAVE_SOCKADDR_SA_LEN
269
270 #elif defined(__FreeBSD__) || \
271       defined(__OpenBSD__) || \
272       defined(__DragonFly__) || \
273       defined(__FreeBSD_kernel__)
274 #define HAVE_BSD_NETWORK
275 /* Later versions of FreeBSD have getopt_long() */
276 #if defined(optional_argument) && defined(required_argument)
277 #   define HAVE_GETOPT_LONG
278 #endif
279 #define HAVE_SOCKADDR_SA_LEN
280
281 #elif defined(__APPLE__)
282 #define HAVE_BSD_NETWORK
283 #define HAVE_GETOPT_LONG
284 #define HAVE_SOCKADDR_SA_LEN
285 /* Define before sys/socket.h is included so we get socklen_t */
286 #define _BSD_SOCKLEN_T_
287 /* Select the RFC_3542 version of the IPv6 socket API. 
288    Define before netinet6/in6.h is included. */
289 #define __APPLE_USE_RFC_3542 
290 #define NO_IPSET
291
292 #elif defined(__NetBSD__)
293 #define HAVE_BSD_NETWORK
294 #define HAVE_GETOPT_LONG
295 #define HAVE_SOCKADDR_SA_LEN
296
297 #elif defined(__sun) || defined(__sun__)
298 #define HAVE_SOLARIS_NETWORK
299 #define HAVE_GETOPT_LONG
300 #undef HAVE_SOCKADDR_SA_LEN
301 #define ETHER_ADDR_LEN 6 
302  
303 #endif
304
305 /* Decide if we're going to support IPv6 */
306 /* We assume that systems which don't have IPv6
307    headers don't have ntop and pton either */
308
309 #if defined(INET6_ADDRSTRLEN) && defined(IPV6_V6ONLY)
310 #  define HAVE_IPV6
311 #  define ADDRSTRLEN INET6_ADDRSTRLEN
312 #else
313 #  if !defined(INET_ADDRSTRLEN)
314 #      define INET_ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
315 #  endif
316 #  undef HAVE_IPV6
317 #  define ADDRSTRLEN INET_ADDRSTRLEN
318 #endif
319
320
321 /* rules to implement compile-time option dependencies and 
322    the NO_XXX flags */
323
324 #ifdef NO_IPV6
325 #undef HAVE_IPV6
326 #endif
327
328 #ifdef NO_TFTP
329 #undef HAVE_TFTP
330 #endif
331
332 #ifdef NO_DHCP
333 #undef HAVE_DHCP
334 #undef HAVE_DHCP6
335 #endif
336
337 #if defined(NO_DHCP6) || !defined(HAVE_IPV6)
338 #undef HAVE_DHCP6
339 #endif
340
341 /* DHCP6 needs DHCP too */
342 #ifdef HAVE_DHCP6
343 #define HAVE_DHCP
344 #endif
345
346 #if defined(NO_SCRIPT) || defined(NO_FORK)
347 #undef HAVE_SCRIPT
348 #undef HAVE_LUASCRIPT
349 #endif
350
351 /* Must HAVE_SCRIPT to HAVE_LUASCRIPT */
352 #ifdef HAVE_LUASCRIPT
353 #define HAVE_SCRIPT
354 #endif
355
356 #ifdef NO_AUTH
357 #undef HAVE_AUTH
358 #endif
359
360 #if defined(NO_IPSET)
361 #undef HAVE_IPSET
362 #endif
363
364 #ifdef NO_LOOP
365 #undef HAVE_LOOP
366 #endif
367
368 #if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
369 #define HAVE_INOTIFY
370 #endif
371
372 /* Define a string indicating which options are in use.
373    DNSMASQ_COMPILE_OPTS is only defined in dnsmasq.c */
374
375 #ifdef DNSMASQ_COMPILE_OPTS
376
377 static char *compile_opts = 
378 #ifndef HAVE_IPV6
379 "no-"
380 #endif
381 "IPv6 "
382 #ifndef HAVE_GETOPT_LONG
383 "no-"
384 #endif
385 "GNU-getopt "
386 #ifdef HAVE_BROKEN_RTC
387 "no-RTC "
388 #endif
389 #ifdef NO_FORK
390 "no-MMU "
391 #endif
392 #ifndef HAVE_DBUS
393 "no-"
394 #endif
395 "DBus "
396 #ifndef LOCALEDIR
397 "no-"
398 #endif
399 "i18n "
400 #if defined(HAVE_LIBIDN2)
401 "IDN2 "
402 #else
403  #if !defined(HAVE_IDN)
404 "no-"
405  #endif 
406 "IDN " 
407 #endif
408 #ifndef HAVE_DHCP
409 "no-"
410 #endif
411 "DHCP "
412 #if defined(HAVE_DHCP)
413 #  if !defined (HAVE_DHCP6)
414      "no-"
415 #  endif  
416      "DHCPv6 "
417 #endif
418 #if !defined(HAVE_SCRIPT)
419      "no-scripts "
420 #else
421 #  if !defined(HAVE_LUASCRIPT)
422      "no-"
423 #  endif
424      "Lua "
425 #endif
426 #ifndef HAVE_TFTP
427 "no-"
428 #endif
429 "TFTP "
430 #ifndef HAVE_CONNTRACK
431 "no-"
432 #endif
433 "conntrack "
434 #ifndef HAVE_IPSET
435 "no-"
436 #endif
437 "ipset "
438 #ifndef HAVE_AUTH
439 "no-"
440 #endif
441 "auth "
442 #ifndef HAVE_DNSSEC
443 "no-"
444 #endif
445 "DNSSEC "
446 #ifdef NO_ID
447 "no-ID "
448 #endif
449 #ifndef HAVE_LOOP
450 "no-"
451 #endif
452 "loop-detect "
453 #ifndef HAVE_INOTIFY
454 "no-"
455 #endif
456 "inotify";
457
458
459 #endif
460
461
462