Import bind-9.3.4
[dragonfly.git] / contrib / bind-9.3 / lib / dns / include / dns / zone.h
blob4baf36ab360af5153bd2de73294d36023c70236c
1 /*
2 * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and 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.
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.
18 /* $Id: zone.h,v 1.106.2.7.4.18 2006/08/01 03:44:00 marka Exp $ */
20 #ifndef DNS_ZONE_H
21 #define DNS_ZONE_H 1
23 /***
24 *** Imports
25 ***/
27 #include <stdio.h>
29 #include <isc/formatcheck.h>
30 #include <isc/lang.h>
31 #include <isc/rwlock.h>
33 #include <dns/types.h>
35 typedef enum {
36 dns_zone_none,
37 dns_zone_master,
38 dns_zone_slave,
39 dns_zone_stub
40 } dns_zonetype_t;
42 #define DNS_ZONEOPT_SERVERS 0x00000001U /* perform server checks */
43 #define DNS_ZONEOPT_PARENTS 0x00000002U /* perform parent checks */
44 #define DNS_ZONEOPT_CHILDREN 0x00000004U /* perform child checks */
45 #define DNS_ZONEOPT_NOTIFY 0x00000008U /* perform NOTIFY */
46 #define DNS_ZONEOPT_MANYERRORS 0x00000010U /* return many errors on load */
47 #define DNS_ZONEOPT_IXFRFROMDIFFS 0x00000020U /* calculate differences */
48 #define DNS_ZONEOPT_NOMERGE 0x00000040U /* don't merge journal */
49 #define DNS_ZONEOPT_CHECKNS 0x00000080U /* check if NS's are addresses */
50 #define DNS_ZONEOPT_FATALNS 0x00000100U /* DNS_ZONEOPT_CHECKNS is fatal */
51 #define DNS_ZONEOPT_MULTIMASTER 0x00000200U /* this zone has multiple masters */
52 #define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /* use alternate transfer sources */
53 #define DNS_ZONEOPT_CHECKNAMES 0x00000800U /* check-names */
54 #define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /* fatal check-name failures */
56 #ifndef NOMINUM_PUBLIC
58 * Nominum specific options build down.
60 #define DNS_ZONEOPT_NOTIFYFORWARD 0x80000000U /* forward notify to master */
61 #endif /* NOMINUM_PUBLIC */
63 #ifndef DNS_ZONE_MINREFRESH
64 #define DNS_ZONE_MINREFRESH 300 /* 5 minutes */
65 #endif
66 #ifndef DNS_ZONE_MAXREFRESH
67 #define DNS_ZONE_MAXREFRESH 2419200 /* 4 weeks */
68 #endif
69 #ifndef DNS_ZONE_DEFAULTREFRESH
70 #define DNS_ZONE_DEFAULTREFRESH 3600 /* 1 hour */
71 #endif
72 #ifndef DNS_ZONE_MINRETRY
73 #define DNS_ZONE_MINRETRY 300 /* 5 minutes */
74 #endif
75 #ifndef DNS_ZONE_MAXRETRY
76 #define DNS_ZONE_MAXRETRY 1209600 /* 2 weeks */
77 #endif
78 #ifndef DNS_ZONE_DEFAULTRETRY
79 #define DNS_ZONE_DEFAULTRETRY 60 /* 1 minute, subject to
80 exponential backoff */
81 #endif
83 #define DNS_ZONESTATE_XFERRUNNING 1
84 #define DNS_ZONESTATE_XFERDEFERRED 2
85 #define DNS_ZONESTATE_SOAQUERY 3
86 #define DNS_ZONESTATE_ANY 4
88 ISC_LANG_BEGINDECLS
90 /***
91 *** Functions
92 ***/
94 isc_result_t
95 dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx);
97 * Creates a new empty zone and attach '*zonep' to it.
99 * Requires:
100 * 'zonep' to point to a NULL pointer.
101 * 'mctx' to be a valid memory context.
103 * Ensures:
104 * '*zonep' refers to a valid zone.
106 * Returns:
107 * ISC_R_SUCCESS
108 * ISC_R_NOMEMORY
109 * ISC_R_UNEXPECTED
112 void
113 dns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass);
115 * Sets the class of a zone. This operation can only be performed
116 * once on a zone.
118 * Require:
119 * 'zone' to be a valid zone.
120 * dns_zone_setclass() not to have been called since the zone was
121 * created.
122 * 'rdclass' != dns_rdataclass_none.
125 dns_rdataclass_t
126 dns_zone_getclass(dns_zone_t *zone);
128 * Returns the current zone class.
130 * Requires:
131 * 'zone' to be a valid zone.
134 void
135 dns_zone_settype(dns_zone_t *zone, dns_zonetype_t type);
137 * Sets the zone type. This operation can only be performed once on
138 * a zone.
140 * Requires:
141 * 'zone' to be a valid zone.
142 * dns_zone_settype() not to have been called since the zone was
143 * created.
144 * 'type' != dns_zone_none
147 void
148 dns_zone_setview(dns_zone_t *zone, dns_view_t *view);
150 * Associate the zone with a view.
152 * Require:
153 * 'zone' to be a valid zone.
156 dns_view_t *
157 dns_zone_getview(dns_zone_t *zone);
159 * Returns the zone's associated view.
161 * Requires:
162 * 'zone' to be a valid zone.
165 isc_result_t
166 dns_zone_setorigin(dns_zone_t *zone, const dns_name_t *origin);
168 * Sets the zones origin to 'origin'.
170 * Require:
171 * 'zone' to be a valid zone.
172 * 'origin' to be non NULL.
174 * Returns:
175 * ISC_R_SUCCESS
176 * ISC_R_NOMEMORY
179 dns_name_t *
180 dns_zone_getorigin(dns_zone_t *zone);
182 * Returns the value of the origin.
184 * Require:
185 * 'zone' to be a valid zone.
188 isc_result_t
189 dns_zone_setfile(dns_zone_t *zone, const char *file);
191 * Sets the name of the master file from which the zone
192 * loads its database to 'file'. For zones that have
193 * no associated master file, 'file' will be NULL.
195 * For zones with persistent databases, the file name
196 * setting is ignored.
198 * Require:
199 * 'zone' to be a valid zone.
201 * Returns:
202 * ISC_R_NOMEMORY
203 * ISC_R_SUCCESS
206 const char *
207 dns_zone_getfile(dns_zone_t *zone);
209 * Gets the name of the zone's master file, if any.
211 * Requires:
212 * 'zone' to be valid initialised zone.
214 * Returns:
215 * Pointer to null-terminated file name, or NULL.
218 isc_result_t
219 dns_zone_load(dns_zone_t *zone);
221 isc_result_t
222 dns_zone_loadnew(dns_zone_t *zone);
224 * Cause the database to be loaded from its backing store.
225 * Confirm that the minimum requirements for the zone type are
226 * met, otherwise DNS_R_BADZONE is returned.
228 * dns_zone_loadnew() only loads zones that are not yet loaded.
229 * dns_zone_load() also loads zones that are already loaded and
230 * and whose master file has changed since the last load.
232 * Require:
233 * 'zone' to be a valid zone.
235 * Returns:
236 * ISC_R_UNEXPECTED
237 * ISC_R_SUCCESS
238 * DNS_R_CONTINUE Incremental load has been queued.
239 * DNS_R_UPTODATE The zone has already been loaded based on
240 * file system timestamps.
241 * DNS_R_BADZONE
242 * Any result value from dns_db_load().
245 void
246 dns_zone_attach(dns_zone_t *source, dns_zone_t **target);
248 * Attach '*target' to 'source' incrementing its external
249 * reference count.
251 * Require:
252 * 'zone' to be a valid zone.
253 * 'target' to be non NULL and '*target' to be NULL.
256 void
257 dns_zone_detach(dns_zone_t **zonep);
259 * Detach from a zone decrementing its external reference count.
260 * If this was the last external reference to the zone it will be
261 * shut down and eventually freed.
263 * Require:
264 * 'zonep' to point to a valid zone.
267 void
268 dns_zone_iattach(dns_zone_t *source, dns_zone_t **target);
270 * Attach '*target' to 'source' incrementing its internal
271 * reference count. This is intended for use by operations
272 * such as zone transfers that need to prevent the zone
273 * object from being freed but not from shutting down.
275 * Require:
276 * The caller is running in the context of the zone's task.
277 * 'zone' to be a valid zone.
278 * 'target' to be non NULL and '*target' to be NULL.
281 void
282 dns_zone_idetach(dns_zone_t **zonep);
284 * Detach from a zone decrementing its internal reference count.
285 * If there are no more internal or external references to the
286 * zone, it will be freed.
288 * Require:
289 * The caller is running in the context of the zone's task.
290 * 'zonep' to point to a valid zone.
293 void
294 dns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value);
296 * Sets ('value' == 'ISC_TRUE') / clears ('value' == 'IS_FALSE')
297 * zone flags. Valid flag bits are DNS_ZONE_F_*.
299 * Requires
300 * 'zone' to be a valid zone.
303 isc_result_t
304 dns_zone_getdb(dns_zone_t *zone, dns_db_t **dbp);
306 * Attach '*dbp' to the database to if it exists otherwise
307 * return DNS_R_NOTLOADED.
309 * Require:
310 * 'zone' to be a valid zone.
311 * 'dbp' to be != NULL && '*dbp' == NULL.
313 * Returns:
314 * ISC_R_SUCCESS
315 * DNS_R_NOTLOADED
318 isc_result_t
319 dns_zone_setdbtype(dns_zone_t *zone,
320 unsigned int dbargc, const char * const *dbargv);
322 * Sets the database type to dbargv[0] and database arguments
323 * to subsequent dbargv elements.
324 * 'db_type' is not checked to see if it is a valid database type.
326 * Require:
327 * 'zone' to be a valid zone.
328 * 'database' to be non NULL.
329 * 'dbargc' to be >= 1
330 * 'dbargv' to point to dbargc NULL-terminated strings
332 * Returns:
333 * ISC_R_NOMEMORY
334 * ISC_R_SUCCESS
337 void
338 dns_zone_markdirty(dns_zone_t *zone);
340 * Mark a zone as 'dirty'.
342 * Require:
343 * 'zone' to be a valid zone.
346 void
347 dns_zone_expire(dns_zone_t *zone);
349 * Mark the zone as expired. If the zone requires dumping cause it to
350 * be initiated. Set the refresh and retry intervals to there default
351 * values and unload the zone.
353 * Require
354 * 'zone' to be a valid zone.
357 void
358 dns_zone_refresh(dns_zone_t *zone);
360 * Initiate zone up to date checks. The zone must already be being
361 * managed.
363 * Require
364 * 'zone' to be a valid zone.
367 isc_result_t
368 dns_zone_flush(dns_zone_t *zone);
370 * Write the zone to database if there are uncommited changes.
372 * Require:
373 * 'zone' to be a valid zone.
376 isc_result_t
377 dns_zone_dump(dns_zone_t *zone);
379 * Write the zone to database.
381 * Require:
382 * 'zone' to be a valid zone.
385 isc_result_t
386 dns_zone_dumptostream(dns_zone_t *zone, FILE *fd);
388 * Write the zone to stream 'fd'.
390 * Require:
391 * 'zone' to be a valid zone.
392 * 'fd' to be a stream open for writing.
395 isc_result_t
396 dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd);
398 * The same as dns_zone_dumptostream, but dumps the zone with
399 * different dump settings (dns_master_style_full).
401 * Require:
402 * 'zone' to be a valid zone.
403 * 'fd' to be a stream open for writing.
406 void
407 dns_zone_maintenance(dns_zone_t *zone);
409 * Perform regular maintenace on the zone. This is called as a
410 * result of a zone being managed.
412 * Require
413 * 'zone' to be a valid zone.
416 isc_result_t
417 dns_zone_setmasters(dns_zone_t *zone, const isc_sockaddr_t *masters,
418 isc_uint32_t count);
419 isc_result_t
420 dns_zone_setmasterswithkeys(dns_zone_t *zone,
421 const isc_sockaddr_t *masters,
422 dns_name_t **keynames,
423 isc_uint32_t count);
425 * Set the list of master servers for the zone.
427 * Require:
428 * 'zone' to be a valid zone.
429 * 'masters' array of isc_sockaddr_t with port set or NULL.
430 * 'count' the number of masters.
431 * 'keynames' array of dns_name_t's for tsig keys or NULL.
433 * dns_zone_setmasters() is just a wrapper to setmasterswithkeys(),
434 * passing NULL in the keynames field.
436 * If 'masters' is NULL then 'count' must be zero.
438 * Returns:
439 * ISC_R_SUCCESS
440 * ISC_R_NOMEMORY
441 * Any result dns_name_dup() can return, if keynames!=NULL
444 isc_result_t
445 dns_zone_setalsonotify(dns_zone_t *zone, const isc_sockaddr_t *notify,
446 isc_uint32_t count);
448 * Set the list of additional servers to be notified when
449 * a zone changes. To clear the list use 'count = 0'.
451 * Require:
452 * 'zone' to be a valid zone.
453 * 'notify' to be non-NULL if count != 0.
454 * 'count' to be the number of notifyees.
456 * Returns:
457 * ISC_R_SUCCESS
458 * ISC_R_NOMEMORY
461 void
462 dns_zone_unload(dns_zone_t *zone);
464 * detach the database from the zone structure.
466 * Require:
467 * 'zone' to be a valid zone.
470 void
471 dns_zone_setoption(dns_zone_t *zone, unsigned int option, isc_boolean_t value);
473 * Set given options on ('value' == ISC_TRUE) or off ('value' ==
474 * ISC_FALSE).
476 * Require:
477 * 'zone' to be a valid zone.
480 unsigned int
481 dns_zone_getoptions(dns_zone_t *zone);
483 * Returns the current zone options.
485 * Require:
486 * 'zone' to be a valid zone.
489 void
490 dns_zone_setminrefreshtime(dns_zone_t *zone, isc_uint32_t val);
492 * Set the minimum refresh time.
494 * Requires:
495 * 'zone' is valid.
496 * val > 0.
499 void
500 dns_zone_setmaxrefreshtime(dns_zone_t *zone, isc_uint32_t val);
502 * Set the maximum refresh time.
504 * Requires:
505 * 'zone' is valid.
506 * val > 0.
509 void
510 dns_zone_setminretrytime(dns_zone_t *zone, isc_uint32_t val);
512 * Set the minimum retry time.
514 * Requires:
515 * 'zone' is valid.
516 * val > 0.
519 void
520 dns_zone_setmaxretrytime(dns_zone_t *zone, isc_uint32_t val);
522 * Set the maximum retry time.
524 * Requires:
525 * 'zone' is valid.
526 * val > 0.
529 isc_result_t
530 dns_zone_setxfrsource4(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
531 isc_result_t
532 dns_zone_setaltxfrsource4(dns_zone_t *zone,
533 const isc_sockaddr_t *xfrsource);
535 * Set the source address to be used in IPv4 zone transfers.
537 * Require:
538 * 'zone' to be a valid zone.
539 * 'xfrsource' to contain the address.
541 * Returns:
542 * ISC_R_SUCCESS
545 isc_sockaddr_t *
546 dns_zone_getxfrsource4(dns_zone_t *zone);
547 isc_sockaddr_t *
548 dns_zone_getaltxfrsource4(dns_zone_t *zone);
550 * Returns the source address set by a previous dns_zone_setxfrsource4
551 * call, or the default of inaddr_any, port 0.
553 * Require:
554 * 'zone' to be a valid zone.
557 isc_result_t
558 dns_zone_setxfrsource6(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
559 isc_result_t
560 dns_zone_setaltxfrsource6(dns_zone_t *zone,
561 const isc_sockaddr_t *xfrsource);
563 * Set the source address to be used in IPv6 zone transfers.
565 * Require:
566 * 'zone' to be a valid zone.
567 * 'xfrsource' to contain the address.
569 * Returns:
570 * ISC_R_SUCCESS
573 isc_sockaddr_t *
574 dns_zone_getxfrsource6(dns_zone_t *zone);
575 isc_sockaddr_t *
576 dns_zone_getaltxfrsource6(dns_zone_t *zone);
578 * Returns the source address set by a previous dns_zone_setxfrsource6
579 * call, or the default of in6addr_any, port 0.
581 * Require:
582 * 'zone' to be a valid zone.
585 isc_result_t
586 dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
588 * Set the source address to be used with IPv4 NOTIFY messages.
590 * Require:
591 * 'zone' to be a valid zone.
592 * 'notifysrc' to contain the address.
594 * Returns:
595 * ISC_R_SUCCESS
598 isc_sockaddr_t *
599 dns_zone_getnotifysrc4(dns_zone_t *zone);
601 * Returns the source address set by a previous dns_zone_setnotifysrc4
602 * call, or the default of inaddr_any, port 0.
604 * Require:
605 * 'zone' to be a valid zone.
608 isc_result_t
609 dns_zone_setnotifysrc6(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
611 * Set the source address to be used with IPv6 NOTIFY messages.
613 * Require:
614 * 'zone' to be a valid zone.
615 * 'notifysrc' to contain the address.
617 * Returns:
618 * ISC_R_SUCCESS
621 isc_sockaddr_t *
622 dns_zone_getnotifysrc6(dns_zone_t *zone);
624 * Returns the source address set by a previous dns_zone_setnotifysrc6
625 * call, or the default of in6addr_any, port 0.
627 * Require:
628 * 'zone' to be a valid zone.
631 void
632 dns_zone_setnotifyacl(dns_zone_t *zone, dns_acl_t *acl);
634 * Sets the notify acl list for the zone.
636 * Require:
637 * 'zone' to be a valid zone.
638 * 'acl' to be a valid acl.
641 void
642 dns_zone_setqueryacl(dns_zone_t *zone, dns_acl_t *acl);
644 * Sets the query acl list for the zone.
646 * Require:
647 * 'zone' to be a valid zone.
648 * 'acl' to be a valid acl.
651 void
652 dns_zone_setupdateacl(dns_zone_t *zone, dns_acl_t *acl);
654 * Sets the update acl list for the zone.
656 * Require:
657 * 'zone' to be a valid zone.
658 * 'acl' to be valid acl.
661 void
662 dns_zone_setforwardacl(dns_zone_t *zone, dns_acl_t *acl);
664 * Sets the forward unsigned updates acl list for the zone.
666 * Require:
667 * 'zone' to be a valid zone.
668 * 'acl' to be valid acl.
671 void
672 dns_zone_setxfracl(dns_zone_t *zone, dns_acl_t *acl);
674 * Sets the transfer acl list for the zone.
676 * Require:
677 * 'zone' to be a valid zone.
678 * 'acl' to be valid acl.
681 dns_acl_t *
682 dns_zone_getnotifyacl(dns_zone_t *zone);
684 * Returns the current notify acl or NULL.
686 * Require:
687 * 'zone' to be a valid zone.
689 * Returns:
690 * acl a pointer to the acl.
691 * NULL
694 dns_acl_t *
695 dns_zone_getqueryacl(dns_zone_t *zone);
697 * Returns the current query acl or NULL.
699 * Require:
700 * 'zone' to be a valid zone.
702 * Returns:
703 * acl a pointer to the acl.
704 * NULL
707 dns_acl_t *
708 dns_zone_getupdateacl(dns_zone_t *zone);
710 * Returns the current update acl or NULL.
712 * Require:
713 * 'zone' to be a valid zone.
715 * Returns:
716 * acl a pointer to the acl.
717 * NULL
720 dns_acl_t *
721 dns_zone_getforwardacl(dns_zone_t *zone);
723 * Returns the current forward unsigned updates acl or NULL.
725 * Require:
726 * 'zone' to be a valid zone.
728 * Returns:
729 * acl a pointer to the acl.
730 * NULL
733 dns_acl_t *
734 dns_zone_getxfracl(dns_zone_t *zone);
736 * Returns the current transfer acl or NULL.
738 * Require:
739 * 'zone' to be a valid zone.
741 * Returns:
742 * acl a pointer to the acl.
743 * NULL
746 void
747 dns_zone_clearupdateacl(dns_zone_t *zone);
749 * Clear the current update acl.
751 * Require:
752 * 'zone' to be a valid zone.
755 void
756 dns_zone_clearforwardacl(dns_zone_t *zone);
758 * Clear the current forward unsigned updates acl.
760 * Require:
761 * 'zone' to be a valid zone.
764 void
765 dns_zone_clearnotifyacl(dns_zone_t *zone);
767 * Clear the current notify acl.
769 * Require:
770 * 'zone' to be a valid zone.
773 void
774 dns_zone_clearqueryacl(dns_zone_t *zone);
776 * Clear the current query acl.
778 * Require:
779 * 'zone' to be a valid zone.
782 void
783 dns_zone_clearxfracl(dns_zone_t *zone);
785 * Clear the current transfer acl.
787 * Require:
788 * 'zone' to be a valid zone.
791 isc_boolean_t
792 dns_zone_getupdatedisabled(dns_zone_t *zone);
794 void
795 dns_zone_setupdatedisabled(dns_zone_t *zone, isc_boolean_t state);
797 void
798 dns_zone_setchecknames(dns_zone_t *zone, dns_severity_t severity);
800 * Set the severity of name checking when loading a zone.
802 * Require:
803 * 'zone' to be a valid zone.
806 dns_severity_t
807 dns_zone_getchecknames(dns_zone_t *zone);
809 * Return the current severity of name checking.
811 * Require:
812 * 'zone' to be a valid zone.
815 void
816 dns_zone_setjournalsize(dns_zone_t *zone, isc_int32_t size);
818 * Sets the journal size for the zone.
820 * Requires:
821 * 'zone' to be a valid zone.
824 isc_int32_t
825 dns_zone_getjournalsize(dns_zone_t *zone);
827 * Return the journal size as set with a previous call to
828 * dns_zone_setjournalsize().
830 * Requires:
831 * 'zone' to be a valid zone.
834 isc_result_t
835 dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
836 dns_message_t *msg);
838 * Tell the zone that it has recieved a NOTIFY message from another
839 * server. This may cause some zone maintainence activity to occur.
841 * Requires:
842 * 'zone' to be a valid zone.
843 * '*from' to contain the address of the server from which 'msg'
844 * was recieved.
845 * 'msg' a message with opcode NOTIFY and qr clear.
847 * Returns:
848 * DNS_R_REFUSED
849 * DNS_R_NOTIMP
850 * DNS_R_FORMERR
851 * DNS_R_SUCCESS
854 void
855 dns_zone_setmaxxfrin(dns_zone_t *zone, isc_uint32_t maxxfrin);
857 * Set the maximum time (in seconds) that a zone transfer in (AXFR/IXFR)
858 * of this zone will use before being aborted.
860 * Requires:
861 * 'zone' to be valid initialised zone.
864 isc_uint32_t
865 dns_zone_getmaxxfrin(dns_zone_t *zone);
867 * Returns the maximum transfer time for this zone. This will be
868 * either the value set by the last call to dns_zone_setmaxxfrin() or
869 * the default value of 1 hour.
871 * Requires:
872 * 'zone' to be valid initialised zone.
875 void
876 dns_zone_setmaxxfrout(dns_zone_t *zone, isc_uint32_t maxxfrout);
878 * Set the maximum time (in seconds) that a zone transfer out (AXFR/IXFR)
879 * of this zone will use before being aborted.
881 * Requires:
882 * 'zone' to be valid initialised zone.
885 isc_uint32_t
886 dns_zone_getmaxxfrout(dns_zone_t *zone);
888 * Returns the maximum transfer time for this zone. This will be
889 * either the value set by the last call to dns_zone_setmaxxfrout() or
890 * the default value of 1 hour.
892 * Requires:
893 * 'zone' to be valid initialised zone.
896 isc_result_t
897 dns_zone_setjournal(dns_zone_t *zone, const char *journal);
899 * Sets the filename used for journaling updates / IXFR transfers.
900 * The default journal name is set by dns_zone_setfile() to be
901 * "file.jnl". If 'journal' is NULL, the zone will have no
902 * journal name.
904 * Requires:
905 * 'zone' to be a valid zone.
907 * Returns:
908 * ISC_R_SUCCESS
909 * ISC_R_NOMEMORY
912 char *
913 dns_zone_getjournal(dns_zone_t *zone);
915 * Returns the journal name associated with this zone.
916 * If no journal has been set this will be NULL.
918 * Requires:
919 * 'zone' to be valid initialised zone.
922 dns_zonetype_t
923 dns_zone_gettype(dns_zone_t *zone);
925 * Returns the type of the zone (master/slave/etc.)
927 * Requires:
928 * 'zone' to be valid initialised zone.
931 void
932 dns_zone_settask(dns_zone_t *zone, isc_task_t *task);
934 * Give a zone a task to work with. Any current task will be detached.
936 * Requires:
937 * 'zone' to be valid.
938 * 'task' to be valid.
941 void
942 dns_zone_gettask(dns_zone_t *zone, isc_task_t **target);
944 * Attach '*target' to the zone's task.
946 * Requires:
947 * 'zone' to be valid initialised zone.
948 * 'zone' to have a task.
949 * 'target' to be != NULL && '*target' == NULL.
952 void
953 dns_zone_notify(dns_zone_t *zone);
955 * Generate notify events for this zone.
957 * Requires:
958 * 'zone' to be a valid zone.
961 isc_result_t
962 dns_zone_replacedb(dns_zone_t *zone, dns_db_t *db, isc_boolean_t dump);
964 * Replace the database of "zone" with a new database "db".
966 * If "dump" is ISC_TRUE, then the new zone contents are dumped
967 * into to the zone's master file for persistence. When replacing
968 * a zone database by one just loaded from a master file, set
969 * "dump" to ISC_FALSE to avoid a redunant redump of the data just
970 * loaded. Otherwise, it should be set to ISC_TRUE.
972 * If the "diff-on-reload" option is enabled in the configuration file,
973 * the differences between the old and the new database are added to the
974 * journal file, and the master file dump is postponed.
976 * Requires:
977 * 'zone' to be a valid zone.
979 * Returns:
980 * DNS_R_SUCCESS
981 * DNS_R_BADZONE zone failed basic consistancy checks:
982 * * a single SOA must exist
983 * * some NS records must exist.
984 * Others
987 isc_uint32_t
988 dns_zone_getidlein(dns_zone_t *zone);
990 * Requires:
991 * 'zone' to be a valid zone.
993 * Returns:
994 * number of seconds of idle time before we abort the transfer in.
997 void
998 dns_zone_setidlein(dns_zone_t *zone, isc_uint32_t idlein);
1000 * Set the idle timeout for transfer the.
1001 * Zero set the default value, 1 hour.
1003 * Requires:
1004 * 'zone' to be a valid zone.
1007 isc_uint32_t
1008 dns_zone_getidleout(dns_zone_t *zone);
1011 * Requires:
1012 * 'zone' to be a valid zone.
1014 * Returns:
1015 * number of seconds of idle time before we abort a transfer out.
1018 void
1019 dns_zone_setidleout(dns_zone_t *zone, isc_uint32_t idleout);
1021 * Set the idle timeout for transfers out.
1022 * Zero set the default value, 1 hour.
1024 * Requires:
1025 * 'zone' to be a valid zone.
1028 void
1029 dns_zone_getssutable(dns_zone_t *zone, dns_ssutable_t **table);
1031 * Get the simple-secure-update policy table.
1033 * Requires:
1034 * 'zone' to be a valid zone.
1037 void
1038 dns_zone_setssutable(dns_zone_t *zone, dns_ssutable_t *table);
1040 * Set / clear the simple-secure-update policy table.
1042 * Requires:
1043 * 'zone' to be a valid zone.
1046 isc_mem_t *
1047 dns_zone_getmctx(dns_zone_t *zone);
1049 * Get the memory context of a zone.
1051 * Requires:
1052 * 'zone' to be a valid zone.
1055 dns_zonemgr_t *
1056 dns_zone_getmgr(dns_zone_t *zone);
1058 * If 'zone' is managed return the zone manager otherwise NULL.
1060 * Requires:
1061 * 'zone' to be a valid zone.
1064 void
1065 dns_zone_setsigvalidityinterval(dns_zone_t *zone, isc_uint32_t interval);
1067 * Set the zone's SIG validity interval. This is the length of time
1068 * for which DNSSEC signatures created as a result of dynamic updates
1069 * to secure zones will remain valid, in seconds.
1071 * Requires:
1072 * 'zone' to be a valid zone.
1075 isc_uint32_t
1076 dns_zone_getsigvalidityinterval(dns_zone_t *zone);
1078 * Get the zone's SIG validity interval.
1080 * Requires:
1081 * 'zone' to be a valid zone.
1084 void
1085 dns_zone_setnotifytype(dns_zone_t *zone, dns_notifytype_t notifytype);
1087 * Sets zone notify method to "notifytype"
1090 isc_result_t
1091 dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
1092 dns_updatecallback_t callback, void *callback_arg);
1094 * Forward 'msg' to each master in turn until we get an answer or we
1095 * have exausted the list of masters. 'callback' will be called with
1096 * ISC_R_SUCCESS if we get an answer and the returned message will be
1097 * passed as 'answer_message', otherwise a non ISC_R_SUCCESS result code
1098 * will be passed and answer_message will be NULL. The callback function
1099 * is responsible for destroying 'answer_message'.
1100 * (callback)(callback_arg, result, answer_message);
1102 * Require:
1103 * 'zone' to be valid
1104 * 'msg' to be valid.
1105 * 'callback' to be non NULL.
1106 * Returns:
1107 * ISC_R_SUCCESS if the message has been forwarded,
1108 * ISC_R_NOMEMORY
1109 * Others
1112 isc_result_t
1113 dns_zone_next(dns_zone_t *zone, dns_zone_t **next);
1115 * Find the next zone in the list of managed zones.
1117 * Requires:
1118 * 'zone' to be valid
1119 * The zone manager for the indicated zone MUST be locked
1120 * by the caller. This is not checked.
1121 * 'next' be non-NULL, and '*next' be NULL.
1123 * Ensures:
1124 * 'next' points to a valid zone (result ISC_R_SUCCESS) or to NULL
1125 * (result ISC_R_NOMORE).
1128 isc_result_t
1129 dns_zone_first(dns_zonemgr_t *zmgr, dns_zone_t **first);
1131 * Find the first zone in the list of managed zones.
1133 * Requires:
1134 * 'zonemgr' to be valid
1135 * The zone manager for the indicated zone MUST be locked
1136 * by the caller. This is not checked.
1137 * 'first' be non-NULL, and '*first' be NULL
1139 * Ensures:
1140 * 'first' points to a valid zone (result ISC_R_SUCCESS) or to NULL
1141 * (result ISC_R_NOMORE).
1144 isc_result_t
1145 dns_zone_setkeydirectory(dns_zone_t *zone, const char *directory);
1147 * Sets the name of the directory where private keys used for
1148 * online signing of dynamic zones are found.
1150 * Require:
1151 * 'zone' to be a valid zone.
1153 * Returns:
1154 * ISC_R_NOMEMORY
1155 * ISC_R_SUCCESS
1158 const char *
1159 dns_zone_getkeydirectory(dns_zone_t *zone);
1161 * Gets the name of the directory where private keys used for
1162 * online signing of dynamic zones are found.
1164 * Requires:
1165 * 'zone' to be valid initialised zone.
1167 * Returns:
1168 * Pointer to null-terminated file name, or NULL.
1172 isc_result_t
1173 dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
1174 isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr,
1175 dns_zonemgr_t **zmgrp);
1177 * Create a zone manager.
1179 * Requires:
1180 * 'mctx' to be a valid memory context.
1181 * 'taskmgr' to be a valid task manager.
1182 * 'timermgr' to be a valid timer manager.
1183 * 'zmgrp' to point to a NULL pointer.
1186 isc_result_t
1187 dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
1189 * Bring the zone under control of a zone manager.
1191 * Require:
1192 * 'zmgr' to be a valid zone manager.
1193 * 'zone' to be a valid zone.
1196 isc_result_t
1197 dns_zonemgr_forcemaint(dns_zonemgr_t *zmgr);
1199 * Force zone maintenance of all zones managed by 'zmgr' at its
1200 * earliest conveniene.
1203 void
1204 dns_zonemgr_resumexfrs(dns_zonemgr_t *zmgr);
1206 * Attempt to start any stalled zone transfers.
1209 void
1210 dns_zonemgr_shutdown(dns_zonemgr_t *zmgr);
1212 * Shut down the zone manager.
1214 * Requires:
1215 * 'zmgr' to be a valid zone manager.
1218 void
1219 dns_zonemgr_attach(dns_zonemgr_t *source, dns_zonemgr_t **target);
1221 * Attach '*target' to 'source' incrementing its external
1222 * reference count.
1224 * Require:
1225 * 'zone' to be a valid zone.
1226 * 'target' to be non NULL and '*target' to be NULL.
1229 void
1230 dns_zonemgr_detach(dns_zonemgr_t **zmgrp);
1232 * Detach from a zone manager.
1234 * Requires:
1235 * '*zmgrp' is a valid, non-NULL zone manager pointer.
1237 * Ensures:
1238 * '*zmgrp' is NULL.
1241 void
1242 dns_zonemgr_releasezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
1244 * Release 'zone' from the managed by 'zmgr'. 'zmgr' is implicitly
1245 * detached from 'zone'.
1247 * Requires:
1248 * 'zmgr' to be a valid zone manager.
1249 * 'zone' to be a valid zone.
1250 * 'zmgr' == 'zone->zmgr'
1252 * Ensures:
1253 * 'zone->zmgr' == NULL;
1256 void
1257 dns_zonemgr_settransfersin(dns_zonemgr_t *zmgr, isc_uint32_t value);
1259 * Set the maximum number of simultaneous transfers in allowed by
1260 * the zone manager.
1262 * Requires:
1263 * 'zmgr' to be a valid zone manager.
1266 isc_uint32_t
1267 dns_zonemgr_getttransfersin(dns_zonemgr_t *zmgr);
1269 * Return the the maximum number of simultaneous transfers in allowed.
1271 * Requires:
1272 * 'zmgr' to be a valid zone manager.
1275 void
1276 dns_zonemgr_settransfersperns(dns_zonemgr_t *zmgr, isc_uint32_t value);
1278 * Set the number of zone transfers allowed per nameserver.
1280 * Requires:
1281 * 'zmgr' to be a valid zone manager
1284 isc_uint32_t
1285 dns_zonemgr_getttransfersperns(dns_zonemgr_t *zmgr);
1287 * Return the number of transfers allowed per nameserver.
1289 * Requires:
1290 * 'zmgr' to be a valid zone manager.
1293 void
1294 dns_zonemgr_setiolimit(dns_zonemgr_t *zmgr, isc_uint32_t iolimit);
1296 * Set the number of simultaneous file descriptors available for
1297 * reading and writing masterfiles.
1299 * Requires:
1300 * 'zmgr' to be a valid zone manager.
1301 * 'iolimit' to be positive.
1304 isc_uint32_t
1305 dns_zonemgr_getiolimit(dns_zonemgr_t *zmgr);
1307 * Get the number of simultaneous file descriptors available for
1308 * reading and writing masterfiles.
1310 * Requires:
1311 * 'zmgr' to be a valid zone manager.
1314 void
1315 dns_zonemgr_setserialqueryrate(dns_zonemgr_t *zmgr, unsigned int value);
1317 * Set the number of SOA queries sent per second.
1319 * Requires:
1320 * 'zmgr' to be a valid zone manager
1323 unsigned int
1324 dns_zonemgr_getserialqueryrate(dns_zonemgr_t *zmgr);
1326 * Return the number of SOA queries sent per second.
1328 * Requires:
1329 * 'zmgr' to be a valid zone manager.
1332 unsigned int
1333 dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state);
1335 * Returns the number of zones in the specified state.
1337 * Requires:
1338 * 'zmgr' to be a valid zone manager.
1339 * 'state' to be a valid DNS_ZONESTATE_ constant.
1342 void
1343 dns_zone_forcereload(dns_zone_t *zone);
1345 * Force a reload of specified zone.
1347 * Requires:
1348 * 'zone' to be a valid zone.
1351 isc_boolean_t
1352 dns_zone_isforced(dns_zone_t *zone);
1354 * Check if the zone is waiting a forced reload.
1356 * Requires:
1357 * 'zone' to be a valid zone.
1360 isc_result_t
1361 dns_zone_setstatistics(dns_zone_t *zone, isc_boolean_t on);
1363 * Make the zone keep or not keep an array of statistics
1364 * counter.
1366 * Requires:
1367 * zone be a valid zone.
1370 isc_uint64_t *
1371 dns_zone_getstatscounters(dns_zone_t *zone);
1373 * Requires:
1374 * zone be a valid zone.
1376 * Returns:
1377 * A pointer to the zone's array of statistics counters,
1378 * or NULL if it has none.
1381 void
1382 dns_zone_dialup(dns_zone_t *zone);
1384 * Perform dialup-time maintenance on 'zone'.
1387 void
1388 dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup);
1390 * Set the dialup type of 'zone' to 'dialup'.
1392 * Requires:
1393 * 'zone' to be valid initialised zone.
1394 * 'dialup' to be a valid dialup type.
1397 void
1398 dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...)
1399 ISC_FORMAT_PRINTF(3, 4);
1401 * Log the message 'msg...' at 'level', including text that identifies
1402 * the message as applying to 'zone'.
1405 void
1406 dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category, int level,
1407 const char *msg, ...) ISC_FORMAT_PRINTF(4, 5);
1409 * Log the message 'msg...' at 'level', including text that identifies
1410 * the message as applying to 'zone'.
1413 void
1414 dns_zone_name(dns_zone_t *zone, char *buf, size_t len);
1416 * Return the name of the zone with class and view.
1418 * Requires:
1419 * 'zone' to be valid.
1420 * 'buf' to be non NULL.
1423 isc_result_t
1424 dns_zone_checknames(dns_zone_t *zone, dns_name_t *name, dns_rdata_t *rdata);
1426 * Check if this record meets the check-names policy.
1428 * Requires:
1429 * 'zone' to be valid.
1430 * 'name' to be valid.
1431 * 'rdata' to be valid.
1433 * Returns:
1434 * DNS_R_SUCCESS passed checks.
1435 * DNS_R_BADOWNERNAME failed ownername checks.
1436 * DNS_R_BADNAME failed rdata checks.
1439 ISC_LANG_ENDDECLS
1441 #endif /* DNS_ZONE_H */