]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - contrib/bind9/lib/dns/include/dns/db.h
MFC 202961:
[FreeBSD/stable/8.git] / contrib / bind9 / lib / dns / include / dns / db.h
1 /*
2  * Copyright (C) 2004-2009  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: db.h,v 1.93.50.3.12.1 2009/12/31 21:44:37 each Exp $ */
19
20 #ifndef DNS_DB_H
21 #define DNS_DB_H 1
22
23 /*****
24  ***** Module Info
25  *****/
26
27 /*! \file dns/db.h
28  * \brief
29  * The DNS DB interface allows named rdatasets to be stored and retrieved.
30  *
31  * The dns_db_t type is like a "virtual class".  To actually use
32  * DBs, an implementation of the class is required.
33  *
34  * XXX more XXX
35  *
36  * MP:
37  * \li  The module ensures appropriate synchronization of data structures it
38  *      creates and manipulates.
39  *
40  * Reliability:
41  * \li  No anticipated impact.
42  *
43  * Resources:
44  * \li  TBS
45  *
46  * Security:
47  * \li  No anticipated impact.
48  *
49  * Standards:
50  * \li  None.
51  */
52
53 /*****
54  ***** Imports
55  *****/
56
57 #include <isc/lang.h>
58 #include <isc/magic.h>
59 #include <isc/ondestroy.h>
60 #include <isc/stdtime.h>
61
62 #include <dns/name.h>
63 #include <dns/types.h>
64
65 ISC_LANG_BEGINDECLS
66
67 /*****
68  ***** Types
69  *****/
70
71 typedef struct dns_dbmethods {
72         void            (*attach)(dns_db_t *source, dns_db_t **targetp);
73         void            (*detach)(dns_db_t **dbp);
74         isc_result_t    (*beginload)(dns_db_t *db, dns_addrdatasetfunc_t *addp,
75                                      dns_dbload_t **dbloadp);
76         isc_result_t    (*endload)(dns_db_t *db, dns_dbload_t **dbloadp);
77         isc_result_t    (*dump)(dns_db_t *db, dns_dbversion_t *version,
78                                 const char *filename,
79                                 dns_masterformat_t masterformat);
80         void            (*currentversion)(dns_db_t *db,
81                                           dns_dbversion_t **versionp);
82         isc_result_t    (*newversion)(dns_db_t *db,
83                                       dns_dbversion_t **versionp);
84         void            (*attachversion)(dns_db_t *db, dns_dbversion_t *source,
85                                          dns_dbversion_t **targetp);
86         void            (*closeversion)(dns_db_t *db,
87                                         dns_dbversion_t **versionp,
88                                         isc_boolean_t commit);
89         isc_result_t    (*findnode)(dns_db_t *db, dns_name_t *name,
90                                     isc_boolean_t create,
91                                     dns_dbnode_t **nodep);
92         isc_result_t    (*find)(dns_db_t *db, dns_name_t *name,
93                                 dns_dbversion_t *version,
94                                 dns_rdatatype_t type, unsigned int options,
95                                 isc_stdtime_t now,
96                                 dns_dbnode_t **nodep, dns_name_t *foundname,
97                                 dns_rdataset_t *rdataset,
98                                 dns_rdataset_t *sigrdataset);
99         isc_result_t    (*findzonecut)(dns_db_t *db, dns_name_t *name,
100                                        unsigned int options, isc_stdtime_t now,
101                                        dns_dbnode_t **nodep,
102                                        dns_name_t *foundname,
103                                        dns_rdataset_t *rdataset,
104                                        dns_rdataset_t *sigrdataset);
105         void            (*attachnode)(dns_db_t *db,
106                                       dns_dbnode_t *source,
107                                       dns_dbnode_t **targetp);
108         void            (*detachnode)(dns_db_t *db,
109                                       dns_dbnode_t **targetp);
110         isc_result_t    (*expirenode)(dns_db_t *db, dns_dbnode_t *node,
111                                       isc_stdtime_t now);
112         void            (*printnode)(dns_db_t *db, dns_dbnode_t *node,
113                                      FILE *out);
114         isc_result_t    (*createiterator)(dns_db_t *db, unsigned int options,
115                                           dns_dbiterator_t **iteratorp);
116         isc_result_t    (*findrdataset)(dns_db_t *db, dns_dbnode_t *node,
117                                         dns_dbversion_t *version,
118                                         dns_rdatatype_t type,
119                                         dns_rdatatype_t covers,
120                                         isc_stdtime_t now,
121                                         dns_rdataset_t *rdataset,
122                                         dns_rdataset_t *sigrdataset);
123         isc_result_t    (*allrdatasets)(dns_db_t *db, dns_dbnode_t *node,
124                                         dns_dbversion_t *version,
125                                         isc_stdtime_t now,
126                                         dns_rdatasetiter_t **iteratorp);
127         isc_result_t    (*addrdataset)(dns_db_t *db, dns_dbnode_t *node,
128                                        dns_dbversion_t *version,
129                                        isc_stdtime_t now,
130                                        dns_rdataset_t *rdataset,
131                                        unsigned int options,
132                                        dns_rdataset_t *addedrdataset);
133         isc_result_t    (*subtractrdataset)(dns_db_t *db, dns_dbnode_t *node,
134                                             dns_dbversion_t *version,
135                                             dns_rdataset_t *rdataset,
136                                             unsigned int options,
137                                             dns_rdataset_t *newrdataset);
138         isc_result_t    (*deleterdataset)(dns_db_t *db, dns_dbnode_t *node,
139                                           dns_dbversion_t *version,
140                                           dns_rdatatype_t type,
141                                           dns_rdatatype_t covers);
142         isc_boolean_t   (*issecure)(dns_db_t *db);
143         unsigned int    (*nodecount)(dns_db_t *db);
144         isc_boolean_t   (*ispersistent)(dns_db_t *db);
145         void            (*overmem)(dns_db_t *db, isc_boolean_t overmem);
146         void            (*settask)(dns_db_t *db, isc_task_t *);
147         isc_result_t    (*getoriginnode)(dns_db_t *db, dns_dbnode_t **nodep);
148         void            (*transfernode)(dns_db_t *db, dns_dbnode_t **sourcep,
149                                         dns_dbnode_t **targetp);
150         isc_result_t    (*getnsec3parameters)(dns_db_t *db,
151                                               dns_dbversion_t *version,
152                                               dns_hash_t *hash,
153                                               isc_uint8_t *flags,
154                                               isc_uint16_t *iterations,
155                                               unsigned char *salt,
156                                               size_t *salt_len);
157         isc_result_t    (*findnsec3node)(dns_db_t *db, dns_name_t *name,
158                                          isc_boolean_t create,
159                                          dns_dbnode_t **nodep);
160         isc_result_t    (*setsigningtime)(dns_db_t *db,
161                                           dns_rdataset_t *rdataset,
162                                           isc_stdtime_t resign);
163         isc_result_t    (*getsigningtime)(dns_db_t *db,
164                                           dns_rdataset_t *rdataset,
165                                           dns_name_t *name);
166         void            (*resigned)(dns_db_t *db, dns_rdataset_t *rdataset,
167                                            dns_dbversion_t *version);
168         isc_boolean_t   (*isdnssec)(dns_db_t *db);
169         dns_stats_t     *(*getrrsetstats)(dns_db_t *db);
170 } dns_dbmethods_t;
171
172 typedef isc_result_t
173 (*dns_dbcreatefunc_t)(isc_mem_t *mctx, dns_name_t *name,
174                       dns_dbtype_t type, dns_rdataclass_t rdclass,
175                       unsigned int argc, char *argv[], void *driverarg,
176                       dns_db_t **dbp);
177
178 #define DNS_DB_MAGIC            ISC_MAGIC('D','N','S','D')
179 #define DNS_DB_VALID(db)        ISC_MAGIC_VALID(db, DNS_DB_MAGIC)
180
181 /*%
182  * This structure is actually just the common prefix of a DNS db
183  * implementation's version of a dns_db_t.
184  * \brief
185  * Direct use of this structure by clients is forbidden.  DB implementations
186  * may change the structure.  'magic' must be DNS_DB_MAGIC for any of the
187  * dns_db_ routines to work.  DB implementations must maintain all DB
188  * invariants.
189  */
190 struct dns_db {
191         unsigned int                    magic;
192         unsigned int                    impmagic;
193         dns_dbmethods_t *               methods;
194         isc_uint16_t                    attributes;
195         dns_rdataclass_t                rdclass;
196         dns_name_t                      origin;
197         isc_ondestroy_t                 ondest;
198         isc_mem_t *                     mctx;
199 };
200
201 #define DNS_DBATTR_CACHE                0x01
202 #define DNS_DBATTR_STUB                 0x02
203
204 /*@{*/
205 /*%
206  * Options that can be specified for dns_db_find().
207  */
208 #define DNS_DBFIND_GLUEOK               0x0001
209 #define DNS_DBFIND_VALIDATEGLUE         0x0002
210 #define DNS_DBFIND_NOWILD               0x0004
211 #define DNS_DBFIND_PENDINGOK            0x0008
212 #define DNS_DBFIND_NOEXACT              0x0010
213 #define DNS_DBFIND_FORCENSEC            0x0020
214 #define DNS_DBFIND_COVERINGNSEC         0x0040
215 #define DNS_DBFIND_FORCENSEC3           0x0080
216 #define DNS_DBFIND_ADDITIONALOK         0x0100
217 /*@}*/
218
219 /*@{*/
220 /*%
221  * Options that can be specified for dns_db_addrdataset().
222  */
223 #define DNS_DBADD_MERGE                 0x01
224 #define DNS_DBADD_FORCE                 0x02
225 #define DNS_DBADD_EXACT                 0x04
226 #define DNS_DBADD_EXACTTTL              0x08
227 /*@}*/
228
229 /*%
230  * Options that can be specified for dns_db_subtractrdataset().
231  */
232 #define DNS_DBSUB_EXACT                 0x01
233
234 /*@{*/
235 /*%
236  * Iterator options
237  */
238 #define DNS_DB_RELATIVENAMES    0x1
239 #define DNS_DB_NSEC3ONLY        0x2
240 #define DNS_DB_NONSEC3          0x4
241 /*@}*/
242
243 /*****
244  ***** Methods
245  *****/
246
247 /***
248  *** Basic DB Methods
249  ***/
250
251 isc_result_t
252 dns_db_create(isc_mem_t *mctx, const char *db_type, dns_name_t *origin,
253               dns_dbtype_t type, dns_rdataclass_t rdclass,
254               unsigned int argc, char *argv[], dns_db_t **dbp);
255 /*%<
256  * Create a new database using implementation 'db_type'.
257  *
258  * Notes:
259  * \li  All names in the database must be subdomains of 'origin' and in class
260  *      'rdclass'.  The database makes its own copy of the origin, so the
261  *      caller may do whatever they like with 'origin' and its storage once the
262  *      call returns.
263  *
264  * \li  DB implementation-specific parameters are passed using argc and argv.
265  *
266  * Requires:
267  *
268  * \li  dbp != NULL and *dbp == NULL
269  *
270  * \li  'origin' is a valid absolute domain name.
271  *
272  * \li  mctx is a valid memory context
273  *
274  * Ensures:
275  *
276  * \li  A copy of 'origin' has been made for the databases use, and the
277  *      caller is free to do whatever they want with the name and storage
278  *      associated with 'origin'.
279  *
280  * Returns:
281  *
282  * \li  #ISC_R_SUCCESS
283  * \li  #ISC_R_NOMEMORY
284  * \li  #ISC_R_NOTFOUND                         db_type not found
285  *
286  * \li  Many other errors are possible, depending on what db_type was
287  *      specified.
288  */
289
290 void
291 dns_db_attach(dns_db_t *source, dns_db_t **targetp);
292 /*%<
293  * Attach *targetp to source.
294  *
295  * Requires:
296  *
297  * \li  'source' is a valid database.
298  *
299  * \li  'targetp' points to a NULL dns_db_t *.
300  *
301  * Ensures:
302  *
303  * \li  *targetp is attached to source.
304  */
305
306 void
307 dns_db_detach(dns_db_t **dbp);
308 /*%<
309  * Detach *dbp from its database.
310  *
311  * Requires:
312  *
313  * \li  'dbp' points to a valid database.
314  *
315  * Ensures:
316  *
317  * \li  *dbp is NULL.
318  *
319  * \li  If '*dbp' is the last reference to the database,
320  *              all resources used by the database will be freed
321  */
322
323 isc_result_t
324 dns_db_ondestroy(dns_db_t *db, isc_task_t *task, isc_event_t **eventp);
325 /*%<
326  * Causes 'eventp' to be sent to be sent to 'task' when the database is
327  * destroyed.
328  *
329  * Note; ownership of the eventp is taken from the caller (and *eventp is
330  * set to NULL). The sender field of the event is set to 'db' before it is
331  * sent to the task.
332  */
333
334 isc_boolean_t
335 dns_db_iscache(dns_db_t *db);
336 /*%<
337  * Does 'db' have cache semantics?
338  *
339  * Requires:
340  *
341  * \li  'db' is a valid database.
342  *
343  * Returns:
344  * \li  #ISC_TRUE       'db' has cache semantics
345  * \li  #ISC_FALSE      otherwise
346  */
347
348 isc_boolean_t
349 dns_db_iszone(dns_db_t *db);
350 /*%<
351  * Does 'db' have zone semantics?
352  *
353  * Requires:
354  *
355  * \li  'db' is a valid database.
356  *
357  * Returns:
358  * \li  #ISC_TRUE       'db' has zone semantics
359  * \li  #ISC_FALSE      otherwise
360  */
361
362 isc_boolean_t
363 dns_db_isstub(dns_db_t *db);
364 /*%<
365  * Does 'db' have stub semantics?
366  *
367  * Requires:
368  *
369  * \li  'db' is a valid database.
370  *
371  * Returns:
372  * \li  #ISC_TRUE       'db' has zone semantics
373  * \li  #ISC_FALSE      otherwise
374  */
375
376 isc_boolean_t
377 dns_db_issecure(dns_db_t *db);
378 /*%<
379  * Is 'db' secure?
380  *
381  * Requires:
382  *
383  * \li  'db' is a valid database with zone semantics.
384  *
385  * Returns:
386  * \li  #ISC_TRUE       'db' is secure.
387  * \li  #ISC_FALSE      'db' is not secure.
388  */
389
390 isc_boolean_t
391 dns_db_isdnssec(dns_db_t *db);
392 /*%<
393  * Is 'db' secure or partially secure?
394  *
395  * Requires:
396  *
397  * \li  'db' is a valid database with zone semantics.
398  *
399  * Returns:
400  * \li  #ISC_TRUE       'db' is secure or is partially.
401  * \li  #ISC_FALSE      'db' is not secure.
402  */
403
404 dns_name_t *
405 dns_db_origin(dns_db_t *db);
406 /*%<
407  * The origin of the database.
408  *
409  * Note: caller must not try to change this name.
410  *
411  * Requires:
412  *
413  * \li  'db' is a valid database.
414  *
415  * Returns:
416  *
417  * \li  The origin of the database.
418  */
419
420 dns_rdataclass_t
421 dns_db_class(dns_db_t *db);
422 /*%<
423  * The class of the database.
424  *
425  * Requires:
426  *
427  * \li  'db' is a valid database.
428  *
429  * Returns:
430  *
431  * \li  The class of the database.
432  */
433
434 isc_result_t
435 dns_db_beginload(dns_db_t *db, dns_addrdatasetfunc_t *addp,
436                  dns_dbload_t **dbloadp);
437 /*%<
438  * Begin loading 'db'.
439  *
440  * Requires:
441  *
442  * \li  'db' is a valid database.
443  *
444  * \li  This is the first attempt to load 'db'.
445  *
446  * \li  addp != NULL && *addp == NULL
447  *
448  * \li  dbloadp != NULL && *dbloadp == NULL
449  *
450  * Ensures:
451  *
452  * \li  On success, *addp will be a valid dns_addrdatasetfunc_t suitable
453  *      for loading 'db'.  *dbloadp will be a valid DB load context which
454  *      should be used as 'arg' when *addp is called.
455  *
456  * Returns:
457  *
458  * \li  #ISC_R_SUCCESS
459  * \li  #ISC_R_NOMEMORY
460  *
461  * \li  Other results are possible, depending upon the database
462  *      implementation used, syntax errors in the master file, etc.
463  */
464
465 isc_result_t
466 dns_db_endload(dns_db_t *db, dns_dbload_t **dbloadp);
467 /*%<
468  * Finish loading 'db'.
469  *
470  * Requires:
471  *
472  * \li  'db' is a valid database that is being loaded.
473  *
474  * \li  dbloadp != NULL and *dbloadp is a valid database load context.
475  *
476  * Ensures:
477  *
478  * \li  *dbloadp == NULL
479  *
480  * Returns:
481  *
482  * \li  #ISC_R_SUCCESS
483  * \li  #ISC_R_NOMEMORY
484  *
485  * \li  Other results are possible, depending upon the database
486  *      implementation used, syntax errors in the master file, etc.
487  */
488
489 isc_result_t
490 dns_db_load(dns_db_t *db, const char *filename);
491
492 isc_result_t
493 dns_db_load2(dns_db_t *db, const char *filename, dns_masterformat_t format);
494 /*%<
495  * Load master file 'filename' into 'db'.
496  *
497  * Notes:
498  * \li  This routine is equivalent to calling
499  *
500  *\code
501  *              dns_db_beginload();
502  *              dns_master_loadfile();
503  *              dns_db_endload();
504  *\endcode
505  *
506  * Requires:
507  *
508  * \li  'db' is a valid database.
509  *
510  * \li  This is the first attempt to load 'db'.
511  *
512  * Returns:
513  *
514  * \li  #ISC_R_SUCCESS
515  * \li  #ISC_R_NOMEMORY
516  *
517  * \li  Other results are possible, depending upon the database
518  *      implementation used, syntax errors in the master file, etc.
519  */
520
521 isc_result_t
522 dns_db_dump(dns_db_t *db, dns_dbversion_t *version, const char *filename);
523
524 isc_result_t
525 dns_db_dump2(dns_db_t *db, dns_dbversion_t *version, const char *filename,
526              dns_masterformat_t masterformat);
527 /*%<
528  * Dump version 'version' of 'db' to master file 'filename'.
529  *
530  * Requires:
531  *
532  * \li  'db' is a valid database.
533  *
534  * \li  'version' is a valid version.
535  *
536  * Returns:
537  *
538  * \li  #ISC_R_SUCCESS
539  * \li  #ISC_R_NOMEMORY
540  *
541  * \li  Other results are possible, depending upon the database
542  *      implementation used, OS file errors, etc.
543  */
544
545 /***
546  *** Version Methods
547  ***/
548
549 void
550 dns_db_currentversion(dns_db_t *db, dns_dbversion_t **versionp);
551 /*%<
552  * Open the current version for reading.
553  *
554  * Requires:
555  *
556  * \li  'db' is a valid database with zone semantics.
557  *
558  * \li  versionp != NULL && *verisonp == NULL
559  *
560  * Ensures:
561  *
562  * \li  On success, '*versionp' is attached to the current version.
563  *
564  */
565
566 isc_result_t
567 dns_db_newversion(dns_db_t *db, dns_dbversion_t **versionp);
568 /*%<
569  * Open a new version for reading and writing.
570  *
571  * Requires:
572  *
573  * \li  'db' is a valid database with zone semantics.
574  *
575  * \li  versionp != NULL && *verisonp == NULL
576  *
577  * Ensures:
578  *
579  * \li  On success, '*versionp' is attached to the current version.
580  *
581  * Returns:
582  *
583  * \li  #ISC_R_SUCCESS
584  * \li  #ISC_R_NOMEMORY
585  *
586  * \li  Other results are possible, depending upon the database
587  *      implementation used.
588  */
589
590 void
591 dns_db_attachversion(dns_db_t *db, dns_dbversion_t *source,
592                      dns_dbversion_t **targetp);
593 /*%<
594  * Attach '*targetp' to 'source'.
595  *
596  * Requires:
597  *
598  * \li  'db' is a valid database with zone semantics.
599  *
600  * \li  source is a valid open version
601  *
602  * \li  targetp != NULL && *targetp == NULL
603  *
604  * Ensures:
605  *
606  * \li  '*targetp' is attached to source.
607  */
608
609 void
610 dns_db_closeversion(dns_db_t *db, dns_dbversion_t **versionp,
611                     isc_boolean_t commit);
612 /*%<
613  * Close version '*versionp'.
614  *
615  * Note: if '*versionp' is a read-write version and 'commit' is ISC_TRUE,
616  * then all changes made in the version will take effect, otherwise they
617  * will be rolled back.  The value if 'commit' is ignored for read-only
618  * versions.
619  *
620  * Requires:
621  *
622  * \li  'db' is a valid database with zone semantics.
623  *
624  * \li  '*versionp' refers to a valid version.
625  *
626  * \li  If committing a writable version, then there must be no other
627  *      outstanding references to the version (e.g. an active rdataset
628  *      iterator).
629  *
630  * Ensures:
631  *
632  * \li  *versionp == NULL
633  *
634  * \li  If *versionp is a read-write version, and commit is ISC_TRUE, then
635  *      the version will become the current version.  If !commit, then all
636  *      changes made in the version will be undone, and the version will
637  *      not become the current version.
638  */
639
640 /***
641  *** Node Methods
642  ***/
643
644 isc_result_t
645 dns_db_findnode(dns_db_t *db, dns_name_t *name, isc_boolean_t create,
646                 dns_dbnode_t **nodep);
647 /*%<
648  * Find the node with name 'name'.
649  *
650  * Notes:
651  * \li  If 'create' is ISC_TRUE and no node with name 'name' exists, then
652  *      such a node will be created.
653  *
654  * \li  This routine is for finding or creating a node with the specified
655  *      name.  There are no partial matches.  It is not suitable for use
656  *      in building responses to ordinary DNS queries; clients which wish
657  *      to do that should use dns_db_find() instead.
658  *
659  * Requires:
660  *
661  * \li  'db' is a valid database.
662  *
663  * \li  'name' is a valid, non-empty, absolute name.
664  *
665  * \li  nodep != NULL && *nodep == NULL
666  *
667  * Ensures:
668  *
669  * \li  On success, *nodep is attached to the node with name 'name'.
670  *
671  * Returns:
672  *
673  * \li  #ISC_R_SUCCESS
674  * \li  #ISC_R_NOTFOUND                 If !create and name not found.
675  * \li  #ISC_R_NOMEMORY                 Can only happen if create is ISC_TRUE.
676  *
677  * \li  Other results are possible, depending upon the database
678  *      implementation used.
679  */
680
681 isc_result_t
682 dns_db_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
683             dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
684             dns_dbnode_t **nodep, dns_name_t *foundname,
685             dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
686 /*%<
687  * Find the best match for 'name' and 'type' in version 'version' of 'db'.
688  *
689  * Notes:
690  *
691  * \li  If type == dns_rdataset_any, then rdataset will not be bound.
692  *
693  * \li  If 'options' does not have #DNS_DBFIND_GLUEOK set, then no glue will
694  *      be returned.  For zone databases, glue is as defined in RFC2181.
695  *      For cache databases, glue is any rdataset with a trust of
696  *      dns_trust_glue.
697  *
698  * \li  If 'options' does not have #DNS_DBFIND_PENDINGOK set, then no
699  *      pending data will be returned.  This option is only meaningful for
700  *      cache databases.
701  *
702  * \li  If the #DNS_DBFIND_NOWILD option is set, then wildcard matching will
703  *      be disabled.  This option is only meaningful for zone databases.
704  *
705  * \li  If the #DNS_DBFIND_FORCENSEC option is set, the database is assumed to
706  *      have NSEC records, and these will be returned when appropriate.  This
707  *      is only necessary when querying a database that was not secure
708  *      when created.
709  *
710  * \li  If the DNS_DBFIND_COVERINGNSEC option is set, then look for a
711  *      NSEC record that potentially covers 'name' if a answer cannot
712  *      be found.  Note the returned NSEC needs to be checked to ensure
713  *      that it is correct.  This only affects answers returned from the
714  *      cache.
715  *
716  * \li  To respond to a query for SIG records, the caller should create a
717  *      rdataset iterator and extract the signatures from each rdataset.
718  *
719  * \li  Making queries of type ANY with #DNS_DBFIND_GLUEOK is not recommended,
720  *      because the burden of determining whether a given rdataset is valid
721  *      glue or not falls upon the caller.
722  *
723  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is a
724  *      cache database, an rdataset will not be found unless it expires after
725  *      'now'.  Any ANY query will not match unless at least one rdataset at
726  *      the node expires after 'now'.  If 'now' is zero, then the current time
727  *      will be used.
728  *
729  * Requires:
730  *
731  * \li  'db' is a valid database.
732  *
733  * \li  'type' is not SIG, or a meta-RR type other than 'ANY' (e.g. 'OPT').
734  *
735  * \li  'nodep' is NULL, or nodep is a valid pointer and *nodep == NULL.
736  *
737  * \li  'foundname' is a valid name with a dedicated buffer.
738  *
739  * \li  'rdataset' is NULL, or is a valid unassociated rdataset.
740  *
741  * Ensures,
742  *      on a non-error completion:
743  *
744  *      \li     If nodep != NULL, then it is bound to the found node.
745  *
746  *      \li     If foundname != NULL, then it contains the full name of the
747  *              found node.
748  *
749  *      \li     If rdataset != NULL and type != dns_rdatatype_any, then
750  *              rdataset is bound to the found rdataset.
751  *
752  *      Non-error results are:
753  *
754  *      \li     #ISC_R_SUCCESS                  The desired node and type were
755  *                                              found.
756  *
757  *      \li     #DNS_R_WILDCARD                 The desired node and type were
758  *                                              found after performing
759  *                                              wildcard matching.  This is
760  *                                              only returned if the
761  *                                              #DNS_DBFIND_INDICATEWILD
762  *                                              option is set; otherwise
763  *                                              #ISC_R_SUCCESS is returned.
764  *
765  *      \li     #DNS_R_GLUE                     The desired node and type were
766  *                                              found, but are glue.  This
767  *                                              result can only occur if
768  *                                              the DNS_DBFIND_GLUEOK option
769  *                                              is set.  This result can only
770  *                                              occur if 'db' is a zone
771  *                                              database.  If type ==
772  *                                              dns_rdatatype_any, then the
773  *                                              node returned may contain, or
774  *                                              consist entirely of invalid
775  *                                              glue (i.e. data occluded by a
776  *                                              zone cut).  The caller must
777  *                                              take care not to return invalid
778  *                                              glue to a client.
779  *
780  *      \li     #DNS_R_DELEGATION               The data requested is beneath
781  *                                              a zone cut.  node, foundname,
782  *                                              and rdataset reference the
783  *                                              NS RRset of the zone cut.
784  *                                              If 'db' is a cache database,
785  *                                              then this is the deepest known
786  *                                              delegation.
787  *
788  *      \li     #DNS_R_ZONECUT                  type == dns_rdatatype_any, and
789  *                                              the desired node is a zonecut.
790  *                                              The caller must take care not
791  *                                              to return inappropriate glue
792  *                                              to a client.  This result can
793  *                                              only occur if 'db' is a zone
794  *                                              database and DNS_DBFIND_GLUEOK
795  *                                              is set.
796  *
797  *      \li     #DNS_R_DNAME                    The data requested is beneath
798  *                                              a DNAME.  node, foundname,
799  *                                              and rdataset reference the
800  *                                              DNAME RRset.
801  *
802  *      \li     #DNS_R_CNAME                    The rdataset requested was not
803  *                                              found, but there is a CNAME
804  *                                              at the desired name.  node,
805  *                                              foundname, and rdataset
806  *                                              reference the CNAME RRset.
807  *
808  *      \li     #DNS_R_NXDOMAIN                 The desired name does not
809  *                                              exist.
810  *
811  *      \li     #DNS_R_NXRRSET                  The desired name exists, but
812  *                                              the desired type does not.
813  *
814  *      \li     #ISC_R_NOTFOUND                 The desired name does not
815  *                                              exist, and no delegation could
816  *                                              be found.  This result can only
817  *                                              occur if 'db' is a cache
818  *                                              database.  The caller should
819  *                                              use its nameserver(s) of last
820  *                                              resort (e.g. root hints).
821  *
822  *      \li     #DNS_R_NCACHENXDOMAIN           The desired name does not
823  *                                              exist.  'node' is bound to the
824  *                                              cache node with the desired
825  *                                              name, and 'rdataset' contains
826  *                                              the negative caching proof.
827  *
828  *      \li     #DNS_R_NCACHENXRRSET            The desired type does not
829  *                                              exist.  'node' is bound to the
830  *                                              cache node with the desired
831  *                                              name, and 'rdataset' contains
832  *                                              the negative caching proof.
833  *
834  *      \li     #DNS_R_EMPTYNAME                The name exists but there is
835  *                                              no data at the name.
836  *
837  *      \li     #DNS_R_COVERINGNSEC             The returned data is a NSEC
838  *                                              that potentially covers 'name'.
839  *
840  *      Error results:
841  *
842  *      \li     #ISC_R_NOMEMORY
843  *
844  *      \li     #DNS_R_BADDB                    Data that is required to be
845  *                                              present in the DB, e.g. an NSEC
846  *                                              record in a secure zone, is not
847  *                                              present.
848  *
849  *      \li     Other results are possible, and should all be treated as
850  *              errors.
851  */
852
853 isc_result_t
854 dns_db_findzonecut(dns_db_t *db, dns_name_t *name,
855                    unsigned int options, isc_stdtime_t now,
856                    dns_dbnode_t **nodep, dns_name_t *foundname,
857                    dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
858 /*%<
859  * Find the deepest known zonecut which encloses 'name' in 'db'.
860  *
861  * Notes:
862  *
863  * \li  If the #DNS_DBFIND_NOEXACT option is set, then the zonecut returned
864  *      (if any) will be the deepest known ancestor of 'name'.
865  *
866  * \li  If 'now' is zero, then the current time will be used.
867  *
868  * Requires:
869  *
870  * \li  'db' is a valid database with cache semantics.
871  *
872  * \li  'nodep' is NULL, or nodep is a valid pointer and *nodep == NULL.
873  *
874  * \li  'foundname' is a valid name with a dedicated buffer.
875  *
876  * \li  'rdataset' is NULL, or is a valid unassociated rdataset.
877  *
878  * Ensures, on a non-error completion:
879  *
880  * \li  If nodep != NULL, then it is bound to the found node.
881  *
882  * \li  If foundname != NULL, then it contains the full name of the
883  *      found node.
884  *
885  * \li  If rdataset != NULL and type != dns_rdatatype_any, then
886  *      rdataset is bound to the found rdataset.
887  *
888  * Non-error results are:
889  *
890  * \li  #ISC_R_SUCCESS
891  *
892  * \li  #ISC_R_NOTFOUND
893  *
894  * \li  Other results are possible, and should all be treated as
895  *      errors.
896  */
897
898 void
899 dns_db_attachnode(dns_db_t *db, dns_dbnode_t *source, dns_dbnode_t **targetp);
900 /*%<
901  * Attach *targetp to source.
902  *
903  * Requires:
904  *
905  * \li  'db' is a valid database.
906  *
907  * \li  'source' is a valid node.
908  *
909  * \li  'targetp' points to a NULL dns_dbnode_t *.
910  *
911  * Ensures:
912  *
913  * \li  *targetp is attached to source.
914  */
915
916 void
917 dns_db_detachnode(dns_db_t *db, dns_dbnode_t **nodep);
918 /*%<
919  * Detach *nodep from its node.
920  *
921  * Requires:
922  *
923  * \li  'db' is a valid database.
924  *
925  * \li  'nodep' points to a valid node.
926  *
927  * Ensures:
928  *
929  * \li  *nodep is NULL.
930  */
931
932 void
933 dns_db_transfernode(dns_db_t *db, dns_dbnode_t **sourcep,
934                     dns_dbnode_t **targetp);
935 /*%<
936  * Transfer a node between pointer.
937  *
938  * This is equivalent to calling dns_db_attachnode() then dns_db_detachnode().
939  *
940  * Requires:
941  *
942  * \li  'db' is a valid database.
943  *
944  * \li  '*sourcep' is a valid node.
945  *
946  * \li  'targetp' points to a NULL dns_dbnode_t *.
947  *
948  * Ensures:
949  *
950  * \li  '*sourcep' is NULL.
951  */
952
953 isc_result_t
954 dns_db_expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now);
955 /*%<
956  * Mark as stale all records at 'node' which expire at or before 'now'.
957  *
958  * Note: if 'now' is zero, then the current time will be used.
959  *
960  * Requires:
961  *
962  * \li  'db' is a valid cache database.
963  *
964  * \li  'node' is a valid node.
965  */
966
967 void
968 dns_db_printnode(dns_db_t *db, dns_dbnode_t *node, FILE *out);
969 /*%<
970  * Print a textual representation of the contents of the node to
971  * 'out'.
972  *
973  * Note: this function is intended for debugging, not general use.
974  *
975  * Requires:
976  *
977  * \li  'db' is a valid database.
978  *
979  * \li  'node' is a valid node.
980  */
981
982 /***
983  *** DB Iterator Creation
984  ***/
985
986 isc_result_t
987 dns_db_createiterator(dns_db_t *db, unsigned int options,
988                       dns_dbiterator_t **iteratorp);
989 /*%<
990  * Create an iterator for version 'version' of 'db'.
991  *
992  * Notes:
993  *
994  * \li  One or more of the following options can be set.
995  *      #DNS_DB_RELATIVENAMES
996  *      #DNS_DB_NSEC3ONLY
997  *      #DNS_DB_NONSEC3
998  *
999  * Requires:
1000  *
1001  * \li  'db' is a valid database.
1002  *
1003  * \li  iteratorp != NULL && *iteratorp == NULL
1004  *
1005  * Ensures:
1006  *
1007  * \li  On success, *iteratorp will be a valid database iterator.
1008  *
1009  * Returns:
1010  *
1011  * \li  #ISC_R_SUCCESS
1012  * \li  #ISC_R_NOMEMORY
1013  */
1014
1015 /***
1016  *** Rdataset Methods
1017  ***/
1018
1019 /*
1020  * XXXRTH  Should we check for glue and pending data in dns_db_findrdataset()?
1021  */
1022
1023 isc_result_t
1024 dns_db_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
1025                     dns_rdatatype_t type, dns_rdatatype_t covers,
1026                     isc_stdtime_t now, dns_rdataset_t *rdataset,
1027                     dns_rdataset_t *sigrdataset);
1028 /*%<
1029  * Search for an rdataset of type 'type' at 'node' that are in version
1030  * 'version' of 'db'.  If found, make 'rdataset' refer to it.
1031  *
1032  * Notes:
1033  *
1034  * \li  If 'version' is NULL, then the current version will be used.
1035  *
1036  * \li  Care must be used when using this routine to build a DNS response:
1037  *      'node' should have been found with dns_db_find(), not
1038  *      dns_db_findnode().  No glue checking is done.  No checking for
1039  *      pending data is done.
1040  *
1041  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is a
1042  *      cache database, an rdataset will not be found unless it expires after
1043  *      'now'.  If 'now' is zero, then the current time will be used.
1044  *
1045  * Requires:
1046  *
1047  * \li  'db' is a valid database.
1048  *
1049  * \li  'node' is a valid node.
1050  *
1051  * \li  'rdataset' is a valid, disassociated rdataset.
1052  *
1053  * \li  'sigrdataset' is a valid, disassociated rdataset, or it is NULL.
1054  *
1055  * \li  If 'covers' != 0, 'type' must be SIG.
1056  *
1057  * \li  'type' is not a meta-RR type such as 'ANY' or 'OPT'.
1058  *
1059  * Ensures:
1060  *
1061  * \li  On success, 'rdataset' is associated with the found rdataset.
1062  *
1063  * Returns:
1064  *
1065  * \li  #ISC_R_SUCCESS
1066  * \li  #ISC_R_NOTFOUND
1067  *
1068  * \li  Other results are possible, depending upon the database
1069  *      implementation used.
1070  */
1071
1072 isc_result_t
1073 dns_db_allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
1074                     isc_stdtime_t now, dns_rdatasetiter_t **iteratorp);
1075 /*%<
1076  * Make '*iteratorp' an rdataset iterator for all rdatasets at 'node' in
1077  * version 'version' of 'db'.
1078  *
1079  * Notes:
1080  *
1081  * \li  If 'version' is NULL, then the current version will be used.
1082  *
1083  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is a
1084  *      cache database, an rdataset will not be found unless it expires after
1085  *      'now'.  Any ANY query will not match unless at least one rdataset at
1086  *      the node expires after 'now'.  If 'now' is zero, then the current time
1087  *      will be used.
1088  *
1089  * Requires:
1090  *
1091  * \li  'db' is a valid database.
1092  *
1093  * \li  'node' is a valid node.
1094  *
1095  * \li  iteratorp != NULL && *iteratorp == NULL
1096  *
1097  * Ensures:
1098  *
1099  * \li  On success, '*iteratorp' is a valid rdataset iterator.
1100  *
1101  * Returns:
1102  *
1103  * \li  #ISC_R_SUCCESS
1104  * \li  #ISC_R_NOTFOUND
1105  *
1106  * \li  Other results are possible, depending upon the database
1107  *      implementation used.
1108  */
1109
1110 isc_result_t
1111 dns_db_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
1112                    isc_stdtime_t now, dns_rdataset_t *rdataset,
1113                    unsigned int options, dns_rdataset_t *addedrdataset);
1114 /*%<
1115  * Add 'rdataset' to 'node' in version 'version' of 'db'.
1116  *
1117  * Notes:
1118  *
1119  * \li  If the database has zone semantics, the #DNS_DBADD_MERGE option is set,
1120  *      and an rdataset of the same type as 'rdataset' already exists at
1121  *      'node' then the contents of 'rdataset' will be merged with the existing
1122  *      rdataset.  If the option is not set, then rdataset will replace any
1123  *      existing rdataset of the same type.  If not merging and the
1124  *      #DNS_DBADD_FORCE option is set, then the data will update the database
1125  *      without regard to trust levels.  If not forcing the data, then the
1126  *      rdataset will only be added if its trust level is >= the trust level of
1127  *      any existing rdataset.  Forcing is only meaningful for cache databases.
1128  *      If #DNS_DBADD_EXACT is set then there must be no rdata in common between
1129  *      the old and new rdata sets.  If #DNS_DBADD_EXACTTTL is set then both
1130  *      the old and new rdata sets must have the same ttl.
1131  *
1132  * \li  The 'now' field is ignored if 'db' is a zone database.  If 'db' is
1133  *      a cache database, then the added rdataset will expire no later than
1134  *      now + rdataset->ttl.
1135  *
1136  * \li  If 'addedrdataset' is not NULL, then it will be attached to the
1137  *      resulting new rdataset in the database, or to the existing data if
1138  *      the existing data was better.
1139  *
1140  * Requires:
1141  *
1142  * \li  'db' is a valid database.
1143  *
1144  * \li  'node' is a valid node.
1145  *
1146  * \li  'rdataset' is a valid, associated rdataset with the same class
1147  *      as 'db'.
1148  *
1149  * \li  'addedrdataset' is NULL, or a valid, unassociated rdataset.
1150  *
1151  * \li  The database has zone semantics and 'version' is a valid
1152  *      read-write version, or the database has cache semantics
1153  *      and version is NULL.
1154  *
1155  * \li  If the database has cache semantics, the #DNS_DBADD_MERGE option must
1156  *      not be set.
1157  *
1158  * Returns:
1159  *
1160  * \li  #ISC_R_SUCCESS
1161  * \li  #DNS_R_UNCHANGED                        The operation did not change anything.
1162  * \li  #ISC_R_NOMEMORY
1163  * \li  #DNS_R_NOTEXACT
1164  *
1165  * \li  Other results are possible, depending upon the database
1166  *      implementation used.
1167  */
1168
1169 isc_result_t
1170 dns_db_subtractrdataset(dns_db_t *db, dns_dbnode_t *node,
1171                         dns_dbversion_t *version, dns_rdataset_t *rdataset,
1172                         unsigned int options, dns_rdataset_t *newrdataset);
1173 /*%<
1174  * Remove any rdata in 'rdataset' from 'node' in version 'version' of
1175  * 'db'.
1176  *
1177  * Notes:
1178  *
1179  * \li  If 'newrdataset' is not NULL, then it will be attached to the
1180  *      resulting new rdataset in the database, unless the rdataset has
1181  *      become nonexistent.  If DNS_DBSUB_EXACT is set then all elements
1182  *      of 'rdataset' must exist at 'node'.
1183  *
1184  * Requires:
1185  *
1186  * \li  'db' is a valid database.
1187  *
1188  * \li  'node' is a valid node.
1189  *
1190  * \li  'rdataset' is a valid, associated rdataset with the same class
1191  *      as 'db'.
1192  *
1193  * \li  'newrdataset' is NULL, or a valid, unassociated rdataset.
1194  *
1195  * \li  The database has zone semantics and 'version' is a valid
1196  *      read-write version.
1197  *
1198  * Returns:
1199  *
1200  * \li  #ISC_R_SUCCESS
1201  * \li  #DNS_R_UNCHANGED                        The operation did not change anything.
1202  * \li  #DNS_R_NXRRSET                  All rdata of the same type as those
1203  *                                      in 'rdataset' have been deleted.
1204  * \li  #DNS_R_NOTEXACT                 Some part of 'rdataset' did not
1205  *                                      exist and DNS_DBSUB_EXACT was set.
1206  *
1207  * \li  Other results are possible, depending upon the database
1208  *      implementation used.
1209  */
1210
1211 isc_result_t
1212 dns_db_deleterdataset(dns_db_t *db, dns_dbnode_t *node,
1213                       dns_dbversion_t *version, dns_rdatatype_t type,
1214                       dns_rdatatype_t covers);
1215 /*%<
1216  * Make it so that no rdataset of type 'type' exists at 'node' in version
1217  * version 'version' of 'db'.
1218  *
1219  * Notes:
1220  *
1221  * \li  If 'type' is dns_rdatatype_any, then no rdatasets will exist in
1222  *      'version' (provided that the dns_db_deleterdataset() isn't followed
1223  *      by one or more dns_db_addrdataset() calls).
1224  *
1225  * Requires:
1226  *
1227  * \li  'db' is a valid database.
1228  *
1229  * \li  'node' is a valid node.
1230  *
1231  * \li  The database has zone semantics and 'version' is a valid
1232  *      read-write version, or the database has cache semantics
1233  *      and version is NULL.
1234  *
1235  * \li  'type' is not a meta-RR type, except for dns_rdatatype_any, which is
1236  *      allowed.
1237  *
1238  * \li  If 'covers' != 0, 'type' must be SIG.
1239  *
1240  * Returns:
1241  *
1242  * \li  #ISC_R_SUCCESS
1243  * \li  #DNS_R_UNCHANGED                        No rdatasets of 'type' existed before
1244  *                                      the operation was attempted.
1245  *
1246  * \li  Other results are possible, depending upon the database
1247  *      implementation used.
1248  */
1249
1250 isc_result_t
1251 dns_db_getsoaserial(dns_db_t *db, dns_dbversion_t *ver, isc_uint32_t *serialp);
1252 /*%<
1253  * Get the current SOA serial number from a zone database.
1254  *
1255  * Requires:
1256  * \li  'db' is a valid database with zone semantics.
1257  * \li  'ver' is a valid version.
1258  */
1259
1260 void
1261 dns_db_overmem(dns_db_t *db, isc_boolean_t overmem);
1262 /*%<
1263  * Enable / disable aggressive cache cleaning.
1264  */
1265
1266 unsigned int
1267 dns_db_nodecount(dns_db_t *db);
1268 /*%<
1269  * Count the number of nodes in 'db'.
1270  *
1271  * Requires:
1272  *
1273  * \li  'db' is a valid database.
1274  *
1275  * Returns:
1276  * \li  The number of nodes in the database
1277  */
1278
1279 void
1280 dns_db_settask(dns_db_t *db, isc_task_t *task);
1281 /*%<
1282  * If task is set then the final detach maybe performed asynchronously.
1283  *
1284  * Requires:
1285  * \li  'db' is a valid database.
1286  * \li  'task' to be valid or NULL.
1287  */
1288
1289 isc_boolean_t
1290 dns_db_ispersistent(dns_db_t *db);
1291 /*%<
1292  * Is 'db' persistent?  A persistent database does not need to be loaded
1293  * from disk or written to disk.
1294  *
1295  * Requires:
1296  *
1297  * \li  'db' is a valid database.
1298  *
1299  * Returns:
1300  * \li  #ISC_TRUE       'db' is persistent.
1301  * \li  #ISC_FALSE      'db' is not persistent.
1302  */
1303
1304 isc_result_t
1305 dns_db_register(const char *name, dns_dbcreatefunc_t create, void *driverarg,
1306                 isc_mem_t *mctx, dns_dbimplementation_t **dbimp);
1307
1308 /*%<
1309  * Register a new database implementation and add it to the list of
1310  * supported implementations.
1311  *
1312  * Requires:
1313  *
1314  * \li  'name' is not NULL
1315  * \li  'order' is a valid function pointer
1316  * \li  'mctx' is a valid memory context
1317  * \li  dbimp != NULL && *dbimp == NULL
1318  *
1319  * Returns:
1320  * \li  #ISC_R_SUCCESS  The registration succeeded
1321  * \li  #ISC_R_NOMEMORY Out of memory
1322  * \li  #ISC_R_EXISTS   A database implementation with the same name exists
1323  *
1324  * Ensures:
1325  *
1326  * \li  *dbimp points to an opaque structure which must be passed to
1327  *      dns_db_unregister().
1328  */
1329
1330 void
1331 dns_db_unregister(dns_dbimplementation_t **dbimp);
1332 /*%<
1333  * Remove a database implementation from the list of supported
1334  * implementations.  No databases of this type can be active when this
1335  * is called.
1336  *
1337  * Requires:
1338  * \li  dbimp != NULL && *dbimp == NULL
1339  *
1340  * Ensures:
1341  *
1342  * \li  Any memory allocated in *dbimp will be freed.
1343  */
1344
1345 isc_result_t
1346 dns_db_getoriginnode(dns_db_t *db, dns_dbnode_t **nodep);
1347 /*%<
1348  * Get the origin DB node corresponding to the DB's zone.  This function
1349  * should typically succeed unless the underlying DB implementation doesn't
1350  * support the feature.
1351  *
1352  * Requires:
1353  *
1354  * \li  'db' is a valid zone database.
1355  * \li  'nodep' != NULL && '*nodep' == NULL
1356  *
1357  * Ensures:
1358  * \li  On success, '*nodep' will point to the DB node of the zone's origin.
1359  *
1360  * Returns:
1361  * \li  #ISC_R_SUCCESS
1362  * \li  #ISC_R_NOTFOUND - the DB implementation does not support this feature.
1363  */
1364
1365 isc_result_t
1366 dns_db_getnsec3parameters(dns_db_t *db, dns_dbversion_t *version,
1367                           dns_hash_t *hash, isc_uint8_t *flags,
1368                           isc_uint16_t *interations,
1369                           unsigned char *salt, size_t *salt_length);
1370 /*%<
1371  * Get the NSEC3 parameters that are associated with this zone.
1372  *
1373  * Requires:
1374  * \li  'db' is a valid zone database.
1375  *
1376  * Returns:
1377  * \li  #ISC_R_SUCCESS
1378  * \li  #ISC_R_NOTFOUND - the DB implementation does not support this feature
1379  *                        or this zone does not have NSEC3 records.
1380  */
1381
1382 isc_result_t
1383 dns_db_findnsec3node(dns_db_t *db, dns_name_t *name,
1384                      isc_boolean_t create, dns_dbnode_t **nodep);
1385 /*%<
1386  * Find the NSEC3 node with name 'name'.
1387  *
1388  * Notes:
1389  * \li  If 'create' is ISC_TRUE and no node with name 'name' exists, then
1390  *      such a node will be created.
1391  *
1392  * Requires:
1393  *
1394  * \li  'db' is a valid database.
1395  *
1396  * \li  'name' is a valid, non-empty, absolute name.
1397  *
1398  * \li  nodep != NULL && *nodep == NULL
1399  *
1400  * Ensures:
1401  *
1402  * \li  On success, *nodep is attached to the node with name 'name'.
1403  *
1404  * Returns:
1405  *
1406  * \li  #ISC_R_SUCCESS
1407  * \li  #ISC_R_NOTFOUND                 If !create and name not found.
1408  * \li  #ISC_R_NOMEMORY                 Can only happen if create is ISC_TRUE.
1409  *
1410  * \li  Other results are possible, depending upon the database
1411  *      implementation used.
1412  */
1413
1414 isc_result_t
1415 dns_db_setsigningtime(dns_db_t *db, dns_rdataset_t *rdataset,
1416                       isc_stdtime_t resign);
1417 /*%<
1418  * Sets the re-signing time associated with 'rdataset' to 'resign'.
1419  *
1420  * Requires:
1421  * \li  'db' is a valid zone database.
1422  * \li  'rdataset' to be associated with 'db'.
1423  *
1424  * Returns:
1425  * \li  #ISC_R_SUCCESS
1426  * \li  #ISC_R_NOMEMORY
1427  * \li  #ISC_R_NOTIMPLEMENTED - Not supported by this DB implementation.
1428  */
1429
1430 isc_result_t
1431 dns_db_getsigningtime(dns_db_t *db, dns_rdataset_t *rdataset, dns_name_t *name);
1432 /*%<
1433  * Return the rdataset with the earliest signing time in the zone.
1434  * Note: the rdataset is version agnostic.
1435  *
1436  * Requires:
1437  * \li  'db' is a valid zone database.
1438  * \li  'rdataset' to be initialized but not associated.
1439  * \li  'name' to be NULL or have a buffer associated with it.
1440  *
1441  * Returns:
1442  * \li  #ISC_R_SUCCESS
1443  * \li  #ISC_R_NOTFOUND - No dataset exists.
1444  */
1445
1446 void
1447 dns_db_resigned(dns_db_t *db, dns_rdataset_t *rdataset,
1448                 dns_dbversion_t *version);
1449 /*%<
1450  * Mark 'rdataset' as not being available to be returned by
1451  * dns_db_getsigningtime().  If the changes associated with 'version'
1452  * are committed this will be permanent.  If the version is not committed
1453  * this change will be rolled back when the version is closed.
1454  *
1455  * Requires:
1456  * \li  'db' is a valid zone database.
1457  * \li  'rdataset' to be associated with 'db'.
1458  * \li  'version' to be open for writing.
1459  */
1460
1461 dns_stats_t *
1462 dns_db_getrrsetstats(dns_db_t *db);
1463 /*%<
1464  * Get statistics information counting RRsets stored in the DB, when available.
1465  * The statistics may not be available depending on the DB implementation.
1466  *
1467  * Requires:
1468  *
1469  * \li  'db' is a valid database (zone or cache).
1470  *
1471  * Returns:
1472  * \li  when available, a pointer to a statistics object created by
1473  *      dns_rdatasetstats_create(); otherwise NULL.
1474  */
1475
1476 ISC_LANG_ENDDECLS
1477
1478 #endif /* DNS_DB_H */