Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / rdataset.h
blobfc3ac4aa83296914792bf29bba069a445734296d
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: rdataset.h,v 1.41.2.6 2004/03/09 06:11:20 marka Exp $ */
20 #ifndef DNS_RDATASET_H
21 #define DNS_RDATASET_H 1
23 /*****
24 ***** Module Info
25 *****/
28 * DNS Rdataset
30 * A DNS rdataset is a handle that can be associated with a collection of
31 * rdata all having a common owner name, class, and type.
33 * The dns_rdataset_t type is like a "virtual class". To actually use
34 * rdatasets, an implementation of the method suite (e.g. "slabbed rdata") is
35 * required.
37 * XXX <more> XXX
39 * MP:
40 * Clients of this module must impose any required synchronization.
42 * Reliability:
43 * No anticipated impact.
45 * Resources:
46 * <TBS>
48 * Security:
49 * No anticipated impact.
51 * Standards:
52 * None.
55 #include <isc/lang.h>
56 #include <isc/magic.h>
58 #include <dns/types.h>
60 ISC_LANG_BEGINDECLS
62 typedef struct dns_rdatasetmethods {
63 void (*disassociate)(dns_rdataset_t *rdataset);
64 isc_result_t (*first)(dns_rdataset_t *rdataset);
65 isc_result_t (*next)(dns_rdataset_t *rdataset);
66 void (*current)(dns_rdataset_t *rdataset,
67 dns_rdata_t *rdata);
68 void (*clone)(dns_rdataset_t *source,
69 dns_rdataset_t *target);
70 unsigned int (*count)(dns_rdataset_t *rdataset);
71 } dns_rdatasetmethods_t;
73 #define DNS_RDATASET_MAGIC ISC_MAGIC('D','N','S','R')
74 #define DNS_RDATASET_VALID(set) ISC_MAGIC_VALID(set, DNS_RDATASET_MAGIC)
77 * Direct use of this structure by clients is strongly discouraged, except
78 * for the 'link' field which may be used however the client wishes. The
79 * 'private', 'current', and 'index' fields MUST NOT be changed by clients.
80 * rdataset implementations may change any of the fields.
82 struct dns_rdataset {
83 unsigned int magic; /* XXX ? */
84 dns_rdatasetmethods_t * methods;
85 ISC_LINK(dns_rdataset_t) link;
87 * XXX do we need these, or should they be retrieved by methods?
88 * Leaning towards the latter, since they are not frequently required
89 * once you have the rdataset.
91 dns_rdataclass_t rdclass;
92 dns_rdatatype_t type;
93 dns_ttl_t ttl;
94 dns_trust_t trust;
95 dns_rdatatype_t covers;
97 * attributes
99 unsigned int attributes;
101 * These are for use by the rdataset implementation, and MUST NOT
102 * be changed by clients.
104 void * private1;
105 void * private2;
106 void * private3;
107 unsigned int privateuint4;
108 void * private5;
112 * _RENDERED:
113 * Used by message.c to indicate that the rdataset was rendered.
115 * _TTLADJUSTED:
116 * Used by message.c to indicate that the rdataset's rdata had differing
117 * TTL values, and the rdataset->ttl holds the smallest.
119 #define DNS_RDATASETATTR_QUESTION 0x0001
120 #define DNS_RDATASETATTR_RENDERED 0x0002 /* Used by message.c */
121 #define DNS_RDATASETATTR_ANSWERED 0x0004 /* Used by server. */
122 #define DNS_RDATASETATTR_CACHE 0x0008 /* Used by resolver. */
123 #define DNS_RDATASETATTR_ANSWER 0x0010 /* Used by resolver. */
124 #define DNS_RDATASETATTR_ANSWERSIG 0x0020 /* Used by resolver. */
125 #define DNS_RDATASETATTR_EXTERNAL 0x0040 /* Used by resolver. */
126 #define DNS_RDATASETATTR_NCACHE 0x0080 /* Used by resolver. */
127 #define DNS_RDATASETATTR_CHAINING 0x0100 /* Used by resolver. */
128 #define DNS_RDATASETATTR_TTLADJUSTED 0x0200 /* Used by message.c */
129 #define DNS_RDATASETATTR_FIXEDORDER 0x0400
130 #define DNS_RDATASETATTR_RANDOMIZE 0x0800
131 #define DNS_RDATASETATTR_CHASE 0x1000 /* Used by resolver. */
132 #define DNS_RDATASETATTR_NXDOMAIN 0x2000
134 void
135 dns_rdataset_init(dns_rdataset_t *rdataset);
137 * Make 'rdataset' a valid, disassociated rdataset.
139 * Requires:
140 * 'rdataset' is not NULL.
142 * Ensures:
143 * 'rdataset' is a valid, disassociated rdataset.
146 void
147 dns_rdataset_invalidate(dns_rdataset_t *rdataset);
149 * Invalidate 'rdataset'.
151 * Requires:
152 * 'rdataset' is a valid, disassociated rdataset.
154 * Ensures:
155 * If assertion checking is enabled, future attempts to use 'rdataset'
156 * without initializing it will cause an assertion failure.
159 void
160 dns_rdataset_disassociate(dns_rdataset_t *rdataset);
162 * Disassociate 'rdataset' from its rdata, allowing it to be reused.
164 * Notes:
165 * The client must ensure it has no references to rdata in the rdataset
166 * before disassociating.
168 * Requires:
169 * 'rdataset' is a valid, associated rdataset.
171 * Ensures:
172 * 'rdataset' is a valid, disassociated rdataset.
175 isc_boolean_t
176 dns_rdataset_isassociated(dns_rdataset_t *rdataset);
178 * Is 'rdataset' associated?
180 * Requires:
181 * 'rdataset' is a valid rdataset.
183 * Returns:
184 * ISC_TRUE 'rdataset' is associated.
185 * ISC_FALSE 'rdataset' is not associated.
188 void
189 dns_rdataset_makequestion(dns_rdataset_t *rdataset, dns_rdataclass_t rdclass,
190 dns_rdatatype_t type);
192 * Make 'rdataset' a valid, associated, question rdataset, with a
193 * question class of 'rdclass' and type 'type'.
195 * Notes:
196 * Question rdatasets have a class and type, but no rdata.
198 * Requires:
199 * 'rdataset' is a valid, disassociated rdataset.
201 * Ensures:
202 * 'rdataset' is a valid, associated, question rdataset.
205 void
206 dns_rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target);
208 * Make 'target' refer to the same rdataset as 'source'.
210 * Requires:
211 * 'source' is a valid, associated rdataset.
213 * 'target' is a valid, dissociated rdataset.
215 * Ensures:
216 * 'target' references the same rdataset as 'source'.
219 unsigned int
220 dns_rdataset_count(dns_rdataset_t *rdataset);
222 * Return the number of records in 'rdataset'.
224 * Requires:
225 * 'rdataset' is a valid, associated rdataset.
227 * Returns:
228 * The number of records in 'rdataset'.
231 isc_result_t
232 dns_rdataset_first(dns_rdataset_t *rdataset);
234 * Move the rdata cursor to the first rdata in the rdataset (if any).
236 * Requires:
237 * 'rdataset' is a valid, associated rdataset.
239 * Returns:
240 * ISC_R_SUCCESS
241 * ISC_R_NOMORE There are no rdata in the set.
244 isc_result_t
245 dns_rdataset_next(dns_rdataset_t *rdataset);
247 * Move the rdata cursor to the next rdata in the rdataset (if any).
249 * Requires:
250 * 'rdataset' is a valid, associated rdataset.
252 * Returns:
253 * ISC_R_SUCCESS
254 * ISC_R_NOMORE There are no more rdata in the set.
257 void
258 dns_rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata);
260 * Make 'rdata' refer to the current rdata.
262 * Notes:
264 * The data returned in 'rdata' is valid for the life of the
265 * rdataset; in particular, subsequent changes in the cursor position
266 * do not invalidate 'rdata'.
268 * Requires:
269 * 'rdataset' is a valid, associated rdataset.
271 * The rdata cursor of 'rdataset' is at a valid location (i.e. the
272 * result of last call to a cursor movement command was ISC_R_SUCCESS).
274 * Ensures:
275 * 'rdata' refers to the rdata at the rdata cursor location of
276 * 'rdataset'.
279 isc_result_t
280 dns_rdataset_totext(dns_rdataset_t *rdataset,
281 dns_name_t *owner_name,
282 isc_boolean_t omit_final_dot,
283 isc_boolean_t question,
284 isc_buffer_t *target);
286 * Convert 'rdataset' to text format, storing the result in 'target'.
288 * Notes:
289 * The rdata cursor position will be changed.
291 * The 'question' flag should normally be ISC_FALSE. If it is
292 * ISC_TRUE, the TTL and rdata fields are not printed. This is
293 * for use when printing an rdata representing a question section.
295 * This interface is deprecated; use dns_master_rdatasettottext()
296 * and/or dns_master_questiontotext() instead.
298 * Requires:
299 * 'rdataset' is a valid rdataset.
301 * 'rdataset' is not empty.
304 isc_result_t
305 dns_rdataset_towire(dns_rdataset_t *rdataset,
306 dns_name_t *owner_name,
307 dns_compress_t *cctx,
308 isc_buffer_t *target,
309 unsigned int *countp);
311 * Convert 'rdataset' to wire format, compressing names as specified
312 * in 'cctx', and storing the result in 'target'.
314 * Notes:
315 * The rdata cursor position will be changed.
317 * The number of RRs added to target will be added to *countp.
319 * Requires:
320 * 'rdataset' is a valid rdataset.
322 * 'rdataset' is not empty.
324 * 'countp' is a valid pointer.
326 * Ensures:
327 * On a return of ISC_R_SUCCESS, 'target' contains a wire format
328 * for the data contained in 'rdataset'. Any error return leaves
329 * the buffer unchanged.
331 * *countp has been incremented by the number of RRs added to
332 * target.
334 * Returns:
335 * ISC_R_SUCCESS - all ok
336 * ISC_R_NOSPACE - 'target' doesn't have enough room
338 * Any error returned by dns_rdata_towire(), dns_rdataset_next(),
339 * dns_name_towire().
342 isc_result_t
343 dns_rdataset_towiresorted(dns_rdataset_t *rdataset,
344 dns_name_t *owner_name,
345 dns_compress_t *cctx,
346 isc_buffer_t *target,
347 dns_rdatasetorderfunc_t order,
348 void *order_arg,
349 unsigned int *countp);
351 * Like dns_rdataset_towire(), but sorting the rdatasets according to
352 * the integer value returned by 'order' when called witih the rdataset
353 * and 'order_arg' as arguments.
355 * Requires:
356 * All the requirements of dns_rdataset_towire(), and
357 * that order_arg is NULL if and only if order is NULL.
360 isc_result_t
361 dns_rdataset_towirepartial(dns_rdataset_t *rdataset,
362 dns_name_t *owner_name,
363 dns_compress_t *cctx,
364 isc_buffer_t *target,
365 dns_rdatasetorderfunc_t order,
366 void *order_arg,
367 unsigned int *countp,
368 void **state);
370 * Like dns_rdataset_towiresorted() except that a partial rdataset
371 * may be written.
373 * Requires:
374 * All the requirements of dns_rdataset_towiresorted().
375 * If 'state' is non NULL then the current position in the
376 * rdataset will be remembered if the rdataset in not
377 * completely written and should be passed on on subsequent
378 * calls (NOT CURRENTLY IMPLEMENTED).
380 * Returns:
381 * ISC_R_SUCCESS if all of the records were written.
382 * ISC_R_NOSPACE if unable to fit in all of the records. *countp
383 * will be updated to reflect the number of records
384 * written.
388 isc_result_t
389 dns_rdataset_additionaldata(dns_rdataset_t *rdataset,
390 dns_additionaldatafunc_t add, void *arg);
392 * For each rdata in rdataset, call 'add' for each name and type in the
393 * rdata which is subject to additional section processing.
395 * Requires:
397 * 'rdataset' is a valid, non-question rdataset.
399 * 'add' is a valid dns_additionaldatafunc_t
401 * Ensures:
403 * If successful, dns_rdata_additionaldata() will have been called for
404 * each rdata in 'rdataset'.
406 * If a call to dns_rdata_additionaldata() is not successful, the
407 * result returned will be the result of dns_rdataset_additionaldata().
409 * Returns:
411 * ISC_R_SUCCESS
413 * Any error that dns_rdata_additionaldata() can return.
416 ISC_LANG_ENDDECLS
418 #endif /* DNS_RDATASET_H */