1 /* $NetBSD: rdataslab.h,v 1.4 2014/12/10 04:37:58 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 1999-2002 Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /* Id: rdataslab.h,v 1.33 2008/04/01 23:47:10 tbox Exp */ 21 22 #ifndef DNS_RDATASLAB_H 23 #define DNS_RDATASLAB_H 1 24 25 /*! \file dns/rdataslab.h 26 * \brief 27 * Implements storage of rdatasets into slabs of memory. 28 * 29 * MP: 30 *\li Clients of this module must impose any required synchronization. 31 * 32 * Reliability: 33 *\li This module deals with low-level byte streams. Errors in any of 34 * the functions are likely to crash the server or corrupt memory. 35 * 36 *\li If the caller passes invalid memory references, these functions are 37 * likely to crash the server or corrupt memory. 38 * 39 * Resources: 40 *\li None. 41 * 42 * Security: 43 *\li None. 44 * 45 * Standards: 46 *\li None. 47 */ 48 49 /*** 50 *** Imports 51 ***/ 52 53 #include <isc/lang.h> 54 55 #include <dns/types.h> 56 57 ISC_LANG_BEGINDECLS 58 59 #define DNS_RDATASLAB_FORCE 0x1 60 #define DNS_RDATASLAB_EXACT 0x2 61 62 #define DNS_RDATASLAB_OFFLINE 0x01 /* RRSIG is for offline DNSKEY */ 63 #define DNS_RDATASLAB_WARNMASK 0x0E /*%< RRSIG(DNSKEY) expired 64 * warnings number mask. */ 65 #define DNS_RDATASLAB_WARNSHIFT 1 /*%< How many bits to shift to find 66 * remaining expired warning number. */ 67 68 69 /*** 70 *** Functions 71 ***/ 72 73 isc_result_t 74 dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, 75 isc_region_t *region, unsigned int reservelen); 76 /*%< 77 * Slabify a rdataset. The slab area will be allocated and returned 78 * in 'region'. 79 * 80 * Requires: 81 *\li 'rdataset' is valid. 82 * 83 * Ensures: 84 *\li 'region' will have base pointing to the start of allocated memory, 85 * with the slabified region beginning at region->base + reservelen. 86 * region->length contains the total length allocated. 87 * 88 * Returns: 89 *\li ISC_R_SUCCESS - successful completion 90 *\li ISC_R_NOMEMORY - no memory. 91 *\li XXX others 92 */ 93 94 void 95 dns_rdataslab_tordataset(unsigned char *slab, unsigned int reservelen, 96 dns_rdataclass_t rdclass, dns_rdatatype_t rdtype, 97 dns_rdatatype_t covers, dns_ttl_t ttl, 98 dns_rdataset_t *rdataset); 99 /*%< 100 * Construct an rdataset from a slab. 101 * 102 * Requires: 103 *\li 'slab' points to a slab. 104 *\li 'rdataset' is disassociated. 105 * 106 * Ensures: 107 *\li 'rdataset' is associated and points to a valid rdataest. 108 */ 109 unsigned int 110 dns_rdataslab_size(unsigned char *slab, unsigned int reservelen); 111 /*%< 112 * Return the total size of an rdataslab. 113 * 114 * Requires: 115 *\li 'slab' points to a slab. 116 * 117 * Returns: 118 *\li The number of bytes in the slab, including the reservelen. 119 */ 120 121 isc_result_t 122 dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab, 123 unsigned int reservelen, isc_mem_t *mctx, 124 dns_rdataclass_t rdclass, dns_rdatatype_t type, 125 unsigned int flags, unsigned char **tslabp); 126 /*%< 127 * Merge 'oslab' and 'nslab'. 128 */ 129 130 isc_result_t 131 dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab, 132 unsigned int reservelen, isc_mem_t *mctx, 133 dns_rdataclass_t rdclass, dns_rdatatype_t type, 134 unsigned int flags, unsigned char **tslabp); 135 /*%< 136 * Subtract 'sslab' from 'mslab'. If 'exact' is true then all elements 137 * of 'sslab' must exist in 'mslab'. 138 * 139 * XXX 140 * valid flags are DNS_RDATASLAB_EXACT 141 */ 142 143 isc_boolean_t 144 dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2, 145 unsigned int reservelen); 146 /*%< 147 * Compare two rdataslabs for equality. This does _not_ do a full 148 * DNSSEC comparison. 149 * 150 * Requires: 151 *\li 'slab1' and 'slab2' point to slabs. 152 * 153 * Returns: 154 *\li ISC_TRUE if the slabs are equal, ISC_FALSE otherwise. 155 */ 156 isc_boolean_t 157 dns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2, 158 unsigned int reservelen, dns_rdataclass_t rdclass, 159 dns_rdatatype_t type); 160 /*%< 161 * Compare two rdataslabs for DNSSEC equality. 162 * 163 * Requires: 164 *\li 'slab1' and 'slab2' point to slabs. 165 * 166 * Returns: 167 *\li ISC_TRUE if the slabs are equal, #ISC_FALSE otherwise. 168 */ 169 170 ISC_LANG_ENDDECLS 171 172 #endif /* DNS_RDATASLAB_H */ 173