1135446Strhodes/*
2234010Sdougb * Copyright (C) 2004-2012  Internet Systems Consortium, Inc. ("ISC")
3135446Strhodes * Copyright (C) 1999-2001, 2003  Internet Software Consortium.
4135446Strhodes *
5193149Sdougb * Permission to use, copy, modify, and/or distribute this software for any
6135446Strhodes * purpose with or without fee is hereby granted, provided that the above
7135446Strhodes * copyright notice and this permission notice appear in all copies.
8135446Strhodes *
9135446Strhodes * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10135446Strhodes * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11135446Strhodes * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12135446Strhodes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13135446Strhodes * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14135446Strhodes * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15135446Strhodes * PERFORMANCE OF THIS SOFTWARE.
16135446Strhodes */
17135446Strhodes
18254897Serwin/* $Id: resolver.h,v 1.72 2011/12/05 17:10:51 each Exp $ */
19135446Strhodes
20135446Strhodes#ifndef DNS_RESOLVER_H
21135446Strhodes#define DNS_RESOLVER_H 1
22135446Strhodes
23135446Strhodes/*****
24135446Strhodes ***** Module Info
25135446Strhodes *****/
26135446Strhodes
27193149Sdougb/*! \file dns/resolver.h
28135446Strhodes *
29170222Sdougb * \brief
30135446Strhodes * This is the BIND 9 resolver, the module responsible for resolving DNS
31135446Strhodes * requests by iteratively querying authoritative servers and following
32135446Strhodes * referrals.  This is a "full resolver", not to be confused with
33135446Strhodes * the stub resolvers most people associate with the word "resolver".
34135446Strhodes * The full resolver is part of the caching name server or resolver
35135446Strhodes * daemon the stub resolver talks to.
36135446Strhodes *
37135446Strhodes * MP:
38170222Sdougb *\li	The module ensures appropriate synchronization of data structures it
39135446Strhodes *	creates and manipulates.
40135446Strhodes *
41135446Strhodes * Reliability:
42170222Sdougb *\li	No anticipated impact.
43135446Strhodes *
44135446Strhodes * Resources:
45170222Sdougb *\li	TBS
46135446Strhodes *
47135446Strhodes * Security:
48170222Sdougb *\li	No anticipated impact.
49135446Strhodes *
50135446Strhodes * Standards:
51170222Sdougb *\li	RFCs:	1034, 1035, 2181, TBS
52170222Sdougb *\li	Drafts:	TBS
53135446Strhodes */
54135446Strhodes
55135446Strhodes#include <isc/lang.h>
56135446Strhodes#include <isc/socket.h>
57135446Strhodes
58135446Strhodes#include <dns/types.h>
59135446Strhodes#include <dns/fixedname.h>
60135446Strhodes
61135446StrhodesISC_LANG_BEGINDECLS
62135446Strhodes
63170222Sdougb/*%
64135446Strhodes * A dns_fetchevent_t is sent when a 'fetch' completes.  Any of 'db',
65135446Strhodes * 'node', 'rdataset', and 'sigrdataset' may be bound.  It is the
66135446Strhodes * receiver's responsibility to detach before freeing the event.
67170222Sdougb * \brief
68170222Sdougb * 'rdataset', 'sigrdataset', 'client' and 'id' are the values that were
69170222Sdougb * supplied when dns_resolver_createfetch() was called.  They are returned
70170222Sdougb *  to the caller so that they may be freed.
71135446Strhodes */
72135446Strhodestypedef struct dns_fetchevent {
73135446Strhodes	ISC_EVENT_COMMON(struct dns_fetchevent);
74135446Strhodes	dns_fetch_t *			fetch;
75135446Strhodes	isc_result_t			result;
76135446Strhodes	dns_rdatatype_t			qtype;
77135446Strhodes	dns_db_t *			db;
78135446Strhodes	dns_dbnode_t *			node;
79135446Strhodes	dns_rdataset_t *		rdataset;
80135446Strhodes	dns_rdataset_t *		sigrdataset;
81135446Strhodes	dns_fixedname_t			foundname;
82170222Sdougb	isc_sockaddr_t *		client;
83170222Sdougb	dns_messageid_t			id;
84224092Sdougb	isc_result_t			vresult;
85275672Sdelphij	isc_uint32_t 			qtotal;
86135446Strhodes} dns_fetchevent_t;
87135446Strhodes
88135446Strhodes/*
89135446Strhodes * Options that modify how a 'fetch' is done.
90135446Strhodes */
91170222Sdougb#define DNS_FETCHOPT_TCP		0x01	     /*%< Use TCP. */
92170222Sdougb#define DNS_FETCHOPT_UNSHARED		0x02	     /*%< See below. */
93170222Sdougb#define DNS_FETCHOPT_RECURSIVE		0x04	     /*%< Set RD? */
94170222Sdougb#define DNS_FETCHOPT_NOEDNS0		0x08	     /*%< Do not use EDNS. */
95170222Sdougb#define DNS_FETCHOPT_FORWARDONLY	0x10	     /*%< Only use forwarders. */
96170222Sdougb#define DNS_FETCHOPT_NOVALIDATE		0x20	     /*%< Disable validation. */
97170222Sdougb#define DNS_FETCHOPT_EDNS512		0x40	     /*%< Advertise a 512 byte
98193149Sdougb							  UDP buffer. */
99193149Sdougb#define DNS_FETCHOPT_WANTNSID           0x80         /*%< Request NSID */
100135446Strhodes
101170222Sdougb#define	DNS_FETCHOPT_EDNSVERSIONSET	0x00800000
102170222Sdougb#define	DNS_FETCHOPT_EDNSVERSIONMASK	0xff000000
103170222Sdougb#define	DNS_FETCHOPT_EDNSVERSIONSHIFT	24
104170222Sdougb
105135446Strhodes/*
106193149Sdougb * Upper bounds of class of query RTT (ms).  Corresponds to
107193149Sdougb * dns_resstatscounter_queryrttX statistics counters.
108193149Sdougb */
109193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS0	10
110193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS0STR	"10"
111193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS1	100
112193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS1STR	"100"
113193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS2	500
114193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS2STR	"500"
115193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS3	800
116193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS3STR	"800"
117193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS4	1600
118193149Sdougb#define DNS_RESOLVER_QRYRTTCLASS4STR	"1600"
119193149Sdougb
120193149Sdougb/*
121135446Strhodes * XXXRTH  Should this API be made semi-private?  (I.e.
122135446Strhodes * _dns_resolver_create()).
123135446Strhodes */
124135446Strhodes
125135446Strhodes#define DNS_RESOLVER_CHECKNAMES		0x01
126135446Strhodes#define DNS_RESOLVER_CHECKNAMESFAIL	0x02
127135446Strhodes
128135446Strhodesisc_result_t
129135446Strhodesdns_resolver_create(dns_view_t *view,
130254897Serwin		    isc_taskmgr_t *taskmgr,
131254897Serwin		    unsigned int ntasks, unsigned int ndisp,
132135446Strhodes		    isc_socketmgr_t *socketmgr,
133135446Strhodes		    isc_timermgr_t *timermgr,
134135446Strhodes		    unsigned int options,
135135446Strhodes		    dns_dispatchmgr_t *dispatchmgr,
136135446Strhodes		    dns_dispatch_t *dispatchv4,
137135446Strhodes		    dns_dispatch_t *dispatchv6,
138135446Strhodes		    dns_resolver_t **resp);
139135446Strhodes
140170222Sdougb/*%<
141135446Strhodes * Create a resolver.
142135446Strhodes *
143135446Strhodes * Notes:
144135446Strhodes *
145170222Sdougb *\li	Generally, applications should not create a resolver directly, but
146135446Strhodes *	should instead call dns_view_createresolver().
147135446Strhodes *
148135446Strhodes * Requires:
149135446Strhodes *
150170222Sdougb *\li	'view' is a valid view.
151135446Strhodes *
152170222Sdougb *\li	'taskmgr' is a valid task manager.
153135446Strhodes *
154170222Sdougb *\li	'ntasks' > 0.
155135446Strhodes *
156170222Sdougb *\li	'socketmgr' is a valid socket manager.
157135446Strhodes *
158170222Sdougb *\li	'timermgr' is a valid timer manager.
159135446Strhodes *
160254897Serwin *\li	'dispatchv4' is a dispatch with an IPv4 UDP socket, or is NULL.
161254897Serwin *	If not NULL, 'ndisp' clones of it will be created by the resolver.
162135446Strhodes *
163254897Serwin *\li	'dispatchv6' is a dispatch with an IPv6 UDP socket, or is NULL.
164254897Serwin *	If not NULL, 'ndisp' clones of it will be created by the resolver.
165135446Strhodes *
166170222Sdougb *\li	resp != NULL && *resp == NULL.
167135446Strhodes *
168135446Strhodes * Returns:
169135446Strhodes *
170170222Sdougb *\li	#ISC_R_SUCCESS				On success.
171135446Strhodes *
172170222Sdougb *\li	Anything else				Failure.
173135446Strhodes */
174135446Strhodes
175135446Strhodesvoid
176135446Strhodesdns_resolver_freeze(dns_resolver_t *res);
177170222Sdougb/*%<
178135446Strhodes * Freeze resolver.
179135446Strhodes *
180135446Strhodes * Notes:
181135446Strhodes *
182170222Sdougb *\li	Certain configuration changes cannot be made after the resolver
183135446Strhodes *	is frozen.  Fetches cannot be created until the resolver is frozen.
184135446Strhodes *
185135446Strhodes * Requires:
186135446Strhodes *
187224092Sdougb *\li	'res' is a valid resolver.
188135446Strhodes *
189135446Strhodes * Ensures:
190135446Strhodes *
191170222Sdougb *\li	'res' is frozen.
192135446Strhodes */
193135446Strhodes
194135446Strhodesvoid
195135446Strhodesdns_resolver_prime(dns_resolver_t *res);
196170222Sdougb/*%<
197135446Strhodes * Prime resolver.
198135446Strhodes *
199135446Strhodes * Notes:
200135446Strhodes *
201170222Sdougb *\li	Resolvers which have a forwarding policy other than dns_fwdpolicy_only
202135446Strhodes *	need to be primed with the root nameservers, otherwise the root
203135446Strhodes *	nameserver hints data may be used indefinitely.  This function requests
204135446Strhodes *	that the resolver start a priming fetch, if it isn't already priming.
205135446Strhodes *
206135446Strhodes * Requires:
207135446Strhodes *
208170222Sdougb *\li	'res' is a valid, frozen resolver.
209135446Strhodes */
210135446Strhodes
211135446Strhodes
212135446Strhodesvoid
213135446Strhodesdns_resolver_whenshutdown(dns_resolver_t *res, isc_task_t *task,
214135446Strhodes			  isc_event_t **eventp);
215170222Sdougb/*%<
216135446Strhodes * Send '*eventp' to 'task' when 'res' has completed shutdown.
217135446Strhodes *
218135446Strhodes * Notes:
219135446Strhodes *
220170222Sdougb *\li	It is not safe to detach the last reference to 'res' until
221135446Strhodes *	shutdown is complete.
222135446Strhodes *
223135446Strhodes * Requires:
224135446Strhodes *
225170222Sdougb *\li	'res' is a valid resolver.
226135446Strhodes *
227170222Sdougb *\li	'task' is a valid task.
228135446Strhodes *
229170222Sdougb *\li	*eventp is a valid event.
230135446Strhodes *
231135446Strhodes * Ensures:
232135446Strhodes *
233170222Sdougb *\li	*eventp == NULL.
234135446Strhodes */
235135446Strhodes
236135446Strhodesvoid
237135446Strhodesdns_resolver_shutdown(dns_resolver_t *res);
238170222Sdougb/*%<
239135446Strhodes * Start the shutdown process for 'res'.
240135446Strhodes *
241135446Strhodes * Notes:
242135446Strhodes *
243170222Sdougb *\li	This call has no effect if the resolver is already shutting down.
244135446Strhodes *
245135446Strhodes * Requires:
246135446Strhodes *
247170222Sdougb *\li	'res' is a valid resolver.
248135446Strhodes */
249135446Strhodes
250135446Strhodesvoid
251135446Strhodesdns_resolver_attach(dns_resolver_t *source, dns_resolver_t **targetp);
252135446Strhodes
253135446Strhodesvoid
254135446Strhodesdns_resolver_detach(dns_resolver_t **resp);
255135446Strhodes
256135446Strhodesisc_result_t
257135446Strhodesdns_resolver_createfetch(dns_resolver_t *res, dns_name_t *name,
258135446Strhodes			 dns_rdatatype_t type,
259135446Strhodes			 dns_name_t *domain, dns_rdataset_t *nameservers,
260135446Strhodes			 dns_forwarders_t *forwarders,
261135446Strhodes			 unsigned int options, isc_task_t *task,
262135446Strhodes			 isc_taskaction_t action, void *arg,
263135446Strhodes			 dns_rdataset_t *rdataset,
264135446Strhodes			 dns_rdataset_t *sigrdataset,
265135446Strhodes			 dns_fetch_t **fetchp);
266170222Sdougb
267170222Sdougbisc_result_t
268170222Sdougbdns_resolver_createfetch2(dns_resolver_t *res, dns_name_t *name,
269170222Sdougb			  dns_rdatatype_t type,
270170222Sdougb			  dns_name_t *domain, dns_rdataset_t *nameservers,
271170222Sdougb			  dns_forwarders_t *forwarders,
272170222Sdougb			  isc_sockaddr_t *client, isc_uint16_t id,
273170222Sdougb			  unsigned int options, isc_task_t *task,
274170222Sdougb			  isc_taskaction_t action, void *arg,
275170222Sdougb			  dns_rdataset_t *rdataset,
276170222Sdougb			  dns_rdataset_t *sigrdataset,
277170222Sdougb			  dns_fetch_t **fetchp);
278275672Sdelphijisc_result_t
279275672Sdelphijdns_resolver_createfetch3(dns_resolver_t *res, dns_name_t *name,
280275672Sdelphij			  dns_rdatatype_t type,
281275672Sdelphij			  dns_name_t *domain, dns_rdataset_t *nameservers,
282275672Sdelphij			  dns_forwarders_t *forwarders,
283275672Sdelphij			  isc_sockaddr_t *client, isc_uint16_t id,
284275672Sdelphij			  unsigned int options, unsigned int depth,
285275672Sdelphij			  isc_task_t *task,
286275672Sdelphij			  isc_taskaction_t action, void *arg,
287275672Sdelphij			  dns_rdataset_t *rdataset,
288275672Sdelphij			  dns_rdataset_t *sigrdataset,
289275672Sdelphij			  dns_fetch_t **fetchp);
290170222Sdougb/*%<
291135446Strhodes * Recurse to answer a question.
292135446Strhodes *
293135446Strhodes * Notes:
294135446Strhodes *
295170222Sdougb *\li	This call starts a query for 'name', type 'type'.
296135446Strhodes *
297170222Sdougb *\li	The 'domain' is a parent domain of 'name' for which
298135446Strhodes *	a set of name servers 'nameservers' is known.  If no
299135446Strhodes *	such name server information is available, set
300135446Strhodes * 	'domain' and 'nameservers' to NULL.
301135446Strhodes *
302170222Sdougb *\li	'forwarders' is unimplemented, and subject to change when
303135446Strhodes *	we figure out how selective forwarding will work.
304135446Strhodes *
305170222Sdougb *\li	When the fetch completes (successfully or otherwise), a
306170222Sdougb *	#DNS_EVENT_FETCHDONE event with action 'action' and arg 'arg' will be
307135446Strhodes *	posted to 'task'.
308135446Strhodes *
309170222Sdougb *\li	The values of 'rdataset' and 'sigrdataset' will be returned in
310135446Strhodes *	the FETCHDONE event.
311135446Strhodes *
312170222Sdougb *\li	'client' and 'id' are used for duplicate query detection.  '*client'
313170222Sdougb *	must remain stable until after 'action' has been called or
314170222Sdougb *	dns_resolver_cancelfetch() is called.
315170222Sdougb *
316135446Strhodes * Requires:
317135446Strhodes *
318170222Sdougb *\li	'res' is a valid resolver that has been frozen.
319135446Strhodes *
320170222Sdougb *\li	'name' is a valid name.
321135446Strhodes *
322170222Sdougb *\li	'type' is not a meta type other than ANY.
323135446Strhodes *
324170222Sdougb *\li	'domain' is a valid name or NULL.
325135446Strhodes *
326170222Sdougb *\li	'nameservers' is a valid NS rdataset (whose owner name is 'domain')
327135446Strhodes *	iff. 'domain' is not NULL.
328135446Strhodes *
329170222Sdougb *\li	'forwarders' is NULL.
330135446Strhodes *
331170222Sdougb *\li	'client' is a valid sockaddr or NULL.
332135446Strhodes *
333170222Sdougb *\li	'options' contains valid options.
334135446Strhodes *
335170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
336135446Strhodes *
337170222Sdougb *\li	'sigrdataset' is NULL, or is a valid, disassociated rdataset.
338135446Strhodes *
339170222Sdougb *\li	fetchp != NULL && *fetchp == NULL.
340170222Sdougb *
341135446Strhodes * Returns:
342135446Strhodes *
343170222Sdougb *\li	#ISC_R_SUCCESS					Success
344170222Sdougb *\li	#DNS_R_DUPLICATE
345170222Sdougb *\li	#DNS_R_DROP
346135446Strhodes *
347170222Sdougb *\li	Many other values are possible, all of which indicate failure.
348135446Strhodes */
349135446Strhodes
350135446Strhodesvoid
351135446Strhodesdns_resolver_cancelfetch(dns_fetch_t *fetch);
352170222Sdougb/*%<
353135446Strhodes * Cancel 'fetch'.
354135446Strhodes *
355135446Strhodes * Notes:
356135446Strhodes *
357170222Sdougb *\li	If 'fetch' has not completed, post its FETCHDONE event with a
358170222Sdougb *	result code of #ISC_R_CANCELED.
359135446Strhodes *
360135446Strhodes * Requires:
361135446Strhodes *
362170222Sdougb *\li	'fetch' is a valid fetch.
363135446Strhodes */
364135446Strhodes
365135446Strhodesvoid
366135446Strhodesdns_resolver_destroyfetch(dns_fetch_t **fetchp);
367170222Sdougb/*%<
368135446Strhodes * Destroy 'fetch'.
369135446Strhodes *
370135446Strhodes * Requires:
371135446Strhodes *
372170222Sdougb *\li	'*fetchp' is a valid fetch.
373135446Strhodes *
374170222Sdougb *\li	The caller has received the FETCHDONE event (either because the
375135446Strhodes *	fetch completed or because dns_resolver_cancelfetch() was called).
376135446Strhodes *
377135446Strhodes * Ensures:
378135446Strhodes *
379170222Sdougb *\li	*fetchp == NULL.
380135446Strhodes */
381135446Strhodes
382193149Sdougbvoid
383193149Sdougbdns_resolver_logfetch(dns_fetch_t *fetch, isc_log_t *lctx,
384193149Sdougb		      isc_logcategory_t *category, isc_logmodule_t *module,
385193149Sdougb		      int level, isc_boolean_t duplicateok);
386193149Sdougb/*%<
387193149Sdougb * Dump a log message on internal state at the completion of given 'fetch'.
388193149Sdougb * 'lctx', 'category', 'module', and 'level' are used to write the log message.
389193149Sdougb * By default, only one log message is written even if the corresponding fetch
390193149Sdougb * context serves multiple clients; if 'duplicateok' is true the suppression
391193149Sdougb * is disabled and the message can be written every time this function is
392193149Sdougb * called.
393193149Sdougb *
394193149Sdougb * Requires:
395193149Sdougb *
396193149Sdougb *\li	'fetch' is a valid fetch, and has completed.
397193149Sdougb */
398193149Sdougb
399135446Strhodesdns_dispatchmgr_t *
400135446Strhodesdns_resolver_dispatchmgr(dns_resolver_t *resolver);
401135446Strhodes
402135446Strhodesdns_dispatch_t *
403135446Strhodesdns_resolver_dispatchv4(dns_resolver_t *resolver);
404135446Strhodes
405135446Strhodesdns_dispatch_t *
406135446Strhodesdns_resolver_dispatchv6(dns_resolver_t *resolver);
407135446Strhodes
408135446Strhodesisc_socketmgr_t *
409135446Strhodesdns_resolver_socketmgr(dns_resolver_t *resolver);
410135446Strhodes
411135446Strhodesisc_taskmgr_t *
412135446Strhodesdns_resolver_taskmgr(dns_resolver_t *resolver);
413135446Strhodes
414135446Strhodesisc_uint32_t
415135446Strhodesdns_resolver_getlamettl(dns_resolver_t *resolver);
416170222Sdougb/*%<
417135446Strhodes * Get the resolver's lame-ttl.  zero => no lame processing.
418135446Strhodes *
419135446Strhodes * Requires:
420170222Sdougb *\li	'resolver' to be valid.
421135446Strhodes */
422135446Strhodes
423135446Strhodesvoid
424135446Strhodesdns_resolver_setlamettl(dns_resolver_t *resolver, isc_uint32_t lame_ttl);
425170222Sdougb/*%<
426135446Strhodes * Set the resolver's lame-ttl.  zero => no lame processing.
427135446Strhodes *
428135446Strhodes * Requires:
429170222Sdougb *\li	'resolver' to be valid.
430135446Strhodes */
431135446Strhodes
432135446Strhodesunsigned int
433135446Strhodesdns_resolver_nrunning(dns_resolver_t *resolver);
434170222Sdougb/*%<
435135446Strhodes * Return the number of currently running resolutions in this
436135446Strhodes * resolver.  This is may be less than the number of outstanding
437135446Strhodes * fetches due to multiple identical fetches, or more than the
438135446Strhodes * number of of outstanding fetches due to the fact that resolution
439135446Strhodes * can continue even though a fetch has been canceled.
440135446Strhodes */
441135446Strhodes
442135446Strhodesisc_result_t
443135446Strhodesdns_resolver_addalternate(dns_resolver_t *resolver, isc_sockaddr_t *alt,
444135446Strhodes			  dns_name_t *name, in_port_t port);
445170222Sdougb/*%<
446135446Strhodes * Add alternate addresses to be tried in the event that the nameservers
447135446Strhodes * for a zone are not available in the address families supported by the
448135446Strhodes * operating system.
449135446Strhodes *
450135446Strhodes * Require:
451170222Sdougb * \li	only one of 'name' or 'alt' to be valid.
452135446Strhodes */
453135446Strhodes
454135446Strhodesvoid
455135446Strhodesdns_resolver_setudpsize(dns_resolver_t *resolver, isc_uint16_t udpsize);
456170222Sdougb/*%<
457135446Strhodes * Set the EDNS UDP buffer size advertised by the server.
458135446Strhodes */
459135446Strhodes
460135446Strhodesisc_uint16_t
461135446Strhodesdns_resolver_getudpsize(dns_resolver_t *resolver);
462170222Sdougb/*%<
463135446Strhodes * Get the current EDNS UDP buffer size.
464135446Strhodes */
465135446Strhodes
466135446Strhodesvoid
467135446Strhodesdns_resolver_reset_algorithms(dns_resolver_t *resolver);
468170222Sdougb/*%<
469135446Strhodes * Clear the disabled DNSSEC algorithms.
470135446Strhodes */
471135446Strhodes
472135446Strhodesisc_result_t
473135446Strhodesdns_resolver_disable_algorithm(dns_resolver_t *resolver, dns_name_t *name,
474135446Strhodes			       unsigned int alg);
475170222Sdougb/*%<
476135446Strhodes * Mark the give DNSSEC algorithm as disabled and below 'name'.
477135446Strhodes * Valid algorithms are less than 256.
478135446Strhodes *
479135446Strhodes * Returns:
480170222Sdougb *\li	#ISC_R_SUCCESS
481170222Sdougb *\li	#ISC_R_RANGE
482170222Sdougb *\li	#ISC_R_NOMEMORY
483135446Strhodes */
484135446Strhodes
485135446Strhodesisc_boolean_t
486135446Strhodesdns_resolver_algorithm_supported(dns_resolver_t *resolver, dns_name_t *name,
487135446Strhodes				 unsigned int alg);
488170222Sdougb/*%<
489135446Strhodes * Check if the given algorithm is supported by this resolver.
490135446Strhodes * This checks if the algorithm has been disabled via
491135446Strhodes * dns_resolver_disable_algorithm() then the underlying
492135446Strhodes * crypto libraries if not specifically disabled.
493135446Strhodes */
494135446Strhodes
495170222Sdougbisc_boolean_t
496170222Sdougbdns_resolver_digest_supported(dns_resolver_t *resolver, unsigned int digest_type);
497170222Sdougb/*%<
498170222Sdougb * Is this digest type supported.
499170222Sdougb */
500170222Sdougb
501135446Strhodesvoid
502135446Strhodesdns_resolver_resetmustbesecure(dns_resolver_t *resolver);
503135446Strhodes
504135446Strhodesisc_result_t
505135446Strhodesdns_resolver_setmustbesecure(dns_resolver_t *resolver, dns_name_t *name,
506135446Strhodes			     isc_boolean_t value);
507135446Strhodes
508135446Strhodesisc_boolean_t
509135446Strhodesdns_resolver_getmustbesecure(dns_resolver_t *resolver, dns_name_t *name);
510135446Strhodes
511224092Sdougb
512170222Sdougbvoid
513224092Sdougbdns_resolver_settimeout(dns_resolver_t *resolver, unsigned int seconds);
514224092Sdougb/*%<
515224092Sdougb * Set the length of time the resolver will work on a query, in seconds.
516224092Sdougb *
517224092Sdougb * If timeout is 0, the default timeout will be applied.
518224092Sdougb *
519224092Sdougb * Requires:
520224092Sdougb * \li  resolver to be valid.
521224092Sdougb */
522224092Sdougb
523224092Sdougbunsigned int
524224092Sdougbdns_resolver_gettimeout(dns_resolver_t *resolver);
525224092Sdougb/*%<
526224092Sdougb * Get the current length of time the resolver will work on a query, in seconds.
527224092Sdougb *
528224092Sdougb * Requires:
529224092Sdougb * \li  resolver to be valid.
530224092Sdougb */
531224092Sdougb
532224092Sdougbvoid
533170222Sdougbdns_resolver_setclientsperquery(dns_resolver_t *resolver,
534170222Sdougb				isc_uint32_t min, isc_uint32_t max);
535170222Sdougb
536170222Sdougbvoid
537170222Sdougbdns_resolver_getclientsperquery(dns_resolver_t *resolver, isc_uint32_t *cur,
538170222Sdougb				isc_uint32_t *min, isc_uint32_t *max);
539170222Sdougb
540170222Sdougbisc_boolean_t
541170222Sdougbdns_resolver_getzeronosoattl(dns_resolver_t *resolver);
542193149Sdougb
543170222Sdougbvoid
544170222Sdougbdns_resolver_setzeronosoattl(dns_resolver_t *resolver, isc_boolean_t state);
545170222Sdougb
546193149Sdougbunsigned int
547193149Sdougbdns_resolver_getoptions(dns_resolver_t *resolver);
548193149Sdougb
549205292Sdougbvoid
550205292Sdougbdns_resolver_addbadcache(dns_resolver_t *resolver, dns_name_t *name,
551205292Sdougb			 dns_rdatatype_t type, isc_time_t *expire);
552205292Sdougb/*%<
553205292Sdougb * Add a entry to the bad cache for <name,type> that will expire at 'expire'.
554205292Sdougb *
555205292Sdougb * Requires:
556205292Sdougb * \li	resolver to be valid.
557205292Sdougb * \li	name to be valid.
558205292Sdougb */
559205292Sdougb
560205292Sdougbisc_boolean_t
561205292Sdougbdns_resolver_getbadcache(dns_resolver_t *resolver, dns_name_t *name,
562205292Sdougb			 dns_rdatatype_t type, isc_time_t *now);
563205292Sdougb/*%<
564205292Sdougb * Check to see if there is a unexpired entry in the bad cache for
565205292Sdougb * <name,type>.
566205292Sdougb *
567205292Sdougb * Requires:
568205292Sdougb * \li	resolver to be valid.
569205292Sdougb * \li	name to be valid.
570205292Sdougb */
571205292Sdougb
572205292Sdougbvoid
573205292Sdougbdns_resolver_flushbadcache(dns_resolver_t *resolver, dns_name_t *name);
574205292Sdougb/*%<
575205292Sdougb * Flush the bad cache of all entries at 'name' if 'name' is non NULL.
576205292Sdougb * Flush the entire bad cache if 'name' is NULL.
577205292Sdougb *
578205292Sdougb * Requires:
579205292Sdougb * \li	resolver to be valid.
580205292Sdougb */
581205292Sdougb
582205292Sdougbvoid
583205292Sdougbdns_resolver_printbadcache(dns_resolver_t *resolver, FILE *fp);
584205292Sdougb/*%
585205292Sdougb * Print out the contents of the bad cache to 'fp'.
586205292Sdougb *
587205292Sdougb * Requires:
588205292Sdougb * \li	resolver to be valid.
589205292Sdougb */
590205292Sdougb
591275672Sdelphijvoid
592275672Sdelphijdns_resolver_setmaxdepth(dns_resolver_t *resolver, unsigned int maxdepth);
593275672Sdelphijunsigned int
594275672Sdelphijdns_resolver_getmaxdepth(dns_resolver_t *resolver);
595275672Sdelphij/*%
596275672Sdelphij * Get and set how many NS indirections will be followed when looking for
597275672Sdelphij * nameserver addresses.
598275672Sdelphij *
599275672Sdelphij * Requires:
600275672Sdelphij * \li	resolver to be valid.
601275672Sdelphij */
602275672Sdelphij
603135446StrhodesISC_LANG_ENDDECLS
604135446Strhodes
605135446Strhodes#endif /* DNS_RESOLVER_H */
606