]>
git.saurik.com Git - apple/network_cmds.git/blob - unbound/iterator/iter_hints.h
715ec9f4106350432b57853006fd262e855330e8
2 * iterator/iter_hints.h - iterative resolver module stub and root hints.
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
6 * This software is open source.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * This file contains functions to assist the iterator module.
40 * Keep track of stub and root hints, and read those from config.
43 #ifndef ITERATOR_ITER_HINTS_H
44 #define ITERATOR_ITER_HINTS_H
45 #include "util/storage/dnstree.h"
51 * Iterator hints structure
55 * Hints are stored in this tree. Sort order is specially chosen.
56 * first sorted on qclass. Then on dname in nsec-like order, so that
57 * a lookup on class, name will return an exact match or the closest
58 * match which gives the ancestor needed.
59 * contents of type iter_hints_stub. The class IN root is in here.
60 * uses name_tree_node from dnstree.h.
66 * Iterator hints for a particular stub.
68 struct iter_hints_stub
{
69 /** tree sorted by name, class */
70 struct name_tree_node node
;
71 /** delegation point with hint information for this stub. malloced. */
73 /** does the stub need to forego priming (like on other ports) */
79 * @return new hints or NULL on error.
81 struct iter_hints
* hints_create(void);
85 * @param hints: to delete.
87 void hints_delete(struct iter_hints
* hints
);
90 * Process hints config. Sets default values for root hints if no config.
91 * @param hints: where to store.
92 * @param cfg: config options.
95 int hints_apply_cfg(struct iter_hints
* hints
, struct config_file
* cfg
);
98 * Find root hints for the given class.
99 * @param hints: hint storage.
100 * @param qclass: class for which root hints are requested. host order.
101 * @return: NULL if no hints, or a ptr to stored hints.
103 struct delegpt
* hints_lookup_root(struct iter_hints
* hints
, uint16_t qclass
);
106 * Find next root hints (to cycle through all root hints).
107 * @param hints: hint storage
108 * @param qclass: class for which root hints are sought.
109 * 0 means give the first available root hints class.
110 * x means, give class x or a higher class if any.
111 * returns the found class in this variable.
112 * @return true if a root hint class is found.
113 * false if not root hint class is found (qclass may have been changed).
115 int hints_next_root(struct iter_hints
* hints
, uint16_t* qclass
);
118 * Given a qname/qclass combination, and the delegation point from the cache
119 * for this qname/qclass, determine if this combination indicates that a
120 * stub hint exists and must be primed.
122 * @param hints: hint storage.
123 * @param qname: The qname that generated the delegation point.
124 * @param qclass: The qclass that generated the delegation point.
125 * @param dp: The cache generated delegation point.
126 * @return: A priming delegation point if there is a stub hint that must
127 * be primed, otherwise null.
129 struct iter_hints_stub
* hints_lookup_stub(struct iter_hints
* hints
,
130 uint8_t* qname
, uint16_t qclass
, struct delegpt
* dp
);
133 * Get memory in use by hints
134 * @param hints: hint storage.
135 * @return bytes in use
137 size_t hints_get_mem(struct iter_hints
* hints
);
140 * Add stub to hints structure. For external use since it recalcs
142 * @param hints: the hints data structure
143 * @param c: class of zone
144 * @param dp: delegation point with name and target nameservers for new
145 * hints stub. malloced.
146 * @param noprime: set noprime option to true or false on new hint stub.
147 * @return false on failure (out of memory);
149 int hints_add_stub(struct iter_hints
* hints
, uint16_t c
, struct delegpt
* dp
,
153 * Remove stub from hints structure. For external use since it
154 * recalcs the tree parents.
155 * @param hints: the hints data structure
156 * @param c: class of stub zone
157 * @param nm: name of stub zone (in uncompressed wireformat).
159 void hints_delete_stub(struct iter_hints
* hints
, uint16_t c
, uint8_t* nm
);
161 #endif /* ITERATOR_ITER_HINTS_H */