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

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 186 lines · 31 code · 16 blank · 139 comment · 0 complexity · f05d3cbf88829a18bb87e553da5014a7 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2010 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: ncache.h,v 1.29 2010/05/14 23:50:40 tbox Exp $ */
  18. #ifndef DNS_NCACHE_H
  19. #define DNS_NCACHE_H 1
  20. /*****
  21. ***** Module Info
  22. *****/
  23. /*! \file dns/ncache.h
  24. *\brief
  25. * DNS Ncache
  26. *
  27. * XXX TBS XXX
  28. *
  29. * MP:
  30. *\li The caller must ensure any required synchronization.
  31. *
  32. * Reliability:
  33. *\li No anticipated impact.
  34. *
  35. * Resources:
  36. *\li TBS
  37. *
  38. * Security:
  39. *\li No anticipated impact.
  40. *
  41. * Standards:
  42. *\li RFC2308
  43. */
  44. #include <isc/lang.h>
  45. #include <isc/stdtime.h>
  46. #include <dns/types.h>
  47. ISC_LANG_BEGINDECLS
  48. /*%
  49. * _OMITDNSSEC:
  50. * Omit DNSSEC records when rendering.
  51. */
  52. #define DNS_NCACHETOWIRE_OMITDNSSEC 0x0001
  53. isc_result_t
  54. dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
  55. dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t maxttl,
  56. dns_rdataset_t *addedrdataset);
  57. isc_result_t
  58. dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache,
  59. dns_dbnode_t *node, dns_rdatatype_t covers,
  60. isc_stdtime_t now, dns_ttl_t maxttl,
  61. isc_boolean_t optout, dns_rdataset_t *addedrdataset);
  62. /*%<
  63. * Convert the authority data from 'message' into a negative cache
  64. * rdataset, and store it in 'cache' at 'node' with a TTL limited to
  65. * 'maxttl'.
  66. *
  67. * The 'covers' argument is the RR type whose nonexistence we are caching,
  68. * or dns_rdatatype_any when caching a NXDOMAIN response.
  69. *
  70. * 'optout' indicates a DNS_RDATASETATTR_OPTOUT should be set.
  71. *
  72. * Note:
  73. *\li If 'addedrdataset' is not NULL, then it will be attached to the added
  74. * rdataset. See dns_db_addrdataset() for more details.
  75. *
  76. * Requires:
  77. *\li 'message' is a valid message with a properly formatting negative cache
  78. * authority section.
  79. *
  80. *\li The requirements of dns_db_addrdataset() apply to 'cache', 'node',
  81. * 'now', and 'addedrdataset'.
  82. *
  83. * Returns:
  84. *\li #ISC_R_SUCCESS
  85. *\li #ISC_R_NOSPACE
  86. *
  87. *\li Any result code of dns_db_addrdataset() is a possible result code
  88. * of dns_ncache_add().
  89. */
  90. isc_result_t
  91. dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
  92. isc_buffer_t *target, unsigned int options,
  93. unsigned int *countp);
  94. /*%<
  95. * Convert the negative caching rdataset 'rdataset' to wire format,
  96. * compressing names as specified in 'cctx', and storing the result in
  97. * 'target'. If 'omit_dnssec' is set, DNSSEC records will not
  98. * be added to 'target'.
  99. *
  100. * Notes:
  101. *\li The number of RRs added to target will be added to *countp.
  102. *
  103. * Requires:
  104. *\li 'rdataset' is a valid negative caching rdataset.
  105. *
  106. *\li 'rdataset' is not empty.
  107. *
  108. *\li 'countp' is a valid pointer.
  109. *
  110. * Ensures:
  111. *\li On a return of ISC_R_SUCCESS, 'target' contains a wire format
  112. * for the data contained in 'rdataset'. Any error return leaves
  113. * the buffer unchanged.
  114. *
  115. *\li *countp has been incremented by the number of RRs added to
  116. * target.
  117. *
  118. * Returns:
  119. *\li #ISC_R_SUCCESS - all ok
  120. *\li #ISC_R_NOSPACE - 'target' doesn't have enough room
  121. *
  122. *\li Any error returned by dns_rdata_towire(), dns_rdataset_next(),
  123. * dns_name_towire().
  124. */
  125. isc_result_t
  126. dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
  127. dns_rdatatype_t type, dns_rdataset_t *rdataset);
  128. /*%<
  129. * Search the negative caching rdataset for an rdataset with the
  130. * specified name and type.
  131. *
  132. * Requires:
  133. *\li 'ncacherdataset' is a valid negative caching rdataset.
  134. *
  135. *\li 'ncacherdataset' is not empty.
  136. *
  137. *\li 'name' is a valid name.
  138. *
  139. *\li 'type' is not SIG, or a meta-RR type.
  140. *
  141. *\li 'rdataset' is a valid disassociated rdataset.
  142. *
  143. * Ensures:
  144. *\li On a return of ISC_R_SUCCESS, 'rdataset' is bound to the found
  145. * rdataset.
  146. *
  147. * Returns:
  148. *\li #ISC_R_SUCCESS - the rdataset was found.
  149. *\li #ISC_R_NOTFOUND - the rdataset was not found.
  150. *
  151. */
  152. isc_result_t
  153. dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
  154. dns_rdatatype_t covers, dns_rdataset_t *rdataset);
  155. /*%<
  156. * Similar to dns_ncache_getrdataset() but get the rrsig that matches.
  157. */
  158. void
  159. dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
  160. dns_rdataset_t *rdataset);
  161. /*%<
  162. * Extract the current rdataset and name from a ncache entry.
  163. *
  164. * Requires:
  165. * \li 'ncacherdataset' to be valid and to be a negative cache entry
  166. * \li 'found' to be valid.
  167. * \li 'rdataset' to be unassociated.
  168. */
  169. ISC_LANG_ENDDECLS
  170. #endif /* DNS_NCACHE_H */