decompression revision 9bff67898d55cddfcec9ce30cc2b1bb6211ec691
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinCopyright (C) 1999, 2000 Internet Software Consortium.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSee COPYRIGHT in the source root or http://www.isc.org/copyright for terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner Name Decompression
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin $Id: decompression,v 1.4 2000/06/21 23:43:32 tale Exp $
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinOverview.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin There are 4 type of compression: global 14 bit, global 16 bit,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin local 14 bit and local 16 bit.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin In general the resolver / nameserver should accept any compression
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin method at any time regardless of whether it was legal to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin send it. This fits with the priciple of being liberal with
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin what you accept and strict with what you send.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin There are a few cases where it does not make sence to accept
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin compression pointers of a given type. i.e. the first domain name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin in a message, local compression pointers in the ownername of a RR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin or in a question.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin When performing regression testing however we should be as strict
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin as possible. Hence we need to be able modifiy the behaviour of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin decompression routines.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin To be able to decompress a domain name we need some or all of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin following pieces of information.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 1. where the message starts.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 2. where the current rdata starts in the message (local compression).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 3. what the current owner name is (local compression).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 4. where the domainname we are decompressing starts.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 5. what are allowable decompression method. These vary across type
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin and edn version.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinImplementation:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dns_rdata_fromwire will set the allowed decompression methods allowed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin by looking at edns, strict and the type values.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinTypes:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin struct dns_decompress {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned int magic;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned int allowed;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int edns;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dns_name_t owner_name;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned int rdata;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin isc_boolean_t strict;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
Functions:
void
dns_decompress_init(dns_decompress_t *dctx, int edns,
isc_boolean_t strict);
initalise dctx
dctx->ownername is invalidated
void
dns_decompress_localinit(dns_decompress_t *dctx, dns_name_t *name,
isc_buffer_t *source);
initalise dctx->ownername
record source->current to dctx->rdata
void
dns_decompress_invalidate(dns_decompress_t *dctx);
invalidate dctx
void
dns_decompress_localinvalidate(dns_decompress_t *dctx);
invalidate dctx->ownername
void
dns_decompress_setmethods(dns_decompress_t *dctx, unsigned int allowed);
sets dctx->allowed
unsigned int
dns_decompress_getmethods(dns_decompress_t *dctx);
returns dctx->allowed
int
dns_decompress_edns(dns_decompress_t *dctx);
returns dctx->edns
isc_boolean_t
dns_decompress_strict(dns_decompress_t *dctx);
returns dctx->strict
dns_result_t
dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
dns_decompress_t *dctx, isc_boolean_t downcase,
isc_buffer_t *target)