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