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

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 219 lines · 119 code · 59 blank · 41 comment · 0 complexity · 7599e8584953647d0ac5bbf9b0159faa MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 2000, 2001, 2003 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: peer.h,v 1.35 2009/01/17 23:47:43 tbox Exp $ */
  18. #ifndef DNS_PEER_H
  19. #define DNS_PEER_H 1
  20. /*****
  21. ***** Module Info
  22. *****/
  23. /*! \file dns/peer.h
  24. * \brief
  25. * Data structures for peers (e.g. a 'server' config file statement)
  26. */
  27. /***
  28. *** Imports
  29. ***/
  30. #include <isc/lang.h>
  31. #include <isc/magic.h>
  32. #include <isc/netaddr.h>
  33. #include <dns/types.h>
  34. #define DNS_PEERLIST_MAGIC ISC_MAGIC('s','e','R','L')
  35. #define DNS_PEER_MAGIC ISC_MAGIC('S','E','r','v')
  36. #define DNS_PEERLIST_VALID(ptr) ISC_MAGIC_VALID(ptr, DNS_PEERLIST_MAGIC)
  37. #define DNS_PEER_VALID(ptr) ISC_MAGIC_VALID(ptr, DNS_PEER_MAGIC)
  38. /***
  39. *** Types
  40. ***/
  41. struct dns_peerlist {
  42. unsigned int magic;
  43. isc_uint32_t refs;
  44. isc_mem_t *mem;
  45. ISC_LIST(dns_peer_t) elements;
  46. };
  47. struct dns_peer {
  48. unsigned int magic;
  49. isc_uint32_t refs;
  50. isc_mem_t *mem;
  51. isc_netaddr_t address;
  52. unsigned int prefixlen;
  53. isc_boolean_t bogus;
  54. dns_transfer_format_t transfer_format;
  55. isc_uint32_t transfers;
  56. isc_boolean_t support_ixfr;
  57. isc_boolean_t provide_ixfr;
  58. isc_boolean_t request_ixfr;
  59. isc_boolean_t support_edns;
  60. isc_boolean_t request_nsid;
  61. dns_name_t *key;
  62. isc_sockaddr_t *transfer_source;
  63. isc_sockaddr_t *notify_source;
  64. isc_sockaddr_t *query_source;
  65. isc_uint16_t udpsize; /* receive size */
  66. isc_uint16_t maxudp; /* transmit size */
  67. isc_uint32_t bitflags;
  68. ISC_LINK(dns_peer_t) next;
  69. };
  70. /***
  71. *** Functions
  72. ***/
  73. ISC_LANG_BEGINDECLS
  74. isc_result_t
  75. dns_peerlist_new(isc_mem_t *mem, dns_peerlist_t **list);
  76. void
  77. dns_peerlist_attach(dns_peerlist_t *source, dns_peerlist_t **target);
  78. void
  79. dns_peerlist_detach(dns_peerlist_t **list);
  80. /*
  81. * After return caller still holds a reference to peer.
  82. */
  83. void
  84. dns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer);
  85. /*
  86. * Ditto. */
  87. isc_result_t
  88. dns_peerlist_peerbyaddr(dns_peerlist_t *peers, isc_netaddr_t *addr,
  89. dns_peer_t **retval);
  90. /*
  91. * What he said.
  92. */
  93. isc_result_t
  94. dns_peerlist_currpeer(dns_peerlist_t *peers, dns_peer_t **retval);
  95. isc_result_t
  96. dns_peer_new(isc_mem_t *mem, isc_netaddr_t *ipaddr, dns_peer_t **peer);
  97. isc_result_t
  98. dns_peer_newprefix(isc_mem_t *mem, isc_netaddr_t *ipaddr,
  99. unsigned int prefixlen, dns_peer_t **peer);
  100. void
  101. dns_peer_attach(dns_peer_t *source, dns_peer_t **target);
  102. void
  103. dns_peer_detach(dns_peer_t **list);
  104. isc_result_t
  105. dns_peer_setbogus(dns_peer_t *peer, isc_boolean_t newval);
  106. isc_result_t
  107. dns_peer_getbogus(dns_peer_t *peer, isc_boolean_t *retval);
  108. isc_result_t
  109. dns_peer_setrequestixfr(dns_peer_t *peer, isc_boolean_t newval);
  110. isc_result_t
  111. dns_peer_getrequestixfr(dns_peer_t *peer, isc_boolean_t *retval);
  112. isc_result_t
  113. dns_peer_setprovideixfr(dns_peer_t *peer, isc_boolean_t newval);
  114. isc_result_t
  115. dns_peer_getprovideixfr(dns_peer_t *peer, isc_boolean_t *retval);
  116. isc_result_t
  117. dns_peer_setrequestnsid(dns_peer_t *peer, isc_boolean_t newval);
  118. isc_result_t
  119. dns_peer_getrequestnsid(dns_peer_t *peer, isc_boolean_t *retval);
  120. isc_result_t
  121. dns_peer_setsupportedns(dns_peer_t *peer, isc_boolean_t newval);
  122. isc_result_t
  123. dns_peer_getsupportedns(dns_peer_t *peer, isc_boolean_t *retval);
  124. isc_result_t
  125. dns_peer_settransfers(dns_peer_t *peer, isc_uint32_t newval);
  126. isc_result_t
  127. dns_peer_gettransfers(dns_peer_t *peer, isc_uint32_t *retval);
  128. isc_result_t
  129. dns_peer_settransferformat(dns_peer_t *peer, dns_transfer_format_t newval);
  130. isc_result_t
  131. dns_peer_gettransferformat(dns_peer_t *peer, dns_transfer_format_t *retval);
  132. isc_result_t
  133. dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval);
  134. isc_result_t
  135. dns_peer_getkey(dns_peer_t *peer, dns_name_t **retval);
  136. isc_result_t
  137. dns_peer_setkey(dns_peer_t *peer, dns_name_t **keyval);
  138. isc_result_t
  139. dns_peer_settransfersource(dns_peer_t *peer,
  140. const isc_sockaddr_t *transfer_source);
  141. isc_result_t
  142. dns_peer_gettransfersource(dns_peer_t *peer, isc_sockaddr_t *transfer_source);
  143. isc_result_t
  144. dns_peer_setudpsize(dns_peer_t *peer, isc_uint16_t udpsize);
  145. isc_result_t
  146. dns_peer_getudpsize(dns_peer_t *peer, isc_uint16_t *udpsize);
  147. isc_result_t
  148. dns_peer_setmaxudp(dns_peer_t *peer, isc_uint16_t maxudp);
  149. isc_result_t
  150. dns_peer_getmaxudp(dns_peer_t *peer, isc_uint16_t *maxudp);
  151. isc_result_t
  152. dns_peer_setnotifysource(dns_peer_t *peer, const isc_sockaddr_t *notify_source);
  153. isc_result_t
  154. dns_peer_getnotifysource(dns_peer_t *peer, isc_sockaddr_t *notify_source);
  155. isc_result_t
  156. dns_peer_setquerysource(dns_peer_t *peer, const isc_sockaddr_t *query_source);
  157. isc_result_t
  158. dns_peer_getquerysource(dns_peer_t *peer, isc_sockaddr_t *query_source);
  159. ISC_LANG_ENDDECLS
  160. #endif /* DNS_PEER_H */