compress.c revision b75ba761f4d8bfc145b5c9010c10da62c4af3a4c
/*
* 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.16 1999/05/10 00:38:52 marka Exp $ */
#include <config.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/compress.h>
#include <dns/fixedname.h>
/***
*** Compression
***/
{
if (result != DNS_R_SUCCESS)
return (result);
return (DNS_R_SUCCESS);
}
{
unsigned int labels;
unsigned int ll; /* logical label length w/o root label */
unsigned int wl; /* wire 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.
*/
return (DNS_R_SUCCESS);
ll = 0; /* logical label index 0 == TLD not root */
/*
* Work from the TLD label to the least signfiant label.
*/
/*
* If it is not a bit string label add to tree.
*/
return (DNS_R_SUCCESS);
if (result != DNS_R_SUCCESS) {
return (DNS_R_SUCCESS);
}
wl++;
ll++;
if (ll > 254)
return (DNS_R_SUCCESS);
continue;
}
/*
* Have to compute logical for bit string labels.
*/
/*
* It is easier to do this the reverse way.
* Adding 'bits' to 'll' may exceed the maximum logical
* offset index. Throw away bits until ll <= 254.
*/
/* clear bit */
bits--;
ll--;
}
/*
* Add entries to tree.
*/
do {
&t);
if (result != DNS_R_SUCCESS)
return (DNS_R_SUCCESS);
return (DNS_R_SUCCESS);
if (result != DNS_R_SUCCESS) {
return (DNS_R_SUCCESS);
}
/* clear bit */
bits--;
ll--;
} while (bits > 0);
wl++;
if (ll > 254)
return (DNS_R_SUCCESS);
}
return (DNS_R_SUCCESS);
}
void
}
void
}
void
}
unsigned int
}
int
}
{
workspace));
}
{
return (ISC_FALSE);
workspace));
}
void
{
}
}
void
/*
* Initalise things.
*/
origin);
if (result != DNS_R_SUCCESS)
break;
if (result != DNS_R_SUCCESS)
break;
if (result != DNS_R_SUCCESS)
break;
/*
* If the delete is successful the chain is broken.
*/
goto again;
}
}
}
/***
*** 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.
*/
{
unsigned int foundlabels;
unsigned int namelabels;
unsigned int foundbits;
unsigned int namebits;
unsigned int bits;
unsigned int prefixlen;
unsigned int j;
return (ISC_FALSE);
return (ISC_FALSE);
/*
* Do we have to do bit string processing?
*/
} else
if (prefixlen == 0) {
} else
return (ISC_TRUE);
}
/*
* At this stage we have a bit string label to split in two.
* There is potentially a prefix before this label and definitly
* a suffix after it (if only the root).
*/
if (prefixlen != 0) {
}
j = 0;
/*
* Copy least significant bits.
*/
while (j < bits) {
if (bit)
j++;
}
buf[0] = DNS_LABELTYPE_BITSTRING;
buf[1] = j;
if (result != DNS_R_SUCCESS)
return (ISC_FALSE);
return (ISC_TRUE);
}