2 * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2003 Internet Software Consortium.
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.
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.160.50.4 2009/01/29 22:40:35 jinmei Exp $ */
23 /*! \file dns/zone.h */
31 #include <isc/formatcheck.h>
33 #include <isc/rwlock.h>
35 #include <dns/masterdump.h>
36 #include <dns/rdatastruct.h>
37 #include <dns/types.h>
46 #define DNS_ZONEOPT_SERVERS 0x00000001U /*%< perform server checks */
47 #define DNS_ZONEOPT_PARENTS 0x00000002U /*%< perform parent checks */
48 #define DNS_ZONEOPT_CHILDREN 0x00000004U /*%< perform child checks */
49 #define DNS_ZONEOPT_NOTIFY 0x00000008U /*%< perform NOTIFY */
50 #define DNS_ZONEOPT_MANYERRORS 0x00000010U /*%< return many errors on load */
51 #define DNS_ZONEOPT_IXFRFROMDIFFS 0x00000020U /*%< calculate differences */
52 #define DNS_ZONEOPT_NOMERGE 0x00000040U /*%< don't merge journal */
53 #define DNS_ZONEOPT_CHECKNS 0x00000080U /*%< check if NS's are addresses */
54 #define DNS_ZONEOPT_FATALNS 0x00000100U /*%< DNS_ZONEOPT_CHECKNS is fatal */
55 #define DNS_ZONEOPT_MULTIMASTER 0x00000200U /*%< this zone has multiple masters */
56 #define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /*%< use alternate transfer sources */
57 #define DNS_ZONEOPT_CHECKNAMES 0x00000800U /*%< check-names */
58 #define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /*%< fatal check-name failures */
59 #define DNS_ZONEOPT_CHECKWILDCARD 0x00002000U /*%< check for internal wildcards */
60 #define DNS_ZONEOPT_CHECKMX 0x00004000U /*%< check-mx */
61 #define DNS_ZONEOPT_CHECKMXFAIL 0x00008000U /*%< fatal check-mx failures */
62 #define DNS_ZONEOPT_CHECKINTEGRITY 0x00010000U /*%< perform integrity checks */
63 #define DNS_ZONEOPT_CHECKSIBLING 0x00020000U /*%< perform sibling glue checks */
64 #define DNS_ZONEOPT_NOCHECKNS 0x00040000U /*%< disable IN NS address checks */
65 #define DNS_ZONEOPT_WARNMXCNAME 0x00080000U /*%< warn on MX CNAME check */
66 #define DNS_ZONEOPT_IGNOREMXCNAME 0x00100000U /*%< ignore MX CNAME check */
67 #define DNS_ZONEOPT_WARNSRVCNAME 0x00200000U /*%< warn on SRV CNAME check */
68 #define DNS_ZONEOPT_IGNORESRVCNAME 0x00400000U /*%< ignore SRV CNAME check */
69 #define DNS_ZONEOPT_UPDATECHECKKSK 0x00800000U /*%< check dnskey KSK flag */
70 #define DNS_ZONEOPT_TRYTCPREFRESH 0x01000000U /*%< try tcp refresh on udp failure */
71 #define DNS_ZONEOPT_NOTIFYTOSOA 0x02000000U /*%< Notify the SOA MNAME */
72 #define DNS_ZONEOPT_NSEC3TESTZONE 0x04000000U /*%< nsec3-test-zone */
74 #ifndef NOMINUM_PUBLIC
76 * Nominum specific options build down.
78 #define DNS_ZONEOPT_NOTIFYFORWARD 0x80000000U /* forward notify to master */
79 #endif /* NOMINUM_PUBLIC */
81 #ifndef DNS_ZONE_MINREFRESH
82 #define DNS_ZONE_MINREFRESH 300 /*%< 5 minutes */
84 #ifndef DNS_ZONE_MAXREFRESH
85 #define DNS_ZONE_MAXREFRESH 2419200 /*%< 4 weeks */
87 #ifndef DNS_ZONE_DEFAULTREFRESH
88 #define DNS_ZONE_DEFAULTREFRESH 3600 /*%< 1 hour */
90 #ifndef DNS_ZONE_MINRETRY
91 #define DNS_ZONE_MINRETRY 300 /*%< 5 minutes */
93 #ifndef DNS_ZONE_MAXRETRY
94 #define DNS_ZONE_MAXRETRY 1209600 /*%< 2 weeks */
96 #ifndef DNS_ZONE_DEFAULTRETRY
97 #define DNS_ZONE_DEFAULTRETRY 60 /*%< 1 minute, subject to
98 exponential backoff */
101 #define DNS_ZONESTATE_XFERRUNNING 1
102 #define DNS_ZONESTATE_XFERDEFERRED 2
103 #define DNS_ZONESTATE_SOAQUERY 3
104 #define DNS_ZONESTATE_ANY 4
113 dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx);
115 * Creates a new empty zone and attach '*zonep' to it.
118 *\li 'zonep' to point to a NULL pointer.
119 *\li 'mctx' to be a valid memory context.
122 *\li '*zonep' refers to a valid zone.
127 *\li #ISC_R_UNEXPECTED
131 dns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass);
133 * Sets the class of a zone. This operation can only be performed
137 *\li 'zone' to be a valid zone.
138 *\li dns_zone_setclass() not to have been called since the zone was
140 *\li 'rdclass' != dns_rdataclass_none.
144 dns_zone_getclass(dns_zone_t *zone);
146 * Returns the current zone class.
149 *\li 'zone' to be a valid zone.
153 dns_zone_getserial(dns_zone_t *zone);
155 * Returns the current serial number of the zone.
158 *\li 'zone' to be a valid zone.
162 dns_zone_settype(dns_zone_t *zone, dns_zonetype_t type);
164 * Sets the zone type. This operation can only be performed once on
168 *\li 'zone' to be a valid zone.
169 *\li dns_zone_settype() not to have been called since the zone was
171 *\li 'type' != dns_zone_none
175 dns_zone_setview(dns_zone_t *zone, dns_view_t *view);
177 * Associate the zone with a view.
180 *\li 'zone' to be a valid zone.
184 dns_zone_getview(dns_zone_t *zone);
186 * Returns the zone's associated view.
189 *\li 'zone' to be a valid zone.
193 dns_zone_setorigin(dns_zone_t *zone, const dns_name_t *origin);
195 * Sets the zones origin to 'origin'.
198 *\li 'zone' to be a valid zone.
199 *\li 'origin' to be non NULL.
207 dns_zone_getorigin(dns_zone_t *zone);
209 * Returns the value of the origin.
212 *\li 'zone' to be a valid zone.
216 dns_zone_setfile(dns_zone_t *zone, const char *file);
219 dns_zone_setfile2(dns_zone_t *zone, const char *file,
220 dns_masterformat_t format);
222 * Sets the name of the master file in the format of 'format' from which
223 * the zone loads its database to 'file'.
225 * For zones that have no associated master file, 'file' will be NULL.
227 * For zones with persistent databases, the file name
228 * setting is ignored.
230 * dns_zone_setfile() is a backward-compatible form of
231 * dns_zone_setfile2(), which always specifies the
232 * dns_masterformat_text (RFC1035) format.
235 *\li 'zone' to be a valid zone.
243 dns_zone_getfile(dns_zone_t *zone);
245 * Gets the name of the zone's master file, if any.
248 *\li 'zone' to be valid initialised zone.
251 *\li Pointer to null-terminated file name, or NULL.
255 dns_zone_load(dns_zone_t *zone);
258 dns_zone_loadnew(dns_zone_t *zone);
260 * Cause the database to be loaded from its backing store.
261 * Confirm that the minimum requirements for the zone type are
262 * met, otherwise DNS_R_BADZONE is returned.
264 * dns_zone_loadnew() only loads zones that are not yet loaded.
265 * dns_zone_load() also loads zones that are already loaded and
266 * and whose master file has changed since the last load.
269 *\li 'zone' to be a valid zone.
272 *\li #ISC_R_UNEXPECTED
274 *\li DNS_R_CONTINUE Incremental load has been queued.
275 *\li DNS_R_UPTODATE The zone has already been loaded based on
276 * file system timestamps.
278 *\li Any result value from dns_db_load().
282 dns_zone_attach(dns_zone_t *source, dns_zone_t **target);
284 * Attach '*target' to 'source' incrementing its external
288 *\li 'zone' to be a valid zone.
289 *\li 'target' to be non NULL and '*target' to be NULL.
293 dns_zone_detach(dns_zone_t **zonep);
295 * Detach from a zone decrementing its external reference count.
296 * If this was the last external reference to the zone it will be
297 * shut down and eventually freed.
300 *\li 'zonep' to point to a valid zone.
304 dns_zone_iattach(dns_zone_t *source, dns_zone_t **target);
306 * Attach '*target' to 'source' incrementing its internal
307 * reference count. This is intended for use by operations
308 * such as zone transfers that need to prevent the zone
309 * object from being freed but not from shutting down.
312 *\li The caller is running in the context of the zone's task.
313 *\li 'zone' to be a valid zone.
314 *\li 'target' to be non NULL and '*target' to be NULL.
318 dns_zone_idetach(dns_zone_t **zonep);
320 * Detach from a zone decrementing its internal reference count.
321 * If there are no more internal or external references to the
322 * zone, it will be freed.
325 *\li The caller is running in the context of the zone's task.
326 *\li 'zonep' to point to a valid zone.
330 dns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value);
332 * Sets ('value' == 'ISC_TRUE') / clears ('value' == 'IS_FALSE')
333 * zone flags. Valid flag bits are DNS_ZONE_F_*.
336 *\li 'zone' to be a valid zone.
340 dns_zone_getdb(dns_zone_t *zone, dns_db_t **dbp);
342 * Attach '*dbp' to the database to if it exists otherwise
343 * return DNS_R_NOTLOADED.
346 *\li 'zone' to be a valid zone.
347 *\li 'dbp' to be != NULL && '*dbp' == NULL.
355 dns_zone_setdbtype(dns_zone_t *zone,
356 unsigned int dbargc, const char * const *dbargv);
358 * Sets the database type to dbargv[0] and database arguments
359 * to subsequent dbargv elements.
360 * 'db_type' is not checked to see if it is a valid database type.
363 *\li 'zone' to be a valid zone.
364 *\li 'database' to be non NULL.
365 *\li 'dbargc' to be >= 1
366 *\li 'dbargv' to point to dbargc NULL-terminated strings
374 dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx);
376 * Returns the current dbtype. isc_mem_free() should be used
377 * to free 'argv' after use.
380 *\li 'zone' to be a valid zone.
381 *\li 'argv' to be non NULL and *argv to be NULL.
382 *\li 'mctx' to be valid.
390 dns_zone_markdirty(dns_zone_t *zone);
392 * Mark a zone as 'dirty'.
395 *\li 'zone' to be a valid zone.
399 dns_zone_expire(dns_zone_t *zone);
401 * Mark the zone as expired. If the zone requires dumping cause it to
402 * be initiated. Set the refresh and retry intervals to there default
403 * values and unload the zone.
406 *\li 'zone' to be a valid zone.
410 dns_zone_refresh(dns_zone_t *zone);
412 * Initiate zone up to date checks. The zone must already be being
416 *\li 'zone' to be a valid zone.
420 dns_zone_flush(dns_zone_t *zone);
422 * Write the zone to database if there are uncommitted changes.
425 *\li 'zone' to be a valid zone.
429 dns_zone_dump(dns_zone_t *zone);
431 * Write the zone to database.
434 *\li 'zone' to be a valid zone.
438 dns_zone_dumptostream(dns_zone_t *zone, FILE *fd);
441 dns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
442 const dns_master_style_t *style);
444 * Write the zone to stream 'fd' in the specified 'format'.
445 * If the 'format' is dns_masterformat_text (RFC1035), 'style' also
446 * specifies the file style (e.g., &dns_master_style_default).
448 * dns_zone_dumptostream() is a backward-compatible form of
449 * dns_zone_dumptostream2(), which always uses the dns_masterformat_text
450 * format and the dns_master_style_default style.
452 * Note that dns_zone_dumptostream2() is the most flexible form. It
453 * can also provide the functionality of dns_zone_fulldumptostream().
456 *\li 'zone' to be a valid zone.
457 *\li 'fd' to be a stream open for writing.
461 dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd);
463 * The same as dns_zone_dumptostream, but dumps the zone with
464 * different dump settings (dns_master_style_full).
467 *\li 'zone' to be a valid zone.
468 *\li 'fd' to be a stream open for writing.
472 dns_zone_maintenance(dns_zone_t *zone);
474 * Perform regular maintenance on the zone. This is called as a
475 * result of a zone being managed.
478 *\li 'zone' to be a valid zone.
482 dns_zone_setmasters(dns_zone_t *zone, const isc_sockaddr_t *masters,
485 dns_zone_setmasterswithkeys(dns_zone_t *zone,
486 const isc_sockaddr_t *masters,
487 dns_name_t **keynames,
490 * Set the list of master servers for the zone.
493 *\li 'zone' to be a valid zone.
494 *\li 'masters' array of isc_sockaddr_t with port set or NULL.
495 *\li 'count' the number of masters.
496 *\li 'keynames' array of dns_name_t's for tsig keys or NULL.
498 * \li dns_zone_setmasters() is just a wrapper to setmasterswithkeys(),
499 * passing NULL in the keynames field.
501 * \li If 'masters' is NULL then 'count' must be zero.
506 *\li Any result dns_name_dup() can return, if keynames!=NULL
510 dns_zone_setalsonotify(dns_zone_t *zone, const isc_sockaddr_t *notify,
513 * Set the list of additional servers to be notified when
514 * a zone changes. To clear the list use 'count = 0'.
517 *\li 'zone' to be a valid zone.
518 *\li 'notify' to be non-NULL if count != 0.
519 *\li 'count' to be the number of notifiees.
527 dns_zone_unload(dns_zone_t *zone);
529 * detach the database from the zone structure.
532 *\li 'zone' to be a valid zone.
536 dns_zone_setoption(dns_zone_t *zone, unsigned int option, isc_boolean_t value);
538 * Set given options on ('value' == ISC_TRUE) or off ('value' ==
542 *\li 'zone' to be a valid zone.
546 dns_zone_getoptions(dns_zone_t *zone);
548 * Returns the current zone options.
551 *\li 'zone' to be a valid zone.
555 dns_zone_setminrefreshtime(dns_zone_t *zone, isc_uint32_t val);
557 * Set the minimum refresh time.
560 *\li 'zone' is valid.
565 dns_zone_setmaxrefreshtime(dns_zone_t *zone, isc_uint32_t val);
567 * Set the maximum refresh time.
570 *\li 'zone' is valid.
575 dns_zone_setminretrytime(dns_zone_t *zone, isc_uint32_t val);
577 * Set the minimum retry time.
580 *\li 'zone' is valid.
585 dns_zone_setmaxretrytime(dns_zone_t *zone, isc_uint32_t val);
587 * Set the maximum retry time.
590 *\li 'zone' is valid.
595 dns_zone_setxfrsource4(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
597 dns_zone_setaltxfrsource4(dns_zone_t *zone,
598 const isc_sockaddr_t *xfrsource);
600 * Set the source address to be used in IPv4 zone transfers.
603 *\li 'zone' to be a valid zone.
604 *\li 'xfrsource' to contain the address.
611 dns_zone_getxfrsource4(dns_zone_t *zone);
613 dns_zone_getaltxfrsource4(dns_zone_t *zone);
615 * Returns the source address set by a previous dns_zone_setxfrsource4
616 * call, or the default of inaddr_any, port 0.
619 *\li 'zone' to be a valid zone.
623 dns_zone_setxfrsource6(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
625 dns_zone_setaltxfrsource6(dns_zone_t *zone,
626 const isc_sockaddr_t *xfrsource);
628 * Set the source address to be used in IPv6 zone transfers.
631 *\li 'zone' to be a valid zone.
632 *\li 'xfrsource' to contain the address.
639 dns_zone_getxfrsource6(dns_zone_t *zone);
641 dns_zone_getaltxfrsource6(dns_zone_t *zone);
643 * Returns the source address set by a previous dns_zone_setxfrsource6
644 * call, or the default of in6addr_any, port 0.
647 *\li 'zone' to be a valid zone.
651 dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
653 * Set the source address to be used with IPv4 NOTIFY messages.
656 *\li 'zone' to be a valid zone.
657 *\li 'notifysrc' to contain the address.
664 dns_zone_getnotifysrc4(dns_zone_t *zone);
666 * Returns the source address set by a previous dns_zone_setnotifysrc4
667 * call, or the default of inaddr_any, port 0.
670 *\li 'zone' to be a valid zone.
674 dns_zone_setnotifysrc6(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
676 * Set the source address to be used with IPv6 NOTIFY messages.
679 *\li 'zone' to be a valid zone.
680 *\li 'notifysrc' to contain the address.
687 dns_zone_getnotifysrc6(dns_zone_t *zone);
689 * Returns the source address set by a previous dns_zone_setnotifysrc6
690 * call, or the default of in6addr_any, port 0.
693 *\li 'zone' to be a valid zone.
697 dns_zone_setnotifyacl(dns_zone_t *zone, dns_acl_t *acl);
699 * Sets the notify acl list for the zone.
702 *\li 'zone' to be a valid zone.
703 *\li 'acl' to be a valid acl.
707 dns_zone_setqueryacl(dns_zone_t *zone, dns_acl_t *acl);
709 * Sets the query acl list for the zone.
712 *\li 'zone' to be a valid zone.
713 *\li 'acl' to be a valid acl.
717 dns_zone_setqueryonacl(dns_zone_t *zone, dns_acl_t *acl);
719 * Sets the query-on acl list for the zone.
722 *\li 'zone' to be a valid zone.
723 *\li 'acl' to be a valid acl.
727 dns_zone_setupdateacl(dns_zone_t *zone, dns_acl_t *acl);
729 * Sets the update acl list for the zone.
732 *\li 'zone' to be a valid zone.
733 *\li 'acl' to be valid acl.
737 dns_zone_setforwardacl(dns_zone_t *zone, dns_acl_t *acl);
739 * Sets the forward unsigned updates acl list for the zone.
742 *\li 'zone' to be a valid zone.
743 *\li 'acl' to be valid acl.
747 dns_zone_setxfracl(dns_zone_t *zone, dns_acl_t *acl);
749 * Sets the transfer acl list for the zone.
752 *\li 'zone' to be a valid zone.
753 *\li 'acl' to be valid acl.
757 dns_zone_getnotifyacl(dns_zone_t *zone);
759 * Returns the current notify acl or NULL.
762 *\li 'zone' to be a valid zone.
765 *\li acl a pointer to the acl.
770 dns_zone_getqueryacl(dns_zone_t *zone);
772 * Returns the current query acl or NULL.
775 *\li 'zone' to be a valid zone.
778 *\li acl a pointer to the acl.
783 dns_zone_getqueryonacl(dns_zone_t *zone);
785 * Returns the current query-on acl or NULL.
788 *\li 'zone' to be a valid zone.
791 *\li acl a pointer to the acl.
796 dns_zone_getupdateacl(dns_zone_t *zone);
798 * Returns the current update acl or NULL.
801 *\li 'zone' to be a valid zone.
804 *\li acl a pointer to the acl.
809 dns_zone_getforwardacl(dns_zone_t *zone);
811 * Returns the current forward unsigned updates acl or NULL.
814 *\li 'zone' to be a valid zone.
817 *\li acl a pointer to the acl.
822 dns_zone_getxfracl(dns_zone_t *zone);
824 * Returns the current transfer acl or NULL.
827 *\li 'zone' to be a valid zone.
830 *\li acl a pointer to the acl.
835 dns_zone_clearupdateacl(dns_zone_t *zone);
837 * Clear the current update acl.
840 *\li 'zone' to be a valid zone.
844 dns_zone_clearforwardacl(dns_zone_t *zone);
846 * Clear the current forward unsigned updates acl.
849 *\li 'zone' to be a valid zone.
853 dns_zone_clearnotifyacl(dns_zone_t *zone);
855 * Clear the current notify acl.
858 *\li 'zone' to be a valid zone.
862 dns_zone_clearqueryacl(dns_zone_t *zone);
864 * Clear the current query acl.
867 *\li 'zone' to be a valid zone.
871 dns_zone_clearqueryonacl(dns_zone_t *zone);
873 * Clear the current query-on acl.
876 *\li 'zone' to be a valid zone.
880 dns_zone_clearxfracl(dns_zone_t *zone);
882 * Clear the current transfer acl.
885 *\li 'zone' to be a valid zone.
889 dns_zone_getupdatedisabled(dns_zone_t *zone);
891 * Return update disabled.
892 * Transient unless called when running in isc_task_exclusive() mode.
896 dns_zone_setupdatedisabled(dns_zone_t *zone, isc_boolean_t state);
898 * Set update disabled.
899 * Should only be called only when running in isc_task_exclusive() mode.
900 * Failure to do so may result in updates being committed after the
901 * call has been made.
905 dns_zone_getzeronosoattl(dns_zone_t *zone);
907 * Return zero-no-soa-ttl status.
911 dns_zone_setzeronosoattl(dns_zone_t *zone, isc_boolean_t state);
913 * Set zero-no-soa-ttl status.
917 dns_zone_setchecknames(dns_zone_t *zone, dns_severity_t severity);
919 * Set the severity of name checking when loading a zone.
922 * \li 'zone' to be a valid zone.
926 dns_zone_getchecknames(dns_zone_t *zone);
928 * Return the current severity of name checking.
931 *\li 'zone' to be a valid zone.
935 dns_zone_setjournalsize(dns_zone_t *zone, isc_int32_t size);
937 * Sets the journal size for the zone.
940 *\li 'zone' to be a valid zone.
944 dns_zone_getjournalsize(dns_zone_t *zone);
946 * Return the journal size as set with a previous call to
947 * dns_zone_setjournalsize().
950 *\li 'zone' to be a valid zone.
954 dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
957 * Tell the zone that it has received a NOTIFY message from another
958 * server. This may cause some zone maintenance activity to occur.
961 *\li 'zone' to be a valid zone.
962 *\li '*from' to contain the address of the server from which 'msg'
964 *\li 'msg' a message with opcode NOTIFY and qr clear.
974 dns_zone_setmaxxfrin(dns_zone_t *zone, isc_uint32_t maxxfrin);
976 * Set the maximum time (in seconds) that a zone transfer in (AXFR/IXFR)
977 * of this zone will use before being aborted.
980 * \li 'zone' to be valid initialised zone.
984 dns_zone_getmaxxfrin(dns_zone_t *zone);
986 * Returns the maximum transfer time for this zone. This will be
987 * either the value set by the last call to dns_zone_setmaxxfrin() or
988 * the default value of 1 hour.
991 *\li 'zone' to be valid initialised zone.
995 dns_zone_setmaxxfrout(dns_zone_t *zone, isc_uint32_t maxxfrout);
997 * Set the maximum time (in seconds) that a zone transfer out (AXFR/IXFR)
998 * of this zone will use before being aborted.
1001 * \li 'zone' to be valid initialised zone.
1005 dns_zone_getmaxxfrout(dns_zone_t *zone);
1007 * Returns the maximum transfer time for this zone. This will be
1008 * either the value set by the last call to dns_zone_setmaxxfrout() or
1009 * the default value of 1 hour.
1012 *\li 'zone' to be valid initialised zone.
1016 dns_zone_setjournal(dns_zone_t *zone, const char *journal);
1018 * Sets the filename used for journaling updates / IXFR transfers.
1019 * The default journal name is set by dns_zone_setfile() to be
1020 * "file.jnl". If 'journal' is NULL, the zone will have no
1024 *\li 'zone' to be a valid zone.
1028 *\li #ISC_R_NOMEMORY
1032 dns_zone_getjournal(dns_zone_t *zone);
1034 * Returns the journal name associated with this zone.
1035 * If no journal has been set this will be NULL.
1038 *\li 'zone' to be valid initialised zone.
1042 dns_zone_gettype(dns_zone_t *zone);
1044 * Returns the type of the zone (master/slave/etc.)
1047 *\li 'zone' to be valid initialised zone.
1051 dns_zone_settask(dns_zone_t *zone, isc_task_t *task);
1053 * Give a zone a task to work with. Any current task will be detached.
1056 *\li 'zone' to be valid.
1057 *\li 'task' to be valid.
1061 dns_zone_gettask(dns_zone_t *zone, isc_task_t **target);
1063 * Attach '*target' to the zone's task.
1066 *\li 'zone' to be valid initialised zone.
1067 *\li 'zone' to have a task.
1068 *\li 'target' to be != NULL && '*target' == NULL.
1072 dns_zone_notify(dns_zone_t *zone);
1074 * Generate notify events for this zone.
1077 *\li 'zone' to be a valid zone.
1081 dns_zone_replacedb(dns_zone_t *zone, dns_db_t *db, isc_boolean_t dump);
1083 * Replace the database of "zone" with a new database "db".
1085 * If "dump" is ISC_TRUE, then the new zone contents are dumped
1086 * into to the zone's master file for persistence. When replacing
1087 * a zone database by one just loaded from a master file, set
1088 * "dump" to ISC_FALSE to avoid a redundant redump of the data just
1089 * loaded. Otherwise, it should be set to ISC_TRUE.
1091 * If the "diff-on-reload" option is enabled in the configuration file,
1092 * the differences between the old and the new database are added to the
1093 * journal file, and the master file dump is postponed.
1096 * \li 'zone' to be a valid zone.
1100 * \li DNS_R_BADZONE zone failed basic consistency checks:
1101 * * a single SOA must exist
1102 * * some NS records must exist.
1107 dns_zone_getidlein(dns_zone_t *zone);
1110 * \li 'zone' to be a valid zone.
1113 * \li number of seconds of idle time before we abort the transfer in.
1117 dns_zone_setidlein(dns_zone_t *zone, isc_uint32_t idlein);
1119 * \li Set the idle timeout for transfer the.
1120 * \li Zero set the default value, 1 hour.
1123 * \li 'zone' to be a valid zone.
1127 dns_zone_getidleout(dns_zone_t *zone);
1131 * \li 'zone' to be a valid zone.
1134 * \li number of seconds of idle time before we abort a transfer out.
1138 dns_zone_setidleout(dns_zone_t *zone, isc_uint32_t idleout);
1140 * \li Set the idle timeout for transfers out.
1141 * \li Zero set the default value, 1 hour.
1144 * \li 'zone' to be a valid zone.
1148 dns_zone_getssutable(dns_zone_t *zone, dns_ssutable_t **table);
1150 * Get the simple-secure-update policy table.
1153 * \li 'zone' to be a valid zone.
1157 dns_zone_setssutable(dns_zone_t *zone, dns_ssutable_t *table);
1159 * Set / clear the simple-secure-update policy table.
1162 * \li 'zone' to be a valid zone.
1166 dns_zone_getmctx(dns_zone_t *zone);
1168 * Get the memory context of a zone.
1171 * \li 'zone' to be a valid zone.
1175 dns_zone_getmgr(dns_zone_t *zone);
1177 * If 'zone' is managed return the zone manager otherwise NULL.
1180 * \li 'zone' to be a valid zone.
1184 dns_zone_setsigvalidityinterval(dns_zone_t *zone, isc_uint32_t interval);
1186 * Set the zone's RRSIG validity interval. This is the length of time
1187 * for which DNSSEC signatures created as a result of dynamic updates
1188 * to secure zones will remain valid, in seconds.
1191 * \li 'zone' to be a valid zone.
1195 dns_zone_getsigvalidityinterval(dns_zone_t *zone);
1197 * Get the zone's RRSIG validity interval.
1200 * \li 'zone' to be a valid zone.
1204 dns_zone_setsigresigninginterval(dns_zone_t *zone, isc_uint32_t interval);
1206 * Set the zone's RRSIG re-signing interval. A dynamic zone's RRSIG's
1207 * will be re-signed 'interval' amount of time before they expire.
1210 * \li 'zone' to be a valid zone.
1214 dns_zone_getsigresigninginterval(dns_zone_t *zone);
1216 * Get the zone's RRSIG re-signing interval.
1219 * \li 'zone' to be a valid zone.
1223 dns_zone_setnotifytype(dns_zone_t *zone, dns_notifytype_t notifytype);
1225 * Sets zone notify method to "notifytype"
1229 dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
1230 dns_updatecallback_t callback, void *callback_arg);
1232 * Forward 'msg' to each master in turn until we get an answer or we
1233 * have exhausted the list of masters. 'callback' will be called with
1234 * ISC_R_SUCCESS if we get an answer and the returned message will be
1235 * passed as 'answer_message', otherwise a non ISC_R_SUCCESS result code
1236 * will be passed and answer_message will be NULL. The callback function
1237 * is responsible for destroying 'answer_message'.
1238 * (callback)(callback_arg, result, answer_message);
1241 *\li 'zone' to be valid
1242 *\li 'msg' to be valid.
1243 *\li 'callback' to be non NULL.
1245 *\li #ISC_R_SUCCESS if the message has been forwarded,
1246 *\li #ISC_R_NOMEMORY
1251 dns_zone_next(dns_zone_t *zone, dns_zone_t **next);
1253 * Find the next zone in the list of managed zones.
1256 *\li 'zone' to be valid
1257 *\li The zone manager for the indicated zone MUST be locked
1258 * by the caller. This is not checked.
1259 *\li 'next' be non-NULL, and '*next' be NULL.
1262 *\li 'next' points to a valid zone (result ISC_R_SUCCESS) or to NULL
1263 * (result ISC_R_NOMORE).
1269 dns_zone_first(dns_zonemgr_t *zmgr, dns_zone_t **first);
1271 * Find the first zone in the list of managed zones.
1274 *\li 'zonemgr' to be valid
1275 *\li The zone manager for the indicated zone MUST be locked
1276 * by the caller. This is not checked.
1277 *\li 'first' be non-NULL, and '*first' be NULL
1280 *\li 'first' points to a valid zone (result ISC_R_SUCCESS) or to NULL
1281 * (result ISC_R_NOMORE).
1285 dns_zone_setkeydirectory(dns_zone_t *zone, const char *directory);
1287 * Sets the name of the directory where private keys used for
1288 * online signing of dynamic zones are found.
1291 *\li 'zone' to be a valid zone.
1294 *\li #ISC_R_NOMEMORY
1299 dns_zone_getkeydirectory(dns_zone_t *zone);
1301 * Gets the name of the directory where private keys used for
1302 * online signing of dynamic zones are found.
1305 *\li 'zone' to be valid initialised zone.
1308 * Pointer to null-terminated file name, or NULL.
1313 dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
1314 isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr,
1315 dns_zonemgr_t **zmgrp);
1317 * Create a zone manager.
1320 *\li 'mctx' to be a valid memory context.
1321 *\li 'taskmgr' to be a valid task manager.
1322 *\li 'timermgr' to be a valid timer manager.
1323 *\li 'zmgrp' to point to a NULL pointer.
1327 dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
1329 * Bring the zone under control of a zone manager.
1332 *\li 'zmgr' to be a valid zone manager.
1333 *\li 'zone' to be a valid zone.
1337 dns_zonemgr_forcemaint(dns_zonemgr_t *zmgr);
1339 * Force zone maintenance of all zones managed by 'zmgr' at its
1340 * earliest convenience.
1344 dns_zonemgr_resumexfrs(dns_zonemgr_t *zmgr);
1346 * Attempt to start any stalled zone transfers.
1350 dns_zonemgr_shutdown(dns_zonemgr_t *zmgr);
1352 * Shut down the zone manager.
1355 *\li 'zmgr' to be a valid zone manager.
1359 dns_zonemgr_attach(dns_zonemgr_t *source, dns_zonemgr_t **target);
1361 * Attach '*target' to 'source' incrementing its external
1365 *\li 'zone' to be a valid zone.
1366 *\li 'target' to be non NULL and '*target' to be NULL.
1370 dns_zonemgr_detach(dns_zonemgr_t **zmgrp);
1372 * Detach from a zone manager.
1375 *\li '*zmgrp' is a valid, non-NULL zone manager pointer.
1378 *\li '*zmgrp' is NULL.
1382 dns_zonemgr_releasezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
1384 * Release 'zone' from the managed by 'zmgr'. 'zmgr' is implicitly
1385 * detached from 'zone'.
1388 *\li 'zmgr' to be a valid zone manager.
1389 *\li 'zone' to be a valid zone.
1390 *\li 'zmgr' == 'zone->zmgr'
1393 *\li 'zone->zmgr' == NULL;
1397 dns_zonemgr_settransfersin(dns_zonemgr_t *zmgr, isc_uint32_t value);
1399 * Set the maximum number of simultaneous transfers in allowed by
1403 *\li 'zmgr' to be a valid zone manager.
1407 dns_zonemgr_getttransfersin(dns_zonemgr_t *zmgr);
1409 * Return the maximum number of simultaneous transfers in allowed.
1412 *\li 'zmgr' to be a valid zone manager.
1416 dns_zonemgr_settransfersperns(dns_zonemgr_t *zmgr, isc_uint32_t value);
1418 * Set the number of zone transfers allowed per nameserver.
1421 *\li 'zmgr' to be a valid zone manager
1425 dns_zonemgr_getttransfersperns(dns_zonemgr_t *zmgr);
1427 * Return the number of transfers allowed per nameserver.
1430 *\li 'zmgr' to be a valid zone manager.
1434 dns_zonemgr_setiolimit(dns_zonemgr_t *zmgr, isc_uint32_t iolimit);
1436 * Set the number of simultaneous file descriptors available for
1437 * reading and writing masterfiles.
1440 *\li 'zmgr' to be a valid zone manager.
1441 *\li 'iolimit' to be positive.
1445 dns_zonemgr_getiolimit(dns_zonemgr_t *zmgr);
1447 * Get the number of simultaneous file descriptors available for
1448 * reading and writing masterfiles.
1451 *\li 'zmgr' to be a valid zone manager.
1455 dns_zonemgr_setserialqueryrate(dns_zonemgr_t *zmgr, unsigned int value);
1457 * Set the number of SOA queries sent per second.
1460 *\li 'zmgr' to be a valid zone manager
1464 dns_zonemgr_getserialqueryrate(dns_zonemgr_t *zmgr);
1466 * Return the number of SOA queries sent per second.
1469 *\li 'zmgr' to be a valid zone manager.
1473 dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state);
1475 * Returns the number of zones in the specified state.
1478 *\li 'zmgr' to be a valid zone manager.
1479 *\li 'state' to be a valid DNS_ZONESTATE_ constant.
1483 dns_zonemgr_unreachableadd(dns_zonemgr_t *zmgr, isc_sockaddr_t *remote,
1484 isc_sockaddr_t *local, isc_time_t *now);
1486 * Add the pair of addresses to the unreachable cache.
1489 *\li 'zmgr' to be a valid zone manager.
1490 *\li 'remote' to be a valid sockaddr.
1491 *\li 'local' to be a valid sockaddr.
1495 dns_zone_forcereload(dns_zone_t *zone);
1497 * Force a reload of specified zone.
1500 *\li 'zone' to be a valid zone.
1504 dns_zone_isforced(dns_zone_t *zone);
1506 * Check if the zone is waiting a forced reload.
1509 * \li 'zone' to be a valid zone.
1513 dns_zone_setstatistics(dns_zone_t *zone, isc_boolean_t on);
1515 * This function is obsoleted by dns_zone_setrequeststats().
1519 dns_zone_getstatscounters(dns_zone_t *zone);
1521 * This function is obsoleted by dns_zone_getrequeststats().
1525 dns_zone_setstats(dns_zone_t *zone, isc_stats_t *stats);
1527 * Set a general zone-maintenance statistics set 'stats' for 'zone'. This
1528 * function is expected to be called only on zone creation (when necessary).
1529 * Once installed, it cannot be removed or replaced. Also, there is no
1530 * interface to get the installed stats from the zone; the caller must keep the
1531 * stats to reference (e.g. dump) it later.
1534 * \li 'zone' to be a valid zone and does not have a statistics set already
1537 *\li stats is a valid statistics supporting zone statistics counters
1538 * (see dns/stats.h).
1542 dns_zone_setrequeststats(dns_zone_t *zone, isc_stats_t *stats);
1544 * Set an additional statistics set to zone. It is attached in the zone
1545 * but is not counted in the zone module; only the caller updates the counters.
1548 * \li 'zone' to be a valid zone.
1550 *\li stats is a valid statistics.
1554 dns_zone_getrequeststats(dns_zone_t *zone);
1556 * Get the additional statistics for zone, if one is installed.
1559 * \li 'zone' to be a valid zone.
1562 * \li when available, a pointer to the statistics set installed in zone;
1567 dns_zone_dialup(dns_zone_t *zone);
1569 * Perform dialup-time maintenance on 'zone'.
1573 dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup);
1575 * Set the dialup type of 'zone' to 'dialup'.
1578 * \li 'zone' to be valid initialised zone.
1579 *\li 'dialup' to be a valid dialup type.
1583 dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...)
1584 ISC_FORMAT_PRINTF(3, 4);
1586 * Log the message 'msg...' at 'level', including text that identifies
1587 * the message as applying to 'zone'.
1591 dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category, int level,
1592 const char *msg, ...) ISC_FORMAT_PRINTF(4, 5);
1594 * Log the message 'msg...' at 'level', including text that identifies
1595 * the message as applying to 'zone'.
1599 dns_zone_name(dns_zone_t *zone, char *buf, size_t len);
1601 * Return the name of the zone with class and view.
1604 *\li 'zone' to be valid.
1605 *\li 'buf' to be non NULL.
1609 dns_zone_checknames(dns_zone_t *zone, dns_name_t *name, dns_rdata_t *rdata);
1611 * Check if this record meets the check-names policy.
1614 * 'zone' to be valid.
1615 * 'name' to be valid.
1616 * 'rdata' to be valid.
1619 * DNS_R_SUCCESS passed checks.
1620 * DNS_R_BADOWNERNAME failed ownername checks.
1621 * DNS_R_BADNAME failed rdata checks.
1625 dns_zone_setacache(dns_zone_t *zone, dns_acache_t *acache);
1627 * Associate the zone with an additional cache.
1630 * 'zone' to be a valid zone.
1631 * 'acache' to be a non NULL pointer.
1634 * 'zone' will have a reference to 'acache'
1638 dns_zone_setcheckmx(dns_zone_t *zone, dns_checkmxfunc_t checkmx);
1640 * Set the post load integrity callback function 'checkmx'.
1641 * 'checkmx' will be called if the MX is not within the zone.
1644 * 'zone' to be a valid zone.
1648 dns_zone_setchecksrv(dns_zone_t *zone, dns_checkmxfunc_t checksrv);
1650 * Set the post load integrity callback function 'checksrv'.
1651 * 'checksrv' will be called if the SRV TARGET is not within the zone.
1654 * 'zone' to be a valid zone.
1658 dns_zone_setcheckns(dns_zone_t *zone, dns_checknsfunc_t checkns);
1660 * Set the post load integrity callback function 'checkmx'.
1661 * 'checkmx' will be called if the MX is not within the zone.
1664 * 'zone' to be a valid zone.
1668 dns_zone_setnotifydelay(dns_zone_t *zone, isc_uint32_t delay);
1670 * Set the minimum delay between sets of notify messages.
1673 * 'zone' to be valid.
1677 dns_zone_getnotifydelay(dns_zone_t *zone);
1679 * Get the minimum delay between sets of notify messages.
1682 * 'zone' to be valid.
1686 dns_zone_setisself(dns_zone_t *zone, dns_isselffunc_t isself, void *arg);
1688 * Set the isself callback function and argument.
1691 * isself(dns_view_t *myview, dns_tsigkey_t *mykey, isc_netaddr_t *srcaddr,
1692 * isc_netaddr_t *destaddr, dns_rdataclass_t rdclass, void *arg);
1694 * 'isself' returns ISC_TRUE if a non-recursive query from 'srcaddr' to
1695 * 'destaddr' with optional key 'mykey' for class 'rdclass' would be
1696 * delivered to 'myview'.
1700 dns_zone_setnodes(dns_zone_t *zone, isc_uint32_t nodes);
1702 * Set the number of nodes that will be checked per quantum.
1706 dns_zone_setsignatures(dns_zone_t *zone, isc_uint32_t signatures);
1708 * Set the number of signatures that will be generated per quantum.
1712 dns_zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm,
1713 isc_uint16_t keyid, isc_boolean_t delete);
1715 * Initiate/resume signing of the entire zone with the zone DNSKEY(s)
1716 * that match the given algorithm and keyid.
1720 dns_zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param);
1722 * Incrementally add a NSEC3 chain that corresponds to 'nsec3param'.
1726 dns_zone_setprivatetype(dns_zone_t *zone, dns_rdatatype_t type);
1728 dns_zone_getprivatetype(dns_zone_t *zone);
1730 * Get/Set the private record type. It is expected that these interfaces
1731 * will not be permanent.
1736 #endif /* DNS_ZONE_H */