compress.h revision ec5347e2c775f027573ce5648b910361aa926c01
/*
* Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 Internet Software Consortium.
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.h,v 1.39 2007/06/18 23:47:42 tbox Exp $ */
#ifndef DNS_COMPRESS_H
#define DNS_COMPRESS_H 1
/*! \file dns/compress.h
* Direct manipulation of the structures is strongly discouraged.
*/
#define DNS_COMPRESS_TABLESIZE 64
#define DNS_COMPRESS_INITIALNODES 16
typedef struct dns_compressnode dns_compressnode_t;
struct dns_compressnode {
isc_region_t r;
};
struct dns_compress {
unsigned int magic; /*%< Magic number. */
unsigned int allowed; /*%< Allowed methods. */
int edns; /*%< Edns version or -1. */
/*% Global compression table. */
/*% Preallocated nodes for the table. */
};
typedef enum {
DNS_DECOMPRESS_ANY, /*%< Any compression */
DNS_DECOMPRESS_STRICT, /*%< Allowed compression */
DNS_DECOMPRESS_NONE /*%< No compression */
struct dns_decompress {
unsigned int magic; /*%< Magic number. */
unsigned int allowed; /*%< Allowed methods. */
int edns; /*%< Edns version or -1. */
};
/*%<
* Inialise the compression context structure pointed to by 'cctx'.
*
* Requires:
* \li 'cctx' is a valid dns_compress_t structure.
* \li 'mctx' is an initialized memory context.
* Ensures:
* \li cctx->global is initialized.
*
* Returns:
* \li #ISC_R_SUCCESS
* \li failures from dns_rbt_create()
*/
void
/*%<
* Invalidate the compression structure pointed to by cctx.
*
* Requires:
*\li 'cctx' to be initialized.
*/
void
/*%<
* Sets allowed compression methods.
*
* Requires:
*\li 'cctx' to be initialized.
*/
unsigned int
/*%<
* Gets allowed compression methods.
*
* Requires:
*\li 'cctx' to be initialized.
*
* Returns:
*\li allowed compression bitmap.
*/
void
/*
* Preserve the case of compressed domain names.
*
* Requires:
* 'cctx' to be initialized.
*/
/*
* Return whether case is to be preservered when compressing
* domain names.
*
* Requires:
* 'cctx' to be initialized.
*/
int
/*%<
* Gets edns value.
*
* Requires:
*\li 'cctx' to be initialized.
*
* Returns:
*\li -1 .. 255
*/
/*%<
* Finds longest possible match of 'name' in the global compression table.
*
* Requires:
*\li 'cctx' to be initialized.
*\li 'name' to be a absolute name.
*\li 'prefix' to be initialized.
*\li 'offset' to point to an isc_uint16_t.
*
* Ensures:
*\li 'prefix' and 'offset' are valid if ISC_TRUE is returned.
*
* Returns:
*\li #ISC_TRUE / #ISC_FALSE
*/
void
/*%<
* Add compression pointers for 'name' to the compression table,
* not replacing existing pointers.
*
* Requires:
*\li 'cctx' initialized
*
*\li 'name' must be initialized and absolute, and must remain
* valid until the message compression is complete.
*
*\li 'prefix' must be a prefix returned by
* dns_compress_findglobal(), or the same as 'name'.
*/
void
/*%<
* Remove any compression pointers from global table >= offset.
*
* Requires:
*\li 'cctx' is initialized.
*/
void
/*%<
* Initializes 'dctx'.
* Records 'edns' and 'type' into the structure.
*
* Requires:
*\li 'dctx' to be a valid pointer.
*/
void
/*%<
* Invalidates 'dctx'.
*
* Requires:
*\li 'dctx' to be initialized
*/
void
/*%<
* Sets 'dctx->allowed' to 'allowed'.
*
* Requires:
*\li 'dctx' to be initialized
*/
unsigned int
/*%<
* Returns 'dctx->allowed'
*
* Requires:
*\li 'dctx' to be initialized
*/
int
/*%<
* Returns 'dctx->edns'
*
* Requires:
*\li 'dctx' to be initialized
*/
/*%<
* Returns 'dctx->type'
*
* Requires:
*\li 'dctx' to be initialized
*/
#endif /* DNS_COMPRESS_H */