rdataset.c revision 364a82f7c25b62967678027043425201a5e5171a
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* 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.
*
* 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.
*/
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdataset.h>
#include <dns/compress.h>
void
/*
* Make 'rdataset' a valid, disassociated rdataset.
*/
rdataset->attributes = 0;
}
void
/*
* Invalidate 'rdataset'.
*/
rdataset->attributes = 0;
}
void
/*
* Disassociate 'rdataset' from its rdata, allowing it to be reused.
*/
rdataset->attributes = 0;
}
/*
* Is 'rdataset' associated?
*/
return (ISC_TRUE);
return (ISC_FALSE);
}
static void
(void)rdataset;
}
static isc_result_t
(void)rdataset;
return (ISC_R_NOMORE);
}
static void
/*
* This routine should never be called.
*/
(void)rdataset;
(void)rdata;
REQUIRE(0);
}
static void
}
static unsigned int
/*
* This routine should never be called.
*/
(void)rdataset;
REQUIRE(0);
return (0);
}
static dns_rdatasetmethods_t question_methods = {
};
void
{
/*
* Make 'rdataset' a valid, associated, question rdataset, with a
* question class of 'rdclass' and type 'type'.
*/
}
unsigned int
/*
* Return the number of records in 'rdataset'.
*/
}
void
/*
* Make 'target' refer to the same rdataset as 'source'.
*/
}
/*
* Move the rdata cursor to the first rdata in the rdataset (if any).
*/
}
/*
* Move the rdata cursor to the next rdata in the rdataset (if any).
*/
}
void
/*
* Make 'rdata' refer to the current rdata.
*/
}
#define MAX_SHUFFLE 32
unsigned int *countp)
{
isc_region_t r;
unsigned int headlen;
/*
* Convert 'rdataset' to wire format, compressing names as specified
* in cctx, and storing the result in 'target'.
*/
count = 0;
count = 1;
/*
* This is a negative caching rdataset.
*/
} else {
if (result == ISC_R_NOMORE)
return (ISC_R_SUCCESS);
if (result != ISC_R_SUCCESS)
return (result);
}
choice = 0;
/*
* We'll only shuffle if we've got enough slots in our
* deck.
*
* There's no point to shuffling SIGs.
*/
if (count <= MAX_SHUFFLE &&
/*
* First we get handles to all of the rdata.
*/
i = 0;
do {
i++;
} while (result == ISC_R_SUCCESS);
if (result != ISC_R_NOMORE)
return (result);
/*
* Now we shuffle.
*/
if (WANT_RANDOM(rdataset)) {
/*
* "Random" order.
*/
for (i = 0; i < count; i++) {
% tcount;
tcount--;
}
choice = 0;
} else {
/*
* "Cyclic" order.
*/
}
}
}
savedbuffer = *target;
i = choice;
tcount = 0;
do {
/*
* copy out the name, type, class, ttl.
*/
else
if (result != ISC_R_SUCCESS)
goto rollback;
if (!question)
+ 2; /* XXX 2 for rdata len */
goto rollback;
}
if (!question) {
/*
* Save space for rdlen.
*/
/*
* copy out the rdata
*/
if (shuffle)
else
if (result != ISC_R_SUCCESS)
goto rollback;
}
if (shuffle) {
i++;
/*
* Wrap around in case we're doing cyclic ordering.
*/
if (i == count)
i = 0;
tcount++;
else
} else
} while (result == ISC_R_SUCCESS);
if (result != ISC_R_NOMORE)
goto rollback;
return (ISC_R_SUCCESS);
*countp = 0;
*target = savedbuffer;
return (result);
}
{
/*
* For each rdata in rdataset, call 'add' for each name and type in the
* rdata which is subject to additional section processing.
*/
if (result != ISC_R_SUCCESS)
return (result);
do {
if (result == ISC_R_SUCCESS)
} while (result == ISC_R_SUCCESS);
if (result != ISC_R_NOMORE)
return (result);
return (ISC_R_SUCCESS);
}