00001 /* 00002 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 00003 * Copyright (C) 2000, 2001 Internet Software Consortium. 00004 * 00005 * Permission to use, copy, modify, and/or distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 00010 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00011 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 00012 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00013 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00014 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00015 * PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 /* $Id: sortlist.h,v 1.11 2007/06/19 23:46:59 tbox Exp $ */ 00019 00020 #ifndef NAMED_SORTLIST_H 00021 #define NAMED_SORTLIST_H 1 00022 00023 /*! \file */ 00024 00025 #include <isc/types.h> 00026 00027 #include <dns/types.h> 00028 00029 /*% 00030 * Type for callback functions that rank addresses. 00031 */ 00032 typedef int 00033 (*dns_addressorderfunc_t)(const isc_netaddr_t *address, const void *arg); 00034 00035 /*% 00036 * Return value type for setup_sortlist. 00037 */ 00038 typedef enum { 00039 NS_SORTLISTTYPE_NONE, 00040 NS_SORTLISTTYPE_1ELEMENT, 00041 NS_SORTLISTTYPE_2ELEMENT 00042 } ns_sortlisttype_t; 00043 00044 ns_sortlisttype_t 00045 ns_sortlist_setup(dns_acl_t *acl, isc_netaddr_t *clientaddr, 00046 const void **argp); 00047 /*%< 00048 * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any. 00049 * 00050 * If a 1-element sortlist item applies, return NS_SORTLISTTYPE_1ELEMENT and 00051 * make '*argp' point to the matching subelement. 00052 * 00053 * If a 2-element sortlist item applies, return NS_SORTLISTTYPE_2ELEMENT and 00054 * make '*argp' point to ACL that forms the second element. 00055 * 00056 * If no sortlist item applies, return NS_SORTLISTTYPE_NONE and set '*argp' 00057 * to NULL. 00058 */ 00059 00060 int 00061 ns_sortlist_addrorder1(const isc_netaddr_t *addr, const void *arg); 00062 /*%< 00063 * Find the sort order of 'addr' in 'arg', the matching element 00064 * of a 1-element top-level sortlist statement. 00065 */ 00066 00067 int 00068 ns_sortlist_addrorder2(const isc_netaddr_t *addr, const void *arg); 00069 /*%< 00070 * Find the sort order of 'addr' in 'arg', a topology-like 00071 * ACL forming the second element in a 2-element top-level 00072 * sortlist statement. 00073 */ 00074 00075 void 00076 ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, isc_netaddr_t *client_addr, 00077 dns_addressorderfunc_t *orderp, 00078 const void **argp); 00079 /*%< 00080 * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any. 00081 * If a sortlist statement applies, return in '*orderp' a pointer to a function 00082 * for ranking network addresses based on that sortlist statement, and in 00083 * '*argp' an argument to pass to said function. If no sortlist statement 00084 * applies, set '*orderp' and '*argp' to NULL. 00085 */ 00086 00087 #endif /* NAMED_SORTLIST_H */