Merge branch 'vendor/GCC44'
[dragonfly.git] / contrib / bind-9.3 / bin / named / include / named / sortlist.h
1 /*
2  * Copyright (C) 2004, 2006  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000, 2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and 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
18 /* $Id: sortlist.h,v 1.4.208.3 2006/03/02 00:37:20 marka Exp $ */
19
20 #ifndef NAMED_SORTLIST_H
21 #define NAMED_SORTLIST_H 1
22
23 #include <isc/types.h>
24
25 #include <dns/types.h>
26
27 /*
28  * Type for callback functions that rank addresses.
29  */
30 typedef int 
31 (*dns_addressorderfunc_t)(const isc_netaddr_t *address, const void *arg);
32
33 /*
34  * Return value type for setup_sortlist.
35  */
36 typedef enum {
37         NS_SORTLISTTYPE_NONE,
38         NS_SORTLISTTYPE_1ELEMENT,
39         NS_SORTLISTTYPE_2ELEMENT
40 } ns_sortlisttype_t;
41
42 ns_sortlisttype_t
43 ns_sortlist_setup(dns_acl_t *acl, isc_netaddr_t *clientaddr,
44                   const void **argp);
45 /*
46  * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any.
47  *
48  * If a 1-element sortlist item applies, return NS_SORTLISTTYPE_1ELEMENT and
49  * make '*argp' point to the matching subelement.
50  *
51  * If a 2-element sortlist item applies, return NS_SORTLISTTYPE_2ELEMENT and
52  * make '*argp' point to ACL that forms the second element.
53  *
54  * If no sortlist item applies, return NS_SORTLISTTYPE_NONE and set '*argp'
55  * to NULL.
56  */
57
58 int
59 ns_sortlist_addrorder1(const isc_netaddr_t *addr, const void *arg);
60 /*
61  * Find the sort order of 'addr' in 'arg', the matching element
62  * of a 1-element top-level sortlist statement.
63  */
64
65 int
66 ns_sortlist_addrorder2(const isc_netaddr_t *addr, const void *arg);
67 /*
68  * Find the sort order of 'addr' in 'arg', a topology-like
69  * ACL forming the second element in a 2-element top-level
70  * sortlist statement.
71  */
72
73 void
74 ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, isc_netaddr_t *client_addr,
75                         dns_addressorderfunc_t *orderp,
76                         const void **argp);
77 /*
78  * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any.
79  * If a sortlist statement applies, return in '*orderp' a pointer to a function
80  * for ranking network addresses based on that sortlist statement, and in
81  * '*argp' an argument to pass to said function.  If no sortlist statement
82  * applies, set '*orderp' and '*argp' to NULL.
83  */
84
85 #endif /* NAMED_SORTLIST_H */