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