1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * SPDX-License-Identifier: MPL-2.0 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 9 * 10 * See the COPYRIGHT file distributed with this work for additional 11 * information regarding copyright ownership. 12 */ 13 14 #ifndef DNS_DBTABLE_H 15 #define DNS_DBTABLE_H 1 16 17 /***** 18 ***** Module Info 19 *****/ 20 21 /*! \file dns/dbtable.h 22 * \brief 23 * DNS DB Tables 24 * 25 * XXX TBS XXX 26 * 27 * MP: 28 *\li The module ensures appropriate synchronization of data structures it 29 * creates and manipulates. 30 * 31 * Reliability: 32 *\li No anticipated impact. 33 * 34 * Resources: 35 *\li None. 36 * 37 * Security: 38 *\li No anticipated impact. 39 * 40 * Standards: 41 *\li None. 42 */ 43 44 #include <isc/lang.h> 45 46 #include <dns/types.h> 47 48 #define DNS_DBTABLEFIND_NOEXACT 0x01 49 50 ISC_LANG_BEGINDECLS 51 52 isc_result_t 53 dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, 54 dns_dbtable_t **dbtablep); 55 /*%< 56 * Make a new dbtable of class 'rdclass' 57 * 58 * Requires: 59 *\li mctx != NULL 60 * \li dbtablep != NULL && *dptablep == NULL 61 *\li 'rdclass' is a valid class 62 * 63 * Returns: 64 *\li #ISC_R_SUCCESS 65 *\li #ISC_R_NOMEMORY 66 *\li #ISC_R_UNEXPECTED 67 */ 68 69 void 70 dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp); 71 /*%< 72 * Attach '*targetp' to 'source'. 73 * 74 * Requires: 75 * 76 *\li 'source' is a valid dbtable. 77 * 78 *\li 'targetp' points to a NULL dns_dbtable_t *. 79 * 80 * Ensures: 81 * 82 *\li *targetp is attached to source. 83 */ 84 85 void 86 dns_dbtable_detach(dns_dbtable_t **dbtablep); 87 /*%< 88 * Detach *dbtablep from its dbtable. 89 * 90 * Requires: 91 * 92 *\li '*dbtablep' points to a valid dbtable. 93 * 94 * Ensures: 95 * 96 *\li *dbtablep is NULL. 97 * 98 *\li If '*dbtablep' is the last reference to the dbtable, 99 * all resources used by the dbtable will be freed 100 */ 101 102 isc_result_t 103 dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db); 104 /*%< 105 * Add 'db' to 'dbtable'. 106 * 107 * Requires: 108 *\li 'dbtable' is a valid dbtable. 109 * 110 *\li 'db' is a valid database with the same class as 'dbtable' 111 */ 112 113 void 114 dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db); 115 /*%< 116 * Remove 'db' from 'dbtable'. 117 * 118 * Requires: 119 *\li 'db' was previously added to 'dbtable'. 120 */ 121 122 void 123 dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db); 124 /*%< 125 * Use 'db' as the result of a dns_dbtable_find() if no better match is 126 * available. 127 */ 128 129 void 130 dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **db); 131 /*%< 132 * Get the 'db' used as the result of a dns_dbtable_find() 133 * if no better match is available. 134 */ 135 136 void 137 dns_dbtable_removedefault(dns_dbtable_t *dbtable); 138 /*%< 139 * Remove the default db from 'dbtable'. 140 */ 141 142 isc_result_t 143 dns_dbtable_find(dns_dbtable_t *dbtable, const dns_name_t *name, 144 unsigned int options, dns_db_t **dbp); 145 /*%< 146 * Find the deepest match to 'name' in the dbtable, and return it 147 * 148 * Notes: 149 *\li If the DNS_DBTABLEFIND_NOEXACT option is set, the best partial 150 * match (if any) to 'name' will be returned. 151 * 152 * Returns: 153 * \li #ISC_R_SUCCESS on success 154 *\li something else: no default and match 155 */ 156 157 ISC_LANG_ENDDECLS 158 159 #endif /* DNS_DBTABLE_H */ 160