Merge branch 'vendor/NCURSES'
[dragonfly.git] / contrib / bind / lib / dns / include / dns / forward.h
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
18 /* $Id: forward.h,v 1.11 2007/06/19 23:47:16 tbox Exp $ */
19
20 #ifndef DNS_FORWARD_H
21 #define DNS_FORWARD_H 1
22
23 /*! \file dns/forward.h */
24
25 #include <isc/lang.h>
26 #include <isc/result.h>
27
28 #include <dns/types.h>
29
30 ISC_LANG_BEGINDECLS
31
32 struct dns_forwarders {
33         isc_sockaddrlist_t      addrs;
34         dns_fwdpolicy_t         fwdpolicy;
35 };
36
37 isc_result_t
38 dns_fwdtable_create(isc_mem_t *mctx, dns_fwdtable_t **fwdtablep);
39 /*%<
40  * Creates a new forwarding table.
41  *
42  * Requires:
43  * \li  mctx is a valid memory context.
44  * \li  fwdtablep != NULL && *fwdtablep == NULL
45  *
46  * Returns:
47  * \li  #ISC_R_SUCCESS
48  * \li  #ISC_R_NOMEMORY
49  */
50
51 isc_result_t
52 dns_fwdtable_add(dns_fwdtable_t *fwdtable, dns_name_t *name,
53                  isc_sockaddrlist_t *addrs, dns_fwdpolicy_t policy);
54 /*%<
55  * Adds an entry to the forwarding table.  The entry associates
56  * a domain with a list of forwarders and a forwarding policy.  The
57  * addrs list is copied if not empty, so the caller should free its copy.
58  *
59  * Requires:
60  * \li  fwdtable is a valid forwarding table.
61  * \li  name is a valid name
62  * \li  addrs is a valid list of sockaddrs, which may be empty.
63  *
64  * Returns:
65  * \li  #ISC_R_SUCCESS
66  * \li  #ISC_R_NOMEMORY
67  */
68
69 isc_result_t
70 dns_fwdtable_find(dns_fwdtable_t *fwdtable, dns_name_t *name,
71                   dns_forwarders_t **forwardersp);
72 /*%<
73  * Finds a domain in the forwarding table.  The closest matching parent
74  * domain is returned.
75  *
76  * Requires:
77  * \li  fwdtable is a valid forwarding table.
78  * \li  name is a valid name
79  * \li  forwardersp != NULL && *forwardersp == NULL
80  *
81  * Returns:
82  * \li  #ISC_R_SUCCESS
83  * \li  #ISC_R_NOTFOUND
84  */
85
86 isc_result_t
87 dns_fwdtable_find2(dns_fwdtable_t *fwdtable, dns_name_t *name,
88                    dns_name_t *foundname, dns_forwarders_t **forwardersp);
89 /*%<
90  * Finds a domain in the forwarding table.  The closest matching parent
91  * domain is returned.
92  *
93  * Requires:
94  * \li  fwdtable is a valid forwarding table.
95  * \li  name is a valid name
96  * \li  forwardersp != NULL && *forwardersp == NULL
97  * \li  foundname to be NULL or a valid name with buffer.
98  *
99  * Returns:
100  * \li  #ISC_R_SUCCESS
101  * \li  #ISC_R_NOTFOUND
102  */
103
104 void
105 dns_fwdtable_destroy(dns_fwdtable_t **fwdtablep);
106 /*%<
107  * Destroys a forwarding table.
108  *
109  * Requires:
110  * \li  fwtablep != NULL && *fwtablep != NULL
111  *
112  * Ensures:
113  * \li  all memory associated with the forwarding table is freed.
114  */
115
116 ISC_LANG_ENDDECLS
117
118 #endif /* DNS_FORWARD_H */