1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
|
/*
* Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: resolver.h,v 1.34.12.9 2006/02/01 23:48:51 marka Exp $ */
#ifndef DNS_RESOLVER_H
#define DNS_RESOLVER_H 1
/*****
***** Module Info
*****/
/*
* DNS Resolver
*
* This is the BIND 9 resolver, the module responsible for resolving DNS
* requests by iteratively querying authoritative servers and following
* referrals. This is a "full resolver", not to be confused with
* the stub resolvers most people associate with the word "resolver".
* The full resolver is part of the caching name server or resolver
* daemon the stub resolver talks to.
*
* MP:
* The module ensures appropriate synchronization of data structures it
* creates and manipulates.
*
* Reliability:
* No anticipated impact.
*
* Resources:
* <TBS>
*
* Security:
* No anticipated impact.
*
* Standards:
* RFCs: 1034, 1035, 2181, <TBS>
* Drafts: <TBS>
*/
#include <isc/lang.h>
#include <isc/socket.h>
#include <dns/types.h>
#include <dns/fixedname.h>
ISC_LANG_BEGINDECLS
/*
* A dns_fetchevent_t is sent when a 'fetch' completes. Any of 'db',
* 'node', 'rdataset', and 'sigrdataset' may be bound. It is the
* receiver's responsibility to detach before freeing the event.
*
* 'rdataset' and 'sigrdataset' are the values that were supplied when
* dns_resolver_createfetch() was called. They are returned to the
* caller so that they may be freed.
*/
typedef struct dns_fetchevent {
ISC_EVENT_COMMON(struct dns_fetchevent);
dns_fetch_t * fetch;
isc_result_t result;
dns_rdatatype_t qtype;
dns_db_t * db;
dns_dbnode_t * node;
dns_rdataset_t * rdataset;
dns_rdataset_t * sigrdataset;
dns_fixedname_t foundname;
} dns_fetchevent_t;
/*
* Options that modify how a 'fetch' is done.
*/
#define DNS_FETCHOPT_TCP 0x01 /* Use TCP. */
#define DNS_FETCHOPT_UNSHARED 0x02 /* See below. */
#define DNS_FETCHOPT_RECURSIVE 0x04 /* Set RD? */
#define DNS_FETCHOPT_NOEDNS0 0x08 /* Do not use EDNS. */
#define DNS_FETCHOPT_FORWARDONLY 0x10 /* Only use forwarders. */
#define DNS_FETCHOPT_NOVALIDATE 0x20 /* Disable validation. */
/*
* XXXRTH Should this API be made semi-private? (I.e.
* _dns_resolver_create()).
*/
#define DNS_RESOLVER_CHECKNAMES 0x01
#define DNS_RESOLVER_CHECKNAMESFAIL 0x02
isc_result_t
dns_resolver_create(dns_view_t *view,
isc_taskmgr_t *taskmgr, unsigned int ntasks,
isc_socketmgr_t *socketmgr,
isc_timermgr_t *timermgr,
unsigned int options,
dns_dispatchmgr_t *dispatchmgr,
dns_dispatch_t *dispatchv4,
dns_dispatch_t *dispatchv6,
dns_resolver_t **resp);
/*
* Create a resolver.
*
* Notes:
*
* Generally, applications should not create a resolver directly, but
* should instead call dns_view_createresolver().
*
* No options are currently defined.
*
* Requires:
*
* 'view' is a valid view.
*
* 'taskmgr' is a valid task manager.
*
* 'ntasks' > 0.
*
* 'socketmgr' is a valid socket manager.
*
* 'timermgr' is a valid timer manager.
*
* 'dispatchv4' is a valid dispatcher with an IPv4 UDP socket, or is NULL.
*
* 'dispatchv6' is a valid dispatcher with an IPv6 UDP socket, or is NULL.
*
* resp != NULL && *resp == NULL.
*
* Returns:
*
* ISC_R_SUCCESS On success.
*
* Anything else Failure.
*/
void
dns_resolver_freeze(dns_resolver_t *res);
/*
* Freeze resolver.
*
* Notes:
*
* Certain configuration changes cannot be made after the resolver
* is frozen. Fetches cannot be created until the resolver is frozen.
*
* Requires:
*
* 'res' is a valid, unfrozen resolver.
*
* Ensures:
*
* 'res' is frozen.
*/
void
dns_resolver_prime(dns_resolver_t *res);
/*
* Prime resolver.
*
* Notes:
*
* Resolvers which have a forwarding policy other than dns_fwdpolicy_only
* need to be primed with the root nameservers, otherwise the root
* nameserver hints data may be used indefinitely. This function requests
* that the resolver start a priming fetch, if it isn't already priming.
*
* Requires:
*
* 'res' is a valid, frozen resolver.
*/
void
dns_resolver_whenshutdown(dns_resolver_t *res, isc_task_t *task,
isc_event_t **eventp);
/*
* Send '*eventp' to 'task' when 'res' has completed shutdown.
*
* Notes:
*
* It is not safe to detach the last reference to 'res' until
* shutdown is complete.
*
* Requires:
*
* 'res' is a valid resolver.
*
* 'task' is a valid task.
*
* *eventp is a valid event.
*
* Ensures:
*
* *eventp == NULL.
*/
void
dns_resolver_shutdown(dns_resolver_t *res);
/*
* Start the shutdown process for 'res'.
*
* Notes:
*
* This call has no effect if the resolver is already shutting down.
*
* Requires:
*
* 'res' is a valid resolver.
*/
void
dns_resolver_attach(dns_resolver_t *source, dns_resolver_t **targetp);
void
dns_resolver_detach(dns_resolver_t **resp);
isc_result_t
dns_resolver_createfetch(dns_resolver_t *res, dns_name_t *name,
dns_rdatatype_t type,
dns_name_t *domain, dns_rdataset_t *nameservers,
dns_forwarders_t *forwarders,
unsigned int options, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_rdataset_t *rdataset,
dns_rdataset_t *sigrdataset,
dns_fetch_t **fetchp);
/*
* Recurse to answer a question.
*
* Notes:
*
* This call starts a query for 'name', type 'type'.
*
* The 'domain' is a parent domain of 'name' for which
* a set of name servers 'nameservers' is known. If no
* such name server information is available, set
* 'domain' and 'nameservers' to NULL.
*
* 'forwarders' is unimplemented, and subject to change when
* we figure out how selective forwarding will work.
*
* When the fetch completes (successfully or otherwise), a
* DNS_EVENT_FETCHDONE event with action 'action' and arg 'arg' will be
* posted to 'task'.
*
* The values of 'rdataset' and 'sigrdataset' will be returned in
* the FETCHDONE event.
*
* Requires:
*
* 'res' is a valid resolver that has been frozen.
*
* 'name' is a valid name.
*
* 'type' is not a meta type other than ANY.
*
* 'domain' is a valid name or NULL.
*
* 'nameservers' is a valid NS rdataset (whose owner name is 'domain')
* iff. 'domain' is not NULL.
*
* 'forwarders' is NULL.
*
* 'options' contains valid options.
*
* 'rdataset' is a valid, disassociated rdataset.
*
* 'sigrdataset' is NULL, or is a valid, disassociated rdataset.
*
* fetchp != NULL && *fetchp == NULL.
*
* Returns:
*
* ISC_R_SUCCESS Success
*
* Many other values are possible, all of which indicate failure.
*/
void
dns_resolver_cancelfetch(dns_fetch_t *fetch);
/*
* Cancel 'fetch'.
*
* Notes:
*
* If 'fetch' has not completed, post its FETCHDONE event with a
* result code of ISC_R_CANCELED.
*
* Requires:
*
* 'fetch' is a valid fetch.
*/
void
dns_resolver_destroyfetch(dns_fetch_t **fetchp);
/*
* Destroy 'fetch'.
*
* Requires:
*
* '*fetchp' is a valid fetch.
*
* The caller has received the FETCHDONE event (either because the
* fetch completed or because dns_resolver_cancelfetch() was called).
*
* Ensures:
*
* *fetchp == NULL.
*/
dns_dispatchmgr_t *
dns_resolver_dispatchmgr(dns_resolver_t *resolver);
dns_dispatch_t *
dns_resolver_dispatchv4(dns_resolver_t *resolver);
dns_dispatch_t *
dns_resolver_dispatchv6(dns_resolver_t *resolver);
isc_socketmgr_t *
dns_resolver_socketmgr(dns_resolver_t *resolver);
isc_taskmgr_t *
dns_resolver_taskmgr(dns_resolver_t *resolver);
isc_uint32_t
dns_resolver_getlamettl(dns_resolver_t *resolver);
/*
* Get the resolver's lame-ttl. zero => no lame processing.
*
* Requires:
* 'resolver' to be valid.
*/
void
dns_resolver_setlamettl(dns_resolver_t *resolver, isc_uint32_t lame_ttl);
/*
* Set the resolver's lame-ttl. zero => no lame processing.
*
* Requires:
* 'resolver' to be valid.
*/
unsigned int
dns_resolver_nrunning(dns_resolver_t *resolver);
/*
* Return the number of currently running resolutions in this
* resolver. This is may be less than the number of outstanding
* fetches due to multiple identical fetches, or more than the
* number of of outstanding fetches due to the fact that resolution
* can continue even though a fetch has been canceled.
*/
isc_result_t
dns_resolver_addalternate(dns_resolver_t *resolver, isc_sockaddr_t *alt,
dns_name_t *name, in_port_t port);
/*
* Add alternate addresses to be tried in the event that the nameservers
* for a zone are not available in the address families supported by the
* operating system.
*
* Require:
* only one of 'name' or 'alt' to be valid.
*/
void
dns_resolver_setudpsize(dns_resolver_t *resolver, isc_uint16_t udpsize);
/*
* Set the EDNS UDP buffer size advertised by the server.
*/
isc_uint16_t
dns_resolver_getudpsize(dns_resolver_t *resolver);
/*
* Get the current EDNS UDP buffer size.
*/
void
dns_resolver_reset_algorithms(dns_resolver_t *resolver);
/*
* Clear the disabled DNSSEC algorithms.
*/
isc_result_t
dns_resolver_disable_algorithm(dns_resolver_t *resolver, dns_name_t *name,
unsigned int alg);
/*
* Mark the give DNSSEC algorithm as disabled and below 'name'.
* Valid algorithms are less than 256.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_RANGE
* ISC_R_NOMEMORY
*/
isc_boolean_t
dns_resolver_algorithm_supported(dns_resolver_t *resolver, dns_name_t *name,
unsigned int alg);
/*
* Check if the given algorithm is supported by this resolver.
* This checks if the algorithm has been disabled via
* dns_resolver_disable_algorithm() then the underlying
* crypto libraries if not specifically disabled.
*/
void
dns_resolver_resetmustbesecure(dns_resolver_t *resolver);
isc_result_t
dns_resolver_setmustbesecure(dns_resolver_t *resolver, dns_name_t *name,
isc_boolean_t value);
isc_boolean_t
dns_resolver_getmustbesecure(dns_resolver_t *resolver, dns_name_t *name);
ISC_LANG_ENDDECLS
#endif /* DNS_RESOLVER_H */
|