compress.h revision 29747dfe5e073a299b3681e01f5c55540f8bfed7
641f68d427629200c29aa62c95e18d46fce434abMark Andrews * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews * Copyright (C) 1999-2002 Internet Software Consortium.
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley * Permission to use, copy, modify, and distribute this software for any
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley * purpose with or without fee is hereby granted, provided that the above
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
29747dfe5e073a299b3681e01f5c55540f8bfed7Mark Andrews/* $Id: compress.h,v 1.38 2006/12/22 01:44:59 marka Exp $ */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#define DNS_COMPRESS_NONE 0x00 /*%< no compression */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#define DNS_COMPRESS_GLOBAL14 0x01 /*%< "normal" compression. */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#define DNS_COMPRESS_ALL 0x01 /*%< all compression. */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#define DNS_COMPRESS_CASESENSITIVE 0x02 /*%< case sensitive compression. */
942d1a339b1fe617f7d17d66cb5fccce798d15aeBrian Wellington * Direct manipulation of the structures is strongly discouraged.
575737b964590103f60542849d4536b5ccd4eb3cBrian Wellingtontypedef struct dns_compressnode dns_compressnode_t;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein /*% Global compression table. */
575737b964590103f60542849d4536b5ccd4eb3cBrian Wellington dns_compressnode_t *table[DNS_COMPRESS_TABLESIZE];
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein /*% Preallocated nodes for the table. */
575737b964590103f60542849d4536b5ccd4eb3cBrian Wellington dns_compressnode_t initialnodes[DNS_COMPRESS_INITIALNODES];
942d1a339b1fe617f7d17d66cb5fccce798d15aeBrian Wellingtontypedef enum {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein DNS_DECOMPRESS_STRICT, /*%< Allowed compression */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein dns_decompresstype_t type; /*%< Strict checking */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencedns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx);
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews * Inialise the compression context structure pointed to by 'cctx'.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * \li 'cctx' is a valid dns_compress_t structure.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * \li 'mctx' is an initialized memory context.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * \li cctx->global is initialized.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * \li #ISC_R_SUCCESS
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * \li failures from dns_rbt_create()
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews * Invalidate the compression structure pointed to by cctx.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'cctx' to be initialized.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrewsdns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed);
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews * Sets allowed compression methods.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'cctx' to be initialized.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews * Gets allowed compression methods.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'cctx' to be initialized.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li allowed compression bitmap.
39c7fc7e00af20144b94ef332943f62c1b3a622fMark Andrewsdns_compress_setsensitive(dns_compress_t *cctx, isc_boolean_t sensitive);
39c7fc7e00af20144b94ef332943f62c1b3a622fMark Andrews * Preserve the case of compressed domain names.
39c7fc7e00af20144b94ef332943f62c1b3a622fMark Andrews * 'cctx' to be initialized.
39c7fc7e00af20144b94ef332943f62c1b3a622fMark Andrewsdns_compress_getsensitive(dns_compress_t *cctx);
39c7fc7e00af20144b94ef332943f62c1b3a622fMark Andrews * Return whether case is to be preservered when compressing
39c7fc7e00af20144b94ef332943f62c1b3a622fMark Andrews * domain names.
39c7fc7e00af20144b94ef332943f62c1b3a622fMark Andrews * 'cctx' to be initialized.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews * Gets edns value.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'cctx' to be initialized.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li -1 .. 255
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsdns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
575737b964590103f60542849d4536b5ccd4eb3cBrian Wellington * Finds longest possible match of 'name' in the global compression table.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'cctx' to be initialized.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'name' to be a absolute name.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'prefix' to be initialized.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'offset' to point to an isc_uint16_t.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'prefix' and 'offset' are valid if ISC_TRUE is returned.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li #ISC_TRUE / #ISC_FALSE
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsdns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const dns_name_t *prefix, isc_uint16_t offset);
4d180bd2100d9c848831c08e7f08a75cc21a9c0aBrian Wellington * Add compression pointers for 'name' to the compression table,
575737b964590103f60542849d4536b5ccd4eb3cBrian Wellington * not replacing existing pointers.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'cctx' initialized
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'name' must be initialized and absolute, and must remain
60103a02c62cadc72fef61b8bdab9694e3fcf57aBrian Wellington * valid until the message compression is complete.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'prefix' must be a prefix returned by
473af331834c05fd41b36a6de116a724eae77890Brian Wellington * dns_compress_findglobal(), or the same as 'name'.
c1e7aff941dbf40090fec49300e728ad017d4f0cMark Andrewsdns_compress_rollback(dns_compress_t *cctx, isc_uint16_t offset);
575737b964590103f60542849d4536b5ccd4eb3cBrian Wellington * Remove any compression pointers from global table >= offset.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'cctx' is initialized.
942d1a339b1fe617f7d17d66cb5fccce798d15aeBrian Wellingtondns_decompress_init(dns_decompress_t *dctx, int edns,
6a8832f784bd53aa6afbda22f6187cea6490e1e1Andreas Gustafsson * Initializes 'dctx'.
942d1a339b1fe617f7d17d66cb5fccce798d15aeBrian Wellington * Records 'edns' and 'type' into the structure.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'dctx' to be a valid pointer.
1ef8965366d91e02a4672c35a187d30aa4a4c72cMark Andrewsdns_decompress_invalidate(dns_decompress_t *dctx);
d0221bfa6a08f7b284b231886928aa5d8ac87fc2Mark Andrews * Invalidates 'dctx'.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'dctx' to be initialized
1ef8965366d91e02a4672c35a187d30aa4a4c72cMark Andrewsdns_decompress_setmethods(dns_decompress_t *dctx, unsigned int allowed);
d0221bfa6a08f7b284b231886928aa5d8ac87fc2Mark Andrews * Sets 'dctx->allowed' to 'allowed'.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'dctx' to be initialized
1ef8965366d91e02a4672c35a187d30aa4a4c72cMark Andrewsdns_decompress_getmethods(dns_decompress_t *dctx);
d0221bfa6a08f7b284b231886928aa5d8ac87fc2Mark Andrews * Returns 'dctx->allowed'
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'dctx' to be initialized
d0221bfa6a08f7b284b231886928aa5d8ac87fc2Mark Andrews * Returns 'dctx->edns'
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'dctx' to be initialized
942d1a339b1fe617f7d17d66cb5fccce798d15aeBrian Wellingtondns_decompress_type(dns_decompress_t *dctx);
942d1a339b1fe617f7d17d66cb5fccce798d15aeBrian Wellington * Returns 'dctx->type'
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'dctx' to be initialized
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley#endif /* DNS_COMPRESS_H */