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