Debian Codegraph @

src/config.h

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