1999-02-22 07:24:05 +00:00
|
|
|
/*
|
2000-02-03 23:50:32 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
1999-02-22 07:24:05 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
/* $Id: compress.c,v 1.26 2000/04/27 00:01:21 tale Exp $ */
|
1999-02-22 07:24:05 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
1999-04-14 17:40:22 +00:00
|
|
|
#include <string.h>
|
1999-02-22 07:24:05 +00:00
|
|
|
|
|
|
|
#include <isc/types.h>
|
|
|
|
#include <isc/assertions.h>
|
|
|
|
#include <isc/buffer.h>
|
|
|
|
|
|
|
|
#include <dns/compress.h>
|
1999-04-14 06:03:15 +00:00
|
|
|
#include <dns/fixedname.h>
|
2000-04-12 21:25:10 +00:00
|
|
|
#include <dns/rbt.h>
|
1999-02-22 07:24:05 +00:00
|
|
|
|
1999-02-24 06:31:35 +00:00
|
|
|
#define CCTX_MAGIC 0x43435458U /* CCTX */
|
1999-02-22 07:24:05 +00:00
|
|
|
#define VALID_CCTX(x) ((x) != NULL && (x)->magic == CCTX_MAGIC)
|
|
|
|
|
1999-02-24 06:31:35 +00:00
|
|
|
#define DCTX_MAGIC 0x44435458U /* DCTX */
|
|
|
|
#define VALID_DCTX(x) ((x) != NULL && (x)->magic == DCTX_MAGIC)
|
|
|
|
|
1999-02-22 07:24:05 +00:00
|
|
|
static void free_offset(void *offset, void *mctx);
|
|
|
|
isc_boolean_t compress_find(dns_rbt_t *root, dns_name_t *name,
|
|
|
|
dns_name_t *prefix, dns_name_t *suffix,
|
|
|
|
isc_uint16_t *offset,
|
|
|
|
isc_buffer_t *workspace);
|
|
|
|
void compress_add(dns_rbt_t *root, dns_name_t *prefix,
|
|
|
|
dns_name_t *suffix, isc_uint16_t offset,
|
|
|
|
isc_boolean_t global16, isc_mem_t *mctx);
|
|
|
|
|
1999-02-24 06:31:35 +00:00
|
|
|
/***
|
|
|
|
*** Compression
|
|
|
|
***/
|
1999-02-22 07:24:05 +00:00
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
1999-02-22 07:24:05 +00:00
|
|
|
dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx)
|
|
|
|
{
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-02-22 07:24:05 +00:00
|
|
|
|
|
|
|
REQUIRE(cctx != NULL);
|
|
|
|
REQUIRE(mctx != NULL);
|
|
|
|
|
|
|
|
cctx->allowed = 0;
|
|
|
|
cctx->rdata = 0;
|
|
|
|
cctx->global16 = (edns >= 1) ? ISC_TRUE : ISC_FALSE;
|
|
|
|
cctx->edns = edns;
|
|
|
|
cctx->global = NULL;
|
|
|
|
result = dns_rbt_create(mctx, free_offset, mctx, &cctx->global);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-02-22 07:24:05 +00:00
|
|
|
return (result);
|
|
|
|
cctx->mctx = mctx;
|
|
|
|
cctx->magic = CCTX_MAGIC;
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-02-22 07:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_compress_invalidate(dns_compress_t *cctx) {
|
|
|
|
|
|
|
|
REQUIRE(VALID_CCTX(cctx));
|
|
|
|
|
|
|
|
cctx->magic = 0;
|
|
|
|
if (cctx->global != NULL)
|
|
|
|
dns_rbt_destroy(&cctx->global);
|
|
|
|
cctx->allowed = 0;
|
|
|
|
cctx->rdata = 0;
|
|
|
|
cctx->global16 = ISC_FALSE;
|
|
|
|
cctx->edns = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed) {
|
|
|
|
REQUIRE(VALID_CCTX(cctx));
|
|
|
|
|
|
|
|
if (cctx->edns >= 1 && (allowed & DNS_COMPRESS_GLOBAL14) != 0)
|
|
|
|
allowed |= DNS_COMPRESS_GLOBAL16;
|
|
|
|
cctx->allowed = allowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
dns_compress_getmethods(dns_compress_t *cctx) {
|
|
|
|
REQUIRE(VALID_CCTX(cctx));
|
|
|
|
return (cctx->allowed);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
dns_compress_getedns(dns_compress_t *cctx) {
|
|
|
|
REQUIRE(VALID_CCTX(cctx));
|
|
|
|
return (cctx->edns);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_boolean_t
|
|
|
|
dns_compress_findglobal(dns_compress_t *cctx, dns_name_t *name,
|
|
|
|
dns_name_t *prefix, dns_name_t *suffix,
|
|
|
|
isc_uint16_t *offset, isc_buffer_t *workspace)
|
|
|
|
{
|
|
|
|
REQUIRE(VALID_CCTX(cctx));
|
|
|
|
REQUIRE(dns_name_isabsolute(name) == ISC_TRUE);
|
|
|
|
REQUIRE(offset != NULL);
|
|
|
|
|
|
|
|
return (compress_find(cctx->global, name, prefix, suffix, offset,
|
|
|
|
workspace));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_compress_add(dns_compress_t *cctx, dns_name_t *prefix,
|
2000-03-23 05:18:46 +00:00
|
|
|
dns_name_t *suffix, isc_uint16_t offset)
|
1999-02-22 07:24:05 +00:00
|
|
|
{
|
|
|
|
REQUIRE(VALID_CCTX(cctx));
|
|
|
|
|
2000-03-23 05:18:46 +00:00
|
|
|
compress_add(cctx->global, prefix, suffix, offset,
|
|
|
|
cctx->global16, cctx->mctx);
|
1999-02-22 07:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-05-03 03:07:16 +00:00
|
|
|
dns_compress_rollback(dns_compress_t *cctx, isc_uint16_t offset) {
|
|
|
|
dns_rbtnode_t *node;
|
|
|
|
dns_fixedname_t foundfixed;
|
|
|
|
dns_fixedname_t fullfixed;
|
|
|
|
dns_fixedname_t originfixed;
|
|
|
|
dns_name_t *foundname;
|
|
|
|
dns_name_t *fullname;
|
|
|
|
dns_name_t *origin;
|
|
|
|
dns_rbtnodechain_t chain;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-05-03 03:07:16 +00:00
|
|
|
|
1999-02-22 07:24:05 +00:00
|
|
|
REQUIRE(VALID_CCTX(cctx));
|
|
|
|
|
1999-05-03 03:07:16 +00:00
|
|
|
/*
|
|
|
|
* Initalise things.
|
|
|
|
*/
|
|
|
|
dns_fixedname_init(&foundfixed);
|
|
|
|
foundname = dns_fixedname_name(&foundfixed);
|
|
|
|
dns_fixedname_init(&fullfixed);
|
|
|
|
fullname = dns_fixedname_name(&fullfixed);
|
|
|
|
dns_fixedname_init(&originfixed);
|
|
|
|
origin = dns_fixedname_name(&originfixed);
|
|
|
|
dns_rbtnodechain_init(&chain, cctx->mctx);
|
|
|
|
|
|
|
|
again:
|
|
|
|
result = dns_rbtnodechain_first(&chain, cctx->global, foundname,
|
|
|
|
origin);
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
while (result == DNS_R_NEWORIGIN || result == ISC_R_SUCCESS) {
|
1999-05-03 03:07:16 +00:00
|
|
|
result = dns_rbtnodechain_current(&chain, foundname,
|
|
|
|
origin, &node);
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-05-03 03:07:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (node->data != NULL &&
|
|
|
|
(*(isc_uint16_t*)node->data >= offset)) {
|
|
|
|
result = dns_name_concatenate(foundname,
|
|
|
|
dns_name_isabsolute(foundname) ?
|
|
|
|
NULL : origin,
|
|
|
|
fullname, NULL);
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-05-03 03:07:16 +00:00
|
|
|
break;
|
1999-02-23 02:25:41 +00:00
|
|
|
|
1999-05-03 03:07:16 +00:00
|
|
|
result = dns_rbt_deletename(cctx->global, fullname,
|
|
|
|
ISC_FALSE);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-05-03 03:07:16 +00:00
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* If the delete is successful the chain is broken.
|
|
|
|
*/
|
|
|
|
dns_rbtnodechain_reset(&chain);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = dns_rbtnodechain_next(&chain, foundname, origin);
|
|
|
|
}
|
|
|
|
dns_rbtnodechain_invalidate(&chain);
|
1999-02-22 07:24:05 +00:00
|
|
|
}
|
|
|
|
|
1999-02-24 06:31:35 +00:00
|
|
|
/***
|
|
|
|
*** Decompression
|
|
|
|
***/
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_decompress_init(dns_decompress_t *dctx, int edns, isc_boolean_t strict) {
|
|
|
|
|
|
|
|
REQUIRE(dctx != NULL);
|
|
|
|
REQUIRE(edns >= -1 && edns <= 255);
|
|
|
|
|
|
|
|
dctx->allowed = DNS_COMPRESS_NONE;
|
|
|
|
dctx->edns = edns;
|
|
|
|
dctx->strict = strict;
|
|
|
|
dctx->rdata = 0;
|
|
|
|
dctx->magic = DCTX_MAGIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_decompress_invalidate(dns_decompress_t *dctx) {
|
|
|
|
|
|
|
|
REQUIRE(VALID_DCTX(dctx));
|
|
|
|
|
|
|
|
dctx->magic = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_decompress_setmethods(dns_decompress_t *dctx, unsigned int allowed) {
|
|
|
|
|
|
|
|
REQUIRE(VALID_DCTX(dctx));
|
|
|
|
|
|
|
|
dctx->allowed = allowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
dns_decompress_getmethods(dns_decompress_t *dctx) {
|
|
|
|
|
|
|
|
REQUIRE(VALID_DCTX(dctx));
|
|
|
|
|
|
|
|
return (dctx->allowed);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
dns_decompress_edns(dns_decompress_t *dctx) {
|
|
|
|
|
|
|
|
REQUIRE(VALID_DCTX(dctx));
|
|
|
|
|
|
|
|
return (dctx->edns);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_boolean_t
|
|
|
|
dns_decompress_strict(dns_decompress_t *dctx) {
|
|
|
|
|
|
|
|
REQUIRE(VALID_DCTX(dctx));
|
|
|
|
|
|
|
|
return (dctx->strict);
|
|
|
|
}
|
|
|
|
|
1999-02-22 07:24:05 +00:00
|
|
|
/***
|
|
|
|
*** Private
|
|
|
|
***/
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_offset(void *offset, void *mctx) {
|
|
|
|
REQUIRE(offset != NULL);
|
|
|
|
REQUIRE(mctx != NULL);
|
|
|
|
isc_mem_put(mctx, offset, sizeof(isc_uint16_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the labels in prefix to RBT.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
compress_add(dns_rbt_t *root, dns_name_t *prefix, dns_name_t *suffix,
|
|
|
|
isc_uint16_t offset, isc_boolean_t global16, isc_mem_t *mctx)
|
|
|
|
{
|
|
|
|
|
|
|
|
dns_name_t name;
|
|
|
|
dns_name_t full;
|
|
|
|
dns_label_t label;
|
|
|
|
unsigned int count;
|
|
|
|
unsigned int start;
|
|
|
|
unsigned int limit;
|
|
|
|
isc_uint16_t *data;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-02-22 07:24:05 +00:00
|
|
|
unsigned char buffer[255];
|
|
|
|
isc_buffer_t target;
|
|
|
|
dns_offsets_t offsets;
|
|
|
|
|
|
|
|
count = dns_name_countlabels(prefix);
|
|
|
|
limit = dns_name_isabsolute(prefix) ? 1 : 0;
|
|
|
|
start = 0;
|
|
|
|
dns_name_init(&full, offsets);
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
while (count > limit) {
|
|
|
|
if (offset >= 16384 && !global16)
|
|
|
|
break;
|
|
|
|
dns_name_getlabelsequence(prefix, start, count, &name);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&target, buffer, sizeof(buffer));
|
1999-02-26 00:25:12 +00:00
|
|
|
result = dns_name_concatenate(&name, suffix, &full, &target);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-02-22 07:24:05 +00:00
|
|
|
return;
|
|
|
|
data = isc_mem_get(mctx, sizeof *data);
|
|
|
|
if (data == NULL)
|
|
|
|
return;
|
|
|
|
*data = offset;
|
|
|
|
result = dns_rbt_addname(root, &full, data);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-02-22 07:24:05 +00:00
|
|
|
isc_mem_put(mctx, data, sizeof *data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dns_name_getlabel(&name, 0, &label);
|
|
|
|
offset += label.length;
|
|
|
|
start++;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-02-02 00:38:28 +00:00
|
|
|
* Find the longest match of name in root.
|
1999-02-22 07:24:05 +00:00
|
|
|
* If match is found return ISC_TRUE. prefix, suffix and offset
|
|
|
|
* are updated.
|
|
|
|
* If no match is found return ISC_FALSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
isc_boolean_t
|
|
|
|
compress_find(dns_rbt_t *root, dns_name_t *name, dns_name_t *prefix,
|
|
|
|
dns_name_t *suffix, isc_uint16_t *offset,
|
|
|
|
isc_buffer_t *workspace)
|
|
|
|
{
|
1999-04-13 05:50:12 +00:00
|
|
|
dns_fixedname_t found;
|
|
|
|
dns_name_t *foundname;
|
1999-04-14 06:03:15 +00:00
|
|
|
dns_name_t tmpprefix;
|
|
|
|
dns_name_t tmpsuffix;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-04-14 06:03:15 +00:00
|
|
|
isc_uint16_t *data = NULL;
|
|
|
|
dns_label_t foundlabel;
|
|
|
|
dns_label_t namelabel;
|
|
|
|
unsigned int foundlabels;
|
|
|
|
unsigned int namelabels;
|
|
|
|
unsigned int foundbits;
|
|
|
|
unsigned int namebits;
|
|
|
|
unsigned int bits;
|
|
|
|
unsigned int prefixlen;
|
|
|
|
unsigned int j;
|
|
|
|
unsigned char buf[2 + 256/8]; /* size of biggest bit label */
|
1999-02-22 07:24:05 +00:00
|
|
|
dns_bitlabel_t bit;
|
1999-04-14 06:03:15 +00:00
|
|
|
isc_region_t region;
|
1999-02-22 07:24:05 +00:00
|
|
|
|
1999-04-13 05:50:12 +00:00
|
|
|
dns_fixedname_init(&found);
|
|
|
|
foundname = dns_fixedname_name(&found);
|
2000-04-19 18:27:24 +00:00
|
|
|
result = dns_rbt_findname(root, name, 0, foundname, (void *)&data);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS && result != DNS_R_PARTIALMATCH)
|
1999-04-14 06:03:15 +00:00
|
|
|
return (ISC_FALSE);
|
1999-04-13 05:50:12 +00:00
|
|
|
if (data == NULL) /* root label */
|
1999-04-14 06:03:15 +00:00
|
|
|
return (ISC_FALSE);
|
|
|
|
/*
|
|
|
|
* Do we have to do bit string processing?
|
|
|
|
*/
|
1999-04-28 03:03:56 +00:00
|
|
|
dns_name_getlabel(foundname, 0, &foundlabel);
|
1999-04-14 06:03:15 +00:00
|
|
|
foundlabels = dns_name_countlabels(foundname);
|
|
|
|
INSIST(foundlabels > 1); /* root labels are not added to tree */
|
|
|
|
namelabels = dns_name_countlabels(name);
|
|
|
|
if (dns_label_type(&foundlabel) == dns_labeltype_bitstring) {
|
|
|
|
dns_name_getlabel(name, namelabels - foundlabels, &namelabel);
|
|
|
|
INSIST(dns_label_type(&namelabel) == dns_labeltype_bitstring);
|
|
|
|
foundbits = dns_label_countbits(&foundlabel);
|
|
|
|
namebits = dns_label_countbits(&namelabel);
|
|
|
|
} else
|
|
|
|
namebits = foundbits = 0;
|
|
|
|
|
|
|
|
if (namebits == foundbits) {
|
|
|
|
INSIST(namelabels >= foundlabels);
|
|
|
|
prefixlen = namelabels - foundlabels;
|
|
|
|
if (prefixlen == 0) {
|
1999-04-13 05:50:12 +00:00
|
|
|
prefix->length = 0;
|
|
|
|
prefix->labels = 0;
|
1999-04-14 06:03:15 +00:00
|
|
|
} else
|
|
|
|
dns_name_getlabelsequence(name, 0, prefixlen, prefix);
|
1999-05-26 00:34:54 +00:00
|
|
|
result = dns_name_concatenate(NULL, foundname, suffix,
|
|
|
|
workspace);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-05-26 00:34:54 +00:00
|
|
|
return (ISC_FALSE);
|
1999-04-13 05:50:12 +00:00
|
|
|
*offset = *data;
|
|
|
|
return (ISC_TRUE);
|
|
|
|
}
|
1999-04-14 06:03:15 +00:00
|
|
|
/*
|
|
|
|
* 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).
|
|
|
|
*/
|
|
|
|
INSIST(result == DNS_R_PARTIALMATCH);
|
1999-05-26 00:34:54 +00:00
|
|
|
result = dns_name_concatenate(NULL, foundname, suffix, workspace);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-05-26 00:34:54 +00:00
|
|
|
return (ISC_FALSE);
|
1999-04-14 06:03:15 +00:00
|
|
|
prefixlen = namelabels - foundlabels;
|
1999-02-22 07:24:05 +00:00
|
|
|
dns_name_init(&tmpprefix, NULL);
|
1999-04-14 06:03:15 +00:00
|
|
|
dns_name_init(&tmpsuffix, NULL);
|
|
|
|
if (prefixlen != 0) {
|
|
|
|
dns_name_getlabelsequence(name, 0, prefixlen, &tmpprefix);
|
1999-02-22 07:24:05 +00:00
|
|
|
}
|
1999-04-14 06:03:15 +00:00
|
|
|
INSIST(namebits > foundbits);
|
|
|
|
bits = namebits - foundbits;
|
1999-02-22 07:24:05 +00:00
|
|
|
j = 0;
|
1999-04-14 06:03:15 +00:00
|
|
|
memset(buf, 0, sizeof buf);
|
|
|
|
INSIST((bits / 8 + 1) < sizeof buf);
|
|
|
|
/*
|
|
|
|
* Copy least significant bits.
|
|
|
|
*/
|
|
|
|
while (j < bits) {
|
|
|
|
bit = dns_label_getbit(&namelabel, foundbits + j);
|
1999-02-22 07:24:05 +00:00
|
|
|
if (bit)
|
|
|
|
buf[2 + j / 8] |= (1 << (7 - (j % 8)));
|
|
|
|
j++;
|
|
|
|
}
|
1999-04-14 06:03:15 +00:00
|
|
|
buf[0] = DNS_LABELTYPE_BITSTRING;
|
1999-02-22 07:24:05 +00:00
|
|
|
buf[1] = j;
|
|
|
|
region.base = buf;
|
1999-04-28 03:03:56 +00:00
|
|
|
region.length = 2 + (j + 7) / 8;
|
1999-02-22 07:24:05 +00:00
|
|
|
dns_name_fromregion(&tmpsuffix, ®ion);
|
1999-02-26 00:25:12 +00:00
|
|
|
result = dns_name_concatenate(&tmpprefix, &tmpsuffix, prefix,
|
|
|
|
workspace);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-02-22 07:24:05 +00:00
|
|
|
return (ISC_FALSE);
|
|
|
|
*offset = *data;
|
|
|
|
return (ISC_TRUE);
|
|
|
|
}
|