"Fossies" - the Fresh Open Source Software Archive

Member "dnsmasq-2.85/src/config.h" (7 Apr 2021, 12604 Bytes) of package /linux/misc/dns/dnsmasq-2.85.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "config.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.84_vs_2.85.

    1 /* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
    2 
    3    This program is free software; you can redistribute it and/or modify
    4    it under the terms of the GNU General Public License as published by
    5    the Free Software Foundation; version 2 dated June, 1991, or
    6    (at your option) version 3 dated 29 June, 2007.
    7  
    8    This program is distributed in the hope that it will be useful,
    9    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11    GNU General Public License for more details.
   12      
   13    You should have received a copy of the GNU General Public License
   14    along with this program.  If not, see <http://www.gnu.org/licenses/>.
   15 */
   16 
   17 #define FTABSIZ 150 /* max number of outstanding requests (default) */
   18 #define MAX_PROCS 20 /* max no children for TCP requests */
   19 #define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */
   20 #define TCP_MAX_QUERIES 100 /* Maximum number of queries per incoming TCP connection */
   21 #define TCP_BACKLOG 32  /* kernel backlog limit for TCP connections */
   22 #define EDNS_PKTSZ 4096 /* default max EDNS.0 UDP packet from RFC5625 */
   23 #define SAFE_PKTSZ 1280 /* "go anywhere" UDP packet size */
   24 #define KEYBLOCK_LEN 40 /* choose to minimise fragmentation when storing DNSSEC keys */
   25 #define DNSSEC_WORK 50 /* Max number of queries to validate one question */
   26 #define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
   27 #define FORWARD_TEST 50 /* try all servers every 50 queries */
   28 #define FORWARD_TIME 20 /* or 20 seconds */
   29 #define UDP_TEST_TIME 60 /* How often to reset our idea of max packet size. */
   30 #define SERVERS_LOGGED 30 /* Only log this many servers when logging state */
   31 #define LOCALS_LOGGED 8 /* Only log this many local addresses when logging state */
   32 #define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
   33 #define CACHESIZ 150 /* default cache size */
   34 #define TTL_FLOOR_LIMIT 3600 /* don't allow --min-cache-ttl to raise TTL above this under any circumstances */
   35 #define MAXLEASES 1000 /* maximum number of DHCP leases */
   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. */
   38 #define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
   39 #define DHCP_PACKET_MAX 16384 /* hard limit on DHCP packet size */
   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 */
   42 #define DNSSEC_MIN_TTL 60 /* DNSKEY and DS records in cache last at least this long */
   43 #define HOSTSFILE "/etc/hosts"
   44 #define ETHERSFILE "/etc/ethers"
   45 #define DEFLEASE 3600 /* default DHCPv4 lease time, one hour */
   46 #define DEFLEASE6 (3600*24) /* default lease time for DHCPv6. One day. */
   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"
   52 #define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */
   53 #define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
   54 #define DNSMASQ_UBUS_NAME "dnsmasq" /* Default - may be overridden by config */
   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 */
   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
   61  
   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 
   99 HAVE_UBUS
  100    define this if you want to link against libubus
  101 
  102 HAVE_IDN
  103    define this if you want international domain name 2003 support.
  104    
  105 HAVE_LIBIDN2
  106    define this if you want international domain name 2008 support.
  107 
  108 HAVE_CONNTRACK
  109    define this to include code which propagates conntrack marks from
  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 
  114 HAVE_IPSET
  115     define this to include the ability to selectively add resolved ip addresses
  116     to given ipsets.
  117 
  118 HAVE_AUTH
  119    define this to include the facility to act as an authoritative DNS
  120    server for one or more zones.
  121 
  122 HAVE_CRYPTOHASH
  123    include just hash function from crypto library, but no DNSSEC.
  124 
  125 HAVE_DNSSEC
  126    include DNSSEC validator.
  127 
  128 HAVE_DUMPFILE
  129    include code to dump packets to a libpcap-format file for debugging.
  130 
  131 HAVE_LOOP
  132    include functionality to probe for and remove DNS forwarding loops.
  133 
  134 HAVE_INOTIFY
  135    use the Linux inotify facility to efficiently re-read configuration files.
  136 
  137 NO_ID
  138    Don't report *.bind CHAOS info to clients, forward such requests upstream instead.
  139 NO_TFTP
  140 NO_DHCP
  141 NO_DHCP6
  142 NO_SCRIPT
  143 NO_LARGEFILE
  144 NO_AUTH
  145 NO_DUMPFILE
  146 NO_INOTIFY
  147    these are available to explicitly disable compile time options which would 
  148    otherwise be enabled automatically or which are enabled  by default 
  149    in the distributed source tree. Building dnsmasq
  150    with something like "make COPTS=-DNO_SCRIPT" will do the trick.
  151 NO_GMP
  152    Don't use and link against libgmp, Useful if nettle is built with --enable-mini-gmp.
  153 
  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 
  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 */
  167 
  168 /* The default set of options to build. Built with these options, dnsmasq
  169    has no library dependencies other than libc */
  170 
  171 #define HAVE_DHCP
  172 #define HAVE_DHCP6 
  173 #define HAVE_TFTP
  174 #define HAVE_SCRIPT
  175 #define HAVE_AUTH
  176 #define HAVE_IPSET 
  177 #define HAVE_LOOP
  178 #define HAVE_DUMPFILE
  179 
  180 /* Build options which require external libraries.
  181    
  182    Defining HAVE_<opt>_STATIC as _well_ as HAVE_<opt> will link the library statically.
  183 
  184    You can use "make COPTS=-DHAVE_<opt>" instead of editing these.
  185 */
  186 
  187 /* #define HAVE_LUASCRIPT */
  188 /* #define HAVE_DBUS */
  189 /* #define HAVE_IDN */
  190 /* #define HAVE_LIBIDN2 */
  191 /* #define HAVE_CONNTRACK */
  192 /* #define HAVE_CRYPTOHASH */
  193 /* #define HAVE_DNSSEC */
  194 
  195 
  196 /* Default locations for important system files. */
  197 
  198 #ifndef LEASEFILE
  199 #   if defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
  200 #      define LEASEFILE "/var/db/dnsmasq.leases"
  201 #   elif defined(__sun__) || defined (__sun)
  202 #      define LEASEFILE "/var/cache/dnsmasq.leases"
  203 #   elif defined(__ANDROID__)
  204 #      define LEASEFILE "/data/misc/dhcp/dnsmasq.leases"
  205 #   else
  206 #      define LEASEFILE "/var/lib/misc/dnsmasq.leases"
  207 #   endif
  208 #endif
  209 
  210 #ifndef CONFFILE
  211 #   if defined(__FreeBSD__)
  212 #      define CONFFILE "/usr/local/etc/dnsmasq.conf"
  213 #   else
  214 #      define CONFFILE "/etc/dnsmasq.conf"
  215 #   endif
  216 #endif
  217 
  218 #ifndef RESOLVFILE
  219 #   if defined(__uClinux__)
  220 #      define RESOLVFILE "/etc/config/resolv.conf"
  221 #   else
  222 #      define RESOLVFILE "/etc/resolv.conf"
  223 #   endif
  224 #endif
  225 
  226 #ifndef RUNFILE
  227 #   if defined(__ANDROID__)
  228 #      define RUNFILE "/data/dnsmasq.pid"
  229 #    else
  230 #      define RUNFILE "/var/run/dnsmasq.pid"
  231 #    endif
  232 #endif
  233 
  234 /* platform dependent options: these are determined automatically below
  235 
  236 HAVE_LINUX_NETWORK
  237 HAVE_BSD_NETWORK
  238 HAVE_SOLARIS_NETWORK
  239    define exactly one of these to alter interaction with kernel networking.
  240 
  241 HAVE_GETOPT_LONG
  242    defined when GNU-style getopt_long available. 
  243 
  244 HAVE_SOCKADDR_SA_LEN
  245    defined if struct sockaddr has sa_len field (*BSD) 
  246 */
  247 
  248 #if defined(__UCLIBC__)
  249 #define HAVE_LINUX_NETWORK
  250 #if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
  251    ((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
  252 #    define HAVE_GETOPT_LONG
  253 #endif
  254 #undef HAVE_SOCKADDR_SA_LEN
  255 #if defined(__UCLIBC_HAS_IPV6__)
  256 #  ifndef IPV6_V6ONLY
  257 #    define IPV6_V6ONLY 26
  258 #  endif
  259 #endif
  260 
  261 /* This is for glibc 2.x */
  262 #elif defined(__linux__)
  263 #define HAVE_LINUX_NETWORK
  264 #define HAVE_GETOPT_LONG
  265 #undef HAVE_SOCKADDR_SA_LEN
  266 
  267 #elif defined(__FreeBSD__) || \
  268       defined(__OpenBSD__) || \
  269       defined(__DragonFly__) || \
  270       defined(__FreeBSD_kernel__)
  271 #define HAVE_BSD_NETWORK
  272 /* Later versions of FreeBSD have getopt_long() */
  273 #if defined(optional_argument) && defined(required_argument)
  274 #   define HAVE_GETOPT_LONG
  275 #endif
  276 #define HAVE_SOCKADDR_SA_LEN
  277 
  278 #elif defined(__APPLE__)
  279 #define HAVE_BSD_NETWORK
  280 #define HAVE_GETOPT_LONG
  281 #define HAVE_SOCKADDR_SA_LEN
  282 #define NO_IPSET
  283 /* Define before sys/socket.h is included so we get socklen_t */
  284 #define _BSD_SOCKLEN_T_
  285 /* Select the RFC_3542 version of the IPv6 socket API. 
  286    Define before netinet6/in6.h is included. */
  287 #define __APPLE_USE_RFC_3542
  288 /* Required for Mojave. */
  289 #ifndef SOL_TCP
  290 #  define SOL_TCP IPPROTO_TCP
  291 #endif
  292 #define NO_IPSET
  293 
  294 #elif defined(__NetBSD__)
  295 #define HAVE_BSD_NETWORK
  296 #define HAVE_GETOPT_LONG
  297 #define HAVE_SOCKADDR_SA_LEN
  298 
  299 #elif defined(__sun) || defined(__sun__)
  300 #define HAVE_SOLARIS_NETWORK
  301 #define HAVE_GETOPT_LONG
  302 #undef HAVE_SOCKADDR_SA_LEN
  303 #define ETHER_ADDR_LEN 6 
  304  
  305 #endif
  306 
  307 /* rules to implement compile-time option dependencies and 
  308    the NO_XXX flags */
  309 
  310 #ifdef NO_TFTP
  311 #undef HAVE_TFTP
  312 #endif
  313 
  314 #ifdef NO_DHCP
  315 #undef HAVE_DHCP
  316 #undef HAVE_DHCP6
  317 #endif
  318 
  319 #if defined(NO_DHCP6)
  320 #undef HAVE_DHCP6
  321 #endif
  322 
  323 /* DHCP6 needs DHCP too */
  324 #ifdef HAVE_DHCP6
  325 #define HAVE_DHCP
  326 #endif
  327 
  328 #if defined(NO_SCRIPT)
  329 #undef HAVE_SCRIPT
  330 #undef HAVE_LUASCRIPT
  331 #endif
  332 
  333 /* Must HAVE_SCRIPT to HAVE_LUASCRIPT */
  334 #ifdef HAVE_LUASCRIPT
  335 #define HAVE_SCRIPT
  336 #endif
  337 
  338 #ifdef NO_AUTH
  339 #undef HAVE_AUTH
  340 #endif
  341 
  342 #if defined(NO_IPSET)
  343 #undef HAVE_IPSET
  344 #endif
  345 
  346 #ifdef NO_LOOP
  347 #undef HAVE_LOOP
  348 #endif
  349 
  350 #ifdef NO_DUMPFILE
  351 #undef HAVE_DUMPFILE
  352 #endif
  353 
  354 #if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
  355 #define HAVE_INOTIFY
  356 #endif
  357 
  358 /* Define a string indicating which options are in use.
  359    DNSMASQ_COMPILE_OPTS is only defined in dnsmasq.c */
  360 
  361 #ifdef DNSMASQ_COMPILE_OPTS
  362 
  363 static char *compile_opts = 
  364 "IPv6 "
  365 #ifndef HAVE_GETOPT_LONG
  366 "no-"
  367 #endif
  368 "GNU-getopt "
  369 #ifdef HAVE_BROKEN_RTC
  370 "no-RTC "
  371 #endif
  372 #ifndef HAVE_DBUS
  373 "no-"
  374 #endif
  375 "DBus "
  376 #ifndef HAVE_UBUS
  377 "no-"
  378 #endif
  379 "UBus "
  380 #ifndef LOCALEDIR
  381 "no-"
  382 #endif
  383 "i18n "
  384 #if defined(HAVE_LIBIDN2)
  385 "IDN2 "
  386 #else
  387  #if !defined(HAVE_IDN)
  388 "no-"
  389  #endif 
  390 "IDN " 
  391 #endif
  392 #ifndef HAVE_DHCP
  393 "no-"
  394 #endif
  395 "DHCP "
  396 #if defined(HAVE_DHCP)
  397 #  if !defined (HAVE_DHCP6)
  398      "no-"
  399 #  endif  
  400      "DHCPv6 "
  401 #endif
  402 #if !defined(HAVE_SCRIPT)
  403      "no-scripts "
  404 #else
  405 #  if !defined(HAVE_LUASCRIPT)
  406      "no-"
  407 #  endif
  408      "Lua "
  409 #endif
  410 #ifndef HAVE_TFTP
  411 "no-"
  412 #endif
  413 "TFTP "
  414 #ifndef HAVE_CONNTRACK
  415 "no-"
  416 #endif
  417 "conntrack "
  418 #ifndef HAVE_IPSET
  419 "no-"
  420 #endif
  421 "ipset "
  422 #ifndef HAVE_AUTH
  423 "no-"
  424 #endif
  425 "auth "
  426 #if !defined(HAVE_CRYPTOHASH) && !defined(HAVE_DNSSEC)
  427 "no-"
  428 #endif
  429 "cryptohash "
  430 #ifndef HAVE_DNSSEC
  431 "no-"
  432 #endif
  433 "DNSSEC "
  434 #ifdef NO_ID
  435 "no-ID "
  436 #endif
  437 #ifndef HAVE_LOOP
  438 "no-"
  439 #endif
  440 "loop-detect "
  441 #ifndef HAVE_INOTIFY
  442 "no-"
  443 #endif
  444 "inotify "
  445 #ifndef HAVE_DUMPFILE
  446 "no-"
  447 #endif
  448 "dumpfile";
  449 
  450 #endif
  451 
  452 
  453