Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/bind9/dns
File: rbt.h
/*
[0] Fix | Delete
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
[1] Fix | Delete
*
[2] Fix | Delete
* This Source Code Form is subject to the terms of the Mozilla Public
[3] Fix | Delete
* License, v. 2.0. If a copy of the MPL was not distributed with this
[4] Fix | Delete
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
[5] Fix | Delete
*
[6] Fix | Delete
* See the COPYRIGHT file distributed with this work for additional
[7] Fix | Delete
* information regarding copyright ownership.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
[11] Fix | Delete
#ifndef DNS_RBT_H
[12] Fix | Delete
#define DNS_RBT_H 1
[13] Fix | Delete
[14] Fix | Delete
/*! \file dns/rbt.h */
[15] Fix | Delete
[16] Fix | Delete
#include <inttypes.h>
[17] Fix | Delete
#include <stdbool.h>
[18] Fix | Delete
[19] Fix | Delete
#include <isc/assertions.h>
[20] Fix | Delete
#include <isc/crc64.h>
[21] Fix | Delete
#include <isc/lang.h>
[22] Fix | Delete
#include <isc/magic.h>
[23] Fix | Delete
#include <isc/refcount.h>
[24] Fix | Delete
[25] Fix | Delete
#include <dns/types.h>
[26] Fix | Delete
[27] Fix | Delete
ISC_LANG_BEGINDECLS
[28] Fix | Delete
[29] Fix | Delete
#define DNS_RBT_USEHASH 1
[30] Fix | Delete
[31] Fix | Delete
/*@{*/
[32] Fix | Delete
/*%
[33] Fix | Delete
* Option values for dns_rbt_findnode() and dns_rbt_findname().
[34] Fix | Delete
* These are used to form a bitmask.
[35] Fix | Delete
*/
[36] Fix | Delete
#define DNS_RBTFIND_NOOPTIONS 0x00
[37] Fix | Delete
#define DNS_RBTFIND_EMPTYDATA 0x01
[38] Fix | Delete
#define DNS_RBTFIND_NOEXACT 0x02
[39] Fix | Delete
#define DNS_RBTFIND_NOPREDECESSOR 0x04
[40] Fix | Delete
/*@}*/
[41] Fix | Delete
[42] Fix | Delete
#ifndef DNS_RBT_USEISCREFCOUNT
[43] Fix | Delete
#ifdef ISC_REFCOUNT_HAVEATOMIC
[44] Fix | Delete
#define DNS_RBT_USEISCREFCOUNT 1
[45] Fix | Delete
#endif
[46] Fix | Delete
#endif
[47] Fix | Delete
[48] Fix | Delete
#define DNS_RBT_USEMAGIC 1
[49] Fix | Delete
[50] Fix | Delete
/*
[51] Fix | Delete
* These should add up to 30.
[52] Fix | Delete
*/
[53] Fix | Delete
#define DNS_RBT_LOCKLENGTH 10
[54] Fix | Delete
#define DNS_RBT_REFLENGTH 20
[55] Fix | Delete
[56] Fix | Delete
#define DNS_RBTNODE_MAGIC ISC_MAGIC('R','B','N','O')
[57] Fix | Delete
#if DNS_RBT_USEMAGIC
[58] Fix | Delete
#define DNS_RBTNODE_VALID(n) ISC_MAGIC_VALID(n, DNS_RBTNODE_MAGIC)
[59] Fix | Delete
#else
[60] Fix | Delete
#define DNS_RBTNODE_VALID(n) true
[61] Fix | Delete
#endif
[62] Fix | Delete
[63] Fix | Delete
/*%
[64] Fix | Delete
* This is the structure that is used for each node in the red/black
[65] Fix | Delete
* tree of trees. NOTE WELL: the implementation manages this as a variable
[66] Fix | Delete
* length structure, with the actual wire-format name and other data
[67] Fix | Delete
* appended to this structure. Allocating a contiguous block of memory for
[68] Fix | Delete
* multiple dns_rbtnode structures will not work.
[69] Fix | Delete
*/
[70] Fix | Delete
typedef struct dns_rbtnode dns_rbtnode_t;
[71] Fix | Delete
enum {
[72] Fix | Delete
DNS_RBT_NSEC_NORMAL=0, /* in main tree */
[73] Fix | Delete
DNS_RBT_NSEC_HAS_NSEC=1, /* also has node in nsec tree */
[74] Fix | Delete
DNS_RBT_NSEC_NSEC=2, /* in nsec tree */
[75] Fix | Delete
DNS_RBT_NSEC_NSEC3=3 /* in nsec3 tree */
[76] Fix | Delete
};
[77] Fix | Delete
struct dns_rbtnode {
[78] Fix | Delete
#if DNS_RBT_USEMAGIC
[79] Fix | Delete
unsigned int magic;
[80] Fix | Delete
#endif
[81] Fix | Delete
/*@{*/
[82] Fix | Delete
/*!
[83] Fix | Delete
* The following bitfields add up to a total bitwidth of 32.
[84] Fix | Delete
* The range of values necessary for each item is indicated,
[85] Fix | Delete
* but in the case of "attributes" the field is wider to accommodate
[86] Fix | Delete
* possible future expansion.
[87] Fix | Delete
*
[88] Fix | Delete
* In each case below the "range" indicated is what's _necessary_ for
[89] Fix | Delete
* the bitfield to hold, not what it actually _can_ hold.
[90] Fix | Delete
*
[91] Fix | Delete
* Note: Tree lock must be held before modifying these
[92] Fix | Delete
* bit-fields.
[93] Fix | Delete
*
[94] Fix | Delete
* Note: The two "unsigned int :0;" unnamed bitfields on either
[95] Fix | Delete
* side of the bitfields below are scaffolding that border the
[96] Fix | Delete
* set of bitfields which are accessed after acquiring the tree
[97] Fix | Delete
* lock. Please don't insert any other bitfield members between
[98] Fix | Delete
* the unnamed bitfields unless they should also be accessed
[99] Fix | Delete
* after acquiring the tree lock.
[100] Fix | Delete
*/
[101] Fix | Delete
unsigned int :0; /* start of bitfields c/o tree lock */
[102] Fix | Delete
unsigned int is_root : 1; /*%< range is 0..1 */
[103] Fix | Delete
unsigned int color : 1; /*%< range is 0..1 */
[104] Fix | Delete
unsigned int find_callback : 1; /*%< range is 0..1 */
[105] Fix | Delete
unsigned int attributes : 3; /*%< range is 0..2 */
[106] Fix | Delete
unsigned int nsec : 2; /*%< range is 0..3 */
[107] Fix | Delete
unsigned int namelen : 8; /*%< range is 1..255 */
[108] Fix | Delete
unsigned int offsetlen : 8; /*%< range is 1..128 */
[109] Fix | Delete
unsigned int oldnamelen : 8; /*%< range is 1..255 */
[110] Fix | Delete
/*@}*/
[111] Fix | Delete
[112] Fix | Delete
/* flags needed for serialization to file*/
[113] Fix | Delete
unsigned int is_mmapped : 1;
[114] Fix | Delete
unsigned int parent_is_relative : 1;
[115] Fix | Delete
unsigned int left_is_relative : 1;
[116] Fix | Delete
unsigned int right_is_relative : 1;
[117] Fix | Delete
unsigned int down_is_relative : 1;
[118] Fix | Delete
unsigned int data_is_relative : 1;
[119] Fix | Delete
[120] Fix | Delete
/* node needs to be cleaned from rpz */
[121] Fix | Delete
unsigned int rpz : 1;
[122] Fix | Delete
unsigned int :0; /* end of bitfields c/o tree lock */
[123] Fix | Delete
[124] Fix | Delete
#ifdef DNS_RBT_USEHASH
[125] Fix | Delete
unsigned int hashval;
[126] Fix | Delete
dns_rbtnode_t *uppernode;
[127] Fix | Delete
dns_rbtnode_t *hashnext;
[128] Fix | Delete
#endif
[129] Fix | Delete
dns_rbtnode_t *parent;
[130] Fix | Delete
dns_rbtnode_t *left;
[131] Fix | Delete
dns_rbtnode_t *right;
[132] Fix | Delete
dns_rbtnode_t *down;
[133] Fix | Delete
[134] Fix | Delete
/*%
[135] Fix | Delete
* Used for LRU cache. This linked list is used to mark nodes which
[136] Fix | Delete
* have no data any longer, but we cannot unlink at that exact moment
[137] Fix | Delete
* because we did not or could not obtain a write lock on the tree.
[138] Fix | Delete
*/
[139] Fix | Delete
ISC_LINK(dns_rbtnode_t) deadlink;
[140] Fix | Delete
[141] Fix | Delete
/*@{*/
[142] Fix | Delete
/*!
[143] Fix | Delete
* These values are used in the RBT DB implementation. The appropriate
[144] Fix | Delete
* node lock must be held before accessing them.
[145] Fix | Delete
*
[146] Fix | Delete
* Note: The two "unsigned int :0;" unnamed bitfields on either
[147] Fix | Delete
* side of the bitfields below are scaffolding that border the
[148] Fix | Delete
* set of bitfields which are accessed after acquiring the node
[149] Fix | Delete
* lock. Please don't insert any other bitfield members between
[150] Fix | Delete
* the unnamed bitfields unless they should also be accessed
[151] Fix | Delete
* after acquiring the node lock.
[152] Fix | Delete
*
[153] Fix | Delete
* NOTE: Do not merge these fields into bitfields above, as
[154] Fix | Delete
* they'll all be put in the same qword that could be accessed
[155] Fix | Delete
* without the node lock as it shares the qword with other
[156] Fix | Delete
* members. Leave these members here so that they occupy a
[157] Fix | Delete
* separate region of memory.
[158] Fix | Delete
*/
[159] Fix | Delete
void *data;
[160] Fix | Delete
unsigned int locknum;
[161] Fix | Delete
unsigned int :0; /* start of bitfields c/o node lock */
[162] Fix | Delete
unsigned int dirty:1;
[163] Fix | Delete
unsigned int wild:1;
[164] Fix | Delete
#ifndef DNS_RBT_USEISCREFCOUNT
[165] Fix | Delete
unsigned int references:DNS_RBT_REFLENGTH;
[166] Fix | Delete
#endif
[167] Fix | Delete
unsigned int :0; /* end of bitfields c/o node lock */
[168] Fix | Delete
#ifdef DNS_RBT_USEISCREFCOUNT
[169] Fix | Delete
isc_refcount_t references; /* note that this is not in the bitfield */
[170] Fix | Delete
#endif
[171] Fix | Delete
/*@}*/
[172] Fix | Delete
};
[173] Fix | Delete
[174] Fix | Delete
typedef isc_result_t (*dns_rbtfindcallback_t)(dns_rbtnode_t *node,
[175] Fix | Delete
dns_name_t *name,
[176] Fix | Delete
void *callback_arg);
[177] Fix | Delete
[178] Fix | Delete
typedef isc_result_t (*dns_rbtdatawriter_t)(FILE *file,
[179] Fix | Delete
unsigned char *data,
[180] Fix | Delete
void *arg,
[181] Fix | Delete
uint64_t *crc);
[182] Fix | Delete
[183] Fix | Delete
typedef isc_result_t (*dns_rbtdatafixer_t)(dns_rbtnode_t *rbtnode,
[184] Fix | Delete
void *base, size_t offset,
[185] Fix | Delete
void *arg, uint64_t *crc);
[186] Fix | Delete
[187] Fix | Delete
typedef void (*dns_rbtdeleter_t)(void *, void *);
[188] Fix | Delete
[189] Fix | Delete
/*****
[190] Fix | Delete
***** Chain Info
[191] Fix | Delete
*****/
[192] Fix | Delete
[193] Fix | Delete
/*!
[194] Fix | Delete
* A chain is used to keep track of the sequence of nodes to reach any given
[195] Fix | Delete
* node from the root of the tree. Originally nodes did not have parent
[196] Fix | Delete
* pointers in them (for memory usage reasons) so there was no way to find
[197] Fix | Delete
* the path back to the root from any given node. Now that nodes have parent
[198] Fix | Delete
* pointers, chains might be going away in a future release, though the
[199] Fix | Delete
* movement functionality would remain.
[200] Fix | Delete
*
[201] Fix | Delete
* Chains may be used to iterate over a tree of trees. After setting up the
[202] Fix | Delete
* chain's structure using dns_rbtnodechain_init(), it needs to be initialized
[203] Fix | Delete
* to point to the lexically first or lexically last node in the tree of trees
[204] Fix | Delete
* using dns_rbtnodechain_first() or dns_rbtnodechain_last(), respectively.
[205] Fix | Delete
* Calling dns_rbtnodechain_next() or dns_rbtnodechain_prev() then moves the
[206] Fix | Delete
* chain over to the next or previous node, respectively.
[207] Fix | Delete
*
[208] Fix | Delete
* In any event, parent information, whether via parent pointers or chains, is
[209] Fix | Delete
* necessary information for iterating through the tree or for basic internal
[210] Fix | Delete
* tree maintenance issues (ie, the rotations that are done to rebalance the
[211] Fix | Delete
* tree when a node is added). The obvious implication of this is that for a
[212] Fix | Delete
* chain to remain valid, the tree has to be locked down against writes for the
[213] Fix | Delete
* duration of the useful life of the chain, because additions or removals can
[214] Fix | Delete
* change the path from the root to the node the chain has targeted.
[215] Fix | Delete
*
[216] Fix | Delete
* The dns_rbtnodechain_ functions _first, _last, _prev and _next all take
[217] Fix | Delete
* dns_name_t parameters for the name and the origin, which can be NULL. If
[218] Fix | Delete
* non-NULL, 'name' will end up pointing to the name data and offsets that are
[219] Fix | Delete
* stored at the node (and thus it will be read-only), so it should be a
[220] Fix | Delete
* regular dns_name_t that has been initialized with dns_name_init. When
[221] Fix | Delete
* 'origin' is non-NULL, it will get the name of the origin stored in it, so it
[222] Fix | Delete
* needs to have its own buffer space and offsets, which is most easily
[223] Fix | Delete
* accomplished with a dns_fixedname_t. It is _not_ necessary to reinitialize
[224] Fix | Delete
* either 'name' or 'origin' between calls to the chain functions.
[225] Fix | Delete
*
[226] Fix | Delete
* NOTE WELL: even though the name data at the root of the tree of trees will
[227] Fix | Delete
* be absolute (typically just "."), it will will be made into a relative name
[228] Fix | Delete
* with an origin of "." -- an empty name when the node is ".". This is
[229] Fix | Delete
* because a common on operation on 'name' and 'origin' is to use
[230] Fix | Delete
* dns_name_concatenate() on them to generate the complete name. An empty name
[231] Fix | Delete
* can be detected when dns_name_countlabels == 0, and is printed by
[232] Fix | Delete
* dns_name_totext()/dns_name_format() as "@", consistent with RFC1035's
[233] Fix | Delete
* definition of "@" as the current origin.
[234] Fix | Delete
*
[235] Fix | Delete
* dns_rbtnodechain_current is similar to the _first, _last, _prev and _next
[236] Fix | Delete
* functions but additionally can provide the node to which the chain points.
[237] Fix | Delete
*/
[238] Fix | Delete
[239] Fix | Delete
/*%
[240] Fix | Delete
* The number of level blocks to allocate at a time. Currently the maximum
[241] Fix | Delete
* number of levels is allocated directly in the structure, but future
[242] Fix | Delete
* revisions of this code might have a static initial block with dynamic
[243] Fix | Delete
* growth. Allocating space for 256 levels when the tree is almost never that
[244] Fix | Delete
* deep is wasteful, but it's not clear that it matters, since the waste is
[245] Fix | Delete
* only 2MB for 1000 concurrently active chains on a system with 64-bit
[246] Fix | Delete
* pointers.
[247] Fix | Delete
*/
[248] Fix | Delete
#define DNS_RBT_LEVELBLOCK 254
[249] Fix | Delete
[250] Fix | Delete
typedef struct dns_rbtnodechain {
[251] Fix | Delete
unsigned int magic;
[252] Fix | Delete
isc_mem_t * mctx;
[253] Fix | Delete
/*%
[254] Fix | Delete
* The terminal node of the chain. It is not in levels[].
[255] Fix | Delete
* This is ostensibly private ... but in a pinch it could be
[256] Fix | Delete
* used tell that the chain points nowhere without needing to
[257] Fix | Delete
* call dns_rbtnodechain_current().
[258] Fix | Delete
*/
[259] Fix | Delete
dns_rbtnode_t * end;
[260] Fix | Delete
/*%
[261] Fix | Delete
* The maximum number of labels in a name is 128; bitstrings mean
[262] Fix | Delete
* a conceptually very large number (which I have not bothered to
[263] Fix | Delete
* compute) of logical levels because splitting can potentially occur
[264] Fix | Delete
* at each bit. However, DNSSEC restricts the number of "logical"
[265] Fix | Delete
* labels in a name to 255, meaning only 254 pointers are needed
[266] Fix | Delete
* in the worst case.
[267] Fix | Delete
*/
[268] Fix | Delete
dns_rbtnode_t * levels[DNS_RBT_LEVELBLOCK];
[269] Fix | Delete
/*%
[270] Fix | Delete
* level_count indicates how deep the chain points into the
[271] Fix | Delete
* tree of trees, and is the index into the levels[] array.
[272] Fix | Delete
* Thus, levels[level_count - 1] is the last level node stored.
[273] Fix | Delete
* A chain that points to the top level of the tree of trees has
[274] Fix | Delete
* a level_count of 0, the first level has a level_count of 1, and
[275] Fix | Delete
* so on.
[276] Fix | Delete
*/
[277] Fix | Delete
unsigned int level_count;
[278] Fix | Delete
/*%
[279] Fix | Delete
* level_matches tells how many levels matched above the node
[280] Fix | Delete
* returned by dns_rbt_findnode(). A match (partial or exact) found
[281] Fix | Delete
* in the first level thus results in level_matches being set to 1.
[282] Fix | Delete
* This is used by the rbtdb to set the start point for a recursive
[283] Fix | Delete
* search of superdomains until the RR it is looking for is found.
[284] Fix | Delete
*/
[285] Fix | Delete
unsigned int level_matches;
[286] Fix | Delete
} dns_rbtnodechain_t;
[287] Fix | Delete
[288] Fix | Delete
/*****
[289] Fix | Delete
***** Public interfaces.
[290] Fix | Delete
*****/
[291] Fix | Delete
isc_result_t
[292] Fix | Delete
dns_rbt_create(isc_mem_t *mctx, dns_rbtdeleter_t deleter,
[293] Fix | Delete
void *deleter_arg, dns_rbt_t **rbtp);
[294] Fix | Delete
/*%<
[295] Fix | Delete
* Initialize a red-black tree of trees.
[296] Fix | Delete
*
[297] Fix | Delete
* Notes:
[298] Fix | Delete
*\li The deleter argument, if non-null, points to a function that is
[299] Fix | Delete
* responsible for cleaning up any memory associated with the data
[300] Fix | Delete
* pointer of a node when the node is deleted. It is passed the
[301] Fix | Delete
* deleted node's data pointer as its first argument and deleter_arg
[302] Fix | Delete
* as its second argument.
[303] Fix | Delete
*
[304] Fix | Delete
* Requires:
[305] Fix | Delete
* \li mctx is a pointer to a valid memory context.
[306] Fix | Delete
*\li rbtp != NULL && *rbtp == NULL
[307] Fix | Delete
*\li arg == NULL iff deleter == NULL
[308] Fix | Delete
*
[309] Fix | Delete
* Ensures:
[310] Fix | Delete
*\li If result is ISC_R_SUCCESS:
[311] Fix | Delete
* *rbtp points to a valid red-black tree manager
[312] Fix | Delete
*
[313] Fix | Delete
*\li If result is failure:
[314] Fix | Delete
* *rbtp does not point to a valid red-black tree manager.
[315] Fix | Delete
*
[316] Fix | Delete
* Returns:
[317] Fix | Delete
*\li #ISC_R_SUCCESS Success
[318] Fix | Delete
*\li #ISC_R_NOMEMORY Resource limit: Out of Memory
[319] Fix | Delete
*/
[320] Fix | Delete
[321] Fix | Delete
isc_result_t
[322] Fix | Delete
dns_rbt_addname(dns_rbt_t *rbt, dns_name_t *name, void *data);
[323] Fix | Delete
/*%<
[324] Fix | Delete
* Add 'name' to the tree of trees, associated with 'data'.
[325] Fix | Delete
*
[326] Fix | Delete
* Notes:
[327] Fix | Delete
*\li 'data' is never required to be non-NULL, but specifying it
[328] Fix | Delete
* when the name is added is faster than searching for 'name'
[329] Fix | Delete
* again and then setting the data pointer. The lack of a data pointer
[330] Fix | Delete
* for a node also has other ramifications regarding whether
[331] Fix | Delete
* dns_rbt_findname considers a node to exist, or dns_rbt_deletename
[332] Fix | Delete
* joins nodes.
[333] Fix | Delete
*
[334] Fix | Delete
* Requires:
[335] Fix | Delete
*\li rbt is a valid rbt manager.
[336] Fix | Delete
*\li dns_name_isabsolute(name) == TRUE
[337] Fix | Delete
*
[338] Fix | Delete
* Ensures:
[339] Fix | Delete
*\li 'name' is not altered in any way.
[340] Fix | Delete
*
[341] Fix | Delete
*\li Any external references to nodes in the tree are unaffected by
[342] Fix | Delete
* node splits that are necessary to insert the new name.
[343] Fix | Delete
*
[344] Fix | Delete
*\li If result is #ISC_R_SUCCESS:
[345] Fix | Delete
* 'name' is findable in the red/black tree of trees in O(log N).
[346] Fix | Delete
* The data pointer of the node for 'name' is set to 'data'.
[347] Fix | Delete
*
[348] Fix | Delete
*\li If result is #ISC_R_EXISTS or #ISC_R_NOSPACE:
[349] Fix | Delete
* The tree of trees is unaltered.
[350] Fix | Delete
*
[351] Fix | Delete
*\li If result is #ISC_R_NOMEMORY:
[352] Fix | Delete
* No guarantees.
[353] Fix | Delete
*
[354] Fix | Delete
* Returns:
[355] Fix | Delete
*\li #ISC_R_SUCCESS Success
[356] Fix | Delete
*\li #ISC_R_EXISTS The name already exists with associated data.
[357] Fix | Delete
*\li #ISC_R_NOSPACE The name had more logical labels than are allowed.
[358] Fix | Delete
*\li #ISC_R_NOMEMORY Resource Limit: Out of Memory
[359] Fix | Delete
*/
[360] Fix | Delete
[361] Fix | Delete
isc_result_t
[362] Fix | Delete
dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep);
[363] Fix | Delete
[364] Fix | Delete
/*%<
[365] Fix | Delete
* Just like dns_rbt_addname, but returns the address of the node.
[366] Fix | Delete
*
[367] Fix | Delete
* Requires:
[368] Fix | Delete
*\li rbt is a valid rbt structure.
[369] Fix | Delete
*\li dns_name_isabsolute(name) == TRUE
[370] Fix | Delete
*\li nodep != NULL && *nodep == NULL
[371] Fix | Delete
*
[372] Fix | Delete
* Ensures:
[373] Fix | Delete
*\li 'name' is not altered in any way.
[374] Fix | Delete
*
[375] Fix | Delete
*\li Any external references to nodes in the tree are unaffected by
[376] Fix | Delete
* node splits that are necessary to insert the new name.
[377] Fix | Delete
*
[378] Fix | Delete
*\li If result is ISC_R_SUCCESS:
[379] Fix | Delete
* 'name' is findable in the red/black tree of trees in O(log N).
[380] Fix | Delete
* *nodep is the node that was added for 'name'.
[381] Fix | Delete
*
[382] Fix | Delete
*\li If result is ISC_R_EXISTS:
[383] Fix | Delete
* The tree of trees is unaltered.
[384] Fix | Delete
* *nodep is the existing node for 'name'.
[385] Fix | Delete
*
[386] Fix | Delete
*\li If result is ISC_R_NOMEMORY:
[387] Fix | Delete
* No guarantees.
[388] Fix | Delete
*
[389] Fix | Delete
* Returns:
[390] Fix | Delete
*\li #ISC_R_SUCCESS Success
[391] Fix | Delete
*\li #ISC_R_EXISTS The name already exists, possibly without data.
[392] Fix | Delete
*\li #ISC_R_NOMEMORY Resource Limit: Out of Memory
[393] Fix | Delete
*/
[394] Fix | Delete
[395] Fix | Delete
isc_result_t
[396] Fix | Delete
dns_rbt_findname(dns_rbt_t *rbt, const dns_name_t *name, unsigned int options,
[397] Fix | Delete
dns_name_t *foundname, void **data);
[398] Fix | Delete
/*%<
[399] Fix | Delete
* Get the data pointer associated with 'name'.
[400] Fix | Delete
*
[401] Fix | Delete
* Notes:
[402] Fix | Delete
*\li When #DNS_RBTFIND_NOEXACT is set, the closest matching superdomain is
[403] Fix | Delete
* returned (also subject to #DNS_RBTFIND_EMPTYDATA), even when there is
[404] Fix | Delete
* an exact match in the tree.
[405] Fix | Delete
*
[406] Fix | Delete
*\li A node that has no data is considered not to exist for this function,
[407] Fix | Delete
* unless the #DNS_RBTFIND_EMPTYDATA option is set.
[408] Fix | Delete
*
[409] Fix | Delete
* Requires:
[410] Fix | Delete
*\li rbt is a valid rbt manager.
[411] Fix | Delete
*\li dns_name_isabsolute(name) == TRUE
[412] Fix | Delete
*\li data != NULL && *data == NULL
[413] Fix | Delete
*
[414] Fix | Delete
* Ensures:
[415] Fix | Delete
*\li 'name' and the tree are not altered in any way.
[416] Fix | Delete
*
[417] Fix | Delete
*\li If result is ISC_R_SUCCESS:
[418] Fix | Delete
* *data is the data associated with 'name'.
[419] Fix | Delete
*
[420] Fix | Delete
*\li If result is DNS_R_PARTIALMATCH:
[421] Fix | Delete
* *data is the data associated with the deepest superdomain
[422] Fix | Delete
* of 'name' which has data.
[423] Fix | Delete
*
[424] Fix | Delete
*\li If result is ISC_R_NOTFOUND:
[425] Fix | Delete
* Neither the name nor a superdomain was found with data.
[426] Fix | Delete
*
[427] Fix | Delete
* Returns:
[428] Fix | Delete
*\li #ISC_R_SUCCESS Success
[429] Fix | Delete
*\li #DNS_R_PARTIALMATCH Superdomain found with data
[430] Fix | Delete
*\li #ISC_R_NOTFOUND No match
[431] Fix | Delete
*\li #ISC_R_NOSPACE Concatenating nodes to form foundname failed
[432] Fix | Delete
*/
[433] Fix | Delete
[434] Fix | Delete
isc_result_t
[435] Fix | Delete
dns_rbt_findnode(dns_rbt_t *rbt, const dns_name_t *name, dns_name_t *foundname,
[436] Fix | Delete
dns_rbtnode_t **node, dns_rbtnodechain_t *chain,
[437] Fix | Delete
unsigned int options, dns_rbtfindcallback_t callback,
[438] Fix | Delete
void *callback_arg);
[439] Fix | Delete
/*%<
[440] Fix | Delete
* Find the node for 'name'.
[441] Fix | Delete
*
[442] Fix | Delete
* Notes:
[443] Fix | Delete
*\li A node that has no data is considered not to exist for this function,
[444] Fix | Delete
* unless the DNS_RBTFIND_EMPTYDATA option is set. This applies to both
[445] Fix | Delete
* exact matches and partial matches.
[446] Fix | Delete
*
[447] Fix | Delete
*\li If the chain parameter is non-NULL, then the path through the tree
[448] Fix | Delete
* to the DNSSEC predecessor of the searched for name is maintained,
[449] Fix | Delete
* unless the DNS_RBTFIND_NOPREDECESSOR or DNS_RBTFIND_NOEXACT option
[450] Fix | Delete
* is used. (For more details on those options, see below.)
[451] Fix | Delete
*
[452] Fix | Delete
*\li If there is no predecessor, then the chain will point to nowhere, as
[453] Fix | Delete
* indicated by chain->end being NULL or dns_rbtnodechain_current
[454] Fix | Delete
* returning ISC_R_NOTFOUND. Note that in a normal Internet DNS RBT
[455] Fix | Delete
* there will always be a predecessor for all names except the root
[456] Fix | Delete
* name, because '.' will exist and '.' is the predecessor of
[457] Fix | Delete
* everything. But you can certainly construct a trivial tree and a
[458] Fix | Delete
* search for it that has no predecessor.
[459] Fix | Delete
*
[460] Fix | Delete
*\li Within the chain structure, the 'levels' member of the structure holds
[461] Fix | Delete
* the root node of each level except the first.
[462] Fix | Delete
*
[463] Fix | Delete
*\li The 'level_count' of the chain indicates how deep the chain to the
[464] Fix | Delete
* predecessor name is, as an index into the 'levels[]' array. It does
[465] Fix | Delete
* not count name elements, per se, but only levels of the tree of trees,
[466] Fix | Delete
* the distinction arising because multiple labels from a name can be
[467] Fix | Delete
* stored on only one level. It is also does not include the level
[468] Fix | Delete
* that has the node, since that level is not stored in levels[].
[469] Fix | Delete
*
[470] Fix | Delete
*\li The chain's 'level_matches' is not directly related to the predecessor.
[471] Fix | Delete
* It is the number of levels above the level of the found 'node',
[472] Fix | Delete
* regardless of whether it was a partial match or exact match. When
[473] Fix | Delete
* the node is found in the top level tree, or no node is found at all,
[474] Fix | Delete
* level_matches is 0.
[475] Fix | Delete
*
[476] Fix | Delete
*\li When DNS_RBTFIND_NOEXACT is set, the closest matching superdomain is
[477] Fix | Delete
* returned (also subject to DNS_RBTFIND_EMPTYDATA), even when
[478] Fix | Delete
* there is an exact match in the tree. In this case, the chain
[479] Fix | Delete
* will not point to the DNSSEC predecessor, but will instead point
[480] Fix | Delete
* to the exact match, if there was any. Thus the preceding paragraphs
[481] Fix | Delete
* should have "exact match" substituted for "predecessor" to describe
[482] Fix | Delete
* how the various elements of the chain are set. This was done to
[483] Fix | Delete
* ensure that the chain's state was sane, and to prevent problems that
[484] Fix | Delete
* occurred when running the predecessor location code under conditions
[485] Fix | Delete
* it was not designed for. It is not clear *where* the chain should
[486] Fix | Delete
* point when DNS_RBTFIND_NOEXACT is set, so if you end up using a chain
[487] Fix | Delete
* with this option because you want a particular node, let us know
[488] Fix | Delete
* where you want the chain pointed, so this can be made more firm.
[489] Fix | Delete
*
[490] Fix | Delete
* Requires:
[491] Fix | Delete
*\li rbt is a valid rbt manager.
[492] Fix | Delete
*\li dns_name_isabsolute(name) == TRUE.
[493] Fix | Delete
*\li node != NULL && *node == NULL.
[494] Fix | Delete
*\li #DNS_RBTFIND_NOEXACT and DNS_RBTFIND_NOPREDECESSOR are mutually
[495] Fix | Delete
* exclusive.
[496] Fix | Delete
*
[497] Fix | Delete
* Ensures:
[498] Fix | Delete
*\li 'name' and the tree are not altered in any way.
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function