db.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2009, 2011-2015  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2003  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id$ */
00019 
00020 #ifndef DNS_DB_H
00021 #define DNS_DB_H 1
00022 
00023 /*****
00024  ***** Module Info
00025  *****/
00026 
00027 /*! \file dns/db.h
00028  * \brief
00029  * The DNS DB interface allows named rdatasets to be stored and retrieved.
00030  *
00031  * The dns_db_t type is like a "virtual class".  To actually use
00032  * DBs, an implementation of the class is required.
00033  *
00034  * XXX more XXX
00035  *
00036  * MP:
00037  * \li  The module ensures appropriate synchronization of data structures it
00038  *      creates and manipulates.
00039  *
00040  * Reliability:
00041  * \li  No anticipated impact.
00042  *
00043  * Resources:
00044  * \li  TBS
00045  *
00046  * Security:
00047  * \li  No anticipated impact.
00048  *
00049  * Standards:
00050  * \li  None.
00051  */
00052 
00053 /*****
00054  ***** Imports
00055  *****/
00056 
00057 #include <isc/lang.h>
00058 #include <isc/magic.h>
00059 #include <isc/ondestroy.h>
00060 #include <isc/stats.h>
00061 #include <isc/stdtime.h>
00062 
00063 #include <dns/clientinfo.h>
00064 #include <dns/fixedname.h>
00065 #include <dns/name.h>
00066 #include <dns/rdata.h>
00067 #include <dns/rdataset.h>
00068 #include <dns/rpz.h>
00069 #include <dns/types.h>
00070 
00071 ISC_LANG_BEGINDECLS
00072 
00073 /*****
00074  ***** Types
00075  *****/
00076 
00077 typedef struct dns_dbmethods {
00078         void            (*attach)(dns_db_t *source, dns_db_t **targetp);
00079         void            (*detach)(dns_db_t **dbp);
00080         isc_result_t    (*beginload)(dns_db_t *db,
00081                                      dns_rdatacallbacks_t *callbacks);
00082         isc_result_t    (*endload)(dns_db_t *db,
00083                                      dns_rdatacallbacks_t *callbacks);
00084         isc_result_t    (*serialize)(dns_db_t *db,
00085                                      dns_dbversion_t *version, FILE *file);
00086         isc_result_t    (*dump)(dns_db_t *db, dns_dbversion_t *version,
00087                                 const char *filename,
00088                                 dns_masterformat_t masterformat);
00089         void            (*currentversion)(dns_db_t *db,
00090                                           dns_dbversion_t **versionp);
00091         isc_result_t    (*newversion)(dns_db_t *db,
00092                                       dns_dbversion_t **versionp);
00093         void            (*attachversion)(dns_db_t *db, dns_dbversion_t *source,
00094                                          dns_dbversion_t **targetp);
00095         void            (*closeversion)(dns_db_t *db,
00096                                         dns_dbversion_t **versionp,
00097                                         isc_boolean_t commit);
00098         isc_result_t    (*findnode)(dns_db_t *db, dns_name_t *name,
00099                                     isc_boolean_t create,
00100                                     dns_dbnode_t **nodep);
00101         isc_result_t    (*find)(dns_db_t *db, dns_name_t *name,
00102                                 dns_dbversion_t *version,
00103                                 dns_rdatatype_t type, unsigned int options,
00104                                 isc_stdtime_t now,
00105                                 dns_dbnode_t **nodep, dns_name_t *foundname,
00106                                 dns_rdataset_t *rdataset,
00107                                 dns_rdataset_t *sigrdataset);
00108         isc_result_t    (*findzonecut)(dns_db_t *db, dns_name_t *name,
00109                                        unsigned int options, isc_stdtime_t now,
00110                                        dns_dbnode_t **nodep,
00111                                        dns_name_t *foundname,
00112                                        dns_rdataset_t *rdataset,
00113                                        dns_rdataset_t *sigrdataset);
00114         void            (*attachnode)(dns_db_t *db,
00115                                       dns_dbnode_t *source,
00116                                       dns_dbnode_t **targetp);
00117         void            (*detachnode)(dns_db_t *db,
00118                                       dns_dbnode_t **targetp);
00119         isc_result_t    (*expirenode)(dns_db_t *db, dns_dbnode_t *node,
00120                                       isc_stdtime_t now);
00121         void            (*printnode)(dns_db_t *db, dns_dbnode_t *node,
00122                                      FILE *out);
00123         isc_result_t    (*createiterator)(dns_db_t *db, unsigned int options,
00124                                           dns_dbiterator_t **iteratorp);
00125         isc_result_t    (*findrdataset)(dns_db_t *db, dns_dbnode_t *node,
00126                                         dns_dbversion_t *version,
00127                                         dns_rdatatype_t type,
00128                                         dns_rdatatype_t covers,
00129                                         isc_stdtime_t now,
00130                                         dns_rdataset_t *rdataset,
00131                                         dns_rdataset_t *sigrdataset);
00132         isc_result_t    (*allrdatasets)(dns_db_t *db, dns_dbnode_t *node,
00133                                         dns_dbversion_t *version,
00134                                         isc_stdtime_t now,
00135                                         dns_rdatasetiter_t **iteratorp);
00136         isc_result_t    (*addrdataset)(dns_db_t *db, dns_dbnode_t *node,
00137                                        dns_dbversion_t *version,
00138                                        isc_stdtime_t now,
00139                                        dns_rdataset_t *rdataset,
00140                                        unsigned int options,
00141                                        dns_rdataset_t *addedrdataset);
00142         isc_result_t    (*subtractrdataset)(dns_db_t *db, dns_dbnode_t *node,
00143                                             dns_dbversion_t *version,
00144                                             dns_rdataset_t *rdataset,
00145                                             unsigned int options,
00146                                             dns_rdataset_t *newrdataset);
00147         isc_result_t    (*deleterdataset)(dns_db_t *db, dns_dbnode_t *node,
00148                                           dns_dbversion_t *version,
00149                                           dns_rdatatype_t type,
00150                                           dns_rdatatype_t covers);
00151         isc_boolean_t   (*issecure)(dns_db_t *db);
00152         unsigned int    (*nodecount)(dns_db_t *db);
00153         isc_boolean_t   (*ispersistent)(dns_db_t *db);
00154         void            (*overmem)(dns_db_t *db, isc_boolean_t overmem);
00155         void            (*settask)(dns_db_t *db, isc_task_t *);
00156         isc_result_t    (*getoriginnode)(dns_db_t *db, dns_dbnode_t **nodep);
00157         void            (*transfernode)(dns_db_t *db, dns_dbnode_t **sourcep,
00158                                         dns_dbnode_t **targetp);
00159         isc_result_t    (*getnsec3parameters)(dns_db_t *db,
00160                                               dns_dbversion_t *version,
00161                                               dns_hash_t *hash,
00162                                               isc_uint8_t *flags,
00163                                               isc_uint16_t *iterations,
00164                                               unsigned char *salt,
00165                                               size_t *salt_len);
00166         isc_result_t    (*findnsec3node)(dns_db_t *db, dns_name_t *name,
00167                                          isc_boolean_t create,
00168                                          dns_dbnode_t **nodep);
00169         isc_result_t    (*setsigningtime)(dns_db_t *db,
00170                                           dns_rdataset_t *rdataset,
00171                                           isc_stdtime_t resign);
00172         isc_result_t    (*getsigningtime)(dns_db_t *db,
00173                                           dns_rdataset_t *rdataset,
00174                                           dns_name_t *name);
00175         void            (*resigned)(dns_db_t *db, dns_rdataset_t *rdataset,
00176                                            dns_dbversion_t *version);
00177         isc_boolean_t   (*isdnssec)(dns_db_t *db);
00178         dns_stats_t     *(*getrrsetstats)(dns_db_t *db);
00179         void            (*rpz_attach)(dns_db_t *db, dns_rpz_zones_t *rpzs,
00180                                       dns_rpz_num_t rpz_num);
00181         isc_result_t    (*rpz_ready)(dns_db_t *db);
00182         isc_result_t    (*findnodeext)(dns_db_t *db, dns_name_t *name,
00183                                      isc_boolean_t create,
00184                                      dns_clientinfomethods_t *methods,
00185                                      dns_clientinfo_t *clientinfo,
00186                                      dns_dbnode_t **nodep);
00187         isc_result_t    (*findext)(dns_db_t *db, dns_name_t *name,
00188                                    dns_dbversion_t *version,
00189                                    dns_rdatatype_t type, unsigned int options,
00190                                    isc_stdtime_t now,
00191                                    dns_dbnode_t **nodep, dns_name_t *foundname,
00192                                    dns_clientinfomethods_t *methods,
00193                                    dns_clientinfo_t *clientinfo,
00194                                    dns_rdataset_t *rdataset,
00195                                    dns_rdataset_t *sigrdataset);
00196         isc_result_t    (*setcachestats)(dns_db_t *db, isc_stats_t *stats);
00197         unsigned int    (*hashsize)(dns_db_t *db);
00198 } dns_dbmethods_t;
00199 
00200 typedef isc_result_t
00201 (*dns_dbcreatefunc_t)(isc_mem_t *mctx, dns_name_t *name,
00202                       dns_dbtype_t type, dns_rdataclass_t rdclass,
00203                       unsigned int argc, char *argv[], void *driverarg,
00204                       dns_db_t **dbp);
00205 
00206 #define DNS_DB_MAGIC            ISC_MAGIC('D','N','S','D')
00207 #define DNS_DB_VALID(db)        ISC_MAGIC_VALID(db, DNS_DB_MAGIC)
00208 
00209 /*%
00210  * This structure is actually just the common prefix of a DNS db
00211  * implementation's version of a dns_db_t.
00212  * \brief
00213  * Direct use of this structure by clients is forbidden.  DB implementations
00214  * may change the structure.  'magic' must be DNS_DB_MAGIC for any of the
00215  * dns_db_ routines to work.  DB implementations must maintain all DB
00216  * invariants.
00217  */
00218 struct dns_db {
00219         unsigned int                    magic;
00220         unsigned int                    impmagic;
00221         dns_dbmethods_t *               methods;
00222         isc_uint16_t                    attributes;
00223         dns_rdataclass_t                rdclass;
00224         dns_name_t                      origin;
00225         isc_ondestroy_t                 ondest;
00226         isc_mem_t *                     mctx;
00227 };
00228 
00229 #define DNS_DBATTR_CACHE                0x01
00230 #define DNS_DBATTR_STUB                 0x02
00231 
00232 /*@{*/
00233 /*%
00234  * Options that can be specified for dns_db_find().
00235  */
00236 #define DNS_DBFIND_GLUEOK               0x0001
00237 #define DNS_DBFIND_VALIDATEGLUE         0x0002
00238 #define DNS_DBFIND_NOWILD               0x0004
00239 #define DNS_DBFIND_PENDINGOK            0x0008
00240 #define DNS_DBFIND_NOEXACT              0x0010
00241 #define DNS_DBFIND_FORCENSEC            0x0020
00242 #define DNS_DBFIND_COVERINGNSEC         0x0040
00243 #define DNS_DBFIND_FORCENSEC3           0x0080
00244 #define DNS_DBFIND_ADDITIONALOK         0x0100
00245 #define DNS_DBFIND_NOZONECUT            0x0200
00246 /*@}*/
00247 
00248 /*@{*/
00249 /*%
00250  * Options that can be specified for dns_db_addrdataset().
00251  */
00252 #define DNS_DBADD_MERGE                 0x01
00253 #define DNS_DBADD_FORCE                 0x02
00254 #define DNS_DBADD_EXACT                 0x04
00255 #define DNS_DBADD_EXACTTTL              0x08
00256 #define DNS_DBADD_PREFETCH              0x10
00257 /*@}*/
00258 
00259 /*%
00260  * Options that can be specified for dns_db_subtractrdataset().
00261  */
00262 #define DNS_DBSUB_EXACT                 0x01
00263 #define DNS_DBSUB_WANTOLD               0x02
00264 
00265 /*@{*/
00266 /*%
00267  * Iterator options
00268  */
00269 #define DNS_DB_RELATIVENAMES    0x1
00270 #define DNS_DB_NSEC3ONLY        0x2
00271 #define DNS_DB_NONSEC3          0x4
00272 /*@}*/
00273 
00274 /*****
00275  ***** Methods
00276  *****/
00277 
00278 /***
00279  *** Basic DB Methods
00280  ***/
00281 
00282 isc_result_t
00283 dns_db_create(isc_mem_t *mctx, const char *db_type, dns_name_t *origin,
00284               dns_dbtype_t type, dns_rdataclass_t rdclass,
00285               unsigned int argc, char *argv[], dns_db_t **dbp);
00286 /*%<
00287  * Create a new database using implementation 'db_type'.
00288  *
00289  * Notes:
00290  * \li  All names in the database must be subdomains of 'origin' and in class
00291  *      'rdclass'.  The database makes its own copy of the origin, so the
00292  *      caller may do whatever they like with 'origin' and its storage once the
00293  *      call returns.
00294  *
00295  * \li  DB implementation-specific parameters are passed using argc and argv.
00296  *
00297  * Requires:
00298  *
00299  * \li  dbp != NULL and *dbp == NULL
00300  *
00301  * \li  'origin' is a valid absolute domain name.
00302  *
00303  * \li  mctx is a valid memory context
00304  *
00305  * Ensures:
00306  *
00307  * \li  A copy of 'origin' has been made for the databases use, and the
00308  *      caller is free to do whatever they want with the name and storage
00309  *      associated with 'origin'.
00310  *
00311  * Returns:
00312  *
00313  * \li  #ISC_R_SUCCESS
00314  * \li  #ISC_R_NOMEMORY
00315  * \li  #ISC_R_NOTFOUND                         db_type not found
00316  *
00317  * \li  Many other errors are possible, depending on what db_type was
00318  *      specified.
00319  */
00320 
00321 void
00322 dns_db_attach(dns_db_t *source, dns_db_t **targetp);
00323 /*%<
00324  * Attach *targetp to source.
00325  *
00326  * Requires:
00327  *
00328  * \li  'source' is a valid database.
00329  *
00330  * \li  'targetp' points to a NULL dns_db_t *.
00331  *
00332  * Ensures:
00333  *
00334  * \li  *targetp is attached to source.
00335  */
00336 
00337 void
00338 dns_db_detach(dns_db_t **dbp);
00339 /*%<
00340  * Detach *dbp from its database.
00341  *
00342  * Requires:
00343  *
00344  * \li  'dbp' points to a valid database.
00345  *
00346  * Ensures:
00347  *
00348  * \li  *dbp is NULL.
00349  *
00350  * \li  If '*dbp' is the last reference to the database,
00351  *              all resources used by the database will be freed
00352  */
00353 
00354 isc_result_t
00355 dns_db_ondestroy(dns_db_t *db, isc_task_t *task, isc_event_t **eventp);
00356 /*%<
00357  * Causes 'eventp' to be sent to be sent to 'task' when the database is
00358  * destroyed.
00359  *
00360  * Note; ownership of the eventp is taken from the caller (and *eventp is
00361  * set to NULL). The sender field of the event is set to 'db' before it is
00362  * sent to the task.
00363  */
00364 
00365 isc_boolean_t
00366 dns_db_iscache(dns_db_t *db);
00367 /*%<
00368  * Does 'db' have cache semantics?
00369  *
00370  * Requires:
00371  *
00372  * \li  'db' is a valid database.
00373  *
00374  * Returns:
00375  * \li  #ISC_TRUE       'db' has cache semantics
00376  * \li  #ISC_FALSE      otherwise
00377  */
00378 
00379 isc_boolean_t
00380 dns_db_iszone(dns_db_t *db);
00381 /*%<
00382  * Does 'db' have zone semantics?
00383  *
00384  * Requires:
00385  *
00386  * \li  'db' is a valid database.
00387  *
00388  * Returns:
00389  * \li  #ISC_TRUE       'db' has zone semantics
00390  * \li  #ISC_FALSE      otherwise
00391  */
00392 
00393 isc_boolean_t
00394 dns_db_isstub(dns_db_t *db);
00395 /*%<
00396  * Does 'db' have stub semantics?
00397  *
00398  * Requires:
00399  *
00400  * \li  'db' is a valid database.
00401  *
00402  * Returns:
00403  * \li  #ISC_TRUE       'db' has zone semantics
00404  * \li  #ISC_FALSE      otherwise
00405  */
00406 
00407 isc_boolean_t
00408 dns_db_issecure(dns_db_t *db);
00409 /*%<
00410  * Is 'db' secure?
00411  *
00412  * Requires:
00413  *
00414  * \li  'db' is a valid database with zone semantics.
00415  *
00416  * Returns:
00417  * \li  #ISC_TRUE       'db' is secure.
00418  * \li  #ISC_FALSE      'db' is not secure.
00419  */
00420 
00421 isc_boolean_t
00422 dns_db_isdnssec(dns_db_t *db);
00423 /*%<
00424  * Is 'db' secure or partially secure?
00425  *
00426  * Requires:
00427  *
00428  * \li  'db' is a valid database with zone semantics.
00429  *
00430  * Returns:
00431  * \li  #ISC_TRUE       'db' is secure or is partially.
00432  * \li  #ISC_FALSE      'db' is not secure.
00433  */
00434 
00435 dns_name_t *
00436 dns_db_origin(dns_db_t *db);
00437 /*%<
00438  * The origin of the database.
00439  *
00440  * Note: caller must not try to change this name.
00441  *
00442  * Requires:
00443  *
00444  * \li  'db' is a valid database.
00445  *
00446  * Returns:
00447  *
00448  * \li  The origin of the database.
00449  */
00450 
00451 dns_rdataclass_t
00452 dns_db_class(dns_db_t *db);
00453 /*%<
00454  * The class of the database.
00455  *
00456  * Requires:
00457  *
00458  * \li  'db' is a valid database.
00459  *
00460  * Returns:
00461  *
00462  * \li  The class of the database.
00463  */
00464 
00465 isc_result_t
00466 dns_db_beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks);
00467 /*%<
00468  * Begin loading 'db'.
00469  *
00470  * Requires:
00471  *
00472  * \li  'db' is a valid database.
00473  *
00474  * \li  This is the first attempt to load 'db'.
00475  *
00476  * \li  'callbacks' is a pointer to an initialized dns_rdatacallbacks_t
00477  *       structure.
00478  *
00479  * Ensures:
00480  *
00481  * \li  On success, callbacks->add will be a valid dns_addrdatasetfunc_t
00482  *      suitable for loading records into 'db' from a raw or text zone
00483  *      file. callbacks->add_private will be a valid DB load context
00484  *      which should be used as 'arg' when callbacks->add is called.
00485  *      callbacks->deserialize will be a valid dns_deserialize_func_t
00486  *      suitable for loading 'db' from a map format zone file.
00487  *
00488  * Returns:
00489  *
00490  * \li  #ISC_R_SUCCESS
00491  * \li  #ISC_R_NOMEMORY
00492  *
00493  * \li  Other results are possible, depending upon the database
00494  *      implementation used, syntax errors in the master file, etc.
00495  */
00496 
00497 isc_result_t
00498 dns_db_endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks);
00499 /*%<
00500  * Finish loading 'db'.
00501  *
00502  * Requires:
00503  *
00504  * \li  'db' is a valid database that is being loaded.
00505  *
00506  * \li  'callbacks' is a valid dns_rdatacallbacks_t structure.
00507  *
00508  * \li  callbacks->add_private is not NULL and is a valid database load context.
00509  *
00510  * Ensures:
00511  *
00512  * \li  'callbacks' is returned to its state prior to calling dns_db_beginload()
00513  *
00514  * Returns:
00515  *
00516  * \li  #ISC_R_SUCCESS
00517  * \li  #ISC_R_NOMEMORY
00518  *
00519  * \li  Other results are possible, depending upon the database
00520  *      implementation used, syntax errors in the master file, etc.
00521  */
00522 
00523 isc_result_t
00524 dns_db_load(dns_db_t *db, const char *filename);
00525 
00526 isc_result_t
00527 dns_db_load2(dns_db_t *db, const char *filename, dns_masterformat_t format);
00528 
00529 isc_result_t
00530 dns_db_load3(dns_db_t *db, const char *filename, dns_masterformat_t format,
00531              unsigned int options);
00532 /*%<
00533  * Load master file 'filename' into 'db'.
00534  *
00535  * Notes:
00536  * \li  This routine is equivalent to calling
00537  *
00538  *\code
00539  *              dns_db_beginload();
00540  *              dns_master_loadfile();
00541  *              dns_db_endload();
00542  *\endcode
00543  *
00544  * Requires:
00545  *
00546  * \li  'db' is a valid database.
00547  *
00548  * \li  This is the first attempt to load 'db'.
00549  *
00550  * Returns:
00551  *
00552  * \li  #ISC_R_SUCCESS
00553  * \li  #ISC_R_NOMEMORY
00554  *
00555  * \li  Other results are possible, depending upon the database
00556  *      implementation used, syntax errors in the master file, etc.
00557  */
00558 
00559 isc_result_t
00560 dns_db_serialize(dns_db_t *db, dns_dbversion_t *version, FILE *rbtfile);
00561 /*%<
00562  * Dump version 'version' of 'db' to map-format file 'filename'.
00563  *
00564  * Requires:
00565  *
00566  * \li  'db' is a valid database.
00567  *
00568  * \li  'version' is a valid version.
00569  *
00570  * Returns:
00571  *
00572  * \li  #ISC_R_SUCCESS
00573  * \li  #ISC_R_NOMEMORY
00574  *
00575  * \li  Other results are possible, depending upon the database
00576  *      implementation used, OS file errors, etc.
00577  */
00578 
00579 isc_result_t
00580 dns_db_dump(dns_db_t *db, dns_dbversion_t *version, const char *filename);
00581 
00582 isc_result_t
00583 dns_db_dump2(dns_db_t *db, dns_dbversion_t *version, const char *filename,
00584              dns_masterformat_t masterformat);
00585 /*%<
00586  * Dump version 'version' of 'db' to master file 'filename'.
00587  *
00588  * Requires:
00589  *
00590  * \li  'db' is a valid database.
00591  *
00592  * \li  'version' is a valid version.
00593  *
00594  * Returns:
00595  *
00596  * \li  #ISC_R_SUCCESS
00597  * \li  #ISC_R_NOMEMORY
00598  *
00599  * \li  Other results are possible, depending upon the database
00600  *      implementation used, OS file errors, etc.
00601  */
00602 
00603 /***
00604  *** Version Methods
00605  ***/
00606 
00607 void
00608 dns_db_currentversion(dns_db_t *db, dns_dbversion_t **versionp);
00609 /*%<
00610  * Open the current version for reading.
00611  *
00612  * Requires:
00613  *
00614  * \li  'db' is a valid database with zone semantics.
00615  *
00616  * \li  versionp != NULL && *verisonp == NULL
00617  *
00618  * Ensures:
00619  *
00620  * \li  On success, '*versionp' is attached to the current version.
00621  *
00622  */
00623 
00624 isc_result_t
00625 dns_db_newversion(dns_db_t *db, dns_dbversion_t **versionp);
00626 /*%<
00627  * Open a new version for reading and writing.
00628  *
00629  * Requires:
00630  *
00631  * \li  'db' is a valid database with zone semantics.
00632  *
00633  * \li  versionp != NULL && *verisonp == NULL
00634  *
00635  * Ensures:
00636  *
00637  * \li  On success, '*versionp' is attached to the current version.
00638  *
00639  * Returns:
00640  *
00641  * \li  #ISC_R_SUCCESS
00642  * \li  #ISC_R_NOMEMORY
00643  *
00644  * \li  Other results are possible, depending upon the database
00645  *      implementation used.
00646  */
00647 
00648 void
00649 dns_db_attachversion(dns_db_t *db, dns_dbversion_t *source,
00650                      dns_dbversion_t **targetp);
00651 /*%<
00652  * Attach '*targetp' to 'source'.
00653  *
00654  * Requires:
00655  *
00656  * \li  'db' is a valid database with zone semantics.
00657  *
00658  * \li  source is a valid open version
00659  *
00660  * \li  targetp != NULL && *targetp == NULL
00661  *
00662  * Ensures:
00663  *
00664  * \li  '*targetp' is attached to source.
00665  */
00666 
00667 void
00668 dns_db_closeversion(dns_db_t *db, dns_dbversion_t **versionp,
00669                     isc_boolean_t commit);
00670 /*%<
00671  * Close version '*versionp'.
00672  *
00673  * Note: if '*versionp' is a read-write version and 'commit' is ISC_TRUE,
00674  * then all changes made in the version will take effect, otherwise they
00675  * will be rolled back.  The value of 'commit' is ignored for read-only
00676  * versions.
00677  *
00678  * Requires:
00679  *
00680  * \li  'db' is a valid database with zone semantics.
00681  *
00682  * \li  '*versionp' refers to a valid version.
00683  *
00684  * \li  If committing a writable version, then there must be no other
00685  *      outstanding references to the version (e.g. an active rdataset
00686  *      iterator).
00687  *
00688  * Ensures:
00689  *
00690  * \li  *versionp == NULL
00691  *
00692  * \li  If *versionp is a read-write version, and commit is ISC_TRUE, then
00693  *      the version will become the current version.  If !commit, then all
00694  *      changes made in the version will be undone, and the version will
00695  *      not become the current version.
00696  */
00697 
00698 /***
00699  *** Node Methods
00700  ***/
00701 
00702 isc_result_t
00703 dns_db_findnode(dns_db_t *db, dns_name_t *name, isc_boolean_t create,
00704                 dns_dbnode_t **nodep);
00705 
00706 isc_result_t
00707 dns_db_findnodeext(dns_db_t *db, dns_name_t *name, isc_boolean_t create,
00708                    dns_clientinfomethods_t *methods,
00709                    dns_clientinfo_t *clientinfo, dns_dbnode_t **nodep);
00710 /*%<
00711  * Find the node with name 'name'.
00712  *
00713  * dns_db_findnodeext() (findnode extended) also accepts parameters
00714  * 'methods' and 'clientinfo', which, when provided, enable the database to
00715  * retreive information about the client from the caller, and modify its
00716  * response on the basis of that information.
00717  *
00718  * Notes:
00719  * \li  If 'create' is ISC_TRUE and no node with name 'name' exists, then
00720  *      such a node will be created.
00721  *
00722  * \li  This routine is for finding or creating a node with the specified
00723  *      name.  There are no partial matches.  It is not suitable for use
00724  *      in building responses to ordinary DNS queries; clients which wish
00725  *      to do that should use dns_db_find() instead.
00726  *
00727  * Requires:
00728  *
00729  * \li  'db' is a valid database.
00730  *
00731  * \li  'name' is a valid, non-empty, absolute name.
00732  *
00733  * \li  nodep != NULL && *nodep == NULL
00734  *
00735  * Ensures:
00736  *
00737  * \li  On success, *nodep is attached to the node with name 'name'.
00738  *
00739  * Returns:
00740  *
00741  * \li  #ISC_R_SUCCESS
00742  * \li  #ISC_R_NOTFOUND                 If !create and name not found.
00743  * \li  #ISC_R_NOMEMORY                 Can only happen if create is ISC_TRUE.
00744  *
00745  * \li  Other results are possible, depending upon the database
00746  *      implementation used.
00747  */
00748 
00749 isc_result_t
00750 dns_db_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
00751             dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
00752             dns_dbnode_t **nodep, dns_name_t *foundname,
00753             dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
00754 
00755 isc_result_t
00756 dns_db_findext(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
00757                dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
00758                dns_dbnode_t **nodep, dns_name_t *foundname,
00759                dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo,
00760                dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
00761 /*%<
00762  * Find the best match for 'name' and 'type' in version 'version' of 'db'.
00763  *
00764  * dns_db_findext() (find extended) also accepts parameters 'methods'
00765  * and 'clientinfo', which when provided enable the database to retreive
00766  * information about the client from the caller, and modify its response
00767  * on the basis of this information.
00768  *
00769  * Notes:
00770  *
00771  * \li  If type == dns_rdataset_any, then rdataset will not be bound.
00772  *
00773  * \li  If 'options' does not have #DNS_DBFIND_GLUEOK set, then no glue will
00774  *      be returned.  For zone databases, glue is as defined in RFC2181.
00775  *      For cache databases, glue is any rdataset with a trust of
00776  *      dns_trust_glue.
00777  *
00778  * \li  If 'options' does not have #DNS_DBFIND_ADDITIONALOK set, then no
00779  *      additional records will be returned.  Only caches can have
00780  *      rdataset with trust dns_trust_additional.
00781  *
00782  * \li  If 'options' does not have #DNS_DBFIND_PENDINGOK set, then no
00783  *      pending data will be returned.  This option is only meaningful for
00784  *      cache databases.
00785  *
00786  * \li  If the #DNS_DBFIND_NOWILD option is set, then wildcard matching will
00787  *      be disabled.  This option is only meaningful for zone databases.
00788  *
00789  * \li  If the #DNS_DBFIND_NOZONECUT option is set, the database is
00790  *      assumed to contain no zone cuts above 'name'.  An implementation
00791  *      may therefore choose to search for a match beginning at 'name'
00792  *      rather than walking down the tree to check check for delegations.
00793  *      If #DNS_DBFIND_NOWILD is not set, wildcard matching will be
00794  *      attempted at each node starting at the direct ancestor of 'name'
00795  *      and working up to the zone origin.  This option is only meaningful
00796  *      when querying redirect zones.
00797  *
00798  * \li  If the #DNS_DBFIND_FORCENSEC option is set, the database is assumed to
00799  *      have NSEC records, and these will be returned when appropriate.  This
00800  *      is only necessary when querying a database that was not secure
00801  *      when created.
00802  *
00803  * \li  If the DNS_DBFIND_COVERINGNSEC option is set, then look for a
00804  *      NSEC record that potentially covers 'name' if a answer cannot
00805  *      be found.  Note the returned NSEC needs to be checked to ensure
00806  *      that it is correct.  This only affects answers returned from the
00807  *      cache.
00808  *
00809  * \li  If the #DNS_DBFIND_FORCENSEC3 option is set, then we are looking
00810  *      in the NSEC3 tree and not the main tree.  Without this option being
00811  *      set NSEC3 records will not be found.
00812  *
00813  * \li  To respond to a query for SIG records, the caller should create a
00814  *      rdataset iterator and extract the signatures from each rdataset.
00815  *
00816  * \li  Making queries of type ANY with #DNS_DBFIND_GLUEOK is not recommended,
00817  *      because the burden of determining whether a given rdataset is valid
00818  *      glue or not falls upon the caller.
00819  *
00820  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is a
00821  *      cache database, an rdataset will not be found unless it expires after
00822  *      'now'.  Any ANY query will not match unless at least one rdataset at
00823  *      the node expires after 'now'.  If 'now' is zero, then the current time
00824  *      will be used.
00825  *
00826  * Requires:
00827  *
00828  * \li  'db' is a valid database.
00829  *
00830  * \li  'type' is not SIG, or a meta-RR type other than 'ANY' (e.g. 'OPT').
00831  *
00832  * \li  'nodep' is NULL, or nodep is a valid pointer and *nodep == NULL.
00833  *
00834  * \li  'foundname' is a valid name with a dedicated buffer.
00835  *
00836  * \li  'rdataset' is NULL, or is a valid unassociated rdataset.
00837  *
00838  * Ensures,
00839  *      on a non-error completion:
00840  *
00841  *      \li     If nodep != NULL, then it is bound to the found node.
00842  *
00843  *      \li     If foundname != NULL, then it contains the full name of the
00844  *              found node.
00845  *
00846  *      \li     If rdataset != NULL and type != dns_rdatatype_any, then
00847  *              rdataset is bound to the found rdataset.
00848  *
00849  *      Non-error results are:
00850  *
00851  *      \li     #ISC_R_SUCCESS                  The desired node and type were
00852  *                                              found.
00853  *
00854  *      \li     #DNS_R_WILDCARD                 The desired node and type were
00855  *                                              found after performing
00856  *                                              wildcard matching.  This is
00857  *                                              only returned if the
00858  *                                              #DNS_DBFIND_INDICATEWILD
00859  *                                              option is set; otherwise
00860  *                                              #ISC_R_SUCCESS is returned.
00861  *
00862  *      \li     #DNS_R_GLUE                     The desired node and type were
00863  *                                              found, but are glue.  This
00864  *                                              result can only occur if
00865  *                                              the DNS_DBFIND_GLUEOK option
00866  *                                              is set.  This result can only
00867  *                                              occur if 'db' is a zone
00868  *                                              database.  If type ==
00869  *                                              dns_rdatatype_any, then the
00870  *                                              node returned may contain, or
00871  *                                              consist entirely of invalid
00872  *                                              glue (i.e. data occluded by a
00873  *                                              zone cut).  The caller must
00874  *                                              take care not to return invalid
00875  *                                              glue to a client.
00876  *
00877  *      \li     #DNS_R_DELEGATION               The data requested is beneath
00878  *                                              a zone cut.  node, foundname,
00879  *                                              and rdataset reference the
00880  *                                              NS RRset of the zone cut.
00881  *                                              If 'db' is a cache database,
00882  *                                              then this is the deepest known
00883  *                                              delegation.
00884  *
00885  *      \li     #DNS_R_ZONECUT                  type == dns_rdatatype_any, and
00886  *                                              the desired node is a zonecut.
00887  *                                              The caller must take care not
00888  *                                              to return inappropriate glue
00889  *                                              to a client.  This result can
00890  *                                              only occur if 'db' is a zone
00891  *                                              database and DNS_DBFIND_GLUEOK
00892  *                                              is set.
00893  *
00894  *      \li     #DNS_R_DNAME                    The data requested is beneath
00895  *                                              a DNAME.  node, foundname,
00896  *                                              and rdataset reference the
00897  *                                              DNAME RRset.
00898  *
00899  *      \li     #DNS_R_CNAME                    The rdataset requested was not
00900  *                                              found, but there is a CNAME
00901  *                                              at the desired name.  node,
00902  *                                              foundname, and rdataset
00903  *                                              reference the CNAME RRset.
00904  *
00905  *      \li     #DNS_R_NXDOMAIN                 The desired name does not
00906  *                                              exist.
00907  *
00908  *      \li     #DNS_R_NXRRSET                  The desired name exists, but
00909  *                                              the desired type does not.
00910  *
00911  *      \li     #ISC_R_NOTFOUND                 The desired name does not
00912  *                                              exist, and no delegation could
00913  *                                              be found.  This result can only
00914  *                                              occur if 'db' is a cache
00915  *                                              database.  The caller should
00916  *                                              use its nameserver(s) of last
00917  *                                              resort (e.g. root hints).
00918  *
00919  *      \li     #DNS_R_NCACHENXDOMAIN           The desired name does not
00920  *                                              exist.  'node' is bound to the
00921  *                                              cache node with the desired
00922  *                                              name, and 'rdataset' contains
00923  *                                              the negative caching proof.
00924  *
00925  *      \li     #DNS_R_NCACHENXRRSET            The desired type does not
00926  *                                              exist.  'node' is bound to the
00927  *                                              cache node with the desired
00928  *                                              name, and 'rdataset' contains
00929  *                                              the negative caching proof.
00930  *
00931  *      \li     #DNS_R_EMPTYNAME                The name exists but there is
00932  *                                              no data at the name.
00933  *
00934  *      \li     #DNS_R_COVERINGNSEC             The returned data is a NSEC
00935  *                                              that potentially covers 'name'.
00936  *
00937  *      \li     #DNS_R_EMPTYWILD                The name is a wildcard without
00938  *                                              resource records.
00939  *
00940  *      Error results:
00941  *
00942  *      \li     #ISC_R_NOMEMORY
00943  *
00944  *      \li     #DNS_R_BADDB                    Data that is required to be
00945  *                                              present in the DB, e.g. an NSEC
00946  *                                              record in a secure zone, is not
00947  *                                              present.
00948  *
00949  *      \li     Other results are possible, and should all be treated as
00950  *              errors.
00951  */
00952 
00953 isc_result_t
00954 dns_db_findzonecut(dns_db_t *db, dns_name_t *name,
00955                    unsigned int options, isc_stdtime_t now,
00956                    dns_dbnode_t **nodep, dns_name_t *foundname,
00957                    dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
00958 /*%<
00959  * Find the deepest known zonecut which encloses 'name' in 'db'.
00960  *
00961  * Notes:
00962  *
00963  * \li  If the #DNS_DBFIND_NOEXACT option is set, then the zonecut returned
00964  *      (if any) will be the deepest known ancestor of 'name'.
00965  *
00966  * \li  If 'now' is zero, then the current time will be used.
00967  *
00968  * Requires:
00969  *
00970  * \li  'db' is a valid database with cache semantics.
00971  *
00972  * \li  'nodep' is NULL, or nodep is a valid pointer and *nodep == NULL.
00973  *
00974  * \li  'foundname' is a valid name with a dedicated buffer.
00975  *
00976  * \li  'rdataset' is NULL, or is a valid unassociated rdataset.
00977  *
00978  * Ensures, on a non-error completion:
00979  *
00980  * \li  If nodep != NULL, then it is bound to the found node.
00981  *
00982  * \li  If foundname != NULL, then it contains the full name of the
00983  *      found node.
00984  *
00985  * \li  If rdataset != NULL and type != dns_rdatatype_any, then
00986  *      rdataset is bound to the found rdataset.
00987  *
00988  * Non-error results are:
00989  *
00990  * \li  #ISC_R_SUCCESS
00991  *
00992  * \li  #ISC_R_NOTFOUND
00993  *
00994  * \li  Other results are possible, and should all be treated as
00995  *      errors.
00996  */
00997 
00998 void
00999 dns_db_attachnode(dns_db_t *db, dns_dbnode_t *source, dns_dbnode_t **targetp);
01000 /*%<
01001  * Attach *targetp to source.
01002  *
01003  * Requires:
01004  *
01005  * \li  'db' is a valid database.
01006  *
01007  * \li  'source' is a valid node.
01008  *
01009  * \li  'targetp' points to a NULL dns_dbnode_t *.
01010  *
01011  * Ensures:
01012  *
01013  * \li  *targetp is attached to source.
01014  */
01015 
01016 void
01017 dns_db_detachnode(dns_db_t *db, dns_dbnode_t **nodep);
01018 /*%<
01019  * Detach *nodep from its node.
01020  *
01021  * Requires:
01022  *
01023  * \li  'db' is a valid database.
01024  *
01025  * \li  'nodep' points to a valid node.
01026  *
01027  * Ensures:
01028  *
01029  * \li  *nodep is NULL.
01030  */
01031 
01032 void
01033 dns_db_transfernode(dns_db_t *db, dns_dbnode_t **sourcep,
01034                     dns_dbnode_t **targetp);
01035 /*%<
01036  * Transfer a node between pointer.
01037  *
01038  * This is equivalent to calling dns_db_attachnode() then dns_db_detachnode().
01039  *
01040  * Requires:
01041  *
01042  * \li  'db' is a valid database.
01043  *
01044  * \li  '*sourcep' is a valid node.
01045  *
01046  * \li  'targetp' points to a NULL dns_dbnode_t *.
01047  *
01048  * Ensures:
01049  *
01050  * \li  '*sourcep' is NULL.
01051  */
01052 
01053 isc_result_t
01054 dns_db_expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now);
01055 /*%<
01056  * Mark as stale all records at 'node' which expire at or before 'now'.
01057  *
01058  * Note: if 'now' is zero, then the current time will be used.
01059  *
01060  * Requires:
01061  *
01062  * \li  'db' is a valid cache database.
01063  *
01064  * \li  'node' is a valid node.
01065  */
01066 
01067 void
01068 dns_db_printnode(dns_db_t *db, dns_dbnode_t *node, FILE *out);
01069 /*%<
01070  * Print a textual representation of the contents of the node to
01071  * 'out'.
01072  *
01073  * Note: this function is intended for debugging, not general use.
01074  *
01075  * Requires:
01076  *
01077  * \li  'db' is a valid database.
01078  *
01079  * \li  'node' is a valid node.
01080  */
01081 
01082 /***
01083  *** DB Iterator Creation
01084  ***/
01085 
01086 isc_result_t
01087 dns_db_createiterator(dns_db_t *db, unsigned int options,
01088                       dns_dbiterator_t **iteratorp);
01089 /*%<
01090  * Create an iterator for version 'version' of 'db'.
01091  *
01092  * Notes:
01093  *
01094  * \li  One or more of the following options can be set.
01095  *      #DNS_DB_RELATIVENAMES
01096  *      #DNS_DB_NSEC3ONLY
01097  *      #DNS_DB_NONSEC3
01098  *
01099  * Requires:
01100  *
01101  * \li  'db' is a valid database.
01102  *
01103  * \li  iteratorp != NULL && *iteratorp == NULL
01104  *
01105  * Ensures:
01106  *
01107  * \li  On success, *iteratorp will be a valid database iterator.
01108  *
01109  * Returns:
01110  *
01111  * \li  #ISC_R_SUCCESS
01112  * \li  #ISC_R_NOMEMORY
01113  */
01114 
01115 /***
01116  *** Rdataset Methods
01117  ***/
01118 
01119 /*
01120  * XXXRTH  Should we check for glue and pending data in dns_db_findrdataset()?
01121  */
01122 
01123 isc_result_t
01124 dns_db_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
01125                     dns_rdatatype_t type, dns_rdatatype_t covers,
01126                     isc_stdtime_t now, dns_rdataset_t *rdataset,
01127                     dns_rdataset_t *sigrdataset);
01128 
01129 /*%<
01130  * Search for an rdataset of type 'type' at 'node' that are in version
01131  * 'version' of 'db'.  If found, make 'rdataset' refer to it.
01132  *
01133  * Notes:
01134  *
01135  * \li  If 'version' is NULL, then the current version will be used.
01136  *
01137  * \li  Care must be used when using this routine to build a DNS response:
01138  *      'node' should have been found with dns_db_find(), not
01139  *      dns_db_findnode().  No glue checking is done.  No checking for
01140  *      pending data is done.
01141  *
01142  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is a
01143  *      cache database, an rdataset will not be found unless it expires after
01144  *      'now'.  If 'now' is zero, then the current time will be used.
01145  *
01146  * Requires:
01147  *
01148  * \li  'db' is a valid database.
01149  *
01150  * \li  'node' is a valid node.
01151  *
01152  * \li  'rdataset' is a valid, disassociated rdataset.
01153  *
01154  * \li  'sigrdataset' is a valid, disassociated rdataset, or it is NULL.
01155  *
01156  * \li  If 'covers' != 0, 'type' must be SIG.
01157  *
01158  * \li  'type' is not a meta-RR type such as 'ANY' or 'OPT'.
01159  *
01160  * Ensures:
01161  *
01162  * \li  On success, 'rdataset' is associated with the found rdataset.
01163  *
01164  * Returns:
01165  *
01166  * \li  #ISC_R_SUCCESS
01167  * \li  #ISC_R_NOTFOUND
01168  *
01169  * \li  Other results are possible, depending upon the database
01170  *      implementation used.
01171  */
01172 
01173 isc_result_t
01174 dns_db_allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
01175                     isc_stdtime_t now, dns_rdatasetiter_t **iteratorp);
01176 /*%<
01177  * Make '*iteratorp' an rdataset iterator for all rdatasets at 'node' in
01178  * version 'version' of 'db'.
01179  *
01180  * Notes:
01181  *
01182  * \li  If 'version' is NULL, then the current version will be used.
01183  *
01184  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is a
01185  *      cache database, an rdataset will not be found unless it expires after
01186  *      'now'.  Any ANY query will not match unless at least one rdataset at
01187  *      the node expires after 'now'.  If 'now' is zero, then the current time
01188  *      will be used.
01189  *
01190  * Requires:
01191  *
01192  * \li  'db' is a valid database.
01193  *
01194  * \li  'node' is a valid node.
01195  *
01196  * \li  iteratorp != NULL && *iteratorp == NULL
01197  *
01198  * Ensures:
01199  *
01200  * \li  On success, '*iteratorp' is a valid rdataset iterator.
01201  *
01202  * Returns:
01203  *
01204  * \li  #ISC_R_SUCCESS
01205  * \li  #ISC_R_NOTFOUND
01206  *
01207  * \li  Other results are possible, depending upon the database
01208  *      implementation used.
01209  */
01210 
01211 isc_result_t
01212 dns_db_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
01213                    isc_stdtime_t now, dns_rdataset_t *rdataset,
01214                    unsigned int options, dns_rdataset_t *addedrdataset);
01215 /*%<
01216  * Add 'rdataset' to 'node' in version 'version' of 'db'.
01217  *
01218  * Notes:
01219  *
01220  * \li  If the database has zone semantics, the #DNS_DBADD_MERGE option is set,
01221  *      and an rdataset of the same type as 'rdataset' already exists at
01222  *      'node' then the contents of 'rdataset' will be merged with the existing
01223  *      rdataset.  If the option is not set, then rdataset will replace any
01224  *      existing rdataset of the same type.  If not merging and the
01225  *      #DNS_DBADD_FORCE option is set, then the data will update the database
01226  *      without regard to trust levels.  If not forcing the data, then the
01227  *      rdataset will only be added if its trust level is >= the trust level of
01228  *      any existing rdataset.  Forcing is only meaningful for cache databases.
01229  *      If #DNS_DBADD_EXACT is set then there must be no rdata in common between
01230  *      the old and new rdata sets.  If #DNS_DBADD_EXACTTTL is set then both
01231  *      the old and new rdata sets must have the same ttl.
01232  *
01233  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is
01234  *      a cache database, then the added rdataset will expire no later than
01235  *      now + rdataset->ttl.
01236  *
01237  * \li  If 'addedrdataset' is not NULL, then it will be attached to the
01238  *      resulting new rdataset in the database, or to the existing data if
01239  *      the existing data was better.
01240  *
01241  * Requires:
01242  *
01243  * \li  'db' is a valid database.
01244  *
01245  * \li  'node' is a valid node.
01246  *
01247  * \li  'rdataset' is a valid, associated rdataset with the same class
01248  *      as 'db'.
01249  *
01250  * \li  'addedrdataset' is NULL, or a valid, unassociated rdataset.
01251  *
01252  * \li  The database has zone semantics and 'version' is a valid
01253  *      read-write version, or the database has cache semantics
01254  *      and version is NULL.
01255  *
01256  * \li  If the database has cache semantics, the #DNS_DBADD_MERGE option must
01257  *      not be set.
01258  *
01259  * Returns:
01260  *
01261  * \li  #ISC_R_SUCCESS
01262  * \li  #DNS_R_UNCHANGED                        The operation did not change anything.
01263  * \li  #ISC_R_NOMEMORY
01264  * \li  #DNS_R_NOTEXACT
01265  *
01266  * \li  Other results are possible, depending upon the database
01267  *      implementation used.
01268  */
01269 
01270 isc_result_t
01271 dns_db_subtractrdataset(dns_db_t *db, dns_dbnode_t *node,
01272                         dns_dbversion_t *version, dns_rdataset_t *rdataset,
01273                         unsigned int options, dns_rdataset_t *newrdataset);
01274 /*%<
01275  * Remove any rdata in 'rdataset' from 'node' in version 'version' of
01276  * 'db'.
01277  *
01278  * Notes:
01279  *
01280  * \li  If 'newrdataset' is not NULL, then it will be attached to the
01281  *      resulting new rdataset in the database, unless the rdataset has
01282  *      become nonexistent.  If DNS_DBSUB_EXACT is set then all elements
01283  *      of 'rdataset' must exist at 'node'.
01284  *
01285  *\li   If DNS_DBSUB_WANTOLD is set and the entire rdataset was deleted
01286  *      then return the original rdatatset in newrdataset if that existed.
01287  *
01288  * Requires:
01289  *
01290  * \li  'db' is a valid database.
01291  *
01292  * \li  'node' is a valid node.
01293  *
01294  * \li  'rdataset' is a valid, associated rdataset with the same class
01295  *      as 'db'.
01296  *
01297  * \li  'newrdataset' is NULL, or a valid, unassociated rdataset.
01298  *
01299  * \li  The database has zone semantics and 'version' is a valid
01300  *      read-write version.
01301  *
01302  * Returns:
01303  *
01304  * \li  #ISC_R_SUCCESS
01305  * \li  #DNS_R_UNCHANGED                        The operation did not change anything.
01306  * \li  #DNS_R_NXRRSET                  All rdata of the same type as those
01307  *                                      in 'rdataset' have been deleted.
01308  * \li  #DNS_R_NOTEXACT                 Some part of 'rdataset' did not
01309  *                                      exist and DNS_DBSUB_EXACT was set.
01310  *
01311  * \li  Other results are possible, depending upon the database
01312  *      implementation used.
01313  */
01314 
01315 isc_result_t
01316 dns_db_deleterdataset(dns_db_t *db, dns_dbnode_t *node,
01317                       dns_dbversion_t *version, dns_rdatatype_t type,
01318                       dns_rdatatype_t covers);
01319 /*%<
01320  * Make it so that no rdataset of type 'type' exists at 'node' in version
01321  * version 'version' of 'db'.
01322  *
01323  * Notes:
01324  *
01325  * \li  If 'type' is dns_rdatatype_any, then no rdatasets will exist in
01326  *      'version' (provided that the dns_db_deleterdataset() isn't followed
01327  *      by one or more dns_db_addrdataset() calls).
01328  *
01329  * Requires:
01330  *
01331  * \li  'db' is a valid database.
01332  *
01333  * \li  'node' is a valid node.
01334  *
01335  * \li  The database has zone semantics and 'version' is a valid
01336  *      read-write version, or the database has cache semantics
01337  *      and version is NULL.
01338  *
01339  * \li  'type' is not a meta-RR type, except for dns_rdatatype_any, which is
01340  *      allowed.
01341  *
01342  * \li  If 'covers' != 0, 'type' must be SIG.
01343  *
01344  * Returns:
01345  *
01346  * \li  #ISC_R_SUCCESS
01347  * \li  #DNS_R_UNCHANGED                        No rdatasets of 'type' existed before
01348  *                                      the operation was attempted.
01349  *
01350  * \li  Other results are possible, depending upon the database
01351  *      implementation used.
01352  */
01353 
01354 isc_result_t
01355 dns_db_getsoaserial(dns_db_t *db, dns_dbversion_t *ver, isc_uint32_t *serialp);
01356 /*%<
01357  * Get the current SOA serial number from a zone database.
01358  *
01359  * Requires:
01360  * \li  'db' is a valid database with zone semantics.
01361  * \li  'ver' is a valid version.
01362  */
01363 
01364 void
01365 dns_db_overmem(dns_db_t *db, isc_boolean_t overmem);
01366 /*%<
01367  * Enable / disable aggressive cache cleaning.
01368  */
01369 
01370 unsigned int
01371 dns_db_nodecount(dns_db_t *db);
01372 /*%<
01373  * Count the number of nodes in 'db'.
01374  *
01375  * Requires:
01376  *
01377  * \li  'db' is a valid database.
01378  *
01379  * Returns:
01380  * \li  The number of nodes in the database
01381  */
01382 
01383 unsigned int
01384 dns_db_hashsize(dns_db_t *db);
01385 /*%<
01386  * For database implementations using a hash table, report the
01387  * current number of buckets.
01388  *
01389  * Requires:
01390  *
01391  * \li  'db' is a valid database.
01392  *
01393  * Returns:
01394  * \li  The number of buckets in the database's hash table, or
01395  *      ISC_R_NOTIMPLEMENTED.
01396  */
01397 
01398 void
01399 dns_db_settask(dns_db_t *db, isc_task_t *task);
01400 /*%<
01401  * If task is set then the final detach maybe performed asynchronously.
01402  *
01403  * Requires:
01404  * \li  'db' is a valid database.
01405  * \li  'task' to be valid or NULL.
01406  */
01407 
01408 isc_boolean_t
01409 dns_db_ispersistent(dns_db_t *db);
01410 /*%<
01411  * Is 'db' persistent?  A persistent database does not need to be loaded
01412  * from disk or written to disk.
01413  *
01414  * Requires:
01415  *
01416  * \li  'db' is a valid database.
01417  *
01418  * Returns:
01419  * \li  #ISC_TRUE       'db' is persistent.
01420  * \li  #ISC_FALSE      'db' is not persistent.
01421  */
01422 
01423 isc_result_t
01424 dns_db_register(const char *name, dns_dbcreatefunc_t create, void *driverarg,
01425                 isc_mem_t *mctx, dns_dbimplementation_t **dbimp);
01426 
01427 /*%<
01428  * Register a new database implementation and add it to the list of
01429  * supported implementations.
01430  *
01431  * Requires:
01432  *
01433  * \li  'name' is not NULL
01434  * \li  'order' is a valid function pointer
01435  * \li  'mctx' is a valid memory context
01436  * \li  dbimp != NULL && *dbimp == NULL
01437  *
01438  * Returns:
01439  * \li  #ISC_R_SUCCESS  The registration succeeded
01440  * \li  #ISC_R_NOMEMORY Out of memory
01441  * \li  #ISC_R_EXISTS   A database implementation with the same name exists
01442  *
01443  * Ensures:
01444  *
01445  * \li  *dbimp points to an opaque structure which must be passed to
01446  *      dns_db_unregister().
01447  */
01448 
01449 void
01450 dns_db_unregister(dns_dbimplementation_t **dbimp);
01451 /*%<
01452  * Remove a database implementation from the list of supported
01453  * implementations.  No databases of this type can be active when this
01454  * is called.
01455  *
01456  * Requires:
01457  * \li  dbimp != NULL && *dbimp == NULL
01458  *
01459  * Ensures:
01460  *
01461  * \li  Any memory allocated in *dbimp will be freed.
01462  */
01463 
01464 isc_result_t
01465 dns_db_getoriginnode(dns_db_t *db, dns_dbnode_t **nodep);
01466 /*%<
01467  * Get the origin DB node corresponding to the DB's zone.  This function
01468  * should typically succeed unless the underlying DB implementation doesn't
01469  * support the feature.
01470  *
01471  * Requires:
01472  *
01473  * \li  'db' is a valid zone database.
01474  * \li  'nodep' != NULL && '*nodep' == NULL
01475  *
01476  * Ensures:
01477  * \li  On success, '*nodep' will point to the DB node of the zone's origin.
01478  *
01479  * Returns:
01480  * \li  #ISC_R_SUCCESS
01481  * \li  #ISC_R_NOTFOUND - the DB implementation does not support this feature.
01482  */
01483 
01484 isc_result_t
01485 dns_db_getnsec3parameters(dns_db_t *db, dns_dbversion_t *version,
01486                           dns_hash_t *hash, isc_uint8_t *flags,
01487                           isc_uint16_t *interations,
01488                           unsigned char *salt, size_t *salt_length);
01489 /*%<
01490  * Get the NSEC3 parameters that are associated with this zone.
01491  *
01492  * Requires:
01493  * \li  'db' is a valid zone database.
01494  *
01495  * Returns:
01496  * \li  #ISC_R_SUCCESS
01497  * \li  #ISC_R_NOTFOUND - the DB implementation does not support this feature
01498  *                        or this zone does not have NSEC3 records.
01499  */
01500 
01501 isc_result_t
01502 dns_db_findnsec3node(dns_db_t *db, dns_name_t *name,
01503                      isc_boolean_t create, dns_dbnode_t **nodep);
01504 /*%<
01505  * Find the NSEC3 node with name 'name'.
01506  *
01507  * Notes:
01508  * \li  If 'create' is ISC_TRUE and no node with name 'name' exists, then
01509  *      such a node will be created.
01510  *
01511  * Requires:
01512  *
01513  * \li  'db' is a valid database.
01514  *
01515  * \li  'name' is a valid, non-empty, absolute name.
01516  *
01517  * \li  nodep != NULL && *nodep == NULL
01518  *
01519  * Ensures:
01520  *
01521  * \li  On success, *nodep is attached to the node with name 'name'.
01522  *
01523  * Returns:
01524  *
01525  * \li  #ISC_R_SUCCESS
01526  * \li  #ISC_R_NOTFOUND                 If !create and name not found.
01527  * \li  #ISC_R_NOMEMORY                 Can only happen if create is ISC_TRUE.
01528  *
01529  * \li  Other results are possible, depending upon the database
01530  *      implementation used.
01531  */
01532 
01533 isc_result_t
01534 dns_db_setsigningtime(dns_db_t *db, dns_rdataset_t *rdataset,
01535                       isc_stdtime_t resign);
01536 /*%<
01537  * Sets the re-signing time associated with 'rdataset' to 'resign'.
01538  *
01539  * Requires:
01540  * \li  'db' is a valid zone database.
01541  * \li  'rdataset' is or is to be associated with 'db'.
01542  * \li  'rdataset' is not pending removed from the heap via an
01543  *       uncommitted call to dns_db_resigned().
01544  *
01545  * Returns:
01546  * \li  #ISC_R_SUCCESS
01547  * \li  #ISC_R_NOMEMORY
01548  * \li  #ISC_R_NOTIMPLEMENTED - Not supported by this DB implementation.
01549  */
01550 
01551 isc_result_t
01552 dns_db_getsigningtime(dns_db_t *db, dns_rdataset_t *rdataset, dns_name_t *name);
01553 /*%<
01554  * Return the rdataset with the earliest signing time in the zone.
01555  * Note: the rdataset is version agnostic.
01556  *
01557  * Requires:
01558  * \li  'db' is a valid zone database.
01559  * \li  'rdataset' to be initialized but not associated.
01560  * \li  'name' to be NULL or have a buffer associated with it.
01561  *
01562  * Returns:
01563  * \li  #ISC_R_SUCCESS
01564  * \li  #ISC_R_NOTFOUND - No dataset exists.
01565  */
01566 
01567 void
01568 dns_db_resigned(dns_db_t *db, dns_rdataset_t *rdataset,
01569                 dns_dbversion_t *version);
01570 /*%<
01571  * Mark 'rdataset' as not being available to be returned by
01572  * dns_db_getsigningtime().  If the changes associated with 'version'
01573  * are committed this will be permanent.  If the version is not committed
01574  * this change will be rolled back when the version is closed.  Until
01575  * 'version' is either committed or rolled back, 'rdataset' can no longer
01576  * be acted upon by dns_db_setsigningtime().
01577  *
01578  * Requires:
01579  * \li  'db' is a valid zone database.
01580  * \li  'rdataset' to be associated with 'db'.
01581  * \li  'version' to be open for writing.
01582  */
01583 
01584 dns_stats_t *
01585 dns_db_getrrsetstats(dns_db_t *db);
01586 /*%<
01587  * Get statistics information counting RRsets stored in the DB, when available.
01588  * The statistics may not be available depending on the DB implementation.
01589  *
01590  * Requires:
01591  *
01592  * \li  'db' is a valid database (cache only).
01593  *
01594  * Returns:
01595  * \li  when available, a pointer to a statistics object created by
01596  *      dns_rdatasetstats_create(); otherwise NULL.
01597  */
01598 
01599 isc_result_t
01600 dns_db_setcachestats(dns_db_t *db, isc_stats_t *stats);
01601 /*%<
01602  * Set the location in which to collect cache statistics.
01603  * This option may not exist depending on the DB implementation.
01604  *
01605  * Requires:
01606  *
01607  * \li  'db' is a valid database (cache only).
01608  *
01609  * Returns:
01610  * \li  when available, a pointer to a statistics object created by
01611  *      dns_rdatasetstats_create(); otherwise NULL.
01612  */
01613 
01614 void
01615 dns_db_rpz_attach(dns_db_t *db, dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num);
01616 /*%<
01617  * Attach the response policy information for a view to a database for a
01618  * zone for the view.
01619  */
01620 
01621 isc_result_t
01622 dns_db_rpz_ready(dns_db_t *db);
01623 /*%<
01624  * Finish loading a response policy zone.
01625  */
01626 
01627 ISC_LANG_ENDDECLS
01628 
01629 #endif /* DNS_DB_H */

Generated on Tue Apr 28 17:40:57 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha