1135446Strhodes/*
2254402Serwin * Copyright (C) 2004-2013  Internet Systems Consortium, Inc. ("ISC")
3135446Strhodes * Copyright (C) 1999-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
18234010Sdougb/* $Id$ */
19135446Strhodes
20135446Strhodes#ifndef DNS_VIEW_H
21135446Strhodes#define DNS_VIEW_H 1
22135446Strhodes
23135446Strhodes/*****
24135446Strhodes ***** Module Info
25135446Strhodes *****/
26135446Strhodes
27193149Sdougb/*! \file dns/view.h
28170222Sdougb * \brief
29135446Strhodes * DNS View
30135446Strhodes *
31135446Strhodes * A "view" is a DNS namespace, together with an optional resolver and a
32135446Strhodes * forwarding policy.  A "DNS namespace" is a (possibly empty) set of
33135446Strhodes * authoritative zones together with an optional cache and optional
34135446Strhodes * "hints" information.
35135446Strhodes *
36135446Strhodes * Views start out "unfrozen".  In this state, core attributes like
37135446Strhodes * the cache, set of zones, and forwarding policy may be set.  While
38135446Strhodes * "unfrozen", the caller (e.g. nameserver configuration loading
39135446Strhodes * code), must ensure exclusive access to the view.  When the view is
40135446Strhodes * "frozen", the core attributes become immutable, and the view module
41135446Strhodes * will ensure synchronization.  Freezing allows the view's core attributes
42135446Strhodes * to be accessed without locking.
43135446Strhodes *
44135446Strhodes * MP:
45170222Sdougb *\li	Before the view is frozen, the caller must ensure synchronization.
46135446Strhodes *
47170222Sdougb *\li	After the view is frozen, the module guarantees appropriate
48135446Strhodes *	synchronization of any data structures it creates and manipulates.
49135446Strhodes *
50135446Strhodes * Reliability:
51170222Sdougb *\li	No anticipated impact.
52135446Strhodes *
53135446Strhodes * Resources:
54170222Sdougb *\li	TBS
55135446Strhodes *
56135446Strhodes * Security:
57170222Sdougb *\li	No anticipated impact.
58135446Strhodes *
59135446Strhodes * Standards:
60170222Sdougb *\li	None.
61135446Strhodes */
62135446Strhodes
63135446Strhodes#include <stdio.h>
64135446Strhodes
65135446Strhodes#include <isc/lang.h>
66135446Strhodes#include <isc/magic.h>
67135446Strhodes#include <isc/event.h>
68135446Strhodes#include <isc/mutex.h>
69135446Strhodes#include <isc/net.h>
70135446Strhodes#include <isc/refcount.h>
71135446Strhodes#include <isc/rwlock.h>
72135446Strhodes#include <isc/stdtime.h>
73135446Strhodes
74135446Strhodes#include <dns/acl.h>
75135446Strhodes#include <dns/fixedname.h>
76262706Serwin#include <dns/rrl.h>
77224092Sdougb#include <dns/rdatastruct.h>
78224092Sdougb#include <dns/rpz.h>
79135446Strhodes#include <dns/types.h>
80254897Serwin#include <dns/zt.h>
81135446Strhodes
82135446StrhodesISC_LANG_BEGINDECLS
83135446Strhodes
84135446Strhodesstruct dns_view {
85135446Strhodes	/* Unlocked. */
86135446Strhodes	unsigned int			magic;
87135446Strhodes	isc_mem_t *			mctx;
88135446Strhodes	dns_rdataclass_t		rdclass;
89135446Strhodes	char *				name;
90135446Strhodes	dns_zt_t *			zonetable;
91170222Sdougb	dns_dlzdb_t *			dlzdatabase;
92135446Strhodes	dns_resolver_t *		resolver;
93135446Strhodes	dns_adb_t *			adb;
94135446Strhodes	dns_requestmgr_t *		requestmgr;
95170222Sdougb	dns_acache_t *			acache;
96135446Strhodes	dns_cache_t *			cache;
97135446Strhodes	dns_db_t *			cachedb;
98135446Strhodes	dns_db_t *			hints;
99224092Sdougb
100224092Sdougb	/*
101224092Sdougb	 * security roots.
102224092Sdougb	 * internal use only; access via * dns_view_getsecroots()
103224092Sdougb	 */
104224092Sdougb	dns_keytable_t *		secroots_priv;
105224092Sdougb
106135446Strhodes	isc_mutex_t			lock;
107135446Strhodes	isc_boolean_t			frozen;
108135446Strhodes	isc_task_t *			task;
109135446Strhodes	isc_event_t			resevent;
110135446Strhodes	isc_event_t			adbevent;
111135446Strhodes	isc_event_t			reqevent;
112193149Sdougb	isc_stats_t *			resstats;
113193149Sdougb	dns_stats_t *			resquerystats;
114224092Sdougb	isc_boolean_t			cacheshared;
115193149Sdougb
116135446Strhodes	/* Configurable data. */
117135446Strhodes	dns_tsig_keyring_t *		statickeys;
118135446Strhodes	dns_tsig_keyring_t *		dynamickeys;
119135446Strhodes	dns_peerlist_t *		peers;
120135446Strhodes	dns_order_t *			order;
121135446Strhodes	dns_fwdtable_t *		fwdtable;
122135446Strhodes	isc_boolean_t			recursion;
123135446Strhodes	isc_boolean_t			auth_nxdomain;
124135446Strhodes	isc_boolean_t			additionalfromcache;
125135446Strhodes	isc_boolean_t			additionalfromauth;
126135446Strhodes	isc_boolean_t			minimalresponses;
127135446Strhodes	isc_boolean_t			enablednssec;
128170222Sdougb	isc_boolean_t			enablevalidation;
129170222Sdougb	isc_boolean_t			acceptexpired;
130135446Strhodes	dns_transfer_format_t		transfer_format;
131216175Sdougb	dns_acl_t *			cacheacl;
132216175Sdougb	dns_acl_t *			cacheonacl;
133135446Strhodes	dns_acl_t *			queryacl;
134193149Sdougb	dns_acl_t *			queryonacl;
135135446Strhodes	dns_acl_t *			recursionacl;
136193149Sdougb	dns_acl_t *			recursiononacl;
137135446Strhodes	dns_acl_t *			sortlist;
138193149Sdougb	dns_acl_t *			notifyacl;
139193149Sdougb	dns_acl_t *			transferacl;
140193149Sdougb	dns_acl_t *			updateacl;
141193149Sdougb	dns_acl_t *			upfwdacl;
142224092Sdougb	dns_acl_t *			denyansweracl;
143224092Sdougb	dns_rbt_t *			answeracl_exclude;
144224092Sdougb	dns_rbt_t *			denyanswernames;
145224092Sdougb	dns_rbt_t *			answernames_exclude;
146262706Serwin	dns_rrl_t *			rrl;
147135446Strhodes	isc_boolean_t			provideixfr;
148193149Sdougb	isc_boolean_t			requestnsid;
149135446Strhodes	dns_ttl_t			maxcachettl;
150135446Strhodes	dns_ttl_t			maxncachettl;
151135446Strhodes	in_port_t			dstport;
152135446Strhodes	dns_aclenv_t			aclenv;
153135446Strhodes	dns_rdatatype_t			preferred_glue;
154135446Strhodes	isc_boolean_t			flush;
155135446Strhodes	dns_namelist_t *		delonly;
156135446Strhodes	isc_boolean_t			rootdelonly;
157135446Strhodes	dns_namelist_t *		rootexclude;
158135446Strhodes	isc_boolean_t			checknames;
159135446Strhodes	dns_name_t *			dlv;
160135446Strhodes	dns_fixedname_t			dlv_fixed;
161170222Sdougb	isc_uint16_t			maxudp;
162254897Serwin	unsigned int			maxbits;
163224092Sdougb	dns_v4_aaaa_t			v4_aaaa;
164224092Sdougb	dns_acl_t *			v4_aaaa_acl;
165224092Sdougb	dns_dns64list_t 		dns64;
166224092Sdougb	unsigned int 			dns64cnt;
167224092Sdougb	ISC_LIST(dns_rpz_zone_t)	rpz_zones;
168245163Serwin	isc_boolean_t			rpz_recursive_only;
169245163Serwin	isc_boolean_t			rpz_break_dnssec;
170254402Serwin	unsigned int			rpz_min_ns_labels;
171135446Strhodes
172135446Strhodes	/*
173135446Strhodes	 * Configurable data for server use only,
174135446Strhodes	 * locked by server configuration lock.
175135446Strhodes	 */
176135446Strhodes	dns_acl_t *			matchclients;
177135446Strhodes	dns_acl_t *			matchdestinations;
178135446Strhodes	isc_boolean_t			matchrecursiveonly;
179135446Strhodes
180135446Strhodes	/* Locked by themselves. */
181135446Strhodes	isc_refcount_t			references;
182135446Strhodes
183135446Strhodes	/* Locked by lock. */
184135446Strhodes	unsigned int			weakrefs;
185135446Strhodes	unsigned int			attributes;
186135446Strhodes	/* Under owner's locking control. */
187135446Strhodes	ISC_LINK(struct dns_view)	link;
188224092Sdougb	dns_viewlist_t *		viewlist;
189224092Sdougb
190224092Sdougb	dns_zone_t *			managed_keys;
191254897Serwin	dns_zone_t *			redirect;
192224092Sdougb
193224092Sdougb#ifdef BIND9
194224092Sdougb	/* File in which to store configuration for newly added zones */
195224092Sdougb	char *				new_zone_file;
196224092Sdougb
197224092Sdougb	void *				new_zone_config;
198224092Sdougb	void				(*cfg_destroy)(void **);
199224092Sdougb#endif
200135446Strhodes};
201135446Strhodes
202135446Strhodes#define DNS_VIEW_MAGIC			ISC_MAGIC('V','i','e','w')
203135446Strhodes#define DNS_VIEW_VALID(view)		ISC_MAGIC_VALID(view, DNS_VIEW_MAGIC)
204135446Strhodes
205135446Strhodes#define DNS_VIEWATTR_RESSHUTDOWN	0x01
206135446Strhodes#define DNS_VIEWATTR_ADBSHUTDOWN	0x02
207135446Strhodes#define DNS_VIEWATTR_REQSHUTDOWN	0x04
208135446Strhodes
209135446Strhodesisc_result_t
210135446Strhodesdns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
211135446Strhodes		const char *name, dns_view_t **viewp);
212170222Sdougb/*%<
213135446Strhodes * Create a view.
214135446Strhodes *
215135446Strhodes * Notes:
216135446Strhodes *
217170222Sdougb *\li	The newly created view has no cache, no resolver, and an empty
218135446Strhodes *	zone table.  The view is not frozen.
219135446Strhodes *
220135446Strhodes * Requires:
221135446Strhodes *
222170222Sdougb *\li	'mctx' is a valid memory context.
223135446Strhodes *
224170222Sdougb *\li	'rdclass' is a valid class.
225135446Strhodes *
226170222Sdougb *\li	'name' is a valid C string.
227135446Strhodes *
228170222Sdougb *\li	viewp != NULL && *viewp == NULL
229135446Strhodes *
230135446Strhodes * Returns:
231135446Strhodes *
232170222Sdougb *\li	#ISC_R_SUCCESS
233170222Sdougb *\li	#ISC_R_NOMEMORY
234135446Strhodes *
235170222Sdougb *\li	Other errors are possible.
236135446Strhodes */
237135446Strhodes
238135446Strhodesvoid
239135446Strhodesdns_view_attach(dns_view_t *source, dns_view_t **targetp);
240170222Sdougb/*%<
241135446Strhodes * Attach '*targetp' to 'source'.
242135446Strhodes *
243135446Strhodes * Requires:
244135446Strhodes *
245170222Sdougb *\li	'source' is a valid, frozen view.
246135446Strhodes *
247170222Sdougb *\li	'targetp' points to a NULL dns_view_t *.
248135446Strhodes *
249135446Strhodes * Ensures:
250135446Strhodes *
251170222Sdougb *\li	*targetp is attached to source.
252135446Strhodes *
253170222Sdougb *\li	While *targetp is attached, the view will not shut down.
254135446Strhodes */
255135446Strhodes
256135446Strhodesvoid
257135446Strhodesdns_view_detach(dns_view_t **viewp);
258170222Sdougb/*%<
259135446Strhodes * Detach '*viewp' from its view.
260135446Strhodes *
261135446Strhodes * Requires:
262135446Strhodes *
263170222Sdougb *\li	'viewp' points to a valid dns_view_t *
264135446Strhodes *
265135446Strhodes * Ensures:
266135446Strhodes *
267170222Sdougb *\li	*viewp is NULL.
268135446Strhodes */
269135446Strhodes
270135446Strhodesvoid
271135446Strhodesdns_view_flushanddetach(dns_view_t **viewp);
272170222Sdougb/*%<
273135446Strhodes * Detach '*viewp' from its view.  If this was the last reference
274193149Sdougb * uncommitted changed in zones will be flushed to disk.
275135446Strhodes *
276135446Strhodes * Requires:
277135446Strhodes *
278170222Sdougb *\li	'viewp' points to a valid dns_view_t *
279135446Strhodes *
280135446Strhodes * Ensures:
281135446Strhodes *
282170222Sdougb *\li	*viewp is NULL.
283135446Strhodes */
284135446Strhodes
285135446Strhodesvoid
286135446Strhodesdns_view_weakattach(dns_view_t *source, dns_view_t **targetp);
287170222Sdougb/*%<
288135446Strhodes * Weakly attach '*targetp' to 'source'.
289135446Strhodes *
290135446Strhodes * Requires:
291135446Strhodes *
292170222Sdougb *\li	'source' is a valid, frozen view.
293135446Strhodes *
294170222Sdougb *\li	'targetp' points to a NULL dns_view_t *.
295135446Strhodes *
296135446Strhodes * Ensures:
297135446Strhodes *
298170222Sdougb *\li	*targetp is attached to source.
299135446Strhodes *
300170222Sdougb * \li	While *targetp is attached, the view will not be freed.
301135446Strhodes */
302135446Strhodes
303135446Strhodesvoid
304135446Strhodesdns_view_weakdetach(dns_view_t **targetp);
305170222Sdougb/*%<
306135446Strhodes * Detach '*viewp' from its view.
307135446Strhodes *
308135446Strhodes * Requires:
309135446Strhodes *
310170222Sdougb *\li	'viewp' points to a valid dns_view_t *.
311135446Strhodes *
312135446Strhodes * Ensures:
313135446Strhodes *
314170222Sdougb *\li	*viewp is NULL.
315135446Strhodes */
316135446Strhodes
317135446Strhodesisc_result_t
318135446Strhodesdns_view_createresolver(dns_view_t *view,
319254897Serwin			isc_taskmgr_t *taskmgr,
320254897Serwin			unsigned int ntasks, unsigned int ndisp,
321135446Strhodes			isc_socketmgr_t *socketmgr,
322135446Strhodes			isc_timermgr_t *timermgr,
323135446Strhodes			unsigned int options,
324135446Strhodes			dns_dispatchmgr_t *dispatchmgr,
325135446Strhodes			dns_dispatch_t *dispatchv4,
326135446Strhodes			dns_dispatch_t *dispatchv6);
327170222Sdougb/*%<
328135446Strhodes * Create a resolver and address database for the view.
329135446Strhodes *
330135446Strhodes * Requires:
331135446Strhodes *
332170222Sdougb *\li	'view' is a valid, unfrozen view.
333135446Strhodes *
334170222Sdougb *\li	'view' does not have a resolver already.
335135446Strhodes *
336170222Sdougb *\li	The requirements of dns_resolver_create() apply to 'taskmgr',
337135446Strhodes *	'ntasks', 'socketmgr', 'timermgr', 'options', 'dispatchv4', and
338135446Strhodes *	'dispatchv6'.
339135446Strhodes *
340135446Strhodes * Returns:
341135446Strhodes *
342170222Sdougb *\li   	#ISC_R_SUCCESS
343135446Strhodes *
344170222Sdougb *\li	Any error that dns_resolver_create() can return.
345135446Strhodes */
346135446Strhodes
347135446Strhodesvoid
348135446Strhodesdns_view_setcache(dns_view_t *view, dns_cache_t *cache);
349224092Sdougbvoid
350224092Sdougbdns_view_setcache2(dns_view_t *view, dns_cache_t *cache, isc_boolean_t shared);
351170222Sdougb/*%<
352224092Sdougb * Set the view's cache database.  If 'shared' is true, this means the cache
353224092Sdougb * is created by another view and is shared with that view.  dns_view_setcache()
354224092Sdougb * is a backward compatible version equivalent to setcache2(..., ISC_FALSE).
355135446Strhodes *
356135446Strhodes * Requires:
357135446Strhodes *
358170222Sdougb *\li	'view' is a valid, unfrozen view.
359135446Strhodes *
360170222Sdougb *\li	'cache' is a valid cache.
361135446Strhodes *
362135446Strhodes * Ensures:
363135446Strhodes *
364170222Sdougb * \li    	The cache of 'view' is 'cached.
365135446Strhodes *
366170222Sdougb *\li	If this is not the first call to dns_view_setcache() for this
367135446Strhodes *	view, then previously set cache is detached.
368135446Strhodes */
369135446Strhodes
370135446Strhodesvoid
371135446Strhodesdns_view_sethints(dns_view_t *view, dns_db_t *hints);
372170222Sdougb/*%<
373135446Strhodes * Set the view's hints database.
374135446Strhodes *
375135446Strhodes * Requires:
376135446Strhodes *
377170222Sdougb *\li	'view' is a valid, unfrozen view, whose hints database has not been
378135446Strhodes *	set.
379135446Strhodes *
380170222Sdougb *\li	'hints' is a valid zone database.
381135446Strhodes *
382135446Strhodes * Ensures:
383135446Strhodes *
384170222Sdougb * \li    	The hints database of 'view' is 'hints'.
385135446Strhodes */
386135446Strhodes
387135446Strhodesvoid
388135446Strhodesdns_view_setkeyring(dns_view_t *view, dns_tsig_keyring_t *ring);
389224092Sdougbvoid
390224092Sdougbdns_view_setdynamickeyring(dns_view_t *view, dns_tsig_keyring_t *ring);
391170222Sdougb/*%<
392135446Strhodes * Set the view's static TSIG keys
393135446Strhodes *
394135446Strhodes * Requires:
395135446Strhodes *
396170222Sdougb *   \li   'view' is a valid, unfrozen view, whose static TSIG keyring has not
397135446Strhodes *	been set.
398135446Strhodes *
399170222Sdougb *\li      'ring' is a valid TSIG keyring
400135446Strhodes *
401135446Strhodes * Ensures:
402135446Strhodes *
403170222Sdougb *\li      The static TSIG keyring of 'view' is 'ring'.
404135446Strhodes */
405135446Strhodes
406135446Strhodesvoid
407224092Sdougbdns_view_getdynamickeyring(dns_view_t *view, dns_tsig_keyring_t **ringp);
408224092Sdougb/*%<
409224092Sdougb * Return the views dynamic keys.
410224092Sdougb *
411224092Sdougb *   \li  'view' is a valid, unfrozen view.
412224092Sdougb *   \li  'ringp' != NULL && ringp == NULL.
413224092Sdougb */
414224092Sdougb
415224092Sdougbvoid
416135446Strhodesdns_view_setdstport(dns_view_t *view, in_port_t dstport);
417170222Sdougb/*%<
418135446Strhodes * Set the view's destination port.  This is the port to
419135446Strhodes * which outgoing queries are sent.  The default is 53,
420135446Strhodes * the standard DNS port.
421135446Strhodes *
422135446Strhodes * Requires:
423135446Strhodes *
424170222Sdougb *\li      'view' is a valid view.
425135446Strhodes *
426170222Sdougb *\li      'dstport' is a valid TCP/UDP port number.
427135446Strhodes *
428135446Strhodes * Ensures:
429193149Sdougb *\li	External name servers will be assumed to be listening
430135446Strhodes *	on 'dstport'.  For servers whose address has already
431135446Strhodes *	obtained obtained at the time of the call, the view may
432135446Strhodes *	continue to use the previously set port until the address
433135446Strhodes *	times out from the view's address database.
434135446Strhodes */
435135446Strhodes
436135446Strhodes
437135446Strhodesisc_result_t
438135446Strhodesdns_view_addzone(dns_view_t *view, dns_zone_t *zone);
439170222Sdougb/*%<
440135446Strhodes * Add zone 'zone' to 'view'.
441135446Strhodes *
442135446Strhodes * Requires:
443135446Strhodes *
444170222Sdougb *\li	'view' is a valid, unfrozen view.
445135446Strhodes *
446170222Sdougb *\li	'zone' is a valid zone.
447135446Strhodes */
448135446Strhodes
449135446Strhodesvoid
450135446Strhodesdns_view_freeze(dns_view_t *view);
451170222Sdougb/*%<
452224092Sdougb * Freeze view.  No changes can be made to view configuration while frozen.
453135446Strhodes *
454135446Strhodes * Requires:
455135446Strhodes *
456170222Sdougb *\li	'view' is a valid, unfrozen view.
457135446Strhodes *
458135446Strhodes * Ensures:
459135446Strhodes *
460170222Sdougb *\li	'view' is frozen.
461135446Strhodes */
462135446Strhodes
463224092Sdougbvoid
464224092Sdougbdns_view_thaw(dns_view_t *view);
465224092Sdougb/*%<
466224092Sdougb * Thaw view.  This allows zones to be added or removed at runtime.  This is
467224092Sdougb * NOT thread-safe; the caller MUST have run isc_task_exclusive() prior to
468224092Sdougb * thawing the view.
469224092Sdougb *
470224092Sdougb * Requires:
471224092Sdougb *
472224092Sdougb *\li	'view' is a valid, frozen view.
473224092Sdougb *
474224092Sdougb * Ensures:
475224092Sdougb *
476224092Sdougb *\li	'view' is no longer frozen.
477224092Sdougb */
478135446Strhodesisc_result_t
479135446Strhodesdns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
480135446Strhodes	      isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints,
481135446Strhodes	      dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname,
482135446Strhodes	      dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
483224092Sdougbisc_result_t
484224092Sdougbdns_view_find2(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
485224092Sdougb	       isc_stdtime_t now, unsigned int options,
486224092Sdougb	       isc_boolean_t use_hints, isc_boolean_t use_static_stub,
487224092Sdougb	       dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname,
488224092Sdougb	       dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
489170222Sdougb/*%<
490135446Strhodes * Find an rdataset whose owner name is 'name', and whose type is
491135446Strhodes * 'type'.
492224092Sdougb * In general, this function first searches view's zone and cache DBs for the
493224092Sdougb * best match data against 'name'.  If nothing found there, and if 'use_hints'
494224092Sdougb * is ISC_TRUE, the view's hint DB (if configured) is searched.
495224092Sdougb * If the view is configured with a static-stub zone which gives the longest
496224092Sdougb * match for 'name' among the zones, however, the cache DB is not consulted
497224092Sdougb * unless 'use_static_stub' is ISC_FALSE (see below about this argument).
498135446Strhodes *
499224092Sdougb * dns_view_find() is a backward compatible version equivalent to
500224092Sdougb * dns_view_find2() with use_static_stub argument being ISC_FALSE.
501224092Sdougb *
502135446Strhodes * Notes:
503135446Strhodes *
504170222Sdougb *\li	See the description of dns_db_find() for information about 'options'.
505170222Sdougb *	If the caller sets #DNS_DBFIND_GLUEOK, it must ensure that 'name'
506135446Strhodes *	and 'type' are appropriate for glue retrieval.
507135446Strhodes *
508170222Sdougb *\li	If 'now' is zero, then the current time will be used.
509135446Strhodes *
510170222Sdougb *\li	If 'use_hints' is ISC_TRUE, and the view has a hints database, then
511135446Strhodes *	it will be searched last.  If the answer is found in the hints
512135446Strhodes *	database, the result code will be DNS_R_HINT.  If the name is found
513135446Strhodes *	in the hints database but not the type, the result code will be
514170222Sdougb *	#DNS_R_HINTNXRRSET.
515135446Strhodes *
516224092Sdougb *\li	If 'use_static_stub' is ISC_FALSE and the longest match zone for 'name'
517224092Sdougb *	is a static-stub zone, it's ignored and the cache and/or hints will be
518224092Sdougb *	searched.  In the majority of the cases this argument should be
519224092Sdougb *	ISC_FALSE.  The only known usage of this argument being ISC_TRUE is
520224092Sdougb *	if this search is for a "bailiwick" glue A or AAAA RRset that may
521224092Sdougb *	best match a static-stub zone.  Consider the following example:
522224092Sdougb *	this view is configured with a static-stub zone "example.com",
523224092Sdougb *	and an attempt of recursive resolution needs to send a query for the
524224092Sdougb *	zone.  In this case it's quite likely that the resolver is trying to
525224092Sdougb *	find A/AAAA RRs for the apex name "example.com".  And, to honor the
526224092Sdougb *	static-stub configuration it needs to return the glue RRs in the
527224092Sdougb *	static-stub zone even if that exact RRs coming from the authoritative
528224092Sdougb *	zone has been cached.
529224092Sdougb *	In other general cases, the requested data is better to be
530224092Sdougb *	authoritative, either locally configured or retrieved from an external
531224092Sdougb *	server, and the data in the static-stub zone should better be ignored.
532224092Sdougb *
533170222Sdougb *\li	'foundname' must meet the requirements of dns_db_find().
534135446Strhodes *
535170222Sdougb *\li	If 'sigrdataset' is not NULL, and there is a SIG rdataset which
536135446Strhodes *	covers 'type', then 'sigrdataset' will be bound to it.
537135446Strhodes *
538135446Strhodes * Requires:
539135446Strhodes *
540170222Sdougb *\li	'view' is a valid, frozen view.
541135446Strhodes *
542170222Sdougb *\li	'name' is valid name.
543135446Strhodes *
544170222Sdougb *\li	'type' is a valid dns_rdatatype_t, and is not a meta query type
545135446Strhodes *	except dns_rdatatype_any.
546135446Strhodes *
547170222Sdougb *\li	dbp == NULL || *dbp == NULL
548135446Strhodes *
549170222Sdougb *\li	nodep == NULL || *nodep == NULL.  If nodep != NULL, dbp != NULL.
550135446Strhodes *
551170222Sdougb *\li	'foundname' is a valid name with a dedicated buffer or NULL.
552135446Strhodes *
553170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
554135446Strhodes *
555170222Sdougb *\li	'sigrdataset' is NULL, or is a valid, disassociated rdataset.
556135446Strhodes *
557135446Strhodes * Ensures:
558135446Strhodes *
559170222Sdougb *\li	In successful cases, 'rdataset', and possibly 'sigrdataset', are
560135446Strhodes *	bound to the found data.
561135446Strhodes *
562170222Sdougb *\li	If dbp != NULL, it points to the database containing the data.
563135446Strhodes *
564170222Sdougb *\li	If nodep != NULL, it points to the database node containing the data.
565135446Strhodes *
566170222Sdougb *\li	If foundname != NULL, it contains the full name of the found data.
567135446Strhodes *
568135446Strhodes * Returns:
569135446Strhodes *
570170222Sdougb *\li	Any result that dns_db_find() can return, with the exception of
571170222Sdougb *	#DNS_R_DELEGATION.
572135446Strhodes */
573135446Strhodes
574135446Strhodesisc_result_t
575135446Strhodesdns_view_simplefind(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
576135446Strhodes		    isc_stdtime_t now, unsigned int options,
577135446Strhodes		    isc_boolean_t use_hints,
578135446Strhodes		    dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
579170222Sdougb/*%<
580135446Strhodes * Find an rdataset whose owner name is 'name', and whose type is
581135446Strhodes * 'type'.
582135446Strhodes *
583135446Strhodes * Notes:
584135446Strhodes *
585170222Sdougb *\li	This routine is appropriate for simple, exact-match queries of the
586135446Strhodes *	view.  'name' must be a canonical name; there is no DNAME or CNAME
587135446Strhodes *	processing.
588135446Strhodes *
589170222Sdougb *\li	See the description of dns_db_find() for information about 'options'.
590135446Strhodes *	If the caller sets DNS_DBFIND_GLUEOK, it must ensure that 'name'
591135446Strhodes *	and 'type' are appropriate for glue retrieval.
592135446Strhodes *
593170222Sdougb *\li	If 'now' is zero, then the current time will be used.
594135446Strhodes *
595170222Sdougb *\li	If 'use_hints' is ISC_TRUE, and the view has a hints database, then
596135446Strhodes *	it will be searched last.  If the answer is found in the hints
597135446Strhodes *	database, the result code will be DNS_R_HINT.  If the name is found
598135446Strhodes *	in the hints database but not the type, the result code will be
599135446Strhodes *	DNS_R_HINTNXRRSET.
600135446Strhodes *
601170222Sdougb *\li	If 'sigrdataset' is not NULL, and there is a SIG rdataset which
602135446Strhodes *	covers 'type', then 'sigrdataset' will be bound to it.
603135446Strhodes *
604135446Strhodes * Requires:
605135446Strhodes *
606170222Sdougb *\li	'view' is a valid, frozen view.
607135446Strhodes *
608170222Sdougb *\li	'name' is valid name.
609135446Strhodes *
610170222Sdougb *\li	'type' is a valid dns_rdatatype_t, and is not a meta query type
611135446Strhodes *	(e.g. dns_rdatatype_any), or dns_rdatatype_rrsig.
612135446Strhodes *
613170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
614135446Strhodes *
615170222Sdougb *\li	'sigrdataset' is NULL, or is a valid, disassociated rdataset.
616135446Strhodes *
617135446Strhodes * Ensures:
618135446Strhodes *
619170222Sdougb *\li	In successful cases, 'rdataset', and possibly 'sigrdataset', are
620135446Strhodes *	bound to the found data.
621135446Strhodes *
622135446Strhodes * Returns:
623135446Strhodes *
624170222Sdougb *\li	#ISC_R_SUCCESS			Success; result is desired type.
625170222Sdougb *\li	DNS_R_GLUE			Success; result is glue.
626170222Sdougb *\li	DNS_R_HINT			Success; result is a hint.
627170222Sdougb *\li	DNS_R_NCACHENXDOMAIN		Success; result is a ncache entry.
628170222Sdougb *\li	DNS_R_NCACHENXRRSET		Success; result is a ncache entry.
629170222Sdougb *\li	DNS_R_NXDOMAIN			The name does not exist.
630170222Sdougb *\li	DNS_R_NXRRSET			The rrset does not exist.
631170222Sdougb *\li	#ISC_R_NOTFOUND			No matching data found,
632135446Strhodes *					or an error occurred.
633135446Strhodes */
634135446Strhodes
635170222Sdougb/*% See dns_view_findzonecut2() */
636135446Strhodesisc_result_t
637135446Strhodesdns_view_findzonecut(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
638135446Strhodes		     isc_stdtime_t now, unsigned int options,
639135446Strhodes		     isc_boolean_t use_hints,
640135446Strhodes		     dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
641135446Strhodes
642135446Strhodesisc_result_t
643135446Strhodesdns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
644135446Strhodes		      isc_stdtime_t now, unsigned int options,
645135446Strhodes		      isc_boolean_t use_hints, isc_boolean_t use_cache,
646135446Strhodes		      dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
647170222Sdougb/*%<
648135446Strhodes * Find the best known zonecut containing 'name'.
649135446Strhodes *
650135446Strhodes * This uses local authority, cache, and optionally hints data.
651135446Strhodes * No external queries are performed.
652135446Strhodes *
653135446Strhodes * Notes:
654135446Strhodes *
655170222Sdougb *\li	If 'now' is zero, then the current time will be used.
656135446Strhodes *
657170222Sdougb *\li	If 'use_hints' is ISC_TRUE, and the view has a hints database, then
658135446Strhodes *	it will be searched last.
659135446Strhodes *
660170222Sdougb *\li	If 'use_cache' is ISC_TRUE, and the view has a cache, then it will be
661135446Strhodes *	searched.
662135446Strhodes *
663170222Sdougb *\li	If 'sigrdataset' is not NULL, and there is a SIG rdataset which
664135446Strhodes *	covers 'type', then 'sigrdataset' will be bound to it.
665135446Strhodes *
666170222Sdougb *\li	If the DNS_DBFIND_NOEXACT option is set, then the zonecut returned
667135446Strhodes *	(if any) will be the deepest known ancestor of 'name'.
668135446Strhodes *
669135446Strhodes * Requires:
670135446Strhodes *
671170222Sdougb *\li	'view' is a valid, frozen view.
672135446Strhodes *
673170222Sdougb *\li	'name' is valid name.
674135446Strhodes *
675170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
676135446Strhodes *
677170222Sdougb *\li	'sigrdataset' is NULL, or is a valid, disassociated rdataset.
678135446Strhodes *
679135446Strhodes * Returns:
680135446Strhodes *
681170222Sdougb *\li	#ISC_R_SUCCESS				Success.
682135446Strhodes *
683170222Sdougb *\li	Many other results are possible.
684135446Strhodes */
685135446Strhodes
686135446Strhodesisc_result_t
687135446Strhodesdns_viewlist_find(dns_viewlist_t *list, const char *name,
688135446Strhodes		  dns_rdataclass_t rdclass, dns_view_t **viewp);
689170222Sdougb/*%<
690135446Strhodes * Search for a view with name 'name' and class 'rdclass' in 'list'.
691135446Strhodes * If found, '*viewp' is (strongly) attached to it.
692135446Strhodes *
693135446Strhodes * Requires:
694135446Strhodes *
695170222Sdougb *\li	'viewp' points to a NULL dns_view_t *.
696135446Strhodes *
697135446Strhodes * Returns:
698135446Strhodes *
699170222Sdougb *\li	#ISC_R_SUCCESS		A matching view was found.
700170222Sdougb *\li	#ISC_R_NOTFOUND		No matching view was found.
701135446Strhodes */
702135446Strhodes
703135446Strhodesisc_result_t
704193149Sdougbdns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name, isc_boolean_t allclasses,
705193149Sdougb		      dns_rdataclass_t rdclass, dns_zone_t **zonep);
706193149Sdougb
707193149Sdougb/*%<
708193149Sdougb * Search zone with 'name' in view with 'rdclass' in viewlist 'list'
709193149Sdougb * If found, zone is returned in *zonep. If allclasses is set rdclass is ignored
710193149Sdougb *
711193149Sdougb * Returns:
712193149Sdougb *\li	#ISC_R_SUCCESS          A matching zone was found.
713193149Sdougb *\li	#ISC_R_NOTFOUND         No matching zone was found.
714193149Sdougb */
715193149Sdougb
716193149Sdougbisc_result_t
717135446Strhodesdns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep);
718170222Sdougb/*%<
719135446Strhodes * Search for the zone 'name' in the zone table of 'view'.
720135446Strhodes * If found, 'zonep' is (strongly) attached to it.  There
721135446Strhodes * are no partial matches.
722135446Strhodes *
723135446Strhodes * Requires:
724135446Strhodes *
725170222Sdougb *\li	'zonep' points to a NULL dns_zone_t *.
726135446Strhodes *
727135446Strhodes * Returns:
728170222Sdougb *\li	#ISC_R_SUCCESS		A matching zone was found.
729170222Sdougb *\li	#ISC_R_NOTFOUND		No matching zone was found.
730170222Sdougb *\li	others			An error occurred.
731135446Strhodes */
732135446Strhodes
733135446Strhodesisc_result_t
734135446Strhodesdns_view_load(dns_view_t *view, isc_boolean_t stop);
735135446Strhodes
736135446Strhodesisc_result_t
737135446Strhodesdns_view_loadnew(dns_view_t *view, isc_boolean_t stop);
738254897Serwin
739254897Serwinisc_result_t
740254897Serwindns_view_asyncload(dns_view_t *view, dns_zt_allloaded_t callback, void *arg);
741170222Sdougb/*%<
742135446Strhodes * Load zones attached to this view.  dns_view_load() loads
743135446Strhodes * all zones whose master file has changed since the last
744193149Sdougb * load; dns_view_loadnew() loads only zones that have never
745135446Strhodes * been loaded.
746135446Strhodes *
747254897Serwin * dns_view_asyncload() loads zones asynchronously.  When all zones
748254897Serwin * in the view have finished loading, 'callback' is called with argument
749254897Serwin * 'arg' to inform the caller.
750254897Serwin *
751135446Strhodes * If 'stop' is ISC_TRUE, stop on the first error and return it.
752254897Serwin * If 'stop' is ISC_FALSE (or we are loading asynchronously), ignore errors.
753135446Strhodes *
754135446Strhodes * Requires:
755135446Strhodes *
756170222Sdougb *\li	'view' is valid.
757135446Strhodes */
758135446Strhodes
759135446Strhodesisc_result_t
760135446Strhodesdns_view_gettsig(dns_view_t *view, dns_name_t *keyname,
761135446Strhodes		 dns_tsigkey_t **keyp);
762170222Sdougb/*%<
763135446Strhodes * Find the TSIG key configured in 'view' with name 'keyname',
764135446Strhodes * if any.
765135446Strhodes *
766193149Sdougb * Requires:
767170222Sdougb *\li	keyp points to a NULL dns_tsigkey_t *.
768135446Strhodes *
769135446Strhodes * Returns:
770170222Sdougb *\li	#ISC_R_SUCCESS	A key was found and '*keyp' now points to it.
771170222Sdougb *\li	#ISC_R_NOTFOUND	No key was found.
772170222Sdougb *\li	others		An error occurred.
773135446Strhodes */
774135446Strhodes
775135446Strhodesisc_result_t
776135446Strhodesdns_view_getpeertsig(dns_view_t *view, isc_netaddr_t *peeraddr,
777135446Strhodes		     dns_tsigkey_t **keyp);
778170222Sdougb/*%<
779135446Strhodes * Find the TSIG key configured in 'view' for the server whose
780135446Strhodes * address is 'peeraddr', if any.
781135446Strhodes *
782193149Sdougb * Requires:
783135446Strhodes *	keyp points to a NULL dns_tsigkey_t *.
784135446Strhodes *
785135446Strhodes * Returns:
786170222Sdougb *\li	#ISC_R_SUCCESS	A key was found and '*keyp' now points to it.
787170222Sdougb *\li	#ISC_R_NOTFOUND	No key was found.
788170222Sdougb *\li	others		An error occurred.
789135446Strhodes */
790135446Strhodes
791135446Strhodesisc_result_t
792135446Strhodesdns_view_checksig(dns_view_t *view, isc_buffer_t *source, dns_message_t *msg);
793170222Sdougb/*%<
794135446Strhodes * Verifies the signature of a message.
795135446Strhodes *
796135446Strhodes * Requires:
797135446Strhodes *
798170222Sdougb *\li	'view' is a valid view.
799170222Sdougb *\li	'source' is a valid buffer containing the message
800170222Sdougb *\li	'msg' is a valid message
801135446Strhodes *
802135446Strhodes * Returns:
803170222Sdougb *\li	see dns_tsig_verify()
804135446Strhodes */
805135446Strhodes
806135446Strhodesvoid
807135446Strhodesdns_view_dialup(dns_view_t *view);
808170222Sdougb/*%<
809135446Strhodes * Perform dialup-time maintenance on the zones of 'view'.
810135446Strhodes */
811135446Strhodes
812135446Strhodesisc_result_t
813135446Strhodesdns_view_dumpdbtostream(dns_view_t *view, FILE *fp);
814170222Sdougb/*%<
815135446Strhodes * Dump the current state of the view 'view' to the stream 'fp'
816135446Strhodes * for purposes of analysis or debugging.
817135446Strhodes *
818135446Strhodes * Currently the dumped state includes the view's cache; in the future
819135446Strhodes * it may also include other state such as the address database.
820135446Strhodes * It will not not include authoritative data since it is voluminous and
821135446Strhodes * easily obtainable by other means.
822135446Strhodes *
823135446Strhodes * Requires:
824193149Sdougb *
825170222Sdougb *\li	'view' is valid.
826135446Strhodes *
827170222Sdougb *\li	'fp' refers to a file open for writing.
828135446Strhodes *
829135446Strhodes * Returns:
830170222Sdougb * \li	ISC_R_SUCCESS	The cache was successfully dumped.
831170222Sdougb * \li	others		An error occurred (see dns_master_dump)
832135446Strhodes */
833135446Strhodes
834135446Strhodesisc_result_t
835135446Strhodesdns_view_flushcache(dns_view_t *view);
836224092Sdougbisc_result_t
837224092Sdougbdns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly);
838170222Sdougb/*%<
839224092Sdougb * Flush the view's cache (and ADB).  If 'fixuponly' is true, it only updates
840224092Sdougb * the internal reference to the cache DB with omitting actual flush operation.
841224092Sdougb * 'fixuponly' is intended to be used for a view that shares a cache with
842224092Sdougb * a different view.  dns_view_flushcache() is a backward compatible version
843224092Sdougb * that always sets fixuponly to false.
844135446Strhodes *
845135446Strhodes * Requires:
846135446Strhodes * 	'view' is valid.
847135446Strhodes *
848135446Strhodes * 	No other tasks are executing.
849135446Strhodes *
850135446Strhodes * Returns:
851170222Sdougb *\li	#ISC_R_SUCCESS
852170222Sdougb *\li	#ISC_R_NOMEMORY
853135446Strhodes */
854135446Strhodes
855135446Strhodesisc_result_t
856254897Serwindns_view_flushnode(dns_view_t *view, dns_name_t *name, isc_boolean_t tree);
857170222Sdougb/*%<
858254897Serwin * Flush the given name from the view's cache (and optionally ADB/badcache).
859135446Strhodes *
860254897Serwin * If 'tree' is true, flush 'name' and all names below it
861254897Serwin * from the cache, but do not flush ADB.
862254897Serwin *
863254897Serwin * If 'tree' is false, flush 'name' frmo both the cache and ADB,
864254897Serwin * but do not touch any other nodes.
865254897Serwin *
866135446Strhodes * Requires:
867170222Sdougb *\li	'view' is valid.
868170222Sdougb *\li	'name' is valid.
869135446Strhodes *
870135446Strhodes * Returns:
871170222Sdougb *\li	#ISC_R_SUCCESS
872135446Strhodes *	other returns are failures.
873135446Strhodes */
874135446Strhodes
875135446Strhodesisc_result_t
876254897Serwindns_view_flushname(dns_view_t *view, dns_name_t *name);
877254897Serwin/*%<
878254897Serwin * Flush the given name from the view's cache, ADB and badcache.
879254897Serwin * Equivalent to dns_view_flushnode(view, name, ISC_FALSE).
880254897Serwin *
881254897Serwin *
882254897Serwin * Requires:
883254897Serwin *\li	'view' is valid.
884254897Serwin *\li	'name' is valid.
885254897Serwin *
886254897Serwin * Returns:
887254897Serwin *\li	#ISC_R_SUCCESS
888254897Serwin *	other returns are failures.
889254897Serwin */
890254897Serwin
891254897Serwinisc_result_t
892135446Strhodesdns_view_adddelegationonly(dns_view_t *view, dns_name_t *name);
893170222Sdougb/*%<
894135446Strhodes * Add the given name to the delegation only table.
895135446Strhodes *
896135446Strhodes * Requires:
897170222Sdougb *\li	'view' is valid.
898170222Sdougb *\li	'name' is valid.
899135446Strhodes *
900135446Strhodes * Returns:
901170222Sdougb *\li	#ISC_R_SUCCESS
902170222Sdougb *\li	#ISC_R_NOMEMORY
903135446Strhodes */
904135446Strhodes
905135446Strhodesisc_result_t
906135446Strhodesdns_view_excludedelegationonly(dns_view_t *view, dns_name_t *name);
907170222Sdougb/*%<
908135446Strhodes * Add the given name to be excluded from the root-delegation-only.
909135446Strhodes *
910193149Sdougb *
911135446Strhodes * Requires:
912170222Sdougb *\li	'view' is valid.
913170222Sdougb *\li	'name' is valid.
914135446Strhodes *
915135446Strhodes * Returns:
916170222Sdougb *\li	#ISC_R_SUCCESS
917170222Sdougb *\li	#ISC_R_NOMEMORY
918135446Strhodes */
919135446Strhodes
920135446Strhodesisc_boolean_t
921135446Strhodesdns_view_isdelegationonly(dns_view_t *view, dns_name_t *name);
922170222Sdougb/*%<
923135446Strhodes * Check if 'name' is in the delegation only table or if
924135446Strhodes * rootdelonly is set that name is not being excluded.
925135446Strhodes *
926135446Strhodes * Requires:
927170222Sdougb *\li	'view' is valid.
928170222Sdougb *\li	'name' is valid.
929135446Strhodes *
930135446Strhodes * Returns:
931193149Sdougb *\li	#ISC_TRUE if the name is the table.
932193149Sdougb *\li	#ISC_FALSE otherwise.
933135446Strhodes */
934135446Strhodes
935135446Strhodesvoid
936135446Strhodesdns_view_setrootdelonly(dns_view_t *view, isc_boolean_t value);
937170222Sdougb/*%<
938135446Strhodes * Set the root delegation only flag.
939135446Strhodes *
940135446Strhodes * Requires:
941170222Sdougb *\li	'view' is valid.
942135446Strhodes */
943135446Strhodes
944135446Strhodesisc_boolean_t
945135446Strhodesdns_view_getrootdelonly(dns_view_t *view);
946170222Sdougb/*%<
947135446Strhodes * Get the root delegation only flag.
948135446Strhodes *
949135446Strhodes * Requires:
950170222Sdougb *\li	'view' is valid.
951135446Strhodes */
952135446Strhodes
953170222Sdougbisc_result_t
954170222Sdougbdns_view_freezezones(dns_view_t *view, isc_boolean_t freeze);
955170222Sdougb/*%<
956170222Sdougb * Freeze/thaw updates to master zones.
957170222Sdougb *
958170222Sdougb * Requires:
959170222Sdougb * \li	'view' is valid.
960170222Sdougb */
961193149Sdougb
962193149Sdougbvoid
963193149Sdougbdns_view_setresstats(dns_view_t *view, isc_stats_t *stats);
964193149Sdougb/*%<
965193149Sdougb * Set a general resolver statistics counter set 'stats' for 'view'.
966193149Sdougb *
967193149Sdougb * Requires:
968193149Sdougb * \li	'view' is valid and is not frozen.
969193149Sdougb *
970193149Sdougb *\li	stats is a valid statistics supporting resolver statistics counters
971193149Sdougb *	(see dns/stats.h).
972193149Sdougb */
973193149Sdougb
974193149Sdougbvoid
975193149Sdougbdns_view_getresstats(dns_view_t *view, isc_stats_t **statsp);
976193149Sdougb/*%<
977193149Sdougb * Get the general statistics counter set for 'view'.  If a statistics set is
978193149Sdougb * set '*statsp' will be attached to the set; otherwise, '*statsp' will be
979193149Sdougb * untouched.
980193149Sdougb *
981193149Sdougb * Requires:
982193149Sdougb * \li	'view' is valid and is not frozen.
983193149Sdougb *
984193149Sdougb *\li	'statsp' != NULL && '*statsp' != NULL
985193149Sdougb */
986193149Sdougb
987193149Sdougbvoid
988193149Sdougbdns_view_setresquerystats(dns_view_t *view, dns_stats_t *stats);
989193149Sdougb/*%<
990193149Sdougb * Set a statistics counter set of rdata type, 'stats', for 'view'.  Once the
991193149Sdougb * statistic set is installed, view's resolver will count outgoing queries
992193149Sdougb * per rdata type.
993193149Sdougb *
994193149Sdougb * Requires:
995193149Sdougb * \li	'view' is valid and is not frozen.
996193149Sdougb *
997193149Sdougb *\li	stats is a valid statistics created by dns_rdatatypestats_create().
998193149Sdougb */
999193149Sdougb
1000193149Sdougbvoid
1001193149Sdougbdns_view_getresquerystats(dns_view_t *view, dns_stats_t **statsp);
1002193149Sdougb/*%<
1003193149Sdougb * Get the rdatatype statistics counter set for 'view'.  If a statistics set is
1004193149Sdougb * set '*statsp' will be attached to the set; otherwise, '*statsp' will be
1005193149Sdougb * untouched.
1006193149Sdougb *
1007193149Sdougb * Requires:
1008193149Sdougb * \li	'view' is valid and is not frozen.
1009193149Sdougb *
1010193149Sdougb *\li	'statsp' != NULL && '*statsp' != NULL
1011193149Sdougb */
1012193149Sdougb
1013224092Sdougbisc_boolean_t
1014224092Sdougbdns_view_iscacheshared(dns_view_t *view);
1015224092Sdougb/*%<
1016224092Sdougb * Check if the view shares the cache created by another view.
1017224092Sdougb *
1018224092Sdougb * Requires:
1019224092Sdougb * \li	'view' is valid.
1020224092Sdougb *
1021224092Sdougb * Returns:
1022224092Sdougb *\li	#ISC_TRUE if the cache is shared.
1023224092Sdougb *\li	#ISC_FALSE otherwise.
1024224092Sdougb */
1025224092Sdougb
1026224092Sdougbisc_result_t
1027224092Sdougbdns_view_initsecroots(dns_view_t *view, isc_mem_t *mctx);
1028224092Sdougb/*%<
1029224092Sdougb * Initialize security roots for the view.  (Note that secroots is
1030224092Sdougb * NULL until this function is called, so any function using
1031224092Sdougb * secroots must check its validity first.  One way to do this is
1032224092Sdougb * use dns_view_getsecroots() and check its return value.)
1033224092Sdougb *
1034224092Sdougb * Requires:
1035224092Sdougb * \li	'view' is valid.
1036224092Sdougb * \li	'view->secroots' is NULL.
1037224092Sdougb *
1038224092Sdougb * Returns:
1039224092Sdougb *\li	ISC_R_SUCCESS
1040224092Sdougb *\li	Any other result indicates failure
1041224092Sdougb */
1042224092Sdougb
1043224092Sdougbisc_result_t
1044224092Sdougbdns_view_getsecroots(dns_view_t *view, dns_keytable_t **ktp);
1045224092Sdougb/*%<
1046224092Sdougb * Get the security roots for this view.  Returns ISC_R_NOTFOUND if
1047224092Sdougb * the security roots keytable has not been initialized for the view.
1048224092Sdougb *
1049224092Sdougb * '*ktp' is attached on success; the caller is responsible for
1050224092Sdougb * detaching it with dns_keytable_detach().
1051224092Sdougb *
1052224092Sdougb * Requires:
1053224092Sdougb * \li	'view' is valid.
1054224092Sdougb * \li	'ktp' is not NULL and '*ktp' is NULL.
1055224092Sdougb *
1056224092Sdougb * Returns:
1057224092Sdougb *\li	ISC_R_SUCCESS
1058224092Sdougb *\li	ISC_R_NOTFOUND
1059224092Sdougb */
1060224092Sdougb
1061224092Sdougbisc_result_t
1062224092Sdougbdns_view_issecuredomain(dns_view_t *view, dns_name_t *name,
1063224092Sdougb			 isc_boolean_t *secure_domain);
1064224092Sdougb/*%<
1065224092Sdougb * Is 'name' at or beneath a trusted key?  Put answer in
1066224092Sdougb * '*secure_domain'.
1067224092Sdougb *
1068224092Sdougb * Requires:
1069224092Sdougb * \li	'view' is valid.
1070224092Sdougb *
1071224092Sdougb * Returns:
1072224092Sdougb *\li	ISC_R_SUCCESS
1073224092Sdougb *\li	Any other value indicates failure
1074224092Sdougb */
1075224092Sdougb
1076224092Sdougbvoid
1077224092Sdougbdns_view_untrust(dns_view_t *view, dns_name_t *keyname,
1078224092Sdougb		 dns_rdata_dnskey_t *dnskey, isc_mem_t *mctx);
1079224092Sdougb/*%<
1080224092Sdougb * Remove keys that match 'keyname' and 'dnskey' from the views trust
1081224092Sdougb * anchors.
1082224092Sdougb *
1083224092Sdougb * Requires:
1084224092Sdougb * \li	'view' is valid.
1085224092Sdougb * \li	'keyname' is valid.
1086224092Sdougb * \li	'mctx' is valid.
1087224092Sdougb * \li	'dnskey' is valid.
1088224092Sdougb */
1089224092Sdougb
1090224092Sdougbvoid
1091224092Sdougbdns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
1092224092Sdougb		     void (*cfg_destroy)(void **));
1093224092Sdougb/*%<
1094224092Sdougb * Set whether or not to allow zones to be created or deleted at runtime.
1095224092Sdougb *
1096224092Sdougb * If 'allow' is ISC_TRUE, determines the filename into which new zone
1097224092Sdougb * configuration will be written.  Preserves the configuration context
1098224092Sdougb * (a pointer to which is passed in 'cfgctx') for use when parsing new
1099224092Sdougb * zone configuration.  'cfg_destroy' points to a callback routine to
1100224092Sdougb * destroy the configuration context when the view is destroyed.  (This
1101224092Sdougb * roundabout method is used in order to avoid libdns having a dependency
1102224092Sdougb * on libisccfg and libbind9.)
1103224092Sdougb *
1104224092Sdougb * If 'allow' is ISC_FALSE, removes any existing references to
1105224092Sdougb * configuration context and frees any memory.
1106224092Sdougb *
1107224092Sdougb * Requires:
1108224092Sdougb * \li 'view' is valid.
1109224092Sdougb */
1110224092Sdougb
1111224092Sdougbvoid
1112224092Sdougbdns_view_restorekeyring(dns_view_t *view);
1113224092Sdougb
1114236374SdougbISC_LANG_ENDDECLS
1115236374Sdougb
1116135446Strhodes#endif /* DNS_VIEW_H */
1117