compress.h revision d780c35e54f877df716e28db3e19d722cec44aa7
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* 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 INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM 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.20 2000/12/28 00:42:56 bwelling Exp $ */
#ifndef DNS_COMPRESS_H
#define DNS_COMPRESS_H 1
/*
* Synonymous with DNS_COMPRESS_GLOBAL. A genuine difference existed when
* local compression was an IETF draft, but that draft has been retired without
* becoming a standard. Numerous bits of code referred to DNS_COMPRESS_ALL
* already, and rather than change them all, the DNS_COMPRESS_ALL definition
* was left in, but no longer refers to local compression.
*/
/*
* Direct manipulation of the structures is strongly discouraged.
*/
struct dns_compress {
unsigned int magic; /* Magic number. */
unsigned int allowed; /* Allowed methods. */
unsigned int rdata; /* Start of local rdata. */
int edns; /* Edns version or -1. */
};
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. */
unsigned int rdata; /* Start of local rdata. */
int edns; /* Edns version or -1. */
};
/*
* Inialise the compression context structure pointed to by 'cctx'.
*
* Requires:
* 'cctx' is a valid dns_compress_t structure.
* 'mctx' is a initalised memory context.
* Ensures:
* cctx->global is initalised.
*
* Returns:
* ISC_R_SUCCESS
* failures from dns_rbt_create()
*/
void
/*
* Invalidate the compression structure pointed to by cctx.
* Destroys 'cctx->glocal' and 'cctx->local' RBT.
*
* Requires:
* 'cctx' to be initalised.
*/
void
/*
* Sets allowed compression methods.
*
* Requires:
* 'cctx' to be initalised.
*/
unsigned int
/*
* Gets allowed compression methods.
*
* Requires:
* 'cctx' to be initalised.
*
* Returns:
* allowed compression bitmap.
*/
int
/*
* Gets edns value.
*
* Requires:
* 'cctx' to be initalised.
*
* Returns:
* -1 .. 255
*/
/*
* Finds longest possible match of 'name' in the global compression
* RBT. Workspace needs to be large enough to hold 'name' when split
* in two (length->name + 3).
*
* Requires:
* 'cctx' to be initalised.
* 'name' to be a absolute name.
* 'prefix' to be initalised.
* 'suffix' to be initalised.
* 'offset' to point it a isc_uint16_t.
* 'workspace' to be initalised.
*
* Ensures:
* 'prefix', 'suffix' and 'offset' are valid if ISC_TRUE is
* returned.
*
* Returns:
* ISC_TRUE / ISC_FALSE
*/
void
/*
* Add compression pointers for labels in prefix to RBT's.
* If 'prefix' is absolute 'suffix' must be NULL otherwise
* suffix must be absolute.
*
* Requires:
* 'cctx' initalised
* 'prefix' to be initalised
* 'suffix' to be initalised or NULL
*/
void
/*
* Remove any compression pointers from global RBT >= offset.
*
* Requires:
* 'cctx' is initalised.
*/
void
/*
* Initalises 'dctx'.
* Records 'edns' and 'type' into the structure.
*
* Requires:
* 'dctx' to be a valid pointer.
*/
void
/*
* Invalidates 'dctx'.
*
* Requires:
* 'dctx' to be initalised
*/
void
/*
* Sets 'dctx->allowed' to 'allowed'.
*
* Requires:
* 'dctx' to be initalised
*/
unsigned int
/*
* Returns 'dctx->allowed'
*
* Requires:
* 'dctx' to be initalised
*/
int
/*
* Returns 'dctx->edns'
*
* Requires:
* 'dctx' to be initalised
*/
/*
* Returns 'dctx->type'
*
* Requires:
* 'dctx' to be initalised
*/
#endif /* DNS_COMPRESS_H */