Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / contrib / bind-9.2.4rc7 / bin / named / include / named / sortlist.h
1 /*
2  * Copyright (C) 2004  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.2.1 2004/03/09 06:09:23 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)(isc_netaddr_t *address, 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, void **argp);
44 /*
45  * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any.
46  *
47  * If a 1-element sortlist item applies, return NS_SORTLISTTYPE_1ELEMENT and
48  * make '*argp' point to the matching subelement.
49  *
50  * If a 2-element sortlist item applies, return NS_SORTLISTTYPE_2ELEMENT and
51  * make '*argp' point to ACL that forms the second element.
52  *
53  * If no sortlist item applies, return NS_SORTLISTTYPE_NONE and set '*argp'
54  * to NULL.
55  */
56
57 int
58 ns_sortlist_addrorder1(isc_netaddr_t *addr, void *arg);
59 /*
60  * Find the sort order of 'addr' in 'arg', the matching element
61  * of a 1-element top-level sortlist statement.
62  */
63
64 int
65 ns_sortlist_addrorder2(isc_netaddr_t *addr, void *arg);
66 /*
67  * Find the sort order of 'addr' in 'arg', a topology-like
68  * ACL forming the second element in a 2-element top-level
69  * sortlist statement.
70  */
71
72 void
73 ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, isc_netaddr_t *client_addr,
74                         dns_addressorderfunc_t *orderp,
75                         void **argp);
76 /*
77  * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any.
78  * If a sortlist statement applies, return in '*orderp' a pointer to a function
79  * for ranking network addresses based on that sortlist statement, and in
80  * '*argp' an argument to pass to said function.  If no sortlist statement
81  * applies, set '*orderp' and '*argp' to NULL.
82  */
83
84 #endif /* NAMED_SORTLIST_H */