2 * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001, 2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: resolver.h,v 1.34.12.9 2006/02/01 23:48:51 marka Exp $ */
20 #ifndef DNS_RESOLVER_H
21 #define DNS_RESOLVER_H 1
30 * This is the BIND 9 resolver, the module responsible for resolving DNS
31 * requests by iteratively querying authoritative servers and following
32 * referrals. This is a "full resolver", not to be confused with
33 * the stub resolvers most people associate with the word "resolver".
34 * The full resolver is part of the caching name server or resolver
35 * daemon the stub resolver talks to.
38 * The module ensures appropriate synchronization of data structures it
39 * creates and manipulates.
42 * No anticipated impact.
48 * No anticipated impact.
51 * RFCs: 1034, 1035, 2181, <TBS>
56 #include <isc/socket.h>
58 #include <dns/types.h>
59 #include <dns/fixedname.h>
64 * A dns_fetchevent_t is sent when a 'fetch' completes. Any of 'db',
65 * 'node', 'rdataset', and 'sigrdataset' may be bound. It is the
66 * receiver's responsibility to detach before freeing the event.
68 * 'rdataset' and 'sigrdataset' are the values that were supplied when
69 * dns_resolver_createfetch() was called. They are returned to the
70 * caller so that they may be freed.
72 typedef struct dns_fetchevent {
73 ISC_EVENT_COMMON(struct dns_fetchevent);
76 dns_rdatatype_t qtype;
79 dns_rdataset_t * rdataset;
80 dns_rdataset_t * sigrdataset;
81 dns_fixedname_t foundname;
85 * Options that modify how a 'fetch' is done.
87 #define DNS_FETCHOPT_TCP 0x01 /* Use TCP. */
88 #define DNS_FETCHOPT_UNSHARED 0x02 /* See below. */
89 #define DNS_FETCHOPT_RECURSIVE 0x04 /* Set RD? */
90 #define DNS_FETCHOPT_NOEDNS0 0x08 /* Do not use EDNS. */
91 #define DNS_FETCHOPT_FORWARDONLY 0x10 /* Only use forwarders. */
92 #define DNS_FETCHOPT_NOVALIDATE 0x20 /* Disable validation. */
95 * XXXRTH Should this API be made semi-private? (I.e.
96 * _dns_resolver_create()).
99 #define DNS_RESOLVER_CHECKNAMES 0x01
100 #define DNS_RESOLVER_CHECKNAMESFAIL 0x02
103 dns_resolver_create(dns_view_t *view,
104 isc_taskmgr_t *taskmgr, unsigned int ntasks,
105 isc_socketmgr_t *socketmgr,
106 isc_timermgr_t *timermgr,
107 unsigned int options,
108 dns_dispatchmgr_t *dispatchmgr,
109 dns_dispatch_t *dispatchv4,
110 dns_dispatch_t *dispatchv6,
111 dns_resolver_t **resp);
118 * Generally, applications should not create a resolver directly, but
119 * should instead call dns_view_createresolver().
121 * No options are currently defined.
125 * 'view' is a valid view.
127 * 'taskmgr' is a valid task manager.
131 * 'socketmgr' is a valid socket manager.
133 * 'timermgr' is a valid timer manager.
135 * 'dispatchv4' is a valid dispatcher with an IPv4 UDP socket, or is NULL.
137 * 'dispatchv6' is a valid dispatcher with an IPv6 UDP socket, or is NULL.
139 * resp != NULL && *resp == NULL.
143 * ISC_R_SUCCESS On success.
145 * Anything else Failure.
149 dns_resolver_freeze(dns_resolver_t *res);
155 * Certain configuration changes cannot be made after the resolver
156 * is frozen. Fetches cannot be created until the resolver is frozen.
160 * 'res' is a valid, unfrozen resolver.
168 dns_resolver_prime(dns_resolver_t *res);
174 * Resolvers which have a forwarding policy other than dns_fwdpolicy_only
175 * need to be primed with the root nameservers, otherwise the root
176 * nameserver hints data may be used indefinitely. This function requests
177 * that the resolver start a priming fetch, if it isn't already priming.
181 * 'res' is a valid, frozen resolver.
186 dns_resolver_whenshutdown(dns_resolver_t *res, isc_task_t *task,
187 isc_event_t **eventp);
189 * Send '*eventp' to 'task' when 'res' has completed shutdown.
193 * It is not safe to detach the last reference to 'res' until
194 * shutdown is complete.
198 * 'res' is a valid resolver.
200 * 'task' is a valid task.
202 * *eventp is a valid event.
210 dns_resolver_shutdown(dns_resolver_t *res);
212 * Start the shutdown process for 'res'.
216 * This call has no effect if the resolver is already shutting down.
220 * 'res' is a valid resolver.
224 dns_resolver_attach(dns_resolver_t *source, dns_resolver_t **targetp);
227 dns_resolver_detach(dns_resolver_t **resp);
230 dns_resolver_createfetch(dns_resolver_t *res, dns_name_t *name,
231 dns_rdatatype_t type,
232 dns_name_t *domain, dns_rdataset_t *nameservers,
233 dns_forwarders_t *forwarders,
234 unsigned int options, isc_task_t *task,
235 isc_taskaction_t action, void *arg,
236 dns_rdataset_t *rdataset,
237 dns_rdataset_t *sigrdataset,
238 dns_fetch_t **fetchp);
240 * Recurse to answer a question.
244 * This call starts a query for 'name', type 'type'.
246 * The 'domain' is a parent domain of 'name' for which
247 * a set of name servers 'nameservers' is known. If no
248 * such name server information is available, set
249 * 'domain' and 'nameservers' to NULL.
251 * 'forwarders' is unimplemented, and subject to change when
252 * we figure out how selective forwarding will work.
254 * When the fetch completes (successfully or otherwise), a
255 * DNS_EVENT_FETCHDONE event with action 'action' and arg 'arg' will be
258 * The values of 'rdataset' and 'sigrdataset' will be returned in
259 * the FETCHDONE event.
263 * 'res' is a valid resolver that has been frozen.
265 * 'name' is a valid name.
267 * 'type' is not a meta type other than ANY.
269 * 'domain' is a valid name or NULL.
271 * 'nameservers' is a valid NS rdataset (whose owner name is 'domain')
272 * iff. 'domain' is not NULL.
274 * 'forwarders' is NULL.
276 * 'options' contains valid options.
278 * 'rdataset' is a valid, disassociated rdataset.
280 * 'sigrdataset' is NULL, or is a valid, disassociated rdataset.
282 * fetchp != NULL && *fetchp == NULL.
286 * ISC_R_SUCCESS Success
288 * Many other values are possible, all of which indicate failure.
292 dns_resolver_cancelfetch(dns_fetch_t *fetch);
298 * If 'fetch' has not completed, post its FETCHDONE event with a
299 * result code of ISC_R_CANCELED.
303 * 'fetch' is a valid fetch.
307 dns_resolver_destroyfetch(dns_fetch_t **fetchp);
313 * '*fetchp' is a valid fetch.
315 * The caller has received the FETCHDONE event (either because the
316 * fetch completed or because dns_resolver_cancelfetch() was called).
324 dns_resolver_dispatchmgr(dns_resolver_t *resolver);
327 dns_resolver_dispatchv4(dns_resolver_t *resolver);
330 dns_resolver_dispatchv6(dns_resolver_t *resolver);
333 dns_resolver_socketmgr(dns_resolver_t *resolver);
336 dns_resolver_taskmgr(dns_resolver_t *resolver);
339 dns_resolver_getlamettl(dns_resolver_t *resolver);
341 * Get the resolver's lame-ttl. zero => no lame processing.
344 * 'resolver' to be valid.
348 dns_resolver_setlamettl(dns_resolver_t *resolver, isc_uint32_t lame_ttl);
350 * Set the resolver's lame-ttl. zero => no lame processing.
353 * 'resolver' to be valid.
357 dns_resolver_nrunning(dns_resolver_t *resolver);
359 * Return the number of currently running resolutions in this
360 * resolver. This is may be less than the number of outstanding
361 * fetches due to multiple identical fetches, or more than the
362 * number of of outstanding fetches due to the fact that resolution
363 * can continue even though a fetch has been canceled.
367 dns_resolver_addalternate(dns_resolver_t *resolver, isc_sockaddr_t *alt,
368 dns_name_t *name, in_port_t port);
370 * Add alternate addresses to be tried in the event that the nameservers
371 * for a zone are not available in the address families supported by the
375 * only one of 'name' or 'alt' to be valid.
379 dns_resolver_setudpsize(dns_resolver_t *resolver, isc_uint16_t udpsize);
381 * Set the EDNS UDP buffer size advertised by the server.
385 dns_resolver_getudpsize(dns_resolver_t *resolver);
387 * Get the current EDNS UDP buffer size.
391 dns_resolver_reset_algorithms(dns_resolver_t *resolver);
393 * Clear the disabled DNSSEC algorithms.
397 dns_resolver_disable_algorithm(dns_resolver_t *resolver, dns_name_t *name,
400 * Mark the give DNSSEC algorithm as disabled and below 'name'.
401 * Valid algorithms are less than 256.
410 dns_resolver_algorithm_supported(dns_resolver_t *resolver, dns_name_t *name,
413 * Check if the given algorithm is supported by this resolver.
414 * This checks if the algorithm has been disabled via
415 * dns_resolver_disable_algorithm() then the underlying
416 * crypto libraries if not specifically disabled.
420 dns_resolver_resetmustbesecure(dns_resolver_t *resolver);
423 dns_resolver_setmustbesecure(dns_resolver_t *resolver, dns_name_t *name,
424 isc_boolean_t value);
427 dns_resolver_getmustbesecure(dns_resolver_t *resolver, dns_name_t *name);
431 #endif /* DNS_RESOLVER_H */