2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00
bind/lib/dns/ncache.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

697 lines
17 KiB
C
Raw Normal View History

1999-09-21 20:41:20 +00:00
/*
2011-02-03 12:18:12 +00:00
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
1999-09-21 20:41:20 +00:00
*
* SPDX-License-Identifier: MPL-2.0
*
1999-09-21 20:41:20 +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/.
*
1999-09-21 20:41:20 +00:00
* See the COPYRIGHT file distributed with this work for additional
1999-09-22 00:26:19 +00:00
* information regarding copyright ownership.
1999-09-21 20:41:20 +00:00
*/
/*! \file */
2000-06-22 22:00:42 +00:00
#include <inttypes.h>
#include <stdbool.h>
2000-05-30 22:29:28 +00:00
#include <isc/buffer.h>
#include <isc/result.h>
2000-04-28 01:12:23 +00:00
#include <isc/util.h>
1999-09-21 20:41:20 +00:00
#include <dns/db.h>
#include <dns/message.h>
#include <dns/ncache.h>
1999-09-21 20:41:20 +00:00
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#define DNS_NCACHE_RDATA 100U
1999-09-21 20:41:20 +00:00
/*
* The format of an ncache rdata is a sequence of zero or more records
* of the following format:
1999-09-21 20:41:20 +00:00
*
* owner name
* type
* trust
1999-09-21 20:41:20 +00:00
* rdata count
* rdata length These two occur 'rdata
* rdata count' times.
1999-09-21 20:41:20 +00:00
*
*/
static uint8_t
atomic_getuint8(isc_buffer_t *b) {
atomic_uchar *cp = isc_buffer_current(b);
uint8_t ret = atomic_load_relaxed(cp);
isc_buffer_forward(b, 1);
return ret;
}
static isc_result_t
1999-09-21 20:41:20 +00:00
copy_rdataset(dns_rdataset_t *rdataset, isc_buffer_t *buffer) {
unsigned int count;
isc_region_t ar, r;
/*
* Copy the rdataset count to the buffer.
*/
isc_buffer_availableregion(buffer, &ar);
1999-09-21 20:41:20 +00:00
if (ar.length < 2) {
return ISC_R_NOSPACE;
}
1999-09-21 20:41:20 +00:00
count = dns_rdataset_count(rdataset);
INSIST(count <= 65535);
isc_buffer_putuint16(buffer, (uint16_t)count);
1999-09-21 20:41:20 +00:00
DNS_RDATASET_FOREACH(rdataset) {
isc_result_t result;
dns_rdata_t rdata = DNS_RDATA_INIT;
1999-09-21 20:41:20 +00:00
dns_rdataset_current(rdataset, &rdata);
1999-09-21 20:41:20 +00:00
dns_rdata_toregion(&rdata, &r);
INSIST(r.length <= 65535);
isc_buffer_availableregion(buffer, &ar);
1999-09-21 20:41:20 +00:00
if (ar.length < 2) {
return ISC_R_NOSPACE;
}
1999-09-21 20:41:20 +00:00
/*
* Copy the rdata length to the buffer.
*/
isc_buffer_putuint16(buffer, (uint16_t)r.length);
1999-09-21 20:41:20 +00:00
/*
* Copy the rdata to the buffer.
*/
result = isc_buffer_copyregion(buffer, &r);
if (result != ISC_R_SUCCESS) {
return result;
}
}
1999-09-21 20:41:20 +00:00
return ISC_R_SUCCESS;
}
isc_result_t
dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl,
dns_ttl_t maxttl, bool optout, bool secure,
dns_rdataset_t *addedrdataset) {
1999-09-21 20:41:20 +00:00
isc_buffer_t buffer;
isc_region_t r;
dns_rdatatype_t type;
dns_ttl_t ttl;
dns_trust_t trust;
dns_rdata_t rdata[DNS_NCACHE_RDATA];
1999-11-03 03:20:34 +00:00
dns_rdataset_t ncrdataset;
dns_rdatalist_t ncrdatalist;
unsigned char data[65536];
unsigned int next = 0;
isc_result_t result;
1999-09-21 20:41:20 +00:00
1999-09-22 00:26:19 +00:00
/*
* Convert the authority data from 'message' into a negative cache
* rdataset, and store it in 'cache' at 'node'.
*
* We assume that all data in the authority section has been
* validated by the caller.
1999-09-22 00:26:19 +00:00
*/
REQUIRE(message != NULL);
1999-09-21 20:41:20 +00:00
/*
* If 'secure' is false, ignore 'optout'.
1999-09-21 20:41:20 +00:00
*/
optout = optout && secure;
1999-09-21 20:41:20 +00:00
/*
* Initialize the list.
*/
dns_rdatalist_init(&ncrdatalist);
ncrdatalist.rdclass = dns_db_class(cache);
ncrdatalist.covers = covers;
ncrdatalist.ttl = maxttl;
/*
* Build an ncache rdatas into buffer.
1999-09-21 20:41:20 +00:00
*/
ttl = maxttl;
trust = 0xffff;
isc_buffer_init(&buffer, data, sizeof(data));
MSG_SECTION_FOREACH(message, DNS_SECTION_AUTHORITY, name) {
result = ISC_R_SUCCESS;
if (name->attributes.ncache) {
ISC_LIST_FOREACH(name->list, rdataset, link) {
if (!rdataset->attributes.ncache) {
1999-10-15 20:50:19 +00:00
continue;
}
1999-10-15 20:50:19 +00:00
type = rdataset->type;
if (type == dns_rdatatype_rrsig) {
1999-10-15 20:50:19 +00:00
type = rdataset->covers;
}
1999-10-15 20:50:19 +00:00
if (type == dns_rdatatype_soa ||
dns_rdatatype_isnsec(type))
{
if (ttl > rdataset->ttl) {
1999-10-15 20:50:19 +00:00
ttl = rdataset->ttl;
}
if (ttl < minttl) {
ttl = minttl;
}
if (trust > rdataset->trust) {
trust = rdataset->trust;
}
1999-10-15 20:50:19 +00:00
/*
* Copy the owner name to the buffer.
*/
dns_name_toregion(name, &r);
result = isc_buffer_copyregion(&buffer,
&r);
if (result != ISC_R_SUCCESS) {
return result;
}
1999-10-15 20:50:19 +00:00
/*
* Copy the type to the buffer.
*/
isc_buffer_availableregion(&buffer, &r);
if (r.length < 3) {
1999-10-15 20:50:19 +00:00
return ISC_R_NOSPACE;
}
isc_buffer_putuint16(&buffer,
rdataset->type);
isc_buffer_putuint8(
&buffer,
(unsigned char)rdataset->trust);
1999-10-15 20:50:19 +00:00
/*
* Copy the rdataset into the buffer.
*/
result = copy_rdataset(rdataset,
&buffer);
if (result != ISC_R_SUCCESS) {
return result;
}
if (next >= DNS_NCACHE_RDATA) {
return ISC_R_NOSPACE;
}
dns_rdata_init(&rdata[next]);
isc_buffer_remainingregion(&buffer, &r);
rdata[next].data = r.base;
rdata[next].length = r.length;
rdata[next].rdclass =
ncrdatalist.rdclass;
rdata[next].type = dns_rdatatype_none;
rdata[next].flags = 0;
ISC_LIST_APPEND(ncrdatalist.rdata,
&rdata[next], link);
isc_buffer_forward(&buffer, r.length);
next++;
1999-10-15 20:50:19 +00:00
}
1999-09-21 20:41:20 +00:00
}
}
}
1999-09-21 20:41:20 +00:00
1999-11-03 03:20:34 +00:00
if (trust == 0xffff) {
if ((message->flags & DNS_MESSAGEFLAG_AA) != 0 &&
message->counts[DNS_SECTION_ANSWER] == 0)
{
/*
* The response has aa set and we haven't followed
* any CNAME or DNAME chains.
*/
trust = dns_trust_authauthority;
} else {
trust = dns_trust_additional;
}
ttl = 0;
1999-11-03 03:20:34 +00:00
}
INSIST(trust != 0xffff);
1999-09-21 20:41:20 +00:00
ncrdatalist.ttl = ttl;
1999-09-21 20:41:20 +00:00
dns_rdataset_init(&ncrdataset);
dns_rdatalist_tordataset(&ncrdatalist, &ncrdataset);
if (!secure && trust > dns_trust_answer) {
trust = dns_trust_answer;
}
ncrdataset.trust = trust;
ncrdataset.attributes.negative = true;
if (message->rcode == dns_rcode_nxdomain) {
ncrdataset.attributes.nxdomain = true;
}
if (optout) {
ncrdataset.attributes.optout = true;
}
1999-09-21 20:41:20 +00:00
result = dns_db_addrdataset(cache, node, NULL, now, &ncrdataset, 0,
addedrdataset);
if (result != ISC_R_SUCCESS && result != DNS_R_UNCHANGED) {
return result;
}
return ISC_R_SUCCESS;
1999-09-21 20:41:20 +00:00
}
isc_result_t
dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
isc_buffer_t *target, unsigned int options,
unsigned int *countp) {
1999-09-22 00:26:19 +00:00
isc_result_t result;
isc_region_t remaining, tavailable;
1999-09-22 00:26:19 +00:00
isc_buffer_t source, savedbuffer, rdlen;
dns_name_t name;
dns_rdatatype_t type;
unsigned int i, rcount, count;
/*
* Convert the negative caching rdataset 'rdataset' to wire format,
* compressing names as specified in 'cctx', and storing the result in
* 'target'.
*/
REQUIRE(rdataset != NULL);
REQUIRE(rdataset->type == dns_rdatatype_none);
REQUIRE(rdataset->attributes.negative);
1999-09-21 20:41:20 +00:00
1999-09-22 00:26:19 +00:00
savedbuffer = *target;
count = 0;
DNS_RDATASET_FOREACH(rdataset) {
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdataset_current(rdataset, &rdata);
isc_buffer_init(&source, rdata.data, rdata.length);
isc_buffer_add(&source, rdata.length);
dns_name_init(&name);
isc_buffer_remainingregion(&source, &remaining);
1999-09-22 00:26:19 +00:00
dns_name_fromregion(&name, &remaining);
INSIST(remaining.length >= name.length);
isc_buffer_forward(&source, name.length);
remaining.length -= name.length;
INSIST(remaining.length >= 5);
1999-09-22 00:26:19 +00:00
type = isc_buffer_getuint16(&source);
isc_buffer_forward(&source, 1);
1999-09-22 00:26:19 +00:00
rcount = isc_buffer_getuint16(&source);
1999-09-21 20:41:20 +00:00
1999-09-22 00:26:19 +00:00
for (i = 0; i < rcount; i++) {
/*
* Get the length of this rdata and set up an
* rdata structure for it.
*/
isc_buffer_remainingregion(&source, &remaining);
1999-09-22 00:26:19 +00:00
INSIST(remaining.length >= 2);
dns_rdata_reset(&rdata);
1999-09-22 00:26:19 +00:00
rdata.length = isc_buffer_getuint16(&source);
isc_buffer_remainingregion(&source, &remaining);
1999-09-22 00:26:19 +00:00
rdata.data = remaining.base;
rdata.type = type;
rdata.rdclass = rdataset->rdclass;
INSIST(remaining.length >= rdata.length);
isc_buffer_forward(&source, rdata.length);
if ((options & DNS_NCACHETOWIRE_OMITDNSSEC) != 0 &&
dns_rdatatype_isdnssec(type))
{
continue;
}
1999-09-22 00:26:19 +00:00
/*
* Write the name.
*/
dns_compress_setpermitted(cctx, true);
result = dns_name_towire(&name, cctx, target);
if (result != ISC_R_SUCCESS) {
1999-09-22 00:26:19 +00:00
goto rollback;
}
1999-09-22 00:26:19 +00:00
/*
* See if we have space for type, class, ttl, and
* rdata length. Write the type, class, and ttl.
*/
isc_buffer_availableregion(target, &tavailable);
if (tavailable.length < 10) {
1999-09-22 00:26:19 +00:00
result = ISC_R_NOSPACE;
goto rollback;
}
isc_buffer_putuint16(target, type);
isc_buffer_putuint16(target, rdataset->rdclass);
isc_buffer_putuint32(target, rdataset->ttl);
/*
* Save space for rdata length.
*/
rdlen = *target;
isc_buffer_add(target, 2);
1999-09-22 00:26:19 +00:00
/*
* Write the rdata.
*/
result = dns_rdata_towire(&rdata, cctx, target);
if (result != ISC_R_SUCCESS) {
1999-09-22 00:26:19 +00:00
goto rollback;
}
1999-09-22 00:26:19 +00:00
/*
* Set the rdata length field to the compressed
* length.
*/
INSIST((target->used >= rdlen.used + 2) &&
(target->used - rdlen.used - 2 < 65536));
1999-09-22 00:26:19 +00:00
isc_buffer_putuint16(
&rdlen,
(uint16_t)(target->used - rdlen.used - 2));
1999-09-22 00:26:19 +00:00
count++;
}
INSIST(isc_buffer_remaininglength(&source) == 0);
}
1999-09-22 00:26:19 +00:00
*countp = count;
1999-09-22 00:26:19 +00:00
return ISC_R_SUCCESS;
rollback:
dns_compress_rollback(cctx, savedbuffer.used);
1999-09-22 00:26:19 +00:00
*countp = 0;
*target = savedbuffer;
return result;
1999-09-21 20:41:20 +00:00
}
static void
rdataset_disassociate(dns_rdataset_t *rdataset DNS__DB_FLARG) {
UNUSED(rdataset);
}
static isc_result_t
rdataset_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
unsigned char *raw;
unsigned int count;
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
raw = rdataset->ncache.raw;
count = raw[0] * 256 + raw[1];
if (count == 0) {
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->ncache.iter_pos = NULL;
return ISC_R_NOMORE;
}
/*
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
* iter_count is the number of rdata beyond the cursor position,
* so we decrement the total count by one before storing it.
*/
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->ncache.iter_pos = raw + 2;
rdataset->ncache.iter_count = count - 1;
return ISC_R_SUCCESS;
}
static isc_result_t
rdataset_next(dns_rdataset_t *rdataset) {
unsigned int count;
unsigned int length;
unsigned char *raw;
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
raw = rdataset->ncache.iter_pos;
count = rdataset->ncache.iter_count;
if (count == 0) {
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->ncache.iter_pos = NULL;
return ISC_R_NOMORE;
}
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
length = raw[0] * 256 + raw[1];
rdataset->ncache.iter_pos = raw + 2 + length;
rdataset->ncache.iter_count = count - 1;
return ISC_R_SUCCESS;
}
static void
rdataset_current(dns_rdataset_t *rdataset, 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
unsigned char *raw;
isc_region_t r;
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
raw = rdataset->ncache.iter_pos;
REQUIRE(raw != NULL);
r.length = raw[0] * 256 + raw[1];
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
r.base = raw + 2;
dns_rdata_fromregion(rdata, rdataset->rdclass, rdataset->type, &r);
}
static void
rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target DNS__DB_FLARG) {
*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->ncache.iter_pos = NULL;
target->ncache.iter_count = 0;
}
static unsigned int
rdataset_count(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
unsigned char *raw;
unsigned int count;
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
raw = rdataset->ncache.raw;
count = raw[0] * 256 + raw[1];
return count;
}
static void
rdataset_settrust(dns_rdataset_t *rdataset, dns_trust_t trust) {
atomic_uchar *raw;
raw = (atomic_uchar *)rdataset->ncache.raw;
atomic_store_relaxed(&raw[-1], (unsigned char)trust);
rdataset->trust = trust;
}
static dns_rdatasetmethods_t rdataset_methods = {
.disassociate = rdataset_disassociate,
.first = rdataset_first,
.next = rdataset_next,
.current = rdataset_current,
.clone = rdataset_clone,
.count = rdataset_count,
.settrust = rdataset_settrust,
};
isc_result_t
dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
dns_rdatatype_t type, dns_rdataset_t *rdataset) {
isc_result_t result = ISC_R_NOTFOUND;
isc_region_t remaining;
isc_buffer_t source;
dns_name_t tname;
dns_rdatatype_t ttype;
dns_trust_t trust = dns_trust_none;
dns_rdataset_t rclone;
REQUIRE(ncacherdataset != 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(DNS_RDATASET_VALID(ncacherdataset));
REQUIRE(ncacherdataset->type == dns_rdatatype_none);
REQUIRE(ncacherdataset->attributes.negative);
REQUIRE(name != NULL);
REQUIRE(!dns_rdataset_isassociated(rdataset));
REQUIRE(type != dns_rdatatype_rrsig);
dns_rdataset_init(&rclone);
dns_rdataset_clone(ncacherdataset, &rclone);
DNS_RDATASET_FOREACH(&rclone) {
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdataset_current(&rclone, &rdata);
isc_buffer_init(&source, rdata.data, rdata.length);
isc_buffer_add(&source, rdata.length);
dns_name_init(&tname);
isc_buffer_remainingregion(&source, &remaining);
dns_name_fromregion(&tname, &remaining);
INSIST(remaining.length >= tname.length);
isc_buffer_forward(&source, tname.length);
remaining.length -= tname.length;
INSIST(remaining.length >= 3);
ttype = isc_buffer_getuint16(&source);
if (ttype == type && dns_name_equal(&tname, name)) {
trust = atomic_getuint8(&source);
INSIST(trust <= dns_trust_ultimate);
isc_buffer_remainingregion(&source, &remaining);
result = ISC_R_SUCCESS;
break;
}
}
dns_rdataset_disassociate(&rclone);
if (result == ISC_R_SUCCESS) {
INSIST(remaining.length != 0);
rdataset->methods = &rdataset_methods;
rdataset->rdclass = ncacherdataset->rdclass;
rdataset->type = type;
rdataset->covers = dns_rdatatype_none;
rdataset->ttl = ncacherdataset->ttl;
rdataset->trust = trust;
rdataset->ncache.raw = remaining.base;
rdataset->ncache.iter_pos = NULL;
rdataset->ncache.iter_count = 0;
}
return result;
}
isc_result_t
dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
2010-05-14 23:50:40 +00:00
dns_rdatatype_t covers, dns_rdataset_t *rdataset) {
isc_result_t result = ISC_R_NOTFOUND;
dns_name_t tname;
dns_rdata_rrsig_t rrsig;
dns_rdataset_t rclone;
dns_rdatatype_t type;
dns_trust_t trust = dns_trust_none;
isc_buffer_t source;
isc_region_t remaining, sigregion;
unsigned char *raw = NULL;
unsigned int count;
REQUIRE(ncacherdataset != NULL);
REQUIRE(ncacherdataset->type == dns_rdatatype_none);
REQUIRE(ncacherdataset->attributes.negative);
REQUIRE(name != NULL);
REQUIRE(!dns_rdataset_isassociated(rdataset));
dns_rdataset_init(&rclone);
dns_rdataset_clone(ncacherdataset, &rclone);
DNS_RDATASET_FOREACH(&rclone) {
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdataset_current(&rclone, &rdata);
isc_buffer_init(&source, rdata.data, rdata.length);
isc_buffer_add(&source, rdata.length);
dns_name_init(&tname);
isc_buffer_remainingregion(&source, &remaining);
dns_name_fromregion(&tname, &remaining);
INSIST(remaining.length >= tname.length);
isc_buffer_forward(&source, tname.length);
isc_region_consume(&remaining, tname.length);
INSIST(remaining.length >= 2);
type = isc_buffer_getuint16(&source);
isc_region_consume(&remaining, 2);
if (type != dns_rdatatype_rrsig ||
2022-11-02 19:33:14 +01:00
!dns_name_equal(&tname, name))
{
continue;
}
INSIST(remaining.length >= 1);
trust = atomic_getuint8(&source);
INSIST(trust <= dns_trust_ultimate);
isc_region_consume(&remaining, 1);
raw = remaining.base;
count = raw[0] * 256 + raw[1];
INSIST(count > 0);
raw += 2;
sigregion.length = raw[0] * 256 + raw[1];
raw += 2;
sigregion.base = raw;
dns_rdata_reset(&rdata);
dns_rdata_fromregion(&rdata, rdataset->rdclass,
dns_rdatatype_rrsig, &sigregion);
(void)dns_rdata_tostruct(&rdata, &rrsig, NULL);
if (rrsig.covered == covers) {
isc_buffer_remainingregion(&source, &remaining);
result = ISC_R_SUCCESS;
break;
}
}
dns_rdataset_disassociate(&rclone);
if (result == ISC_R_SUCCESS) {
INSIST(remaining.length != 0);
rdataset->methods = &rdataset_methods;
rdataset->rdclass = ncacherdataset->rdclass;
rdataset->type = dns_rdatatype_rrsig;
rdataset->covers = covers;
rdataset->ttl = ncacherdataset->ttl;
rdataset->trust = trust;
rdataset->ncache.raw = remaining.base;
rdataset->ncache.iter_pos = NULL;
rdataset->ncache.iter_count = 0;
}
return result;
}
void
dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
dns_rdataset_t *rdataset) {
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_trust_t trust;
isc_region_t remaining, sigregion;
isc_buffer_t source;
dns_name_t tname;
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_rdatatype_t type, covers;
unsigned int count;
dns_rdata_rrsig_t rrsig;
unsigned char *raw;
REQUIRE(ncacherdataset != NULL);
REQUIRE(ncacherdataset->type == dns_rdatatype_none);
REQUIRE(ncacherdataset->attributes.negative);
REQUIRE(found != NULL);
REQUIRE(!dns_rdataset_isassociated(rdataset));
dns_rdataset_current(ncacherdataset, &rdata);
isc_buffer_init(&source, rdata.data, rdata.length);
isc_buffer_add(&source, rdata.length);
dns_name_init(&tname);
isc_buffer_remainingregion(&source, &remaining);
dns_name_fromregion(found, &remaining);
INSIST(remaining.length >= found->length);
isc_buffer_forward(&source, found->length);
remaining.length -= found->length;
INSIST(remaining.length >= 5);
type = isc_buffer_getuint16(&source);
trust = atomic_getuint8(&source);
INSIST(trust <= dns_trust_ultimate);
isc_buffer_remainingregion(&source, &remaining);
if (type == dns_rdatatype_rrsig) {
/*
* Extract covers from RRSIG.
*/
raw = remaining.base;
count = raw[0] * 256 + raw[1];
INSIST(count > 0);
raw += 2;
sigregion.length = raw[0] * 256 + raw[1];
raw += 2;
sigregion.base = raw;
dns_rdata_reset(&rdata);
dns_rdata_fromregion(&rdata, ncacherdataset->rdclass, type,
&sigregion);
(void)dns_rdata_tostruct(&rdata, &rrsig, 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
covers = rrsig.covered;
} else {
covers = dns_rdatatype_none;
}
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->methods = &rdataset_methods;
rdataset->rdclass = ncacherdataset->rdclass;
rdataset->type = type;
rdataset->covers = covers;
rdataset->ttl = ncacherdataset->ttl;
rdataset->trust = trust;
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->ncache.raw = remaining.base;
rdataset->ncache.iter_pos = NULL;
rdataset->ncache.iter_count = 0;
}