1999-01-15 08:05:14 +00:00
|
|
|
/*
|
2011-02-21 23:47:45 +00:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
1999-01-15 08:05:14 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
1999-01-15 08:05:14 +00:00
|
|
|
* 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/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
1999-01-15 08:05:14 +00:00
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*! \file */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1999-01-15 08:05:14 +00:00
|
|
|
#include <stddef.h>
|
2015-02-27 15:08:38 +11:00
|
|
|
#include <string.h>
|
1999-01-15 08:05:14 +00:00
|
|
|
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-01-15 08:05:14 +00:00
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
#include <dns/name.h>
|
2008-09-24 02:46:23 +00:00
|
|
|
#include <dns/nsec3.h>
|
1999-01-15 08:05:14 +00:00
|
|
|
#include <dns/rdata.h>
|
|
|
|
#include <dns/rdatalist.h>
|
|
|
|
#include <dns/rdataset.h>
|
|
|
|
|
|
|
|
static dns_rdatasetmethods_t methods = {
|
2023-02-17 11:46:58 -08:00
|
|
|
.disassociate = dns_rdatalist_disassociate,
|
|
|
|
.first = dns_rdatalist_first,
|
|
|
|
.next = dns_rdatalist_next,
|
|
|
|
.current = dns_rdatalist_current,
|
|
|
|
.clone = dns_rdatalist_clone,
|
|
|
|
.count = dns_rdatalist_count,
|
|
|
|
.addnoqname = dns_rdatalist_addnoqname,
|
|
|
|
.getnoqname = dns_rdatalist_getnoqname,
|
|
|
|
.addclosest = dns_rdatalist_addclosest,
|
|
|
|
.getclosest = dns_rdatalist_getclosest,
|
|
|
|
.setownercase = dns_rdatalist_setownercase,
|
|
|
|
.getownercase = dns_rdatalist_getownercase,
|
1999-01-15 08:05:14 +00:00
|
|
|
};
|
|
|
|
|
1999-10-27 00:43:43 +00:00
|
|
|
void
|
|
|
|
dns_rdatalist_init(dns_rdatalist_t *rdatalist) {
|
2011-02-21 07:01:09 +00:00
|
|
|
REQUIRE(rdatalist != NULL);
|
|
|
|
|
1999-10-27 00:43:43 +00:00
|
|
|
/*
|
|
|
|
* Initialize rdatalist.
|
|
|
|
*/
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
*rdatalist = (dns_rdatalist_t){
|
|
|
|
.rdata = ISC_LIST_INITIALIZER,
|
|
|
|
.link = ISC_LINK_INITIALIZER,
|
|
|
|
};
|
2015-02-27 15:08:38 +11:00
|
|
|
memset(rdatalist->upper, 0xeb, sizeof(rdatalist->upper));
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
|
2015-02-27 15:08:38 +11:00
|
|
|
/*
|
|
|
|
* Clear upper set bit.
|
|
|
|
*/
|
|
|
|
rdatalist->upper[0] &= ~0x01;
|
1999-10-27 00:43:43 +00:00
|
|
|
}
|
|
|
|
|
2022-07-29 12:40:45 +00:00
|
|
|
void
|
1999-01-15 08:05:14 +00:00
|
|
|
dns_rdatalist_tordataset(dns_rdatalist_t *rdatalist, dns_rdataset_t *rdataset) {
|
|
|
|
/*
|
|
|
|
* Make 'rdataset' refer to the rdata in 'rdatalist'.
|
|
|
|
*/
|
|
|
|
|
|
|
|
REQUIRE(rdatalist != NULL);
|
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
2000-04-28 23:46:43 +00:00
|
|
|
REQUIRE(!dns_rdataset_isassociated(rdataset));
|
1999-01-15 08:05:14 +00:00
|
|
|
|
2015-03-03 16:43:42 +11:00
|
|
|
/* Check if dns_rdatalist_init has was called. */
|
|
|
|
REQUIRE(rdatalist->upper[0] == 0xea);
|
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
*rdataset = (dns_rdataset_t){
|
|
|
|
.methods = &methods,
|
|
|
|
.rdclass = rdatalist->rdclass,
|
|
|
|
.type = rdatalist->type,
|
|
|
|
.covers = rdatalist->covers,
|
|
|
|
.ttl = rdatalist->ttl,
|
|
|
|
.rdlist.list = rdatalist,
|
|
|
|
|
|
|
|
.link = rdataset->link,
|
|
|
|
.count = rdataset->count,
|
|
|
|
.attributes = rdataset->attributes,
|
|
|
|
.magic = rdataset->magic,
|
|
|
|
};
|
1999-01-15 08:05:14 +00:00
|
|
|
}
|
|
|
|
|
2022-07-29 12:40:45 +00:00
|
|
|
void
|
2008-04-03 02:01:08 +00:00
|
|
|
dns_rdatalist_fromrdataset(dns_rdataset_t *rdataset,
|
|
|
|
dns_rdatalist_t **rdatalist) {
|
|
|
|
REQUIRE(rdatalist != NULL && rdataset != NULL);
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
REQUIRE(rdataset->methods == &methods);
|
|
|
|
|
|
|
|
*rdatalist = rdataset->rdlist.list;
|
2008-04-03 02:01:08 +00:00
|
|
|
}
|
|
|
|
|
2000-08-21 22:17:14 +00:00
|
|
|
void
|
2023-01-05 09:12:35 +01:00
|
|
|
dns_rdatalist_disassociate(dns_rdataset_t *rdataset DNS__DB_FLARG) {
|
2000-05-11 22:47:00 +00:00
|
|
|
UNUSED(rdataset);
|
1999-01-15 08:05:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-21 22:17:14 +00:00
|
|
|
isc_result_t
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_first(dns_rdataset_t *rdataset) {
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
dns_rdatalist_t *rdatalist = NULL;
|
1999-01-15 08:05:14 +00:00
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdatalist = rdataset->rdlist.list;
|
|
|
|
rdataset->rdlist.iter = ISC_LIST_HEAD(rdatalist->rdata);
|
1999-01-15 08:05:14 +00:00
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
if (rdataset->rdlist.iter == NULL) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return ISC_R_NOMORE;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-01-15 08:05:14 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return ISC_R_SUCCESS;
|
1999-01-15 08:05:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-21 22:17:14 +00:00
|
|
|
isc_result_t
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_next(dns_rdataset_t *rdataset) {
|
1999-01-15 08:05:14 +00:00
|
|
|
dns_rdata_t *rdata;
|
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdata = rdataset->rdlist.iter;
|
1999-03-11 06:01:31 +00:00
|
|
|
if (rdata == NULL) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return ISC_R_NOMORE;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-03-11 06:01:31 +00:00
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdataset->rdlist.iter = ISC_LIST_NEXT(rdata, link);
|
1999-01-15 08:05:14 +00:00
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
if (rdataset->rdlist.iter == NULL) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return ISC_R_NOMORE;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-01-15 08:05:14 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return ISC_R_SUCCESS;
|
1999-01-15 08:05:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-21 22:17:14 +00:00
|
|
|
void
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
|
1999-01-15 08:05:14 +00:00
|
|
|
dns_rdata_t *list_rdata;
|
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
list_rdata = rdataset->rdlist.iter;
|
1999-01-15 08:05:14 +00:00
|
|
|
INSIST(list_rdata != NULL);
|
|
|
|
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_clone(list_rdata, rdata);
|
1999-01-15 08:05:14 +00:00
|
|
|
}
|
1999-07-13 01:50:22 +00:00
|
|
|
|
2000-08-21 22:17:14 +00:00
|
|
|
void
|
2023-01-05 09:12:35 +01:00
|
|
|
dns_rdatalist_clone(dns_rdataset_t *source,
|
|
|
|
dns_rdataset_t *target DNS__DB_FLARG) {
|
2011-02-21 07:01:09 +00:00
|
|
|
REQUIRE(source != NULL);
|
|
|
|
REQUIRE(target != NULL);
|
|
|
|
|
1999-07-13 01:50:22 +00:00
|
|
|
*target = *source;
|
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
target->rdlist.iter = NULL;
|
1999-07-13 01:50:22 +00:00
|
|
|
}
|
1999-09-21 20:40:42 +00:00
|
|
|
|
2000-08-21 22:17:14 +00:00
|
|
|
unsigned int
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_count(dns_rdataset_t *rdataset) {
|
2025-03-20 22:25:56 -07:00
|
|
|
dns_rdatalist_t *rdatalist = NULL;
|
1999-09-21 20:40:42 +00:00
|
|
|
unsigned int count;
|
|
|
|
|
2011-02-21 07:01:09 +00:00
|
|
|
REQUIRE(rdataset != NULL);
|
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdatalist = rdataset->rdlist.list;
|
1999-09-21 20:40:42 +00:00
|
|
|
|
|
|
|
count = 0;
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (rdatalist->rdata, rdata, link) {
|
1999-09-21 20:40:42 +00:00
|
|
|
count++;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-09-21 20:40:42 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
|
|
|
|
isc_result_t
|
2025-03-20 22:25:56 -07:00
|
|
|
dns_rdatalist_addnoqname(dns_rdataset_t *rdataset, dns_name_t *name) {
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_rdataset_t *neg = NULL;
|
|
|
|
dns_rdataset_t *negsig = NULL;
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_ttl_t ttl;
|
|
|
|
|
2011-02-21 07:01:09 +00:00
|
|
|
REQUIRE(rdataset != NULL);
|
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (name->list, rdset, link) {
|
2004-01-14 02:06:51 +00:00
|
|
|
if (rdset->rdclass != rdataset->rdclass) {
|
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2025-08-11 10:06:33 +02:00
|
|
|
if (dns_rdatatype_isnsec(rdset->type)) {
|
2008-09-24 02:46:23 +00:00
|
|
|
neg = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
if (neg == NULL) {
|
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (name->list, rdset, link) {
|
2004-01-14 02:06:51 +00:00
|
|
|
if (rdset->type == dns_rdatatype_rrsig &&
|
2022-11-02 19:33:14 +01:00
|
|
|
rdset->covers == neg->type)
|
|
|
|
{
|
2008-09-24 02:46:23 +00:00
|
|
|
negsig = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
if (negsig == NULL) {
|
2004-01-14 02:06:51 +00:00
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2025-03-20 22:25:56 -07:00
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
/*
|
|
|
|
* Minimise ttl.
|
|
|
|
*/
|
|
|
|
ttl = rdataset->ttl;
|
2008-09-24 02:46:23 +00:00
|
|
|
if (neg->ttl < ttl) {
|
|
|
|
ttl = neg->ttl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
if (negsig->ttl < ttl) {
|
|
|
|
ttl = negsig->ttl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
rdataset->ttl = neg->ttl = negsig->ttl = ttl;
|
2025-07-09 16:56:22 +02:00
|
|
|
rdataset->attributes.noqname = true;
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdataset->rdlist.noqname = name;
|
2004-01-14 02:06:51 +00:00
|
|
|
return ISC_R_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name,
|
2023-01-05 09:12:35 +01:00
|
|
|
dns_rdataset_t *neg,
|
|
|
|
dns_rdataset_t *negsig DNS__DB_FLARG) {
|
2019-09-27 11:37:27 +02:00
|
|
|
dns_rdataclass_t rdclass;
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_rdataset_t *tneg = NULL;
|
|
|
|
dns_rdataset_t *tnegsig = NULL;
|
2025-03-20 22:25:56 -07:00
|
|
|
dns_name_t *noqname = NULL;
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2011-02-21 07:01:09 +00:00
|
|
|
REQUIRE(rdataset != NULL);
|
2025-07-09 16:56:22 +02:00
|
|
|
REQUIRE(rdataset->attributes.noqname);
|
2011-02-21 07:01:09 +00:00
|
|
|
|
2019-09-27 11:37:27 +02:00
|
|
|
rdclass = rdataset->rdclass;
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
noqname = rdataset->rdlist.noqname;
|
2019-09-27 11:37:27 +02:00
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
(void)dns_name_dynamic(noqname); /* Sanity Check. */
|
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (noqname->list, rdset, link) {
|
|
|
|
if (rdset->rdclass != rdclass) {
|
2004-01-14 02:06:51 +00:00
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2025-08-11 10:06:33 +02:00
|
|
|
if (dns_rdatatype_isnsec(rdset->type)) {
|
2025-03-20 22:25:56 -07:00
|
|
|
tneg = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
if (tneg == NULL) {
|
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (noqname->list, rdset, link) {
|
|
|
|
if (rdset->type == dns_rdatatype_rrsig &&
|
|
|
|
rdset->covers == tneg->type)
|
2022-11-02 19:33:14 +01:00
|
|
|
{
|
2025-03-20 22:25:56 -07:00
|
|
|
tnegsig = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
if (tnegsig == NULL) {
|
2004-01-14 02:06:51 +00:00
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
|
|
|
|
dns_name_clone(noqname, name);
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_rdataset_clone(tneg, neg);
|
|
|
|
dns_rdataset_clone(tnegsig, negsig);
|
|
|
|
return ISC_R_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
2025-03-20 22:25:56 -07:00
|
|
|
dns_rdatalist_addclosest(dns_rdataset_t *rdataset, dns_name_t *name) {
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_rdataset_t *neg = NULL;
|
|
|
|
dns_rdataset_t *negsig = NULL;
|
|
|
|
dns_ttl_t ttl;
|
|
|
|
|
2011-02-21 07:01:09 +00:00
|
|
|
REQUIRE(rdataset != NULL);
|
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (name->list, rdset, link) {
|
2008-09-24 02:46:23 +00:00
|
|
|
if (rdset->rdclass != rdataset->rdclass) {
|
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2025-08-11 10:06:33 +02:00
|
|
|
if (dns_rdatatype_isnsec(rdset->type)) {
|
2008-09-24 02:46:23 +00:00
|
|
|
neg = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
if (neg == NULL) {
|
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (name->list, rdset, link) {
|
2008-09-24 02:46:23 +00:00
|
|
|
if (rdset->type == dns_rdatatype_rrsig &&
|
2022-11-02 19:33:14 +01:00
|
|
|
rdset->covers == neg->type)
|
|
|
|
{
|
2008-09-24 02:46:23 +00:00
|
|
|
negsig = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (negsig == NULL) {
|
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
/*
|
|
|
|
* Minimise ttl.
|
|
|
|
*/
|
|
|
|
ttl = rdataset->ttl;
|
|
|
|
if (neg->ttl < ttl) {
|
|
|
|
ttl = neg->ttl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
if (negsig->ttl < ttl) {
|
|
|
|
ttl = negsig->ttl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
rdataset->ttl = neg->ttl = negsig->ttl = ttl;
|
2025-07-09 16:56:22 +02:00
|
|
|
rdataset->attributes.closest = true;
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdataset->rdlist.closest = name;
|
2008-09-24 02:46:23 +00:00
|
|
|
return ISC_R_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_getclosest(dns_rdataset_t *rdataset, dns_name_t *name,
|
2023-01-05 09:12:35 +01:00
|
|
|
dns_rdataset_t *neg,
|
|
|
|
dns_rdataset_t *negsig DNS__DB_FLARG) {
|
2019-09-27 11:37:27 +02:00
|
|
|
dns_rdataclass_t rdclass;
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_rdataset_t *tneg = NULL;
|
|
|
|
dns_rdataset_t *tnegsig = NULL;
|
2025-03-20 22:25:56 -07:00
|
|
|
dns_name_t *closest = NULL;
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2011-02-21 07:01:09 +00:00
|
|
|
REQUIRE(rdataset != NULL);
|
2025-07-09 16:56:22 +02:00
|
|
|
REQUIRE(rdataset->attributes.closest);
|
2011-02-21 07:01:09 +00:00
|
|
|
|
2019-09-27 11:37:27 +02:00
|
|
|
rdclass = rdataset->rdclass;
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
closest = rdataset->rdlist.closest;
|
2019-09-27 11:37:27 +02:00
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
(void)dns_name_dynamic(closest); /* Sanity Check. */
|
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (closest->list, rdset, link) {
|
|
|
|
if (rdset->rdclass != rdclass) {
|
2008-09-24 02:46:23 +00:00
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2025-08-11 10:06:33 +02:00
|
|
|
if (dns_rdatatype_isnsec(rdset->type)) {
|
2025-03-20 22:25:56 -07:00
|
|
|
tneg = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
if (tneg == NULL) {
|
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2025-03-20 22:25:56 -07:00
|
|
|
ISC_LIST_FOREACH (closest->list, rdset, link) {
|
|
|
|
if (rdset->type == dns_rdatatype_rrsig &&
|
|
|
|
rdset->covers == tneg->type)
|
2022-11-02 19:33:14 +01:00
|
|
|
{
|
2025-03-20 22:25:56 -07:00
|
|
|
tnegsig = rdset;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
if (tnegsig == NULL) {
|
|
|
|
return ISC_R_NOTFOUND;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
|
|
|
dns_name_clone(closest, name);
|
|
|
|
dns_rdataset_clone(tneg, neg);
|
|
|
|
dns_rdataset_clone(tnegsig, negsig);
|
2004-01-14 02:06:51 +00:00
|
|
|
return ISC_R_SUCCESS;
|
|
|
|
}
|
2015-02-27 15:08:38 +11:00
|
|
|
|
|
|
|
void
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_setownercase(dns_rdataset_t *rdataset, const dns_name_t *name) {
|
2015-02-27 15:08:38 +11:00
|
|
|
dns_rdatalist_t *rdatalist;
|
|
|
|
unsigned int i;
|
2015-03-01 23:45:20 +00:00
|
|
|
|
2015-02-27 15:08:38 +11:00
|
|
|
/*
|
|
|
|
* We do not need to worry about label lengths as they are all
|
|
|
|
* less than or equal to 63.
|
|
|
|
*/
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdatalist = rdataset->rdlist.list;
|
2015-02-27 15:08:38 +11:00
|
|
|
memset(rdatalist->upper, 0, sizeof(rdatalist->upper));
|
2020-02-13 18:16:57 +01:00
|
|
|
for (i = 1; i < name->length; i++) {
|
|
|
|
if (name->ndata[i] >= 0x41 && name->ndata[i] <= 0x5a) {
|
2015-02-27 15:08:38 +11:00
|
|
|
rdatalist->upper[i / 8] |= 1 << (i % 8);
|
2020-02-13 18:16:57 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-27 15:08:38 +11:00
|
|
|
/*
|
|
|
|
* Record that upper has been set.
|
|
|
|
*/
|
|
|
|
rdatalist->upper[0] |= 0x01;
|
|
|
|
}
|
2015-03-01 23:45:20 +00:00
|
|
|
|
2015-02-27 15:08:38 +11:00
|
|
|
void
|
2023-02-17 11:57:05 -08:00
|
|
|
dns_rdatalist_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
|
2015-02-27 15:08:38 +11:00
|
|
|
dns_rdatalist_t *rdatalist;
|
|
|
|
unsigned int i;
|
2015-03-01 23:45:20 +00:00
|
|
|
|
Give the rdataset->privateN fields more helpful names
BIND's rdataset structure is a view of some DNS records. It is
polymorphic, so the details of how the records are stored can vary.
For instance, the records can be held in an rdatalist, or in an
rdataslab in the rbtdb.
The dns_rdataset structure previously had a number of fields called
`private1` up to `private7`, which were used by the various rdataset
implementations. It was not at all clear what these fields were for,
without reading the code and working it out from context.
This change makes the rdataset inheritance hierarchy more clear. The
polymorphic part of a `struct dns_rdataset` is now a union of structs,
each of which is named for the class of implementation using it. The
fields of these structs replace the old `privateN` fields. (Note: the
term "inheritance hierarchy" refers to the fact that the builtin and
SDLZ implementations are based on and inherit from the rdatalist
implementation, which in turn inherits from the generic rdataset.
Most of this change is mechanical, but there are a few extras.
In keynode.c there were a number of REQUIRE()ments that were not
necessary: they had already been checked by the rdataset method
dispatch code. On the other hand, In ncache.c there was a public
function which needed to REQUIRE() that an rdataset was valid.
I have removed lots of "reset iterator state" comments, because it
should now be clear from `target->iter = NULL` where before
`target->private5 = NULL` could have been doing anything.
Initialization is a bit neater in a few places, using C structure
literals where appropriate.
The pointer arithmetic for translating between an rdataslab header and
its raw contents is now fractionally safer.
2023-04-28 01:12:39 +01:00
|
|
|
rdatalist = rdataset->rdlist.list;
|
2015-02-27 15:08:38 +11:00
|
|
|
if ((rdatalist->upper[0] & 0x01) == 0) {
|
|
|
|
return;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2015-02-27 15:08:38 +11:00
|
|
|
for (i = 0; i < name->length; i++) {
|
|
|
|
/*
|
|
|
|
* Set the case bit if it does not match the recorded bit.
|
|
|
|
*/
|
|
|
|
if (name->ndata[i] >= 0x61 && name->ndata[i] <= 0x7a &&
|
|
|
|
(rdatalist->upper[i / 8] & (1 << (i % 8))) != 0)
|
|
|
|
{
|
|
|
|
name->ndata[i] &= ~0x20; /* clear the lower case bit */
|
|
|
|
} else if (name->ndata[i] >= 0x41 && name->ndata[i] <= 0x5a &&
|
|
|
|
(rdatalist->upper[i / 8] & (1 << (i % 8))) == 0)
|
|
|
|
{
|
|
|
|
name->ndata[i] |= 0x20; /* set the lower case bit */
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2015-02-27 15:08:38 +11:00
|
|
|
}
|
|
|
|
}
|