decompression revision dafcb997e390efa4423883dafd100c975c4095d6
dafcb997e390efa4423883dafd100c975c4095d6Mark AndrewsCopyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
499b34cea04a46823d003d4c0520c8b03e8513cbBrian WellingtonCopyright (C) 1999-2001 Internet Software Consortium.
816e576f77e2c46df3e3d97d65822aa8aded7c4bDavid LawrenceSee COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
0d92b2da03ce93c195fc3a8ff0b2364791695531Mark Andrews Name Decompression
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews $Id: decompression,v 1.8 2004/03/05 05:04:46 marka Exp $
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews There are 4 type of compression: global 14 bit, global 16 bit,
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews local 14 bit and local 16 bit.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews In general the resolver / nameserver should accept any compression
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews method at any time regardless of whether it was legal to
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews send it. This fits with the priciple of being liberal with
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews what you accept and strict with what you send.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews There are a few cases where it does not make sence to accept
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews compression pointers of a given type. i.e. the first domain name
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews in a message, local compression pointers in the ownername of a RR
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews or in a question.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews When performing regression testing however we should be as strict
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews as possible. Hence we need to be able modifiy the behaviour of the
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews decompression routines.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews To be able to decompress a domain name we need some or all of the
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews following pieces of information.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews 1. where the message starts.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews 2. where the current rdata starts in the message (local compression).
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews 3. what the current owner name is (local compression).
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews 4. where the domainname we are decompressing starts.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews 5. what are allowable decompression method. These vary across type
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews and edn version.
0d92b2da03ce93c195fc3a8ff0b2364791695531Mark AndrewsImplementation:
0d92b2da03ce93c195fc3a8ff0b2364791695531Mark Andrews dns_rdata_fromwire will set the allowed decompression methods allowed
0d92b2da03ce93c195fc3a8ff0b2364791695531Mark Andrews by looking at edns, strict and the type values.
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews struct dns_decompress {
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews unsigned int magic;
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews unsigned int allowed;
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_name_t owner_name;
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews unsigned int rdata;
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews isc_boolean_t strict;
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_init(dns_decompress_t *dctx, int edns,
1ef8965366d91e02a4672c35a187d30aa4a4c72cMark Andrews isc_boolean_t strict);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews initalise dctx
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dctx->ownername is invalidated
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_localinit(dns_decompress_t *dctx, dns_name_t *name,
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews isc_buffer_t *source);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews initalise dctx->ownername
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews record source->current to dctx->rdata
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_invalidate(dns_decompress_t *dctx);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews invalidate dctx
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_localinvalidate(dns_decompress_t *dctx);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews invalidate dctx->ownername
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_setmethods(dns_decompress_t *dctx, unsigned int allowed);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews sets dctx->allowed
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews unsigned int
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_getmethods(dns_decompress_t *dctx);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews returns dctx->allowed
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_edns(dns_decompress_t *dctx);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews returns dctx->edns
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews isc_boolean_t
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_strict(dns_decompress_t *dctx);
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews returns dctx->strict
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_result_t
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews dns_decompress_t *dctx, isc_boolean_t downcase,
95a08101c00db050de55b627dcd00a8d98831e32Mark Andrews isc_buffer_t *target)