]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - contrib/bind9/lib/dns/include/dns/rdata.h
MFC r362623:
[FreeBSD/stable/8.git] / contrib / bind9 / lib / dns / include / dns / rdata.h
1 /*
2  * Copyright (C) 2004-2009, 2012, 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$ */
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
173 /*% Output KEYDATA in human readable format. */
174 #define DNS_STYLEFLAG_KEYDATA           0x00000008U
175
176 #define DNS_RDATA_DOWNCASE              DNS_NAME_DOWNCASE
177 #define DNS_RDATA_CHECKNAMES            DNS_NAME_CHECKNAMES
178 #define DNS_RDATA_CHECKNAMESFAIL        DNS_NAME_CHECKNAMESFAIL
179 #define DNS_RDATA_CHECKREVERSE          DNS_NAME_CHECKREVERSE
180 #define DNS_RDATA_CHECKMX               DNS_NAME_CHECKMX
181 #define DNS_RDATA_CHECKMXFAIL           DNS_NAME_CHECKMXFAIL
182 #define DNS_RDATA_UNKNOWNESCAPE         0x80000000
183
184 /***
185  *** Initialization
186  ***/
187
188 void
189 dns_rdata_init(dns_rdata_t *rdata);
190 /*%<
191  * Make 'rdata' empty.
192  *
193  * Requires:
194  *      'rdata' is a valid rdata (i.e. not NULL, points to a struct dns_rdata)
195  */
196
197 void
198 dns_rdata_reset(dns_rdata_t *rdata);
199 /*%<
200  * Make 'rdata' empty.
201  *
202  * Requires:
203  *\li   'rdata' is a previously initialized rdata and is not linked.
204  */
205
206 void
207 dns_rdata_clone(const dns_rdata_t *src, dns_rdata_t *target);
208 /*%<
209  * Clone 'target' from 'src'.
210  *
211  * Requires:
212  *\li   'src' to be initialized.
213  *\li   'target' to be initialized.
214  */
215
216 /***
217  *** Comparisons
218  ***/
219
220 int
221 dns_rdata_compare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2);
222 /*%<
223  * Determine the relative ordering under the DNSSEC order relation of
224  * 'rdata1' and 'rdata2'.
225  *
226  * Requires:
227  *
228  *\li   'rdata1' is a valid, non-empty rdata
229  *
230  *\li   'rdata2' is a valid, non-empty rdata
231  *
232  * Returns:
233  *\li   < 0             'rdata1' is less than 'rdata2'
234  *\li   0               'rdata1' is equal to 'rdata2'
235  *\li   > 0             'rdata1' is greater than 'rdata2'
236  */
237
238 int
239 dns_rdata_casecompare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2);
240 /*%<
241  * dns_rdata_casecompare() is similar to dns_rdata_compare() but also
242  * compares domain names case insensitively in known rdata types that
243  * are treated as opaque data by dns_rdata_compare().
244  *
245  * Requires:
246  *
247  *\li   'rdata1' is a valid, non-empty rdata
248  *
249  *\li   'rdata2' is a valid, non-empty rdata
250  *
251  * Returns:
252  *\li   < 0             'rdata1' is less than 'rdata2'
253  *\li   0               'rdata1' is equal to 'rdata2'
254  *\li   > 0             'rdata1' is greater than 'rdata2'
255  */
256
257 /***
258  *** Conversions
259  ***/
260
261 void
262 dns_rdata_fromregion(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
263                      dns_rdatatype_t type, isc_region_t *r);
264 /*%<
265  * Make 'rdata' refer to region 'r'.
266  *
267  * Requires:
268  *
269  *\li   The data in 'r' is properly formatted for whatever type it is.
270  */
271
272 void
273 dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r);
274 /*%<
275  * Make 'r' refer to 'rdata'.
276  */
277
278 isc_result_t
279 dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
280                    dns_rdatatype_t type, isc_buffer_t *source,
281                    dns_decompress_t *dctx, unsigned int options,
282                    isc_buffer_t *target);
283 /*%<
284  * Copy the possibly-compressed rdata at source into the target region.
285  *
286  * Notes:
287  *\li   Name decompression policy is controlled by 'dctx'.
288  *
289  *      'options'
290  *\li   DNS_RDATA_DOWNCASE      downcase domain names when they are copied
291  *                              into target.
292  *
293  * Requires:
294  *
295  *\li   'rdclass' and 'type' are valid.
296  *
297  *\li   'source' is a valid buffer, and the active region of 'source'
298  *      references the rdata to be processed.
299  *
300  *\li   'target' is a valid buffer.
301  *
302  *\li   'dctx' is a valid decompression context.
303  *
304  * Ensures,
305  *      if result is success:
306  *      \li     If 'rdata' is not NULL, it is attached to the target.
307  *      \li     The conditions dns_name_fromwire() ensures for names hold
308  *              for all names in the rdata.
309  *      \li     The current location in source is advanced, and the used space
310  *              in target is updated.
311  *
312  * Result:
313  *\li   Success
314  *\li   Any non-success status from dns_name_fromwire()
315  *\li   Various 'Bad Form' class failures depending on class and type
316  *\li   Bad Form: Input too short
317  *\li   Resource Limit: Not enough space
318  */
319
320 isc_result_t
321 dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
322                  isc_buffer_t *target);
323 /*%<
324  * Convert 'rdata' into wire format, compressing it as specified by the
325  * compression context 'cctx', and storing the result in 'target'.
326  *
327  * Notes:
328  *\li   If the compression context allows global compression, then the
329  *      global compression table may be updated.
330  *
331  * Requires:
332  *\li   'rdata' is a valid, non-empty rdata
333  *
334  *\li   target is a valid buffer
335  *
336  *\li   Any offsets specified in a global compression table are valid
337  *      for target.
338  *
339  * Ensures,
340  *      if the result is success:
341  *      \li     The used space in target is updated.
342  *
343  * Returns:
344  *\li   Success
345  *\li   Any non-success status from dns_name_towire()
346  *\li   Resource Limit: Not enough space
347  */
348
349 isc_result_t
350 dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
351                    dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin,
352                    unsigned int options, isc_mem_t *mctx,
353                    isc_buffer_t *target, dns_rdatacallbacks_t *callbacks);
354 /*%<
355  * Convert the textual representation of a DNS rdata into uncompressed wire
356  * form stored in the target region.  Tokens constituting the text of the rdata
357  * are taken from 'lexer'.
358  *
359  * Notes:
360  *\li   Relative domain names in the rdata will have 'origin' appended to them.
361  *      A NULL origin implies "origin == dns_rootname".
362  *
363  *
364  *      'options'
365  *\li   DNS_RDATA_DOWNCASE      downcase domain names when they are copied
366  *                              into target.
367  *\li   DNS_RDATA_CHECKNAMES    perform checknames checks.
368  *\li   DNS_RDATA_CHECKNAMESFAIL fail if the checknames check fail.  If
369  *                              not set a warning will be issued.
370  *\li   DNS_RDATA_CHECKREVERSE  this should set if the owner name ends
371  *                              in IP6.ARPA, IP6.INT or IN-ADDR.ARPA.
372  *
373  * Requires:
374  *
375  *\li   'rdclass' and 'type' are valid.
376  *
377  *\li   'lexer' is a valid isc_lex_t.
378  *
379  *\li   'mctx' is a valid isc_mem_t.
380  *
381  *\li   'target' is a valid region.
382  *
383  *\li   'origin' if non NULL it must be absolute.
384  *
385  *\li   'callbacks' to be NULL or callbacks->warn and callbacks->error be
386  *      initialized.
387  *
388  * Ensures,
389  *      if result is success:
390  *\li           If 'rdata' is not NULL, it is attached to the target.
391
392  *\li           The conditions dns_name_fromtext() ensures for names hold
393  *              for all names in the rdata.
394
395  *\li           The used space in target is updated.
396  *
397  * Result:
398  *\li   Success
399  *\li   Translated result codes from isc_lex_gettoken
400  *\li   Various 'Bad Form' class failures depending on class and type
401  *\li   Bad Form: Input too short
402  *\li   Resource Limit: Not enough space
403  *\li   Resource Limit: Not enough memory
404  */
405
406 isc_result_t
407 dns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target);
408 /*%<
409  * Convert 'rdata' into text format, storing the result in 'target'.
410  * The text will consist of a single line, with fields separated by
411  * single spaces.
412  *
413  * Notes:
414  *\li   If 'origin' is not NULL, then any names in the rdata that are
415  *      subdomains of 'origin' will be made relative it.
416  *
417  *\li   XXX Do we *really* want to support 'origin'?  I'm inclined towards "no"
418  *      at the moment.
419  *
420  * Requires:
421  *
422  *\li   'rdata' is a valid, non-empty rdata
423  *
424  *\li   'origin' is NULL, or is a valid name
425  *
426  *\li   'target' is a valid text buffer
427  *
428  * Ensures,
429  *      if the result is success:
430  *
431  *      \li     The used space in target is updated.
432  *
433  * Returns:
434  *\li   Success
435  *\li   Any non-success status from dns_name_totext()
436  *\li   Resource Limit: Not enough space
437  */
438
439 isc_result_t
440 dns_rdata_tofmttext(dns_rdata_t *rdata, dns_name_t *origin, unsigned int flags,
441                     unsigned int width, const char *linebreak,
442                     isc_buffer_t *target);
443 /*%<
444  * Like dns_rdata_totext, but do formatted output suitable for
445  * database dumps.  This is intended for use by dns_db_dump();
446  * library users are discouraged from calling it directly.
447  *
448  * If (flags & #DNS_STYLEFLAG_MULTILINE) != 0, attempt to stay
449  * within 'width' by breaking the text into multiple lines.
450  * The string 'linebreak' is inserted between lines, and parentheses
451  * are added when necessary.  Because RRs contain unbreakable elements
452  * such as domain names whose length is variable, unpredictable, and
453  * potentially large, there is no guarantee that the lines will
454  * not exceed 'width' anyway.
455  *
456  * If (flags & #DNS_STYLEFLAG_MULTILINE) == 0, the rdata is always
457  * printed as a single line, and no parentheses are used.
458  * The 'width' and 'linebreak' arguments are ignored.
459  *
460  * If (flags & #DNS_STYLEFLAG_COMMENT) != 0, output explanatory
461  * comments next to things like the SOA timer fields.  Some
462  * comments (e.g., the SOA ones) are only printed when multiline
463  * output is selected.
464  */
465
466 isc_result_t
467 dns_rdata_fromstruct(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
468                      dns_rdatatype_t type, void *source, isc_buffer_t *target);
469 /*%<
470  * Convert the C structure representation of an rdata into uncompressed wire
471  * format in 'target'.
472  *
473  * XXX  Should we have a 'size' parameter as a sanity check on target?
474  *
475  * Requires:
476  *
477  *\li   'rdclass' and 'type' are valid.
478  *
479  *\li   'source' points to a valid C struct for the class and type.
480  *
481  *\li   'target' is a valid buffer.
482  *
483  *\li   All structure pointers to memory blocks should be NULL if their
484  *      corresponding length values are zero.
485  *
486  * Ensures,
487  *      if result is success:
488  *      \li     If 'rdata' is not NULL, it is attached to the target.
489  *
490  *      \li     The used space in 'target' is updated.
491  *
492  * Result:
493  *\li   Success
494  *\li   Various 'Bad Form' class failures depending on class and type
495  *\li   Resource Limit: Not enough space
496  */
497
498 isc_result_t
499 dns_rdata_tostruct(dns_rdata_t *rdata, void *target, isc_mem_t *mctx);
500 /*%<
501  * Convert an rdata into its C structure representation.
502  *
503  * If 'mctx' is NULL then 'rdata' must persist while 'target' is being used.
504  *
505  * If 'mctx' is non NULL then memory will be allocated if required.
506  *
507  * Requires:
508  *
509  *\li   'rdata' is a valid, non-empty rdata.
510  *
511  *\li   'target' to point to a valid pointer for the type and class.
512  *
513  * Result:
514  *\li   Success
515  *\li   Resource Limit: Not enough memory
516  */
517
518 void
519 dns_rdata_freestruct(void *source);
520 /*%<
521  * Free dynamic memory attached to 'source' (if any).
522  *
523  * Requires:
524  *
525  *\li   'source' to point to the structure previously filled in by
526  *      dns_rdata_tostruct().
527  */
528
529 isc_boolean_t
530 dns_rdatatype_ismeta(dns_rdatatype_t type);
531 /*%<
532  * Return true iff the rdata type 'type' is a meta-type
533  * like ANY or AXFR.
534  */
535
536 isc_boolean_t
537 dns_rdatatype_issingleton(dns_rdatatype_t type);
538 /*%<
539  * Return true iff the rdata type 'type' is a singleton type,
540  * like CNAME or SOA.
541  *
542  * Requires:
543  * \li  'type' is a valid rdata type.
544  *
545  */
546
547 isc_boolean_t
548 dns_rdataclass_ismeta(dns_rdataclass_t rdclass);
549 /*%<
550  * Return true iff the rdata class 'rdclass' is a meta-class
551  * like ANY or NONE.
552  */
553
554 isc_boolean_t
555 dns_rdatatype_isdnssec(dns_rdatatype_t type);
556 /*%<
557  * Return true iff 'type' is one of the DNSSEC
558  * rdata types that may exist alongside a CNAME record.
559  *
560  * Requires:
561  * \li  'type' is a valid rdata type.
562  */
563
564 isc_boolean_t
565 dns_rdatatype_iszonecutauth(dns_rdatatype_t type);
566 /*%<
567  * Return true iff rdata of type 'type' is considered authoritative
568  * data (not glue) in the NSEC chain when it occurs in the parent zone
569  * at a zone cut.
570  *
571  * Requires:
572  * \li  'type' is a valid rdata type.
573  *
574  */
575
576 isc_boolean_t
577 dns_rdatatype_isknown(dns_rdatatype_t type);
578 /*%<
579  * Return true iff the rdata type 'type' is known.
580  *
581  * Requires:
582  * \li  'type' is a valid rdata type.
583  *
584  */
585
586
587 isc_result_t
588 dns_rdata_additionaldata(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
589                          void *arg);
590 /*%<
591  * Call 'add' for each name and type from 'rdata' which is subject to
592  * additional section processing.
593  *
594  * Requires:
595  *
596  *\li   'rdata' is a valid, non-empty rdata.
597  *
598  *\li   'add' is a valid dns_additionalfunc_t.
599  *
600  * Ensures:
601  *
602  *\li   If successful, then add() will have been called for each name
603  *      and type subject to additional section processing.
604  *
605  *\li   If add() returns something other than #ISC_R_SUCCESS, that result
606  *      will be returned as the result of dns_rdata_additionaldata().
607  *
608  * Returns:
609  *
610  *\li   ISC_R_SUCCESS
611  *
612  *\li   Many other results are possible if not successful.
613  */
614
615 isc_result_t
616 dns_rdata_digest(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg);
617 /*%<
618  * Send 'rdata' in DNSSEC canonical form to 'digest'.
619  *
620  * Note:
621  *\li   'digest' may be called more than once by dns_rdata_digest().  The
622  *      concatenation of all the regions, in the order they were given
623  *      to 'digest', will be the DNSSEC canonical form of 'rdata'.
624  *
625  * Requires:
626  *
627  *\li   'rdata' is a valid, non-empty rdata.
628  *
629  *\li   'digest' is a valid dns_digestfunc_t.
630  *
631  * Ensures:
632  *
633  *\li   If successful, then all of the rdata's data has been sent, in
634  *      DNSSEC canonical form, to 'digest'.
635  *
636  *\li   If digest() returns something other than ISC_R_SUCCESS, that result
637  *      will be returned as the result of dns_rdata_digest().
638  *
639  * Returns:
640  *
641  *\li   ISC_R_SUCCESS
642  *
643  *\li   Many other results are possible if not successful.
644  */
645
646 isc_boolean_t
647 dns_rdatatype_questiononly(dns_rdatatype_t type);
648 /*%<
649  * Return true iff rdata of type 'type' can only appear in the question
650  * section of a properly formatted message.
651  *
652  * Requires:
653  * \li  'type' is a valid rdata type.
654  *
655  */
656
657 isc_boolean_t
658 dns_rdatatype_notquestion(dns_rdatatype_t type);
659 /*%<
660  * Return true iff rdata of type 'type' can not appear in the question
661  * section of a properly formatted message.
662  *
663  * Requires:
664  * \li  'type' is a valid rdata type.
665  *
666  */
667
668 isc_boolean_t
669 dns_rdatatype_atparent(dns_rdatatype_t type);
670 /*%<
671  * Return true iff rdata of type 'type' should appear at the parent of
672  * a zone cut.
673  *
674  * Requires:
675  * \li  'type' is a valid rdata type.
676  *
677  */
678
679 unsigned int
680 dns_rdatatype_attributes(dns_rdatatype_t rdtype);
681 /*%<
682  * Return attributes for the given type.
683  *
684  * Requires:
685  *\li   'rdtype' are known.
686  *
687  * Returns:
688  *\li   a bitmask consisting of the following flags.
689  */
690
691 /*% only one may exist for a name */
692 #define DNS_RDATATYPEATTR_SINGLETON             0x00000001U
693 /*% requires no other data be present */
694 #define DNS_RDATATYPEATTR_EXCLUSIVE             0x00000002U
695 /*% Is a meta type */
696 #define DNS_RDATATYPEATTR_META                  0x00000004U
697 /*% Is a DNSSEC type, like RRSIG or NSEC */
698 #define DNS_RDATATYPEATTR_DNSSEC                0x00000008U
699 /*% Is a zone cut authority type */
700 #define DNS_RDATATYPEATTR_ZONECUTAUTH           0x00000010U
701 /*% Is reserved (unusable) */
702 #define DNS_RDATATYPEATTR_RESERVED              0x00000020U
703 /*% Is an unknown type */
704 #define DNS_RDATATYPEATTR_UNKNOWN               0x00000040U
705 /*% Is META, and can only be in a question section */
706 #define DNS_RDATATYPEATTR_QUESTIONONLY          0x00000080U
707 /*% is META, and can NOT be in a question section */
708 #define DNS_RDATATYPEATTR_NOTQUESTION           0x00000100U
709 /*% Is present at zone cuts in the parent, not the child */
710 #define DNS_RDATATYPEATTR_ATPARENT              0x00000200U
711
712 dns_rdatatype_t
713 dns_rdata_covers(dns_rdata_t *rdata);
714 /*%<
715  * Return the rdatatype that this type covers.
716  *
717  * Requires:
718  *\li   'rdata' is a valid, non-empty rdata.
719  *
720  *\li   'rdata' is a type that covers other rdata types.
721  *
722  * Returns:
723  *\li   The type covered.
724  */
725
726 isc_boolean_t
727 dns_rdata_checkowner(dns_name_t* name, dns_rdataclass_t rdclass,
728                      dns_rdatatype_t type, isc_boolean_t wildcard);
729 /*
730  * Returns whether this is a valid ownername for this <type,class>.
731  * If wildcard is true allow the first label to be a wildcard if
732  * appropriate.
733  *
734  * Requires:
735  *      'name' is a valid name.
736  */
737
738 isc_boolean_t
739 dns_rdata_checknames(dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad);
740 /*
741  * Returns whether 'rdata' contains valid domain names.  The checks are
742  * sensitive to the owner name.
743  *
744  * If 'bad' is non-NULL and a domain name fails the check the
745  * the offending name will be return in 'bad' by cloning from
746  * the 'rdata' contents.
747  *
748  * Requires:
749  *      'rdata' to be valid.
750  *      'owner' to be valid.
751  *      'bad'   to be NULL or valid.
752  */
753
754 void
755 dns_rdata_exists(dns_rdata_t *rdata, dns_rdatatype_t type);
756
757 void
758 dns_rdata_notexist(dns_rdata_t *rdata, dns_rdatatype_t type);
759
760 void
761 dns_rdata_deleterrset(dns_rdata_t *rdata, dns_rdatatype_t type);
762
763 void
764 dns_rdata_makedelete(dns_rdata_t *rdata);
765
766 const char *
767 dns_rdata_updateop(dns_rdata_t *rdata, dns_section_t section);
768
769 ISC_LANG_ENDDECLS
770
771 #endif /* DNS_RDATA_H */