/contrib/bind9/lib/dns/include/dns/rdataslab.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 170 lines · 39 code · 18 blank · 113 comment · 0 complexity · 7415e8a30f854ad0c7eecfce33717f46 MD5 · raw file

  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. /* $Id: rdataslab.h,v 1.33 2008/04/01 23:47:10 tbox Exp $ */
  18. #ifndef DNS_RDATASLAB_H
  19. #define DNS_RDATASLAB_H 1
  20. /*! \file dns/rdataslab.h
  21. * \brief
  22. * Implements storage of rdatasets into slabs of memory.
  23. *
  24. * MP:
  25. *\li Clients of this module must impose any required synchronization.
  26. *
  27. * Reliability:
  28. *\li This module deals with low-level byte streams. Errors in any of
  29. * the functions are likely to crash the server or corrupt memory.
  30. *
  31. *\li If the caller passes invalid memory references, these functions are
  32. * likely to crash the server or corrupt memory.
  33. *
  34. * Resources:
  35. *\li None.
  36. *
  37. * Security:
  38. *\li None.
  39. *
  40. * Standards:
  41. *\li None.
  42. */
  43. /***
  44. *** Imports
  45. ***/
  46. #include <isc/lang.h>
  47. #include <dns/types.h>
  48. ISC_LANG_BEGINDECLS
  49. #define DNS_RDATASLAB_FORCE 0x1
  50. #define DNS_RDATASLAB_EXACT 0x2
  51. #define DNS_RDATASLAB_OFFLINE 0x01 /* RRSIG is for offline DNSKEY */
  52. #define DNS_RDATASLAB_WARNMASK 0x0E /*%< RRSIG(DNSKEY) expired
  53. * warnings number mask. */
  54. #define DNS_RDATASLAB_WARNSHIFT 1 /*%< How many bits to shift to find
  55. * remaining expired warning number. */
  56. /***
  57. *** Functions
  58. ***/
  59. isc_result_t
  60. dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
  61. isc_region_t *region, unsigned int reservelen);
  62. /*%<
  63. * Slabify a rdataset. The slab area will be allocated and returned
  64. * in 'region'.
  65. *
  66. * Requires:
  67. *\li 'rdataset' is valid.
  68. *
  69. * Ensures:
  70. *\li 'region' will have base pointing to the start of allocated memory,
  71. * with the slabified region beginning at region->base + reservelen.
  72. * region->length contains the total length allocated.
  73. *
  74. * Returns:
  75. *\li ISC_R_SUCCESS - successful completion
  76. *\li ISC_R_NOMEMORY - no memory.
  77. *\li XXX others
  78. */
  79. void
  80. dns_rdataslab_tordataset(unsigned char *slab, unsigned int reservelen,
  81. dns_rdataclass_t rdclass, dns_rdatatype_t rdtype,
  82. dns_rdatatype_t covers, dns_ttl_t ttl,
  83. dns_rdataset_t *rdataset);
  84. /*%<
  85. * Construct an rdataset from a slab.
  86. *
  87. * Requires:
  88. *\li 'slab' points to a slab.
  89. *\li 'rdataset' is disassociated.
  90. *
  91. * Ensures:
  92. *\li 'rdataset' is associated and points to a valid rdataest.
  93. */
  94. unsigned int
  95. dns_rdataslab_size(unsigned char *slab, unsigned int reservelen);
  96. /*%<
  97. * Return the total size of an rdataslab.
  98. *
  99. * Requires:
  100. *\li 'slab' points to a slab.
  101. *
  102. * Returns:
  103. *\li The number of bytes in the slab, including the reservelen.
  104. */
  105. isc_result_t
  106. dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
  107. unsigned int reservelen, isc_mem_t *mctx,
  108. dns_rdataclass_t rdclass, dns_rdatatype_t type,
  109. unsigned int flags, unsigned char **tslabp);
  110. /*%<
  111. * Merge 'oslab' and 'nslab'.
  112. */
  113. isc_result_t
  114. dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
  115. unsigned int reservelen, isc_mem_t *mctx,
  116. dns_rdataclass_t rdclass, dns_rdatatype_t type,
  117. unsigned int flags, unsigned char **tslabp);
  118. /*%<
  119. * Subtract 'sslab' from 'mslab'. If 'exact' is true then all elements
  120. * of 'sslab' must exist in 'mslab'.
  121. *
  122. * XXX
  123. * valid flags are DNS_RDATASLAB_EXACT
  124. */
  125. isc_boolean_t
  126. dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
  127. unsigned int reservelen);
  128. /*%<
  129. * Compare two rdataslabs for equality. This does _not_ do a full
  130. * DNSSEC comparison.
  131. *
  132. * Requires:
  133. *\li 'slab1' and 'slab2' point to slabs.
  134. *
  135. * Returns:
  136. *\li ISC_TRUE if the slabs are equal, ISC_FALSE otherwise.
  137. */
  138. isc_boolean_t
  139. dns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2,
  140. unsigned int reservelen, dns_rdataclass_t rdclass,
  141. dns_rdatatype_t type);
  142. /*%<
  143. * Compare two rdataslabs for DNSSEC equality.
  144. *
  145. * Requires:
  146. *\li 'slab1' and 'slab2' point to slabs.
  147. *
  148. * Returns:
  149. *\li ISC_TRUE if the slabs are equal, #ISC_FALSE otherwise.
  150. */
  151. ISC_LANG_ENDDECLS
  152. #endif /* DNS_RDATASLAB_H */