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

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 133 lines · 27 code · 15 blank · 91 comment · 0 complexity · 9b142c5cf41c15135ddb150622bcb8ad MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 2000, 2001 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: forward.h,v 1.13 2009/09/02 23:48:02 tbox Exp $ */
  18. #ifndef DNS_FORWARD_H
  19. #define DNS_FORWARD_H 1
  20. /*! \file dns/forward.h */
  21. #include <isc/lang.h>
  22. #include <isc/result.h>
  23. #include <dns/types.h>
  24. ISC_LANG_BEGINDECLS
  25. struct dns_forwarders {
  26. isc_sockaddrlist_t addrs;
  27. dns_fwdpolicy_t fwdpolicy;
  28. };
  29. isc_result_t
  30. dns_fwdtable_create(isc_mem_t *mctx, dns_fwdtable_t **fwdtablep);
  31. /*%<
  32. * Creates a new forwarding table.
  33. *
  34. * Requires:
  35. * \li mctx is a valid memory context.
  36. * \li fwdtablep != NULL && *fwdtablep == NULL
  37. *
  38. * Returns:
  39. * \li #ISC_R_SUCCESS
  40. * \li #ISC_R_NOMEMORY
  41. */
  42. isc_result_t
  43. dns_fwdtable_add(dns_fwdtable_t *fwdtable, dns_name_t *name,
  44. isc_sockaddrlist_t *addrs, dns_fwdpolicy_t policy);
  45. /*%<
  46. * Adds an entry to the forwarding table. The entry associates
  47. * a domain with a list of forwarders and a forwarding policy. The
  48. * addrs list is copied if not empty, so the caller should free its copy.
  49. *
  50. * Requires:
  51. * \li fwdtable is a valid forwarding table.
  52. * \li name is a valid name
  53. * \li addrs is a valid list of sockaddrs, which may be empty.
  54. *
  55. * Returns:
  56. * \li #ISC_R_SUCCESS
  57. * \li #ISC_R_NOMEMORY
  58. */
  59. isc_result_t
  60. dns_fwdtable_delete(dns_fwdtable_t *fwdtable, dns_name_t *name);
  61. /*%<
  62. * Removes an entry for 'name' from the forwarding table. If an entry
  63. * that exactly matches 'name' does not exist, ISC_R_NOTFOUND will be returned.
  64. *
  65. * Requires:
  66. * \li fwdtable is a valid forwarding table.
  67. * \li name is a valid name
  68. *
  69. * Returns:
  70. * \li #ISC_R_SUCCESS
  71. * \li #ISC_R_NOTFOUND
  72. */
  73. isc_result_t
  74. dns_fwdtable_find(dns_fwdtable_t *fwdtable, dns_name_t *name,
  75. dns_forwarders_t **forwardersp);
  76. /*%<
  77. * Finds a domain in the forwarding table. The closest matching parent
  78. * domain is returned.
  79. *
  80. * Requires:
  81. * \li fwdtable is a valid forwarding table.
  82. * \li name is a valid name
  83. * \li forwardersp != NULL && *forwardersp == NULL
  84. *
  85. * Returns:
  86. * \li #ISC_R_SUCCESS
  87. * \li #ISC_R_NOTFOUND
  88. */
  89. isc_result_t
  90. dns_fwdtable_find2(dns_fwdtable_t *fwdtable, dns_name_t *name,
  91. dns_name_t *foundname, dns_forwarders_t **forwardersp);
  92. /*%<
  93. * Finds a domain in the forwarding table. The closest matching parent
  94. * domain is returned.
  95. *
  96. * Requires:
  97. * \li fwdtable is a valid forwarding table.
  98. * \li name is a valid name
  99. * \li forwardersp != NULL && *forwardersp == NULL
  100. * \li foundname to be NULL or a valid name with buffer.
  101. *
  102. * Returns:
  103. * \li #ISC_R_SUCCESS
  104. * \li #ISC_R_NOTFOUND
  105. */
  106. void
  107. dns_fwdtable_destroy(dns_fwdtable_t **fwdtablep);
  108. /*%<
  109. * Destroys a forwarding table.
  110. *
  111. * Requires:
  112. * \li fwtablep != NULL && *fwtablep != NULL
  113. *
  114. * Ensures:
  115. * \li all memory associated with the forwarding table is freed.
  116. */
  117. ISC_LANG_ENDDECLS
  118. #endif /* DNS_FORWARD_H */