Dnsmasq v2.68 rc4
[tomato.git] / release / src / router / dnsmasq / src / config.h
blob0f0fee6954c71da69b5fb73c6626fa9cc185513e
1 /* dnsmasq is Copyright (c) 2000-2013 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 EDNS_PKTSZ 4096 /* default max EDNS.0 UDP packet from RFC5625 */
21 #define KEYBLOCK_LEN 140 /* choose to mininise fragmentation when storing DNSSEC keys */
22 #define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
23 #define FORWARD_TEST 50 /* try all servers every 50 queries */
24 #define FORWARD_TIME 20 /* or 20 seconds */
25 #define RANDOM_SOCKS 64 /* max simultaneous random ports */
26 #define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
27 #define CACHESIZ 150 /* default cache size */
28 #define MAXLEASES 1000 /* maximum number of DHCP leases */
29 #define PING_WAIT 3 /* wait for ping address-in-use test */
30 #define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */
31 #define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
32 #define DHCP_PACKET_MAX 16384 /* hard limit on DHCP packet size */
33 #define SMALLDNAME 40 /* most domain names are smaller than this */
34 #define HOSTSFILE "/etc/hosts"
35 #define ETHERSFILE "/etc/ethers"
36 #define DEFLEASE 3600 /* default lease time, 1 hour */
37 #define CHUSER "nobody"
38 #define CHGRP "dip"
39 #define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
40 #define LOG_MAX 5 /* log-queue length */
41 #define RANDFILE "/dev/urandom"
42 #define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */
43 #define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
44 #define AUTH_TTL 600 /* default TTL for auth DNS */
45 #define SOA_REFRESH 1200 /* SOA refresh default */
46 #define SOA_RETRY 180 /* SOA retry default */
47 #define SOA_EXPIRY 1209600 /* SOA expiry default */
49 /* compile-time options: uncomment below to enable or do eg.
50 make COPTS=-DHAVE_BROKEN_RTC
52 HAVE_BROKEN_RTC
53 define this on embedded systems which don't have an RTC
54 which keeps time over reboots. Causes dnsmasq to use uptime
55 for timing, and keep lease lengths rather than expiry times
56 in its leases file. This also make dnsmasq "flash disk friendly".
57 Normally, dnsmasq tries very hard to keep the on-disk leases file
58 up-to-date: rewriting it after every renewal. When HAVE_BROKEN_RTC
59 is in effect, the lease file is only written when a new lease is
60 created, or an old one destroyed. (Because those are the only times
61 it changes.) This vastly reduces the number of file writes, and makes
62 it viable to keep the lease file on a flash filesystem.
63 NOTE: when enabling or disabling this, be sure to delete any old
64 leases file, otherwise dnsmasq may get very confused.
66 HAVE_LEASEFILE_EXPIRE
68 HAVE_TOMATO
70 HAVE_TFTP
71 define this to get dnsmasq's built-in TFTP server.
73 HAVE_DHCP
74 define this to get dnsmasq's DHCPv4 server.
76 HAVE_DHCP6
77 define this to get dnsmasq's DHCPv6 server. (implies HAVE_DHCP).
79 HAVE_SCRIPT
80 define this to get the ability to call scripts on lease-change.
82 HAVE_LUASCRIPT
83 define this to get the ability to call Lua script on lease-change. (implies HAVE_SCRIPT)
85 HAVE_DBUS
86 define this if you want to link against libdbus, and have dnsmasq
87 support some methods to allow (re)configuration of the upstream DNS
88 servers via DBus.
90 HAVE_IDN
91 define this if you want international domain name support.
92 NOTE: for backwards compatibility, IDN support is automatically
93 included when internationalisation support is built, using the
94 *-i18n makefile targets, even if HAVE_IDN is not explicitly set.
96 HAVE_CONNTRACK
97 define this to include code which propogates conntrack marks from
98 incoming DNS queries to the corresponding upstream queries. This adds
99 a build-dependency on libnetfilter_conntrack, but the resulting binary will
100 still run happily on a kernel without conntrack support.
102 HAVE_IPSET
103 define this to include the ability to selectively add resolved ip addresses
104 to given ipsets.
106 HAVE_AUTH
107 define this to include the facility to act as an authoritative DNS
108 server for one or more zones.
111 NO_IPV6
112 NO_TFTP
113 NO_DHCP
114 NO_DHCP6
115 NO_SCRIPT
116 NO_LARGEFILE
117 NO_AUTH
118 these are avilable to explictly disable compile time options which would
119 otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
120 which are enabled by default in the distributed source tree. Building dnsmasq
121 with something like "make COPTS=-DNO_SCRIPT" will do the trick.
123 LEASEFILE
124 CONFFILE
125 RESOLVFILE
126 the default locations of these files are determined below, but may be overridden
127 in a build command line using COPTS.
132 /* The default set of options to build. Built with these options, dnsmasq
133 has no library dependencies other than libc */
135 #define HAVE_DHCP
136 #define HAVE_DHCP6
137 #define HAVE_TFTP
138 #define HAVE_SCRIPT
139 #define HAVE_AUTH
140 #define HAVE_IPSET
141 /* #define HAVE_LUASCRIPT */
142 /* #define HAVE_BROKEN_RTC */
143 /* #define HAVE_DBUS */
144 /* #define HAVE_IDN */
145 /* #define HAVE_CONNTRACK */
148 /* Default locations for important system files. */
150 #ifndef LEASEFILE
151 # if defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
152 # define LEASEFILE "/var/db/dnsmasq.leases"
153 # elif defined(__sun__) || defined (__sun)
154 # define LEASEFILE "/var/cache/dnsmasq.leases"
155 # elif defined(__ANDROID__)
156 # define LEASEFILE "/data/misc/dhcp/dnsmasq.leases"
157 # else
158 # define LEASEFILE "/var/lib/misc/dnsmasq.leases"
159 # endif
160 #endif
162 #ifndef CONFFILE
163 # if defined(__FreeBSD__)
164 # define CONFFILE "/usr/local/etc/dnsmasq.conf"
165 # else
166 # define CONFFILE "/etc/dnsmasq.conf"
167 # endif
168 #endif
170 #ifndef RESOLVFILE
171 # if defined(__uClinux__)
172 # define RESOLVFILE "/etc/config/resolv.conf"
173 # else
174 # define RESOLVFILE "/etc/resolv.conf"
175 # endif
176 #endif
178 #ifndef RUNFILE
179 # if defined(__ANDROID__)
180 # define RUNFILE "/data/dnsmasq.pid"
181 # else
182 # define RUNFILE "/var/run/dnsmasq.pid"
183 # endif
184 #endif
186 /* platform dependent options: these are determined automatically below
188 HAVE_LINUX_NETWORK
189 HAVE_BSD_NETWORK
190 HAVE_SOLARIS_NETWORK
191 define exactly one of these to alter interaction with kernel networking.
193 HAVE_GETOPT_LONG
194 defined when GNU-style getopt_long available.
196 HAVE_SOCKADDR_SA_LEN
197 defined if struct sockaddr has sa_len field (*BSD)
200 /* Must preceed __linux__ since uClinux defines __linux__ too. */
201 #if defined(__uClinux__)
202 #define HAVE_LINUX_NETWORK
203 #define HAVE_GETOPT_LONG
204 #undef HAVE_SOCKADDR_SA_LEN
205 /* Never use fork() on uClinux. Note that this is subtly different from the
206 --keep-in-foreground option, since it also suppresses forking new
207 processes for TCP connections and disables the call-a-script on leasechange
208 system. It's intended for use on MMU-less kernels. */
209 #define NO_FORK
211 #elif defined(__UCLIBC__)
212 #define HAVE_LINUX_NETWORK
213 #if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
214 ((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
215 # define HAVE_GETOPT_LONG
216 #endif
217 #undef HAVE_SOCKADDR_SA_LEN
218 #if !defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
219 # define NO_FORK
220 #endif
221 #if defined(__UCLIBC_HAS_IPV6__)
222 # ifndef IPV6_V6ONLY
223 # define IPV6_V6ONLY 26
224 # endif
225 #endif
227 /* This is for glibc 2.x */
228 #elif defined(__linux__)
229 #define HAVE_LINUX_NETWORK
230 #define HAVE_GETOPT_LONG
231 #undef HAVE_SOCKADDR_SA_LEN
233 #elif defined(__FreeBSD__) || \
234 defined(__OpenBSD__) || \
235 defined(__DragonFly__) || \
236 defined(__FreeBSD_kernel__)
237 #define HAVE_BSD_NETWORK
238 /* Later verions of FreeBSD have getopt_long() */
239 #if defined(optional_argument) && defined(required_argument)
240 # define HAVE_GETOPT_LONG
241 #endif
242 #define HAVE_SOCKADDR_SA_LEN
244 #elif defined(__APPLE__)
245 #define HAVE_BSD_NETWORK
246 #define HAVE_GETOPT_LONG
247 #define HAVE_SOCKADDR_SA_LEN
248 /* Define before sys/socket.h is included so we get socklen_t */
249 #define _BSD_SOCKLEN_T_
250 /* Select the RFC_3542 version of the IPv6 socket API.
251 Define before netinet6/in6.h is included. */
252 #define __APPLE_USE_RFC_3542
254 #elif defined(__NetBSD__)
255 #define HAVE_BSD_NETWORK
256 #define HAVE_GETOPT_LONG
257 #define HAVE_SOCKADDR_SA_LEN
259 #elif defined(__sun) || defined(__sun__)
260 #define HAVE_SOLARIS_NETWORK
261 #define HAVE_GETOPT_LONG
262 #undef HAVE_SOCKADDR_SA_LEN
263 #define ETHER_ADDR_LEN 6
265 #endif
267 /* Decide if we're going to support IPv6 */
268 /* We assume that systems which don't have IPv6
269 headers don't have ntop and pton either */
271 #if defined(INET6_ADDRSTRLEN) && defined(IPV6_V6ONLY)
272 # define HAVE_IPV6
273 # define ADDRSTRLEN INET6_ADDRSTRLEN
274 #else
275 # if !defined(INET_ADDRSTRLEN)
276 # define INET_ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
277 # endif
278 # undef HAVE_IPV6
279 # define ADDRSTRLEN INET_ADDRSTRLEN
280 #endif
283 /* rules to implement compile-time option dependencies and
284 the NO_XXX flags */
286 #ifdef NO_IPV6
287 #undef HAVE_IPV6
288 #endif
290 #ifdef NO_TFTP
291 #undef HAVE_TFTP
292 #endif
294 #ifdef NO_DHCP
295 #undef HAVE_DHCP
296 #undef HAVE_DHCP6
297 #endif
299 #if defined(NO_DHCP6) || !defined(HAVE_IPV6)
300 #undef HAVE_DHCP6
301 #endif
303 /* DHCP6 needs DHCP too */
304 #ifdef HAVE_DHCP6
305 #define HAVE_DHCP
306 #endif
308 #if defined(NO_SCRIPT) || !defined(HAVE_DHCP) || defined(NO_FORK)
309 #undef HAVE_SCRIPT
310 #undef HAVE_LUASCRIPT
311 #endif
313 /* Must HAVE_SCRIPT to HAVE_LUASCRIPT */
314 #ifdef HAVE_LUASCRIPT
315 #define HAVE_SCRIPT
316 #endif
318 #ifdef NO_AUTH
319 #undef HAVE_AUTH
320 #endif
322 #if defined(NO_IPSET) || !defined(HAVE_LINUX_NETWORK)
323 #undef HAVE_IPSET
324 #endif
326 #ifdef HAVE_TOMATO
327 #define HAVE_LEASEFILE_EXPIRE
328 #endif
330 /* Define a string indicating which options are in use.
331 DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
333 #ifdef DNSMASQ_COMPILE_OPTS
335 static char *compile_opts =
336 #ifndef HAVE_IPV6
337 "no-"
338 #endif
339 "IPv6 "
340 #ifndef HAVE_GETOPT_LONG
341 "no-"
342 #endif
343 "GNU-getopt "
344 #ifdef HAVE_BROKEN_RTC
345 "no-RTC "
346 #endif
347 #ifdef NO_FORK
348 "no-MMU "
349 #endif
350 #ifndef HAVE_DBUS
351 "no-"
352 #endif
353 "DBus "
354 #ifndef LOCALEDIR
355 "no-"
356 #endif
357 "i18n "
358 #if !defined(LOCALEDIR) && !defined(HAVE_IDN)
359 "no-"
360 #endif
361 "IDN "
362 #ifndef HAVE_DHCP
363 "no-"
364 #endif
365 "DHCP "
366 #if defined(HAVE_DHCP)
367 # if !defined (HAVE_DHCP6)
368 "no-"
369 # endif
370 "DHCPv6 "
371 # if !defined(HAVE_SCRIPT)
372 "no-scripts "
373 # else
374 # if !defined(HAVE_LUASCRIPT)
375 "no-"
376 # endif
377 "Lua "
378 # endif
379 #endif
380 #ifndef HAVE_TFTP
381 "no-"
382 #endif
383 "TFTP "
384 #ifndef HAVE_CONNTRACK
385 "no-"
386 #endif
387 "conntrack "
388 #ifndef HAVE_IPSET
389 "no-"
390 #endif
391 "ipset "
392 #ifdef HAVE_TOMATO
393 "Tomato-helper "
394 #endif
395 #ifndef HAVE_AUTH
396 "no-"
397 #endif
398 "auth";
400 #endif