1 /* $NetBSD: dbtable.h,v 1.4 2014/12/10 04:37:58 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 1999-2001 Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /* Id: dbtable.h,v 1.23 2007/06/19 23:47:16 tbox Exp */ 21 22 #ifndef DNS_DBTABLE_H 23 #define DNS_DBTABLE_H 1 24 25 /***** 26 ***** Module Info 27 *****/ 28 29 /*! \file dns/dbtable.h 30 * \brief 31 * DNS DB Tables 32 * 33 * XXX TBS XXX 34 * 35 * MP: 36 *\li The module ensures appropriate synchronization of data structures it 37 * creates and manipulates. 38 * 39 * Reliability: 40 *\li No anticipated impact. 41 * 42 * Resources: 43 *\li None. 44 * 45 * Security: 46 *\li No anticipated impact. 47 * 48 * Standards: 49 *\li None. 50 */ 51 52 #include <isc/lang.h> 53 54 #include <dns/types.h> 55 56 #define DNS_DBTABLEFIND_NOEXACT 0x01 57 58 ISC_LANG_BEGINDECLS 59 60 isc_result_t 61 dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, 62 dns_dbtable_t **dbtablep); 63 /*%< 64 * Make a new dbtable of class 'rdclass' 65 * 66 * Requires: 67 *\li mctx != NULL 68 * \li dbtablep != NULL && *dptablep == NULL 69 *\li 'rdclass' is a valid class 70 * 71 * Returns: 72 *\li #ISC_R_SUCCESS 73 *\li #ISC_R_NOMEMORY 74 *\li #ISC_R_UNEXPECTED 75 */ 76 77 void 78 dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp); 79 /*%< 80 * Attach '*targetp' to 'source'. 81 * 82 * Requires: 83 * 84 *\li 'source' is a valid dbtable. 85 * 86 *\li 'targetp' points to a NULL dns_dbtable_t *. 87 * 88 * Ensures: 89 * 90 *\li *targetp is attached to source. 91 */ 92 93 void 94 dns_dbtable_detach(dns_dbtable_t **dbtablep); 95 /*%< 96 * Detach *dbtablep from its dbtable. 97 * 98 * Requires: 99 * 100 *\li '*dbtablep' points to a valid dbtable. 101 * 102 * Ensures: 103 * 104 *\li *dbtablep is NULL. 105 * 106 *\li If '*dbtablep' is the last reference to the dbtable, 107 * all resources used by the dbtable will be freed 108 */ 109 110 isc_result_t 111 dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db); 112 /*%< 113 * Add 'db' to 'dbtable'. 114 * 115 * Requires: 116 *\li 'dbtable' is a valid dbtable. 117 * 118 *\li 'db' is a valid database with the same class as 'dbtable' 119 */ 120 121 void 122 dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db); 123 /*%< 124 * Remove 'db' from 'dbtable'. 125 * 126 * Requires: 127 *\li 'db' was previously added to 'dbtable'. 128 */ 129 130 void 131 dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db); 132 /*%< 133 * Use 'db' as the result of a dns_dbtable_find() if no better match is 134 * available. 135 */ 136 137 void 138 dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **db); 139 /*%< 140 * Get the 'db' used as the result of a dns_dbtable_find() 141 * if no better match is available. 142 */ 143 144 void 145 dns_dbtable_removedefault(dns_dbtable_t *dbtable); 146 /*%< 147 * Remove the default db from 'dbtable'. 148 */ 149 150 isc_result_t 151 dns_dbtable_find(dns_dbtable_t *dbtable, dns_name_t *name, 152 unsigned int options, dns_db_t **dbp); 153 /*%< 154 * Find the deepest match to 'name' in the dbtable, and return it 155 * 156 * Notes: 157 *\li If the DNS_DBTABLEFIND_NOEXACT option is set, the best partial 158 * match (if any) to 'name' will be returned. 159 * 160 * Returns: 161 * \li #ISC_R_SUCCESS on success 162 *\li something else: no default and match 163 */ 164 165 ISC_LANG_ENDDECLS 166 167 #endif /* DNS_DBTABLE_H */ 168