Add wire compression.

This commit is contained in:
Mark Andrews 1999-02-22 07:24:05 +00:00
parent 2429685db2
commit 52637f592f
64 changed files with 1213 additions and 90 deletions

View file

@ -75,6 +75,7 @@ dump_packet(unsigned char *buf, u_int len)
dns_message_t message;
dns_result_t result;
isc_buffer_t source, target;
unsigned int i;
rdcount = 0;
rlcount = 0;
@ -83,6 +84,17 @@ dump_packet(unsigned char *buf, u_int len)
dctx.allowed = DNS_COMPRESS_GLOBAL14;
dns_name_init(&dctx.owner_name, NULL);
for (i = 0 ; i < len ; /* */ ) {
fprintf(stdout, "%02x", buf[i]);
if ((++i % 20) == 0)
fputs("\n", stdout);
else
if (i == len)
fputs("\n", stdout);
else
fputs(" ", stdout);
}
isc_buffer_init(&source, buf, len, ISC_BUFFERTYPE_BINARY);
isc_buffer_add(&source, len);
isc_buffer_init(&target, t, sizeof(t), ISC_BUFFERTYPE_BINARY);
@ -144,8 +156,9 @@ resolve_packet(dns_db_t *db, isc_buffer_t *source, isc_buffer_t *target)
dctx.allowed = DNS_COMPRESS_GLOBAL14;
dns_name_init(&dctx.owner_name, NULL);
cctx.allowed = DNS_COMPRESS_GLOBAL14;
dns_name_init(&cctx.owner_name, NULL);
result = dns_compress_init(&cctx, -1, db->mctx);
if (result != DNS_R_SUCCESS)
return (result);
/*
* Expand the name requested into buffer (tbuf)
@ -244,6 +257,7 @@ resolve_packet(dns_db_t *db, isc_buffer_t *source, isc_buffer_t *target)
target->used = oldused;
}
}
dns_compress_invalidate(&cctx);
return (DNS_R_SUCCESS);
}

View file

@ -98,8 +98,8 @@ main(int argc, char *argv[]) {
}
}
memset(&cctx, '0', sizeof cctx);
memset(&dctx, '0', sizeof dctx);
dctx.allowed = DNS_COMPRESS_ALL;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
@ -187,6 +187,7 @@ main(int argc, char *argv[]) {
dns_rdata_init(&rdata);
isc_buffer_init(&dbuf, inbuf, sizeof(inbuf),
ISC_BUFFERTYPE_BINARY);
RUNTIME_CHECK(dns_compress_init(&cctx, -1, mctx) == DNS_R_SUCCESS);
result = dns_rdata_fromtext(&rdata, class, type, lex,
NULL, ISC_FALSE, &dbuf, NULL);
if (result != DNS_R_SUCCESS) {
@ -194,6 +195,7 @@ main(int argc, char *argv[]) {
"dns_rdata_fromtext returned %s(%d)\n",
dns_result_totext(result), result);
fflush(stdout);
dns_compress_invalidate(&cctx);
continue;
}
if (raw) {
@ -219,6 +221,7 @@ main(int argc, char *argv[]) {
fprintf(stdout,
"dns_rdata_towire returned %s(%d)\n",
dns_result_totext(result), result);
dns_compress_invalidate(&cctx);
continue;
}
len = wbuf.used - wbuf.current;
@ -257,6 +260,7 @@ main(int argc, char *argv[]) {
"dns_rdata_fromwire returned %s(%d)\n",
dns_result_totext(result), result);
fflush(stdout);
dns_compress_invalidate(&cctx);
continue;
}
}
@ -285,6 +289,7 @@ main(int argc, char *argv[]) {
fprintf(stdout, "\"%.*s\"\n",
(int)tbuf.used, (char*)tbuf.base);
fflush(stdout);
dns_compress_invalidate(&cctx);
if (lasttype == type) {
fprintf(stdout, "dns_rdata_compare = %d\n",
dns_rdata_compare(&rdata, &last));

View file

@ -5,7 +5,7 @@ Overview.
BIND 4.x and BIND 8.x only had one methods of compression to deal
with 14 bit compression. BIND 9 has 3 methods of compression
to deal with 14 bit, 16 bit and local compression.
to deal with 14 bit, 16 bit and local compression (14 and 16 bit).
In addition to this the allowed compression methods vary across
types and across client revisions thanks to EDNS.
@ -59,20 +59,17 @@ Implementation:
We only need to maintain one global RBT as 16 bit compression
pointers are either valid or invalid for the whole message.
Functions:
unsigned int
dns_compress_allowed(dns_rdatatype_t type, int edns,
isc_boolean_t isowner);
dns_rdata_towire() will set the allowed methods based on the
edns version.
Returns allowed compression methods based on type, edns, and whether
we are about to compress a owner name.
Functions:
dns_result_t
dns_compress_init(dns_compress_t *cctx, isc_boolean_t global16,
isc_mem_t *mctx);
dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx);
Initalises cctx to empty and sets whether 16 bit global
compression targets are to be added to the global RBT.
compression targets are to be added to the global RBT based on the
edns value.
dns_result_t
dns_compress_localinit(dns_compress_t *cctx, dns_name_t *owner,
@ -85,12 +82,19 @@ Functions:
Free any RBT's and make empty.
dns_compress_localinvalidate(dns_compress_t *cctx);
Free the local RBT.
void
dns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed);
unsigned int
dns_compress_getmethods(dns_compress_t *cctx);
int
dns_compress_getedns(dns_compress_t *cctx);
dns_result_t
dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
isc_buffer_t *target);
@ -109,6 +113,33 @@ Functions:
isc_mem_t *mctx; /* Required by RBT */
};
sets allowed based on the value of 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);
isc_boolean_t
dns_compress_findlocal(dns_compress_t *cctx, dns_name_t *name,
dns_name_t *prefix, dns_name_t *suffix,
isc_uint16_t *offset, isc_buffer_t *workspace);
Find the best best match in the global / local RBT. Returns prefix,
suffix and offset of the bestmatch. Findglobal(), findlocal()
requires as workspace as it may be neccessary to spit a bit stream
label. The result prefix will be such that it can be added to the
wire format followed by a compression pointer pointing to offset.
Suffix is returned so that it is possible to add the compression
pointers via dns_compress_add().
void
dns_compress_add(dns_compress_t *cctx, dns_name_t *prefix,
dns_name_t *suffix, isc_uint16_t offset);
Add compression pointers pointing to lebels (if any) in prefix.
The offset to the first label is passed in offset.
Dependancy:
Requires RBT deepest match.

View file

@ -265,6 +265,16 @@ towire_<I>typename</I>(dns_rdata_t *rdata, dns_compress_t *cctx,
towire_<I>classname_typename</I>(dns_rdata_t *rdata, dns_compress_t *cctx,
isc_buffer_t *target);<CODE>
</PRE>
<P>
<CODE>towire_<I>classname_typename</I>()</CODE> is required to set the
allowed name compression methods based on EDNS version if there is a
domain name in the rdata.
<PRE>
<CODE>if (dns_compress_getedns(cctx) >= #)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_LOCAL);</CODE>
</PRE>
<DL>
<DT><CODE>rdata</CODE></DT>
<DD>

439
lib/dns/compress.c Normal file
View file

@ -0,0 +1,439 @@
/*
* 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.1 1999/02/22 07:23:54 marka Exp $ */
#include <config.h>
#include <isc/types.h>
#include <isc/assertions.h>
#include <isc/buffer.h>
#include <dns/compress.h>
#define CCTX_MAGIC 0x43435458U
#define VALID_CCTX(x) ((x) != NULL && (x)->magic == CCTX_MAGIC)
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);
dns_result_t
dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx)
{
dns_result_t result;
REQUIRE(cctx != NULL);
REQUIRE(mctx != NULL);
cctx->allowed = 0;
cctx->rdata = 0;
cctx->global16 = (edns >= 1) ? ISC_TRUE : ISC_FALSE;
cctx->edns = edns;
cctx->local = NULL;
cctx->global = NULL;
result = dns_rbt_create(mctx, free_offset, mctx, &cctx->global);
if (result != DNS_R_SUCCESS)
return (result);
cctx->mctx = mctx;
cctx->magic = CCTX_MAGIC;
return (DNS_R_SUCCESS);
}
dns_result_t
dns_compress_localinit(dns_compress_t *cctx, dns_name_t *owner,
isc_buffer_t *target)
{
dns_result_t result;
unsigned int labels;
unsigned int ll, wl;
unsigned int bits;
dns_name_t name;
dns_name_t prefix;
dns_name_t suffix;
dns_label_t label;
isc_uint16_t *data;
unsigned char buf[34];
unsigned char namebuf[255];
isc_buffer_t t;
isc_region_t region;
REQUIRE(VALID_CCTX(cctx));
REQUIRE(cctx->local == NULL);
REQUIRE(dns_name_isabsolute(owner) == ISC_TRUE);
REQUIRE(target != NULL);
result = dns_rbt_create(cctx->mctx, free_offset, cctx->mctx,
&cctx->local);
if (result != DNS_R_SUCCESS)
return (result);
/*
* Errors from here on are not passed back up.
*/
cctx->rdata = target->used; /* XXX layer violation */
labels = dns_name_countlabels(owner);
ll = 0;
wl = 0;
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_name_init(&suffix, NULL);
/*
* XXX we should be adding all the logical label in a
* bit stream as well.
* See also compress_add().
*/
while (labels > 0) {
dns_name_getlabelsequence(owner, wl, labels, &name);
data = isc_mem_get(cctx->mctx, sizeof *data);
if (data != NULL)
return (DNS_R_SUCCESS);
*data = ll;
result = dns_rbt_addname(cctx->local, &name, data);
if (result != DNS_R_SUCCESS) {
isc_mem_put(cctx->mctx, data, sizeof *data);
return (DNS_R_SUCCESS);
}
labels --;
wl++;
ll++;
if (ll > 255)
return (DNS_R_SUCCESS);
dns_name_getlabel(&name, 0, &label);
if (dns_label_type(&label) != dns_labeltype_bitstring)
continue;
bits = dns_label_countbits(&label);
if (bits == 1)
continue;
INSIST(label.length < sizeof buf);
memcpy(buf, label.base, label.length);
region.base = buf;
dns_name_getlabelsequence(owner, wl, labels, &suffix);
do {
/* clear bit */
buf[2 + bits / 8] &= ~(1 << (7 - (bits % 8)));
bits--;
region.length = 2 + (bits + 7) / 8;
buf[1] = bits;
dns_name_fromregion(&prefix, &region);
isc_buffer_init(&t, namebuf, sizeof namebuf,
ISC_BUFFERTYPE_BINARY);
result = dns_name_cat(&prefix, &suffix, &name, &t);
if (result != DNS_R_SUCCESS)
return (DNS_R_SUCCESS);
data = isc_mem_get(cctx->mctx, sizeof *data);
if (data != NULL)
return (DNS_R_SUCCESS);
*data = ll;
result = dns_rbt_addname(cctx->local, &name, data);
if (result != DNS_R_SUCCESS) {
isc_mem_put(cctx->mctx, data, sizeof *data);
return (DNS_R_SUCCESS);
}
ll++;
if (ll > 255)
return (DNS_R_SUCCESS);
} while (bits > 1);
}
return (DNS_R_SUCCESS);
}
void
dns_compress_invalidate(dns_compress_t *cctx) {
REQUIRE(VALID_CCTX(cctx));
cctx->magic = 0;
if (cctx->global != NULL)
dns_rbt_destroy(&cctx->global);
if (cctx->local != NULL)
dns_rbt_destroy(&cctx->local);
cctx->allowed = 0;
cctx->rdata = 0;
cctx->global16 = ISC_FALSE;
cctx->edns = -1;
}
void
dns_compress_localinvalidate(dns_compress_t *cctx) {
REQUIRE(VALID_CCTX(cctx));
if (cctx->local != NULL)
dns_rbt_destroy(&cctx->local);
}
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));
}
isc_boolean_t
dns_compress_findlocal(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);
if (cctx->local == NULL)
return (ISC_FALSE);
return (compress_find(cctx->local, name, prefix, suffix, offset,
workspace));
}
void
dns_compress_add(dns_compress_t *cctx, dns_name_t *prefix,
dns_name_t *suffix, isc_uint16_t offset)
{
isc_uint16_t local;
REQUIRE(VALID_CCTX(cctx));
if (cctx->local != NULL && (cctx->allowed & DNS_COMPRESS_LOCAL) != 0) {
REQUIRE(cctx->rdata <= offset);
local = offset - cctx->rdata + 256;
compress_add(cctx->local, prefix, suffix, local, ISC_TRUE,
cctx->mctx);
}
compress_add(cctx->global, prefix, suffix, offset, cctx->global16,
cctx->mctx);
}
void
dns_compress_backout(dns_compress_t *cctx, isc_uint16_t offset) {
REQUIRE(VALID_CCTX(cctx));
/* XXX need tree walking code */
}
/***
*** 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;
dns_result_t result;
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);
isc_buffer_init(&target, buffer, sizeof buffer,
ISC_BUFFERTYPE_BINARY);
result = dns_name_cat(&name, suffix, &full, &target);
if (result != DNS_R_SUCCESS)
return;
data = isc_mem_get(mctx, sizeof *data);
if (data == NULL)
return;
*data = offset;
result = dns_rbt_addname(root, &full, data);
if (result != DNS_R_SUCCESS) {
isc_mem_put(mctx, data, sizeof *data);
return;
}
dns_name_getlabel(&name, 0, &label);
offset += label.length;
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.
*/
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)
{
unsigned int count;
unsigned int labels;
unsigned int start;
unsigned int bits;
isc_uint16_t *data;
dns_name_t tmpname;
dns_name_t tmpprefix;
dns_name_t tmpsuffix;
isc_region_t region;
unsigned char buf[255];
dns_label_t label;
unsigned int i, j;
dns_result_t result;
dns_bitlabel_t bit;
labels = count = dns_name_countlabels(name);
start = 0;
data = NULL;
bits = 0;
dns_name_init(&tmpname, NULL);
dns_name_init(&tmpsuffix, NULL);
dns_name_init(&tmpprefix, NULL);
/* Don't look for the root label (count == 1). */
while (count > 1) {
dns_name_getlabelsequence(name, start, count, &tmpname);
data = dns_rbt_findname(root, &tmpname);
if (data != NULL)
break;
count--;
start++;
if (workspace == NULL)
continue;
dns_name_getlabel(&tmpname, 0, &label);
if (dns_label_type(&label) != dns_labeltype_bitstring)
continue;
bits = dns_label_countbits(&label);
if (bits == 1) {
bits = 0;
continue;
}
INSIST(label.length < sizeof buf);
memcpy(buf, label.base, label.length);
region.base = buf;
dns_name_getlabelsequence(name, start, count, &tmpsuffix);
do {
/* clear lsb */
buf[2 + bits / 8] &= ~(1 << (7 - (bits % 8)));
bits--;
region.length = 2 + (bits + 7) / 8;
buf[1] = bits;
dns_name_fromregion(&tmpprefix, &region);
isc_buffer_clear(workspace);
result = dns_name_cat(&tmpprefix, &tmpsuffix,
&tmpname, workspace);
if (result != DNS_R_SUCCESS)
continue;
data = dns_rbt_findname(root, &tmpname);
if (data != NULL)
break;
if (bits == 1)
bits = 0;
} while (bits > 1);
if (data != NULL)
break;
}
if (data == NULL)
return (ISC_FALSE);
if (bits == 0) {
if (start != 0)
dns_name_getlabelsequence(name, 0, start, prefix);
dns_name_getlabelsequence(name, start, count, suffix);
*offset = *data;
return (ISC_TRUE);
}
*suffix = tmpname;
i = dns_label_countbits(&label);
j = 0;
while (bits < i) {
bit = dns_label_getbit(&label, bits);
bits++;
if (bit)
buf[2 + j / 8] |= (1 << (7 - (j % 8)));
else
buf[2 + j / 8] &= ~(1 << (7 - (j % 8)));
j++;
}
buf[1] = j;
while ((j % 8) != 0) {
buf[2 + j / 8] &= ~(1 << (7 - (j % 8)));
j++;
}
region.base = buf;
region.length = 2 + j / 8;
dns_name_fromregion(&tmpsuffix, &region);
if (start == 1)
tmpprefix = *dns_rootname;
else
dns_name_getlabelsequence(name, 0, start - 1, &tmpprefix);
result = dns_name_cat(&tmpprefix, &tmpsuffix, &tmpname, workspace);
if (result != DNS_R_SUCCESS)
return (ISC_FALSE);
dns_name_getlabelsequence(&tmpname, 0, start, prefix);
*offset = *data;
return (ISC_TRUE);
}

View file

@ -21,10 +21,14 @@
#include <isc/mem.h>
#include <dns/types.h>
#include <dns/rbt.h>
#define DNS_COMPRESS_NONE 0x00 /* no compression */
#define DNS_COMPRESS_GLOBAL14 0x01 /* "normal" compression. */
#define DNS_COMPRESS_GLOBAL16 0x02 /* 16-bit global comp. */
#define DNS_COMPRESS_LOCAL 0x04 /* Local compression. */
#define DNS_COMPRESS_GLOBAL 0x03 /* all global comp. */
#define DNS_COMPRESS_LOCAL 0x04 /* local compression. */
#define DNS_COMPRESS_ALL 0x07 /* all compression. */
/*
* XXX An API for manipulating these structures will be forthcoming.
@ -33,9 +37,14 @@
*/
struct dns_compress {
unsigned int allowed; /* Allowed methods. */
dns_name_t owner_name; /* For local compression. */
/* XXX compression table here */
unsigned int magic; /* Magic number. */
unsigned int allowed; /* Allowed methods. */
unsigned int rdata; /* Start of local rdata. */
isc_boolean_t global16; /* 16 bit offsets allowed. */
int edns; /* Edns version or -1. */
dns_rbt_t *local; /* Local RBT. */
dns_rbt_t *global; /* Global RBT. */
isc_mem_t *mctx; /* Memeory context. */
};
struct dns_decompress {
@ -43,4 +52,172 @@ struct dns_decompress {
dns_name_t owner_name; /* For local compression. */
};
dns_result_t dns_compress_init(dns_compress_t *cctx, int edns,
isc_mem_t *mctx);
/*
* Inialise the compression context structure pointed to by 'cctx'.
*
* Requires:
* 'cctx' is a valid dns_compress_t structure.
* 'mctx' is a initalised memory context.
* Ensures:
* cctx->global is initalised.
*
* Returns:
* DNS_R_SUCCESS
* failures from dns_rbt_create()
*/
dns_result_t
dns_compress_localinit(dns_compress_t *cctx, dns_name_t *owner,
isc_buffer_t *target);
/*
* Initalise 'cctx->local'.
* All compression pointers pointing to logical labels in owner.
* Record start of rdata 'target->used'.
*
* Ensures:
* 'cctx->local' is valid.
*
* Requires:
* 'cctx' initaliased
* 'cctx->local' be NULL
* 'owner' is a absolute name
* 'target' is a valid buffer
*
* Returns:
* DNS_R_SUCCESS
* failures from dns_rbt_create()
*/
void
dns_compress_invalidate(dns_compress_t *cctx);
/*
* Invalidate the compression structure pointed to by cctx.
* Destroys 'cctx->glocal' and 'cctx->local' RBT.
*
* Requires:
* 'cctx' to be initalised.
*/
void
dns_compress_localinvalidate(dns_compress_t *cctx);
/*
* Destroys 'cctx->local'.
*
* Requires:
* 'cctx' to be initalised.
*/
void
dns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed);
/*
* Sets allowed compression methods.
*
* Requires:
* 'cctx' to be initalised.
*/
unsigned int
dns_compress_getmethods(dns_compress_t *cctx);
/*
* Gets allowed compression methods.
*
* Requires:
* 'cctx' to be initalised.
*
* Returns:
* allowed compression bitmap.
*/
int
dns_compress_getedns(dns_compress_t *cctx);
/*
* Gets edns value.
*
* Requires:
* 'cctx' to be initalised.
*
* Returns:
* -1 .. 255
*/
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);
/*
* Finds longest possible match of 'name' in the global compression
* RBT. Workspace needs to be large enough to hold 'name' when split
* in two (length->name + 3).
*
* Requires:
* 'cctx' to be initalised.
* 'name' to be a absolute name.
* 'prefix' to be initalised.
* 'suffix' to be initalised.
* 'offset' to point it a isc_uint16_t.
* 'workspace' to be initalised.
*
* Ensures:
* 'prefix', 'suffix' and 'offset' are valid is ISC_TRUE is
* returned.
*
* Returns:
* ISC_TRUE / ISC_FALSE
*/
isc_boolean_t
dns_compress_findlocal(dns_compress_t *cctx, dns_name_t *name,
dns_name_t *prefix, dns_name_t *suffix,
isc_uint16_t *offset, isc_buffer_t *workspace);
/*
* Finds longest possible match of 'name' in the local compression
* RBT. Workspace needs to be large enough to hold 'name' when split
* in two (length->name + 3).
*
* Requires:
* 'cctx' to be initalised.
* 'name' to be a absolute name.
* 'prefix' to be initalised.
* 'suffix' to be initalised.
* 'offset' to point it a isc_uint16_t.
* 'workspace' to be initalised.
*
* Ensures:
* 'prefix', 'suffix' and 'offset' are valid is ISC_TRUE is
* returned.
*
* Returns:
* ISC_TRUE / ISC_FALSE
*/
void
dns_compress_add(dns_compress_t *cctx, dns_name_t *prefix,
dns_name_t *suffix, isc_uint16_t offset);
/*
* Add compression pointers for labels in prefix to RBT's.
*
* Requires:
* 'cctx' initalised
* 'prefix' to be initalised
*/
void
dns_compress_backout(dns_compress_t *cctx, isc_uint16_t offset);
/*
* Remove any compression pointers from global RBT >= offset.
*
* Requires:
* 'cctx' is initalised.
*/
#endif /* DNS_COMPRESS_H */

View file

@ -663,4 +663,13 @@ dns_result_t dns_name_totext(dns_name_t *name,
* DNS_R_NOSPACE
*/
dns_result_t dns_name_cat(dns_name_t *prefix, dns_name_t *suffix,
dns_name_t *name, isc_buffer_t *target);
/*
* Concatenate 'prefix' & 'suffix' and return the result in 'name'.
*
* Returns:
* DNS_R_SUCCESS
* DNS_R_NOSPACE
*/
#endif /* DNS_NAME_H */

View file

@ -96,6 +96,7 @@
#include <dns/types.h>
#include <dns/name.h>
#include <dns/callbacks.h>
#include <dns/compress.h>
/*****
***** RData

View file

@ -1863,6 +1863,19 @@ dns_result_t
dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
isc_buffer_t *target)
{
unsigned int methods;
unsigned int offset;
dns_name_t gp, gs;
dns_name_t lp, ls;
isc_boolean_t gf;
isc_boolean_t lf;
isc_int16_t go;
isc_int16_t lo;
unsigned char gb[257];
unsigned char lb[257];
isc_buffer_t gws;
isc_buffer_t lws;
/*
* Convert 'name' into wire format, compressing it as specified by the
* compression context 'cctx', and storing the result in 'target'.
@ -1872,17 +1885,153 @@ dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
REQUIRE(cctx != NULL);
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
/*
* XXX We don't try to compress the name; we just copy the
* uncompressed version into the target buffer.
*/
dns_name_init(&lp, NULL);
dns_name_init(&gp, NULL);
dns_name_init(&ls, NULL);
dns_name_init(&gs, NULL);
isc_buffer_init(&gws, gb, sizeof gb, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&lws, lb, sizeof lb, ISC_BUFFERTYPE_BINARY);
if (target->length - target->used < name->length)
return (DNS_R_NOSPACE);
(void)memcpy((unsigned char *)target->base + target->used,
name->ndata, (size_t)name->length);
offset = target->used; /*XXX*/
isc_buffer_add(target, name->length);
methods = dns_compress_getmethods(cctx);
if ((methods & DNS_COMPRESS_GLOBAL) != 0)
gf = dns_compress_findglobal(cctx, name, &gp, &gs, &go, &gws);
else
gf = ISC_FALSE;
if ((methods & DNS_COMPRESS_LOCAL) != 0)
lf = dns_compress_findlocal(cctx, name, &lp, &ls, &lo, &lws);
else
lf = ISC_FALSE;
/* find the best compression */
if (lf && gf) {
if (lp.length < gp.length)
gf = ISC_FALSE;
else
lf = ISC_FALSE;
}
if (gf) {
if (target->length - target->used < gp.length)
return (DNS_R_NOSPACE);
(void)memcpy((unsigned char *)target->base + target->used,
gp.ndata, (size_t)gp.length);
isc_buffer_add(target, gp.length);
if (go < 16384) {
go |= 0xc000;
if (target->length - target->used < 2)
return (DNS_R_NOSPACE);
isc_buffer_putuint16(target, go);
} else {
if (target->length - target->used < 3)
return (DNS_R_NOSPACE);
*((unsigned char*)target->base + target->used) =
DNS_LABELTYPE_GLOBALCOMP16;
isc_buffer_add(target, 1);
isc_buffer_putuint16(target, go);
}
if (gp.length != 0)
dns_compress_add(cctx, &gp, &gs, offset);
} else if (lf) {
if (target->length - target->used < lp.length)
return (DNS_R_NOSPACE);
(void)memcpy((unsigned char *)target->base + target->used,
lp.ndata, (size_t)lp.length);
isc_buffer_add(target, lp.length);
if (lo < 16384) {
lo |= 0x8000;
if (target->length - target->used < 2)
return (DNS_R_NOSPACE);
isc_buffer_putuint16(target, lo);
} else {
if (target->length - target->used < 3)
return (DNS_R_NOSPACE);
*((unsigned char*)target->base + target->used) =
DNS_LABELTYPE_LOCALCOMP;
isc_buffer_add(target, 1);
isc_buffer_putuint16(target, lo);
}
if (lp.length != 0)
dns_compress_add(cctx, &lp, &ls, offset);
} else {
if (target->length - target->used < name->length)
return (DNS_R_NOSPACE);
(void)memcpy((unsigned char *)target->base + target->used,
name->ndata, (size_t)name->length);
isc_buffer_add(target, name->length);
dns_compress_add(cctx, name, NULL, offset);
}
return (DNS_R_SUCCESS);
}
dns_result_t
dns_name_cat(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name,
isc_buffer_t *target)
{
unsigned char *ndata;
unsigned char *offsets;
dns_offsets_t odata;
unsigned int nrem;
unsigned int labels;
unsigned int count;
REQUIRE(VALID_NAME(name));
REQUIRE(VALID_NAME(prefix));
if (suffix != NULL)
REQUIRE(VALID_NAME(suffix));
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
REQUIRE((name->attributes & DNS_NAMEATTR_READONLY) == 0);
nrem = target->length - target->used;
ndata = (unsigned char *)target->base + target->used;
if (nrem > 255)
nrem = 255;
if (dns_name_isabsolute(prefix)) {
count = prefix->length - 1;
labels = prefix->labels - 1;
} else {
count = prefix->length;
labels = prefix->labels;
}
if (count > nrem)
return (DNS_R_NOSPACE);
memcpy(ndata, prefix->ndata, count);
nrem -= count;
ndata += count;
/* append suffix */
if (suffix != NULL) {
if (dns_name_isabsolute(suffix)) {
count = suffix->length - 1;
labels += suffix->labels - 1;
} else {
count = suffix->length;
labels += suffix->labels;
}
if (count > nrem)
return (DNS_R_NOSPACE);
memcpy(ndata, suffix->ndata, count);
ndata += count;
}
/* root label */
if (nrem < 1)
return (DNS_R_NOSPACE);
*ndata++ = 0;
labels++;
name->ndata = (unsigned char *)target->base + target->used;
name->labels = labels;
name->length = ndata - name->ndata;
name->attributes |= DNS_NAMEATTR_ABSOLUTE;
INIT_OFFSETS(name, offsets, odata);
set_offsets(name, offsets, ISC_FALSE, ISC_FALSE, ISC_FALSE);
compact(name, offsets);
isc_buffer_add(target, name->length);
return (DNS_R_SUCCESS);
}

View file

@ -253,7 +253,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) {
int compared, add_labels, current_labels, keep_labels, start_label;
dns_result_t result;
dns_rbtnodechain_t chain;
dns_offsets_t o1, o2;
dns_offsets_t o1, o2, new_offset;
isc_region_t r;
REQUIRE(VALID_RBT(rbt));
@ -410,7 +410,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) {
start_label = 0;
keep_labels = current_labels - compared;
dns_name_init(&new_name, NULL);
dns_name_init(&new_name, new_offset);
dns_name_getlabelsequence(&current_name,
start_label,
keep_labels,

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rdata.c,v 1.35 1999/02/16 22:42:23 marka Exp $ */
/* $Id: rdata.c,v 1.36 1999/02/22 07:23:57 marka Exp $ */
#include <config.h>
@ -296,9 +296,11 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
dns_result_t result = DNS_R_NOTIMPLEMENTED;
isc_boolean_t use_default = ISC_FALSE;
isc_region_t tr;
isc_buffer_t st;
REQUIRE(rdata != NULL);
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
st = *target;
TOWIRESWITCH
@ -310,6 +312,10 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
isc_buffer_add(target, rdata->length);
return (DNS_R_SUCCESS);
}
if (result != DNS_R_SUCCESS) {
*target = st;
dns_compress_backout(cctx, target->used);
}
return (result);
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.c,v 1.5 1999/02/16 22:42:23 marka Exp $ */
/* $Id: tsig_250.c,v 1.6 1999/02/22 07:23:59 marka Exp $ */
/* draft-ietf-dnsind-tsig-07.txt */
@ -234,7 +234,10 @@ towire_any_tsig(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
REQUIRE(rdata->type == 250);
REQUIRE(rdata->class == 255);
cctx = cctx; /*unused*/
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
dns_name_init(&name, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.h,v 1.5 1999/02/16 22:42:23 marka Exp $ */
/* $Id: tsig_250.h,v 1.6 1999/02/22 07:23:59 marka Exp $ */
/* draft-ietf-dnsind-tsig-07.txt */
@ -234,7 +234,10 @@ towire_any_tsig(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
REQUIRE(rdata->type == 250);
REQUIRE(rdata->class == 255);
cctx = cctx; /*unused*/
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
dns_name_init(&name, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: afsdb_18.c,v 1.3 1999/02/16 22:42:23 marka Exp $ */
/* $Id: afsdb_18.c,v 1.4 1999/02/22 07:23:59 marka Exp $ */
/* RFC 1183 */
@ -108,6 +108,11 @@ towire_afsdb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 18);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_available(target, &tr);
dns_rdata_toregion(rdata, &sr);
if (tr.length < 2)

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: afsdb_18.h,v 1.3 1999/02/16 22:42:23 marka Exp $ */
/* $Id: afsdb_18.h,v 1.4 1999/02/22 07:23:59 marka Exp $ */
/* RFC 1183 */
@ -108,6 +108,11 @@ towire_afsdb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 18);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_available(target, &tr);
dns_rdata_toregion(rdata, &sr);
if (tr.length < 2)

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cname_5.c,v 1.9 1999/02/16 22:51:17 marka Exp $ */
/* $Id: cname_5.c,v 1.10 1999/02/22 07:23:59 marka Exp $ */
#ifndef RDATA_GENERIC_CNAME_5_H
#define RDATA_GENERIC_CNAME_5_H
@ -84,6 +84,11 @@ towire_cname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 5);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cname_5.h,v 1.9 1999/02/16 22:51:17 marka Exp $ */
/* $Id: cname_5.h,v 1.10 1999/02/22 07:23:59 marka Exp $ */
#ifndef RDATA_GENERIC_CNAME_5_H
#define RDATA_GENERIC_CNAME_5_H
@ -84,6 +84,11 @@ towire_cname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 5);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: dname_39.c,v 1.2 1999/02/15 05:44:16 marka Exp $ */
/* $Id: dname_39.c,v 1.3 1999/02/22 07:24:00 marka Exp $ */
/* draft-ietf-dnsind-dname-02.txt */
@ -84,6 +84,11 @@ towire_dname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 39);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: dname_39.h,v 1.2 1999/02/15 05:44:16 marka Exp $ */
/* $Id: dname_39.h,v 1.3 1999/02/22 07:24:00 marka Exp $ */
/* draft-ietf-dnsind-dname-02.txt */
@ -84,6 +84,11 @@ towire_dname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 39);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mb_7.c,v 1.9 1999/02/16 22:51:18 marka Exp $ */
/* $Id: mb_7.c,v 1.10 1999/02/22 07:24:00 marka Exp $ */
#ifndef RDATA_GENERIC_MB_7_H
#define RDATA_GENERIC_MB_7_H
@ -84,6 +84,11 @@ towire_mb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 7);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mb_7.h,v 1.9 1999/02/16 22:51:18 marka Exp $ */
/* $Id: mb_7.h,v 1.10 1999/02/22 07:24:00 marka Exp $ */
#ifndef RDATA_GENERIC_MB_7_H
#define RDATA_GENERIC_MB_7_H
@ -84,6 +84,11 @@ towire_mb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 7);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: md_3.c,v 1.9 1999/02/16 22:51:18 marka Exp $ */
/* $Id: md_3.c,v 1.10 1999/02/22 07:24:00 marka Exp $ */
#ifndef RDATA_GENERIC_MD_3_H
#define RDATA_GENERIC_MD_3_H
@ -82,6 +82,11 @@ towire_md(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 3);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: md_3.h,v 1.9 1999/02/16 22:51:18 marka Exp $ */
/* $Id: md_3.h,v 1.10 1999/02/22 07:24:00 marka Exp $ */
#ifndef RDATA_GENERIC_MD_3_H
#define RDATA_GENERIC_MD_3_H
@ -82,6 +82,11 @@ towire_md(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 3);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mf_4.c,v 1.8 1999/02/16 22:42:26 marka Exp $ */
/* $Id: mf_4.c,v 1.9 1999/02/22 07:24:00 marka Exp $ */
#ifndef RDATA_GENERIC_MF_4_H
#define RDATA_GENERIC_MF_4_H
@ -82,6 +82,11 @@ towire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 4);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mf_4.h,v 1.8 1999/02/16 22:42:26 marka Exp $ */
/* $Id: mf_4.h,v 1.9 1999/02/22 07:24:00 marka Exp $ */
#ifndef RDATA_GENERIC_MF_4_H
#define RDATA_GENERIC_MF_4_H
@ -82,6 +82,11 @@ towire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 4);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mg_8.c,v 1.8 1999/02/16 22:42:27 marka Exp $ */
/* $Id: mg_8.c,v 1.9 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MG_8_H
#define RDATA_GENERIC_MG_8_H
@ -84,6 +84,11 @@ towire_mg(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 8);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mg_8.h,v 1.8 1999/02/16 22:42:27 marka Exp $ */
/* $Id: mg_8.h,v 1.9 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MG_8_H
#define RDATA_GENERIC_MG_8_H
@ -84,6 +84,11 @@ towire_mg(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 8);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: minfo_14.c,v 1.9 1999/02/16 22:42:27 marka Exp $ */
/* $Id: minfo_14.c,v 1.10 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MINFO_14_H
#define RDATA_GENERIC_MINFO_14_H
@ -106,6 +106,11 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 14);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: minfo_14.h,v 1.9 1999/02/16 22:42:27 marka Exp $ */
/* $Id: minfo_14.h,v 1.10 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MINFO_14_H
#define RDATA_GENERIC_MINFO_14_H
@ -106,6 +106,11 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 14);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mr_9.c,v 1.8 1999/02/16 22:42:27 marka Exp $ */
/* $Id: mr_9.c,v 1.9 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MR_9_H
#define RDATA_GENERIC_MR_9_H
@ -84,6 +84,11 @@ towire_mr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 9);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mr_9.h,v 1.8 1999/02/16 22:42:27 marka Exp $ */
/* $Id: mr_9.h,v 1.9 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MR_9_H
#define RDATA_GENERIC_MR_9_H
@ -84,6 +84,11 @@ towire_mr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 9);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mx_15.c,v 1.11 1999/02/16 22:42:28 marka Exp $ */
/* $Id: mx_15.c,v 1.12 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MX_15_H
#define RDATA_GENERIC_MX_15_H
@ -105,6 +105,11 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 15);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
isc_buffer_available(target, &tr);
dns_rdata_toregion(rdata, &region);
if (tr.length < 2)

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mx_15.h,v 1.11 1999/02/16 22:42:28 marka Exp $ */
/* $Id: mx_15.h,v 1.12 1999/02/22 07:24:01 marka Exp $ */
#ifndef RDATA_GENERIC_MX_15_H
#define RDATA_GENERIC_MX_15_H
@ -105,6 +105,11 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 15);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
isc_buffer_available(target, &tr);
dns_rdata_toregion(rdata, &region);
if (tr.length < 2)

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: ns_2.c,v 1.8 1999/02/16 22:42:28 marka Exp $ */
/* $Id: ns_2.c,v 1.9 1999/02/22 07:24:02 marka Exp $ */
#ifndef RDATA_GENERIC_NS_2_H
#define RDATA_GENERIC_NS_2_H
@ -84,6 +84,11 @@ towire_ns(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 2);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: ns_2.h,v 1.8 1999/02/16 22:42:28 marka Exp $ */
/* $Id: ns_2.h,v 1.9 1999/02/22 07:24:02 marka Exp $ */
#ifndef RDATA_GENERIC_NS_2_H
#define RDATA_GENERIC_NS_2_H
@ -84,6 +84,11 @@ towire_ns(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 2);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nxt_30.c,v 1.5 1999/02/16 22:42:28 marka Exp $ */
/* $Id: nxt_30.c,v 1.6 1999/02/22 07:24:02 marka Exp $ */
/* RFC 2065 */
@ -146,6 +146,11 @@ towire_nxt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 30);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &sr);
dns_name_fromregion(&name, &sr);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nxt_30.h,v 1.5 1999/02/16 22:42:28 marka Exp $ */
/* $Id: nxt_30.h,v 1.6 1999/02/22 07:24:02 marka Exp $ */
/* RFC 2065 */
@ -146,6 +146,11 @@ towire_nxt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 30);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &sr);
dns_name_fromregion(&name, &sr);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: proforma.c,v 1.6 1999/02/16 22:51:19 marka Exp $ */
/* $Id: proforma.c,v 1.7 1999/02/22 07:24:02 marka Exp $ */
#ifndef RDATA_GENERIC_#_#_H
#define RDATA_GENERIC_#_#_H
@ -60,6 +60,11 @@ towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == #);
REQUIRE(rdata->class == #);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL):
else
dns_compress_setmethods(cctx, DNS_COMPRESS_LOCAL);
return (DNS_R_NOTIMPLEMENTED);
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: proforma.h,v 1.6 1999/02/16 22:51:19 marka Exp $ */
/* $Id: proforma.h,v 1.7 1999/02/22 07:24:02 marka Exp $ */
#ifndef RDATA_GENERIC_#_#_H
#define RDATA_GENERIC_#_#_H
@ -60,6 +60,11 @@ towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == #);
REQUIRE(rdata->class == #);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL):
else
dns_compress_setmethods(cctx, DNS_COMPRESS_LOCAL);
return (DNS_R_NOTIMPLEMENTED);
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: ptr_12.c,v 1.9 1999/02/16 22:51:19 marka Exp $ */
/* $Id: ptr_12.c,v 1.10 1999/02/22 07:24:02 marka Exp $ */
#ifndef RDATA_GENERIC_PTR_12_H
#define RDATA_GENERIC_PTR_12_H
@ -84,6 +84,11 @@ towire_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 12);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: ptr_12.h,v 1.9 1999/02/16 22:51:19 marka Exp $ */
/* $Id: ptr_12.h,v 1.10 1999/02/22 07:24:02 marka Exp $ */
#ifndef RDATA_GENERIC_PTR_12_H
#define RDATA_GENERIC_PTR_12_H
@ -84,6 +84,11 @@ towire_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 12);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rp_17.c,v 1.3 1999/02/16 22:42:29 marka Exp $ */
/* $Id: rp_17.c,v 1.4 1999/02/22 07:24:03 marka Exp $ */
/* RFC 1183 */
@ -108,6 +108,11 @@ towire_rp(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 17);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rp_17.h,v 1.3 1999/02/16 22:42:29 marka Exp $ */
/* $Id: rp_17.h,v 1.4 1999/02/22 07:24:03 marka Exp $ */
/* RFC 1183 */
@ -108,6 +108,11 @@ towire_rp(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 17);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rt_21.c,v 1.3 1999/02/16 22:42:29 marka Exp $ */
/* $Id: rt_21.c,v 1.4 1999/02/22 07:24:03 marka Exp $ */
/* RFC 1183 */
@ -107,6 +107,11 @@ towire_rt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 21);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_available(target, &tr);
dns_rdata_toregion(rdata, &region);
if (tr.length < 2)

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rt_21.h,v 1.3 1999/02/16 22:42:29 marka Exp $ */
/* $Id: rt_21.h,v 1.4 1999/02/22 07:24:03 marka Exp $ */
/* RFC 1183 */
@ -107,6 +107,11 @@ towire_rt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 21);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_available(target, &tr);
dns_rdata_toregion(rdata, &region);
if (tr.length < 2)

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: sig_24.c,v 1.7 1999/02/16 22:42:29 marka Exp $ */
/* $Id: sig_24.c,v 1.8 1999/02/22 07:24:03 marka Exp $ */
/* RFC 2065 */
@ -216,6 +216,11 @@ towire_sig(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 24);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
/*
* type covered: 2

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: sig_24.h,v 1.7 1999/02/16 22:42:29 marka Exp $ */
/* $Id: sig_24.h,v 1.8 1999/02/22 07:24:03 marka Exp $ */
/* RFC 2065 */
@ -216,6 +216,11 @@ towire_sig(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 24);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
/*
* type covered: 2

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: soa_6.c,v 1.12 1999/02/16 22:51:19 marka Exp $ */
/* $Id: soa_6.c,v 1.13 1999/02/22 07:24:04 marka Exp $ */
#ifndef RDATA_GENERIC_SOA_6_H
#define RDATA_GENERIC_SOA_6_H
@ -142,6 +142,11 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 6);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: soa_6.h,v 1.12 1999/02/16 22:51:19 marka Exp $ */
/* $Id: soa_6.h,v 1.13 1999/02/22 07:24:04 marka Exp $ */
#ifndef RDATA_GENERIC_SOA_6_H
#define RDATA_GENERIC_SOA_6_H
@ -142,6 +142,11 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 6);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tkey_249.c,v 1.5 1999/02/15 05:44:20 marka Exp $ */
/* $Id: tkey_249.c,v 1.6 1999/02/22 07:24:04 marka Exp $ */
/* draft-ietf-dnssec-tkey-01.txt */
@ -224,6 +224,11 @@ towire_tkey(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 249);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* Algorithm */
dns_rdata_toregion(rdata, &sr);
dns_name_init(&name, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tkey_249.h,v 1.5 1999/02/15 05:44:20 marka Exp $ */
/* $Id: tkey_249.h,v 1.6 1999/02/22 07:24:04 marka Exp $ */
/* draft-ietf-dnssec-tkey-01.txt */
@ -224,6 +224,11 @@ towire_tkey(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 249);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* Algorithm */
dns_rdata_toregion(rdata, &sr);
dns_name_init(&name, NULL);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: a6_38.c,v 1.5 1999/02/16 22:42:31 marka Exp $ */
/* $Id: a6_38.c,v 1.6 1999/02/22 07:24:04 marka Exp $ */
/* draft-ietf-ipngwg-dns-lookups-03.txt */
@ -188,6 +188,11 @@ towire_in_a6(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 38);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
prefixlen = sr.base[0];
INSIST(prefixlen <= 128);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: a6_38.h,v 1.5 1999/02/16 22:42:31 marka Exp $ */
/* $Id: a6_38.h,v 1.6 1999/02/22 07:24:04 marka Exp $ */
/* draft-ietf-ipngwg-dns-lookups-03.txt */
@ -188,6 +188,11 @@ towire_in_a6(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 38);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
prefixlen = sr.base[0];
INSIST(prefixlen <= 128);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: kx_36.c,v 1.3 1999/02/16 22:42:32 marka Exp $ */
/* $Id: kx_36.c,v 1.4 1999/02/22 07:24:04 marka Exp $ */
/* RFC 2230 */
@ -101,6 +101,11 @@ towire_in_kx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 36);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &region);
RETERR(mem_tobuffer(target, region.base, 2));
isc_region_consume(&region, 2);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: kx_36.h,v 1.3 1999/02/16 22:42:32 marka Exp $ */
/* $Id: kx_36.h,v 1.4 1999/02/22 07:24:04 marka Exp $ */
/* RFC 2230 */
@ -101,6 +101,11 @@ towire_in_kx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 36);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &region);
RETERR(mem_tobuffer(target, region.base, 2));
isc_region_consume(&region, 2);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: naptr_35.c,v 1.3 1999/02/16 22:42:32 marka Exp $ */
/* $Id: naptr_35.c,v 1.4 1999/02/22 07:24:05 marka Exp $ */
/* RFC 2168 */
@ -152,6 +152,11 @@ towire_in_naptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
REQUIRE(rdata->type == 35);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* priority, weight */
dns_rdata_toregion(rdata, &sr);
RETERR(mem_tobuffer(target, sr.base, 4));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: naptr_35.h,v 1.3 1999/02/16 22:42:32 marka Exp $ */
/* $Id: naptr_35.h,v 1.4 1999/02/22 07:24:05 marka Exp $ */
/* RFC 2168 */
@ -152,6 +152,11 @@ towire_in_naptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
REQUIRE(rdata->type == 35);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* priority, weight */
dns_rdata_toregion(rdata, &sr);
RETERR(mem_tobuffer(target, sr.base, 4));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nsap-ptr_23.c,v 1.2 1999/02/15 05:44:21 marka Exp $ */
/* $Id: nsap-ptr_23.c,v 1.3 1999/02/22 07:24:05 marka Exp $ */
/* RFC 1348 */
@ -90,6 +90,11 @@ towire_in_nsap_ptr(dns_rdata_t *rdata, dns_compress_t *cctx,
REQUIRE(rdata->type == 23);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nsap-ptr_23.h,v 1.2 1999/02/15 05:44:21 marka Exp $ */
/* $Id: nsap-ptr_23.h,v 1.3 1999/02/22 07:24:05 marka Exp $ */
/* RFC 1348 */
@ -90,6 +90,11 @@ towire_in_nsap_ptr(dns_rdata_t *rdata, dns_compress_t *cctx,
REQUIRE(rdata->type == 23);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: px_26.c,v 1.2 1999/02/15 05:44:22 marka Exp $ */
/* $Id: px_26.c,v 1.3 1999/02/22 07:24:05 marka Exp $ */
/* RFC 2163 */
@ -126,6 +126,11 @@ towire_in_px(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 26);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* preference */
dns_rdata_toregion(rdata, &region);
RETERR(mem_tobuffer(target, region.base, 2));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: px_26.h,v 1.2 1999/02/15 05:44:22 marka Exp $ */
/* $Id: px_26.h,v 1.3 1999/02/22 07:24:05 marka Exp $ */
/* RFC 2163 */
@ -126,6 +126,11 @@ towire_in_px(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 26);
REQUIRE(rdata->class == 1);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* preference */
dns_rdata_toregion(rdata, &region);
RETERR(mem_tobuffer(target, region.base, 2));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: srv_33.c,v 1.2 1999/02/15 05:44:22 marka Exp $ */
/* $Id: srv_33.c,v 1.3 1999/02/22 07:24:05 marka Exp $ */
/* RFC 2052 bis */
@ -129,6 +129,11 @@ towire_in_srv(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 33);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* priority, weight, port */
dns_rdata_toregion(rdata, &sr);
RETERR(mem_tobuffer(target, sr.base, 6));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: srv_33.h,v 1.2 1999/02/15 05:44:22 marka Exp $ */
/* $Id: srv_33.h,v 1.3 1999/02/22 07:24:05 marka Exp $ */
/* RFC 2052 bis */
@ -129,6 +129,11 @@ towire_in_srv(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 33);
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/* priority, weight, port */
dns_rdata_toregion(rdata, &sr);
RETERR(mem_tobuffer(target, sr.base, 6));

View file

@ -26,6 +26,7 @@
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdataset.h>
#include <dns/compress.h>
void
dns_rdataset_init(dns_rdataset_t *rdataset) {
@ -272,6 +273,8 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
isc_region_t r;
dns_result_t result;
unsigned int count;
isc_buffer_t st;
isc_buffer_t rdlen;
/*
* Convert 'rdataset' to wire format, compressing names as specified
@ -288,31 +291,54 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
/*
* copy out the name, type, class, ttl.
*/
if (dns_compress_getedns(cctx) >= 1)
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL);
else
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
st = *target;
result = dns_name_towire(owner_name, cctx, target);
if (result != DNS_R_SUCCESS)
if (result != DNS_R_SUCCESS) {
dns_compress_backout(cctx, st.used);
*target = st;
return (result);
}
isc_buffer_available(target, &r);
if (r.length < (sizeof(dns_rdataclass_t)
+ sizeof(dns_rdatatype_t)
+ sizeof(dns_ttl_t)
+ 2)) /* XXX 2? it's for the rdata length */
+ 2)) { /* XXX 2? it's for the rdata length */
dns_compress_backout(cctx, st.used);
*target = st;
return (DNS_R_NOSPACE);
}
isc_buffer_putuint16(target, rdataset->type);
isc_buffer_putuint16(target, rdataset->class);
isc_buffer_putuint32(target, rdataset->ttl);
/*
* copy out the rdata length
* Save space for rdlen.
*/
dns_rdataset_current(rdataset, &rdata);
isc_buffer_putuint16(target, rdata.length);
rdlen = *target;
isc_buffer_add(target, 2);
/*
* copy out the rdata
*/
result = dns_rdata_towire(&rdata, cctx, target);
if (result != DNS_R_SUCCESS)
dns_rdataset_current(rdataset, &rdata);
result = dns_compress_localinit(cctx, owner_name, target);
if (result != DNS_R_SUCCESS) {
dns_compress_backout(cctx, st.used);
*target = st;
return (result);
}
result = dns_rdata_towire(&rdata, cctx, target);
dns_compress_localinvalidate(cctx);
if (result != DNS_R_SUCCESS) {
dns_compress_backout(cctx, st.used);
*target = st;
return (result);
}
isc_buffer_putuint16(&rdlen, target->used - rdlen.used - 2);
count++;