2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001, 2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and 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.
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.
18 /* $Id: rdataslab.h,v 1.20.2.3 2004/03/09 06:11:21 marka Exp $ */
20 #ifndef DNS_RDATASLAB_H
21 #define DNS_RDATASLAB_H 1
26 * Implements storage of rdatasets into slabs of memory.
29 * Clients of this module must impose any required synchronization.
32 * This module deals with low-level byte streams. Errors in any of
33 * the functions are likely to crash the server or corrupt memory.
35 * If the caller passes invalid memory references, these functions are
36 * likely to crash the server or corrupt memory.
54 #include <dns/types.h>
58 #define DNS_RDATASLAB_FORCE 0x1
59 #define DNS_RDATASLAB_EXACT 0x2
66 dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
67 isc_region_t *region, unsigned int reservelen);
69 * Slabify a rdataset. The slab area will be allocated and returned
73 * 'rdataset' is valid.
76 * 'region' will have base pointing to the start of allocated memory,
77 * with the slabified region beginning at region->base + reservelen.
78 * region->length contains the total length allocated.
81 * ISC_R_SUCCESS - successful completion
82 * DNS_R_NOMEM - no memory.
87 dns_rdataslab_size(unsigned char *slab, unsigned int reservelen);
89 * Return the total size of an rdataslab.
92 * 'slab' points to a slab.
95 * The number of bytes in the slab, including the reservelen.
99 dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
100 unsigned int reservelen, isc_mem_t *mctx,
101 dns_rdataclass_t rdclass, dns_rdatatype_t type,
102 unsigned int flags, unsigned char **tslabp);
104 * Merge 'oslab' and 'nslab'.
108 dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
109 unsigned int reservelen, isc_mem_t *mctx,
110 dns_rdataclass_t rdclass, dns_rdatatype_t type,
111 unsigned int flags, unsigned char **tslabp);
113 * Subtract 'sslab' from 'mslab'. If 'exact' is true then all elements
114 * of 'sslab' must exist in 'mslab'.
117 * valid flags are DNS_RDATASLAB_EXACT
121 dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
122 unsigned int reservelen);
125 * Compare two rdataslabs for equality. This does _not_ do a full
129 * 'slab1' and 'slab2' point to slabs.
132 * ISC_TRUE if the slabs are equal, ISC_FALSE otherwise.
136 dns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2,
137 unsigned int reservelen, dns_rdataclass_t rdclass,
138 dns_rdatatype_t type);
140 * Compare two rdataslabs for DNSSEC equality.
143 * 'slab1' and 'slab2' point to slabs.
146 * ISC_TRUE if the slabs are equal, ISC_FALSE otherwise.
151 #endif /* DNS_RDATASLAB_H */