rdataslab.c revision da41917c3f882b6e12c7101b653926830a396b81
/*
* 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.
*/
/* $Id: rdataslab.c,v 1.19 2000/09/01 19:59:35 gson Exp $ */
#include <config.h>
#include <stdlib.h>
#include <dns/rdataset.h>
#include <dns/rdataslab.h>
/* Note: the "const void *" are just to make qsort happy. */
static int
int n;
if (n != 0)
return (n);
}
{
unsigned char *rawbuf;
unsigned int buflen;
unsigned int nitems;
unsigned int nalloc;
unsigned int i;
return (ISC_R_NOMEMORY);
/*
* Save all of the rdata members into an array.
*/
for (i = 0; i < nalloc; i++) {
}
/*
* Remove duplicates.
*/
for (i = 1; i < nalloc; i++) {
nitems--;
}
}
/*
* Run through the rdataset list once, counting up the size
* of all the rdata members within it. We do not store the
* class, type, etc, just the rdata, so our overhead is 2 bytes
* for the number of records, and 2 for each rdata length, and
* then the rdata itself.
*/
for (i = 0; i < nalloc; i++) {
}
if (result != ISC_R_NOMORE) {
return (result);
}
/*
* Allocate the memory, set up a buffer, start copying in
* data.
*/
goto free_rdatas;
}
rawbuf += reservelen;
for (i = 0; i < nalloc; i++) {
continue;
}
return (result);
}
unsigned int
unsigned char *current;
while (count > 0) {
count--;
}
}
/*
* Make the dns_rdata_t 'rdata' refer to the slab item
* beginning at '*current', which is part of a slab of type
* 'type' and class 'rdclass', and advance '*current' to
* point to the next item in the slab.
*/
static inline void
rdata_from_slab(unsigned char **current,
{
}
/*
* Return true iff 'slab' (slab data of type 'type' and class 'rdclass')
* contains an rdata identical to 'rdata'. This does case insensitive
* comparisons per DNSSEC.
*/
static inline isc_boolean_t
{
unsigned int count, i;
unsigned char *current;
for (i = 0; i < count; i++) {
return (ISC_TRUE);
}
return (ISC_FALSE);
}
{
unsigned int oadded = 0;
unsigned int nadded = 0;
unsigned int nncount = 0;
/*
* XXX Need parameter to allow "delete rdatasets in nslab" merge,
* or perhaps another merge routine for this purpose.
*/
/*
* Yes, this is inefficient!
*/
/*
* Figure out the length of the old slab's data.
*/
olength = 0;
}
/*
* Start figuring out the target length and count.
*/
/*
* Add in the length of rdata in the new slab that aren't in
* the old slab.
*/
do {
{
/*
* This rdata isn't in the old slab.
*/
tcount++;
nncount++;
}
ncount--;
} while (ncount > 0);
if (!added_something && !force)
return (DNS_R_UNCHANGED);
/*
* Copy the reserved area from the new slab.
*/
return (ISC_R_NOMEMORY);
/*
* Write the new count.
*/
/*
* Merge the two slabs.
*/
if (ncount > 0) {
do {
}
else
if (fromold) {
oadded++;
&ordata);
}
} else {
nadded++;
do {
&nrdata));
}
}
}
return (ISC_R_SUCCESS);
}
unsigned char **tslabp)
{
/*
* Yes, this is inefficient!
*/
/*
* Start figuring out the target length and count.
*/
tcount = 0;
/*
* Add in the length of rdata in the mslab that aren't in
* the sslab.
*/
do {
unsigned char *mrdatabegin = mcurrent;
break;
}
/*
* This rdata isn't in the sslab, and thus isn't
* being subtracted.
*/
tcount++;
} else
mcount--;
} while (mcount > 0);
/*
* Don't continue if the new rdataslab would be empty.
*/
if (tcount == 0)
return (DNS_R_NXRRSET);
/*
* If nothing is going to change, we can stop.
*/
if (!removed_something)
return (DNS_R_UNCHANGED);
/*
* Copy the reserved area from the mslab.
*/
return (ISC_R_NOMEMORY);
/*
* Write the new count.
*/
/*
* Copy the parts of mslab not in sslab.
*/
do {
unsigned char *mrdatabegin = mcurrent;
break;
}
/*
* This rdata isn't in the sslab, and thus should be
* copied to the tslab.
*/
}
mcount--;
} while (mcount > 0);
return (ISC_R_SUCCESS);
}
unsigned int reservelen)
{
return (ISC_FALSE);
while (count1 > 0) {
return (ISC_FALSE);
count1--;
}
return (ISC_TRUE);
}