/contrib/bind9/lib/dns/include/dns/zone.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 1903 lines · 436 code · 181 blank · 1286 comment · 0 complexity · 0020730989caf10490b696c49f240f5c MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 1999-2003 Internet Software Consortium.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. * PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /* $Id$ */
  18. #ifndef DNS_ZONE_H
  19. #define DNS_ZONE_H 1
  20. /*! \file dns/zone.h */
  21. /***
  22. *** Imports
  23. ***/
  24. #include <stdio.h>
  25. #include <isc/formatcheck.h>
  26. #include <isc/lang.h>
  27. #include <isc/rwlock.h>
  28. #include <dns/masterdump.h>
  29. #include <dns/rdatastruct.h>
  30. #include <dns/types.h>
  31. typedef enum {
  32. dns_zone_none,
  33. dns_zone_master,
  34. dns_zone_slave,
  35. dns_zone_stub,
  36. dns_zone_staticstub,
  37. dns_zone_key,
  38. dns_zone_dlz
  39. } dns_zonetype_t;
  40. #define DNS_ZONEOPT_SERVERS 0x00000001U /*%< perform server checks */
  41. #define DNS_ZONEOPT_PARENTS 0x00000002U /*%< perform parent checks */
  42. #define DNS_ZONEOPT_CHILDREN 0x00000004U /*%< perform child checks */
  43. #define DNS_ZONEOPT_NOTIFY 0x00000008U /*%< perform NOTIFY */
  44. #define DNS_ZONEOPT_MANYERRORS 0x00000010U /*%< return many errors on load */
  45. #define DNS_ZONEOPT_IXFRFROMDIFFS 0x00000020U /*%< calculate differences */
  46. #define DNS_ZONEOPT_NOMERGE 0x00000040U /*%< don't merge journal */
  47. #define DNS_ZONEOPT_CHECKNS 0x00000080U /*%< check if NS's are addresses */
  48. #define DNS_ZONEOPT_FATALNS 0x00000100U /*%< DNS_ZONEOPT_CHECKNS is fatal */
  49. #define DNS_ZONEOPT_MULTIMASTER 0x00000200U /*%< this zone has multiple masters */
  50. #define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /*%< use alternate transfer sources */
  51. #define DNS_ZONEOPT_CHECKNAMES 0x00000800U /*%< check-names */
  52. #define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /*%< fatal check-name failures */
  53. #define DNS_ZONEOPT_CHECKWILDCARD 0x00002000U /*%< check for internal wildcards */
  54. #define DNS_ZONEOPT_CHECKMX 0x00004000U /*%< check-mx */
  55. #define DNS_ZONEOPT_CHECKMXFAIL 0x00008000U /*%< fatal check-mx failures */
  56. #define DNS_ZONEOPT_CHECKINTEGRITY 0x00010000U /*%< perform integrity checks */
  57. #define DNS_ZONEOPT_CHECKSIBLING 0x00020000U /*%< perform sibling glue checks */
  58. #define DNS_ZONEOPT_NOCHECKNS 0x00040000U /*%< disable IN NS address checks */
  59. #define DNS_ZONEOPT_WARNMXCNAME 0x00080000U /*%< warn on MX CNAME check */
  60. #define DNS_ZONEOPT_IGNOREMXCNAME 0x00100000U /*%< ignore MX CNAME check */
  61. #define DNS_ZONEOPT_WARNSRVCNAME 0x00200000U /*%< warn on SRV CNAME check */
  62. #define DNS_ZONEOPT_IGNORESRVCNAME 0x00400000U /*%< ignore SRV CNAME check */
  63. #define DNS_ZONEOPT_UPDATECHECKKSK 0x00800000U /*%< check dnskey KSK flag */
  64. #define DNS_ZONEOPT_TRYTCPREFRESH 0x01000000U /*%< try tcp refresh on udp failure */
  65. #define DNS_ZONEOPT_NOTIFYTOSOA 0x02000000U /*%< Notify the SOA MNAME */
  66. #define DNS_ZONEOPT_NSEC3TESTZONE 0x04000000U /*%< nsec3-test-zone */
  67. #define DNS_ZONEOPT_SECURETOINSECURE 0x08000000U /*%< dnssec-secure-to-insecure */
  68. #define DNS_ZONEOPT_DNSKEYKSKONLY 0x10000000U /*%< dnssec-dnskey-kskonly */
  69. #define DNS_ZONEOPT_CHECKDUPRR 0x20000000U /*%< check-dup-records */
  70. #define DNS_ZONEOPT_CHECKDUPRRFAIL 0x40000000U /*%< fatal check-dup-records failures */
  71. #ifndef NOMINUM_PUBLIC
  72. /*
  73. * Nominum specific options build down.
  74. */
  75. #define DNS_ZONEOPT_NOTIFYFORWARD 0x80000000U /* forward notify to master */
  76. #endif /* NOMINUM_PUBLIC */
  77. /*
  78. * Zone key maintenance options
  79. */
  80. #define DNS_ZONEKEY_ALLOW 0x00000001U /*%< fetch keys on command */
  81. #define DNS_ZONEKEY_MAINTAIN 0x00000002U /*%< publish/sign on schedule */
  82. #define DNS_ZONEKEY_CREATE 0x00000004U /*%< make keys when needed */
  83. #define DNS_ZONEKEY_FULLSIGN 0x00000008U /*%< roll to new keys immediately */
  84. #ifndef DNS_ZONE_MINREFRESH
  85. #define DNS_ZONE_MINREFRESH 300 /*%< 5 minutes */
  86. #endif
  87. #ifndef DNS_ZONE_MAXREFRESH
  88. #define DNS_ZONE_MAXREFRESH 2419200 /*%< 4 weeks */
  89. #endif
  90. #ifndef DNS_ZONE_DEFAULTREFRESH
  91. #define DNS_ZONE_DEFAULTREFRESH 3600 /*%< 1 hour */
  92. #endif
  93. #ifndef DNS_ZONE_MINRETRY
  94. #define DNS_ZONE_MINRETRY 300 /*%< 5 minutes */
  95. #endif
  96. #ifndef DNS_ZONE_MAXRETRY
  97. #define DNS_ZONE_MAXRETRY 1209600 /*%< 2 weeks */
  98. #endif
  99. #ifndef DNS_ZONE_DEFAULTRETRY
  100. #define DNS_ZONE_DEFAULTRETRY 60 /*%< 1 minute, subject to
  101. exponential backoff */
  102. #endif
  103. #define DNS_ZONESTATE_XFERRUNNING 1
  104. #define DNS_ZONESTATE_XFERDEFERRED 2
  105. #define DNS_ZONESTATE_SOAQUERY 3
  106. #define DNS_ZONESTATE_ANY 4
  107. ISC_LANG_BEGINDECLS
  108. /***
  109. *** Functions
  110. ***/
  111. isc_result_t
  112. dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx);
  113. /*%<
  114. * Creates a new empty zone and attach '*zonep' to it.
  115. *
  116. * Requires:
  117. *\li 'zonep' to point to a NULL pointer.
  118. *\li 'mctx' to be a valid memory context.
  119. *
  120. * Ensures:
  121. *\li '*zonep' refers to a valid zone.
  122. *
  123. * Returns:
  124. *\li #ISC_R_SUCCESS
  125. *\li #ISC_R_NOMEMORY
  126. *\li #ISC_R_UNEXPECTED
  127. */
  128. void
  129. dns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass);
  130. /*%<
  131. * Sets the class of a zone. This operation can only be performed
  132. * once on a zone.
  133. *
  134. * Require:
  135. *\li 'zone' to be a valid zone.
  136. *\li dns_zone_setclass() not to have been called since the zone was
  137. * created.
  138. *\li 'rdclass' != dns_rdataclass_none.
  139. */
  140. dns_rdataclass_t
  141. dns_zone_getclass(dns_zone_t *zone);
  142. /*%<
  143. * Returns the current zone class.
  144. *
  145. * Requires:
  146. *\li 'zone' to be a valid zone.
  147. */
  148. isc_result_t
  149. dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp);
  150. isc_uint32_t
  151. dns_zone_getserial(dns_zone_t *zone);
  152. /*%<
  153. * Returns the current serial number of the zone. On success, the SOA
  154. * serial of the zone will be copied into '*serialp'.
  155. * dns_zone_getserial() cannot catch failure cases and is deprecated by
  156. * dns_zone_getserial2().
  157. *
  158. * Requires:
  159. *\li 'zone' to be a valid zone.
  160. *\li 'serialp' to be non NULL
  161. *
  162. * Returns:
  163. *\li #ISC_R_SUCCESS
  164. *\li #DNS_R_NOTLOADED zone DB is not loaded
  165. */
  166. void
  167. dns_zone_settype(dns_zone_t *zone, dns_zonetype_t type);
  168. /*%<
  169. * Sets the zone type. This operation can only be performed once on
  170. * a zone.
  171. *
  172. * Requires:
  173. *\li 'zone' to be a valid zone.
  174. *\li dns_zone_settype() not to have been called since the zone was
  175. * created.
  176. *\li 'type' != dns_zone_none
  177. */
  178. void
  179. dns_zone_setview(dns_zone_t *zone, dns_view_t *view);
  180. /*%<
  181. * Associate the zone with a view.
  182. *
  183. * Require:
  184. *\li 'zone' to be a valid zone.
  185. */
  186. dns_view_t *
  187. dns_zone_getview(dns_zone_t *zone);
  188. /*%<
  189. * Returns the zone's associated view.
  190. *
  191. * Requires:
  192. *\li 'zone' to be a valid zone.
  193. */
  194. isc_result_t
  195. dns_zone_setorigin(dns_zone_t *zone, const dns_name_t *origin);
  196. /*%<
  197. * Sets the zones origin to 'origin'.
  198. *
  199. * Require:
  200. *\li 'zone' to be a valid zone.
  201. *\li 'origin' to be non NULL.
  202. *
  203. * Returns:
  204. *\li #ISC_R_SUCCESS
  205. *\li #ISC_R_NOMEMORY
  206. */
  207. dns_name_t *
  208. dns_zone_getorigin(dns_zone_t *zone);
  209. /*%<
  210. * Returns the value of the origin.
  211. *
  212. * Require:
  213. *\li 'zone' to be a valid zone.
  214. */
  215. isc_result_t
  216. dns_zone_setfile(dns_zone_t *zone, const char *file);
  217. isc_result_t
  218. dns_zone_setfile2(dns_zone_t *zone, const char *file,
  219. dns_masterformat_t format);
  220. /*%<
  221. * Sets the name of the master file in the format of 'format' from which
  222. * the zone loads its database to 'file'.
  223. *
  224. * For zones that have no associated master file, 'file' will be NULL.
  225. *
  226. * For zones with persistent databases, the file name
  227. * setting is ignored.
  228. *
  229. * dns_zone_setfile() is a backward-compatible form of
  230. * dns_zone_setfile2(), which always specifies the
  231. * dns_masterformat_text (RFC1035) format.
  232. *
  233. * Require:
  234. *\li 'zone' to be a valid zone.
  235. *
  236. * Returns:
  237. *\li #ISC_R_NOMEMORY
  238. *\li #ISC_R_SUCCESS
  239. */
  240. const char *
  241. dns_zone_getfile(dns_zone_t *zone);
  242. /*%<
  243. * Gets the name of the zone's master file, if any.
  244. *
  245. * Requires:
  246. *\li 'zone' to be valid initialised zone.
  247. *
  248. * Returns:
  249. *\li Pointer to null-terminated file name, or NULL.
  250. */
  251. isc_result_t
  252. dns_zone_load(dns_zone_t *zone);
  253. isc_result_t
  254. dns_zone_loadnew(dns_zone_t *zone);
  255. isc_result_t
  256. dns_zone_loadandthaw(dns_zone_t *zone);
  257. /*%<
  258. * Cause the database to be loaded from its backing store.
  259. * Confirm that the minimum requirements for the zone type are
  260. * met, otherwise DNS_R_BADZONE is returned.
  261. *
  262. * dns_zone_loadnew() only loads zones that are not yet loaded.
  263. * dns_zone_load() also loads zones that are already loaded and
  264. * and whose master file has changed since the last load.
  265. * dns_zone_loadandthaw() is similar to dns_zone_load() but will
  266. * also re-enable DNS UPDATEs when the load completes.
  267. *
  268. * Require:
  269. *\li 'zone' to be a valid zone.
  270. *
  271. * Returns:
  272. *\li #ISC_R_UNEXPECTED
  273. *\li #ISC_R_SUCCESS
  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.
  277. *\li DNS_R_BADZONE
  278. *\li Any result value from dns_db_load().
  279. */
  280. void
  281. dns_zone_attach(dns_zone_t *source, dns_zone_t **target);
  282. /*%<
  283. * Attach '*target' to 'source' incrementing its external
  284. * reference count.
  285. *
  286. * Require:
  287. *\li 'zone' to be a valid zone.
  288. *\li 'target' to be non NULL and '*target' to be NULL.
  289. */
  290. void
  291. dns_zone_detach(dns_zone_t **zonep);
  292. /*%<
  293. * Detach from a zone decrementing its external reference count.
  294. * If this was the last external reference to the zone it will be
  295. * shut down and eventually freed.
  296. *
  297. * Require:
  298. *\li 'zonep' to point to a valid zone.
  299. */
  300. void
  301. dns_zone_iattach(dns_zone_t *source, dns_zone_t **target);
  302. /*%<
  303. * Attach '*target' to 'source' incrementing its internal
  304. * reference count. This is intended for use by operations
  305. * such as zone transfers that need to prevent the zone
  306. * object from being freed but not from shutting down.
  307. *
  308. * Require:
  309. *\li The caller is running in the context of the zone's task.
  310. *\li 'zone' to be a valid zone.
  311. *\li 'target' to be non NULL and '*target' to be NULL.
  312. */
  313. void
  314. dns_zone_idetach(dns_zone_t **zonep);
  315. /*%<
  316. * Detach from a zone decrementing its internal reference count.
  317. * If there are no more internal or external references to the
  318. * zone, it will be freed.
  319. *
  320. * Require:
  321. *\li The caller is running in the context of the zone's task.
  322. *\li 'zonep' to point to a valid zone.
  323. */
  324. void
  325. dns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value);
  326. /*%<
  327. * Sets ('value' == 'ISC_TRUE') / clears ('value' == 'IS_FALSE')
  328. * zone flags. Valid flag bits are DNS_ZONE_F_*.
  329. *
  330. * Requires
  331. *\li 'zone' to be a valid zone.
  332. */
  333. isc_result_t
  334. dns_zone_getdb(dns_zone_t *zone, dns_db_t **dbp);
  335. /*%<
  336. * Attach '*dbp' to the database to if it exists otherwise
  337. * return DNS_R_NOTLOADED.
  338. *
  339. * Require:
  340. *\li 'zone' to be a valid zone.
  341. *\li 'dbp' to be != NULL && '*dbp' == NULL.
  342. *
  343. * Returns:
  344. *\li #ISC_R_SUCCESS
  345. *\li DNS_R_NOTLOADED
  346. */
  347. void
  348. dns_zone_setdb(dns_zone_t *zone, dns_db_t *db);
  349. /*%<
  350. * Sets the zone database to 'db'.
  351. *
  352. * This function is expected to be used to configure a zone with a
  353. * database which is not loaded from a file or zone transfer.
  354. * It can be used for a general purpose zone, but right now its use
  355. * is limited to static-stub zones to avoid possible undiscovered
  356. * problems in the general cases.
  357. *
  358. * Require:
  359. *\li 'zone' to be a valid zone of static-stub.
  360. *\li zone doesn't have a database.
  361. */
  362. isc_result_t
  363. dns_zone_setdbtype(dns_zone_t *zone,
  364. unsigned int dbargc, const char * const *dbargv);
  365. /*%<
  366. * Sets the database type to dbargv[0] and database arguments
  367. * to subsequent dbargv elements.
  368. * 'db_type' is not checked to see if it is a valid database type.
  369. *
  370. * Require:
  371. *\li 'zone' to be a valid zone.
  372. *\li 'database' to be non NULL.
  373. *\li 'dbargc' to be >= 1
  374. *\li 'dbargv' to point to dbargc NULL-terminated strings
  375. *
  376. * Returns:
  377. *\li #ISC_R_NOMEMORY
  378. *\li #ISC_R_SUCCESS
  379. */
  380. isc_result_t
  381. dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx);
  382. /*%<
  383. * Returns the current dbtype. isc_mem_free() should be used
  384. * to free 'argv' after use.
  385. *
  386. * Require:
  387. *\li 'zone' to be a valid zone.
  388. *\li 'argv' to be non NULL and *argv to be NULL.
  389. *\li 'mctx' to be valid.
  390. *
  391. * Returns:
  392. *\li #ISC_R_NOMEMORY
  393. *\li #ISC_R_SUCCESS
  394. */
  395. void
  396. dns_zone_markdirty(dns_zone_t *zone);
  397. /*%<
  398. * Mark a zone as 'dirty'.
  399. *
  400. * Require:
  401. *\li 'zone' to be a valid zone.
  402. */
  403. void
  404. dns_zone_expire(dns_zone_t *zone);
  405. /*%<
  406. * Mark the zone as expired. If the zone requires dumping cause it to
  407. * be initiated. Set the refresh and retry intervals to there default
  408. * values and unload the zone.
  409. *
  410. * Require
  411. *\li 'zone' to be a valid zone.
  412. */
  413. void
  414. dns_zone_refresh(dns_zone_t *zone);
  415. /*%<
  416. * Initiate zone up to date checks. The zone must already be being
  417. * managed.
  418. *
  419. * Require
  420. *\li 'zone' to be a valid zone.
  421. */
  422. isc_result_t
  423. dns_zone_flush(dns_zone_t *zone);
  424. /*%<
  425. * Write the zone to database if there are uncommitted changes.
  426. *
  427. * Require:
  428. *\li 'zone' to be a valid zone.
  429. */
  430. isc_result_t
  431. dns_zone_dump(dns_zone_t *zone);
  432. /*%<
  433. * Write the zone to database.
  434. *
  435. * Require:
  436. *\li 'zone' to be a valid zone.
  437. */
  438. isc_result_t
  439. dns_zone_dumptostream(dns_zone_t *zone, FILE *fd);
  440. isc_result_t
  441. dns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
  442. const dns_master_style_t *style);
  443. /*%<
  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).
  447. *
  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.
  451. *
  452. * Note that dns_zone_dumptostream2() is the most flexible form. It
  453. * can also provide the functionality of dns_zone_fulldumptostream().
  454. *
  455. * Require:
  456. *\li 'zone' to be a valid zone.
  457. *\li 'fd' to be a stream open for writing.
  458. */
  459. isc_result_t
  460. dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd);
  461. /*%<
  462. * The same as dns_zone_dumptostream, but dumps the zone with
  463. * different dump settings (dns_master_style_full).
  464. *
  465. * Require:
  466. *\li 'zone' to be a valid zone.
  467. *\li 'fd' to be a stream open for writing.
  468. */
  469. void
  470. dns_zone_maintenance(dns_zone_t *zone);
  471. /*%<
  472. * Perform regular maintenance on the zone. This is called as a
  473. * result of a zone being managed.
  474. *
  475. * Require
  476. *\li 'zone' to be a valid zone.
  477. */
  478. isc_result_t
  479. dns_zone_setmasters(dns_zone_t *zone, const isc_sockaddr_t *masters,
  480. isc_uint32_t count);
  481. isc_result_t
  482. dns_zone_setmasterswithkeys(dns_zone_t *zone,
  483. const isc_sockaddr_t *masters,
  484. dns_name_t **keynames,
  485. isc_uint32_t count);
  486. /*%<
  487. * Set the list of master servers for the zone.
  488. *
  489. * Require:
  490. *\li 'zone' to be a valid zone.
  491. *\li 'masters' array of isc_sockaddr_t with port set or NULL.
  492. *\li 'count' the number of masters.
  493. *\li 'keynames' array of dns_name_t's for tsig keys or NULL.
  494. *
  495. * \li dns_zone_setmasters() is just a wrapper to setmasterswithkeys(),
  496. * passing NULL in the keynames field.
  497. *
  498. * \li If 'masters' is NULL then 'count' must be zero.
  499. *
  500. * Returns:
  501. *\li #ISC_R_SUCCESS
  502. *\li #ISC_R_NOMEMORY
  503. *\li Any result dns_name_dup() can return, if keynames!=NULL
  504. */
  505. isc_result_t
  506. dns_zone_setalsonotify(dns_zone_t *zone, const isc_sockaddr_t *notify,
  507. isc_uint32_t count);
  508. /*%<
  509. * Set the list of additional servers to be notified when
  510. * a zone changes. To clear the list use 'count = 0'.
  511. *
  512. * Require:
  513. *\li 'zone' to be a valid zone.
  514. *\li 'notify' to be non-NULL if count != 0.
  515. *\li 'count' to be the number of notifiees.
  516. *
  517. * Returns:
  518. *\li #ISC_R_SUCCESS
  519. *\li #ISC_R_NOMEMORY
  520. */
  521. void
  522. dns_zone_unload(dns_zone_t *zone);
  523. /*%<
  524. * detach the database from the zone structure.
  525. *
  526. * Require:
  527. *\li 'zone' to be a valid zone.
  528. */
  529. void
  530. dns_zone_setoption(dns_zone_t *zone, unsigned int option, isc_boolean_t value);
  531. /*%<
  532. * Set given options on ('value' == ISC_TRUE) or off ('value' ==
  533. * #ISC_FALSE).
  534. *
  535. * Require:
  536. *\li 'zone' to be a valid zone.
  537. */
  538. unsigned int
  539. dns_zone_getoptions(dns_zone_t *zone);
  540. /*%<
  541. * Returns the current zone options.
  542. *
  543. * Require:
  544. *\li 'zone' to be a valid zone.
  545. */
  546. void
  547. dns_zone_setkeyopt(dns_zone_t *zone, unsigned int option, isc_boolean_t value);
  548. /*%<
  549. * Set key options on ('value' == ISC_TRUE) or off ('value' ==
  550. * #ISC_FALSE).
  551. *
  552. * Require:
  553. *\li 'zone' to be a valid zone.
  554. */
  555. unsigned int
  556. dns_zone_getkeyopts(dns_zone_t *zone);
  557. /*%<
  558. * Returns the current zone key options.
  559. *
  560. * Require:
  561. *\li 'zone' to be a valid zone.
  562. */
  563. void
  564. dns_zone_setminrefreshtime(dns_zone_t *zone, isc_uint32_t val);
  565. /*%<
  566. * Set the minimum refresh time.
  567. *
  568. * Requires:
  569. *\li 'zone' is valid.
  570. *\li val > 0.
  571. */
  572. void
  573. dns_zone_setmaxrefreshtime(dns_zone_t *zone, isc_uint32_t val);
  574. /*%<
  575. * Set the maximum refresh time.
  576. *
  577. * Requires:
  578. *\li 'zone' is valid.
  579. *\li val > 0.
  580. */
  581. void
  582. dns_zone_setminretrytime(dns_zone_t *zone, isc_uint32_t val);
  583. /*%<
  584. * Set the minimum retry time.
  585. *
  586. * Requires:
  587. *\li 'zone' is valid.
  588. *\li val > 0.
  589. */
  590. void
  591. dns_zone_setmaxretrytime(dns_zone_t *zone, isc_uint32_t val);
  592. /*%<
  593. * Set the maximum retry time.
  594. *
  595. * Requires:
  596. *\li 'zone' is valid.
  597. * val > 0.
  598. */
  599. isc_result_t
  600. dns_zone_setxfrsource4(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
  601. isc_result_t
  602. dns_zone_setaltxfrsource4(dns_zone_t *zone,
  603. const isc_sockaddr_t *xfrsource);
  604. /*%<
  605. * Set the source address to be used in IPv4 zone transfers.
  606. *
  607. * Require:
  608. *\li 'zone' to be a valid zone.
  609. *\li 'xfrsource' to contain the address.
  610. *
  611. * Returns:
  612. *\li #ISC_R_SUCCESS
  613. */
  614. isc_sockaddr_t *
  615. dns_zone_getxfrsource4(dns_zone_t *zone);
  616. isc_sockaddr_t *
  617. dns_zone_getaltxfrsource4(dns_zone_t *zone);
  618. /*%<
  619. * Returns the source address set by a previous dns_zone_setxfrsource4
  620. * call, or the default of inaddr_any, port 0.
  621. *
  622. * Require:
  623. *\li 'zone' to be a valid zone.
  624. */
  625. isc_result_t
  626. dns_zone_setxfrsource6(dns_zone_t *zone, const isc_sockaddr_t *xfrsource);
  627. isc_result_t
  628. dns_zone_setaltxfrsource6(dns_zone_t *zone,
  629. const isc_sockaddr_t *xfrsource);
  630. /*%<
  631. * Set the source address to be used in IPv6 zone transfers.
  632. *
  633. * Require:
  634. *\li 'zone' to be a valid zone.
  635. *\li 'xfrsource' to contain the address.
  636. *
  637. * Returns:
  638. *\li #ISC_R_SUCCESS
  639. */
  640. isc_sockaddr_t *
  641. dns_zone_getxfrsource6(dns_zone_t *zone);
  642. isc_sockaddr_t *
  643. dns_zone_getaltxfrsource6(dns_zone_t *zone);
  644. /*%<
  645. * Returns the source address set by a previous dns_zone_setxfrsource6
  646. * call, or the default of in6addr_any, port 0.
  647. *
  648. * Require:
  649. *\li 'zone' to be a valid zone.
  650. */
  651. isc_result_t
  652. dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
  653. /*%<
  654. * Set the source address to be used with IPv4 NOTIFY messages.
  655. *
  656. * Require:
  657. *\li 'zone' to be a valid zone.
  658. *\li 'notifysrc' to contain the address.
  659. *
  660. * Returns:
  661. *\li #ISC_R_SUCCESS
  662. */
  663. isc_sockaddr_t *
  664. dns_zone_getnotifysrc4(dns_zone_t *zone);
  665. /*%<
  666. * Returns the source address set by a previous dns_zone_setnotifysrc4
  667. * call, or the default of inaddr_any, port 0.
  668. *
  669. * Require:
  670. *\li 'zone' to be a valid zone.
  671. */
  672. isc_result_t
  673. dns_zone_setnotifysrc6(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
  674. /*%<
  675. * Set the source address to be used with IPv6 NOTIFY messages.
  676. *
  677. * Require:
  678. *\li 'zone' to be a valid zone.
  679. *\li 'notifysrc' to contain the address.
  680. *
  681. * Returns:
  682. *\li #ISC_R_SUCCESS
  683. */
  684. isc_sockaddr_t *
  685. dns_zone_getnotifysrc6(dns_zone_t *zone);
  686. /*%<
  687. * Returns the source address set by a previous dns_zone_setnotifysrc6
  688. * call, or the default of in6addr_any, port 0.
  689. *
  690. * Require:
  691. *\li 'zone' to be a valid zone.
  692. */
  693. void
  694. dns_zone_setnotifyacl(dns_zone_t *zone, dns_acl_t *acl);
  695. /*%<
  696. * Sets the notify acl list for the zone.
  697. *
  698. * Require:
  699. *\li 'zone' to be a valid zone.
  700. *\li 'acl' to be a valid acl.
  701. */
  702. void
  703. dns_zone_setqueryacl(dns_zone_t *zone, dns_acl_t *acl);
  704. /*%<
  705. * Sets the query acl list for the zone.
  706. *
  707. * Require:
  708. *\li 'zone' to be a valid zone.
  709. *\li 'acl' to be a valid acl.
  710. */
  711. void
  712. dns_zone_setqueryonacl(dns_zone_t *zone, dns_acl_t *acl);
  713. /*%<
  714. * Sets the query-on acl list for the zone.
  715. *
  716. * Require:
  717. *\li 'zone' to be a valid zone.
  718. *\li 'acl' to be a valid acl.
  719. */
  720. void
  721. dns_zone_setupdateacl(dns_zone_t *zone, dns_acl_t *acl);
  722. /*%<
  723. * Sets the update acl list for the zone.
  724. *
  725. * Require:
  726. *\li 'zone' to be a valid zone.
  727. *\li 'acl' to be valid acl.
  728. */
  729. void
  730. dns_zone_setforwardacl(dns_zone_t *zone, dns_acl_t *acl);
  731. /*%<
  732. * Sets the forward unsigned updates acl list for the zone.
  733. *
  734. * Require:
  735. *\li 'zone' to be a valid zone.
  736. *\li 'acl' to be valid acl.
  737. */
  738. void
  739. dns_zone_setxfracl(dns_zone_t *zone, dns_acl_t *acl);
  740. /*%<
  741. * Sets the transfer acl list for the zone.
  742. *
  743. * Require:
  744. *\li 'zone' to be a valid zone.
  745. *\li 'acl' to be valid acl.
  746. */
  747. dns_acl_t *
  748. dns_zone_getnotifyacl(dns_zone_t *zone);
  749. /*%<
  750. * Returns the current notify acl or NULL.
  751. *
  752. * Require:
  753. *\li 'zone' to be a valid zone.
  754. *
  755. * Returns:
  756. *\li acl a pointer to the acl.
  757. *\li NULL
  758. */
  759. dns_acl_t *
  760. dns_zone_getqueryacl(dns_zone_t *zone);
  761. /*%<
  762. * Returns the current query acl or NULL.
  763. *
  764. * Require:
  765. *\li 'zone' to be a valid zone.
  766. *
  767. * Returns:
  768. *\li acl a pointer to the acl.
  769. *\li NULL
  770. */
  771. dns_acl_t *
  772. dns_zone_getqueryonacl(dns_zone_t *zone);
  773. /*%<
  774. * Returns the current query-on acl or NULL.
  775. *
  776. * Require:
  777. *\li 'zone' to be a valid zone.
  778. *
  779. * Returns:
  780. *\li acl a pointer to the acl.
  781. *\li NULL
  782. */
  783. dns_acl_t *
  784. dns_zone_getupdateacl(dns_zone_t *zone);
  785. /*%<
  786. * Returns the current update acl or NULL.
  787. *
  788. * Require:
  789. *\li 'zone' to be a valid zone.
  790. *
  791. * Returns:
  792. *\li acl a pointer to the acl.
  793. *\li NULL
  794. */
  795. dns_acl_t *
  796. dns_zone_getforwardacl(dns_zone_t *zone);
  797. /*%<
  798. * Returns the current forward unsigned updates acl or NULL.
  799. *
  800. * Require:
  801. *\li 'zone' to be a valid zone.
  802. *
  803. * Returns:
  804. *\li acl a pointer to the acl.
  805. *\li NULL
  806. */
  807. dns_acl_t *
  808. dns_zone_getxfracl(dns_zone_t *zone);
  809. /*%<
  810. * Returns the current transfer acl or NULL.
  811. *
  812. * Require:
  813. *\li 'zone' to be a valid zone.
  814. *
  815. * Returns:
  816. *\li acl a pointer to the acl.
  817. *\li NULL
  818. */
  819. void
  820. dns_zone_clearupdateacl(dns_zone_t *zone);
  821. /*%<
  822. * Clear the current update acl.
  823. *
  824. * Require:
  825. *\li 'zone' to be a valid zone.
  826. */
  827. void
  828. dns_zone_clearforwardacl(dns_zone_t *zone);
  829. /*%<
  830. * Clear the current forward unsigned updates acl.
  831. *
  832. * Require:
  833. *\li 'zone' to be a valid zone.
  834. */
  835. void
  836. dns_zone_clearnotifyacl(dns_zone_t *zone);
  837. /*%<
  838. * Clear the current notify acl.
  839. *
  840. * Require:
  841. *\li 'zone' to be a valid zone.
  842. */
  843. void
  844. dns_zone_clearqueryacl(dns_zone_t *zone);
  845. /*%<
  846. * Clear the current query acl.
  847. *
  848. * Require:
  849. *\li 'zone' to be a valid zone.
  850. */
  851. void
  852. dns_zone_clearqueryonacl(dns_zone_t *zone);
  853. /*%<
  854. * Clear the current query-on acl.
  855. *
  856. * Require:
  857. *\li 'zone' to be a valid zone.
  858. */
  859. void
  860. dns_zone_clearxfracl(dns_zone_t *zone);
  861. /*%<
  862. * Clear the current transfer acl.
  863. *
  864. * Require:
  865. *\li 'zone' to be a valid zone.
  866. */
  867. isc_boolean_t
  868. dns_zone_getupdatedisabled(dns_zone_t *zone);
  869. /*%<
  870. * Return update disabled.
  871. * Transient unless called when running in isc_task_exclusive() mode.
  872. */
  873. void
  874. dns_zone_setupdatedisabled(dns_zone_t *zone, isc_boolean_t state);
  875. /*%<
  876. * Set update disabled.
  877. * Should only be called only when running in isc_task_exclusive() mode.
  878. * Failure to do so may result in updates being committed after the
  879. * call has been made.
  880. */
  881. isc_boolean_t
  882. dns_zone_getzeronosoattl(dns_zone_t *zone);
  883. /*%<
  884. * Return zero-no-soa-ttl status.
  885. */
  886. void
  887. dns_zone_setzeronosoattl(dns_zone_t *zone, isc_boolean_t state);
  888. /*%<
  889. * Set zero-no-soa-ttl status.
  890. */
  891. void
  892. dns_zone_setchecknames(dns_zone_t *zone, dns_severity_t severity);
  893. /*%<
  894. * Set the severity of name checking when loading a zone.
  895. *
  896. * Require:
  897. * \li 'zone' to be a valid zone.
  898. */
  899. dns_severity_t
  900. dns_zone_getchecknames(dns_zone_t *zone);
  901. /*%<
  902. * Return the current severity of name checking.
  903. *
  904. * Require:
  905. *\li 'zone' to be a valid zone.
  906. */
  907. void
  908. dns_zone_setjournalsize(dns_zone_t *zone, isc_int32_t size);
  909. /*%<
  910. * Sets the journal size for the zone.
  911. *
  912. * Requires:
  913. *\li 'zone' to be a valid zone.
  914. */
  915. isc_int32_t
  916. dns_zone_getjournalsize(dns_zone_t *zone);
  917. /*%<
  918. * Return the journal size as set with a previous call to
  919. * dns_zone_setjournalsize().
  920. *
  921. * Requires:
  922. *\li 'zone' to be a valid zone.
  923. */
  924. isc_result_t
  925. dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
  926. dns_message_t *msg);
  927. /*%<
  928. * Tell the zone that it has received a NOTIFY message from another
  929. * server. This may cause some zone maintenance activity to occur.
  930. *
  931. * Requires:
  932. *\li 'zone' to be a valid zone.
  933. *\li '*from' to contain the address of the server from which 'msg'
  934. * was received.
  935. *\li 'msg' a message with opcode NOTIFY and qr clear.
  936. *
  937. * Returns:
  938. *\li DNS_R_REFUSED
  939. *\li DNS_R_NOTIMP
  940. *\li DNS_R_FORMERR
  941. *\li DNS_R_SUCCESS
  942. */
  943. void
  944. dns_zone_setmaxxfrin(dns_zone_t *zone, isc_uint32_t maxxfrin);
  945. /*%<
  946. * Set the maximum time (in seconds) that a zone transfer in (AXFR/IXFR)
  947. * of this zone will use before being aborted.
  948. *
  949. * Requires:
  950. * \li 'zone' to be valid initialised zone.
  951. */
  952. isc_uint32_t
  953. dns_zone_getmaxxfrin(dns_zone_t *zone);
  954. /*%<
  955. * Returns the maximum transfer time for this zone. This will be
  956. * either the value set by the last call to dns_zone_setmaxxfrin() or
  957. * the default value of 1 hour.
  958. *
  959. * Requires:
  960. *\li 'zone' to be valid initialised zone.
  961. */
  962. void
  963. dns_zone_setmaxxfrout(dns_zone_t *zone, isc_uint32_t maxxfrout);
  964. /*%<
  965. * Set the maximum time (in seconds) that a zone transfer out (AXFR/IXFR)
  966. * of this zone will use before being aborted.
  967. *
  968. * Requires:
  969. * \li 'zone' to be valid initialised zone.
  970. */
  971. isc_uint32_t
  972. dns_zone_getmaxxfrout(dns_zone_t *zone);
  973. /*%<
  974. * Returns the maximum transfer time for this zone. This will be
  975. * either the value set by the last call to dns_zone_setmaxxfrout() or
  976. * the default value of 1 hour.
  977. *
  978. * Requires:
  979. *\li 'zone' to be valid initialised zone.
  980. */
  981. isc_result_t
  982. dns_zone_setjournal(dns_zone_t *zone, const char *journal);
  983. /*%<
  984. * Sets the filename used for journaling updates / IXFR transfers.
  985. * The default journal name is set by dns_zone_setfile() to be
  986. * "file.jnl". If 'journal' is NULL, the zone will have no
  987. * journal name.
  988. *
  989. * Requires:
  990. *\li 'zone' to be a valid zone.
  991. *
  992. * Returns:
  993. *\li #ISC_R_SUCCESS
  994. *\li #ISC_R_NOMEMORY
  995. */
  996. char *
  997. dns_zone_getjournal(dns_zone_t *zone);
  998. /*%<
  999. * Returns the journal name associated with this zone.
  1000. * If no journal has been set this will be NULL.
  1001. *
  1002. * Requires:
  1003. *\li 'zone' to be valid initialised zone.
  1004. */
  1005. dns_zonetype_t
  1006. dns_zone_gettype(dns_zone_t *zone);
  1007. /*%<
  1008. * Returns the type of the zone (master/slave/etc.)
  1009. *
  1010. * Requires:
  1011. *\li 'zone' to be valid initialised zone.
  1012. */
  1013. void
  1014. dns_zone_settask(dns_zone_t *zone, isc_task_t *task);
  1015. /*%<
  1016. * Give a zone a task to work with. Any current task will be detached.
  1017. *
  1018. * Requires:
  1019. *\li 'zone' to be valid.
  1020. *\li 'task' to be valid.
  1021. */
  1022. void
  1023. dns_zone_gettask(dns_zone_t *zone, isc_task_t **target);
  1024. /*%<
  1025. * Attach '*target' to the zone's task.
  1026. *
  1027. * Requires:
  1028. *\li 'zone' to be valid initialised zone.
  1029. *\li 'zone' to have a task.
  1030. *\li 'target' to be != NULL && '*target' == NULL.
  1031. */
  1032. void
  1033. dns_zone_notify(dns_zone_t *zone);
  1034. /*%<
  1035. * Generate notify events for this zone.
  1036. *
  1037. * Requires:
  1038. *\li 'zone' to be a valid zone.
  1039. */
  1040. isc_result_t
  1041. dns_zone_replacedb(dns_zone_t *zone, dns_db_t *db, isc_boolean_t dump);
  1042. /*%<
  1043. * Replace the database of "zone" with a new database "db".
  1044. *
  1045. * If "dump" is ISC_TRUE, then the new zone contents are dumped
  1046. * into to the zone's master file for persistence. When replacing
  1047. * a zone database by one just loaded from a master file, set
  1048. * "dump" to ISC_FALSE to avoid a redundant redump of the data just
  1049. * loaded. Otherwise, it should be set to ISC_TRUE.
  1050. *
  1051. * If the "diff-on-reload" option is enabled in the configuration file,
  1052. * the differences between the old and the new database are added to the
  1053. * journal file, and the master file dump is postponed.
  1054. *
  1055. * Requires:
  1056. * \li 'zone' to be a valid zone.
  1057. *
  1058. * Returns:
  1059. * \li DNS_R_SUCCESS
  1060. * \li DNS_R_BADZONE zone failed basic consistency checks:
  1061. * * a single SOA must exist
  1062. * * some NS records must exist.
  1063. * Others
  1064. */
  1065. isc_uint32_t
  1066. dns_zone_getidlein(dns_zone_t *zone);
  1067. /*%<
  1068. * Requires:
  1069. * \li 'zone' to be a valid zone.
  1070. *
  1071. * Returns:
  1072. * \li number of seconds of idle time before we abort the transfer in.
  1073. */
  1074. void
  1075. dns_zone_setidlein(dns_zone_t *zone, isc_uint32_t idlein);
  1076. /*%<
  1077. * \li Set the idle timeout for transfer the.
  1078. * \li Zero set the default value, 1 hour.
  1079. *
  1080. * Requires:
  1081. * \li 'zone' to be a valid zone.
  1082. */
  1083. isc_uint32_t
  1084. dns_zone_getidleout(dns_zone_t *zone);
  1085. /*%<
  1086. *
  1087. * Requires:
  1088. * \li 'zone' to be a valid zone.
  1089. *
  1090. * Returns:
  1091. * \li number of seconds of idle time before we abort a transfer out.
  1092. */
  1093. void
  1094. dns_zone_setidleout(dns_zone_t *zone, isc_uint32_t idleout);
  1095. /*%<
  1096. * \li Set the idle timeout for transfers out.
  1097. * \li Zero set the default value, 1 hour.
  1098. *
  1099. * Requires:
  1100. * \li 'zone' to be a valid zone.
  1101. */
  1102. void
  1103. dns_zone_getssutable(dns_zone_t *zone, dns_ssutable_t **table);
  1104. /*%<
  1105. * Get the simple-secure-update policy table.
  1106. *
  1107. * Requires:
  1108. * \li 'zone' to be a valid zone.
  1109. */
  1110. void
  1111. dns_zone_setssutable(dns_zone_t *zone, dns_ssutable_t *table);
  1112. /*%<
  1113. * Set / clear the simple-secure-update policy table.
  1114. *
  1115. * Requires:
  1116. * \li 'zone' to be a valid zone.
  1117. */
  1118. isc_mem_t *
  1119. dns_zone_getmctx(dns_zone_t *zone);
  1120. /*%<
  1121. * Get the memory context of a zone.
  1122. *
  1123. * Requires:
  1124. * \li 'zone' to be a valid zone.
  1125. */
  1126. dns_zonemgr_t *
  1127. dns_zone_getmgr(dns_zone_t *zone);
  1128. /*%<
  1129. * If 'zone' is managed return the zone manager otherwise NULL.
  1130. *
  1131. * Requires:
  1132. * \li 'zone' to be a valid zone.
  1133. */
  1134. void
  1135. dns_zone_setsigvalidityinterval(dns_zone_t *zone, isc_uint32_t interval);
  1136. /*%<
  1137. * Set the zone's RRSIG validity interval. This is the length of time
  1138. * for which DNSSEC signatures created as a result of dynamic updates
  1139. * to secure zones will remain valid, in seconds.
  1140. *
  1141. * Requires:
  1142. * \li 'zone' to be a valid zone.
  1143. */
  1144. isc_uint32_t
  1145. dns_zone_getsigvalidityinterval(dns_zone_t *zone);
  1146. /*%<
  1147. * Get the zone's RRSIG validity interval.
  1148. *
  1149. * Requires:
  1150. * \li 'zone' to be a valid zone.
  1151. */
  1152. void
  1153. dns_zone_setsigresigninginterval(dns_zone_t *zone, isc_uint32_t interval);
  1154. /*%<
  1155. * Set the zone's RRSIG re-signing interval. A dynamic zone's RRSIG's
  1156. * will be re-signed 'interval' amount of time before they expire.
  1157. *
  1158. * Requires:
  1159. * \li 'zone' to be a valid zone.
  1160. */
  1161. isc_uint32_t
  1162. dns_zone_getsigresigninginterval(dns_zone_t *zone);
  1163. /*%<
  1164. * Get the zone's RRSIG re-signing interval.
  1165. *
  1166. * Requires:
  1167. * \li 'zone' to be a valid zone.
  1168. */
  1169. void
  1170. dns_zone_setnotifytype(dns_zone_t *zone, dns_notifytype_t notifytype);
  1171. /*%<
  1172. * Sets zone notify method to "notifytype"
  1173. */
  1174. isc_result_t
  1175. dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
  1176. dns_updatecallback_t callback, void *callback_arg);
  1177. /*%<
  1178. * Forward 'msg' to each master in turn until we get an answer or we
  1179. * have exhausted the list of masters. 'callback' will be called with
  1180. * ISC_R_SUCCESS if we get an answer and the returned message will be
  1181. * passed as 'answer_message', otherwise a non ISC_R_SUCCESS result code
  1182. * will be passed and answer_message will be NULL. The callback function
  1183. * is responsible for destroying 'answer_message'.
  1184. * (callback)(callback_arg, result, answer_message);
  1185. *
  1186. * Require:
  1187. *\li 'zone' to be valid
  1188. *\li 'msg' to be valid.
  1189. *\li 'callback' to be non NULL.
  1190. * Returns:
  1191. *\li #ISC_R_SUCCESS if the message has been forwarded,
  1192. *\li #ISC_R_NOMEMORY
  1193. *\li Others
  1194. */
  1195. isc_result_t
  1196. dns_zone_next(dns_zone_t *zone, dns_zone_t **next);
  1197. /*%<
  1198. * Find the next zone in the list of managed zones.
  1199. *
  1200. * Requires:
  1201. *\li 'zone' to be valid
  1202. *\li The zone manager for the indicated zone MUST be locked
  1203. * by the caller. This is not checked.
  1204. *\li 'next' be non-NULL, and '*next' be NULL.
  1205. *
  1206. * Ensures:
  1207. *\li 'next' points to a valid zone (result ISC_R_SUCCESS) or to NULL
  1208. * (result ISC_R_NOMORE).
  1209. */
  1210. isc_result_t
  1211. dns_zone_first(dns_zonemgr_t *zmgr, dns_zone_t **first);
  1212. /*%<
  1213. * Find the first zone in the list of managed zones.
  1214. *
  1215. * Requires:
  1216. *\li 'zonemgr' to be valid
  1217. *\li The zone manager for the indicated zone MUST be locked
  1218. * by the caller. This is not checked.
  1219. *\li 'first' be non-NULL, and '*first' be NULL
  1220. *
  1221. * Ensures:
  1222. *\li 'first' points to a valid zone (result ISC_R_SUCCESS) or to NULL
  1223. * (result ISC_R_NOMORE).
  1224. */
  1225. isc_result_t
  1226. dns_zone_setkeydirectory(dns_zone_t *zone, const char *directory);
  1227. /*%<
  1228. * Sets the name of the directory where private keys used for
  1229. * online signing of dynamic zones are found.
  1230. *
  1231. * Require:
  1232. *\li 'zone' to be a valid zone.
  1233. *
  1234. * Returns:
  1235. *\li #ISC_R_NOMEMORY
  1236. *\li #ISC_R_SUCCESS
  1237. */
  1238. const char *
  1239. dns_zone_getkeydirectory(dns_zone_t *zone);
  1240. /*%<
  1241. * Gets the name of the directory where private keys used for
  1242. * online signing of dynamic zones are found.
  1243. *
  1244. * Requires:
  1245. *\li 'zone' to be valid initialised zone.
  1246. *
  1247. * Returns:
  1248. * Pointer to null-terminated file name, or NULL.
  1249. */
  1250. isc_result_t
  1251. dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
  1252. isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr,
  1253. dns_zonemgr_t **zmgrp);
  1254. /*%<
  1255. * Create a zone manager. Note: the zone manager will not be able to
  1256. * manage any zones until dns_zonemgr_setsize() has been run.
  1257. *
  1258. * Requires:
  1259. *\li 'mctx' to be a valid memory context.
  1260. *\li 'taskmgr' to be a valid task manager.
  1261. *\li 'timermgr' to be a valid timer manager.
  1262. *\li 'zmgrp' to point to a NULL pointer.
  1263. */
  1264. isc_result_t
  1265. dns_zonemgr_setsize(dns_zonemgr_t *zmgr, int num_zones);
  1266. /*%<
  1267. * Set the size of the zone manager task pool. This must be run
  1268. * before zmgr can be used for managing zones. Currently, it can only
  1269. * be run once; the task pool cannot be resized.
  1270. *
  1271. * Requires:
  1272. *\li zmgr is a valid zone manager.
  1273. *\li zmgr->zonetasks has been initialized.
  1274. */
  1275. isc_result_t
  1276. dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
  1277. /*%<
  1278. * Bring the zone under control of a zone manager.
  1279. *
  1280. * Require:
  1281. *\li 'zmgr' to be a valid zone manager.
  1282. *\li 'zone' to be a valid zone.
  1283. */
  1284. isc_result_t
  1285. dns_zonemgr_forcemaint(dns_zonemgr_t *zmgr);
  1286. /*%<
  1287. * Force zone maintenance of all zones managed by 'zmgr' at its
  1288. * earliest convenience.
  1289. */
  1290. void
  1291. dns_zonemgr_resumexfrs(dns_zonemgr_t *zmgr);
  1292. /*%<
  1293. * Attempt to start any stalled zone transfers.
  1294. */
  1295. void
  1296. dns_zonemgr_shutdown(dns_zonemgr_t *zmgr);
  1297. /*%<
  1298. * Shut down the zone manager.
  1299. *
  1300. * Requires:
  1301. *\li 'zmgr' to be a valid zone manager.
  1302. */
  1303. void
  1304. dns_zonemgr_attach(dns_zonemgr_t *source, dns_zonemgr_t **target);
  1305. /*%<
  1306. * Attach '*target' to 'source' incrementing its external
  1307. * reference count.
  1308. *
  1309. * Require:
  1310. *\li 'zone' to be a valid zone.
  1311. *\li 'target' to be non NULL and '*target' to be NULL.
  1312. */
  1313. void
  1314. dns_zonemgr_detach(dns_zonemgr_t **zmgrp);
  1315. /*%<
  1316. * Detach from a zone manager.
  1317. *
  1318. * Requires:
  1319. *\li '*zmgrp' is a valid, non-NULL zone manager pointer.
  1320. *
  1321. * Ensures:
  1322. *\li '*zmgrp' is NULL.
  1323. */
  1324. void
  1325. dns_zonemgr_releasezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
  1326. /*%<
  1327. * Release 'zone' from the managed by 'zmgr'. 'zmgr' is implicitly
  1328. * detached from 'zone'.
  1329. *
  1330. * Requires:
  1331. *\li 'zmgr' to be a valid zone manager.
  1332. *\li 'zone' to be a valid zone.
  1333. *\li 'zmgr' == 'zone->zmgr'
  1334. *
  1335. * Ensures:
  1336. *\li 'zone->zmgr' == NULL;
  1337. */
  1338. void
  1339. dns_zonemgr_settransfersin(dns_zonemgr_t *zmgr, isc_uint32_t value);
  1340. /*%<
  1341. * Set the maximum number of simultaneous transfers in allowed by
  1342. * the zone manager.
  1343. *
  1344. * Requires:
  1345. *\li 'zmgr' to be a valid zone manager.
  1346. */
  1347. isc_uint32_t
  1348. dns_zonemgr_getttransfersin(dns_zonemgr_t *zmgr);
  1349. /*%<
  1350. * Return the maximum number of simultaneous transfers in allowed.
  1351. *
  1352. * Requires:
  1353. *\li 'zmgr' to be a valid zone manager.
  1354. */
  1355. void
  1356. dns_zonemgr_settransfersperns(dns_zonemgr_t *zmgr, isc_uint32_t value);
  1357. /*%<
  1358. * Set the number of zone transfers allowed per nameserver.
  1359. *
  1360. * Requires:
  1361. *\li 'zmgr' to be a valid zone manager
  1362. */
  1363. isc_uint32_t
  1364. dns_zonemgr_getttransfersperns(dns_zonemgr_t *zmgr);
  1365. /*%<
  1366. * Return the number of transfers allowed per nameserver.
  1367. *
  1368. * Requires:
  1369. *\li 'zmgr' to be a valid zone manager.
  1370. */
  1371. void
  1372. dns_zonemgr_setiolimit(dns_zonemgr_t *zmgr, isc_uint32_t iolimit);
  1373. /*%<
  1374. * Set the number of simultaneous file descriptors available for
  1375. * reading and writing masterfiles.
  1376. *
  1377. * Requires:
  1378. *\li 'zmgr' to be a valid zone manager.
  1379. *\li 'iolimit' to be positive.
  1380. */
  1381. isc_uint32_t
  1382. dns_zonemgr_getiolimit(dns_zonemgr_t *zmgr);
  1383. /*%<
  1384. * Get the number of simultaneous file descriptors available for
  1385. * reading and writing masterfiles.
  1386. *
  1387. * Requires:
  1388. *\li 'zmgr' to be a valid zone manager.
  1389. */
  1390. void
  1391. dns_zonemgr_setserialqueryrate(dns_zonemgr_t *zmgr, unsigned int value);
  1392. /*%<
  1393. * Set the number of SOA queries sent per second.
  1394. *
  1395. * Requires:
  1396. *\li 'zmgr' to be a valid zone manager
  1397. */
  1398. unsigned int
  1399. dns_zonemgr_getserialqueryrate(dns_zonemgr_t *zmgr);
  1400. /*%<
  1401. * Return the number of SOA queries sent per second.
  1402. *
  1403. * Requires:
  1404. *\li 'zmgr' to be a valid zone manager.
  1405. */
  1406. unsigned int
  1407. dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state);
  1408. /*%<
  1409. * Returns the number of zones in the specified state.
  1410. *
  1411. * Requires:
  1412. *\li 'zmgr' to be a valid zone manager.
  1413. *\li 'state' to be a valid DNS_ZONESTATE_ constant.
  1414. */
  1415. void
  1416. dns_zonemgr_unreachableadd(dns_zonemgr_t *zmgr, isc_sockaddr_t *remote,
  1417. isc_sockaddr_t *local, isc_time_t *now);
  1418. /*%<
  1419. * Add the pair of addresses to the unreachable cache.
  1420. *
  1421. * Requires:
  1422. *\li 'zmgr' to be a valid zone manager.
  1423. *\li 'remote' to be a valid sockaddr.
  1424. *\li 'local' to be a valid sockaddr.
  1425. */
  1426. isc_boolean_t
  1427. dns_zonemgr_unreachable(dns_zonemgr_t *zmgr, isc_sockaddr_t *remote,
  1428. isc_sockaddr_t *local, isc_time_t *now);
  1429. /*%<
  1430. * Returns ISC_TRUE if the given local/remote address pair
  1431. * is found in the zone maanger's unreachable cache.
  1432. *
  1433. * Requires:
  1434. *\li 'zmgr' to be a valid zone manager.
  1435. *\li 'remote' to be a valid sockaddr.
  1436. *\li 'local' to be a valid sockaddr.
  1437. *\li 'now' != NULL
  1438. */
  1439. void
  1440. dns_zonemgr_unreachabledel(dns_zonemgr_t *zmgr, isc_sockaddr_t *remote,
  1441. isc_sockaddr_t *local);
  1442. /*%<
  1443. * Remove the pair of addresses from the unreachable cache.
  1444. *
  1445. * Requires:
  1446. *\li 'zmgr' to be a valid zone manager.
  1447. *\li 'remote' to be a valid sockaddr.
  1448. *\li 'local' to be a valid sockaddr.
  1449. */
  1450. void
  1451. dns_zone_forcereload(dns_zone_t *zone);
  1452. /*%<
  1453. * Force a reload of specified zone.
  1454. *
  1455. * Requires:
  1456. *\li 'zone' to be a valid zone.
  1457. */
  1458. isc_boolean_t
  1459. dns_zone_isforced(dns_zone_t *zone);
  1460. /*%<
  1461. * Check if the zone is waiting a forced reload.
  1462. *
  1463. * Requires:
  1464. * \li 'zone' to be a valid zone.
  1465. */
  1466. isc_result_t
  1467. dns_zone_setstatistics(dns_zone_t *zone, isc_boolean_t on);
  1468. /*%<
  1469. * This function is obsoleted by dns_zone_setrequeststats().
  1470. */
  1471. isc_uint64_t *
  1472. dns_zone_getstatscounters(dns_zone_t *zone);
  1473. /*%<
  1474. * This function is obsoleted by dns_zone_getrequeststats().
  1475. */
  1476. void
  1477. dns_zone_setstats(dns_zone_t *zone, isc_stats_t *stats);
  1478. /*%<
  1479. * Set a general zone-maintenance statistics set 'stats' for 'zone'. This
  1480. * function is expected to be called only on zone creation (when necessary).
  1481. * Once installed, it cannot be removed or replaced. Also, there is no
  1482. * interface to get the installed stats from the zone; the caller must keep the
  1483. * stats to reference (e.g. dump) it later.
  1484. *
  1485. * Requires:
  1486. * \li 'zone' to be a valid zone and does not have a statistics set already
  1487. * installed.
  1488. *
  1489. *\li stats is a valid statistics supporting zone statistics counters
  1490. * (see dns/stats.h).
  1491. */
  1492. void
  1493. dns_zone_setrequeststats(dns_zone_t *zone, isc_stats_t *stats);
  1494. /*%<
  1495. * Set an additional statistics set to zone. It is attached in the zone
  1496. * but is not counted in the zone module; only the caller updates the counters.
  1497. *
  1498. * Requires:
  1499. * \li 'zone' to be a valid zone.
  1500. *
  1501. *\li stats is a valid statistics.
  1502. */
  1503. isc_stats_t *
  1504. dns_zone_getrequeststats(dns_zone_t *zone);
  1505. /*%<
  1506. * Get the additional statistics for zone, if one is installed.
  1507. *
  1508. * Requires:
  1509. * \li 'zone' to be a valid zone.
  1510. *
  1511. * Returns:
  1512. * \li when available, a pointer to the statistics set installed in zone;
  1513. * otherwise NULL.
  1514. */
  1515. void
  1516. dns_zone_dialup(dns_zone_t *zone);
  1517. /*%<
  1518. * Perform dialup-time maintenance on 'zone'.
  1519. */
  1520. void
  1521. dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup);
  1522. /*%<
  1523. * Set the dialup type of 'zone' to 'dialup'.
  1524. *
  1525. * Requires:
  1526. * \li 'zone' to be valid initialised zone.
  1527. *\li 'dialup' to be a valid dialup type.
  1528. */
  1529. void
  1530. dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...)
  1531. ISC_FORMAT_PRINTF(3, 4);
  1532. /*%<
  1533. * Log the message 'msg...' at 'level', including text that identifies
  1534. * the message as applying to 'zone'.
  1535. */
  1536. void
  1537. dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category, int level,
  1538. const char *msg, ...) ISC_FORMAT_PRINTF(4, 5);
  1539. /*%<
  1540. * Log the message 'msg...' at 'level', including text that identifies
  1541. * the message as applying to 'zone'.
  1542. */
  1543. void
  1544. dns_zone_name(dns_zone_t *zone, char *buf, size_t len);
  1545. /*%<
  1546. * Return the name of the zone with class and view.
  1547. *
  1548. * Requires:
  1549. *\li 'zone' to be valid.
  1550. *\li 'buf' to be non NULL.
  1551. */
  1552. isc_result_t
  1553. dns_zone_checknames(dns_zone_t *zone, dns_name_t *name, dns_rdata_t *rdata);
  1554. /*%<
  1555. * Check if this record meets the check-names policy.
  1556. *
  1557. * Requires:
  1558. * 'zone' to be valid.
  1559. * 'name' to be valid.
  1560. * 'rdata' to be valid.
  1561. *
  1562. * Returns:
  1563. * DNS_R_SUCCESS passed checks.
  1564. * DNS_R_BADOWNERNAME failed ownername checks.
  1565. * DNS_R_BADNAME failed rdata checks.
  1566. */
  1567. void
  1568. dns_zone_setacache(dns_zone_t *zone, dns_acache_t *acache);
  1569. /*%<
  1570. * Associate the zone with an additional cache.
  1571. *
  1572. * Require:
  1573. * 'zone' to be a valid zone.
  1574. * 'acache' to be a non NULL pointer.
  1575. *
  1576. * Ensures:
  1577. * 'zone' will have a reference to 'acache'
  1578. */
  1579. void
  1580. dns_zone_setcheckmx(dns_zone_t *zone, dns_checkmxfunc_t checkmx);
  1581. /*%<
  1582. * Set the post load integrity callback function 'checkmx'.
  1583. * 'checkmx' will be called if the MX TARGET is not within the zone.
  1584. *
  1585. * Require:
  1586. * 'zone' to be a valid zone.
  1587. */
  1588. void
  1589. dns_zone_setchecksrv(dns_zone_t *zone, dns_checkmxfunc_t checksrv);
  1590. /*%<
  1591. * Set the post load integrity callback function 'checksrv'.
  1592. * 'checksrv' will be called if the SRV TARGET is not within the zone.
  1593. *
  1594. * Require:
  1595. * 'zone' to be a valid zone.
  1596. */
  1597. void
  1598. dns_zone_setcheckns(dns_zone_t *zone, dns_checknsfunc_t checkns);
  1599. /*%<
  1600. * Set the post load integrity callback function 'checkns'.
  1601. * 'checkns' will be called if the NS TARGET is not within the zone.
  1602. *
  1603. * Require:
  1604. * 'zone' to be a valid zone.
  1605. */
  1606. void
  1607. dns_zone_setnotifydelay(dns_zone_t *zone, isc_uint32_t delay);
  1608. /*%<
  1609. * Set the minimum delay between sets of notify messages.
  1610. *
  1611. * Requires:
  1612. * 'zone' to be valid.
  1613. */
  1614. isc_uint32_t
  1615. dns_zone_getnotifydelay(dns_zone_t *zone);
  1616. /*%<
  1617. * Get the minimum delay between sets of notify messages.
  1618. *
  1619. * Requires:
  1620. * 'zone' to be valid.
  1621. */
  1622. void
  1623. dns_zone_setisself(dns_zone_t *zone, dns_isselffunc_t isself, void *arg);
  1624. /*%<
  1625. * Set the isself callback function and argument.
  1626. *
  1627. * isc_boolean_t
  1628. * isself(dns_view_t *myview, dns_tsigkey_t *mykey, isc_netaddr_t *srcaddr,
  1629. * isc_netaddr_t *destaddr, dns_rdataclass_t rdclass, void *arg);
  1630. *
  1631. * 'isself' returns ISC_TRUE if a non-recursive query from 'srcaddr' to
  1632. * 'destaddr' with optional key 'mykey' for class 'rdclass' would be
  1633. * delivered to 'myview'.
  1634. */
  1635. void
  1636. dns_zone_setnodes(dns_zone_t *zone, isc_uint32_t nodes);
  1637. /*%<
  1638. * Set the number of nodes that will be checked per quantum.
  1639. */
  1640. void
  1641. dns_zone_setsignatures(dns_zone_t *zone, isc_uint32_t signatures);
  1642. /*%<
  1643. * Set the number of signatures that will be generated per quantum.
  1644. */
  1645. isc_result_t
  1646. dns_zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm,
  1647. isc_uint16_t keyid, isc_boolean_t delete);
  1648. /*%<
  1649. * Initiate/resume signing of the entire zone with the zone DNSKEY(s)
  1650. * that match the given algorithm and keyid.
  1651. */
  1652. isc_result_t
  1653. dns_zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param);
  1654. /*%<
  1655. * Incrementally add a NSEC3 chain that corresponds to 'nsec3param'.
  1656. */
  1657. void
  1658. dns_zone_setprivatetype(dns_zone_t *zone, dns_rdatatype_t type);
  1659. dns_rdatatype_t
  1660. dns_zone_getprivatetype(dns_zone_t *zone);
  1661. /*
  1662. * Get/Set the private record type. It is expected that these interfaces
  1663. * will not be permanent.
  1664. */
  1665. void
  1666. dns_zone_rekey(dns_zone_t *zone, isc_boolean_t fullsign);
  1667. /*%<
  1668. * Update the zone's DNSKEY set from the key repository.
  1669. *
  1670. * If 'fullsign' is true, trigger an immediate full signing of
  1671. * the zone with the new key. Otherwise, if there are no keys or
  1672. * if the new keys are for algorithms that have already signed the
  1673. * zone, then the zone can be re-signed incrementally.
  1674. */
  1675. isc_result_t
  1676. dns_zone_nscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version,
  1677. unsigned int *errors);
  1678. /*%
  1679. * Check if the name servers for the zone are sane (have address, don't
  1680. * refer to CNAMEs/DNAMEs. The number of constiancy errors detected in
  1681. * returned in '*errors'
  1682. *
  1683. * Requires:
  1684. * \li 'zone' to be valid.
  1685. * \li 'db' to be valid.
  1686. * \li 'version' to be valid or NULL.
  1687. * \li 'errors' to be non NULL.
  1688. *
  1689. * Returns:
  1690. * ISC_R_SUCCESS if there were no errors examining the zone contents.
  1691. */
  1692. void
  1693. dns_zone_setadded(dns_zone_t *zone, isc_boolean_t added);
  1694. /*%
  1695. * Sets the value of zone->added, which should be ISC_TRUE for
  1696. * zones that were originally added by "rndc addzone".
  1697. *
  1698. * Requires:
  1699. * \li 'zone' to be valid.
  1700. */
  1701. isc_boolean_t
  1702. dns_zone_getadded(dns_zone_t *zone);
  1703. /*%
  1704. * Returns ISC_TRUE if the zone was originally added at runtime
  1705. * using "rndc addzone".
  1706. *
  1707. * Requires:
  1708. * \li 'zone' to be valid.
  1709. */
  1710. isc_result_t
  1711. dns_zone_dlzpostload(dns_zone_t *zone, dns_db_t *db);
  1712. /*%
  1713. * Load the origin names for a writeable DLZ database.
  1714. */
  1715. isc_result_t
  1716. dns_zone_synckeyzone(dns_zone_t *zone);
  1717. /*%
  1718. * Force the managed key zone to synchronize, and start the key
  1719. * maintenance timer.
  1720. */
  1721. ISC_LANG_ENDDECLS
  1722. #endif /* DNS_ZONE_H */