compress.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2001, 2004-2007, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*! \file */
#define DNS_NAME_USEINLINE 1
#include <config.h>
#include <dns/compress.h>
#include <dns/fixedname.h>
#define TABLE_READY \
do { \
unsigned int i; \
\
for (i = 0; i < DNS_COMPRESS_TABLESIZE; i++) \
} \
} while (0)
/***
*** Compression
***/
return (ISC_R_SUCCESS);
}
void
unsigned int i;
for (i = 0; i < DNS_COMPRESS_TABLESIZE; i++) {
continue;
}
}
}
}
void
}
unsigned int
}
void
}
void
if (sensitive)
else
}
}
int
}
do { \
} while (0)
/*
* Find the longest match of name in the table.
* If match is found return ISC_TRUE. prefix, suffix and offset are updated.
* If no match is found return ISC_FALSE.
*/
{
return (ISC_FALSE);
return (ISC_FALSE);
for (n = 0; n < labels - 1; n++) {
{
break;
} else {
break;
}
}
break;
}
/*
* If node == NULL, we found no match at all.
*/
return (ISC_FALSE);
if (n == 0)
else
return (ISC_TRUE);
}
static inline unsigned int
isc_region_t r;
dns_name_toregion(name, &r);
return (r.length);
}
void
{
unsigned int start;
unsigned int n;
unsigned int count;
unsigned int hash;
unsigned int length;
unsigned int tlength;
unsigned char *tmp;
isc_region_t r;
return;
if (offset >= 0x4000)
return;
n = dns_name_countlabels(name);
if (dns_name_isabsolute(prefix))
count--;
if (count == 0)
return;
start = 0;
dns_name_toregion(name, &r);
return;
/*
* Copy name data to 'tmp' and make 'r' use 'tmp'.
*/
dns_name_fromregion(&xname, &r);
while (count > 0) {
if (toffset >= 0x4000)
break;
/*
* Create a new node and add it.
*/
else {
sizeof(dns_compressnode_t));
break;
}
/*
* 'node->r.base' becomes 'tmp' when start == 0.
* Record this by setting 0x8000 so it can be freed later.
*/
if (start == 0)
toffset |= 0x8000;
start++;
n--;
count--;
}
if (start == 0)
}
void
unsigned int i;
return;
return;
for (i = 0; i < DNS_COMPRESS_TABLESIZE; i++) {
/*
* This relies on nodes with greater offsets being
* closer to the beginning of the list, and the
* items with the greatest offsets being at the end
* of the initialnodes[] array.
*/
}
}
}
/***
*** Decompression
***/
void
}
void
}
void
case DNS_DECOMPRESS_ANY:
break;
case DNS_DECOMPRESS_NONE:
break;
case DNS_DECOMPRESS_STRICT:
break;
}
}
unsigned int
}
int
}
}