1135446Strhodes/*
2234010Sdougb * Copyright (C) 2004-2012  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
18254897Serwin/* $Id: rdataset.h,v 1.72 2011/06/08 22:13:51 each Exp $ */
19135446Strhodes
20135446Strhodes#ifndef DNS_RDATASET_H
21135446Strhodes#define DNS_RDATASET_H 1
22135446Strhodes
23135446Strhodes/*****
24135446Strhodes ***** Module Info
25135446Strhodes *****/
26135446Strhodes
27193149Sdougb/*! \file dns/rdataset.h
28170222Sdougb * \brief
29135446Strhodes * A DNS rdataset is a handle that can be associated with a collection of
30135446Strhodes * rdata all having a common owner name, class, and type.
31135446Strhodes *
32135446Strhodes * The dns_rdataset_t type is like a "virtual class".  To actually use
33135446Strhodes * rdatasets, an implementation of the method suite (e.g. "slabbed rdata") is
34135446Strhodes * required.
35135446Strhodes *
36170222Sdougb * XXX <more> XXX
37135446Strhodes *
38135446Strhodes * MP:
39170222Sdougb *\li	Clients of this module must impose any required synchronization.
40135446Strhodes *
41135446Strhodes * Reliability:
42170222Sdougb *\li	No anticipated impact.
43135446Strhodes *
44135446Strhodes * Resources:
45170222Sdougb *\li	TBS
46135446Strhodes *
47135446Strhodes * Security:
48170222Sdougb *\li	No anticipated impact.
49135446Strhodes *
50135446Strhodes * Standards:
51170222Sdougb *\li	None.
52135446Strhodes */
53135446Strhodes
54135446Strhodes#include <isc/lang.h>
55135446Strhodes#include <isc/magic.h>
56170222Sdougb#include <isc/stdtime.h>
57135446Strhodes
58135446Strhodes#include <dns/types.h>
59245163Serwin#include <dns/rdatastruct.h>
60135446Strhodes
61135446StrhodesISC_LANG_BEGINDECLS
62135446Strhodes
63170222Sdougbtypedef enum {
64170222Sdougb	dns_rdatasetadditional_fromauth,
65170222Sdougb	dns_rdatasetadditional_fromcache,
66170222Sdougb	dns_rdatasetadditional_fromglue
67170222Sdougb} dns_rdatasetadditional_t;
68170222Sdougb
69135446Strhodestypedef struct dns_rdatasetmethods {
70135446Strhodes	void			(*disassociate)(dns_rdataset_t *rdataset);
71135446Strhodes	isc_result_t		(*first)(dns_rdataset_t *rdataset);
72135446Strhodes	isc_result_t		(*next)(dns_rdataset_t *rdataset);
73135446Strhodes	void			(*current)(dns_rdataset_t *rdataset,
74135446Strhodes					   dns_rdata_t *rdata);
75135446Strhodes	void			(*clone)(dns_rdataset_t *source,
76135446Strhodes					 dns_rdataset_t *target);
77135446Strhodes	unsigned int		(*count)(dns_rdataset_t *rdataset);
78135446Strhodes	isc_result_t		(*addnoqname)(dns_rdataset_t *rdataset,
79135446Strhodes					      dns_name_t *name);
80135446Strhodes	isc_result_t		(*getnoqname)(dns_rdataset_t *rdataset,
81135446Strhodes					      dns_name_t *name,
82193149Sdougb					      dns_rdataset_t *neg,
83193149Sdougb					      dns_rdataset_t *negsig);
84193149Sdougb	isc_result_t		(*addclosest)(dns_rdataset_t *rdataset,
85193149Sdougb					      dns_name_t *name);
86193149Sdougb	isc_result_t		(*getclosest)(dns_rdataset_t *rdataset,
87193149Sdougb					      dns_name_t *name,
88193149Sdougb					      dns_rdataset_t *neg,
89193149Sdougb					      dns_rdataset_t *negsig);
90170222Sdougb	isc_result_t		(*getadditional)(dns_rdataset_t *rdataset,
91170222Sdougb						 dns_rdatasetadditional_t type,
92170222Sdougb						 dns_rdatatype_t qtype,
93170222Sdougb						 dns_acache_t *acache,
94170222Sdougb						 dns_zone_t **zonep,
95170222Sdougb						 dns_db_t **dbp,
96170222Sdougb						 dns_dbversion_t **versionp,
97170222Sdougb						 dns_dbnode_t **nodep,
98170222Sdougb						 dns_name_t *fname,
99170222Sdougb						 dns_message_t *msg,
100170222Sdougb						 isc_stdtime_t now);
101170222Sdougb	isc_result_t		(*setadditional)(dns_rdataset_t *rdataset,
102170222Sdougb						 dns_rdatasetadditional_t type,
103170222Sdougb						 dns_rdatatype_t qtype,
104170222Sdougb						 dns_acache_t *acache,
105170222Sdougb						 dns_zone_t *zone,
106170222Sdougb						 dns_db_t *db,
107170222Sdougb						 dns_dbversion_t *version,
108170222Sdougb						 dns_dbnode_t *node,
109170222Sdougb						 dns_name_t *fname);
110170222Sdougb	isc_result_t		(*putadditional)(dns_acache_t *acache,
111170222Sdougb						 dns_rdataset_t *rdataset,
112170222Sdougb						 dns_rdatasetadditional_t type,
113170222Sdougb						 dns_rdatatype_t qtype);
114205292Sdougb	void			(*settrust)(dns_rdataset_t *rdataset,
115205292Sdougb					    dns_trust_t trust);
116205292Sdougb	void			(*expire)(dns_rdataset_t *rdataset);
117135446Strhodes} dns_rdatasetmethods_t;
118135446Strhodes
119135446Strhodes#define DNS_RDATASET_MAGIC	       ISC_MAGIC('D','N','S','R')
120135446Strhodes#define DNS_RDATASET_VALID(set)	       ISC_MAGIC_VALID(set, DNS_RDATASET_MAGIC)
121135446Strhodes
122170222Sdougb/*%
123135446Strhodes * Direct use of this structure by clients is strongly discouraged, except
124135446Strhodes * for the 'link' field which may be used however the client wishes.  The
125135446Strhodes * 'private', 'current', and 'index' fields MUST NOT be changed by clients.
126135446Strhodes * rdataset implementations may change any of the fields.
127135446Strhodes */
128135446Strhodesstruct dns_rdataset {
129135446Strhodes	unsigned int			magic;		/* XXX ? */
130135446Strhodes	dns_rdatasetmethods_t *		methods;
131135446Strhodes	ISC_LINK(dns_rdataset_t)	link;
132135446Strhodes	/*
133135446Strhodes	 * XXX do we need these, or should they be retrieved by methods?
134135446Strhodes	 * Leaning towards the latter, since they are not frequently required
135135446Strhodes	 * once you have the rdataset.
136135446Strhodes	 */
137135446Strhodes	dns_rdataclass_t		rdclass;
138135446Strhodes	dns_rdatatype_t			type;
139135446Strhodes	dns_ttl_t			ttl;
140135446Strhodes	dns_trust_t			trust;
141135446Strhodes	dns_rdatatype_t			covers;
142135446Strhodes	/*
143135446Strhodes	 * attributes
144135446Strhodes	 */
145135446Strhodes	unsigned int			attributes;
146170222Sdougb	/*%
147135446Strhodes	 * the counter provides the starting point in the "cyclic" order.
148135446Strhodes	 * The value ISC_UINT32_MAX has a special meaning of "picking up a
149135446Strhodes	 * random value." in order to take care of databases that do not
150135446Strhodes	 * increment the counter.
151135446Strhodes	 */
152135446Strhodes	isc_uint32_t			count;
153193149Sdougb	/*
154193149Sdougb	 * This RRSIG RRset should be re-generated around this time.
155193149Sdougb	 * Only valid if DNS_RDATASETATTR_RESIGN is set in attributes.
156193149Sdougb	 */
157193149Sdougb	isc_stdtime_t			resign;
158170222Sdougb	/*@{*/
159170222Sdougb	/*%
160135446Strhodes	 * These are for use by the rdataset implementation, and MUST NOT
161135446Strhodes	 * be changed by clients.
162135446Strhodes	 */
163135446Strhodes	void *				private1;
164135446Strhodes	void *				private2;
165135446Strhodes	void *				private3;
166135446Strhodes	unsigned int			privateuint4;
167135446Strhodes	void *				private5;
168135446Strhodes	void *				private6;
169193149Sdougb	void *				private7;
170170222Sdougb	/*@}*/
171193149Sdougb
172135446Strhodes};
173135446Strhodes
174170222Sdougb/*!
175170222Sdougb * \def DNS_RDATASETATTR_RENDERED
176135446Strhodes *	Used by message.c to indicate that the rdataset was rendered.
177135446Strhodes *
178170222Sdougb * \def DNS_RDATASETATTR_TTLADJUSTED
179135446Strhodes *	Used by message.c to indicate that the rdataset's rdata had differing
180135446Strhodes *	TTL values, and the rdataset->ttl holds the smallest.
181170222Sdougb *
182170222Sdougb * \def DNS_RDATASETATTR_LOADORDER
183170222Sdougb *	Output the RRset in load order.
184135446Strhodes */
185170222Sdougb
186153816Sdougb#define DNS_RDATASETATTR_QUESTION	0x00000001
187170222Sdougb#define DNS_RDATASETATTR_RENDERED	0x00000002	/*%< Used by message.c */
188170222Sdougb#define DNS_RDATASETATTR_ANSWERED	0x00000004	/*%< Used by server. */
189170222Sdougb#define DNS_RDATASETATTR_CACHE		0x00000008	/*%< Used by resolver. */
190170222Sdougb#define DNS_RDATASETATTR_ANSWER		0x00000010	/*%< Used by resolver. */
191170222Sdougb#define DNS_RDATASETATTR_ANSWERSIG	0x00000020	/*%< Used by resolver. */
192170222Sdougb#define DNS_RDATASETATTR_EXTERNAL	0x00000040	/*%< Used by resolver. */
193170222Sdougb#define DNS_RDATASETATTR_NCACHE		0x00000080	/*%< Used by resolver. */
194170222Sdougb#define DNS_RDATASETATTR_CHAINING	0x00000100	/*%< Used by resolver. */
195170222Sdougb#define DNS_RDATASETATTR_TTLADJUSTED	0x00000200	/*%< Used by message.c */
196153816Sdougb#define DNS_RDATASETATTR_FIXEDORDER	0x00000400
197153816Sdougb#define DNS_RDATASETATTR_RANDOMIZE	0x00000800
198170222Sdougb#define DNS_RDATASETATTR_CHASE		0x00001000	/*%< Used by resolver. */
199153816Sdougb#define DNS_RDATASETATTR_NXDOMAIN	0x00002000
200153816Sdougb#define DNS_RDATASETATTR_NOQNAME	0x00004000
201170222Sdougb#define DNS_RDATASETATTR_CHECKNAMES	0x00008000	/*%< Used by resolver. */
202153816Sdougb#define DNS_RDATASETATTR_REQUIREDGLUE	0x00010000
203170222Sdougb#define DNS_RDATASETATTR_LOADORDER	0x00020000
204193149Sdougb#define DNS_RDATASETATTR_RESIGN		0x00040000
205193149Sdougb#define DNS_RDATASETATTR_CLOSEST	0x00080000
206193149Sdougb#define DNS_RDATASETATTR_OPTOUT		0x00100000	/*%< OPTOUT proof */
207223812Sdougb#define DNS_RDATASETATTR_NEGATIVE	0x00200000
208135446Strhodes
209170222Sdougb/*%
210135446Strhodes * _OMITDNSSEC:
211135446Strhodes * 	Omit DNSSEC records when rendering ncache records.
212135446Strhodes */
213135446Strhodes#define DNS_RDATASETTOWIRE_OMITDNSSEC	0x0001
214135446Strhodes
215135446Strhodesvoid
216135446Strhodesdns_rdataset_init(dns_rdataset_t *rdataset);
217170222Sdougb/*%<
218135446Strhodes * Make 'rdataset' a valid, disassociated rdataset.
219135446Strhodes *
220135446Strhodes * Requires:
221170222Sdougb *\li	'rdataset' is not NULL.
222135446Strhodes *
223135446Strhodes * Ensures:
224170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
225135446Strhodes */
226135446Strhodes
227135446Strhodesvoid
228135446Strhodesdns_rdataset_invalidate(dns_rdataset_t *rdataset);
229170222Sdougb/*%<
230135446Strhodes * Invalidate 'rdataset'.
231135446Strhodes *
232135446Strhodes * Requires:
233170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
234135446Strhodes *
235135446Strhodes * Ensures:
236170222Sdougb *\li	If assertion checking is enabled, future attempts to use 'rdataset'
237135446Strhodes *	without initializing it will cause an assertion failure.
238135446Strhodes */
239135446Strhodes
240135446Strhodesvoid
241135446Strhodesdns_rdataset_disassociate(dns_rdataset_t *rdataset);
242170222Sdougb/*%<
243135446Strhodes * Disassociate 'rdataset' from its rdata, allowing it to be reused.
244135446Strhodes *
245135446Strhodes * Notes:
246170222Sdougb *\li	The client must ensure it has no references to rdata in the rdataset
247135446Strhodes *	before disassociating.
248135446Strhodes *
249135446Strhodes * Requires:
250170222Sdougb *\li	'rdataset' is a valid, associated rdataset.
251135446Strhodes *
252135446Strhodes * Ensures:
253170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
254135446Strhodes */
255135446Strhodes
256135446Strhodesisc_boolean_t
257135446Strhodesdns_rdataset_isassociated(dns_rdataset_t *rdataset);
258170222Sdougb/*%<
259135446Strhodes * Is 'rdataset' associated?
260135446Strhodes *
261135446Strhodes * Requires:
262170222Sdougb *\li	'rdataset' is a valid rdataset.
263135446Strhodes *
264135446Strhodes * Returns:
265170222Sdougb *\li	#ISC_TRUE			'rdataset' is associated.
266170222Sdougb *\li	#ISC_FALSE			'rdataset' is not associated.
267135446Strhodes */
268135446Strhodes
269135446Strhodesvoid
270135446Strhodesdns_rdataset_makequestion(dns_rdataset_t *rdataset, dns_rdataclass_t rdclass,
271135446Strhodes			  dns_rdatatype_t type);
272170222Sdougb/*%<
273135446Strhodes * Make 'rdataset' a valid, associated, question rdataset, with a
274135446Strhodes * question class of 'rdclass' and type 'type'.
275135446Strhodes *
276135446Strhodes * Notes:
277170222Sdougb *\li	Question rdatasets have a class and type, but no rdata.
278135446Strhodes *
279135446Strhodes * Requires:
280170222Sdougb *\li	'rdataset' is a valid, disassociated rdataset.
281135446Strhodes *
282135446Strhodes * Ensures:
283170222Sdougb *\li	'rdataset' is a valid, associated, question rdataset.
284135446Strhodes */
285135446Strhodes
286135446Strhodesvoid
287135446Strhodesdns_rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target);
288170222Sdougb/*%<
289135446Strhodes * Make 'target' refer to the same rdataset as 'source'.
290135446Strhodes *
291135446Strhodes * Requires:
292170222Sdougb *\li	'source' is a valid, associated rdataset.
293135446Strhodes *
294170222Sdougb *\li	'target' is a valid, dissociated rdataset.
295135446Strhodes *
296135446Strhodes * Ensures:
297170222Sdougb *\li	'target' references the same rdataset as 'source'.
298135446Strhodes */
299135446Strhodes
300135446Strhodesunsigned int
301135446Strhodesdns_rdataset_count(dns_rdataset_t *rdataset);
302170222Sdougb/*%<
303135446Strhodes * Return the number of records in 'rdataset'.
304135446Strhodes *
305135446Strhodes * Requires:
306170222Sdougb *\li	'rdataset' is a valid, associated rdataset.
307135446Strhodes *
308135446Strhodes * Returns:
309170222Sdougb *\li	The number of records in 'rdataset'.
310135446Strhodes */
311135446Strhodes
312135446Strhodesisc_result_t
313135446Strhodesdns_rdataset_first(dns_rdataset_t *rdataset);
314170222Sdougb/*%<
315135446Strhodes * Move the rdata cursor to the first rdata in the rdataset (if any).
316135446Strhodes *
317135446Strhodes * Requires:
318170222Sdougb *\li	'rdataset' is a valid, associated rdataset.
319135446Strhodes *
320135446Strhodes * Returns:
321170222Sdougb *\li	#ISC_R_SUCCESS
322170222Sdougb *\li	#ISC_R_NOMORE			There are no rdata in the set.
323135446Strhodes */
324135446Strhodes
325135446Strhodesisc_result_t
326135446Strhodesdns_rdataset_next(dns_rdataset_t *rdataset);
327170222Sdougb/*%<
328135446Strhodes * Move the rdata cursor to the next rdata in the rdataset (if any).
329135446Strhodes *
330135446Strhodes * Requires:
331170222Sdougb *\li	'rdataset' is a valid, associated rdataset.
332135446Strhodes *
333135446Strhodes * Returns:
334170222Sdougb *\li	#ISC_R_SUCCESS
335170222Sdougb *\li	#ISC_R_NOMORE			There are no more rdata in the set.
336135446Strhodes */
337135446Strhodes
338135446Strhodesvoid
339135446Strhodesdns_rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata);
340170222Sdougb/*%<
341135446Strhodes * Make 'rdata' refer to the current rdata.
342135446Strhodes *
343135446Strhodes * Notes:
344135446Strhodes *
345170222Sdougb *\li	The data returned in 'rdata' is valid for the life of the
346135446Strhodes *	rdataset; in particular, subsequent changes in the cursor position
347135446Strhodes *	do not invalidate 'rdata'.
348135446Strhodes *
349135446Strhodes * Requires:
350170222Sdougb *\li	'rdataset' is a valid, associated rdataset.
351135446Strhodes *
352170222Sdougb *\li	The rdata cursor of 'rdataset' is at a valid location (i.e. the
353135446Strhodes *	result of last call to a cursor movement command was ISC_R_SUCCESS).
354135446Strhodes *
355135446Strhodes * Ensures:
356170222Sdougb *\li	'rdata' refers to the rdata at the rdata cursor location of
357170222Sdougb *\li	'rdataset'.
358135446Strhodes */
359135446Strhodes
360135446Strhodesisc_result_t
361135446Strhodesdns_rdataset_totext(dns_rdataset_t *rdataset,
362135446Strhodes		    dns_name_t *owner_name,
363135446Strhodes		    isc_boolean_t omit_final_dot,
364135446Strhodes		    isc_boolean_t question,
365135446Strhodes		    isc_buffer_t *target);
366170222Sdougb/*%<
367135446Strhodes * Convert 'rdataset' to text format, storing the result in 'target'.
368135446Strhodes *
369135446Strhodes * Notes:
370170222Sdougb *\li	The rdata cursor position will be changed.
371135446Strhodes *
372193149Sdougb *\li	The 'question' flag should normally be #ISC_FALSE.  If it is
373193149Sdougb *	#ISC_TRUE, the TTL and rdata fields are not printed.  This is
374135446Strhodes *	for use when printing an rdata representing a question section.
375135446Strhodes *
376170222Sdougb *\li	This interface is deprecated; use dns_master_rdatasettottext()
377135446Strhodes * 	and/or dns_master_questiontotext() instead.
378135446Strhodes *
379135446Strhodes * Requires:
380170222Sdougb *\li	'rdataset' is a valid rdataset.
381135446Strhodes *
382170222Sdougb *\li	'rdataset' is not empty.
383135446Strhodes */
384135446Strhodes
385135446Strhodesisc_result_t
386135446Strhodesdns_rdataset_towire(dns_rdataset_t *rdataset,
387135446Strhodes		    dns_name_t *owner_name,
388135446Strhodes		    dns_compress_t *cctx,
389135446Strhodes		    isc_buffer_t *target,
390135446Strhodes		    unsigned int options,
391135446Strhodes		    unsigned int *countp);
392170222Sdougb/*%<
393135446Strhodes * Convert 'rdataset' to wire format, compressing names as specified
394135446Strhodes * in 'cctx', and storing the result in 'target'.
395135446Strhodes *
396135446Strhodes * Notes:
397170222Sdougb *\li	The rdata cursor position will be changed.
398135446Strhodes *
399170222Sdougb *\li	The number of RRs added to target will be added to *countp.
400135446Strhodes *
401135446Strhodes * Requires:
402170222Sdougb *\li	'rdataset' is a valid rdataset.
403135446Strhodes *
404170222Sdougb *\li	'rdataset' is not empty.
405135446Strhodes *
406170222Sdougb *\li	'countp' is a valid pointer.
407135446Strhodes *
408135446Strhodes * Ensures:
409170222Sdougb *\li	On a return of ISC_R_SUCCESS, 'target' contains a wire format
410135446Strhodes *	for the data contained in 'rdataset'.  Any error return leaves
411135446Strhodes *	the buffer unchanged.
412135446Strhodes *
413170222Sdougb *\li	*countp has been incremented by the number of RRs added to
414135446Strhodes *	target.
415135446Strhodes *
416135446Strhodes * Returns:
417170222Sdougb *\li	#ISC_R_SUCCESS		- all ok
418170222Sdougb *\li	#ISC_R_NOSPACE		- 'target' doesn't have enough room
419135446Strhodes *
420170222Sdougb *\li	Any error returned by dns_rdata_towire(), dns_rdataset_next(),
421135446Strhodes *	dns_name_towire().
422135446Strhodes */
423135446Strhodes
424135446Strhodesisc_result_t
425135446Strhodesdns_rdataset_towiresorted(dns_rdataset_t *rdataset,
426165071Sdougb			  const dns_name_t *owner_name,
427135446Strhodes			  dns_compress_t *cctx,
428135446Strhodes			  isc_buffer_t *target,
429135446Strhodes			  dns_rdatasetorderfunc_t order,
430165071Sdougb			  const void *order_arg,
431135446Strhodes			  unsigned int options,
432135446Strhodes			  unsigned int *countp);
433170222Sdougb/*%<
434135446Strhodes * Like dns_rdataset_towire(), but sorting the rdatasets according to
435193149Sdougb * the integer value returned by 'order' when called with the rdataset
436135446Strhodes * and 'order_arg' as arguments.
437135446Strhodes *
438135446Strhodes * Requires:
439170222Sdougb *\li	All the requirements of dns_rdataset_towire(), and
440135446Strhodes *	that order_arg is NULL if and only if order is NULL.
441135446Strhodes */
442135446Strhodes
443135446Strhodesisc_result_t
444135446Strhodesdns_rdataset_towirepartial(dns_rdataset_t *rdataset,
445165071Sdougb			   const dns_name_t *owner_name,
446135446Strhodes			   dns_compress_t *cctx,
447135446Strhodes			   isc_buffer_t *target,
448135446Strhodes			   dns_rdatasetorderfunc_t order,
449165071Sdougb			   const void *order_arg,
450135446Strhodes			   unsigned int options,
451135446Strhodes			   unsigned int *countp,
452135446Strhodes			   void **state);
453170222Sdougb/*%<
454135446Strhodes * Like dns_rdataset_towiresorted() except that a partial rdataset
455135446Strhodes * may be written.
456135446Strhodes *
457135446Strhodes * Requires:
458170222Sdougb *\li	All the requirements of dns_rdataset_towiresorted().
459135446Strhodes *	If 'state' is non NULL then the current position in the
460135446Strhodes *	rdataset will be remembered if the rdataset in not
461135446Strhodes *	completely written and should be passed on on subsequent
462135446Strhodes *	calls (NOT CURRENTLY IMPLEMENTED).
463135446Strhodes *
464135446Strhodes * Returns:
465170222Sdougb *\li	#ISC_R_SUCCESS if all of the records were written.
466170222Sdougb *\li	#ISC_R_NOSPACE if unable to fit in all of the records. *countp
467135446Strhodes *		      will be updated to reflect the number of records
468135446Strhodes *		      written.
469135446Strhodes */
470135446Strhodes
471135446Strhodesisc_result_t
472135446Strhodesdns_rdataset_additionaldata(dns_rdataset_t *rdataset,
473135446Strhodes			    dns_additionaldatafunc_t add, void *arg);
474170222Sdougb/*%<
475135446Strhodes * For each rdata in rdataset, call 'add' for each name and type in the
476135446Strhodes * rdata which is subject to additional section processing.
477135446Strhodes *
478135446Strhodes * Requires:
479135446Strhodes *
480170222Sdougb *\li	'rdataset' is a valid, non-question rdataset.
481135446Strhodes *
482170222Sdougb *\li	'add' is a valid dns_additionaldatafunc_t
483135446Strhodes *
484135446Strhodes * Ensures:
485135446Strhodes *
486170222Sdougb *\li	If successful, dns_rdata_additionaldata() will have been called for
487135446Strhodes *	each rdata in 'rdataset'.
488135446Strhodes *
489170222Sdougb *\li	If a call to dns_rdata_additionaldata() is not successful, the
490135446Strhodes *	result returned will be the result of dns_rdataset_additionaldata().
491135446Strhodes *
492135446Strhodes * Returns:
493135446Strhodes *
494170222Sdougb *\li	#ISC_R_SUCCESS
495135446Strhodes *
496170222Sdougb *\li	Any error that dns_rdata_additionaldata() can return.
497135446Strhodes */
498135446Strhodes
499135446Strhodesisc_result_t
500135446Strhodesdns_rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name,
501193149Sdougb			dns_rdataset_t *neg, dns_rdataset_t *negsig);
502170222Sdougb/*%<
503135446Strhodes * Return the noqname proof for this record.
504135446Strhodes *
505135446Strhodes * Requires:
506170222Sdougb *\li	'rdataset' to be valid and #DNS_RDATASETATTR_NOQNAME to be set.
507170222Sdougb *\li	'name' to be valid.
508193149Sdougb *\li	'neg' and 'negsig' to be valid and not associated.
509135446Strhodes */
510135446Strhodes
511135446Strhodesisc_result_t
512135446Strhodesdns_rdataset_addnoqname(dns_rdataset_t *rdataset, dns_name_t *name);
513170222Sdougb/*%<
514135446Strhodes * Associate a noqname proof with this record.
515170222Sdougb * Sets #DNS_RDATASETATTR_NOQNAME if successful.
516135446Strhodes * Adjusts the 'rdataset->ttl' to minimum of the 'rdataset->ttl' and
517193149Sdougb * the 'nsec'/'nsec3' and 'rrsig(nsec)'/'rrsig(nsec3)' ttl.
518135446Strhodes *
519135446Strhodes * Requires:
520170222Sdougb *\li	'rdataset' to be valid and #DNS_RDATASETATTR_NOQNAME to be set.
521193149Sdougb *\li	'name' to be valid and have NSEC or NSEC3 and associated RRSIG
522193149Sdougb *	 rdatasets.
523135446Strhodes */
524135446Strhodes
525170222Sdougbisc_result_t
526193149Sdougbdns_rdataset_getclosest(dns_rdataset_t *rdataset, dns_name_t *name,
527193149Sdougb			dns_rdataset_t *nsec, dns_rdataset_t *nsecsig);
528193149Sdougb/*%<
529193149Sdougb * Return the closest encloser for this record.
530193149Sdougb *
531193149Sdougb * Requires:
532193149Sdougb *\li	'rdataset' to be valid and #DNS_RDATASETATTR_CLOSEST to be set.
533193149Sdougb *\li	'name' to be valid.
534193149Sdougb *\li	'nsec' and 'nsecsig' to be valid and not associated.
535193149Sdougb */
536193149Sdougb
537193149Sdougbisc_result_t
538193149Sdougbdns_rdataset_addclosest(dns_rdataset_t *rdataset, dns_name_t *name);
539193149Sdougb/*%<
540193149Sdougb * Associate a closest encloset proof with this record.
541193149Sdougb * Sets #DNS_RDATASETATTR_CLOSEST if successful.
542193149Sdougb * Adjusts the 'rdataset->ttl' to minimum of the 'rdataset->ttl' and
543193149Sdougb * the 'nsec' and 'rrsig(nsec)' ttl.
544193149Sdougb *
545193149Sdougb * Requires:
546193149Sdougb *\li	'rdataset' to be valid and #DNS_RDATASETATTR_CLOSEST to be set.
547193149Sdougb *\li	'name' to be valid and have NSEC3 and RRSIG(NSEC3) rdatasets.
548193149Sdougb */
549193149Sdougb
550193149Sdougbisc_result_t
551170222Sdougbdns_rdataset_getadditional(dns_rdataset_t *rdataset,
552170222Sdougb			   dns_rdatasetadditional_t type,
553170222Sdougb			   dns_rdatatype_t qtype,
554170222Sdougb			   dns_acache_t *acache,
555170222Sdougb			   dns_zone_t **zonep,
556170222Sdougb			   dns_db_t **dbp,
557170222Sdougb			   dns_dbversion_t **versionp,
558170222Sdougb			   dns_dbnode_t **nodep,
559170222Sdougb			   dns_name_t *fname,
560170222Sdougb			   dns_message_t *msg,
561170222Sdougb			   isc_stdtime_t now);
562170222Sdougb/*%<
563170222Sdougb * Get cached additional information from the DB node for a particular
564170222Sdougb * 'rdataset.'  'type' is one of dns_rdatasetadditional_fromauth,
565170222Sdougb * dns_rdatasetadditional_fromcache, and dns_rdatasetadditional_fromglue,
566170222Sdougb * which specifies the origin of the information.  'qtype' is intended to
567170222Sdougb * be used for specifying a particular rdata type in the cached information.
568170222Sdougb *
569170222Sdougb * Requires:
570170222Sdougb * \li	'rdataset' is a valid rdataset.
571170222Sdougb * \li	'acache' can be NULL, in which case this function will simply return
572170222Sdougb * 	ISC_R_FAILURE.
573170222Sdougb * \li	For the other pointers, see dns_acache_getentry().
574170222Sdougb *
575170222Sdougb * Ensures:
576170222Sdougb * \li	See dns_acache_getentry().
577170222Sdougb *
578170222Sdougb * Returns:
579170222Sdougb * \li	#ISC_R_SUCCESS
580170222Sdougb * \li	#ISC_R_FAILURE	- additional information caching is not supported.
581170222Sdougb * \li	#ISC_R_NOTFOUND	- the corresponding DB node has not cached additional
582170222Sdougb *			  information for 'rdataset.'
583170222Sdougb * \li	Any error that dns_acache_getentry() can return.
584170222Sdougb */
585170222Sdougb
586170222Sdougbisc_result_t
587170222Sdougbdns_rdataset_setadditional(dns_rdataset_t *rdataset,
588170222Sdougb			   dns_rdatasetadditional_t type,
589170222Sdougb			   dns_rdatatype_t qtype,
590170222Sdougb			   dns_acache_t *acache,
591170222Sdougb			   dns_zone_t *zone,
592170222Sdougb			   dns_db_t *db,
593170222Sdougb			   dns_dbversion_t *version,
594170222Sdougb			   dns_dbnode_t *node,
595170222Sdougb			   dns_name_t *fname);
596170222Sdougb/*%<
597170222Sdougb * Set cached additional information to the DB node for a particular
598170222Sdougb * 'rdataset.'  See dns_rdataset_getadditional for the semantics of 'type'
599170222Sdougb * and 'qtype'.
600170222Sdougb *
601170222Sdougb * Requires:
602170222Sdougb * \li	'rdataset' is a valid rdataset.
603170222Sdougb * \li	'acache' can be NULL, in which case this function will simply return
604170222Sdougb *	ISC_R_FAILURE.
605170222Sdougb * \li	For the other pointers, see dns_acache_setentry().
606170222Sdougb *
607170222Sdougb * Ensures:
608170222Sdougb * \li	See dns_acache_setentry().
609170222Sdougb *
610170222Sdougb * Returns:
611170222Sdougb * \li	#ISC_R_SUCCESS
612170222Sdougb * \li	#ISC_R_FAILURE	- additional information caching is not supported.
613170222Sdougb * \li	#ISC_R_NOMEMORY
614170222Sdougb * \li	Any error that dns_acache_setentry() can return.
615170222Sdougb */
616170222Sdougb
617170222Sdougbisc_result_t
618170222Sdougbdns_rdataset_putadditional(dns_acache_t *acache,
619170222Sdougb			   dns_rdataset_t *rdataset,
620170222Sdougb			   dns_rdatasetadditional_t type,
621170222Sdougb			   dns_rdatatype_t qtype);
622170222Sdougb/*%<
623170222Sdougb * Discard cached additional information stored in the DB node for a particular
624170222Sdougb * 'rdataset.'  See dns_rdataset_getadditional for the semantics of 'type'
625170222Sdougb * and 'qtype'.
626170222Sdougb *
627170222Sdougb * Requires:
628170222Sdougb * \li	'rdataset' is a valid rdataset.
629170222Sdougb * \li	'acache' can be NULL, in which case this function will simply return
630170222Sdougb *	ISC_R_FAILURE.
631170222Sdougb *
632170222Sdougb * Ensures:
633170222Sdougb * \li	See dns_acache_cancelentry().
634170222Sdougb *
635170222Sdougb * Returns:
636170222Sdougb * \li	#ISC_R_SUCCESS
637170222Sdougb * \li	#ISC_R_FAILURE	- additional information caching is not supported.
638170222Sdougb * \li	#ISC_R_NOTFOUND	- the corresponding DB node has not cached additional
639170222Sdougb *			  information for 'rdataset.'
640170222Sdougb */
641170222Sdougb
642205292Sdougbvoid
643205292Sdougbdns_rdataset_settrust(dns_rdataset_t *rdataset, dns_trust_t trust);
644205292Sdougb/*%<
645205292Sdougb * Set the trust of the 'rdataset' to trust in any in the backing database.
646205292Sdougb * The local trust level of 'rdataset' is also set.
647205292Sdougb */
648205292Sdougb
649205292Sdougbvoid
650205292Sdougbdns_rdataset_expire(dns_rdataset_t *rdataset);
651205292Sdougb/*%<
652205292Sdougb * Mark the rdataset to be expired in the backing database.
653205292Sdougb */
654205292Sdougb
655245163Serwinvoid
656245163Serwindns_rdataset_trimttl(dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
657245163Serwin		     dns_rdata_rrsig_t *rrsig, isc_stdtime_t now,
658245163Serwin		     isc_boolean_t acceptexpired);
659245163Serwin/*%<
660245163Serwin * Trim the ttl of 'rdataset' and 'sigrdataset' so that they will expire
661245163Serwin * at or before 'rrsig->expiretime'.  If 'acceptexpired' is true and the
662245163Serwin * signature has expired or will expire in the next 120 seconds, limit
663245163Serwin * the ttl to be no more than 120 seconds.
664245163Serwin *
665245163Serwin * The ttl is further limited by the original ttl as stored in 'rrsig'
666245163Serwin * and the original ttl values of 'rdataset' and 'sigrdataset'.
667245163Serwin *
668245163Serwin * Requires:
669245163Serwin * \li	'rdataset' is a valid rdataset.
670245163Serwin * \li	'sigrdataset' is a valid rdataset.
671245163Serwin * \li	'rrsig' is non NULL.
672245163Serwin */
673245163Serwin
674222395Sdougbconst char *
675222395Sdougbdns_trust_totext(dns_trust_t trust);
676225361Sdougb/*
677222395Sdougb * Display trust in textual form.
678222395Sdougb */
679222395Sdougb
680135446StrhodesISC_LANG_ENDDECLS
681135446Strhodes
682135446Strhodes#endif /* DNS_RDATASET_H */
683