dnsmasq: re-apply original Tomato specific code
[tomato.git] / release / src / router / dnsmasq / src / config.h
blob3f3280cfd77b9fecfafc0062563826bb8acd207c
1 /* dnsmasq is Copyright (c) 2000-2016 Simon Kelley
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.
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.
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/>.
17 #define FTABSIZ 150 /* max number of outstanding requests (default) */
18 #define MAX_PROCS 20 /* max no children for TCP requests */
19 #define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */
20 #define TCP_MAX_QUERIES 100 /* Maximum number of queries per incoming TCP connection */
21 #define EDNS_PKTSZ 4096 /* default max EDNS.0 UDP packet from RFC5625 */
22 #define SAFE_PKTSZ 1280 /* "go anywhere" UDP packet size */
23 #define KEYBLOCK_LEN 40 /* choose to mininise fragmentation when storing DNSSEC keys */
24 #define DNSSEC_WORK 50 /* Max number of queries to validate one question */
25 #define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
26 #define FORWARD_TEST 50 /* try all servers every 50 queries */
27 #define FORWARD_TIME 20 /* or 20 seconds */
28 #define SERVERS_LOGGED 30 /* Only log this many servers when logging state */
29 #define RANDOM_SOCKS 64 /* max simultaneous random ports */
30 #define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
31 #define CACHESIZ 150 /* default cache size */
32 #define TTL_FLOOR_LIMIT 3600 /* don't allow --min-cache-ttl to raise TTL above this under any circumstances */
33 #define MAXLEASES 1000 /* maximum number of DHCP leases */
34 #define PING_WAIT 3 /* wait for ping address-in-use test */
35 #define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */
36 #define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
37 #define DHCP_PACKET_MAX 16384 /* hard limit on DHCP packet size */
38 #define SMALLDNAME 50 /* most domain names are smaller than this */
39 #define CNAME_CHAIN 10 /* chains longer than this atr dropped for loop protection */
40 #define HOSTSFILE "/etc/hosts"
41 #define ETHERSFILE "/etc/ethers"
42 #define DEFLEASE 3600 /* default lease time, 1 hour */
43 #define CHUSER "nobody"
44 #define CHGRP "dip"
45 #define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
46 #define LOG_MAX 5 /* log-queue length */
47 #define RANDFILE "/dev/urandom"
48 #define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */
49 #define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
50 #define AUTH_TTL 600 /* default TTL for auth DNS */
51 #define SOA_REFRESH 1200 /* SOA refresh default */
52 #define SOA_RETRY 180 /* SOA retry default */
53 #define SOA_EXPIRY 1209600 /* SOA expiry default */
54 #define LOOP_TEST_DOMAIN "test" /* domain for loop testing, "test" is reserved by RFC 2606 and won't therefore clash */
55 #define LOOP_TEST_TYPE T_TXT
57 /* compile-time options: uncomment below to enable or do eg.
58 make COPTS=-DHAVE_BROKEN_RTC
60 HAVE_BROKEN_RTC
61 define this on embedded systems which don't have an RTC
62 which keeps time over reboots. Causes dnsmasq to use uptime
63 for timing, and keep lease lengths rather than expiry times
64 in its leases file. This also make dnsmasq "flash disk friendly".
65 Normally, dnsmasq tries very hard to keep the on-disk leases file
66 up-to-date: rewriting it after every renewal. When HAVE_BROKEN_RTC
67 is in effect, the lease file is only written when a new lease is
68 created, or an old one destroyed. (Because those are the only times
69 it changes.) This vastly reduces the number of file writes, and makes
70 it viable to keep the lease file on a flash filesystem.
71 NOTE: when enabling or disabling this, be sure to delete any old
72 leases file, otherwise dnsmasq may get very confused.
74 HAVE_LEASEFILE_EXPIRE
76 HAVE_TOMATO
78 HAVE_TFTP
79 define this to get dnsmasq's built-in TFTP server.
81 HAVE_DHCP
82 define this to get dnsmasq's DHCPv4 server.
84 HAVE_DHCP6
85 define this to get dnsmasq's DHCPv6 server. (implies HAVE_DHCP).
87 HAVE_SCRIPT
88 define this to get the ability to call scripts on lease-change.
90 HAVE_LUASCRIPT
91 define this to get the ability to call Lua script on lease-change. (implies HAVE_SCRIPT)
93 HAVE_DBUS
94 define this if you want to link against libdbus, and have dnsmasq
95 support some methods to allow (re)configuration of the upstream DNS
96 servers via DBus.
98 HAVE_IDN
99 define this if you want international domain name support.
100 NOTE: for backwards compatibility, IDN support is automatically
101 included when internationalisation support is built, using the
102 *-i18n makefile targets, even if HAVE_IDN is not explicitly set.
104 HAVE_CONNTRACK
105 define this to include code which propogates conntrack marks from
106 incoming DNS queries to the corresponding upstream queries. This adds
107 a build-dependency on libnetfilter_conntrack, but the resulting binary will
108 still run happily on a kernel without conntrack support.
110 HAVE_IPSET
111 define this to include the ability to selectively add resolved ip addresses
112 to given ipsets.
114 HAVE_AUTH
115 define this to include the facility to act as an authoritative DNS
116 server for one or more zones.
118 HAVE_DNSSEC
119 include DNSSEC validator.
121 HAVE_LOOP
122 include functionality to probe for and remove DNS forwarding loops.
124 HAVE_INOTIFY
125 use the Linux inotify facility to efficiently re-read configuration files.
127 NO_IPV6
128 NO_TFTP
129 NO_DHCP
130 NO_DHCP6
131 NO_SCRIPT
132 NO_LARGEFILE
133 NO_AUTH
134 NO_INOTIFY
135 these are avilable to explictly disable compile time options which would
136 otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
137 which are enabled by default in the distributed source tree. Building dnsmasq
138 with something like "make COPTS=-DNO_SCRIPT" will do the trick.
140 NO_NETTLE_ECC
141 Don't include the ECDSA cypher in DNSSEC validation. Needed for older Nettle versions.
142 NO_GMP
143 Don't use and link against libgmp, Useful if nettle is built with --enable-mini-gmp.
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.
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.
157 /* #define HAVE_BROKEN_RTC */
159 /* The default set of options to build. Built with these options, dnsmasq
160 has no library dependencies other than libc */
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
170 /* Build options which require external libraries.
172 Defining HAVE_<opt>_STATIC as _well_ as HAVE_<opt> will link the library statically.
174 You can use "make COPTS=-DHAVE_<opt>" instead of editing these.
177 /* #define HAVE_LUASCRIPT */
178 /* #define HAVE_DBUS */
179 /* #define HAVE_IDN */
180 /* #define HAVE_CONNTRACK */
181 /* #define HAVE_DNSSEC */
184 /* Default locations for important system files. */
186 #ifndef LEASEFILE
187 # if defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
188 # define LEASEFILE "/var/db/dnsmasq.leases"
189 # elif defined(__sun__) || defined (__sun)
190 # define LEASEFILE "/var/cache/dnsmasq.leases"
191 # elif defined(__ANDROID__)
192 # define LEASEFILE "/data/misc/dhcp/dnsmasq.leases"
193 # else
194 # define LEASEFILE "/var/lib/misc/dnsmasq.leases"
195 # endif
196 #endif
198 #ifndef CONFFILE
199 # if defined(__FreeBSD__)
200 # define CONFFILE "/usr/local/etc/dnsmasq.conf"
201 # else
202 # define CONFFILE "/etc/dnsmasq.conf"
203 # endif
204 #endif
206 #ifndef RESOLVFILE
207 # if defined(__uClinux__)
208 # define RESOLVFILE "/etc/config/resolv.conf"
209 # else
210 # define RESOLVFILE "/etc/resolv.conf"
211 # endif
212 #endif
214 #ifndef RUNFILE
215 # if defined(__ANDROID__)
216 # define RUNFILE "/data/dnsmasq.pid"
217 # else
218 # define RUNFILE "/var/run/dnsmasq.pid"
219 # endif
220 #endif
222 /* platform dependent options: these are determined automatically below
224 HAVE_LINUX_NETWORK
225 HAVE_BSD_NETWORK
226 HAVE_SOLARIS_NETWORK
227 define exactly one of these to alter interaction with kernel networking.
229 HAVE_GETOPT_LONG
230 defined when GNU-style getopt_long available.
232 HAVE_SOCKADDR_SA_LEN
233 defined if struct sockaddr has sa_len field (*BSD)
236 /* Must preceed __linux__ since uClinux defines __linux__ too. */
237 #if defined(__uClinux__)
238 #define HAVE_LINUX_NETWORK
239 #define HAVE_GETOPT_LONG
240 #undef HAVE_SOCKADDR_SA_LEN
241 /* Never use fork() on uClinux. Note that this is subtly different from the
242 --keep-in-foreground option, since it also suppresses forking new
243 processes for TCP connections and disables the call-a-script on leasechange
244 system. It's intended for use on MMU-less kernels. */
245 #define NO_FORK
247 #elif 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(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
255 # define NO_FORK
256 #endif
257 #if defined(__UCLIBC_HAS_IPV6__)
258 # ifndef IPV6_V6ONLY
259 # define IPV6_V6ONLY 26
260 # endif
261 #endif
263 /* This is for glibc 2.x */
264 #elif defined(__linux__)
265 #define HAVE_LINUX_NETWORK
266 #define HAVE_GETOPT_LONG
267 #undef HAVE_SOCKADDR_SA_LEN
269 #elif defined(__FreeBSD__) || \
270 defined(__OpenBSD__) || \
271 defined(__DragonFly__) || \
272 defined(__FreeBSD_kernel__)
273 #define HAVE_BSD_NETWORK
274 /* Later verions of FreeBSD have getopt_long() */
275 #if defined(optional_argument) && defined(required_argument)
276 # define HAVE_GETOPT_LONG
277 #endif
278 #define HAVE_SOCKADDR_SA_LEN
280 #elif defined(__APPLE__)
281 #define HAVE_BSD_NETWORK
282 #define HAVE_GETOPT_LONG
283 #define HAVE_SOCKADDR_SA_LEN
284 /* Define before sys/socket.h is included so we get socklen_t */
285 #define _BSD_SOCKLEN_T_
286 /* Select the RFC_3542 version of the IPv6 socket API.
287 Define before netinet6/in6.h is included. */
288 #define __APPLE_USE_RFC_3542
289 #define NO_IPSET
291 #elif defined(__NetBSD__)
292 #define HAVE_BSD_NETWORK
293 #define HAVE_GETOPT_LONG
294 #define HAVE_SOCKADDR_SA_LEN
296 #elif defined(__sun) || defined(__sun__)
297 #define HAVE_SOLARIS_NETWORK
298 #define HAVE_GETOPT_LONG
299 #undef HAVE_SOCKADDR_SA_LEN
300 #define ETHER_ADDR_LEN 6
302 #endif
304 /* Decide if we're going to support IPv6 */
305 /* We assume that systems which don't have IPv6
306 headers don't have ntop and pton either */
308 #if defined(INET6_ADDRSTRLEN) && defined(IPV6_V6ONLY)
309 # define HAVE_IPV6
310 # define ADDRSTRLEN INET6_ADDRSTRLEN
311 #else
312 # if !defined(INET_ADDRSTRLEN)
313 # define INET_ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
314 # endif
315 # undef HAVE_IPV6
316 # define ADDRSTRLEN INET_ADDRSTRLEN
317 #endif
320 /* rules to implement compile-time option dependencies and
321 the NO_XXX flags */
323 #ifdef NO_IPV6
324 #undef HAVE_IPV6
325 #endif
327 #ifdef NO_TFTP
328 #undef HAVE_TFTP
329 #endif
331 #ifdef NO_DHCP
332 #undef HAVE_DHCP
333 #undef HAVE_DHCP6
334 #endif
336 #if defined(NO_DHCP6) || !defined(HAVE_IPV6)
337 #undef HAVE_DHCP6
338 #endif
340 /* DHCP6 needs DHCP too */
341 #ifdef HAVE_DHCP6
342 #define HAVE_DHCP
343 #endif
345 #if defined(NO_SCRIPT) || defined(NO_FORK)
346 #undef HAVE_SCRIPT
347 #undef HAVE_LUASCRIPT
348 #endif
350 /* Must HAVE_SCRIPT to HAVE_LUASCRIPT */
351 #ifdef HAVE_LUASCRIPT
352 #define HAVE_SCRIPT
353 #endif
355 #ifdef NO_AUTH
356 #undef HAVE_AUTH
357 #endif
359 #if defined(NO_IPSET)
360 #undef HAVE_IPSET
361 #endif
363 #ifdef NO_LOOP
364 #undef HAVE_LOOP
365 #endif
367 #ifdef HAVE_TOMATO
368 #define HAVE_LEASEFILE_EXPIRE
369 #endif
371 #if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
372 #define HAVE_INOTIFY
373 #endif
375 /* Define a string indicating which options are in use.
376 DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
378 #ifdef DNSMASQ_COMPILE_OPTS
380 static char *compile_opts =
381 #ifndef HAVE_IPV6
382 "no-"
383 #endif
384 "IPv6 "
385 #ifndef HAVE_GETOPT_LONG
386 "no-"
387 #endif
388 "GNU-getopt "
389 #ifdef HAVE_BROKEN_RTC
390 "no-RTC "
391 #endif
392 #ifdef NO_FORK
393 "no-MMU "
394 #endif
395 #ifndef HAVE_DBUS
396 "no-"
397 #endif
398 "DBus "
399 #ifndef LOCALEDIR
400 "no-"
401 #endif
402 "i18n "
403 #if !defined(LOCALEDIR) && !defined(HAVE_IDN)
404 "no-"
405 #endif
406 "IDN "
407 #ifndef HAVE_DHCP
408 "no-"
409 #endif
410 "DHCP "
411 #if defined(HAVE_DHCP)
412 # if !defined (HAVE_DHCP6)
413 "no-"
414 # endif
415 "DHCPv6 "
416 # if !defined(HAVE_SCRIPT)
417 "no-scripts "
418 # else
419 # if !defined(HAVE_LUASCRIPT)
420 "no-"
421 # endif
422 "Lua "
423 # endif
424 #endif
425 #ifndef HAVE_TFTP
426 "no-"
427 #endif
428 "TFTP "
429 #ifndef HAVE_CONNTRACK
430 "no-"
431 #endif
432 "conntrack "
433 #ifndef HAVE_IPSET
434 "no-"
435 #endif
436 "ipset "
437 #ifdef HAVE_TOMATO
438 "Tomato-helper "
439 #endif
440 #ifndef HAVE_AUTH
441 "no-"
442 #endif
443 "auth "
444 #ifndef HAVE_DNSSEC
445 "no-"
446 #endif
447 "DNSSEC "
448 #ifndef HAVE_LOOP
449 "no-"
450 #endif
451 "loop-detect "
452 #ifndef HAVE_INOTIFY
453 "no-"
454 #endif
455 "inotify";
457 #endif