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