* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
* A DNS rdataset is a handle that can be associated with a collection of
* rdata all having a common owner name, class, and type.
* The dns_rdataset_t type is like a "virtual class". To actually use
* rdatasets, an implementation of the method suite (e.g. "slabbed rdata") is
*\li Clients of this module must impose any required synchronization.
*\li No anticipated impact.
*\li No anticipated impact.
#include <dns/rdatastruct.h>
dns_rdatasetadditional_fromauth,
dns_rdatasetadditional_fromcache,
dns_rdatasetadditional_fromglue
} dns_rdatasetadditional_t;
typedef struct dns_rdatasetmethods {
void (*disassociate)(dns_rdataset_t *rdataset);
isc_result_t (*first)(dns_rdataset_t *rdataset);
isc_result_t (*next)(dns_rdataset_t *rdataset);
void (*current)(dns_rdataset_t *rdataset,
void (*clone)(dns_rdataset_t *source,
unsigned int (*count)(dns_rdataset_t *rdataset);
isc_result_t (*addnoqname)(dns_rdataset_t *rdataset,
isc_result_t (*getnoqname)(dns_rdataset_t *rdataset,
isc_result_t (*addclosest)(dns_rdataset_t *rdataset,
isc_result_t (*getclosest)(dns_rdataset_t *rdataset,
isc_result_t (*getadditional)(dns_rdataset_t *rdataset,
dns_rdatasetadditional_t type,
dns_dbversion_t **versionp,
isc_result_t (*setadditional)(dns_rdataset_t *rdataset,
dns_rdatasetadditional_t type,
dns_dbversion_t *version,
isc_result_t (*putadditional)(dns_acache_t *acache,
dns_rdataset_t *rdataset,
dns_rdatasetadditional_t type,
void (*settrust)(dns_rdataset_t *rdataset,
void (*expire)(dns_rdataset_t *rdataset);
void (*clearprefetch)(dns_rdataset_t *rdataset);
void (*setownercase)(dns_rdataset_t *rdataset,
void (*getownercase)(const dns_rdataset_t *rdataset, dns_name_t *name);
#define DNS_RDATASET_MAGIC ISC_MAGIC('D','N','S','R')
#define DNS_RDATASET_VALID(set) ISC_MAGIC_VALID(set, DNS_RDATASET_MAGIC)
* Direct use of this structure by clients is strongly discouraged, except
* for the 'link' field which may be used however the client wishes. The
* 'private', 'current', and 'index' fields MUST NOT be changed by clients.
* rdataset implementations may change any of the fields.
unsigned int magic; /* XXX ? */
dns_rdatasetmethods_t * methods;
ISC_LINK(dns_rdataset_t) link;
* XXX do we need these, or should they be retrieved by methods?
* Leaning towards the latter, since they are not frequently required
* once you have the rdataset.
dns_rdataclass_t rdclass;
* Stale ttl is used to see how long this RRset can still be used
* to serve to clients, after the TTL has expired.
* the counter provides the starting point in the "cyclic" order.
* The value UINT32_MAX has a special meaning of "picking up a
* random value." in order to take care of databases that do not
* This RRSIG RRset should be re-generated around this time.
* Only valid if DNS_RDATASETATTR_RESIGN is set in attributes.
* These are for use by the rdataset implementation, and MUST NOT
unsigned int privateuint4;
* \def DNS_RDATASETATTR_RENDERED
* Used by message.c to indicate that the rdataset was rendered.
* \def DNS_RDATASETATTR_TTLADJUSTED
* Used by message.c to indicate that the rdataset's rdata had differing
* TTL values, and the rdataset->ttl holds the smallest.
* \def DNS_RDATASETATTR_LOADORDER
* Output the RRset in load order.
#define DNS_RDATASETATTR_QUESTION 0x00000001
#define DNS_RDATASETATTR_RENDERED 0x00000002 /*%< Used by message.c */
#define DNS_RDATASETATTR_ANSWERED 0x00000004 /*%< Used by server. */
#define DNS_RDATASETATTR_CACHE 0x00000008 /*%< Used by resolver. */
#define DNS_RDATASETATTR_ANSWER 0x00000010 /*%< Used by resolver. */
#define DNS_RDATASETATTR_ANSWERSIG 0x00000020 /*%< Used by resolver. */
#define DNS_RDATASETATTR_EXTERNAL 0x00000040 /*%< Used by resolver. */
#define DNS_RDATASETATTR_NCACHE 0x00000080 /*%< Used by resolver. */
#define DNS_RDATASETATTR_CHAINING 0x00000100 /*%< Used by resolver. */
#define DNS_RDATASETATTR_TTLADJUSTED 0x00000200 /*%< Used by message.c */
#define DNS_RDATASETATTR_FIXEDORDER 0x00000400
#define DNS_RDATASETATTR_RANDOMIZE 0x00000800
#define DNS_RDATASETATTR_CHASE 0x00001000 /*%< Used by resolver. */
#define DNS_RDATASETATTR_NXDOMAIN 0x00002000
#define DNS_RDATASETATTR_NOQNAME 0x00004000
#define DNS_RDATASETATTR_CHECKNAMES 0x00008000 /*%< Used by resolver. */
#define DNS_RDATASETATTR_REQUIRED 0x00010000
#define DNS_RDATASETATTR_REQUIREDGLUE DNS_RDATASETATTR_REQUIRED
#define DNS_RDATASETATTR_LOADORDER 0x00020000
#define DNS_RDATASETATTR_RESIGN 0x00040000
#define DNS_RDATASETATTR_CLOSEST 0x00080000
#define DNS_RDATASETATTR_OPTOUT 0x00100000 /*%< OPTOUT proof */
#define DNS_RDATASETATTR_NEGATIVE 0x00200000
#define DNS_RDATASETATTR_PREFETCH 0x00400000
#define DNS_RDATASETATTR_STALE 0x01000000
* Omit DNSSEC records when rendering ncache records.
#define DNS_RDATASETTOWIRE_OMITDNSSEC 0x0001
dns_rdataset_init(dns_rdataset_t *rdataset);
* Make 'rdataset' a valid, disassociated rdataset.
*\li 'rdataset' is not NULL.
*\li 'rdataset' is a valid, disassociated rdataset.
dns_rdataset_invalidate(dns_rdataset_t *rdataset);
*\li 'rdataset' is a valid, disassociated rdataset.
*\li If assertion checking is enabled, future attempts to use 'rdataset'
* without initializing it will cause an assertion failure.
dns_rdataset_disassociate(dns_rdataset_t *rdataset);
* Disassociate 'rdataset' from its rdata, allowing it to be reused.
*\li The client must ensure it has no references to rdata in the rdataset
*\li 'rdataset' is a valid, associated rdataset.
*\li 'rdataset' is a valid, disassociated rdataset.
dns_rdataset_isassociated(dns_rdataset_t *rdataset);
* Is 'rdataset' associated?
*\li 'rdataset' is a valid rdataset.
*\li #true 'rdataset' is associated.
*\li #false 'rdataset' is not associated.
dns_rdataset_makequestion(dns_rdataset_t *rdataset, dns_rdataclass_t rdclass,
* Make 'rdataset' a valid, associated, question rdataset, with a
* question class of 'rdclass' and type 'type'.
*\li Question rdatasets have a class and type, but no rdata.
*\li 'rdataset' is a valid, disassociated rdataset.
*\li 'rdataset' is a valid, associated, question rdataset.
dns_rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target);
* Make 'target' refer to the same rdataset as 'source'.
*\li 'source' is a valid, associated rdataset.
*\li 'target' is a valid, dissociated rdataset.
*\li 'target' references the same rdataset as 'source'.
dns_rdataset_count(dns_rdataset_t *rdataset);
* Return the number of records in 'rdataset'.
*\li 'rdataset' is a valid, associated rdataset.
*\li The number of records in 'rdataset'.
dns_rdataset_first(dns_rdataset_t *rdataset);
* Move the rdata cursor to the first rdata in the rdataset (if any).
*\li 'rdataset' is a valid, associated rdataset.
*\li #ISC_R_NOMORE There are no rdata in the set.
dns_rdataset_next(dns_rdataset_t *rdataset);
* Move the rdata cursor to the next rdata in the rdataset (if any).
*\li 'rdataset' is a valid, associated rdataset.
*\li #ISC_R_NOMORE There are no more rdata in the set.
dns_rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata);
* Make 'rdata' refer to the current rdata.
*\li The data returned in 'rdata' is valid for the life of the
* rdataset; in particular, subsequent changes in the cursor position
* do not invalidate 'rdata'.
*\li 'rdataset' is a valid, associated rdataset.
*\li The rdata cursor of 'rdataset' is at a valid location (i.e. the
* result of last call to a cursor movement command was ISC_R_SUCCESS).
*\li 'rdata' refers to the rdata at the rdata cursor location of
dns_rdataset_totext(dns_rdataset_t *rdataset,
* Convert 'rdataset' to text format, storing the result in 'target'.
*\li The rdata cursor position will be changed.
*\li The 'question' flag should normally be #false. If it is
* #true, the TTL and rdata fields are not printed. This is
* for use when printing an rdata representing a question section.
*\li This interface is deprecated; use dns_master_rdatasettottext()
* and/or dns_master_questiontotext() instead.
*\li 'rdataset' is a valid rdataset.
*\li 'rdataset' is not empty.
dns_rdataset_towire(dns_rdataset_t *rdataset,
* Convert 'rdataset' to wire format, compressing names as specified
* in 'cctx', and storing the result in 'target'.
*\li The rdata cursor position will be changed.
*\li The number of RRs added to target will be added to *countp.
*\li 'rdataset' is a valid rdataset.
*\li 'rdataset' is not empty.
*\li 'countp' is a valid pointer.
*\li On a return of ISC_R_SUCCESS, 'target' contains a wire format
* for the data contained in 'rdataset'. Any error return leaves
*\li *countp has been incremented by the number of RRs added to
*\li #ISC_R_SUCCESS - all ok
*\li #ISC_R_NOSPACE - 'target' doesn't have enough room
*\li Any error returned by dns_rdata_towire(), dns_rdataset_next(),
dns_rdataset_towiresorted(dns_rdataset_t *rdataset,
const dns_name_t *owner_name,
dns_rdatasetorderfunc_t order,
* Like dns_rdataset_towire(), but sorting the rdatasets according to
* the integer value returned by 'order' when called with the rdataset
* and 'order_arg' as arguments.
*\li All the requirements of dns_rdataset_towire(), and
* that order_arg is NULL if and only if order is NULL.
dns_rdataset_towirepartial(dns_rdataset_t *rdataset,
const dns_name_t *owner_name,
dns_rdatasetorderfunc_t order,
* Like dns_rdataset_towiresorted() except that a partial rdataset
*\li All the requirements of dns_rdataset_towiresorted().
* If 'state' is non NULL then the current position in the
* rdataset will be remembered if the rdataset in not
* completely written and should be passed on on subsequent
* calls (NOT CURRENTLY IMPLEMENTED).
*\li #ISC_R_SUCCESS if all of the records were written.
*\li #ISC_R_NOSPACE if unable to fit in all of the records. *countp
* will be updated to reflect the number of records
dns_rdataset_additionaldata(dns_rdataset_t *rdataset,
dns_additionaldatafunc_t add, void *arg);
* For each rdata in rdataset, call 'add' for each name and type in the
* rdata which is subject to additional section processing.
*\li 'rdataset' is a valid, non-question rdataset.
*\li 'add' is a valid dns_additionaldatafunc_t
*\li If successful, dns_rdata_additionaldata() will have been called for
* each rdata in 'rdataset'.