Home | History | Annotate | Line # | Download | only in dns
      1 /*	$NetBSD: adb.h,v 1.11 2026/04/08 00:16:14 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      5  *
      6  * SPDX-License-Identifier: MPL-2.0
      7  *
      8  * This Source Code Form is subject to the terms of the Mozilla Public
      9  * License, v. 2.0. If a copy of the MPL was not distributed with this
     10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
     11  *
     12  * See the COPYRIGHT file distributed with this work for additional
     13  * information regarding copyright ownership.
     14  */
     15 
     16 #pragma once
     17 
     18 /*****
     19 ***** Module Info
     20 *****/
     21 
     22 /*! \file dns/adb.h
     23  *\brief
     24  * DNS Address Database
     25  *
     26  * This module implements an address database (ADB) for mapping a name
     27  * to an isc_sockaddr_t. It also provides statistical information on
     28  * how good that address might be.
     29  *
     30  * A client will pass in a dns_name_t, and the ADB will walk through
     31  * the rdataset looking up addresses associated with the name.  If it
     32  * is found on the internal lists, a structure is filled in with the
     33  * address information and stats for found addresses.
     34  *
     35  * If the name cannot be found on the internal lists, a new entry will
     36  * be created for a name if all the information needed can be found
     37  * in the zone table or cache.  This new address will then be returned.
     38  *
     39  * If a request must be made to remote servers to satisfy a name lookup,
     40  * this module will start fetches to try to complete these addresses.  When
     41  * at least one more completes, an event is sent to the caller.  If none of
     42  * them resolve before the fetch times out, an event indicating this is
     43  * sent instead.
     44  *
     45  * Records are stored internally until a timer expires. The timer is the
     46  * smaller of the TTL or signature validity period.
     47  *
     48  * MP:
     49  *
     50  *\li	The ADB takes care of all necessary locking.
     51  *
     52  *\li	Only the task which initiated the name lookup can cancel the lookup.
     53  *
     54  *
     55  * Security:
     56  *
     57  *\li	None, since all data stored is required to be pre-filtered.
     58  *	(Cache needs to be sane, fetches return bounds-checked and sanity-
     59  *       checked data, caller passes a good dns_name_t for the zone, etc)
     60  */
     61 
     62 /***
     63  *** Imports
     64  ***/
     65 
     66 /* Add -DDNS_ADB_TRACE=1 to CFLAGS for detailed reference tracing */
     67 
     68 #include <inttypes.h>
     69 #include <stdbool.h>
     70 
     71 #include <isc/lang.h>
     72 #include <isc/magic.h>
     73 #include <isc/mem.h>
     74 #include <isc/mutex.h>
     75 #include <isc/sockaddr.h>
     76 
     77 #include <dns/types.h>
     78 #include <dns/view.h>
     79 
     80 ISC_LANG_BEGINDECLS
     81 
     82 /***
     83  *** Magic number checks
     84  ***/
     85 
     86 #define DNS_ADBFIND_MAGIC	 ISC_MAGIC('a', 'd', 'b', 'H')
     87 #define DNS_ADBFIND_VALID(x)	 ISC_MAGIC_VALID(x, DNS_ADBFIND_MAGIC)
     88 #define DNS_ADBADDRINFO_MAGIC	 ISC_MAGIC('a', 'd', 'A', 'I')
     89 #define DNS_ADBADDRINFO_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBADDRINFO_MAGIC)
     90 
     91 /***
     92  *** TYPES
     93  ***/
     94 
     95 typedef struct dns_adbname dns_adbname_t;
     96 
     97 typedef enum {
     98 	DNS_ADB_UNSET = 0,
     99 	DNS_ADB_MOREADDRESSES,
    100 	DNS_ADB_NOMOREADDRESSES,
    101 	DNS_ADB_EXPIRED,
    102 	DNS_ADB_CANCELED,
    103 	DNS_ADB_SHUTTINGDOWN
    104 } dns_adbstatus_t;
    105 
    106 /*!
    107  *\brief
    108  * Represents a lookup for a single name.
    109  *
    110  * On return, the client can safely use "list", and can reorder the list.
    111  * Items may not be _deleted_ from this list, however, or added to it
    112  * other than by using the dns_adb_*() API.
    113  */
    114 struct dns_adbfind {
    115 	/* Public */
    116 	unsigned int	      magic;	      /*%< RO: magic */
    117 	dns_adbaddrinfolist_t list;	      /*%< RO: list of addrs */
    118 	unsigned int	      query_pending;  /*%< RO: partial list */
    119 	unsigned int	      partial_result; /*%< RO: addrs missing */
    120 	unsigned int	      options;	      /*%< RO: options */
    121 	isc_result_t	      result_v4;      /*%< RO: v4 result */
    122 	isc_result_t	      result_v6;      /*%< RO: v6 result */
    123 	ISC_LINK(dns_adbfind_t) publink;      /*%< RW: client use */
    124 
    125 	/* Private */
    126 	isc_mutex_t		 lock; /* locks all below */
    127 	in_port_t		 port;
    128 	unsigned int		 flags;
    129 	dns_adbname_t		*adbname;
    130 	dns_adb_t		*adb;
    131 	isc_loop_t		*loop;
    132 	_Atomic(dns_adbstatus_t) status;
    133 	isc_job_cb		 cb;
    134 	void			*cbarg;
    135 	ISC_LINK(dns_adbfind_t) plink;
    136 };
    137 
    138 /*
    139  * _INET:
    140  * _INET6:
    141  *	return addresses of that type.
    142  *
    143  * _EMPTYEVENT:
    144  *	Only schedule an event if no addresses are known.
    145  *	Must set _WANTEVENT for this to be meaningful.
    146  *
    147  * _WANTEVENT:
    148  *	An event is desired.  Check this bit in the returned find to see
    149  *	if one will actually be generated.
    150  *
    151  * _AVOIDFETCHES:
    152  *	If set, fetches will not be generated unless no addresses are
    153  *	available in any of the address families requested.
    154  *
    155  * _STARTATZONE:
    156  *	Fetches will start using the closest zone data or use the root servers.
    157  *	This is useful for reestablishing glue that has expired.
    158  */
    159 /*% Return addresses of type INET. */
    160 #define DNS_ADBFIND_INET 0x00000001
    161 /*% Return addresses of type INET6. */
    162 #define DNS_ADBFIND_INET6	0x00000002
    163 #define DNS_ADBFIND_ADDRESSMASK 0x00000003
    164 /*%
    165  *      Only schedule an event if no addresses are known.
    166  *      Must set _WANTEVENT for this to be meaningful.
    167  */
    168 #define DNS_ADBFIND_EMPTYEVENT 0x00000004
    169 /*%
    170  *	An event is desired.  Check this bit in the returned find to see
    171  *	if one will actually be generated.
    172  */
    173 #define DNS_ADBFIND_WANTEVENT 0x00000008
    174 /*%
    175  *	If set, fetches will not be generated unless no addresses are
    176  *	available in any of the address families requested.
    177  */
    178 #define DNS_ADBFIND_AVOIDFETCHES 0x00000010
    179 /*%
    180  *	Fetches will start using the closest zone data or use the root servers.
    181  *	This is useful for reestablishing glue that has expired.
    182  */
    183 #define DNS_ADBFIND_STARTATZONE 0x00000020
    184 /*%
    185  *	Fetches will be exempted from the quota.
    186  */
    187 #define DNS_ADBFIND_QUOTAEXEMPT 0x00000040
    188 /*%
    189  *      The server's fetch quota is exceeded; it will be treated as
    190  *      lame for this query.
    191  */
    192 #define DNS_ADBFIND_OVERQUOTA 0x00000400
    193 /*%
    194  *	Don't perform a fetch even if there are no address records available.
    195  */
    196 #define DNS_ADBFIND_NOFETCH 0x00000800
    197 /*%
    198  *	Only look for glue record for static stub.
    199  */
    200 #define DNS_ADBFIND_STATICSTUB 0x00001000
    201 /*%
    202  *      This specific find created a fetch
    203  */
    204 #define DNS_ADBFIND_STARTEDFETCH 0x00010000
    205 
    206 /*%
    207  * The answers to queries come back as a list of these.
    208  */
    209 struct dns_adbaddrinfo {
    210 	unsigned int magic; /*%< private */
    211 
    212 	isc_sockaddr_t	 sockaddr; /*%< [rw] */
    213 	unsigned int	 srtt;	   /*%< [rw] microsecs */
    214 	dns_transport_t *transport;
    215 
    216 	unsigned int	flags; /*%< [rw] */
    217 	dns_adbentry_t *entry; /*%< private */
    218 	ISC_LINK(dns_adbaddrinfo_t) publink;
    219 };
    220 
    221 /*!<
    222  * When the caller recieves a callback from dns_adb_createfind(), the
    223  * argument will a pointer to the dns_adbfind_t structure, which includes
    224  * this includes a copy of the callback function and argument passed to
    225  * dns_adb_createfind(), and a dns_adbstatus_t in the 'status' field,
    226  * which indicates one of the following:
    227  *
    228  *\li	#DNS_ADB_MOREADDRESSES   -- another address resolved.
    229  *\li	#DNS_ADB_NOMOREADDRESSES -- all pending addresses failed,
    230  *				    were canceled, or otherwise will
    231  *				    not be usable.
    232  *\li	#DNS_ADB_CANCELED	 -- The request was canceled by a
    233  *				    3rd party.
    234  *\li	#DNS_ADB_EXPIRED	 -- The name was expired, so this request
    235  *				    was canceled.
    236  *
    237  * In each of these cases, the addresses returned by the initial call
    238  * to dns_adb_createfind() can still be used until they are no longer needed.
    239  */
    240 
    241 /****
    242  **** FUNCTIONS
    243  ****/
    244 
    245 void
    246 dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **newadb);
    247 /*%<
    248  * Create a new ADB.
    249  *
    250  * Notes:
    251  *
    252  *\li	Generally, applications should not create an ADB directly, but
    253  *	should instead call dns_view_createresolver().
    254  *
    255  * Requires:
    256  *
    257  *\li	'mem' must be a valid memory context.
    258  *
    259  *\li	'view' be a pointer to a valid view.
    260  *
    261  *\li	'newadb' != NULL && '*newadb' == NULL.
    262  */
    263 
    264 #if DNS_ADB_TRACE
    265 #define dns_adb_ref(ptr)   dns_adb__ref(ptr, __func__, __FILE__, __LINE__)
    266 #define dns_adb_unref(ptr) dns_adb__unref(ptr, __func__, __FILE__, __LINE__)
    267 #define dns_adb_attach(ptr, ptrp) \
    268 	dns_adb__attach(ptr, ptrp, __func__, __FILE__, __LINE__)
    269 #define dns_adb_detach(ptrp) dns_adb__detach(ptrp, __func__, __FILE__, __LINE__)
    270 ISC_REFCOUNT_TRACE_DECL(dns_adb);
    271 #else
    272 ISC_REFCOUNT_DECL(dns_adb);
    273 #endif
    274 
    275 void
    276 dns_adb_shutdown(dns_adb_t *adb);
    277 /*%<
    278  * Shutdown 'adb'.
    279  *
    280  * Requires:
    281  *
    282  * \li	'*adb' is a valid dns_adb_t.
    283  */
    284 
    285 isc_result_t
    286 dns_adb_createfind(dns_adb_t *adb, isc_loop_t *loop, isc_job_cb cb, void *cbarg,
    287 		   const dns_name_t *name, const dns_name_t *qname,
    288 		   dns_rdatatype_t qtype, unsigned int options,
    289 		   isc_stdtime_t now, dns_name_t *target, in_port_t port,
    290 		   unsigned int depth, isc_counter_t *qc, isc_counter_t *gqc,
    291 		   fetchctx_t *parent, dns_adbfind_t **find);
    292 /*%<
    293  * Main interface for clients. The adb will look up the name given in
    294  * "name" and will build up a list of found addresses, and perhaps start
    295  * internal fetches to resolve names that are unknown currently.
    296  *
    297  * If other addresses resolve after this call completes, the 'cb' callback
    298  * will be called with a pointer to the dns_adbfind_t returned by this
    299  * structure, which in turn has a pointer to the callback argument passed
    300  * in as 'cbarg'. The caller is responsible for freeing the find object.
    301  *
    302  * If no events will be generated, the *find->result_v4 and/or result_v6
    303  * members may be examined for address lookup status.  The usual #ISC_R_SUCCESS,
    304  * #ISC_R_FAILURE, #DNS_R_NXDOMAIN, and #DNS_R_NXRRSET are returned, along with
    305  * #ISC_R_NOTFOUND meaning the ADB has not _yet_ found the values.  In this
    306  * latter case, retrying may produce more addresses.
    307  *
    308  * If events will be returned, the result_v[46] members are only valid
    309  * when that event is actually returned.
    310  *
    311  * The list of addresses returned is unordered.  The caller must impose
    312  * any ordering required.  The list will not contain "known bad" addresses,
    313  * however.
    314  *
    315  * The caller cannot (directly) modify the contents of the address list's
    316  * fields other than the "link" field.  All values can be read at any
    317  * time, however.
    318  *
    319  * The "now" parameter is used only for determining which entries that
    320  * have a specific time to live or expire time should be removed from
    321  * the running database.  If specified as zero, the current time will
    322  * be retrieved and used.
    323  *
    324  * If 'target' is not NULL and 'name' is an alias (i.e. the name is
    325  * CNAME'd or DNAME'd to another name), then 'target' will be updated with
    326  * the domain name that 'name' is aliased to.
    327  *
    328  * All addresses returned will have the sockaddr's port set to 'port.'
    329  * The caller may change them directly in the dns_adbaddrinfo_t since
    330  * they are copies of the internal address only.
    331  *
    332  * Requires:
    333  *
    334  *\li	*adb be a valid isc_adb_t object.
    335  *
    336  *\li	If events are to be sent, *loop be a valid loop,
    337  *	and cb != NULL.
    338  *
    339  *\li	*name is a valid dns_name_t.
    340  *
    341  *\li	qname != NULL and *qname be a valid dns_name_t.
    342  *
    343  *\li	target == NULL or target is a valid name with a buffer.
    344  *
    345  *\li	find != NULL && *find == NULL.
    346  *
    347  * Returns:
    348  *
    349  *\li	#ISC_R_SUCCESS	Addresses might have been returned, and events will be
    350  *			delivered for unresolved addresses.
    351  *\li	#ISC_R_NOMORE	Addresses might have been returned, but no events
    352  *			will ever be posted for this context.  This is only
    353  *			returned if task != NULL.
    354  *\li	#ISC_R_NOMEMORY	insufficient resources
    355  *\li	#DNS_R_ALIAS	'name' is an alias for another name.
    356  *
    357  * Notes:
    358  *
    359  *\li	No internal reference to "name" exists after this function
    360  *	returns.
    361  */
    362 
    363 void
    364 dns_adb_cancelfind(dns_adbfind_t *find);
    365 /*%<
    366  * Cancels the find, and sends the event off to the caller.
    367  *
    368  * It is an error to call dns_adb_cancelfind() on a find where
    369  * no event is wanted, or will ever be sent.
    370  *
    371  * Note:
    372  *
    373  *\li	It is possible that the real completion event was posted just
    374  *	before the dns_adb_cancelfind() call was made.  In this case,
    375  *	dns_adb_cancelfind() will do nothing.  The event callback needs
    376  *	to be prepared to find this situation (i.e. result is valid but
    377  *	the caller expects it to be canceled).
    378  *
    379  * Requires:
    380  *
    381  *\li	'find' be a valid dns_adbfind_t pointer.
    382  *
    383  *\li	events would have been posted to the task.  This can be checked
    384  *	with (find->options & DNS_ADBFIND_WANTEVENT).
    385  *
    386  * Ensures:
    387  *
    388  *\li	The event was posted to the task.
    389  */
    390 
    391 void
    392 dns_adbfind_done(dns_adbfind_t find);
    393 /*%<
    394  * Marks a find as ready to free.
    395  *
    396  * Requires:
    397  *
    398  *\li	'find' != NULL and *find be valid dns_adbfind_t pointer.
    399  */
    400 
    401 unsigned int
    402 dns_adb_findstatus(dns_adbfind_t *);
    403 /*%<
    404  * Returns the status field of the find.
    405  *
    406  * Requires:
    407  *
    408  *\li	'find' be a valid dns_adbfind_t pointer.
    409  */
    410 
    411 void
    412 dns_adb_destroyfind(dns_adbfind_t **find);
    413 /*%<
    414  * Destroys the find reference.
    415  *
    416  * Note:
    417  *
    418  *\li	This can only be called after the event was delivered for a
    419  *	find.
    420  *
    421  * Requires:
    422  *
    423  *\li	'find' != NULL and *find be valid dns_adbfind_t pointer.
    424  *
    425  * Ensures:
    426  *
    427  *\li	No "address found" events will be posted to the originating task
    428  *	after this function returns.
    429  */
    430 
    431 void
    432 dns_adb_dump(dns_adb_t *adb, FILE *f);
    433 /*%<
    434  * Used by "rndc dumpdb": Dump the state of the running ADB.
    435  *
    436  * Requires:
    437  *
    438  *\li	adb is valid.
    439  *
    440  *\li	f != NULL, and is a file open for writing.
    441  */
    442 
    443 /*
    444  * Reasonable defaults for RTT adjustments
    445  *
    446  * (Note: these values function both as scaling factors and as
    447  * indicators of the type of RTT adjustment operation taking place.
    448  * Adjusting the scaling factors is fine, as long as they all remain
    449  * unique values.)
    450  */
    451 #define DNS_ADB_RTTADJDEFAULT 7	 /*%< default scale */
    452 #define DNS_ADB_RTTADJREPLACE 0	 /*%< replace with our rtt */
    453 #define DNS_ADB_RTTADJAGE     10 /*%< age this rtt */
    454 
    455 void
    456 dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr, unsigned int rtt,
    457 		   unsigned int factor);
    458 /*%<
    459  * Mix the round trip time into the existing smoothed rtt.
    460  *
    461  * Requires:
    462  *
    463  *\li	adb be valid.
    464  *
    465  *\li	addr be valid.
    466  *
    467  *\li	0 <= factor <= 10
    468  *
    469  * Note:
    470  *
    471  *\li	The srtt in addr will be updated to reflect the new global
    472  *	srtt value.  This may include changes made by others.
    473  */
    474 
    475 void
    476 dns_adb_agesrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr, isc_stdtime_t now);
    477 /*
    478  * dns_adb_agesrtt is equivalent to dns_adb_adjustsrtt with factor
    479  * equal to DNS_ADB_RTTADJAGE and the current time passed in.
    480  *
    481  * Requires:
    482  *
    483  *\li	adb be valid.
    484  *
    485  *\li	addr be valid.
    486  *
    487  * Note:
    488  *
    489  *\li	The srtt in addr will be updated to reflect the new global
    490  *	srtt value.  This may include changes made by others.
    491  */
    492 
    493 void
    494 dns_adb_changeflags(dns_adb_t *adb, dns_adbaddrinfo_t *addr, unsigned int bits,
    495 		    unsigned int mask);
    496 /*%
    497  * Change Flags.
    498  *
    499  * Set the flags as given by:
    500  *
    501  *\li	newflags = (oldflags & ~mask) | (bits & mask);
    502  *
    503  * Requires:
    504  *
    505  *\li	adb be valid.
    506  *
    507  *\li	addr be valid.
    508  */
    509 
    510 void
    511 dns_adb_setudpsize(dns_adb_t *adb, dns_adbaddrinfo_t *addr, unsigned int size);
    512 /*%
    513  * Update seen UDP response size.  The largest seen will be returned by
    514  * dns_adb_getudpsize().
    515  *
    516  * Requires:
    517  *
    518  *\li	adb be valid.
    519  *
    520  *\li	addr be valid.
    521  */
    522 
    523 unsigned int
    524 dns_adb_getudpsize(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
    525 /*%
    526  * Return the largest seen UDP response size.
    527  *
    528  * Requires:
    529  *
    530  *\li	adb be valid.
    531  *
    532  *\li	addr be valid.
    533  */
    534 
    535 void
    536 dns_adb_plainresponse(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
    537 /*%
    538  * Record a successful plain DNS response.
    539  *
    540  * Requires:
    541  *
    542  *\li	adb be valid.
    543  *
    544  *\li	addr be valid.
    545  */
    546 
    547 void
    548 dns_adb_timeout(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
    549 /*%
    550  * Record a plain DNS UDP query failed.
    551  *
    552  * Requires:
    553  *
    554  *\li	adb be valid.
    555  *
    556  *\li	addr be valid.
    557  */
    558 
    559 void
    560 dns_adb_ednsto(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
    561 /*%
    562  * Record a EDNS UDP query failed.
    563  *
    564  * Requires:
    565  *
    566  *\li	adb be valid.
    567  *
    568  *\li	addr be valid.
    569  */
    570 
    571 isc_result_t
    572 dns_adb_findaddrinfo(dns_adb_t *adb, const isc_sockaddr_t *sa,
    573 		     dns_adbaddrinfo_t **addrp, isc_stdtime_t now);
    574 /*%<
    575  * Return a dns_adbaddrinfo_t that is associated with address 'sa'.
    576  *
    577  * Requires:
    578  *
    579  *\li	adb is valid.
    580  *
    581  *\li	sa is valid.
    582  *
    583  *\li	addrp != NULL && *addrp == NULL
    584  *
    585  * Returns:
    586  *\li	#ISC_R_SUCCESS
    587  *\li	#ISC_R_NOMEMORY
    588  *\li	#ISC_R_SHUTTINGDOWN
    589  */
    590 
    591 void
    592 dns_adb_freeaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **addrp);
    593 /*%<
    594  * Free a dns_adbaddrinfo_t allocated by dns_adb_findaddrinfo().
    595  *
    596  * Requires:
    597  *
    598  *\li	adb is valid.
    599  *
    600  *\li	*addrp is a valid dns_adbaddrinfo_t *.
    601  */
    602 
    603 void
    604 dns_adb_flush(dns_adb_t *adb);
    605 /*%<
    606  * Flushes all cached data from the adb.
    607  *
    608  * Requires:
    609  *\li 	adb is valid.
    610  */
    611 
    612 void
    613 dns_adb_setadbsize(dns_adb_t *adb, size_t size);
    614 /*%<
    615  * Set a target memory size.  If memory usage exceeds the target
    616  * size entries will be removed before they would have expired on
    617  * a random basis.
    618  *
    619  * If 'size' is 0 then memory usage is unlimited.
    620  *
    621  * Requires:
    622  *\li	'adb' is valid.
    623  */
    624 
    625 void
    626 dns_adb_flushname(dns_adb_t *adb, const dns_name_t *name);
    627 /*%<
    628  * Flush 'name' from the adb cache.
    629  *
    630  * Requires:
    631  *\li	'adb' is valid.
    632  *\li	'name' is valid.
    633  */
    634 
    635 void
    636 dns_adb_flushnames(dns_adb_t *adb, const dns_name_t *name);
    637 /*%<
    638  * Flush 'name' and all subdomains from the adb cache.
    639  *
    640  * Requires:
    641  *\li	'adb' is valid.
    642  *\li	'name' is valid.
    643  */
    644 
    645 void
    646 dns_adb_setcookie(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
    647 		  const unsigned char *cookie, size_t len);
    648 /*%<
    649  * Record the COOKIE associated with this address.  If
    650  * cookie is NULL or len is zero the recorded COOKIE is cleared.
    651  *
    652  * Requires:
    653  *\li	'adb' is valid.
    654  *\li	'addr' is valid.
    655  */
    656 
    657 size_t
    658 dns_adb_getcookie(dns_adbaddrinfo_t *addr, unsigned char *cookie, size_t len);
    659 /*
    660  * If 'cookie' is not NULL, then retrieve the saved COOKIE value and store it
    661  * in 'cookie' which has size 'len'.
    662  *
    663  * Requires:
    664  *\li	'addr' is valid.
    665  *
    666  * Returns:
    667  *	The size of the cookie or zero if it doesn't exist, or when 'cookie' is
    668  *      not NULL and it doesn't fit in the buffer.
    669  */
    670 
    671 void
    672 dns_adb_setquota(dns_adb_t *adb, uint32_t quota, uint32_t freq, double low,
    673 		 double high, double discount);
    674 /*%<
    675  * Set the baseline ADB quota, and configure parameters for the
    676  * quota adjustment algorithm.
    677  *
    678  * If the number of fetches currently waiting for responses from this
    679  * address exceeds the current quota, then additional fetches are spilled.
    680  *
    681  * 'quota' is the highest permissible quota; it will adjust itself
    682  * downward in response to detected congestion.
    683  *
    684  * After every 'freq' fetches have either completed or timed out, an
    685  * exponentially weighted moving average of the ratio of timeouts
    686  * to responses is calculated.  If the EWMA goes above a 'high'
    687  * threshold, then the quota is adjusted down one step; if it drops
    688  * below a 'low' threshold, then the quota is adjusted back up one
    689  * step.
    690  *
    691  * The quota adjustment is based on the function (1 / 1 + (n/10)^(3/2)),
    692  * for values of n from 0 to 99.  It starts at 100% of the baseline
    693  * quota, and descends after 100 steps to 2%.
    694  *
    695  * 'discount' represents the discount rate of the moving average. Higher
    696  * values cause older values to be discounted sooner, providing a faster
    697  * response to changes in the timeout ratio.
    698  *
    699  * Requires:
    700  *\li	'adb' is valid.
    701  */
    702 
    703 void
    704 dns_adb_getquota(dns_adb_t *adb, uint32_t *quotap, uint32_t *freqp,
    705 		 double *lowp, double *highp, double *discountp);
    706 /*%<
    707  * Get the quota values set by dns_adb_setquota().
    708  * If any of the 'quotap', 'freqp', 'lowp', 'highp', and
    709  * 'discountp' parameters are non-NULL, then the memory they
    710  * point to will be updated to hold the corresponding quota
    711  * or parameter value.
    712  *
    713  * Requires:
    714  *\li	'adb' is valid.
    715  */
    716 
    717 bool
    718 dns_adb_overquota(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
    719 /*%<
    720  * Returns true if the specified ADB has too many active fetches.
    721  *
    722  * Requires:
    723  *\li	'entry' is valid.
    724  */
    725 
    726 void
    727 dns_adb_beginudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
    728 void
    729 dns_adb_endudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
    730 /*%
    731  * Begin/end a UDP fetch on a particular address.
    732  *
    733  * These functions increment or decrement the fetch counter for
    734  * the ADB entry so that the fetch quota can be enforced.
    735  *
    736  * Requires:
    737  *
    738  *\li	adb be valid.
    739  *
    740  *\li	addr be valid.
    741  */
    742 
    743 isc_stats_t *
    744 dns_adb_getstats(dns_adb_t *adb);
    745 /*%<
    746  * Get the adb statistics counter set for 'adb'.
    747  *
    748  * Requires:
    749  * \li 'adb' is valid.
    750  */
    751 
    752 isc_result_t
    753 dns_adb_dumpquota(dns_adb_t *adb, isc_buffer_t **buf);
    754 /*%
    755  * Dump the addresses, current quota values, and current ATR values
    756  * for all servers that are currently being fetchlimited. Servers
    757  * for which the quota is still equal to the default and the ATR
    758  * is zero are not printed.
    759  *
    760  * Requires:
    761  * \li 'adb' is valid.
    762  */
    763 ISC_LANG_ENDDECLS
    764