/contrib/bind9/bin/named/include/named/sortlist.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 87 lines · 23 code · 12 blank · 52 comment · 0 complexity · 5362cc311b7f20e2d3f56506e02a3197 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2007 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: sortlist.h,v 1.11 2007/06/19 23:46:59 tbox Exp $ */
  18. #ifndef NAMED_SORTLIST_H
  19. #define NAMED_SORTLIST_H 1
  20. /*! \file */
  21. #include <isc/types.h>
  22. #include <dns/types.h>
  23. /*%
  24. * Type for callback functions that rank addresses.
  25. */
  26. typedef int
  27. (*dns_addressorderfunc_t)(const isc_netaddr_t *address, const void *arg);
  28. /*%
  29. * Return value type for setup_sortlist.
  30. */
  31. typedef enum {
  32. NS_SORTLISTTYPE_NONE,
  33. NS_SORTLISTTYPE_1ELEMENT,
  34. NS_SORTLISTTYPE_2ELEMENT
  35. } ns_sortlisttype_t;
  36. ns_sortlisttype_t
  37. ns_sortlist_setup(dns_acl_t *acl, isc_netaddr_t *clientaddr,
  38. const void **argp);
  39. /*%<
  40. * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any.
  41. *
  42. * If a 1-element sortlist item applies, return NS_SORTLISTTYPE_1ELEMENT and
  43. * make '*argp' point to the matching subelement.
  44. *
  45. * If a 2-element sortlist item applies, return NS_SORTLISTTYPE_2ELEMENT and
  46. * make '*argp' point to ACL that forms the second element.
  47. *
  48. * If no sortlist item applies, return NS_SORTLISTTYPE_NONE and set '*argp'
  49. * to NULL.
  50. */
  51. int
  52. ns_sortlist_addrorder1(const isc_netaddr_t *addr, const void *arg);
  53. /*%<
  54. * Find the sort order of 'addr' in 'arg', the matching element
  55. * of a 1-element top-level sortlist statement.
  56. */
  57. int
  58. ns_sortlist_addrorder2(const isc_netaddr_t *addr, const void *arg);
  59. /*%<
  60. * Find the sort order of 'addr' in 'arg', a topology-like
  61. * ACL forming the second element in a 2-element top-level
  62. * sortlist statement.
  63. */
  64. void
  65. ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, isc_netaddr_t *client_addr,
  66. dns_addressorderfunc_t *orderp,
  67. const void **argp);
  68. /*%<
  69. * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any.
  70. * If a sortlist statement applies, return in '*orderp' a pointer to a function
  71. * for ranking network addresses based on that sortlist statement, and in
  72. * '*argp' an argument to pass to said function. If no sortlist statement
  73. * applies, set '*orderp' and '*argp' to NULL.
  74. */
  75. #endif /* NAMED_SORTLIST_H */