1/* $NetBSD: sortlist.h,v 1.2.6.1 2012/06/05 21:15:09 bouyer Exp $ */ 2 3/* 4 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 2000, 2001 Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20/* Id: sortlist.h,v 1.11 2007/06/19 23:46:59 tbox Exp */ 21 22#ifndef NAMED_SORTLIST_H 23#define NAMED_SORTLIST_H 1 24 25/*! \file */ 26 27#include <isc/types.h> 28 29#include <dns/types.h> 30 31/*% 32 * Type for callback functions that rank addresses. 33 */ 34typedef int 35(*dns_addressorderfunc_t)(const isc_netaddr_t *address, const void *arg); 36 37/*% 38 * Return value type for setup_sortlist. 39 */ 40typedef enum { 41 NS_SORTLISTTYPE_NONE, 42 NS_SORTLISTTYPE_1ELEMENT, 43 NS_SORTLISTTYPE_2ELEMENT 44} ns_sortlisttype_t; 45 46ns_sortlisttype_t 47ns_sortlist_setup(dns_acl_t *acl, isc_netaddr_t *clientaddr, 48 const void **argp); 49/*%< 50 * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any. 51 * 52 * If a 1-element sortlist item applies, return NS_SORTLISTTYPE_1ELEMENT and 53 * make '*argp' point to the matching subelement. 54 * 55 * If a 2-element sortlist item applies, return NS_SORTLISTTYPE_2ELEMENT and 56 * make '*argp' point to ACL that forms the second element. 57 * 58 * If no sortlist item applies, return NS_SORTLISTTYPE_NONE and set '*argp' 59 * to NULL. 60 */ 61 62int 63ns_sortlist_addrorder1(const isc_netaddr_t *addr, const void *arg); 64/*%< 65 * Find the sort order of 'addr' in 'arg', the matching element 66 * of a 1-element top-level sortlist statement. 67 */ 68 69int 70ns_sortlist_addrorder2(const isc_netaddr_t *addr, const void *arg); 71/*%< 72 * Find the sort order of 'addr' in 'arg', a topology-like 73 * ACL forming the second element in a 2-element top-level 74 * sortlist statement. 75 */ 76 77void 78ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, isc_netaddr_t *client_addr, 79 dns_addressorderfunc_t *orderp, 80 const void **argp); 81/*%< 82 * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any. 83 * If a sortlist statement applies, return in '*orderp' a pointer to a function 84 * for ranking network addresses based on that sortlist statement, and in 85 * '*argp' an argument to pass to said function. If no sortlist statement 86 * applies, set '*orderp' and '*argp' to NULL. 87 */ 88 89#endif /* NAMED_SORTLIST_H */ 90