0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1999-2002, 2004-2008, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater/* $Id: rdataslab.h,v 1.33 2008/04/01 23:47:10 tbox Exp $ */
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * Implements storage of rdatasets into slabs of memory.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li Clients of this module must impose any required synchronization.
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * Reliability:
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li This module deals with low-level byte streams. Errors in any of
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * the functions are likely to crash the server or corrupt memory.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li If the caller passes invalid memory references, these functions are
e800570a5a7572a94604815cd7d7e788c0479ed2Bob Halley * likely to crash the server or corrupt memory.
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews#define DNS_RDATASLAB_OFFLINE 0x01 /* RRSIG is for offline DNSKEY */
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews#define DNS_RDATASLAB_WARNMASK 0x0E /*%< RRSIG(DNSKEY) expired
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews * warnings number mask. */
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews#define DNS_RDATASLAB_WARNSHIFT 1 /*%< How many bits to shift to find
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews * remaining expired warning number. */
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff *** Functions
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graffdns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_region_t *region, unsigned int reservelen);
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * Slabify a rdataset. The slab area will be allocated and returned
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * in 'region'.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'rdataset' is valid.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'region' will have base pointing to the start of allocated memory,
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * with the slabified region beginning at region->base + reservelen.
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * region->length contains the total length allocated.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li ISC_R_SUCCESS - successful completion
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li ISC_R_NOMEMORY - no memory.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li XXX others
8cf24d101a291aa3274e8fd07d1a13cb5fe9976bBrian Wellingtondns_rdataslab_tordataset(unsigned char *slab, unsigned int reservelen,
8cf24d101a291aa3274e8fd07d1a13cb5fe9976bBrian Wellington dns_rdataclass_t rdclass, dns_rdatatype_t rdtype,
8cf24d101a291aa3274e8fd07d1a13cb5fe9976bBrian Wellington * Construct an rdataset from a slab.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'slab' points to a slab.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'rdataset' is disassociated.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'rdataset' is associated and points to a valid rdataest.
e800570a5a7572a94604815cd7d7e788c0479ed2Bob Halleydns_rdataslab_size(unsigned char *slab, unsigned int reservelen);
e800570a5a7572a94604815cd7d7e788c0479ed2Bob Halley * Return the total size of an rdataslab.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'slab' points to a slab.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li The number of bytes in the slab, including the reservelen.
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrewsdns_rdataslab_count(unsigned char *slab, unsigned int reservelen);
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews * Return the number of records in the rdataslab
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews *\li 'slab' points to a slab.
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews *\li The number of records in the slab.
5bfea18ff8bfa907b86ba7d17fb38b9cf493ae97Bob Halleydns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
5bfea18ff8bfa907b86ba7d17fb38b9cf493ae97Bob Halley * Merge 'oslab' and 'nslab'.
926cde044f4334f7afd9d1123ab0f01ec93e7e72Bob Halleydns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
b55c30f2de6e1baaa3a9ba69b92f428f2c255ac3Mark Andrews * Subtract 'sslab' from 'mslab'. If 'exact' is true then all elements
b55c30f2de6e1baaa3a9ba69b92f428f2c255ac3Mark Andrews * of 'sslab' must exist in 'mslab'.
f8abaa0fae7f75d9601c10b6a4af8dd907494d45Mark Andrews * valid flags are DNS_RDATASLAB_EXACT
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellingtondns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
6434457b0b380aa43d7159299776959a00269d65Michael Graff * Compare two rdataslabs for equality. This does _not_ do a full
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington * DNSSEC comparison.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'slab1' and 'slab2' point to slabs.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li ISC_TRUE if the slabs are equal, ISC_FALSE otherwise.
6434457b0b380aa43d7159299776959a00269d65Michael Graffdns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2,
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater unsigned int reservelen, dns_rdataclass_t rdclass,
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater * Compare two rdataslabs for DNSSEC equality.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li 'slab1' and 'slab2' point to slabs.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *\li ISC_TRUE if the slabs are equal, #ISC_FALSE otherwise.
4be63b1fd8c18dbeca1648d6cf22fa14f057a469David Lawrence#endif /* DNS_RDATASLAB_H */