compress.h revision bfd4b9e11aa9e8c2b43022a6b7a896b26bd5d7a0
002a514a7a09e0b8700895f4f215e4c60e1b4f56cmarqu * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
002a514a7a09e0b8700895f4f215e4c60e1b4f56cmarqu * Copyright (C) 1999-2002 Internet Software Consortium.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Permission to use, copy, modify, and/or distribute this software for any
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * purpose with or without fee is hereby granted, provided that the above
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * copyright notice and this permission notice appear in all copies.
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
002a514a7a09e0b8700895f4f215e4c60e1b4f56cmarqu * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * PERFORMANCE OF THIS SOFTWARE.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Direct manipulation of the structures is strongly discouraged.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * A name compression context handles compression of multiple DNS names
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * in relation to a single DNS message. The context can be used to
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * selectively turn on/off compression for specific names (depending on
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * the RR type) by using \c dns_compress_setmethods(). Alternately,
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * compression can be disabled completely using \c
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * dns_compress_disable().
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * \c dns_compress_setmethods() is intended for use by RDATA towire()
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * implementations, whereas \c dns_compress_disable() is intended to be
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * used by a nameserver's configuration manager.
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu#define DNS_COMPRESS_GLOBAL14 0x01 /*%< "normal" compression. */
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu#define DNS_COMPRESS_ALL 0x01 /*%< all compression. */
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu#define DNS_COMPRESS_CASESENSITIVE 0x02 /*%< case sensitive compression. */
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu isc_boolean_t enabled; /*%< If the compression is enabled at all. */
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas /*% Global compression table. */
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas /*% Preallocated nodes for the table. */
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu dns_compressnode_t initialnodes[DNS_COMPRESS_INITIALNODES];
30655a0f93fae148eacdc4e7795479377b4a1a08matiphastypedef enum {
30655a0f93fae148eacdc4e7795479377b4a1a08matiphasdns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx);
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Initialise the compression context structure pointed to by
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * 'cctx'. A freshly initialized context has name compression
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * enabled, but no methods are set. Please use \c
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * dns_compress_setmethods() to set a compression method.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * \li 'cctx' is a valid dns_compress_t structure.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * \li 'mctx' is an initialized memory context.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * \li cctx->global is initialized.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * \li #ISC_R_SUCCESS
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * \li failures from dns_rbt_create()
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * Invalidate the compression structure pointed to by cctx.
a6497e78e9df7f139540c920875ba8fe622f9371cwebb * Requires:
a6497e78e9df7f139540c920875ba8fe622f9371cwebb *\li 'cctx' to be initialized.
a6497e78e9df7f139540c920875ba8fe622f9371cwebbdns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed);
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * Sets allowed compression methods.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'cctx' to be initialized.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphasunsigned int
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Gets allowed compression methods.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu *\li 'cctx' to be initialized.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li allowed compression bitmap.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Disables all name compression in the context. Once disabled,
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * name compression cannot currently be re-enabled.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu *\li 'cctx' to be initialized.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphasdns_compress_setsensitive(dns_compress_t *cctx, isc_boolean_t sensitive);
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu * Preserve the case of compressed domain names.
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu * Requires:
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu * 'cctx' to be initialized.
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu * Return whether case is to be preserved when compressing
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu * domain names.
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu * Requires:
36de3346306c17768d6c2e284df34581c4cd0e67cmarqu * 'cctx' to be initialized.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Gets edns value.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'cctx' to be initialized.
619df37631a53fcf45cbe42ac39a74f9750fee67cmarqu *\li -1 .. 255
30655a0f93fae148eacdc4e7795479377b4a1a08matiphasdns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Finds longest possible match of 'name' in the global compression table.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'cctx' to be initialized.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'name' to be a absolute name.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'prefix' to be initialized.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'offset' to point to an isc_uint16_t.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'prefix' and 'offset' are valid if ISC_TRUE is returned.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li #ISC_TRUE / #ISC_FALSE
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqudns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Add compression pointers for 'name' to the compression table,
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * not replacing existing pointers.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'cctx' initialized
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'name' must be initialized and absolute, and must remain
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * valid until the message compression is complete.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'prefix' must be a prefix returned by
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu * dns_compress_findglobal(), or the same as 'name'.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphasdns_compress_rollback(dns_compress_t *cctx, isc_uint16_t offset);
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Remove any compression pointers from global table >= offset.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'cctx' is initialized.
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu * Initializes 'dctx'.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Records 'edns' and 'type' into the structure.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'dctx' to be a valid pointer.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Invalidates 'dctx'.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'dctx' to be initialized
30655a0f93fae148eacdc4e7795479377b4a1a08matiphasdns_decompress_setmethods(dns_decompress_t *dctx, unsigned int allowed);
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Sets 'dctx->allowed' to 'allowed'.
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'dctx' to be initialized
30655a0f93fae148eacdc4e7795479377b4a1a08matiphasunsigned int
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Returns 'dctx->allowed'
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas *\li 'dctx' to be initialized
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Returns 'dctx->edns'
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'dctx' to be initialized
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Returns 'dctx->type'
30655a0f93fae148eacdc4e7795479377b4a1a08matiphas * Requires:
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu *\li 'dctx' to be initialized
ac2de0b006739c10b0ab8917e9c470200c06ee2dcmarqu#endif /* DNS_COMPRESS_H */