view.h 18.7 KB
Newer Older
Bob Halley's avatar
add  
Bob Halley committed
1
/*
Brian Wellington's avatar
Brian Wellington committed
2
 * Copyright (C) 1999-2001  Internet Software Consortium.
3
 *
Bob Halley's avatar
add  
Bob Halley committed
4 5 6
 * 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.
7
 *
8 9 10 11 12 13 14 15
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 * INTERNET SOFTWARE CONSORTIUM 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.
Bob Halley's avatar
add  
Bob Halley committed
16 17
 */

18
/* $Id: view.h,v 1.88 2004/02/17 03:40:23 marka Exp $ */
David Lawrence's avatar
David Lawrence committed
19

Bob Halley's avatar
add  
Bob Halley committed
20 21 22 23 24 25 26 27 28 29
#ifndef DNS_VIEW_H
#define DNS_VIEW_H 1

/*****
 ***** Module Info
 *****/

/*
 * DNS View
 *
Bob Halley's avatar
Bob Halley committed
30 31 32 33 34 35 36 37 38 39 40 41
 * A "view" is a DNS namespace, together with an optional resolver and a
 * forwarding policy.  A "DNS namespace" is a (possibly empty) set of
 * authoritative zones together with an optional cache and optional
 * "hints" information.
 *
 * Views start out "unfrozen".  In this state, core attributes like
 * the cache, set of zones, and forwarding policy may be set.  While
 * "unfrozen", the caller (e.g. nameserver configuration loading
 * code), must ensure exclusive access to the view.  When the view is
 * "frozen", the core attributes become immutable, and the view module
 * will ensure synchronization.  Freezing allows the view's core attributes
 * to be accessed without locking.
Bob Halley's avatar
add  
Bob Halley committed
42 43
 *
 * MP:
Bob Halley's avatar
Bob Halley committed
44 45 46 47
 *	Before the view is frozen, the caller must ensure synchronization.
 *
 *	After the view is frozen, the module guarantees appropriate
 *	synchronization of any data structures it creates and manipulates.
Bob Halley's avatar
add  
Bob Halley committed
48 49 50 51 52 53 54 55 56 57 58
 *
 * Reliability:
 *	No anticipated impact.
 *
 * Resources:
 *	<TBS>
 *
 * Security:
 *	No anticipated impact.
 *
 * Standards:
59 60
 *	None.
 */
Bob Halley's avatar
add  
Bob Halley committed
61

Brian Wellington's avatar
Brian Wellington committed
62 63
#include <stdio.h>

Bob Halley's avatar
add  
Bob Halley committed
64
#include <isc/lang.h>
65
#include <isc/magic.h>
Bob Halley's avatar
add  
Bob Halley committed
66
#include <isc/event.h>
Brian Wellington's avatar
Brian Wellington committed
67
#include <isc/mutex.h>
68
#include <isc/net.h>
69
#include <isc/refcount.h>
70
#include <isc/rwlock.h>
Bob Halley's avatar
Bob Halley committed
71
#include <isc/stdtime.h>
Bob Halley's avatar
add  
Bob Halley committed
72

73
#include <dns/acl.h>
Bob Halley's avatar
add  
Bob Halley committed
74 75 76 77 78 79 80 81 82 83
#include <dns/types.h>

ISC_LANG_BEGINDECLS

struct dns_view {
	/* Unlocked. */
	unsigned int			magic;
	isc_mem_t *			mctx;
	dns_rdataclass_t		rdclass;
	char *				name;
84
	dns_zt_t *			zonetable;
Bob Halley's avatar
add  
Bob Halley committed
85
	dns_resolver_t *		resolver;
Bob Halley's avatar
add adb  
Bob Halley committed
86
	dns_adb_t *			adb;
Mark Andrews's avatar
Mark Andrews committed
87
	dns_requestmgr_t *		requestmgr;
88
	dns_cache_t *			cache;
Bob Halley's avatar
Bob Halley committed
89
	dns_db_t *			cachedb;
Bob Halley's avatar
Bob Halley committed
90
	dns_db_t *			hints;
91 92
	dns_keytable_t *		secroots;
	dns_keytable_t *		trustedkeys;
Bob Halley's avatar
add  
Bob Halley committed
93
	isc_mutex_t			lock;
Bob Halley's avatar
Bob Halley committed
94
	isc_boolean_t			frozen;
95 96 97
	isc_task_t *			task;
	isc_event_t			resevent;
	isc_event_t			adbevent;
Mark Andrews's avatar
Mark Andrews committed
98
	isc_event_t			reqevent;
99
	/* Configurable data. */
Brian Wellington's avatar
Brian Wellington committed
100 101
	dns_tsig_keyring_t *		statickeys;
	dns_tsig_keyring_t *		dynamickeys;
102
	dns_peerlist_t *		peers;
103
	dns_order_t *			order;
104
	dns_fwdtable_t *		fwdtable;
105 106
	isc_boolean_t			recursion;
	isc_boolean_t			auth_nxdomain;
Michael Graff's avatar
 
Michael Graff committed
107 108
	isc_boolean_t			additionalfromcache;
	isc_boolean_t			additionalfromauth;
Bob Halley's avatar
Bob Halley committed
109
	isc_boolean_t			minimalresponses;
110
	isc_boolean_t			enablednssec;
111
	dns_transfer_format_t		transfer_format;
112 113
	dns_acl_t *			queryacl;
	dns_acl_t *			recursionacl;
114
	dns_acl_t *			sortlist;
115 116
	isc_boolean_t			requestixfr;
	isc_boolean_t			provideixfr;
117 118
	dns_ttl_t			maxcachettl;
	dns_ttl_t			maxncachettl;
119
	in_port_t			dstport;
120
	dns_aclenv_t			aclenv;
121
	dns_rdatatype_t			preferred_glue;
122
	isc_boolean_t			flush;
123
	dns_namelist_t *		delonly;
124
	isc_boolean_t			rootdelonly;
Mark Andrews's avatar
Mark Andrews committed
125
	dns_namelist_t *		rootexclude;
126

127 128 129 130 131
	/*
	 * Configurable data for server use only,
	 * locked by server configuration lock.
	 */
	dns_acl_t *			matchclients;
132 133
	dns_acl_t *			matchdestinations;
	isc_boolean_t			matchrecursiveonly;
134

135 136 137
	/* Locked by themselves. */
	isc_refcount_t			references;

Bob Halley's avatar
add  
Bob Halley committed
138
	/* Locked by lock. */
139
	unsigned int			weakrefs;
140
	unsigned int			attributes;
Bob Halley's avatar
add  
Bob Halley committed
141 142 143 144
	/* Under owner's locking control. */
	ISC_LINK(struct dns_view)	link;
};

145
#define DNS_VIEW_MAGIC			ISC_MAGIC('V','i','e','w')
146
#define DNS_VIEW_VALID(view)		ISC_MAGIC_VALID(view, DNS_VIEW_MAGIC)
Bob Halley's avatar
add  
Bob Halley committed
147

148 149
#define DNS_VIEWATTR_RESSHUTDOWN	0x01
#define DNS_VIEWATTR_ADBSHUTDOWN	0x02
Mark Andrews's avatar
Mark Andrews committed
150
#define DNS_VIEWATTR_REQSHUTDOWN	0x04
151

Bob Halley's avatar
add  
Bob Halley committed
152
isc_result_t
153 154
dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
		const char *name, dns_view_t **viewp);
Bob Halley's avatar
Bob Halley committed
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
/*
 * Create a view.
 *
 * Notes:
 *
 *	The newly created view has no cache, no resolver, and an empty
 *	zone table.  The view is not frozen.
 *
 * Requires:
 *
 *	'mctx' is a valid memory context.
 *
 *	'rdclass' is a valid class.
 *
 *	'name' is a valid C string.
 *
 *	viewp != NULL && *viewp == NULL
 *
 * Returns:
 *
 *	ISC_R_SUCCESS
 *	ISC_R_NOMEMORY
 *
 *	Other errors are possible.
 */
Bob Halley's avatar
add  
Bob Halley committed
180 181 182

void
dns_view_attach(dns_view_t *source, dns_view_t **targetp);
Bob Halley's avatar
Bob Halley committed
183 184 185 186 187 188 189 190 191 192 193 194
/*
 * Attach '*targetp' to 'source'.
 *
 * Requires:
 *
 *	'source' is a valid, frozen view.
 *
 *	'targetp' points to a NULL dns_view_t *.
 *
 * Ensures:
 *
 *	*targetp is attached to source.
195 196
 *
 *	While *targetp is attached, the view will not shut down.
Bob Halley's avatar
Bob Halley committed
197
 */
Bob Halley's avatar
add  
Bob Halley committed
198 199 200

void
dns_view_detach(dns_view_t **viewp);
Bob Halley's avatar
Bob Halley committed
201 202 203 204 205
/*
 * Detach '*viewp' from its view.
 *
 * Requires:
 *
206
 *	'viewp' points to a valid dns_view_t *
Bob Halley's avatar
Bob Halley committed
207 208 209 210
 *
 * Ensures:
 *
 *	*viewp is NULL.
211 212
 */

213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
void
dns_view_flushanddetach(dns_view_t **viewp);
/*
 * Detach '*viewp' from its view.  If this was the last reference
 * uncommited changed in zones will be flushed to disk.
 *
 * Requires:
 *
 *	'viewp' points to a valid dns_view_t *
 *
 * Ensures:
 *
 *	*viewp is NULL.
 */

228 229 230 231 232 233 234 235 236 237 238 239
void
dns_view_weakattach(dns_view_t *source, dns_view_t **targetp);
/*
 * Weakly attach '*targetp' to 'source'.
 *
 * Requires:
 *
 *	'source' is a valid, frozen view.
 *
 *	'targetp' points to a NULL dns_view_t *.
 *
 * Ensures:
Bob Halley's avatar
Bob Halley committed
240
 *
241 242 243 244 245 246 247 248 249
 *	*targetp is attached to source.
 *
 * 	While *targetp is attached, the view will not be freed.
 */

void
dns_view_weakdetach(dns_view_t **targetp);
/*
 * Detach '*viewp' from its view.
Bob Halley's avatar
Bob Halley committed
250
 *
251 252 253 254 255 256 257
 * Requires:
 *
 *	'viewp' points to a valid dns_view_t *.
 *
 * Ensures:
 *
 *	*viewp is NULL.
Bob Halley's avatar
Bob Halley committed
258
 */
Bob Halley's avatar
add  
Bob Halley committed
259

Bob Halley's avatar
Bob Halley committed
260
isc_result_t
Bob Halley's avatar
Bob Halley committed
261 262 263 264
dns_view_createresolver(dns_view_t *view,
			isc_taskmgr_t *taskmgr, unsigned int ntasks,
			isc_socketmgr_t *socketmgr,
			isc_timermgr_t *timermgr,
265
			unsigned int options,
266
			dns_dispatchmgr_t *dispatchmgr,
267 268
			dns_dispatch_t *dispatchv4,
			dns_dispatch_t *dispatchv6);
Bob Halley's avatar
Bob Halley committed
269
/*
Bob Halley's avatar
add adb  
Bob Halley committed
270
 * Create a resolver and address database for the view.
Bob Halley's avatar
Bob Halley committed
271 272 273
 *
 * Requires:
 *
Bob Halley's avatar
Bob Halley committed
274
 *	'view' is a valid, unfrozen view.
Bob Halley's avatar
Bob Halley committed
275
 *
Bob Halley's avatar
Bob Halley committed
276
 *	'view' does not have a resolver already.
Bob Halley's avatar
Bob Halley committed
277
 *
Bob Halley's avatar
Bob Halley committed
278
 *	The requirements of dns_resolver_create() apply to 'taskmgr',
279 280
 *	'ntasks', 'socketmgr', 'timermgr', 'options', 'dispatchv4', and
 *	'dispatchv6'.
Bob Halley's avatar
Bob Halley committed
281 282
 *
 * Returns:
Bob Halley's avatar
Bob Halley committed
283
 *
Bob Halley's avatar
Bob Halley committed
284 285 286
 *     	ISC_R_SUCCESS
 *
 *	Any error that dns_resolver_create() can return.
Bob Halley's avatar
Bob Halley committed
287
 */
288 289

void
290
dns_view_setcache(dns_view_t *view, dns_cache_t *cache);
Bob Halley's avatar
Bob Halley committed
291 292 293 294 295
/*
 * Set the view's cache database.
 *
 * Requires:
 *
Bob Halley's avatar
add adb  
Bob Halley committed
296
 *	'view' is a valid, unfrozen view.
Bob Halley's avatar
Bob Halley committed
297
 *
298
 *	'cache' is a valid cache.
Bob Halley's avatar
Bob Halley committed
299 300 301
 *
 * Ensures:
 *
302
 *     	The cache of 'view' is 'cached.
Bob Halley's avatar
add adb  
Bob Halley committed
303
 *
304 305
 *	If this is not the first call to dns_view_setcache() for this
 *	view, then previously set cache is detached.
Bob Halley's avatar
Bob Halley committed
306
 */
307

Bob Halley's avatar
Bob Halley committed
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
void
dns_view_sethints(dns_view_t *view, dns_db_t *hints);
/*
 * Set the view's hints database.
 *
 * Requires:
 *
 *	'view' is a valid, unfrozen view, whose hints database has not been
 *	set.
 *
 *	'hints' is a valid zone database.
 *
 * Ensures:
 *
 *     	The hints database of 'view' is 'hints'.
 */

Brian Wellington's avatar
Brian Wellington committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
void
dns_view_setkeyring(dns_view_t *view, dns_tsig_keyring_t *ring);
/*
 * Set the view's static TSIG keys
 *
 * Requires:
 *
 *      'view' is a valid, unfrozen view, whose static TSIG keyring has not
 *	been set.
 *
 *      'ring' is a valid TSIG keyring
 *
 * Ensures:
 *
 *      The static TSIG keyring of 'view' is 'ring'.
 */

342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
void
dns_view_setdstport(dns_view_t *view, in_port_t dstport);
/*
 * Set the view's destination port.  This is the port to
 * which outgoing queries are sent.  The default is 53,
 * the standard DNS port.
 *
 * Requires:
 *
 *      'view' is a valid view.
 *
 *      'dstport' is a valid TCP/UDP port number.
 *
 * Ensures:
 *	External name servers will be assumed to be listning
 *	on 'dstport'.  For servers whose address has already
 *	obtained obtained at the time of the call, the view may
 *	continue to use the previously set port until the address
 *	times out from the view's address database.
 */
Brian Wellington's avatar
Brian Wellington committed
362 363


364
isc_result_t
365
dns_view_addzone(dns_view_t *view, dns_zone_t *zone);
Bob Halley's avatar
Bob Halley committed
366
/*
367
 * Add zone 'zone' to 'view'.
Bob Halley's avatar
Bob Halley committed
368 369 370 371 372
 *
 * Requires:
 *
 *	'view' is a valid, unfrozen view.
 *
373 374
 *	'zone' is a valid zone.
 */
375 376 377

void
dns_view_freeze(dns_view_t *view);
Bob Halley's avatar
Bob Halley committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391
/*
 * Freeze view.
 *
 * Requires:
 *
 *	'view' is a valid, unfrozen view.
 *
 * Ensures:
 *
 *	'view' is frozen.
 */

isc_result_t
dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
392 393
	      isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints,
	      dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname,
Bob Halley's avatar
Bob Halley committed
394
	      dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
395 396 397 398 399 400 401 402 403 404 405 406 407 408
/*
 * Find an rdataset whose owner name is 'name', and whose type is
 * 'type'.
 *
 * Notes:
 *
 *	See the description of dns_db_find() for information about 'options'.
 *	If the caller sets DNS_DBFIND_GLUEOK, it must ensure that 'name'
 *	and 'type' are appropriate for glue retrieval.
 *
 *	If 'now' is zero, then the current time will be used.
 *
 *	If 'use_hints' is ISC_TRUE, and the view has a hints database, then
 *	it will be searched last.  If the answer is found in the hints
409 410 411
 *	database, the result code will be DNS_R_HINT.  If the name is found
 *	in the hints database but not the type, the result code will be
 *	DNS_R_HINTNXRRSET.
412 413 414 415 416 417 418 419 420 421 422 423 424
 *
 *	'foundname' must meet the requirements of dns_db_find().
 *
 *	If 'sigrdataset' is not NULL, and there is a SIG rdataset which
 *	covers 'type', then 'sigrdataset' will be bound to it.
 *
 * Requires:
 *
 *	'view' is a valid, frozen view.
 *
 *	'name' is valid name.
 *
 *	'type' is a valid dns_rdatatype_t, and is not a meta query type
425
 *	except dns_rdatatype_any.
426
 *
427 428 429 430 431
 *	dbp == NULL || *dbp == NULL
 *
 *	nodep == NULL || *nodep == NULL.  If nodep != NULL, dbp != NULL.
 *
 *	'foundname' is a valid name with a dedicated buffer or NULL.
432 433 434 435 436 437 438 439 440 441
 *
 *	'rdataset' is a valid, disassociated rdataset.
 *
 *	'sigrdataset' is NULL, or is a valid, disassociated rdataset.
 *
 * Ensures:
 *
 *	In successful cases, 'rdataset', and possibly 'sigrdataset', are
 *	bound to the found data.
 *
442 443 444 445 446 447
 *	If dbp != NULL, it points to the database containing the data.
 *
 *	If nodep != NULL, it points to the database node containing the data.
 *
 *	If foundname != NULL, it contains the full name of the found data.
 *
448 449 450 451 452 453 454 455 456 457 458
 * Returns:
 *
 *	Any result that dns_db_find() can return, with the exception of
 *	DNS_R_DELEGATION.
 */

isc_result_t
dns_view_simplefind(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
		    isc_stdtime_t now, unsigned int options,
		    isc_boolean_t use_hints,
		    dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
Bob Halley's avatar
Bob Halley committed
459 460 461 462 463 464 465
/*
 * Find an rdataset whose owner name is 'name', and whose type is
 * 'type'.
 *
 * Notes:
 *
 *	This routine is appropriate for simple, exact-match queries of the
Bob Halley's avatar
Bob Halley committed
466 467
 *	view.  'name' must be a canonical name; there is no DNAME or CNAME
 *	processing.
Bob Halley's avatar
Bob Halley committed
468 469 470 471 472 473 474
 *
 *	See the description of dns_db_find() for information about 'options'.
 *	If the caller sets DNS_DBFIND_GLUEOK, it must ensure that 'name'
 *	and 'type' are appropriate for glue retrieval.
 *
 *	If 'now' is zero, then the current time will be used.
 *
Bob Halley's avatar
Bob Halley committed
475 476
 *	If 'use_hints' is ISC_TRUE, and the view has a hints database, then
 *	it will be searched last.  If the answer is found in the hints
477 478 479
 *	database, the result code will be DNS_R_HINT.  If the name is found
 *	in the hints database but not the type, the result code will be
 *	DNS_R_HINTNXRRSET.
Bob Halley's avatar
Bob Halley committed
480
 *
Bob Halley's avatar
Bob Halley committed
481 482 483 484 485 486 487 488 489 490
 *	If 'sigrdataset' is not NULL, and there is a SIG rdataset which
 *	covers 'type', then 'sigrdataset' will be bound to it.
 *
 * Requires:
 *
 *	'view' is a valid, frozen view.
 *
 *	'name' is valid name.
 *
 *	'type' is a valid dns_rdatatype_t, and is not a meta query type
491
 *	(e.g. dns_rdatatype_any), or dns_rdatatype_rrsig.
Bob Halley's avatar
Bob Halley committed
492 493 494 495 496 497 498
 *
 *	'rdataset' is a valid, disassociated rdataset.
 *
 *	'sigrdataset' is NULL, or is a valid, disassociated rdataset.
 *
 * Ensures:
 *
499 500
 *	In successful cases, 'rdataset', and possibly 'sigrdataset', are
 *	bound to the found data.
Bob Halley's avatar
Bob Halley committed
501 502 503
 *
 * Returns:
 *
504
 *	ISC_R_SUCCESS			Success; result is desired type.
505 506 507 508
 *	DNS_R_GLUE			Success; result is glue.
 *	DNS_R_HINT			Success; result is a hint.
 *	DNS_R_NCACHENXDOMAIN		Success; result is a ncache entry.
 *	DNS_R_NCACHENXRRSET		Success; result is a ncache entry.
509 510
 *	DNS_R_NXDOMAIN			The name does not exist.
 *	DNS_R_NXRRSET			The rrset does not exist.
511 512
 *	ISC_R_NOTFOUND			No matching data found,
 *					or an error occurred.
Bob Halley's avatar
Bob Halley committed
513
 */
514

Bob Halley's avatar
Bob Halley committed
515 516 517 518 519
isc_result_t
dns_view_findzonecut(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
		     isc_stdtime_t now, unsigned int options,
		     isc_boolean_t use_hints,
		     dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
520 521 522 523 524 525

isc_result_t
dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
		      isc_stdtime_t now, unsigned int options,
		      isc_boolean_t use_hints, isc_boolean_t use_cache,
		      dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
Bob Halley's avatar
Bob Halley committed
526 527 528
/*
 * Find the best known zonecut containing 'name'.
 *
Andreas Gustafsson's avatar
Andreas Gustafsson committed
529 530 531
 * This uses local authority, cache, and optionally hints data.
 * No external queries are performed.
 *
Bob Halley's avatar
Bob Halley committed
532 533 534 535 536 537 538
 * Notes:
 *
 *	If 'now' is zero, then the current time will be used.
 *
 *	If 'use_hints' is ISC_TRUE, and the view has a hints database, then
 *	it will be searched last.
 *
539 540 541
 *	If 'use_cache' is ISC_TRUE, and the view has a cache, then it will be
 *	searched.
 *
Bob Halley's avatar
Bob Halley committed
542 543 544
 *	If 'sigrdataset' is not NULL, and there is a SIG rdataset which
 *	covers 'type', then 'sigrdataset' will be bound to it.
 *
Andreas Gustafsson's avatar
Andreas Gustafsson committed
545
 *	If the DNS_DBFIND_NOEXACT option is set, then the zonecut returned
546
 *	(if any) will be the deepest known ancestor of 'name'.
Andreas Gustafsson's avatar
Andreas Gustafsson committed
547
 *
Bob Halley's avatar
Bob Halley committed
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
 * Requires:
 *
 *	'view' is a valid, frozen view.
 *
 *	'name' is valid name.
 *
 *	'rdataset' is a valid, disassociated rdataset.
 *
 *	'sigrdataset' is NULL, or is a valid, disassociated rdataset.
 *
 * Returns:
 *
 *	ISC_R_SUCCESS				Success.
 *
 *	Many other results are possible.
 */

565 566 567
isc_result_t
dns_viewlist_find(dns_viewlist_t *list, const char *name,
		  dns_rdataclass_t rdclass, dns_view_t **viewp);
568
/*
569 570 571 572 573 574 575 576 577 578 579
 * Search for a view with name 'name' and class 'rdclass' in 'list'.
 * If found, '*viewp' is (strongly) attached to it.
 *
 * Requires:
 *
 *	'viewp' points to a NULL dns_view_t *.
 *
 * Returns:
 *
 *	ISC_R_SUCCESS		A matching view was found.
 *	ISC_R_NOTFOUND		No matching view was found.
580 581
 */

582
isc_result_t
583
dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep);
584
/*
585 586 587 588 589 590 591 592 593 594 595 596
 * Search for the zone 'name' in the zone table of 'view'.
 * If found, 'zonep' is (strongly) attached to it.  There
 * are no partial matches.
 *
 * Requires:
 *
 *	'zonep' points to a NULL dns_zone_t *.
 *
 * Returns:
 *	ISC_R_SUCCESS		A matching zone was found.
 *	ISC_R_NOTFOUND		No matching zone was found.
 *	others			An error occurred.
597 598
 */

599 600
isc_result_t
dns_view_load(dns_view_t *view, isc_boolean_t stop);
601 602 603

isc_result_t
dns_view_loadnew(dns_view_t *view, isc_boolean_t stop);
Mark Andrews's avatar
Mark Andrews committed
604
/*
605 606 607 608 609 610 611
 * Load zones attached to this view.  dns_view_load() loads
 * all zones whose master file has changed since the last
 * load; dns_view_loadnew() loads only zones that have never 
 * been loaded.
 *
 * If 'stop' is ISC_TRUE, stop on the first error and return it.
 * If 'stop' is ISC_FALSE, ignore errors.
Mark Andrews's avatar
Mark Andrews committed
612 613 614
 *
 * Requires:
 *
615
 *	'view' is valid.
Mark Andrews's avatar
Mark Andrews committed
616
 */
617

618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
isc_result_t
dns_view_gettsig(dns_view_t *view, dns_name_t *keyname,
		 dns_tsigkey_t **keyp);
/*
 * Find the TSIG key configured in 'view' with name 'keyname',
 * if any.
 *
 * Reqires:
 *	keyp points to a NULL dns_tsigkey_t *.
 *
 * Returns:
 *	ISC_R_SUCCESS	A key was found and '*keyp' now points to it.
 *	ISC_R_NOTFOUND	No key was found.
 *	others		An error occurred.
 */

isc_result_t
dns_view_getpeertsig(dns_view_t *view, isc_netaddr_t *peeraddr,
		     dns_tsigkey_t **keyp);
/*
 * Find the TSIG key configured in 'view' for the server whose
 * address is 'peeraddr', if any.
 *
 * Reqires:
 *	keyp points to a NULL dns_tsigkey_t *.
 *
 * Returns:
 *	ISC_R_SUCCESS	A key was found and '*keyp' now points to it.
 *	ISC_R_NOTFOUND	No key was found.
 *	others		An error occurred.
 */

Brian Wellington's avatar
Brian Wellington committed
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
isc_result_t
dns_view_checksig(dns_view_t *view, isc_buffer_t *source, dns_message_t *msg);
/*
 * Verifies the signature of a message.
 *
 * Requires:
 *
 *	'view' is a valid view.
 *	'source' is a valid buffer containing the message
 *	'msg' is a valid message
 *
 * Returns:
 *	see dns_tsig_verify()
 */

Mark Andrews's avatar
Mark Andrews committed
665 666
void
dns_view_dialup(dns_view_t *view);
667 668 669
/*
 * Perform dialup-time maintenance on the zones of 'view'.
 */
Mark Andrews's avatar
Mark Andrews committed
670

671
isc_result_t
672
dns_view_dumpdbtostream(dns_view_t *view, FILE *fp);
673
/*
674 675 676 677 678 679 680
 * Dump the current state of the view 'view' to the stream 'fp'
 * for purposes of analysis or debugging.
 *
 * Currently the dumped state includes the view's cache; in the future
 * it may also include other state such as the address database.
 * It will not not include authoritative data since it is voluminous and
 * easily obtainable by other means.
681 682 683 684 685
 *
 * Requires:
 * 	
 *	'view' is valid.
 *
686
 *	'fp' refers to a file open for writing.
687 688 689 690 691 692
 *
 * Returns:
 * 	ISC_R_SUCCESS	The cache was successfully dumped.
 * 	others		An error occurred (see dns_master_dump)
 */

693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
isc_result_t
dns_view_flushcache(dns_view_t *view);
/*
 * Flush the view's cache (and ADB).
 *
 * Requires:
 * 	'view' is valid.
 *
 * 	No other tasks are executing.
 *
 * Returns:
 *	ISC_R_SUCCESS
 *	ISC_R_NOMEMORY
 */

708 709 710 711 712 713 714 715 716 717 718 719 720 721
isc_result_t
dns_view_flushname(dns_view_t *view, dns_name_t *);
/*
 * Flush the given name from the view's cache (and ADB).
 *
 * Requires:
 *	'view' is valid.
 *	'name' is valid.
 *
 * Returns:
 *	ISC_R_SUCCESS
 *	other returns are failures.
 */

722 723 724 725
isc_result_t
dns_view_adddelegationonly(dns_view_t *view, dns_name_t *name);
/*
 * Add the given name to the delegation only table.
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
 * 
 *
 * Requires:
 *	'view' is valid.
 *	'name' is valid.
 *
 * Returns:
 *	ISC_R_SUCCESS
 *	ISC_R_NOMEMORY
 */

isc_result_t
dns_view_excludedelegationonly(dns_view_t *view, dns_name_t *name);
/*
 * Add the given name to be excluded from the root-delegation-only.
 * 
742 743 744 745 746 747 748 749 750 751 752 753 754
 *
 * Requires:
 *	'view' is valid.
 *	'name' is valid.
 *
 * Returns:
 *	ISC_R_SUCCESS
 *	ISC_R_NOMEMORY
 */

isc_boolean_t
dns_view_isdelegationonly(dns_view_t *view, dns_name_t *name);
/*
755 756
 * Check if 'name' is in the delegation only table or if
 * rootdelonly is set that name is not being excluded.
757 758 759 760 761 762 763 764 765 766
 *
 * Requires:
 *	'view' is valid.
 *	'name' is valid.
 *
 * Returns:
 *	ISC_TRUE if the name is is the table.
 *	ISC_FALSE othewise.
 */

767 768 769 770 771 772 773 774
void
dns_view_setrootdelonly(dns_view_t *view, isc_boolean_t value);
/*
 * Set the root delegation only flag.
 *
 * Requires:
 *	'view' is valid.
 */
775

776 777 778 779 780 781 782 783
isc_boolean_t
dns_view_getrootdelonly(dns_view_t *view);
/*
 * Get the root delegation only flag.
 *
 * Requires:
 *	'view' is valid.
 */
Bob Halley's avatar
add  
Bob Halley committed
784 785

#endif /* DNS_VIEW_H */