2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2002 Internet Software Consortium.
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.
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.
18 /* $Id: rbt.h,v 1.55.12.6 2004/10/11 05:55:51 marka Exp $ */
24 #include <isc/magic.h>
26 #include <dns/types.h>
30 #define DNS_RBT_USEHASH 1
33 * Option values for dns_rbt_findnode() and dns_rbt_findname().
34 * These are used to form a bitmask.
36 #define DNS_RBTFIND_NOOPTIONS 0x00
37 #define DNS_RBTFIND_EMPTYDATA 0x01
38 #define DNS_RBTFIND_NOEXACT 0x02
39 #define DNS_RBTFIND_NOPREDECESSOR 0x04
42 * These should add up to 30.
44 #define DNS_RBT_LOCKLENGTH 10
45 #define DNS_RBT_REFLENGTH 20
47 #define DNS_RBTNODE_MAGIC ISC_MAGIC('R','B','N','O')
49 #define DNS_RBTNODE_VALID(n) ISC_MAGIC_VALID(n, DNS_RBTNODE_MAGIC)
51 #define DNS_RBTNODE_VALID(n) ISC_TRUE
55 * This is the structure that is used for each node in the red/black
56 * tree of trees. NOTE WELL: the implementation manages this as a variable
57 * length structure, with the actual wire-format name and other data
58 * appended to this structure. Allocating a contiguous block of memory for
59 * multiple dns_rbtnode structures will not work.
61 typedef struct dns_rbtnode {
65 struct dns_rbtnode *parent;
66 struct dns_rbtnode *left;
67 struct dns_rbtnode *right;
68 struct dns_rbtnode *down;
69 #ifdef DNS_RBT_USEHASH
70 struct dns_rbtnode *hashnext;
73 * The following bitfields add up to a total bitwidth of 32.
74 * The range of values necessary for each item is indicated,
75 * but in the case of "attributes" the field is wider to accomodate
76 * possible future expansion. "offsetlen" could be one bit
77 * narrower by always adjusting its value by 1 to find the real
78 * offsetlen, but doing so does not gain anything (except perhaps
79 * another bit for "attributes", which doesn't yet need any more).
81 * In each case below the "range" indicated is what's _necessary_ for
82 * the bitfield to hold, not what it actually _can_ hold.
84 unsigned int is_root : 1; /* range is 0..1 */
85 unsigned int color : 1; /* range is 0..1 */
86 unsigned int find_callback : 1; /* range is 0..1 */
87 unsigned int attributes : 4; /* range is 0..2 */
88 unsigned int namelen : 8; /* range is 1..255 */
89 unsigned int offsetlen : 8; /* range is 1..128 */
90 unsigned int padbytes : 9; /* range is 0..380 */
92 #ifdef DNS_RBT_USEHASH
97 * These values are used in the RBT DB implementation. The appropriate
98 * node lock must be held before accessing them.
101 unsigned int dirty:1;
103 unsigned int locknum:DNS_RBT_LOCKLENGTH;
104 unsigned int references:DNS_RBT_REFLENGTH;
107 typedef isc_result_t (*dns_rbtfindcallback_t)(dns_rbtnode_t *node,
116 * A chain is used to keep track of the sequence of nodes to reach any given
117 * node from the root of the tree. Originally nodes did not have parent
118 * pointers in them (for memory usage reasons) so there was no way to find
119 * the path back to the root from any given node. Now that nodes have parent
120 * pointers, chains might be going away in a future release, though the
121 * movement functionality would remain.
123 * In any event, parent information, whether via parent pointers or chains, is
124 * necessary information for iterating through the tree or for basic internal
125 * tree maintenance issues (ie, the rotations that are done to rebalance the
126 * tree when a node is added). The obvious implication of this is that for a
127 * chain to remain valid, the tree has to be locked down against writes for the
128 * duration of the useful life of the chain, because additions or removals can
129 * change the path from the root to the node the chain has targetted.
131 * The dns_rbtnodechain_ functions _first, _last, _prev and _next all take
132 * dns_name_t parameters for the name and the origin, which can be NULL. If
133 * non-NULL, 'name' will end up pointing to the name data and offsets that are
134 * stored at the node (and thus it will be read-only), so it should be a
135 * regular dns_name_t that has been initialized with dns_name_init. When
136 * 'origin' is non-NULL, it will get the name of the origin stored in it, so it
137 * needs to have its own buffer space and offsets, which is most easily
138 * accomplished with a dns_fixedname_t. It is _not_ necessary to reinitialize
139 * either 'name' or 'origin' between calls to the chain functions.
141 * NOTE WELL: even though the name data at the root of the tree of trees will
142 * be absolute (typically just "."), it will will be made into a relative name
143 * with an origin of "." -- an empty name when the node is ".". This is
144 * because a common on operation on 'name' and 'origin' is to use
145 * dns_name_concatenate() on them to generate the complete name. An empty name
146 * can be detected when dns_name_countlabels == 0, and is printed by
147 * dns_name_totext()/dns_name_format() as "@", consistent with RFC1035's
148 * definition of "@" as the current origin.
150 * dns_rbtnodechain_current is similar to the _first, _last, _prev and _next
151 * functions but additionally can provide the node to which the chain points.
155 * The number of level blocks to allocate at a time. Currently the maximum
156 * number of levels is allocated directly in the structure, but future
157 * revisions of this code might have a static initial block with dynamic
158 * growth. Allocating space for 256 levels when the tree is almost never that
159 * deep is wasteful, but it's not clear that it matters, since the waste is
160 * only 2MB for 1000 concurrently active chains on a system with 64-bit
163 #define DNS_RBT_LEVELBLOCK 254
165 typedef struct dns_rbtnodechain {
169 * The terminal node of the chain. It is not in levels[].
170 * This is ostensibly private ... but in a pinch it could be
171 * used tell that the chain points nowhere without needing to
172 * call dns_rbtnodechain_current().
176 * The maximum number of labels in a name is 128; bitstrings mean
177 * a conceptually very large number (which I have not bothered to
178 * compute) of logical levels because splitting can potentially occur
179 * at each bit. However, DNSSEC restricts the number of "logical"
180 * labels in a name to 255, meaning only 254 pointers are needed
183 dns_rbtnode_t * levels[DNS_RBT_LEVELBLOCK];
185 * level_count indicates how deep the chain points into the
186 * tree of trees, and is the index into the levels[] array.
187 * Thus, levels[level_count - 1] is the last level node stored.
188 * A chain that points to the top level of the tree of trees has
189 * a level_count of 0, the first level has a level_count of 1, and
192 unsigned int level_count;
194 * level_matches tells how many levels matched above the node
195 * returned by dns_rbt_findnode(). A match (partial or exact) found
196 * in the first level thus results in level_matches being set to 1.
197 * This is used by the rbtdb to set the start point for a recursive
198 * search of superdomains until the RR it is looking for is found.
200 unsigned int level_matches;
201 } dns_rbtnodechain_t;
204 ***** Public interfaces.
208 dns_rbt_create(isc_mem_t *mctx, void (*deleter)(void *, void *),
209 void *deleter_arg, dns_rbt_t **rbtp);
211 * Initialize a red-black tree of trees.
214 * The deleter argument, if non-null, points to a function that is
215 * responsible for cleaning up any memory associated with the data
216 * pointer of a node when the node is deleted. It is passed the
217 * deleted node's data pointer as its first argument and deleter_arg
218 * as its second argument.
221 * mctx is a pointer to a valid memory context.
222 * rbtp != NULL && *rbtp == NULL
223 * arg == NULL iff deleter == NULL
226 * If result is ISC_R_SUCCESS:
227 * *rbtp points to a valid red-black tree manager
229 * If result is failure:
230 * *rbtp does not point to a valid red-black tree manager.
233 * ISC_R_SUCCESS Success
234 * ISC_R_NOMEMORY Resource limit: Out of Memory
238 dns_rbt_addname(dns_rbt_t *rbt, dns_name_t *name, void *data);
240 * Add 'name' to the tree of trees, associated with 'data'.
243 * 'data' is never required to be non-NULL, but specifying it
244 * when the name is added is faster than searching for 'name'
245 * again and then setting the data pointer. The lack of a data pointer
246 * for a node also has other ramifications regarding whether
247 * dns_rbt_findname considers a node to exist, or dns_rbt_deletename
251 * rbt is a valid rbt manager.
252 * dns_name_isabsolute(name) == TRUE
255 * 'name' is not altered in any way.
257 * Any external references to nodes in the tree are unaffected by
258 * node splits that are necessary to insert the new name.
260 * If result is ISC_R_SUCCESS:
261 * 'name' is findable in the red/black tree of trees in O(log N).
263 * The data pointer of the node for 'name' is set to 'data'.
265 * If result is ISC_R_EXISTS or ISC_R_NOSPACE:
266 * The tree of trees is unaltered.
268 * If result is ISC_R_NOMEMORY:
272 * ISC_R_SUCCESS Success
273 * ISC_R_EXISTS The name already exists with associated data.
274 * ISC_R_NOSPACE The name had more logical labels than are allowed.
275 * ISC_R_NOMEMORY Resource Limit: Out of Memory
279 dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep);
282 * Just like dns_rbt_addname, but returns the address of the node.
285 * rbt is a valid rbt structure.
286 * dns_name_isabsolute(name) == TRUE
287 * nodep != NULL && *nodep == NULL
290 * 'name' is not altered in any way.
292 * Any external references to nodes in the tree are unaffected by
293 * node splits that are necessary to insert the new name.
295 * If result is ISC_R_SUCCESS:
296 * 'name' is findable in the red/black tree of trees in O(log N).
298 * *nodep is the node that was added for 'name'.
300 * If result is ISC_R_EXISTS:
301 * The tree of trees is unaltered.
303 * *nodep is the existing node for 'name'.
305 * If result is ISC_R_NOMEMORY:
309 * ISC_R_SUCCESS Success
310 * ISC_R_EXISTS The name already exists, possibly without data.
311 * ISC_R_NOMEMORY Resource Limit: Out of Memory
315 dns_rbt_findname(dns_rbt_t *rbt, dns_name_t *name, unsigned int options,
316 dns_name_t *foundname, void **data);
318 * Get the data pointer associated with 'name'.
321 * When DNS_RBTFIND_NOEXACT is set, the closest matching superdomain is
322 * returned (also subject to DNS_RBTFIND_EMPTYDATA), even when there is
323 * an exact match in the tree.
325 * A node that has no data is considered not to exist for this function,
326 * unless the DNS_RBTFIND_EMPTYDATA option is set.
329 * rbt is a valid rbt manager.
330 * dns_name_isabsolute(name) == TRUE
331 * data != NULL && *data == NULL
334 * 'name' and the tree are not altered in any way.
336 * If result is ISC_R_SUCCESS:
337 * *data is the data associated with 'name'.
339 * If result is DNS_R_PARTIALMATCH:
340 * *data is the data associated with the deepest superdomain
341 * of 'name' which has data.
343 * If result is ISC_R_NOTFOUND:
344 * Neither the name nor a superdomain was found with data.
347 * ISC_R_SUCCESS Success
348 * DNS_R_PARTIALMATCH Superdomain found with data
349 * ISC_R_NOTFOUND No match
350 * ISC_R_NOSPACE Concatenating nodes to form foundname failed
354 dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname,
355 dns_rbtnode_t **node, dns_rbtnodechain_t *chain,
356 unsigned int options, dns_rbtfindcallback_t callback,
359 * Find the node for 'name'.
362 * A node that has no data is considered not to exist for this function,
363 * unless the DNS_RBTFIND_EMPTYDATA option is set. This applies to both
364 * exact matches and partial matches.
366 * If the chain parameter is non-NULL, then the path through the tree
367 * to the DNSSEC predecessor of the searched for name is maintained,
368 * unless the DNS_RBTFIND_NOPREDECESSOR or DNS_RBTFIND_NOEXACT option
369 * is used. (For more details on those options, see below.)
371 * If there is no predecessor, then the chain will point to nowhere, as
372 * indicated by chain->end being NULL or dns_rbtnodechain_current
373 * returning ISC_R_NOTFOUND. Note that in a normal Internet DNS RBT
374 * there will always be a predecessor for all names except the root
375 * name, because '.' will exist and '.' is the predecessor of
376 * everything. But you can certainly construct a trivial tree and a
377 * search for it that has no predecessor.
379 * Within the chain structure, the 'levels' member of the structure holds
380 * the root node of each level except the first.
382 * The 'level_count' of the chain indicates how deep the chain to the
383 * predecessor name is, as an index into the 'levels[]' array. It does
384 * not count name elements, per se, but only levels of the tree of trees,
385 * the distinction arrising because multiple labels from a name can be
386 * stored on only one level. It is also does not include the level
387 * that has the node, since that level is not stored in levels[].
389 * The chain's 'level_matches' is not directly related to the predecessor.
390 * It is the number of levels above the level of the found 'node',
391 * regardless of whether it was a partial match or exact match. When
392 * the node is found in the top level tree, or no node is found at all,
393 * level_matches is 0.
395 * When DNS_RBTFIND_NOEXACT is set, the closest matching superdomain is
396 * returned (also subject to DNS_RBTFIND_EMPTYDATA), even when
397 * there is an exact match in the tree. In this case, the chain
398 * will not point to the DNSSEC predecessor, but will instead point
399 * to the exact match, if there was any. Thus the preceding paragraphs
400 * should have "exact match" substituted for "predecessor" to describe
401 * how the various elements of the chain are set. This was done to
402 * ensure that the chain's state was sane, and to prevent problems that
403 * occurred when running the predecessor location code under conditions
404 * it was not designed for. It is not clear *where* the chain should
405 * point when DNS_RBTFIND_NOEXACT is set, so if you end up using a chain
406 * with this option because you want a particular node, let us know
407 * where you want the chain pointed, so this can be made more firm.
410 * rbt is a valid rbt manager.
411 * dns_name_isabsolute(name) == TRUE.
412 * node != NULL && *node == NULL.
413 * DNS_RBTFIND_NOEXACT and DNS_RBTFIND_NOPREDECESSOR are mutally
417 * 'name' and the tree are not altered in any way.
419 * If result is ISC_R_SUCCESS:
420 * *node is the terminal node for 'name'.
422 * 'foundname' and 'name' represent the same name (though not
425 * 'chain' points to the DNSSEC predecessor, if any, of 'name'.
427 * chain->level_matches and chain->level_count are equal.
429 * If result is DNS_R_PARTIALMATCH:
430 * *node is the data associated with the deepest superdomain
431 * of 'name' which has data.
433 * 'foundname' is the name of deepest superdomain (which has
434 * data, unless the DNS_RBTFIND_EMPTYDATA option is set).
436 * 'chain' points to the DNSSEC predecessor, if any, of 'name'.
438 * If result is ISC_R_NOTFOUND:
439 * Neither the name nor a superdomain was found. *node is NULL.
441 * 'chain' points to the DNSSEC predecessor, if any, of 'name'.
443 * chain->level_matches is 0.
446 * ISC_R_SUCCESS Success
447 * DNS_R_PARTIALMATCH Superdomain found with data
448 * ISC_R_NOTFOUND No match, or superdomain with no data
449 * ISC_R_NOSPACE Concatenating nodes to form foundname failed
453 dns_rbt_deletename(dns_rbt_t *rbt, dns_name_t *name, isc_boolean_t recurse);
455 * Delete 'name' from the tree of trees.
458 * When 'name' is removed, if recurse is ISC_TRUE then all of its
459 * subnames are removed too.
462 * rbt is a valid rbt manager.
463 * dns_name_isabsolute(name) == TRUE
466 * 'name' is not altered in any way.
468 * Does NOT ensure that any external references to nodes in the tree
469 * are unaffected by node joins.
471 * If result is ISC_R_SUCCESS:
472 * 'name' does not appear in the tree with data; however,
473 * the node for the name might still exist which can be
474 * found with dns_rbt_findnode (but not dns_rbt_findname).
476 * If result is ISC_R_NOTFOUND:
477 * 'name' does not appear in the tree with data, because
478 * it did not appear in the tree before the function was called.
480 * If result is something else:
481 * See result codes for dns_rbt_findnode (if it fails, the
482 * node is not deleted) or dns_rbt_deletenode (if it fails,
483 * the node is deleted, but the tree is not optimized when
484 * it could have been).
487 * ISC_R_SUCCESS Success
488 * ISC_R_NOTFOUND No match
489 * something_else Any return code from dns_rbt_findnode except
490 * DNS_R_PARTIALMATCH (which causes ISC_R_NOTFOUND
491 * to be returned instead), and any code from
492 * dns_rbt_deletenode.
496 dns_rbt_deletenode(dns_rbt_t *rbt, dns_rbtnode_t *node, isc_boolean_t recurse);
498 * Delete 'node' from the tree of trees.
501 * When 'node' is removed, if recurse is ISC_TRUE then all nodes
502 * in levels down from it are removed too.
505 * rbt is a valid rbt manager.
509 * Does NOT ensure that any external references to nodes in the tree
510 * are unaffected by node joins.
512 * If result is ISC_R_SUCCESS:
513 * 'node' does not appear in the tree with data; however,
514 * the node might still exist if it serves as a pointer to
515 * a lower tree level as long as 'recurse' was false, hence
516 * the node could can be found with dns_rbt_findnode whem
517 * that function's empty_data_ok parameter is true.
519 * If result is ISC_R_NOMEMORY or ISC_R_NOSPACE:
520 * The node was deleted, but the tree structure was not
524 * ISC_R_SUCCESS Success
525 * ISC_R_NOMEMORY Resource Limit: Out of Memory when joining nodes.
526 * ISC_R_NOSPACE dns_name_concatenate failed when joining nodes.
530 dns_rbt_namefromnode(dns_rbtnode_t *node, dns_name_t *name);
532 * Convert the sequence of labels stored at 'node' into a 'name'.
535 * This function does not return the full name, from the root, but
536 * just the labels at the indicated node.
538 * The name data pointed to by 'name' is the information stored
539 * in the node, not a copy. Altering the data at this pointer
540 * will likely cause grief.
543 * name->offsets == NULL
546 * 'name' is DNS_NAMEATTR_READONLY.
548 * 'name' will point directly to the labels stored after the
549 * dns_rbtnode_t struct.
551 * 'name' will have offsets that also point to the information stored
552 * as part of the node.
556 dns_rbt_fullnamefromnode(dns_rbtnode_t *node, dns_name_t *name);
558 * Like dns_rbt_namefromnode, but returns the full name from the root.
561 * Unlike dns_rbt_namefromnode, the name will not point directly
562 * to node data. Rather, dns_name_concatenate will be used to copy
563 * the name data from each node into the 'name' argument.
567 * name has a dedicated buffer.
571 * ISC_R_NOSPACE (possible via dns_name_concatenate)
572 * DNS_R_NAMETOOLONG (possible via dns_name_concatenate)
576 dns_rbt_formatnodename(dns_rbtnode_t *node, char *printname,
579 * Format the full name of a node for printing, using dns_name_format().
582 * 'size' is the length of the printname buffer. This should be
583 * DNS_NAME_FORMATSIZE or larger.
586 * node and printname are not NULL.
589 * The 'printname' pointer.
593 dns_rbt_nodecount(dns_rbt_t *rbt);
595 * Obtain the number of nodes in the tree of trees.
598 * rbt is a valid rbt manager.
602 dns_rbt_destroy(dns_rbt_t **rbtp);
604 dns_rbt_destroy2(dns_rbt_t **rbtp, unsigned int quantum);
606 * Stop working with a red-black tree of trees.
607 * If 'quantum' is zero then the entire tree will be destroyed.
608 * If 'quantum' is non zero then up to 'quantum' nodes will be destroyed
609 * allowing the rbt to be incrementally destroyed by repeated calls to
610 * dns_rbt_destroy2(). Once dns_rbt_destroy2() has been called no other
611 * operations than dns_rbt_destroy()/dns_rbt_destroy2() should be
612 * performed on the tree of trees.
615 * *rbt is a valid rbt manager.
617 * Ensures on ISC_R_SUCCESS:
618 * All space allocated by the RBT library has been returned.
620 * *rbt is invalidated as an rbt manager.
624 * ISC_R_QUOTA if 'quantum' nodes have been destroyed.
628 dns_rbt_printall(dns_rbt_t *rbt);
630 * Print an ASCII representation of the internal structure of the red-black
634 * The name stored at each node, along with the node's color, is printed.
635 * Then the down pointer, left and right pointers are displayed
636 * recursively in turn. NULL down pointers are silently omitted;
637 * NULL left and right pointers are printed.
641 ***** Chain Functions
645 dns_rbtnodechain_init(dns_rbtnodechain_t *chain, isc_mem_t *mctx);
647 * Initialize 'chain'.
650 * 'chain' is a valid pointer.
652 * 'mctx' is a valid memory context.
655 * 'chain' is suitable for use.
659 dns_rbtnodechain_reset(dns_rbtnodechain_t *chain);
661 * Free any dynamic storage associated with 'chain', and then reinitialize
665 * 'chain' is a valid pointer.
668 * 'chain' is suitable for use, and uses no dynamic storage.
672 dns_rbtnodechain_invalidate(dns_rbtnodechain_t *chain);
674 * Free any dynamic storage associated with 'chain', and then invalidates it.
677 * Future calls to any dns_rbtnodechain_ function will need to call
678 * dns_rbtnodechain_init on the chain first (except, of course,
679 * dns_rbtnodechain_init itself).
682 * 'chain' is a valid chain.
685 * 'chain' is no longer suitable for use, and uses no dynamic storage.
689 dns_rbtnodechain_current(dns_rbtnodechain_t *chain, dns_name_t *name,
690 dns_name_t *origin, dns_rbtnode_t **node);
692 * Provide the name, origin and node to which the chain is currently pointed.
695 * The tree need not have be locked against additions for the chain
696 * to remain valid, however there are no guarantees if any deletion
697 * has been made since the chain was established.
700 * 'chain' is a valid chain.
703 * 'node', if non-NULL, is the node to which the chain was pointed
704 * by dns_rbt_findnode, dns_rbtnodechain_first or dns_rbtnodechain_last.
705 * If none were called for the chain since it was initialized or reset,
706 * or if the was no predecessor to the name searched for with
707 * dns_rbt_findnode, then '*node' is NULL and ISC_R_NOTFOUND is returned.
709 * 'name', if non-NULL, is the name stored at the terminal level of
710 * the chain. This is typically a single label, like the "www" of
711 * "www.isc.org", but need not be so. At the root of the tree of trees,
712 * if the node is "." then 'name' is ".", otherwise it is relative to ".".
713 * (Minimalist and atypical case: if the tree has just the name
714 * "isc.org." then the root node's stored name is "isc.org." but 'name'
715 * will be "isc.org".)
717 * 'origin', if non-NULL, is the sequence of labels in the levels
718 * above the terminal level, such as "isc.org." in the above example.
719 * 'origin' is always "." for the root node.
723 * ISC_R_SUCCESS name, origin & node were successfully set.
724 * ISC_R_NOTFOUND The chain does not point to any node.
725 * <something_else> Any error return from dns_name_concatenate.
729 dns_rbtnodechain_first(dns_rbtnodechain_t *chain, dns_rbt_t *rbt,
730 dns_name_t *name, dns_name_t *origin);
732 * Set the chain to the lexically first node in the tree of trees.
735 * By the definition of ordering for DNS names, the root of the tree of
736 * trees is the very first node, since everything else in the megatree
737 * uses it as a common suffix.
740 * 'chain' is a valid chain.
741 * 'rbt' is a valid rbt manager.
744 * The chain points to the very first node of the tree.
746 * 'name' and 'origin', if non-NULL, are set as described for
747 * dns_rbtnodechain_current. Thus 'origin' will always be ".".
750 * DNS_R_NEWORIGIN The name & origin were successfully set.
751 * <something_else> Any error result from dns_rbtnodechain_current.
755 dns_rbtnodechain_last(dns_rbtnodechain_t *chain, dns_rbt_t *rbt,
756 dns_name_t *name, dns_name_t *origin);
758 * Set the chain to the lexically last node in the tree of trees.
761 * 'chain' is a valid chain.
762 * 'rbt' is a valid rbt manager.
765 * The chain points to the very last node of the tree.
767 * 'name' and 'origin', if non-NULL, are set as described for
768 * dns_rbtnodechain_current.
771 * DNS_R_NEWORIGIN The name & origin were successfully set.
772 * ISC_R_NOMEMORY Resource Limit: Out of Memory building chain.
773 * <something_else> Any error result from dns_name_concatenate.
777 dns_rbtnodechain_prev(dns_rbtnodechain_t *chain, dns_name_t *name,
780 * Adjusts chain to point the DNSSEC predecessor of the name to which it
781 * is currently pointed.
784 * 'chain' is a valid chain.
785 * 'chain' has been pointed somewhere in the tree with dns_rbt_findnode,
786 * dns_rbtnodechain_first or dns_rbtnodechain_last -- and remember that
787 * dns_rbt_findnode is not guaranteed to point the chain somewhere,
788 * since there may have been no predecessor to the searched for name.
791 * The chain is pointed to the predecessor of its current target.
793 * 'name' and 'origin', if non-NULL, are set as described for
794 * dns_rbtnodechain_current.
796 * 'origin' is only if a new origin was found.
799 * ISC_R_SUCCESS The predecessor was found and 'name' was set.
800 * DNS_R_NEWORIGIN The predecessor was found with a different
801 * origin and 'name' and 'origin' were set.
802 * ISC_R_NOMORE There was no predecessor.
803 * <something_else> Any error result from dns_rbtnodechain_current.
807 dns_rbtnodechain_next(dns_rbtnodechain_t *chain, dns_name_t *name,
810 * Adjusts chain to point the DNSSEC successor of the name to which it
811 * is currently pointed.
814 * 'chain' is a valid chain.
815 * 'chain' has been pointed somewhere in the tree with dns_rbt_findnode,
816 * dns_rbtnodechain_first or dns_rbtnodechain_last -- and remember that
817 * dns_rbt_findnode is not guaranteed to point the chain somewhere,
818 * since there may have been no predecessor to the searched for name.
821 * The chain is pointed to the successor of its current target.
823 * 'name' and 'origin', if non-NULL, are set as described for
824 * dns_rbtnodechain_current.
826 * 'origin' is only if a new origin was found.
829 * ISC_R_SUCCESS The successor was found and 'name' was set.
830 * DNS_R_NEWORIGIN The successor was found with a different
831 * origin and 'name' and 'origin' were set.
832 * ISC_R_NOMORE There was no successor.
833 * <something_else> Any error result from dns_name_concatenate.
838 #endif /* DNS_RBT_H */