rdataslab.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2002  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: rdataslab.h,v 1.33 2008/04/01 23:47:10 tbox Exp $ */
00019 
00020 #ifndef DNS_RDATASLAB_H
00021 #define DNS_RDATASLAB_H 1
00022 
00023 /*! \file dns/rdataslab.h
00024  * \brief
00025  * Implements storage of rdatasets into slabs of memory.
00026  *
00027  * MP:
00028  *\li   Clients of this module must impose any required synchronization.
00029  *
00030  * Reliability:
00031  *\li   This module deals with low-level byte streams.  Errors in any of
00032  *      the functions are likely to crash the server or corrupt memory.
00033  *
00034  *\li   If the caller passes invalid memory references, these functions are
00035  *      likely to crash the server or corrupt memory.
00036  *
00037  * Resources:
00038  *\li   None.
00039  *
00040  * Security:
00041  *\li   None.
00042  *
00043  * Standards:
00044  *\li   None.
00045  */
00046 
00047 /***
00048  *** Imports
00049  ***/
00050 
00051 #include <isc/lang.h>
00052 
00053 #include <dns/types.h>
00054 
00055 ISC_LANG_BEGINDECLS
00056 
00057 #define DNS_RDATASLAB_FORCE 0x1
00058 #define DNS_RDATASLAB_EXACT 0x2
00059 
00060 #define DNS_RDATASLAB_OFFLINE 0x01      /* RRSIG is for offline DNSKEY */
00061 #define DNS_RDATASLAB_WARNMASK 0x0E     /*%< RRSIG(DNSKEY) expired
00062                                          * warnings number mask. */
00063 #define DNS_RDATASLAB_WARNSHIFT 1       /*%< How many bits to shift to find
00064                                          * remaining expired warning number. */
00065 
00066 
00067 /***
00068  *** Functions
00069  ***/
00070 
00071 isc_result_t
00072 dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
00073                            isc_region_t *region, unsigned int reservelen);
00074 /*%<
00075  * Slabify a rdataset.  The slab area will be allocated and returned
00076  * in 'region'.
00077  *
00078  * Requires:
00079  *\li   'rdataset' is valid.
00080  *
00081  * Ensures:
00082  *\li   'region' will have base pointing to the start of allocated memory,
00083  *      with the slabified region beginning at region->base + reservelen.
00084  *      region->length contains the total length allocated.
00085  *
00086  * Returns:
00087  *\li   ISC_R_SUCCESS           - successful completion
00088  *\li   ISC_R_NOMEMORY          - no memory.
00089  *\li   XXX others
00090  */
00091 
00092 void
00093 dns_rdataslab_tordataset(unsigned char *slab, unsigned int reservelen,
00094                          dns_rdataclass_t rdclass, dns_rdatatype_t rdtype,
00095                          dns_rdatatype_t covers, dns_ttl_t ttl,
00096                          dns_rdataset_t *rdataset);
00097 /*%<
00098  * Construct an rdataset from a slab.
00099  *
00100  * Requires:
00101  *\li   'slab' points to a slab.
00102  *\li   'rdataset' is disassociated.
00103  *
00104  * Ensures:
00105  *\li   'rdataset' is associated and points to a valid rdataest.
00106  */
00107 unsigned int
00108 dns_rdataslab_size(unsigned char *slab, unsigned int reservelen);
00109 /*%<
00110  * Return the total size of an rdataslab.
00111  *
00112  * Requires:
00113  *\li   'slab' points to a slab.
00114  *
00115  * Returns:
00116  *\li   The number of bytes in the slab, including the reservelen.
00117  */
00118 
00119 isc_result_t
00120 dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
00121                     unsigned int reservelen, isc_mem_t *mctx,
00122                     dns_rdataclass_t rdclass, dns_rdatatype_t type,
00123                     unsigned int flags, unsigned char **tslabp);
00124 /*%<
00125  * Merge 'oslab' and 'nslab'.
00126  */
00127 
00128 isc_result_t
00129 dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
00130                        unsigned int reservelen, isc_mem_t *mctx,
00131                        dns_rdataclass_t rdclass, dns_rdatatype_t type,
00132                        unsigned int flags, unsigned char **tslabp);
00133 /*%<
00134  * Subtract 'sslab' from 'mslab'.  If 'exact' is true then all elements
00135  * of 'sslab' must exist in 'mslab'.
00136  *
00137  * XXX
00138  * valid flags are DNS_RDATASLAB_EXACT
00139  */
00140 
00141 isc_boolean_t
00142 dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
00143                     unsigned int reservelen);
00144 /*%<
00145  * Compare two rdataslabs for equality.  This does _not_ do a full
00146  * DNSSEC comparison.
00147  *
00148  * Requires:
00149  *\li   'slab1' and 'slab2' point to slabs.
00150  *
00151  * Returns:
00152  *\li   ISC_TRUE if the slabs are equal, ISC_FALSE otherwise.
00153  */
00154 isc_boolean_t
00155 dns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2,
00156                      unsigned int reservelen, dns_rdataclass_t rdclass,
00157                      dns_rdatatype_t type);
00158 /*%<
00159  * Compare two rdataslabs for DNSSEC equality.
00160  *
00161  * Requires:
00162  *\li   'slab1' and 'slab2' point to slabs.
00163  *
00164  * Returns:
00165  *\li   ISC_TRUE if the slabs are equal, #ISC_FALSE otherwise.
00166  */
00167 
00168 ISC_LANG_ENDDECLS
00169 
00170 #endif /* DNS_RDATASLAB_H */

Generated on Tue Apr 28 17:40:57 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha