zoneconf.c revision 54477d367bb80484ba8e9ca4eac43c0c317d4968
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt/*
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Copyright (C) 1999, 2000 Internet Software Consortium.
c8175ece69d986ccd0671bc4d2571b247dfae177Automatic Updater *
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Permission to use, copy, modify, and distribute this software for any
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * purpose with or without fee is hereby granted, provided that the above
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * copyright notice and this permission notice appear in all copies.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt *
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
f83682f368a967d5d27e5c2c52896300efed95f8Mark Andrews
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt/* $Id: zoneconf.c,v 1.62 2000/10/13 23:21:16 bwelling Exp $ */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#include <config.h>
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
bbedadf76ab670b01887fb9b41097120ea4fdf14Evan Hunt#include <isc/mem.h>
bbedadf76ab670b01887fb9b41097120ea4fdf14Evan Hunt#include <isc/string.h> /* Required for HP/UX (and others?) */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#include <isc/util.h>
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#include <dns/acl.h>
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#include <dns/ssu.h>
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#include <dns/zone.h>
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews#include <dns/zoneconf.h>
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews/*
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews * These are BIND9 server defaults, not necessarily identical to the
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews * library defaults defined in zone.c.
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews */
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews#define MAX_XFER_TIME (2*3600) /* Documented default is 2 hours. */
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews#define DNS_DEFAULT_IDLEIN 3600 /* 1 hour */
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews#define DNS_DEFAULT_IDLEOUT 3600 /* 1 hour */
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews#define RETERR(x) do { \
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews isc_result_t _r = (x); \
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews if (_r != ISC_R_SUCCESS) \
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews return (_r); \
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews } while (0)
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews/*
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews * Convenience function for configuring a single zone ACL.
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews */
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrewsstatic isc_result_t
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrewsconfigure_zone_acl(dns_c_zone_t *czone, dns_c_ctx_t *cctx, dns_c_view_t *cview,
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews dns_aclconfctx_t *aclconfctx, dns_zone_t *zone,
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews isc_result_t (*getcacl)(dns_c_zone_t *,
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews dns_c_ipmatchlist_t **),
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews isc_result_t (*getviewcacl)(dns_c_view_t *
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews , dns_c_ipmatchlist_t **),
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews isc_result_t (*getglobalcacl)(dns_c_ctx_t *,
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews dns_c_ipmatchlist_t **),
ba88bcf08b965f65c07735efa2f675b8cbeb735aMark Andrews void (*setzacl)(dns_zone_t *, dns_acl_t *),
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews void (*clearzacl)(dns_zone_t *))
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews{
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews isc_result_t result;
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews dns_c_ipmatchlist_t *cacl;
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews dns_acl_t *dacl = NULL;
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews result = (*getcacl)(czone, &cacl);
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews if (result == ISC_R_NOTFOUND && getviewcacl != NULL && cview != NULL) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt result = (*getviewcacl)(cview, &cacl);
e24ccb512c110d181e01f977196e518b0e72e451Mark Andrews }
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt if (result == ISC_R_NOTFOUND && getglobalcacl != NULL) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt result = (*getglobalcacl)(cctx, &cacl);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt }
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt if (result == ISC_R_SUCCESS) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt result = dns_acl_fromconfig(cacl, cctx, aclconfctx,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_zone_getmctx(zone), &dacl);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_c_ipmatchlist_detach(&cacl);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt if (result != ISC_R_SUCCESS)
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt return (result);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt (*setzacl)(zone, dacl);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_acl_detach(&dacl);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt return (ISC_R_SUCCESS);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt } else if (result == ISC_R_NOTFOUND) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt (*clearzacl)(zone);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt return (ISC_R_SUCCESS);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt } else {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt return (result);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt }
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt}
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt/*
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Conver a config file zone type into a server zone type.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntstatic dns_zonetype_t
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntdns_zonetype_fromconf(dns_c_zonetype_t cztype) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt switch (cztype) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt case dns_c_zone_master:
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return dns_zone_master;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt case dns_c_zone_slave:
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return dns_zone_slave;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt case dns_c_zone_stub:
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return dns_zone_stub;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt default:
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt /*
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Hint and forward zones are not really zones;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * they should never get this far.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt INSIST(0);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (dns_zone_none); /*NOTREACHED*/
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt }
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt}
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt/*
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * Helper function for strtoargv(). Pardon the gratuitous recursion.
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt */
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic isc_result_t
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstrtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt char ***argvp, unsigned int n)
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt{
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_result_t result;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt /* Discard leading whitespace. */
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt while (*s == ' ' || *s == '\t')
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt s++;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt if (*s == '\0') {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt /* We have reached the end of the string. */
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt *argcp = n;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt *argvp = isc_mem_get(mctx, n * sizeof(char *));
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt if (*argvp == NULL)
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt return (ISC_R_NOMEMORY);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt } else {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt char *p = s;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt while (*p != ' ' && *p != '\t' && *p != '\0')
36b2d5f93c22b096c0417495f27ae0bdebf06ae1Evan Hunt p++;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (*p != '\0')
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt *p++ = '\0';
36b2d5f93c22b096c0417495f27ae0bdebf06ae1Evan Hunt
36b2d5f93c22b096c0417495f27ae0bdebf06ae1Evan Hunt result = strtoargvsub(mctx, p, argcp, argvp, n + 1);
36b2d5f93c22b096c0417495f27ae0bdebf06ae1Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (result);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt (*argvp)[n] = s;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt }
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt return (ISC_R_SUCCESS);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt}
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt/*
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * Tokenize the string "s" into whitespace-separated words,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * return the number of words in '*argcp' and an array
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * of pointers to the words in '*argvp'. The caller
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * must free the array using isc_mem_put(). The string
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * is modified in-place.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic isc_result_t
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstrtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) {
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt return (strtoargvsub(mctx, s, argcp, argvp, 0));
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt}
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntisc_result_t
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntdns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_c_zone_t *czone, dns_aclconfctx_t *ac,
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_zone_t *zone)
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt{
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_result_t result;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_boolean_t boolean;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt const char *filename = NULL;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_notifytype_t notifytype;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt#ifdef notyet
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_c_severity_t severity;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt#endif
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_c_iplist_t *iplist;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_sockaddr_t sockaddr;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_uint32_t uintval;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_sockaddr_t sockaddr_any4, sockaddr_any6;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt dns_ssutable_t *ssutable = NULL;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt char *cpval;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt unsigned int dbargc;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt char **dbargv;
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt static char default_dbtype[] = "rbt";
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_mem_t *mctx = dns_zone_getmctx(zone);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt isc_sockaddr_any(&sockaddr_any4);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt isc_sockaddr_any6(&sockaddr_any6);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt /*
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * Configure values common to all zone types.
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt */
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt dns_zone_setclass(zone, czone->zclass);
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt dns_zone_settype(zone, dns_zonetype_fromconf(czone->ztype));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt cpval = NULL;
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt result = dns_c_zone_getdatabase(czone, &cpval);
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt#ifdef notyet
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt result = dns_c_view_getdatabase(cview, &cpval);
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt if (result != ISC_R_SUCCESS)
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt result = dns_c_ctx_getdatabase(cview, &cpval);
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt#endif
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt if (result != ISC_R_SUCCESS)
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt cpval = default_dbtype;
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt RETERR(strtoargv(mctx, cpval, &dbargc, &dbargv));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt /*
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * ANSI C is strange here. There is no logical reason why (char **)
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * cannot be promoted automatically to (const char * const *) by the
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * compiler w/o generating a warning.
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt */
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt RETERR(dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt result = dns_c_zone_getfile(czone, &filename);
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt if (result == ISC_R_SUCCESS)
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt RETERR(dns_zone_setdatabase(zone, filename));
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt else if (czone->ztype != dns_c_zone_slave &&
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt czone->ztype != dns_c_zone_stub)
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt return (result);
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt#ifdef notyet
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt result = dns_c_zone_getchecknames(czone, &severity);
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt if (result == ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setchecknames(zone, severity);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt else
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setchecknames(zone, dns_c_severity_warn);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#endif
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#ifndef NOMINUM_PUBLIC
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (czone->ztype == dns_c_zone_slave)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_zone_getallownotify,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_view_getallownotify,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_ctx_getallownotify,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setnotifyacl,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_clearnotifyacl));
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#endif /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt /*
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * XXXAG This probably does not make sense for stubs.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_zone_getallowquery,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_view_getallowquery,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_ctx_getallowquery,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setqueryacl,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_clearqueryacl));
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getdialup(czone, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getdialup(cctx, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt boolean = ISC_FALSE;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setoption(zone, DNS_ZONEOPT_DIALUP, boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#ifndef NOMINUM_PUBLIC
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (czone->ztype != dns_c_zone_stub) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxnames(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getmaxnames(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxnames(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = 0;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setmaxnames(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt }
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (czone->ztype == dns_c_zone_slave) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getnotifyforward(czone, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getnotifyforward(cview, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getnotifyforward(cctx, &boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt boolean = ISC_FALSE;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setoption(zone, DNS_ZONEOPT_NOTIFYFORWARD, boolean);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt }
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#endif /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt /*
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Configure master functionality. This applies
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * to primary masters (type "master") and slaves
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * acting as masters (type "slave"), but not to stubs.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (czone->ztype != dns_c_zone_stub) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getnotify(czone, &notifytype);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getnotify(cview, &notifytype);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getnotify(cctx, &notifytype);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt notifytype = dns_notifytype_yes;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setnotifytype(zone, notifytype);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt iplist = NULL;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getalsonotify(czone, &iplist);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getalsonotify(cview, &iplist);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getalsonotify(cctx, &iplist);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result == ISC_R_SUCCESS) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_zone_setalsonotify(zone, iplist->ips,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt iplist->nextidx);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_iplist_detach(&iplist);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (result);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt } else
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(dns_zone_setalsonotify(zone, NULL, 0));
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, cview, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_zone_getallowtransfer,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_view_gettransferacl,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_ctx_getallowtransfer,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setxfracl,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_clearxfracl));
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtranstimeout(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getmaxtransfertimeout(cview,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxtransfertimeout(cctx,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = MAX_XFER_TIME;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setmaxxfrout(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtransidleout(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getmaxtransferidleout(cview,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxtransferidleout(cctx,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = DNS_DEFAULT_IDLEOUT;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setidleout(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt }
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt /*
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Configure update-related options. These apply to
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * primary masters only.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (czone->ztype == dns_c_zone_master) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(configure_zone_acl(czone, cctx, NULL, ac, zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_c_zone_getallowupd,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt NULL, NULL,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setupdateacl,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_clearupdateacl));
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getssuauth(czone, &ssutable);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result == ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setssutable(zone, ssutable);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getsigvalidityinterval(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getsigvalidityinterval(cview,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getsigvalidityinterval(cctx,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = 30 * 24 * 3600;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setsigvalidityinterval(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt }
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt /*
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Configure slave functionality.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt switch (czone->ztype) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt case dns_c_zone_slave:
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt case dns_c_zone_stub:
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt iplist = NULL;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmasterips(czone, &iplist);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result == ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#ifndef NOMINUM_PUBLIC
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_zone_setmasterswithkeys(zone,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt iplist->ips,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt iplist->keys,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt iplist->nextidx);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#else /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_zone_setmasters(zone, iplist->ips,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt iplist->nextidx);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt#endif /* NOMINUM_PUBLIC */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt else
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_zone_setmasters(zone, NULL, 0);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt RETERR(result);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtranstimein(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxtransfertimein(cctx,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = MAX_XFER_TIME;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setmaxxfrin(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxtransidlein(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxtransferidlein(cctx,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = DNS_DEFAULT_IDLEIN;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setidlein(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_gettransfersource(czone, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_gettransfersource(cview,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt sockaddr = sockaddr_any4;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setxfrsource4(zone, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_gettransfersourcev6(czone, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_gettransfersourcev6(cview,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_gettransfersourcev6(cctx,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt sockaddr = sockaddr_any6;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setxfrsource6(zone, &sockaddr);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxrefreshtime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getmaxrefreshtime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxrefreshtime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = DNS_ZONE_MAXREFRESH;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setmaxrefreshtime(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getminrefreshtime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getminrefreshtime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getminrefreshtime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = DNS_ZONE_MINREFRESH;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setminrefreshtime(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getmaxretrytime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getmaxretrytime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getmaxretrytime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = DNS_ZONE_MAXRETRY;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setmaxretrytime(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_zone_getminretrytime(czone, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS && cview != NULL)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_view_getminretrytime(cview, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_getminretrytime(cctx, &uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt uintval = DNS_ZONE_MINRETRY;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zone_setminretrytime(zone, uintval);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt break;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt default:
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt break;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt }
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (ISC_R_SUCCESS);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt}
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntisc_boolean_t
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntdns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt const char *cfilename;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt const char *zfilename;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (dns_zonetype_fromconf(czone->ztype) != dns_zone_gettype(zone))
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (ISC_FALSE);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt cfilename = NULL;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt (void) dns_c_zone_getfile(czone, &cfilename);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt zfilename = dns_zone_getdatabase(zone);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (cfilename == NULL || zfilename == NULL ||
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt strcmp(cfilename, zfilename) != 0)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (ISC_FALSE);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (ISC_TRUE);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt}
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntisc_result_t
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntdns_zonemgr_configure(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt isc_uint32_t val;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt isc_result_t result;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_gettransfersin(cctx, &val);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt val = 10;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zonemgr_settransfersin(zmgr, val);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt result = dns_c_ctx_gettransfersperns(cctx, &val);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt if (result != ISC_R_SUCCESS)
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt val = 2;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt dns_zonemgr_settransfersperns(zmgr, val);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt return (ISC_R_SUCCESS);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt}
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt