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