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