2 * Copyright (C) 2004-2012 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.
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>
49 #define DNS_ZONEOPT_SERVERS 0x00000001U /*%< perform server checks */
50 #define DNS_ZONEOPT_PARENTS 0x00000002U /*%< perform parent checks */
51 #define DNS_ZONEOPT_CHILDREN 0x00000004U /*%< perform child checks */
52 #define DNS_ZONEOPT_NOTIFY 0x00000008U /*%< perform NOTIFY */
53 #define DNS_ZONEOPT_MANYERRORS 0x00000010U /*%< return many errors on load */
54 #define DNS_ZONEOPT_IXFRFROMDIFFS 0x00000020U /*%< calculate differences */
55 #define DNS_ZONEOPT_NOMERGE 0x00000040U /*%< don't merge journal */
56 #define DNS_ZONEOPT_CHECKNS 0x00000080U /*%< check if NS's are addresses */
57 #define DNS_ZONEOPT_FATALNS 0x00000100U /*%< DNS_ZONEOPT_CHECKNS is fatal */
58 #define DNS_ZONEOPT_MULTIMASTER 0x00000200U /*%< this zone has multiple masters */
59 #define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /*%< use alternate transfer sources */
60 #define DNS_ZONEOPT_CHECKNAMES 0x00000800U /*%< check-names */
61 #define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /*%< fatal check-name failures */
62 #define DNS_ZONEOPT_CHECKWILDCARD 0x00002000U /*%< check for internal wildcards */
63 #define DNS_ZONEOPT_CHECKMX 0x00004000U /*%< check-mx */
64 #define DNS_ZONEOPT_CHECKMXFAIL 0x00008000U /*%< fatal check-mx failures */
65 #define DNS_ZONEOPT_CHECKINTEGRITY 0x00010000U /*%< perform integrity checks */
66 #define DNS_ZONEOPT_CHECKSIBLING 0x00020000U /*%< perform sibling glue checks */
67 #define DNS_ZONEOPT_NOCHECKNS 0x00040000U /*%< disable IN NS address checks */
68 #define DNS_ZONEOPT_WARNMXCNAME 0x00080000U /*%< warn on MX CNAME check */
69 #define DNS_ZONEOPT_IGNOREMXCNAME 0x00100000U /*%< ignore MX CNAME check */
70 #define DNS_ZONEOPT_WARNSRVCNAME 0x00200000U /*%< warn on SRV CNAME check */
71 #define DNS_ZONEOPT_IGNORESRVCNAME 0x00400000U /*%< ignore SRV CNAME check */
72 #define DNS_ZONEOPT_UPDATECHECKKSK 0x00800000U /*%< check dnskey KSK flag */
73 #define DNS_ZONEOPT_TRYTCPREFRESH 0x01000000U /*%< try tcp refresh on udp failure */
74 #define DNS_ZONEOPT_NOTIFYTOSOA 0x02000000U /*%< Notify the SOA MNAME */
75 #define DNS_ZONEOPT_NSEC3TESTZONE 0x04000000U /*%< nsec3-test-zone */
76 #define DNS_ZONEOPT_SECURETOINSECURE 0x08000000U /*%< dnssec-secure-to-insecure */
77 #define DNS_ZONEOPT_DNSKEYKSKONLY 0x10000000U /*%< dnssec-dnskey-kskonly */
78 #define DNS_ZONEOPT_CHECKDUPRR 0x20000000U /*%< check-dup-records */
79 #define DNS_ZONEOPT_CHECKDUPRRFAIL 0x40000000U /*%< fatal check-dup-records failures */
81 #ifndef NOMINUM_PUBLIC
83 * Nominum specific options build down.
85 #define DNS_ZONEOPT_NOTIFYFORWARD 0x80000000U /* forward notify to master */
86 #endif /* NOMINUM_PUBLIC */
89 * Zone key maintenance options
91 #define DNS_ZONEKEY_ALLOW 0x00000001U /*%< fetch keys on command */
92 #define DNS_ZONEKEY_MAINTAIN 0x00000002U /*%< publish/sign on schedule */
93 #define DNS_ZONEKEY_CREATE 0x00000004U /*%< make keys when needed */
94 #define DNS_ZONEKEY_FULLSIGN 0x00000008U /*%< roll to new keys immediately */
96 #ifndef DNS_ZONE_MINREFRESH
97 #define DNS_ZONE_MINREFRESH 300 /*%< 5 minutes */
99 #ifndef DNS_ZONE_MAXREFRESH
100 #define DNS_ZONE_MAXREFRESH 2419200 /*%< 4 weeks */
102 #ifndef DNS_ZONE_DEFAULTREFRESH
103 #define DNS_ZONE_DEFAULTREFRESH 3600 /*%< 1 hour */
105 #ifndef DNS_ZONE_MINRETRY
106 #define DNS_ZONE_MINRETRY 300 /*%< 5 minutes */
108 #ifndef DNS_ZONE_MAXRETRY
109 #define DNS_ZONE_MAXRETRY 1209600 /*%< 2 weeks */
111 #ifndef DNS_ZONE_DEFAULTRETRY
112 #define DNS_ZONE_DEFAULTRETRY 60 /*%< 1 minute, subject to
113 exponential backoff */
116 #define DNS_ZONESTATE_XFERRUNNING 1
117 #define DNS_ZONESTATE_XFERDEFERRED 2
118 #define DNS_ZONESTATE_SOAQUERY 3
119 #define DNS_ZONESTATE_ANY 4
128 dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx);
130 * Creates a new empty zone and attach '*zonep' to it.
133 *\li 'zonep' to point to a NULL pointer.
134 *\li 'mctx' to be a valid memory context.
137 *\li '*zonep' refers to a valid zone.
142 *\li #ISC_R_UNEXPECTED
146 dns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass);
148 * Sets the class of a zone. This operation can only be performed
152 *\li 'zone' to be a valid zone.
153 *\li dns_zone_setclass() not to have been called since the zone was
155 *\li 'rdclass' != dns_rdataclass_none.
159 dns_zone_getclass(dns_zone_t *zone);
161 * Returns the current zone class.
164 *\li 'zone' to be a valid zone.
168 dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp);
171 dns_zone_getserial(dns_zone_t *zone);
173 * Returns the current serial number of the zone. On success, the SOA
174 * serial of the zone will be copied into '*serialp'.
175 * dns_zone_getserial() cannot catch failure cases and is deprecated by
176 * dns_zone_getserial2().
179 *\li 'zone' to be a valid zone.
180 *\li 'serialp' to be non NULL
184 *\li #DNS_R_NOTLOADED zone DB is not loaded
188 dns_zone_settype(dns_zone_t *zone, dns_zonetype_t type);
190 * Sets the zone type. This operation can only be performed once on
194 *\li 'zone' to be a valid zone.
195 *\li dns_zone_settype() not to have been called since the zone was
197 *\li 'type' != dns_zone_none
201 dns_zone_setview(dns_zone_t *zone, dns_view_t *view);
203 * Associate the zone with a view.
206 *\li 'zone' to be a valid zone.
210 dns_zone_getview(dns_zone_t *zone);
212 * Returns the zone's associated view.
215 *\li 'zone' to be a valid zone.
219 dns_zone_setorigin(dns_zone_t *zone, const dns_name_t *origin);
221 * Sets the zones origin to 'origin'.
224 *\li 'zone' to be a valid zone.
225 *\li 'origin' to be non NULL.
233 dns_zone_getorigin(dns_zone_t *zone);
235 * Returns the value of the origin.
238 *\li 'zone' to be a valid zone.
242 dns_zone_setfile(dns_zone_t *zone, const char *file);
245 dns_zone_setfile2(dns_zone_t *zone, const char *file,
246 dns_masterformat_t format);
248 * Sets the name of the master file in the format of 'format' from which
249 * the zone loads its database to 'file'.
251 * For zones that have no associated master file, 'file' will be NULL.
253 * For zones with persistent databases, the file name
254 * setting is ignored.
256 * dns_zone_setfile() is a backward-compatible form of
257 * dns_zone_setfile2(), which always specifies the
258 * dns_masterformat_text (RFC1035) format.
261 *\li 'zone' to be a valid zone.
269 dns_zone_getfile(dns_zone_t *zone);
271 * Gets the name of the zone's master file, if any.
274 *\li 'zone' to be valid initialised zone.
277 *\li Pointer to null-terminated file name, or NULL.
281 dns_zone_load(dns_zone_t *zone);
284 dns_zone_loadnew(dns_zone_t *zone);
287 dns_zone_loadandthaw(dns_zone_t *zone);
289 * Cause the database to be loaded from its backing store.
290 * Confirm that the minimum requirements for the zone type are
291 * met, otherwise DNS_R_BADZONE is returned.
293 * dns_zone_loadnew() only loads zones that are not yet loaded.
294 * dns_zone_load() also loads zones that are already loaded and
295 * and whose master file has changed since the last load.
296 * dns_zone_loadandthaw() is similar to dns_zone_load() but will
297 * also re-enable DNS UPDATEs when the load completes.
300 *\li 'zone' to be a valid zone.
303 *\li #ISC_R_UNEXPECTED
305 *\li DNS_R_CONTINUE Incremental load has been queued.
306 *\li DNS_R_UPTODATE The zone has already been loaded based on
307 * file system timestamps.
309 *\li Any result value from dns_db_load().
313 dns_zone_attach(dns_zone_t *source, dns_zone_t **target);
315 * Attach '*target' to 'source' incrementing its external
319 *\li 'zone' to be a valid zone.
320 *\li 'target' to be non NULL and '*target' to be NULL.
324 dns_zone_detach(dns_zone_t **zonep);
326 * Detach from a zone decrementing its external reference count.
327 * If this was the last external reference to the zone it will be
328 * shut down and eventually freed.
331 *\li 'zonep' to point to a valid zone.
335 dns_zone_iattach(dns_zone_t *source, dns_zone_t **target);
337 * Attach '*target' to 'source' incrementing its internal
338 * reference count. This is intended for use by operations
339 * such as zone transfers that need to prevent the zone
340 * object from being freed but not from shutting down.
343 *\li The caller is running in the context of the zone's task.
344 *\li 'zone' to be a valid zone.
345 *\li 'target' to be non NULL and '*target' to be NULL.
349 dns_zone_idetach(dns_zone_t **zonep);
351 * Detach from a zone decrementing its internal reference count.
352 * If there are no more internal or external references to the
353 * zone, it will be freed.
356 *\li The caller is running in the context of the zone's task.
357 *\li 'zonep' to point to a valid zone.
361 dns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value);
363 * Sets ('value' == 'ISC_TRUE') / clears ('value' == 'IS_FALSE')
364 * zone flags. Valid flag bits are DNS_ZONE_F_*.
367 *\li 'zone' to be a valid zone.
371 dns_zone_getdb(dns_zone_t *zone, dns_db_t **dbp);
373 * Attach '*dbp' to the database to if it exists otherwise
374 * return DNS_R_NOTLOADED.
377 *\li 'zone' to be a valid zone.
378 *\li 'dbp' to be != NULL && '*dbp' == NULL.
386 dns_zone_setdb(dns_zone_t *zone, dns_db_t *db);
388 * Sets the zone database to 'db'.
390 * This function is expected to be used to configure a zone with a
391 * database which is not loaded from a file or zone transfer.
392 * It can be used for a general purpose zone, but right now its use
393 * is limited to static-stub zones to avoid possible undiscovered
394 * problems in the general cases.
397 *\li 'zone' to be a valid zone of static-stub.
398 *\li zone doesn't have a database.
402 dns_zone_setdbtype(dns_zone_t *zone,
403 unsigned int dbargc, const char * const *dbargv);
405 * Sets the database type to dbargv[0] and database arguments
406 * to subsequent dbargv elements.
407 * 'db_type' is not checked to see if it is a valid database type.
410 *\li 'zone' to be a valid zone.
411 *\li 'database' to be non NULL.
412 *\li 'dbargc' to be >= 1
413 *\li 'dbargv' to point to dbargc NULL-terminated strings
421 dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx);
423 * Returns the current dbtype. isc_mem_free() should be used
424 * to free 'argv' after use.
427 *\li 'zone' to be a valid zone.
428 *\li 'argv' to be non NULL and *argv to be NULL.
429 *\li 'mctx' to be valid.
437 dns_zone_markdirty(dns_zone_t *zone);
439 * Mark a zone as 'dirty'.
442 *\li 'zone' to be a valid zone.
446 dns_zone_expire(dns_zone_t *zone);
448 * Mark the zone as expired. If the zone requires dumping cause it to
449 * be initiated. Set the refresh and retry intervals to there default
450 * values and unload the zone.
453 *\li 'zone' to be a valid zone.
457 dns_zone_refresh(dns_zone_t *zone);
459 * Initiate zone up to date checks. The zone must already be being
463 *\li 'zone' to be a valid zone.
467 dns_zone_flush(dns_zone_t *zone);
469 * Write the zone to database if there are uncommitted changes.
472 *\li 'zone' to be a valid zone.
476 dns_zone_dump(dns_zone_t *zone);
478 * Write the zone to database.
481 *\li 'zone' to be a valid zone.
485 dns_zone_dumptostream(dns_zone_t *zone, FILE *fd);
488 dns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
489 const dns_master_style_t *style);
491 * Write the zone to stream 'fd' in the specified 'format'.
492 * If the 'format' is dns_masterformat_text (RFC1035), 'style' also
493 * specifies the file style (e.g., &dns_master_style_default).
495 * dns_zone_dumptostream() is a backward-compatible form of
496 * dns_zone_dumptostream2(), which always uses the dns_masterformat_text
497 * format and the dns_master_style_default style.
499 * Note that dns_zone_dumptostream2() is the most flexible form. It
500 * can also provide the functionality of dns_zone_fulldumptostream().
503 *\li 'zone' to be a valid zone.
504 *\li 'fd' to be a stream open for writing.
508 dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd);
510 * The same as dns_zone_dumptostream, but dumps the zone with
511 * different dump settings (dns_master_style_full).
514 *\li 'zone' to be a valid zone.
515 *\li 'fd' to be a stream open for writing.
519 dns_zone_maintenance(dns_zone_t *zone);
521 * Perform regular maintenance on the zone. This is called as a
522 * result of a zone being managed.
525 *\li 'zone' to be a valid zone.
529 dns_zone_setmasters(dns_zone_t *zone, const isc_sockaddr_t *masters,
532 dns_zone_setmasterswithkeys(dns_zone_t *zone,
533 const isc_sockaddr_t *masters,
534 dns_name_t **keynames,
537 * Set the list of master servers for the zone.
540 *\li 'zone' to be a valid zone.
541 *\li 'masters' array of isc_sockaddr_t with port set or NULL.
542 *\li 'count' the number of masters.
543 *\li 'keynames' array of dns_name_t's for tsig keys or NULL.
545 * \li dns_zone_setmasters() is just a wrapper to setmasterswithkeys(),
546 * passing NULL in the keynames field.
548 * \li If 'masters' is NULL then 'count' must be zero.
553 *\li Any result dns_name_dup() can return, if keynames!=NULL
557 dns_zone_setalsonotify(dns_zone_t *zone, const isc_sockaddr_t *notify,
560 * Set the list of additional servers to be notified when
561 * a zone changes. To clear the list use 'count = 0'.
564 *\li 'zone' to be a valid zone.
565 *\li 'notify' to be non-NULL if count != 0.
566 *\li 'count' to be the number of notifiees.
574 dns_zone_unload(dns_zone_t *zone);
576 * detach the database from the zone structure.
579 *\li 'zone' to be a valid zone.
583 dns_zone_setoption(dns_zone_t *zone, unsigned int option, isc_boolean_t value);
585 * Set given options on ('value' == ISC_TRUE) or off ('value' ==
589 *\li 'zone' to be a valid zone.
593 dns_zone_getoptions(dns_zone_t *zone);
595 * Returns the current zone options.
598 *\li 'zone' to be a valid zone.
602 dns_zone_setkeyopt(dns_zone_t *zone, unsigned int option, isc_boolean_t value);
604 * Set key options on ('value' == ISC_TRUE) or off ('value' ==
608 *\li 'zone' to be a valid zone.
612 dns_zone_getkeyopts(dns_zone_t *zone);
614 * Returns the current zone key options.
617 *\li 'zone' to be a valid zone.
621 dns_zone_setminrefreshtime(dns_zone_t *zone, isc_uint32_t val);
623 * Set the minimum refresh time.
626 *\li 'zone' is valid.
631 dns_zone_setmaxrefreshtime(dns_zone_t *zone, isc_uint32_t val);
633 * Set the maximum refresh time.
636 *\li 'zone' is valid.
641 dns_zone_setminretrytime(dns_zone_t *zone, isc_uint32_t val);
643 * Set the minimum retry time.
646 *\li 'zone' is valid.
651 dns_zone_setmaxretrytime(dns_zone_t *zone, isc_uint32_t val);
653 * Set the maximum retry time.
656 *\li 'zone' is valid.
661 dns_zone_setxfrsource4(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
663 dns_zone_setaltxfrsource4(dns_zone_t *zone,
664 const isc_sockaddr_t *xfrsource);
666 * Set the source address to be used in IPv4 zone transfers.
669 *\li 'zone' to be a valid zone.
670 *\li 'xfrsource' to contain the address.
677 dns_zone_getxfrsource4(dns_zone_t *zone);
679 dns_zone_getaltxfrsource4(dns_zone_t *zone);
681 * Returns the source address set by a previous dns_zone_setxfrsource4
682 * call, or the default of inaddr_any, port 0.
685 *\li 'zone' to be a valid zone.
689 dns_zone_setxfrsource6(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
691 dns_zone_setaltxfrsource6(dns_zone_t *zone,
692 const isc_sockaddr_t *xfrsource);
694 * Set the source address to be used in IPv6 zone transfers.
697 *\li 'zone' to be a valid zone.
698 *\li 'xfrsource' to contain the address.
705 dns_zone_getxfrsource6(dns_zone_t *zone);
707 dns_zone_getaltxfrsource6(dns_zone_t *zone);
709 * Returns the source address set by a previous dns_zone_setxfrsource6
710 * call, or the default of in6addr_any, port 0.
713 *\li 'zone' to be a valid zone.
717 dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
719 * Set the source address to be used with IPv4 NOTIFY messages.
722 *\li 'zone' to be a valid zone.
723 *\li 'notifysrc' to contain the address.
730 dns_zone_getnotifysrc4(dns_zone_t *zone);
732 * Returns the source address set by a previous dns_zone_setnotifysrc4
733 * call, or the default of inaddr_any, port 0.
736 *\li 'zone' to be a valid zone.
740 dns_zone_setnotifysrc6(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
742 * Set the source address to be used with IPv6 NOTIFY messages.
745 *\li 'zone' to be a valid zone.
746 *\li 'notifysrc' to contain the address.
753 dns_zone_getnotifysrc6(dns_zone_t *zone);
755 * Returns the source address set by a previous dns_zone_setnotifysrc6
756 * call, or the default of in6addr_any, port 0.
759 *\li 'zone' to be a valid zone.
763 dns_zone_setnotifyacl(dns_zone_t *zone, dns_acl_t *acl);
765 * Sets the notify acl list for the zone.
768 *\li 'zone' to be a valid zone.
769 *\li 'acl' to be a valid acl.
773 dns_zone_setqueryacl(dns_zone_t *zone, dns_acl_t *acl);
775 * Sets the query acl list for the zone.
778 *\li 'zone' to be a valid zone.
779 *\li 'acl' to be a valid acl.
783 dns_zone_setqueryonacl(dns_zone_t *zone, dns_acl_t *acl);
785 * Sets the query-on acl list for the zone.
788 *\li 'zone' to be a valid zone.
789 *\li 'acl' to be a valid acl.
793 dns_zone_setupdateacl(dns_zone_t *zone, dns_acl_t *acl);
795 * Sets the update acl list for the zone.
798 *\li 'zone' to be a valid zone.
799 *\li 'acl' to be valid acl.
803 dns_zone_setforwardacl(dns_zone_t *zone, dns_acl_t *acl);
805 * Sets the forward unsigned updates acl list for the zone.
808 *\li 'zone' to be a valid zone.
809 *\li 'acl' to be valid acl.
813 dns_zone_setxfracl(dns_zone_t *zone, dns_acl_t *acl);
815 * Sets the transfer acl list for the zone.
818 *\li 'zone' to be a valid zone.
819 *\li 'acl' to be valid acl.
823 dns_zone_getnotifyacl(dns_zone_t *zone);
825 * Returns the current notify acl or NULL.
828 *\li 'zone' to be a valid zone.
831 *\li acl a pointer to the acl.
836 dns_zone_getqueryacl(dns_zone_t *zone);
838 * Returns the current query acl or NULL.
841 *\li 'zone' to be a valid zone.
844 *\li acl a pointer to the acl.
849 dns_zone_getqueryonacl(dns_zone_t *zone);
851 * Returns the current query-on acl or NULL.
854 *\li 'zone' to be a valid zone.
857 *\li acl a pointer to the acl.
862 dns_zone_getupdateacl(dns_zone_t *zone);
864 * Returns the current update acl or NULL.
867 *\li 'zone' to be a valid zone.
870 *\li acl a pointer to the acl.
875 dns_zone_getforwardacl(dns_zone_t *zone);
877 * Returns the current forward unsigned updates acl or NULL.
880 *\li 'zone' to be a valid zone.
883 *\li acl a pointer to the acl.
888 dns_zone_getxfracl(dns_zone_t *zone);
890 * Returns the current transfer acl or NULL.
893 *\li 'zone' to be a valid zone.
896 *\li acl a pointer to the acl.
901 dns_zone_clearupdateacl(dns_zone_t *zone);
903 * Clear the current update acl.
906 *\li 'zone' to be a valid zone.
910 dns_zone_clearforwardacl(dns_zone_t *zone);
912 * Clear the current forward unsigned updates acl.
915 *\li 'zone' to be a valid zone.
919 dns_zone_clearnotifyacl(dns_zone_t *zone);
921 * Clear the current notify acl.
924 *\li 'zone' to be a valid zone.
928 dns_zone_clearqueryacl(dns_zone_t *zone);
930 * Clear the current query acl.
933 *\li 'zone' to be a valid zone.
937 dns_zone_clearqueryonacl(dns_zone_t *zone);
939 * Clear the current query-on acl.
942 *\li 'zone' to be a valid zone.
946 dns_zone_clearxfracl(dns_zone_t *zone);
948 * Clear the current transfer acl.
951 *\li 'zone' to be a valid zone.
955 dns_zone_getupdatedisabled(dns_zone_t *zone);
957 * Return update disabled.
958 * Transient unless called when running in isc_task_exclusive() mode.
962 dns_zone_setupdatedisabled(dns_zone_t *zone, isc_boolean_t state);
964 * Set update disabled.
965 * Should only be called only when running in isc_task_exclusive() mode.
966 * Failure to do so may result in updates being committed after the
967 * call has been made.
971 dns_zone_getzeronosoattl(dns_zone_t *zone);
973 * Return zero-no-soa-ttl status.
977 dns_zone_setzeronosoattl(dns_zone_t *zone, isc_boolean_t state);
979 * Set zero-no-soa-ttl status.
983 dns_zone_setchecknames(dns_zone_t *zone, dns_severity_t severity);
985 * Set the severity of name checking when loading a zone.
988 * \li 'zone' to be a valid zone.
992 dns_zone_getchecknames(dns_zone_t *zone);
994 * Return the current severity of name checking.
997 *\li 'zone' to be a valid zone.
1001 dns_zone_setjournalsize(dns_zone_t *zone, isc_int32_t size);
1003 * Sets the journal size for the zone.
1006 *\li 'zone' to be a valid zone.
1010 dns_zone_getjournalsize(dns_zone_t *zone);
1012 * Return the journal size as set with a previous call to
1013 * dns_zone_setjournalsize().
1016 *\li 'zone' to be a valid zone.
1020 dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
1021 dns_message_t *msg);
1023 * Tell the zone that it has received a NOTIFY message from another
1024 * server. This may cause some zone maintenance activity to occur.
1027 *\li 'zone' to be a valid zone.
1028 *\li '*from' to contain the address of the server from which 'msg'
1030 *\li 'msg' a message with opcode NOTIFY and qr clear.
1040 dns_zone_setmaxxfrin(dns_zone_t *zone, isc_uint32_t maxxfrin);
1042 * Set the maximum time (in seconds) that a zone transfer in (AXFR/IXFR)
1043 * of this zone will use before being aborted.
1046 * \li 'zone' to be valid initialised zone.
1050 dns_zone_getmaxxfrin(dns_zone_t *zone);
1052 * Returns the maximum transfer time for this zone. This will be
1053 * either the value set by the last call to dns_zone_setmaxxfrin() or
1054 * the default value of 1 hour.
1057 *\li 'zone' to be valid initialised zone.
1061 dns_zone_setmaxxfrout(dns_zone_t *zone, isc_uint32_t maxxfrout);
1063 * Set the maximum time (in seconds) that a zone transfer out (AXFR/IXFR)
1064 * of this zone will use before being aborted.
1067 * \li 'zone' to be valid initialised zone.
1071 dns_zone_getmaxxfrout(dns_zone_t *zone);
1073 * Returns the maximum transfer time for this zone. This will be
1074 * either the value set by the last call to dns_zone_setmaxxfrout() or
1075 * the default value of 1 hour.
1078 *\li 'zone' to be valid initialised zone.
1082 dns_zone_setjournal(dns_zone_t *zone, const char *journal);
1084 * Sets the filename used for journaling updates / IXFR transfers.
1085 * The default journal name is set by dns_zone_setfile() to be
1086 * "file.jnl". If 'journal' is NULL, the zone will have no
1090 *\li 'zone' to be a valid zone.
1094 *\li #ISC_R_NOMEMORY
1098 dns_zone_getjournal(dns_zone_t *zone);
1100 * Returns the journal name associated with this zone.
1101 * If no journal has been set this will be NULL.
1104 *\li 'zone' to be valid initialised zone.
1108 dns_zone_gettype(dns_zone_t *zone);
1110 * Returns the type of the zone (master/slave/etc.)
1113 *\li 'zone' to be valid initialised zone.
1117 dns_zone_settask(dns_zone_t *zone, isc_task_t *task);
1119 * Give a zone a task to work with. Any current task will be detached.
1122 *\li 'zone' to be valid.
1123 *\li 'task' to be valid.
1127 dns_zone_gettask(dns_zone_t *zone, isc_task_t **target);
1129 * Attach '*target' to the zone's task.
1132 *\li 'zone' to be valid initialised zone.
1133 *\li 'zone' to have a task.
1134 *\li 'target' to be != NULL && '*target' == NULL.
1138 dns_zone_notify(dns_zone_t *zone);
1140 * Generate notify events for this zone.
1143 *\li 'zone' to be a valid zone.
1147 dns_zone_replacedb(dns_zone_t *zone, dns_db_t *db, isc_boolean_t dump);
1149 * Replace the database of "zone" with a new database "db".
1151 * If "dump" is ISC_TRUE, then the new zone contents are dumped
1152 * into to the zone's master file for persistence. When replacing
1153 * a zone database by one just loaded from a master file, set
1154 * "dump" to ISC_FALSE to avoid a redundant redump of the data just
1155 * loaded. Otherwise, it should be set to ISC_TRUE.
1157 * If the "diff-on-reload" option is enabled in the configuration file,
1158 * the differences between the old and the new database are added to the
1159 * journal file, and the master file dump is postponed.
1162 * \li 'zone' to be a valid zone.
1166 * \li DNS_R_BADZONE zone failed basic consistency checks:
1167 * * a single SOA must exist
1168 * * some NS records must exist.
1173 dns_zone_getidlein(dns_zone_t *zone);
1176 * \li 'zone' to be a valid zone.
1179 * \li number of seconds of idle time before we abort the transfer in.
1183 dns_zone_setidlein(dns_zone_t *zone, isc_uint32_t idlein);
1185 * \li Set the idle timeout for transfer the.
1186 * \li Zero set the default value, 1 hour.
1189 * \li 'zone' to be a valid zone.
1193 dns_zone_getidleout(dns_zone_t *zone);
1197 * \li 'zone' to be a valid zone.
1200 * \li number of seconds of idle time before we abort a transfer out.
1204 dns_zone_setidleout(dns_zone_t *zone, isc_uint32_t idleout);
1206 * \li Set the idle timeout for transfers out.
1207 * \li Zero set the default value, 1 hour.
1210 * \li 'zone' to be a valid zone.
1214 dns_zone_getssutable(dns_zone_t *zone, dns_ssutable_t **table);
1216 * Get the simple-secure-update policy table.
1219 * \li 'zone' to be a valid zone.
1223 dns_zone_setssutable(dns_zone_t *zone, dns_ssutable_t *table);
1225 * Set / clear the simple-secure-update policy table.
1228 * \li 'zone' to be a valid zone.
1232 dns_zone_getmctx(dns_zone_t *zone);
1234 * Get the memory context of a zone.
1237 * \li 'zone' to be a valid zone.
1241 dns_zone_getmgr(dns_zone_t *zone);
1243 * If 'zone' is managed return the zone manager otherwise NULL.
1246 * \li 'zone' to be a valid zone.
1250 dns_zone_setsigvalidityinterval(dns_zone_t *zone, isc_uint32_t interval);
1252 * Set the zone's RRSIG validity interval. This is the length of time
1253 * for which DNSSEC signatures created as a result of dynamic updates
1254 * to secure zones will remain valid, in seconds.
1257 * \li 'zone' to be a valid zone.
1261 dns_zone_getsigvalidityinterval(dns_zone_t *zone);
1263 * Get the zone's RRSIG validity interval.
1266 * \li 'zone' to be a valid zone.
1270 dns_zone_setsigresigninginterval(dns_zone_t *zone, isc_uint32_t interval);
1272 * Set the zone's RRSIG re-signing interval. A dynamic zone's RRSIG's
1273 * will be re-signed 'interval' amount of time before they expire.
1276 * \li 'zone' to be a valid zone.
1280 dns_zone_getsigresigninginterval(dns_zone_t *zone);
1282 * Get the zone's RRSIG re-signing interval.
1285 * \li 'zone' to be a valid zone.
1289 dns_zone_setnotifytype(dns_zone_t *zone, dns_notifytype_t notifytype);
1291 * Sets zone notify method to "notifytype"
1295 dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
1296 dns_updatecallback_t callback, void *callback_arg);
1298 * Forward 'msg' to each master in turn until we get an answer or we
1299 * have exhausted the list of masters. 'callback' will be called with
1300 * ISC_R_SUCCESS if we get an answer and the returned message will be
1301 * passed as 'answer_message', otherwise a non ISC_R_SUCCESS result code
1302 * will be passed and answer_message will be NULL. The callback function
1303 * is responsible for destroying 'answer_message'.
1304 * (callback)(callback_arg, result, answer_message);
1307 *\li 'zone' to be valid
1308 *\li 'msg' to be valid.
1309 *\li 'callback' to be non NULL.
1311 *\li #ISC_R_SUCCESS if the message has been forwarded,
1312 *\li #ISC_R_NOMEMORY
1317 dns_zone_next(dns_zone_t *zone, dns_zone_t **next);
1319 * Find the next zone in the list of managed zones.
1322 *\li 'zone' to be valid
1323 *\li The zone manager for the indicated zone MUST be locked
1324 * by the caller. This is not checked.
1325 *\li 'next' be non-NULL, and '*next' be NULL.
1328 *\li 'next' points to a valid zone (result ISC_R_SUCCESS) or to NULL
1329 * (result ISC_R_NOMORE).
1335 dns_zone_first(dns_zonemgr_t *zmgr, dns_zone_t **first);
1337 * Find the first zone in the list of managed zones.
1340 *\li 'zonemgr' to be valid
1341 *\li The zone manager for the indicated zone MUST be locked
1342 * by the caller. This is not checked.
1343 *\li 'first' be non-NULL, and '*first' be NULL
1346 *\li 'first' points to a valid zone (result ISC_R_SUCCESS) or to NULL
1347 * (result ISC_R_NOMORE).
1351 dns_zone_setkeydirectory(dns_zone_t *zone, const char *directory);
1353 * Sets the name of the directory where private keys used for
1354 * online signing of dynamic zones are found.
1357 *\li 'zone' to be a valid zone.
1360 *\li #ISC_R_NOMEMORY
1365 dns_zone_getkeydirectory(dns_zone_t *zone);
1367 * Gets the name of the directory where private keys used for
1368 * online signing of dynamic zones are found.
1371 *\li 'zone' to be valid initialised zone.
1374 * Pointer to null-terminated file name, or NULL.
1379 dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
1380 isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr,
1381 dns_zonemgr_t **zmgrp);
1383 * Create a zone manager. Note: the zone manager will not be able to
1384 * manage any zones until dns_zonemgr_setsize() has been run.
1387 *\li 'mctx' to be a valid memory context.
1388 *\li 'taskmgr' to be a valid task manager.
1389 *\li 'timermgr' to be a valid timer manager.
1390 *\li 'zmgrp' to point to a NULL pointer.
1394 dns_zonemgr_setsize(dns_zonemgr_t *zmgr, int num_zones);
1396 * Set the size of the zone manager task pool. This must be run
1397 * before zmgr can be used for managing zones. Currently, it can only
1398 * be run once; the task pool cannot be resized.
1401 *\li zmgr is a valid zone manager.
1402 *\li zmgr->zonetasks has been initialized.
1406 dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
1408 * Bring the zone under control of a zone manager.
1411 *\li 'zmgr' to be a valid zone manager.
1412 *\li 'zone' to be a valid zone.
1416 dns_zonemgr_forcemaint(dns_zonemgr_t *zmgr);
1418 * Force zone maintenance of all zones managed by 'zmgr' at its
1419 * earliest convenience.
1423 dns_zonemgr_resumexfrs(dns_zonemgr_t *zmgr);
1425 * Attempt to start any stalled zone transfers.
1429 dns_zonemgr_shutdown(dns_zonemgr_t *zmgr);
1431 * Shut down the zone manager.
1434 *\li 'zmgr' to be a valid zone manager.
1438 dns_zonemgr_attach(dns_zonemgr_t *source, dns_zonemgr_t **target);
1440 * Attach '*target' to 'source' incrementing its external
1444 *\li 'zone' to be a valid zone.
1445 *\li 'target' to be non NULL and '*target' to be NULL.
1449 dns_zonemgr_detach(dns_zonemgr_t **zmgrp);
1451 * Detach from a zone manager.
1454 *\li '*zmgrp' is a valid, non-NULL zone manager pointer.
1457 *\li '*zmgrp' is NULL.
1461 dns_zonemgr_releasezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
1463 * Release 'zone' from the managed by 'zmgr'. 'zmgr' is implicitly
1464 * detached from 'zone'.
1467 *\li 'zmgr' to be a valid zone manager.
1468 *\li 'zone' to be a valid zone.
1469 *\li 'zmgr' == 'zone->zmgr'
1472 *\li 'zone->zmgr' == NULL;
1476 dns_zonemgr_settransfersin(dns_zonemgr_t *zmgr, isc_uint32_t value);
1478 * Set the maximum number of simultaneous transfers in allowed by
1482 *\li 'zmgr' to be a valid zone manager.
1486 dns_zonemgr_getttransfersin(dns_zonemgr_t *zmgr);
1488 * Return the maximum number of simultaneous transfers in allowed.
1491 *\li 'zmgr' to be a valid zone manager.
1495 dns_zonemgr_settransfersperns(dns_zonemgr_t *zmgr, isc_uint32_t value);
1497 * Set the number of zone transfers allowed per nameserver.
1500 *\li 'zmgr' to be a valid zone manager
1504 dns_zonemgr_getttransfersperns(dns_zonemgr_t *zmgr);
1506 * Return the number of transfers allowed per nameserver.
1509 *\li 'zmgr' to be a valid zone manager.
1513 dns_zonemgr_setiolimit(dns_zonemgr_t *zmgr, isc_uint32_t iolimit);
1515 * Set the number of simultaneous file descriptors available for
1516 * reading and writing masterfiles.
1519 *\li 'zmgr' to be a valid zone manager.
1520 *\li 'iolimit' to be positive.
1524 dns_zonemgr_getiolimit(dns_zonemgr_t *zmgr);
1526 * Get the number of simultaneous file descriptors available for
1527 * reading and writing masterfiles.
1530 *\li 'zmgr' to be a valid zone manager.
1534 dns_zonemgr_setserialqueryrate(dns_zonemgr_t *zmgr, unsigned int value);
1536 * Set the number of SOA queries sent per second.
1539 *\li 'zmgr' to be a valid zone manager
1543 dns_zonemgr_getserialqueryrate(dns_zonemgr_t *zmgr);
1545 * Return the number of SOA queries sent per second.
1548 *\li 'zmgr' to be a valid zone manager.
1552 dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state);
1554 * Returns the number of zones in the specified state.
1557 *\li 'zmgr' to be a valid zone manager.
1558 *\li 'state' to be a valid DNS_ZONESTATE_ constant.
1562 dns_zonemgr_unreachableadd(dns_zonemgr_t *zmgr, isc_sockaddr_t *remote,
1563 isc_sockaddr_t *local, isc_time_t *now);
1565 * Add the pair of addresses to the unreachable cache.
1568 *\li 'zmgr' to be a valid zone manager.
1569 *\li 'remote' to be a valid sockaddr.
1570 *\li 'local' to be a valid sockaddr.
1574 dns_zonemgr_unreachable(dns_zonemgr_t *zmgr, isc_sockaddr_t *remote,
1575 isc_sockaddr_t *local, isc_time_t *now);
1577 * Returns ISC_TRUE if the given local/remote address pair
1578 * is found in the zone maanger's unreachable cache.
1581 *\li 'zmgr' to be a valid zone manager.
1582 *\li 'remote' to be a valid sockaddr.
1583 *\li 'local' to be a valid sockaddr.
1588 dns_zonemgr_unreachabledel(dns_zonemgr_t *zmgr, isc_sockaddr_t *remote,
1589 isc_sockaddr_t *local);
1591 * Remove the pair of addresses from the unreachable cache.
1594 *\li 'zmgr' to be a valid zone manager.
1595 *\li 'remote' to be a valid sockaddr.
1596 *\li 'local' to be a valid sockaddr.
1600 dns_zone_forcereload(dns_zone_t *zone);
1602 * Force a reload of specified zone.
1605 *\li 'zone' to be a valid zone.
1609 dns_zone_isforced(dns_zone_t *zone);
1611 * Check if the zone is waiting a forced reload.
1614 * \li 'zone' to be a valid zone.
1618 dns_zone_setstatistics(dns_zone_t *zone, isc_boolean_t on);
1620 * This function is obsoleted by dns_zone_setrequeststats().
1624 dns_zone_getstatscounters(dns_zone_t *zone);
1626 * This function is obsoleted by dns_zone_getrequeststats().
1630 dns_zone_setstats(dns_zone_t *zone, isc_stats_t *stats);
1632 * Set a general zone-maintenance statistics set 'stats' for 'zone'. This
1633 * function is expected to be called only on zone creation (when necessary).
1634 * Once installed, it cannot be removed or replaced. Also, there is no
1635 * interface to get the installed stats from the zone; the caller must keep the
1636 * stats to reference (e.g. dump) it later.
1639 * \li 'zone' to be a valid zone and does not have a statistics set already
1642 *\li stats is a valid statistics supporting zone statistics counters
1643 * (see dns/stats.h).
1647 dns_zone_setrequeststats(dns_zone_t *zone, isc_stats_t *stats);
1649 * Set an additional statistics set to zone. It is attached in the zone
1650 * but is not counted in the zone module; only the caller updates the counters.
1653 * \li 'zone' to be a valid zone.
1655 *\li stats is a valid statistics.
1659 dns_zone_getrequeststats(dns_zone_t *zone);
1661 * Get the additional statistics for zone, if one is installed.
1664 * \li 'zone' to be a valid zone.
1667 * \li when available, a pointer to the statistics set installed in zone;
1672 dns_zone_dialup(dns_zone_t *zone);
1674 * Perform dialup-time maintenance on 'zone'.
1678 dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup);
1680 * Set the dialup type of 'zone' to 'dialup'.
1683 * \li 'zone' to be valid initialised zone.
1684 *\li 'dialup' to be a valid dialup type.
1688 dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...)
1689 ISC_FORMAT_PRINTF(3, 4);
1691 * Log the message 'msg...' at 'level', including text that identifies
1692 * the message as applying to 'zone'.
1696 dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category, int level,
1697 const char *msg, ...) ISC_FORMAT_PRINTF(4, 5);
1699 * Log the message 'msg...' at 'level', including text that identifies
1700 * the message as applying to 'zone'.
1704 dns_zone_name(dns_zone_t *zone, char *buf, size_t len);
1706 * Return the name of the zone with class and view.
1709 *\li 'zone' to be valid.
1710 *\li 'buf' to be non NULL.
1714 dns_zone_checknames(dns_zone_t *zone, dns_name_t *name, dns_rdata_t *rdata);
1716 * Check if this record meets the check-names policy.
1719 * 'zone' to be valid.
1720 * 'name' to be valid.
1721 * 'rdata' to be valid.
1724 * DNS_R_SUCCESS passed checks.
1725 * DNS_R_BADOWNERNAME failed ownername checks.
1726 * DNS_R_BADNAME failed rdata checks.
1730 dns_zone_setacache(dns_zone_t *zone, dns_acache_t *acache);
1732 * Associate the zone with an additional cache.
1735 * 'zone' to be a valid zone.
1736 * 'acache' to be a non NULL pointer.
1739 * 'zone' will have a reference to 'acache'
1743 dns_zone_setcheckmx(dns_zone_t *zone, dns_checkmxfunc_t checkmx);
1745 * Set the post load integrity callback function 'checkmx'.
1746 * 'checkmx' will be called if the MX TARGET is not within the zone.
1749 * 'zone' to be a valid zone.
1753 dns_zone_setchecksrv(dns_zone_t *zone, dns_checkmxfunc_t checksrv);
1755 * Set the post load integrity callback function 'checksrv'.
1756 * 'checksrv' will be called if the SRV TARGET is not within the zone.
1759 * 'zone' to be a valid zone.
1763 dns_zone_setcheckns(dns_zone_t *zone, dns_checknsfunc_t checkns);
1765 * Set the post load integrity callback function 'checkns'.
1766 * 'checkns' will be called if the NS TARGET is not within the zone.
1769 * 'zone' to be a valid zone.
1773 dns_zone_setnotifydelay(dns_zone_t *zone, isc_uint32_t delay);
1775 * Set the minimum delay between sets of notify messages.
1778 * 'zone' to be valid.
1782 dns_zone_getnotifydelay(dns_zone_t *zone);
1784 * Get the minimum delay between sets of notify messages.
1787 * 'zone' to be valid.
1791 dns_zone_setisself(dns_zone_t *zone, dns_isselffunc_t isself, void *arg);
1793 * Set the isself callback function and argument.
1796 * isself(dns_view_t *myview, dns_tsigkey_t *mykey, isc_netaddr_t *srcaddr,
1797 * isc_netaddr_t *destaddr, dns_rdataclass_t rdclass, void *arg);
1799 * 'isself' returns ISC_TRUE if a non-recursive query from 'srcaddr' to
1800 * 'destaddr' with optional key 'mykey' for class 'rdclass' would be
1801 * delivered to 'myview'.
1805 dns_zone_setnodes(dns_zone_t *zone, isc_uint32_t nodes);
1807 * Set the number of nodes that will be checked per quantum.
1811 dns_zone_setsignatures(dns_zone_t *zone, isc_uint32_t signatures);
1813 * Set the number of signatures that will be generated per quantum.
1817 dns_zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm,
1818 isc_uint16_t keyid, isc_boolean_t deleteit);
1820 * Initiate/resume signing of the entire zone with the zone DNSKEY(s)
1821 * that match the given algorithm and keyid.
1825 dns_zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param);
1827 * Incrementally add a NSEC3 chain that corresponds to 'nsec3param'.
1831 dns_zone_setprivatetype(dns_zone_t *zone, dns_rdatatype_t type);
1833 dns_zone_getprivatetype(dns_zone_t *zone);
1835 * Get/Set the private record type. It is expected that these interfaces
1836 * will not be permanent.
1840 dns_zone_rekey(dns_zone_t *zone, isc_boolean_t fullsign);
1842 * Update the zone's DNSKEY set from the key repository.
1844 * If 'fullsign' is true, trigger an immediate full signing of
1845 * the zone with the new key. Otherwise, if there are no keys or
1846 * if the new keys are for algorithms that have already signed the
1847 * zone, then the zone can be re-signed incrementally.
1851 dns_zone_nscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version,
1852 unsigned int *errors);
1854 * Check if the name servers for the zone are sane (have address, don't
1855 * refer to CNAMEs/DNAMEs. The number of constiancy errors detected in
1856 * returned in '*errors'
1859 * \li 'zone' to be valid.
1860 * \li 'db' to be valid.
1861 * \li 'version' to be valid or NULL.
1862 * \li 'errors' to be non NULL.
1865 * ISC_R_SUCCESS if there were no errors examining the zone contents.
1869 dns_zone_setadded(dns_zone_t *zone, isc_boolean_t added);
1871 * Sets the value of zone->added, which should be ISC_TRUE for
1872 * zones that were originally added by "rndc addzone".
1875 * \li 'zone' to be valid.
1879 dns_zone_getadded(dns_zone_t *zone);
1881 * Returns ISC_TRUE if the zone was originally added at runtime
1882 * using "rndc addzone".
1885 * \li 'zone' to be valid.
1889 dns_zone_dlzpostload(dns_zone_t *zone, dns_db_t *db);
1891 * Load the origin names for a writeable DLZ database.
1895 dns_zone_synckeyzone(dns_zone_t *zone);
1897 * Force the managed key zone to synchronize, and start the key
1898 * maintenance timer.
1903 #endif /* DNS_ZONE_H */