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