xref: /minix/external/bsd/bind/dist/lib/dns/include/dns/rdata.h (revision fb9c64b2)
1 /*	$NetBSD: rdata.h,v 1.9 2014/12/10 04:37:58 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2009, 2011-2013  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 1998-2003  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /* Id: rdata.h,v 1.80 2011/03/20 02:31:53 marka Exp  */
21 
22 #ifndef DNS_RDATA_H
23 #define DNS_RDATA_H 1
24 
25 /*****
26  ***** Module Info
27  *****/
28 
29 /*! \file dns/rdata.h
30  * \brief
31  * Provides facilities for manipulating DNS rdata, including conversions to
32  * and from wire format and text format.
33  *
34  * Given the large amount of rdata possible in a nameserver, it was important
35  * to come up with a very efficient way of storing rdata, but at the same
36  * time allow it to be manipulated.
37  *
38  * The decision was to store rdata in uncompressed wire format,
39  * and not to make it a fully abstracted object; i.e. certain parts of the
40  * server know rdata is stored that way.  This saves a lot of memory, and
41  * makes adding rdata to messages easy.  Having much of the server know
42  * the representation would be perilous, and we certainly don't want each
43  * user of rdata to be manipulating such a low-level structure.  This is
44  * where the rdata module comes in.  The module allows rdata handles to be
45  * created and attached to uncompressed wire format regions.  All rdata
46  * operations and conversions are done through these handles.
47  *
48  * Implementation Notes:
49  *
50  *\li	The routines in this module are expected to be synthesized by the
51  *	build process from a set of source files, one per rdata type.  For
52  *	portability, it's probably best that the building be done by a C
53  *	program.  Adding a new rdata type will be a simple matter of adding
54  *	a file to a directory and rebuilding the server.  *All* knowledge of
55  *	the format of a particular rdata type is in this file.
56  *
57  * MP:
58  *\li	Clients of this module must impose any required synchronization.
59  *
60  * Reliability:
61  *\li	This module deals with low-level byte streams.  Errors in any of
62  *	the functions are likely to crash the server or corrupt memory.
63  *
64  *\li	Rdata is typed, and the caller must know what type of rdata it has.
65  *	A caller that gets this wrong could crash the server.
66  *
67  *\li	The fromstruct() and tostruct() routines use a void * pointer to
68  *	represent the structure.  The caller must ensure that it passes a
69  *	pointer to the appropriate type, or the server could crash or memory
70  *	could be corrupted.
71  *
72  * Resources:
73  *\li	None.
74  *
75  * Security:
76  *
77  *\li	*** WARNING ***
78  *	dns_rdata_fromwire() deals with raw network data.  An error in
79  *	this routine could result in the failure or hijacking of the server.
80  *
81  * Standards:
82  *\li	RFC1035
83  *\li	Draft EDNS0 (0)
84  *\li	Draft EDNS1 (0)
85  *\li	Draft Binary Labels (2)
86  *\li	Draft Local Compression (1)
87  *\li	Various RFCs for particular types; these will be documented in the
88  *	 sources files of the types.
89  *
90  */
91 
92 /***
93  *** Imports
94  ***/
95 
96 #include <isc/lang.h>
97 
98 #include <dns/types.h>
99 #include <dns/name.h>
100 #include <dns/message.h>
101 
102 ISC_LANG_BEGINDECLS
103 
104 
105 /***
106  *** Types
107  ***/
108 
109 /*%
110  ***** An 'rdata' is a handle to a binary region.  The handle has an RR
111  ***** class and type, and the data in the binary region is in the format
112  ***** of the given class and type.
113  *****/
114 /*%
115  * Clients are strongly discouraged from using this type directly, with
116  * the exception of the 'link' field which may be used directly for whatever
117  * purpose the client desires.
118  */
119 struct dns_rdata {
120 	unsigned char *			data;
121 	unsigned int			length;
122 	dns_rdataclass_t		rdclass;
123 	dns_rdatatype_t			type;
124 	unsigned int			flags;
125 	ISC_LINK(dns_rdata_t)		link;
126 };
127 
128 #define DNS_RDATA_INIT { NULL, 0, 0, 0, 0, {(void*)(-1), (void *)(-1)}}
129 
130 #define DNS_RDATA_CHECKINITIALIZED
131 #ifdef DNS_RDATA_CHECKINITIALIZED
132 #define DNS_RDATA_INITIALIZED(rdata) \
133 	((rdata)->data == NULL && (rdata)->length == 0 && \
134 	 (rdata)->rdclass == 0 && (rdata)->type == 0 && (rdata)->flags == 0 && \
135 	 !ISC_LINK_LINKED((rdata), link))
136 #else
137 #ifdef ISC_LIST_CHECKINIT
138 #define DNS_RDATA_INITIALIZED(rdata) \
139 	(!ISC_LINK_LINKED((rdata), link))
140 #else
141 #define DNS_RDATA_INITIALIZED(rdata) ISC_TRUE
142 #endif
143 #endif
144 
145 #define DNS_RDATA_UPDATE	0x0001		/*%< update pseudo record. */
146 #define DNS_RDATA_OFFLINE	0x0002		/*%< RRSIG has a offline key. */
147 
148 #define DNS_RDATA_VALIDFLAGS(rdata) \
149 	(((rdata)->flags & ~(DNS_RDATA_UPDATE|DNS_RDATA_OFFLINE)) == 0)
150 
151 /*
152  * The maximum length of a RDATA that can be sent on the wire.
153  * Max packet size (65535) less header (12), less name (1), type (2),
154  * class (2), ttl(4), length (2).
155  *
156  * None of the defined types that support name compression can exceed
157  * this and all new types are to be sent uncompressed.
158  */
159 
160 #define DNS_RDATA_MAXLENGTH	65512U
161 
162 /*
163  * Flags affecting rdata formatting style.  Flags 0xFFFF0000
164  * are used by masterfile-level formatting and defined elsewhere.
165  * See additional comments at dns_rdata_tofmttext().
166  */
167 
168 /*% Split the rdata into multiple lines to try to keep it
169  within the "width". */
170 #define DNS_STYLEFLAG_MULTILINE		0x00000001U
171 
172 /*% Output explanatory comments. */
173 #define DNS_STYLEFLAG_COMMENT		0x00000002U
174 #define DNS_STYLEFLAG_RRCOMMENT		0x00000004U
175 
176 /*% Output KEYDATA in human readable format. */
177 #define DNS_STYLEFLAG_KEYDATA		0x00000008U
178 
179 #define DNS_RDATA_DOWNCASE		DNS_NAME_DOWNCASE
180 #define DNS_RDATA_CHECKNAMES		DNS_NAME_CHECKNAMES
181 #define DNS_RDATA_CHECKNAMESFAIL	DNS_NAME_CHECKNAMESFAIL
182 #define DNS_RDATA_CHECKREVERSE		DNS_NAME_CHECKREVERSE
183 #define DNS_RDATA_CHECKMX		DNS_NAME_CHECKMX
184 #define DNS_RDATA_CHECKMXFAIL		DNS_NAME_CHECKMXFAIL
185 #define DNS_RDATA_UNKNOWNESCAPE		0x80000000
186 
187 /***
188  *** Initialization
189  ***/
190 
191 void
192 dns_rdata_init(dns_rdata_t *rdata);
193 /*%<
194  * Make 'rdata' empty.
195  *
196  * Requires:
197  *	'rdata' is a valid rdata (i.e. not NULL, points to a struct dns_rdata)
198  */
199 
200 void
201 dns_rdata_reset(dns_rdata_t *rdata);
202 /*%<
203  * Make 'rdata' empty.
204  *
205  * Requires:
206  *\li	'rdata' is a previously initialized rdata and is not linked.
207  */
208 
209 void
210 dns_rdata_clone(const dns_rdata_t *src, dns_rdata_t *target);
211 /*%<
212  * Clone 'target' from 'src'.
213  *
214  * Requires:
215  *\li	'src' to be initialized.
216  *\li	'target' to be initialized.
217  */
218 
219 /***
220  *** Comparisons
221  ***/
222 
223 int
224 dns_rdata_compare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2);
225 /*%<
226  * Determine the relative ordering under the DNSSEC order relation of
227  * 'rdata1' and 'rdata2'.
228  *
229  * Requires:
230  *
231  *\li	'rdata1' is a valid, non-empty rdata
232  *
233  *\li	'rdata2' is a valid, non-empty rdata
234  *
235  * Returns:
236  *\li	< 0		'rdata1' is less than 'rdata2'
237  *\li	0		'rdata1' is equal to 'rdata2'
238  *\li	> 0		'rdata1' is greater than 'rdata2'
239  */
240 
241 int
242 dns_rdata_casecompare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2);
243 /*%<
244  * dns_rdata_casecompare() is similar to dns_rdata_compare() but also
245  * compares domain names case insensitively in known rdata types that
246  * are treated as opaque data by dns_rdata_compare().
247  *
248  * Requires:
249  *
250  *\li	'rdata1' is a valid, non-empty rdata
251  *
252  *\li	'rdata2' is a valid, non-empty rdata
253  *
254  * Returns:
255  *\li	< 0		'rdata1' is less than 'rdata2'
256  *\li	0		'rdata1' is equal to 'rdata2'
257  *\li	> 0		'rdata1' is greater than 'rdata2'
258  */
259 
260 /***
261  *** Conversions
262  ***/
263 
264 void
265 dns_rdata_fromregion(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
266 		     dns_rdatatype_t type, isc_region_t *r);
267 /*%<
268  * Make 'rdata' refer to region 'r'.
269  *
270  * Requires:
271  *
272  *\li	The data in 'r' is properly formatted for whatever type it is.
273  */
274 
275 void
276 dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r);
277 /*%<
278  * Make 'r' refer to 'rdata'.
279  */
280 
281 isc_result_t
282 dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
283 		   dns_rdatatype_t type, isc_buffer_t *source,
284 		   dns_decompress_t *dctx, unsigned int options,
285 		   isc_buffer_t *target);
286 /*%<
287  * Copy the possibly-compressed rdata at source into the target region.
288  *
289  * Notes:
290  *\li	Name decompression policy is controlled by 'dctx'.
291  *
292  *	'options'
293  *\li	DNS_RDATA_DOWNCASE	downcase domain names when they are copied
294  *				into target.
295  *
296  * Requires:
297  *
298  *\li	'rdclass' and 'type' are valid.
299  *
300  *\li	'source' is a valid buffer, and the active region of 'source'
301  *	references the rdata to be processed.
302  *
303  *\li	'target' is a valid buffer.
304  *
305  *\li	'dctx' is a valid decompression context.
306  *
307  * Ensures,
308  *	if result is success:
309  *	\li 	If 'rdata' is not NULL, it is attached to the target.
310  *	\li	The conditions dns_name_fromwire() ensures for names hold
311  *		for all names in the rdata.
312  *	\li	The current location in source is advanced, and the used space
313  *		in target is updated.
314  *
315  * Result:
316  *\li	Success
317  *\li	Any non-success status from dns_name_fromwire()
318  *\li	Various 'Bad Form' class failures depending on class and type
319  *\li	Bad Form: Input too short
320  *\li	Resource Limit: Not enough space
321  */
322 
323 isc_result_t
324 dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
325 		 isc_buffer_t *target);
326 /*%<
327  * Convert 'rdata' into wire format, compressing it as specified by the
328  * compression context 'cctx', and storing the result in 'target'.
329  *
330  * Notes:
331  *\li	If the compression context allows global compression, then the
332  *	global compression table may be updated.
333  *
334  * Requires:
335  *\li	'rdata' is a valid, non-empty rdata
336  *
337  *\li	target is a valid buffer
338  *
339  *\li	Any offsets specified in a global compression table are valid
340  *	for target.
341  *
342  * Ensures,
343  *	if the result is success:
344  *	\li	The used space in target is updated.
345  *
346  * Returns:
347  *\li	Success
348  *\li	Any non-success status from dns_name_towire()
349  *\li	Resource Limit: Not enough space
350  */
351 
352 isc_result_t
353 dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
354 		   dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin,
355 		   unsigned int options, isc_mem_t *mctx,
356 		   isc_buffer_t *target, dns_rdatacallbacks_t *callbacks);
357 /*%<
358  * Convert the textual representation of a DNS rdata into uncompressed wire
359  * form stored in the target region.  Tokens constituting the text of the rdata
360  * are taken from 'lexer'.
361  *
362  * Notes:
363  *\li	Relative domain names in the rdata will have 'origin' appended to them.
364  *	A NULL origin implies "origin == dns_rootname".
365  *
366  *
367  *	'options'
368  *\li	DNS_RDATA_DOWNCASE	downcase domain names when they are copied
369  *				into target.
370  *\li	DNS_RDATA_CHECKNAMES 	perform checknames checks.
371  *\li	DNS_RDATA_CHECKNAMESFAIL fail if the checknames check fail.  If
372  *				not set a warning will be issued.
373  *\li	DNS_RDATA_CHECKREVERSE  this should set if the owner name ends
374  *				in IP6.ARPA, IP6.INT or IN-ADDR.ARPA.
375  *
376  * Requires:
377  *
378  *\li	'rdclass' and 'type' are valid.
379  *
380  *\li	'lexer' is a valid isc_lex_t.
381  *
382  *\li	'mctx' is a valid isc_mem_t.
383  *
384  *\li	'target' is a valid region.
385  *
386  *\li	'origin' if non NULL it must be absolute.
387  *
388  *\li	'callbacks' to be NULL or callbacks->warn and callbacks->error be
389  *	initialized.
390  *
391  * Ensures,
392  *	if result is success:
393  *\li	 	If 'rdata' is not NULL, it is attached to the target.
394 
395  *\li		The conditions dns_name_fromtext() ensures for names hold
396  *		for all names in the rdata.
397 
398  *\li		The used space in target is updated.
399  *
400  * Result:
401  *\li	Success
402  *\li	Translated result codes from isc_lex_gettoken
403  *\li	Various 'Bad Form' class failures depending on class and type
404  *\li	Bad Form: Input too short
405  *\li	Resource Limit: Not enough space
406  *\li	Resource Limit: Not enough memory
407  */
408 
409 isc_result_t
410 dns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target);
411 /*%<
412  * Convert 'rdata' into text format, storing the result in 'target'.
413  * The text will consist of a single line, with fields separated by
414  * single spaces.
415  *
416  * Notes:
417  *\li	If 'origin' is not NULL, then any names in the rdata that are
418  *	subdomains of 'origin' will be made relative it.
419  *
420  *\li	XXX Do we *really* want to support 'origin'?  I'm inclined towards "no"
421  *	at the moment.
422  *
423  * Requires:
424  *
425  *\li	'rdata' is a valid, non-empty rdata
426  *
427  *\li	'origin' is NULL, or is a valid name
428  *
429  *\li	'target' is a valid text buffer
430  *
431  * Ensures,
432  *	if the result is success:
433  *
434  *	\li	The used space in target is updated.
435  *
436  * Returns:
437  *\li	Success
438  *\li	Any non-success status from dns_name_totext()
439  *\li	Resource Limit: Not enough space
440  */
441 
442 isc_result_t
443 dns_rdata_tofmttext(dns_rdata_t *rdata, dns_name_t *origin, unsigned int flags,
444 		    unsigned int width, unsigned int split_width,
445 		    const char *linebreak, isc_buffer_t *target);
446 /*%<
447  * Like dns_rdata_totext, but do formatted output suitable for
448  * database dumps.  This is intended for use by dns_db_dump();
449  * library users are discouraged from calling it directly.
450  *
451  * If (flags & #DNS_STYLEFLAG_MULTILINE) != 0, attempt to stay
452  * within 'width' by breaking the text into multiple lines.
453  * The string 'linebreak' is inserted between lines, and parentheses
454  * are added when necessary.  Because RRs contain unbreakable elements
455  * such as domain names whose length is variable, unpredictable, and
456  * potentially large, there is no guarantee that the lines will
457  * not exceed 'width' anyway.
458  *
459  * If (flags & #DNS_STYLEFLAG_MULTILINE) == 0, the rdata is always
460  * printed as a single line, and no parentheses are used.
461  * The 'width' and 'linebreak' arguments are ignored.
462  *
463  * If (flags & #DNS_STYLEFLAG_COMMENT) != 0, output explanatory
464  * comments next to things like the SOA timer fields.  Some
465  * comments (e.g., the SOA ones) are only printed when multiline
466  * output is selected.
467  *
468  * base64 rdata text (e.g., DNSKEY records) will be split into chunks
469  * of 'split_width' characters.  If split_width == 0, the text will
470  * not be split at all.  If split_width == UINT_MAX (0xffffffff), then
471  * it is undefined and falls back to the default value of 'width'
472  */
473 
474 isc_result_t
475 dns_rdata_fromstruct(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
476 		     dns_rdatatype_t type, void *source, isc_buffer_t *target);
477 /*%<
478  * Convert the C structure representation of an rdata into uncompressed wire
479  * format in 'target'.
480  *
481  * XXX  Should we have a 'size' parameter as a sanity check on target?
482  *
483  * Requires:
484  *
485  *\li	'rdclass' and 'type' are valid.
486  *
487  *\li	'source' points to a valid C struct for the class and type.
488  *
489  *\li	'target' is a valid buffer.
490  *
491  *\li	All structure pointers to memory blocks should be NULL if their
492  *	corresponding length values are zero.
493  *
494  * Ensures,
495  *	if result is success:
496  *	\li 	If 'rdata' is not NULL, it is attached to the target.
497  *
498  *	\li	The used space in 'target' is updated.
499  *
500  * Result:
501  *\li	Success
502  *\li	Various 'Bad Form' class failures depending on class and type
503  *\li	Resource Limit: Not enough space
504  */
505 
506 isc_result_t
507 dns_rdata_tostruct(dns_rdata_t *rdata, void *target, isc_mem_t *mctx);
508 /*%<
509  * Convert an rdata into its C structure representation.
510  *
511  * If 'mctx' is NULL then 'rdata' must persist while 'target' is being used.
512  *
513  * If 'mctx' is non NULL then memory will be allocated if required.
514  *
515  * Requires:
516  *
517  *\li	'rdata' is a valid, non-empty rdata.
518  *
519  *\li	'target' to point to a valid pointer for the type and class.
520  *
521  * Result:
522  *\li	Success
523  *\li	Resource Limit: Not enough memory
524  */
525 
526 void
527 dns_rdata_freestruct(void *source);
528 /*%<
529  * Free dynamic memory attached to 'source' (if any).
530  *
531  * Requires:
532  *
533  *\li	'source' to point to the structure previously filled in by
534  *	dns_rdata_tostruct().
535  */
536 
537 isc_boolean_t
538 dns_rdatatype_ismeta(dns_rdatatype_t type);
539 /*%<
540  * Return true iff the rdata type 'type' is a meta-type
541  * like ANY or AXFR.
542  */
543 
544 isc_boolean_t
545 dns_rdatatype_issingleton(dns_rdatatype_t type);
546 /*%<
547  * Return true iff the rdata type 'type' is a singleton type,
548  * like CNAME or SOA.
549  *
550  * Requires:
551  * \li	'type' is a valid rdata type.
552  *
553  */
554 
555 isc_boolean_t
556 dns_rdataclass_ismeta(dns_rdataclass_t rdclass);
557 /*%<
558  * Return true iff the rdata class 'rdclass' is a meta-class
559  * like ANY or NONE.
560  */
561 
562 isc_boolean_t
563 dns_rdatatype_isdnssec(dns_rdatatype_t type);
564 /*%<
565  * Return true iff 'type' is one of the DNSSEC
566  * rdata types that may exist alongside a CNAME record.
567  *
568  * Requires:
569  * \li	'type' is a valid rdata type.
570  */
571 
572 isc_boolean_t
573 dns_rdatatype_iszonecutauth(dns_rdatatype_t type);
574 /*%<
575  * Return true iff rdata of type 'type' is considered authoritative
576  * data (not glue) in the NSEC chain when it occurs in the parent zone
577  * at a zone cut.
578  *
579  * Requires:
580  * \li	'type' is a valid rdata type.
581  *
582  */
583 
584 isc_boolean_t
585 dns_rdatatype_isknown(dns_rdatatype_t type);
586 /*%<
587  * Return true iff the rdata type 'type' is known.
588  *
589  * Requires:
590  * \li	'type' is a valid rdata type.
591  *
592  */
593 
594 
595 isc_result_t
596 dns_rdata_additionaldata(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
597 			 void *arg);
598 /*%<
599  * Call 'add' for each name and type from 'rdata' which is subject to
600  * additional section processing.
601  *
602  * Requires:
603  *
604  *\li	'rdata' is a valid, non-empty rdata.
605  *
606  *\li	'add' is a valid dns_additionalfunc_t.
607  *
608  * Ensures:
609  *
610  *\li	If successful, then add() will have been called for each name
611  *	and type subject to additional section processing.
612  *
613  *\li	If add() returns something other than #ISC_R_SUCCESS, that result
614  *	will be returned as the result of dns_rdata_additionaldata().
615  *
616  * Returns:
617  *
618  *\li	ISC_R_SUCCESS
619  *
620  *\li	Many other results are possible if not successful.
621  */
622 
623 isc_result_t
624 dns_rdata_digest(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg);
625 /*%<
626  * Send 'rdata' in DNSSEC canonical form to 'digest'.
627  *
628  * Note:
629  *\li	'digest' may be called more than once by dns_rdata_digest().  The
630  *	concatenation of all the regions, in the order they were given
631  *	to 'digest', will be the DNSSEC canonical form of 'rdata'.
632  *
633  * Requires:
634  *
635  *\li	'rdata' is a valid, non-empty rdata.
636  *
637  *\li	'digest' is a valid dns_digestfunc_t.
638  *
639  * Ensures:
640  *
641  *\li	If successful, then all of the rdata's data has been sent, in
642  *	DNSSEC canonical form, to 'digest'.
643  *
644  *\li	If digest() returns something other than ISC_R_SUCCESS, that result
645  *	will be returned as the result of dns_rdata_digest().
646  *
647  * Returns:
648  *
649  *\li	ISC_R_SUCCESS
650  *
651  *\li	Many other results are possible if not successful.
652  */
653 
654 isc_boolean_t
655 dns_rdatatype_questiononly(dns_rdatatype_t type);
656 /*%<
657  * Return true iff rdata of type 'type' can only appear in the question
658  * section of a properly formatted message.
659  *
660  * Requires:
661  * \li	'type' is a valid rdata type.
662  *
663  */
664 
665 isc_boolean_t
666 dns_rdatatype_notquestion(dns_rdatatype_t type);
667 /*%<
668  * Return true iff rdata of type 'type' can not appear in the question
669  * section of a properly formatted message.
670  *
671  * Requires:
672  * \li	'type' is a valid rdata type.
673  *
674  */
675 
676 isc_boolean_t
677 dns_rdatatype_atparent(dns_rdatatype_t type);
678 /*%<
679  * Return true iff rdata of type 'type' should appear at the parent of
680  * a zone cut.
681  *
682  * Requires:
683  * \li	'type' is a valid rdata type.
684  *
685  */
686 
687 unsigned int
688 dns_rdatatype_attributes(dns_rdatatype_t rdtype);
689 /*%<
690  * Return attributes for the given type.
691  *
692  * Requires:
693  *\li	'rdtype' are known.
694  *
695  * Returns:
696  *\li	a bitmask consisting of the following flags.
697  */
698 
699 /*% only one may exist for a name */
700 #define DNS_RDATATYPEATTR_SINGLETON		0x00000001U
701 /*% requires no other data be present */
702 #define DNS_RDATATYPEATTR_EXCLUSIVE		0x00000002U
703 /*% Is a meta type */
704 #define DNS_RDATATYPEATTR_META			0x00000004U
705 /*% Is a DNSSEC type, like RRSIG or NSEC */
706 #define DNS_RDATATYPEATTR_DNSSEC		0x00000008U
707 /*% Is a zone cut authority type */
708 #define DNS_RDATATYPEATTR_ZONECUTAUTH		0x00000010U
709 /*% Is reserved (unusable) */
710 #define DNS_RDATATYPEATTR_RESERVED		0x00000020U
711 /*% Is an unknown type */
712 #define DNS_RDATATYPEATTR_UNKNOWN		0x00000040U
713 /*% Is META, and can only be in a question section */
714 #define DNS_RDATATYPEATTR_QUESTIONONLY		0x00000080U
715 /*% is META, and can NOT be in a question section */
716 #define DNS_RDATATYPEATTR_NOTQUESTION		0x00000100U
717 /*% Is present at zone cuts in the parent, not the child */
718 #define DNS_RDATATYPEATTR_ATPARENT		0x00000200U
719 
720 dns_rdatatype_t
721 dns_rdata_covers(dns_rdata_t *rdata);
722 /*%<
723  * Return the rdatatype that this type covers.
724  *
725  * Requires:
726  *\li	'rdata' is a valid, non-empty rdata.
727  *
728  *\li	'rdata' is a type that covers other rdata types.
729  *
730  * Returns:
731  *\li	The type covered.
732  */
733 
734 isc_boolean_t
735 dns_rdata_checkowner(dns_name_t* name, dns_rdataclass_t rdclass,
736 		     dns_rdatatype_t type, isc_boolean_t wildcard);
737 /*
738  * Returns whether this is a valid ownername for this <type,class>.
739  * If wildcard is true allow the first label to be a wildcard if
740  * appropriate.
741  *
742  * Requires:
743  *	'name' is a valid name.
744  */
745 
746 isc_boolean_t
747 dns_rdata_checknames(dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad);
748 /*
749  * Returns whether 'rdata' contains valid domain names.  The checks are
750  * sensitive to the owner name.
751  *
752  * If 'bad' is non-NULL and a domain name fails the check the
753  * the offending name will be return in 'bad' by cloning from
754  * the 'rdata' contents.
755  *
756  * Requires:
757  *	'rdata' to be valid.
758  *	'owner' to be valid.
759  *	'bad'	to be NULL or valid.
760  */
761 
762 void
763 dns_rdata_exists(dns_rdata_t *rdata, dns_rdatatype_t type);
764 
765 void
766 dns_rdata_notexist(dns_rdata_t *rdata, dns_rdatatype_t type);
767 
768 void
769 dns_rdata_deleterrset(dns_rdata_t *rdata, dns_rdatatype_t type);
770 
771 void
772 dns_rdata_makedelete(dns_rdata_t *rdata);
773 
774 const char *
775 dns_rdata_updateop(dns_rdata_t *rdata, dns_section_t section);
776 
777 ISC_LANG_ENDDECLS
778 
779 #endif /* DNS_RDATA_H */
780