compress.c revision 587fc7b519b0fed4e3dd234527edba1ca9334757
/*
* Copyright (C) 1999 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: compress.c,v 1.5 1999/03/04 21:03:29 tale Exp $ */
#include <config.h>
#include <isc/assertions.h>
#include <dns/compress.h>
/***
*** Compression
***/
{
if (result != DNS_R_SUCCESS)
return (result);
return (DNS_R_SUCCESS);
}
{
unsigned int labels;
unsigned int bits;
unsigned char buf[34];
unsigned char namebuf[255];
isc_buffer_t t;
if (result != DNS_R_SUCCESS)
return (result);
/*
* Errors from here on are not passed back up.
*/
ll = 0;
wl = 0;
/*
* XXX we should be adding all the logical label in a
* bit stream as well.
* See also compress_add().
*/
while (labels > 0) {
return (DNS_R_SUCCESS);
if (result != DNS_R_SUCCESS) {
return (DNS_R_SUCCESS);
}
labels --;
wl++;
ll++;
if (ll > 255)
return (DNS_R_SUCCESS);
continue;
if (bits == 1)
continue;
do {
/* clear bit */
bits--;
&t);
if (result != DNS_R_SUCCESS)
return (DNS_R_SUCCESS);
return (DNS_R_SUCCESS);
if (result != DNS_R_SUCCESS) {
return (DNS_R_SUCCESS);
}
ll++;
if (ll > 255)
return (DNS_R_SUCCESS);
} while (bits > 1);
}
return (DNS_R_SUCCESS);
}
void
}
void
}
void
}
unsigned int
}
int
}
{
workspace));
}
{
return (ISC_FALSE);
workspace));
}
void
{
}
}
void
/* XXX need tree walking code */
/* Remove all nodes in cctx->global that have *data >= offset. */
}
/***
*** Decompression
***/
void
}
void
{
}
void
}
void
}
void
}
unsigned int
}
int
}
}
/***
*** Private
***/
static void
}
/*
* Add the labels in prefix to RBT.
*/
void
{
unsigned int count;
unsigned int start;
unsigned int limit;
unsigned char buffer[255];
start = 0;
break;
if (result != DNS_R_SUCCESS)
return;
return;
if (result != DNS_R_SUCCESS) {
return;
}
start++;
count--;
}
}
/*
* Find the loggest match of name in root.
* If match is found return ISC_TRUE. prefix, suffix and offset
* are updated.
* If no match is found return ISC_FALSE.
* XXX should used dns_rbt_findlongestmatch() when written.
*/
{
unsigned int count;
unsigned int labels;
unsigned int start;
unsigned int bits;
unsigned char buf[255];
unsigned int i, j;
start = 0;
bits = 0;
/* Don't look for the root label (count == 1). */
while (count > 1) {
/* XXX @@@ is this right, Mark?
note that for data to be non-null, then result can
be DNS_R_SUCCESS or DNS_R_PARTIALMATCH */
break;
count--;
start++;
continue;
continue;
if (bits == 1) {
bits = 0;
continue;
}
do {
/* clear lsb */
bits--;
if (result != DNS_R_SUCCESS)
continue;
/* XXX @@@ is this right, Mark? */
break;
if (bits == 1)
bits = 0;
} while (bits > 1);
break;
}
return (ISC_FALSE);
if (bits == 0) {
if (start != 0)
else {
}
return (ISC_TRUE);
}
i = dns_label_countbits(&label);
j = 0;
while (bits < i) {
bits++;
if (bit)
else
j++;
}
buf[1] = j;
while ((j % 8) != 0) {
j++;
}
if (start == 1)
else
if (result != DNS_R_SUCCESS)
return (ISC_FALSE);
return (ISC_TRUE);
}