1999-01-15 03:31:17 +00:00
|
|
|
/*
|
2000-02-03 23:50:32 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
1999-01-15 03:31:17 +00:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2000-07-27 09:55:03 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
|
|
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
|
|
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
1999-01-15 03:31:17 +00:00
|
|
|
*/
|
|
|
|
|
2000-12-11 23:09:47 +00:00
|
|
|
/* $Id: rdataset.c,v 1.53 2000/12/11 23:09:45 marka Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1999-01-22 01:21:44 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-02-24 21:08:34 +00:00
|
|
|
#include <stdlib.h>
|
1999-01-15 03:31:17 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/buffer.h>
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-01-15 03:31:17 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/name.h>
|
1999-09-22 00:26:40 +00:00
|
|
|
#include <dns/ncache.h>
|
1999-01-15 19:36:07 +00:00
|
|
|
#include <dns/rdata.h>
|
1999-01-15 03:31:17 +00:00
|
|
|
#include <dns/rdataset.h>
|
1999-02-22 07:24:05 +00:00
|
|
|
#include <dns/compress.h>
|
1999-01-15 03:31:17 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
dns_rdataset_init(dns_rdataset_t *rdataset) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make 'rdataset' a valid, disassociated rdataset.
|
|
|
|
*/
|
|
|
|
|
|
|
|
REQUIRE(rdataset != NULL);
|
|
|
|
|
1999-01-15 08:07:09 +00:00
|
|
|
rdataset->magic = DNS_RDATASET_MAGIC;
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->methods = NULL;
|
|
|
|
ISC_LINK_INIT(rdataset, link);
|
1999-03-04 02:48:47 +00:00
|
|
|
rdataset->rdclass = 0;
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->type = 0;
|
|
|
|
rdataset->ttl = 0;
|
1999-06-16 23:47:09 +00:00
|
|
|
rdataset->trust = 0;
|
1999-08-31 22:14:06 +00:00
|
|
|
rdataset->covers = 0;
|
1999-05-21 00:48:45 +00:00
|
|
|
rdataset->attributes = 0;
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->private1 = NULL;
|
|
|
|
rdataset->private2 = NULL;
|
|
|
|
rdataset->private3 = NULL;
|
1999-01-29 22:19:38 +00:00
|
|
|
rdataset->private4 = NULL;
|
|
|
|
rdataset->private5 = NULL;
|
1999-01-15 03:31:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_rdataset_invalidate(dns_rdataset_t *rdataset) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Invalidate 'rdataset'.
|
|
|
|
*/
|
|
|
|
|
1999-01-15 08:07:09 +00:00
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
1999-01-15 03:31:17 +00:00
|
|
|
REQUIRE(rdataset->methods == NULL);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->magic = 0;
|
|
|
|
ISC_LINK_INIT(rdataset, link);
|
1999-03-04 02:48:47 +00:00
|
|
|
rdataset->rdclass = 0;
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->type = 0;
|
|
|
|
rdataset->ttl = 0;
|
1999-06-16 23:47:09 +00:00
|
|
|
rdataset->trust = 0;
|
1999-08-31 22:14:06 +00:00
|
|
|
rdataset->covers = 0;
|
1999-05-21 00:48:45 +00:00
|
|
|
rdataset->attributes = 0;
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->private1 = NULL;
|
|
|
|
rdataset->private2 = NULL;
|
|
|
|
rdataset->private3 = NULL;
|
1999-01-29 22:19:38 +00:00
|
|
|
rdataset->private4 = NULL;
|
|
|
|
rdataset->private5 = NULL;
|
1999-01-15 03:31:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_rdataset_disassociate(dns_rdataset_t *rdataset) {
|
|
|
|
|
|
|
|
/*
|
1999-01-28 23:52:24 +00:00
|
|
|
* Disassociate 'rdataset' from its rdata, allowing it to be reused.
|
1999-01-15 03:31:17 +00:00
|
|
|
*/
|
|
|
|
|
1999-01-15 08:07:09 +00:00
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
1999-04-01 04:01:30 +00:00
|
|
|
REQUIRE(rdataset->methods != NULL);
|
1999-01-15 03:31:17 +00:00
|
|
|
|
|
|
|
(rdataset->methods->disassociate)(rdataset);
|
|
|
|
rdataset->methods = NULL;
|
|
|
|
ISC_LINK_INIT(rdataset, link);
|
1999-03-04 02:48:47 +00:00
|
|
|
rdataset->rdclass = 0;
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->type = 0;
|
|
|
|
rdataset->ttl = 0;
|
1999-06-16 23:47:09 +00:00
|
|
|
rdataset->trust = 0;
|
1999-08-31 22:14:06 +00:00
|
|
|
rdataset->covers = 0;
|
1999-05-21 00:48:45 +00:00
|
|
|
rdataset->attributes = 0;
|
1999-01-15 03:31:17 +00:00
|
|
|
rdataset->private1 = NULL;
|
|
|
|
rdataset->private2 = NULL;
|
|
|
|
rdataset->private3 = NULL;
|
1999-01-29 22:19:38 +00:00
|
|
|
rdataset->private4 = NULL;
|
|
|
|
rdataset->private5 = NULL;
|
1999-01-15 03:31:17 +00:00
|
|
|
}
|
|
|
|
|
1999-08-19 20:44:56 +00:00
|
|
|
isc_boolean_t
|
|
|
|
dns_rdataset_isassociated(dns_rdataset_t *rdataset) {
|
|
|
|
/*
|
|
|
|
* Is 'rdataset' associated?
|
|
|
|
*/
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-08-19 20:44:56 +00:00
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
|
|
|
|
|
|
|
if (rdataset->methods != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
|
|
|
|
return (ISC_FALSE);
|
|
|
|
}
|
|
|
|
|
1999-07-03 20:52:50 +00:00
|
|
|
static void
|
|
|
|
question_disassociate(dns_rdataset_t *rdataset) {
|
2000-08-11 16:47:33 +00:00
|
|
|
UNUSED(rdataset);
|
1999-07-03 20:52:50 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static isc_result_t
|
1999-07-03 20:52:50 +00:00
|
|
|
question_cursor(dns_rdataset_t *rdataset) {
|
2000-08-11 16:47:33 +00:00
|
|
|
UNUSED(rdataset);
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_NOMORE);
|
1999-07-03 20:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
question_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
|
|
|
|
/*
|
|
|
|
* This routine should never be called.
|
|
|
|
*/
|
2000-08-11 16:47:33 +00:00
|
|
|
UNUSED(rdataset);
|
|
|
|
UNUSED(rdata);
|
|
|
|
|
1999-07-03 20:52:50 +00:00
|
|
|
REQUIRE(0);
|
|
|
|
}
|
|
|
|
|
1999-07-13 01:50:22 +00:00
|
|
|
static void
|
|
|
|
question_clone(dns_rdataset_t *source, dns_rdataset_t *target) {
|
|
|
|
*target = *source;
|
|
|
|
}
|
|
|
|
|
1999-09-21 20:40:42 +00:00
|
|
|
static unsigned int
|
|
|
|
question_count(dns_rdataset_t *rdataset) {
|
|
|
|
/*
|
|
|
|
* This routine should never be called.
|
|
|
|
*/
|
2000-08-11 16:47:33 +00:00
|
|
|
UNUSED(rdataset);
|
1999-09-21 20:40:42 +00:00
|
|
|
REQUIRE(0);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-07-03 20:52:50 +00:00
|
|
|
static dns_rdatasetmethods_t question_methods = {
|
|
|
|
question_disassociate,
|
|
|
|
question_cursor,
|
|
|
|
question_cursor,
|
1999-07-13 01:50:22 +00:00
|
|
|
question_current,
|
1999-08-31 22:14:06 +00:00
|
|
|
question_clone,
|
1999-09-21 20:40:42 +00:00
|
|
|
question_count
|
1999-07-03 20:52:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_rdataset_makequestion(dns_rdataset_t *rdataset, dns_rdataclass_t rdclass,
|
|
|
|
dns_rdatatype_t type)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make 'rdataset' a valid, associated, question rdataset, with a
|
|
|
|
* question class of 'rdclass' and type 'type'.
|
|
|
|
*/
|
|
|
|
|
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
|
|
|
REQUIRE(rdataset->methods == NULL);
|
|
|
|
|
|
|
|
rdataset->methods = &question_methods;
|
|
|
|
rdataset->rdclass = rdclass;
|
|
|
|
rdataset->type = type;
|
|
|
|
rdataset->attributes |= DNS_RDATASETATTR_QUESTION;
|
|
|
|
}
|
|
|
|
|
1999-09-21 20:40:42 +00:00
|
|
|
unsigned int
|
|
|
|
dns_rdataset_count(dns_rdataset_t *rdataset) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the number of records in 'rdataset'.
|
|
|
|
*/
|
|
|
|
|
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
|
|
|
REQUIRE(rdataset->methods != NULL);
|
|
|
|
|
|
|
|
return ((rdataset->methods->count)(rdataset));
|
|
|
|
}
|
|
|
|
|
1999-07-13 01:50:22 +00:00
|
|
|
void
|
|
|
|
dns_rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make 'target' refer to the same rdataset as 'source'.
|
|
|
|
*/
|
|
|
|
|
|
|
|
REQUIRE(DNS_RDATASET_VALID(source));
|
|
|
|
REQUIRE(source->methods != NULL);
|
|
|
|
REQUIRE(DNS_RDATASET_VALID(target));
|
|
|
|
REQUIRE(target->methods == NULL);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-07-13 01:50:22 +00:00
|
|
|
(source->methods->clone)(source, target);
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
1999-01-15 03:31:17 +00:00
|
|
|
dns_rdataset_first(dns_rdataset_t *rdataset) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move the rdata cursor to the first rdata in the rdataset (if any).
|
|
|
|
*/
|
|
|
|
|
1999-01-15 08:07:09 +00:00
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
1999-04-01 04:01:30 +00:00
|
|
|
REQUIRE(rdataset->methods != NULL);
|
1999-01-15 03:31:17 +00:00
|
|
|
|
|
|
|
return ((rdataset->methods->first)(rdataset));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
1999-01-15 03:31:17 +00:00
|
|
|
dns_rdataset_next(dns_rdataset_t *rdataset) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move the rdata cursor to the next rdata in the rdataset (if any).
|
|
|
|
*/
|
|
|
|
|
1999-01-15 08:07:09 +00:00
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
1999-04-01 04:01:30 +00:00
|
|
|
REQUIRE(rdataset->methods != NULL);
|
1999-01-15 03:31:17 +00:00
|
|
|
|
|
|
|
return ((rdataset->methods->next)(rdataset));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make 'rdata' refer to the current rdata.
|
|
|
|
*/
|
|
|
|
|
1999-01-15 08:07:09 +00:00
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
1999-04-01 04:01:30 +00:00
|
|
|
REQUIRE(rdataset->methods != NULL);
|
1999-01-15 03:31:17 +00:00
|
|
|
|
|
|
|
(rdataset->methods->current)(rdataset, rdata);
|
|
|
|
}
|
|
|
|
|
2000-02-24 21:08:34 +00:00
|
|
|
#define MAX_SHUFFLE 32
|
|
|
|
#define WANT_FIXED(r) (((r)->attributes & DNS_RDATASETATTR_FIXEDORDER) != 0)
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-11-10 03:16:26 +00:00
|
|
|
struct towire_sort {
|
|
|
|
int key;
|
|
|
|
dns_rdata_t *rdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
towire_compare(const void *av, const void *bv) {
|
|
|
|
const struct towire_sort *a = (const struct towire_sort *) av;
|
|
|
|
const struct towire_sort *b = (const struct towire_sort *) bv;
|
|
|
|
return (a->key - b->key);
|
|
|
|
}
|
2000-02-24 21:08:34 +00:00
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
2000-11-10 03:16:26 +00:00
|
|
|
dns_rdataset_towiresorted(dns_rdataset_t *rdataset,
|
|
|
|
dns_name_t *owner_name,
|
|
|
|
dns_compress_t *cctx,
|
|
|
|
isc_buffer_t *target,
|
|
|
|
dns_rdatasetorderfunc_t order,
|
|
|
|
void *order_arg,
|
|
|
|
unsigned int *countp)
|
1999-01-15 03:31:17 +00:00
|
|
|
{
|
2000-12-11 23:09:47 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
1999-01-27 05:54:39 +00:00
|
|
|
isc_region_t r;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
2000-11-10 03:16:26 +00:00
|
|
|
unsigned int i, count;
|
1999-09-22 00:26:40 +00:00
|
|
|
isc_buffer_t savedbuffer, rdlen;
|
1999-04-30 07:08:55 +00:00
|
|
|
unsigned int headlen;
|
1999-07-03 20:52:50 +00:00
|
|
|
isc_boolean_t question = ISC_FALSE;
|
2000-02-24 21:08:34 +00:00
|
|
|
isc_boolean_t shuffle = ISC_FALSE;
|
|
|
|
dns_rdata_t shuffled[MAX_SHUFFLE];
|
2000-11-10 03:16:26 +00:00
|
|
|
struct towire_sort sorted[MAX_SHUFFLE];
|
1999-01-15 03:31:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert 'rdataset' to wire format, compressing names as specified
|
|
|
|
* in cctx, and storing the result in 'target'.
|
|
|
|
*/
|
|
|
|
|
1999-01-15 19:36:07 +00:00
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
1999-01-30 05:01:01 +00:00
|
|
|
REQUIRE(countp != NULL);
|
2000-11-10 03:16:26 +00:00
|
|
|
REQUIRE((order == NULL) == (order_arg == NULL));
|
1999-01-15 19:36:07 +00:00
|
|
|
|
2000-02-24 21:08:34 +00:00
|
|
|
count = 0;
|
1999-08-03 20:54:56 +00:00
|
|
|
if ((rdataset->attributes & DNS_RDATASETATTR_QUESTION) != 0) {
|
1999-07-03 20:52:50 +00:00
|
|
|
question = ISC_TRUE;
|
2000-02-24 21:08:34 +00:00
|
|
|
count = 1;
|
1999-08-03 20:54:56 +00:00
|
|
|
result = dns_rdataset_first(rdataset);
|
2000-04-06 22:03:35 +00:00
|
|
|
INSIST(result == ISC_R_NOMORE);
|
1999-09-22 00:26:40 +00:00
|
|
|
} else if (rdataset->type == 0) {
|
|
|
|
/*
|
|
|
|
* This is a negative caching rdataset.
|
|
|
|
*/
|
|
|
|
return (dns_ncache_towire(rdataset, cctx, target, countp));
|
1999-08-03 20:54:56 +00:00
|
|
|
} else {
|
2000-02-24 21:08:34 +00:00
|
|
|
count = (rdataset->methods->count)(rdataset);
|
1999-07-03 20:52:50 +00:00
|
|
|
result = dns_rdataset_first(rdataset);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_NOMORE)
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-07-03 20:52:50 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-11-10 03:16:26 +00:00
|
|
|
/*
|
|
|
|
* We'll only shuffle if we've got enough slots in our
|
|
|
|
* deck.
|
|
|
|
*
|
|
|
|
* There's no point to shuffling SIGs.
|
|
|
|
*/
|
|
|
|
if (!question &&
|
|
|
|
count > 1 &&
|
|
|
|
!WANT_FIXED(rdataset) &&
|
|
|
|
count <= MAX_SHUFFLE &&
|
|
|
|
rdataset->type != dns_rdatatype_sig)
|
|
|
|
{
|
|
|
|
shuffle = ISC_TRUE;
|
|
|
|
/*
|
|
|
|
* First we get handles to all of the rdata.
|
|
|
|
*/
|
|
|
|
i = 0;
|
|
|
|
do {
|
|
|
|
INSIST(i < count);
|
|
|
|
dns_rdata_init(&shuffled[i]);
|
|
|
|
dns_rdataset_current(rdataset, &shuffled[i]);
|
|
|
|
i++;
|
|
|
|
result = dns_rdataset_next(rdataset);
|
|
|
|
} while (result == ISC_R_SUCCESS);
|
|
|
|
if (result != ISC_R_NOMORE)
|
|
|
|
return (result);
|
|
|
|
INSIST(i == count);
|
2000-02-24 21:08:34 +00:00
|
|
|
/*
|
2000-11-10 03:16:26 +00:00
|
|
|
* Now we shuffle.
|
2000-02-24 21:08:34 +00:00
|
|
|
*/
|
2000-11-10 03:16:26 +00:00
|
|
|
if (order != NULL) {
|
2000-02-24 21:08:34 +00:00
|
|
|
/*
|
2000-11-10 03:16:26 +00:00
|
|
|
* Sorted order.
|
2000-02-24 21:08:34 +00:00
|
|
|
*/
|
2000-11-10 03:16:26 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
sorted[i].key = (*order)(&shuffled[i],
|
|
|
|
order_arg);
|
|
|
|
sorted[i].rdata = &shuffled[i];
|
|
|
|
}
|
|
|
|
qsort(sorted, count, sizeof(sorted[0]),
|
|
|
|
towire_compare);
|
|
|
|
} else {
|
2000-02-24 21:08:34 +00:00
|
|
|
/*
|
2000-11-10 03:16:26 +00:00
|
|
|
* "Cyclic" order.
|
2000-02-24 21:08:34 +00:00
|
|
|
*/
|
2000-11-10 03:16:26 +00:00
|
|
|
unsigned int j = (((unsigned int)rand()) >> 3) % count;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
sorted[j].key = 0; /* Unused */
|
|
|
|
sorted[j].rdata = &shuffled[i];
|
|
|
|
j++;
|
|
|
|
if (j == count)
|
|
|
|
j = 0; /* Wrap around. */
|
2000-02-24 21:08:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-22 00:26:40 +00:00
|
|
|
savedbuffer = *target;
|
2000-11-10 03:16:26 +00:00
|
|
|
i = 0;
|
1999-09-22 00:26:40 +00:00
|
|
|
|
1999-01-27 05:54:39 +00:00
|
|
|
do {
|
|
|
|
/*
|
2000-05-08 14:38:29 +00:00
|
|
|
* Copy out the name, type, class, ttl.
|
1999-01-27 05:54:39 +00:00
|
|
|
*/
|
2000-05-04 22:19:34 +00:00
|
|
|
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
1999-01-27 05:54:39 +00:00
|
|
|
result = dns_name_towire(owner_name, cctx, target);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-09-22 00:26:40 +00:00
|
|
|
goto rollback;
|
1999-04-30 07:08:55 +00:00
|
|
|
headlen = sizeof(dns_rdataclass_t) + sizeof(dns_rdatatype_t);
|
1999-07-03 20:52:50 +00:00
|
|
|
if (!question)
|
1999-04-30 07:08:55 +00:00
|
|
|
headlen += sizeof(dns_ttl_t)
|
|
|
|
+ 2; /* XXX 2 for rdata len */
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_availableregion(target, &r);
|
1999-04-30 07:08:55 +00:00
|
|
|
if (r.length < headlen) {
|
1999-09-22 00:26:40 +00:00
|
|
|
result = ISC_R_NOSPACE;
|
|
|
|
goto rollback;
|
1999-02-22 07:24:05 +00:00
|
|
|
}
|
1999-01-27 06:18:45 +00:00
|
|
|
isc_buffer_putuint16(target, rdataset->type);
|
1999-03-04 02:48:47 +00:00
|
|
|
isc_buffer_putuint16(target, rdataset->rdclass);
|
1999-07-03 20:52:50 +00:00
|
|
|
if (!question) {
|
1999-04-30 07:08:55 +00:00
|
|
|
isc_buffer_putuint32(target, rdataset->ttl);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save space for rdlen.
|
|
|
|
*/
|
|
|
|
rdlen = *target;
|
|
|
|
isc_buffer_add(target, 2);
|
|
|
|
|
|
|
|
/*
|
2000-05-08 14:38:29 +00:00
|
|
|
* Copy out the rdata
|
1999-04-30 07:08:55 +00:00
|
|
|
*/
|
2000-02-24 21:08:34 +00:00
|
|
|
if (shuffle)
|
2000-11-10 03:16:26 +00:00
|
|
|
rdata = *(sorted[i].rdata);
|
2000-10-25 04:26:57 +00:00
|
|
|
else {
|
|
|
|
dns_rdata_init(&rdata);
|
2000-02-24 21:08:34 +00:00
|
|
|
dns_rdataset_current(rdataset, &rdata);
|
2000-10-25 04:26:57 +00:00
|
|
|
}
|
1999-04-30 07:08:55 +00:00
|
|
|
result = dns_rdata_towire(&rdata, cctx, target);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-09-22 00:26:40 +00:00
|
|
|
goto rollback;
|
1999-10-17 22:40:05 +00:00
|
|
|
INSIST((target->used >= rdlen.used + 2) &&
|
|
|
|
(target->used - rdlen.used - 2 < 65536));
|
1999-04-30 07:08:55 +00:00
|
|
|
isc_buffer_putuint16(&rdlen,
|
1999-10-17 22:40:05 +00:00
|
|
|
(isc_uint16_t)(target->used -
|
|
|
|
rdlen.used - 2));
|
1999-02-22 07:24:05 +00:00
|
|
|
}
|
1999-01-27 05:54:39 +00:00
|
|
|
|
2000-02-24 21:08:34 +00:00
|
|
|
if (shuffle) {
|
|
|
|
i++;
|
|
|
|
if (i == count)
|
2000-04-06 22:03:35 +00:00
|
|
|
result = ISC_R_NOMORE;
|
2000-02-24 21:08:34 +00:00
|
|
|
else
|
|
|
|
result = ISC_R_SUCCESS;
|
2000-11-10 03:16:26 +00:00
|
|
|
} else {
|
2000-02-24 21:08:34 +00:00
|
|
|
result = dns_rdataset_next(rdataset);
|
2000-11-10 03:16:26 +00:00
|
|
|
}
|
2000-04-06 22:03:35 +00:00
|
|
|
} while (result == ISC_R_SUCCESS);
|
1999-01-27 05:54:39 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_NOMORE)
|
2000-02-24 21:08:34 +00:00
|
|
|
goto rollback;
|
1999-01-27 05:54:39 +00:00
|
|
|
|
1999-01-30 05:01:01 +00:00
|
|
|
*countp += count;
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-09-22 00:26:40 +00:00
|
|
|
|
|
|
|
rollback:
|
1999-10-17 22:40:05 +00:00
|
|
|
INSIST(savedbuffer.used < 65536);
|
|
|
|
dns_compress_rollback(cctx, (isc_uint16_t)savedbuffer.used);
|
1999-09-22 00:26:40 +00:00
|
|
|
*countp = 0;
|
|
|
|
*target = savedbuffer;
|
|
|
|
|
|
|
|
return (result);
|
1999-01-15 03:31:17 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2000-11-10 03:16:26 +00:00
|
|
|
isc_result_t
|
|
|
|
dns_rdataset_towire(dns_rdataset_t *rdataset,
|
|
|
|
dns_name_t *owner_name,
|
|
|
|
dns_compress_t *cctx,
|
|
|
|
isc_buffer_t *target,
|
|
|
|
unsigned int *countp)
|
|
|
|
{
|
|
|
|
return (dns_rdataset_towiresorted(rdataset, owner_name, cctx, target,
|
|
|
|
NULL, NULL, countp));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
dns_rdataset_additionaldata(dns_rdataset_t *rdataset,
|
|
|
|
dns_additionaldatafunc_t add, void *arg)
|
|
|
|
{
|
2000-12-11 23:09:47 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-08-02 22:18:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For each rdata in rdataset, call 'add' for each name and type in the
|
|
|
|
* rdata which is subject to additional section processing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
|
|
|
REQUIRE((rdataset->attributes & DNS_RDATASETATTR_QUESTION) == 0);
|
|
|
|
|
|
|
|
result = dns_rdataset_first(rdataset);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-08-02 22:18:31 +00:00
|
|
|
return (result);
|
|
|
|
|
|
|
|
do {
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_init(&rdata);
|
1999-08-02 22:18:31 +00:00
|
|
|
dns_rdataset_current(rdataset, &rdata);
|
|
|
|
result = dns_rdata_additionaldata(&rdata, add, arg);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS)
|
1999-08-02 22:18:31 +00:00
|
|
|
result = dns_rdataset_next(rdataset);
|
2000-04-06 22:03:35 +00:00
|
|
|
} while (result == ISC_R_SUCCESS);
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_NOMORE)
|
1999-08-02 22:18:31 +00:00
|
|
|
return (result);
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-08-02 22:18:31 +00:00
|
|
|
}
|
2000-10-11 17:44:18 +00:00
|
|
|
|