📄 zone.h
字号:
/* * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *//* $Id: zone.h,v 1.106.2.7 2003/03/06 04:38:22 marka Exp $ */#ifndef DNS_ZONE_H#define DNS_ZONE_H 1/*** *** Imports ***/#include <stdio.h>#include <isc/formatcheck.h>#include <isc/lang.h>#include <isc/rwlock.h>#include <dns/types.h>typedef enum { dns_zone_none, dns_zone_master, dns_zone_slave, dns_zone_stub} dns_zonetype_t;#define DNS_ZONEOPT_SERVERS 0x00000001U /* perform server checks */#define DNS_ZONEOPT_PARENTS 0x00000002U /* perform parent checks */#define DNS_ZONEOPT_CHILDREN 0x00000004U /* perform child checks */#define DNS_ZONEOPT_NOTIFY 0x00000008U /* perform NOTIFY */#define DNS_ZONEOPT_MANYERRORS 0x00000010U /* return many errors on load */#define DNS_ZONEOPT_NOMERGE 0x00000040U /* don't merge journal */#ifndef NOMINUM_PUBLIC/* * Nominum specific options build down. */#define DNS_ZONEOPT_NOTIFYFORWARD 0x80000000U /* forward notify to master */#endif /* NOMINUM_PUBLIC */#ifndef DNS_ZONE_MINREFRESH#define DNS_ZONE_MINREFRESH 300 /* 5 minutes */#endif#ifndef DNS_ZONE_MAXREFRESH#define DNS_ZONE_MAXREFRESH 2419200 /* 4 weeks */#endif#ifndef DNS_ZONE_DEFAULTREFRESH#define DNS_ZONE_DEFAULTREFRESH 3600 /* 1 hour */#endif#ifndef DNS_ZONE_MINRETRY#define DNS_ZONE_MINRETRY 300 /* 5 minutes */#endif#ifndef DNS_ZONE_MAXRETRY#define DNS_ZONE_MAXRETRY 1209600 /* 2 weeks */#endif#ifndef DNS_ZONE_DEFAULTRETRY#define DNS_ZONE_DEFAULTRETRY 60 /* 1 minute, subject to exponential backoff */#endif#define DNS_ZONESTATE_XFERRUNNING 1#define DNS_ZONESTATE_XFERDEFERRED 2#define DNS_ZONESTATE_SOAQUERY 3#define DNS_ZONESTATE_ANY 4ISC_LANG_BEGINDECLS/*** *** Functions ***/isc_result_tdns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx);/* * Creates a new empty zone and attach '*zonep' to it. * * Requires: * 'zonep' to point to a NULL pointer. * 'mctx' to be a valid memory context. * * Ensures: * '*zonep' refers to a valid zone. * * Returns: * ISC_R_SUCCESS * ISC_R_NOMEMORY * ISC_R_UNEXPECTED */voiddns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass);/* * Sets the class of a zone. This operation can only be performed * once on a zone. * * Require: * 'zone' to be a valid zone. * dns_zone_setclass() not to have been called since the zone was * created. * 'rdclass' != dns_rdataclass_none. */dns_rdataclass_tdns_zone_getclass(dns_zone_t *zone);/* * Returns the current zone class. * * Requires: * 'zone' to be a valid zone. */voiddns_zone_settype(dns_zone_t *zone, dns_zonetype_t type);/* * Sets the zone type. This operation can only be performed once on * a zone. * * Requires: * 'zone' to be a valid zone. * dns_zone_settype() not to have been called since the zone was * created. * 'type' != dns_zone_none */voiddns_zone_setview(dns_zone_t *zone, dns_view_t *view);/* * Associate the zone with a view. * * Require: * 'zone' to be a valid zone. */dns_view_t *dns_zone_getview(dns_zone_t *zone);/* * Returns the zone's associated view. * * Requires: * 'zone' to be a valid zone. */isc_result_tdns_zone_setorigin(dns_zone_t *zone, dns_name_t *origin);/* * Sets the zones origin to 'origin'. * * Require: * 'zone' to be a valid zone. * 'origin' to be non NULL. * * Returns: * ISC_R_SUCCESS * ISC_R_NOMEMORY */dns_name_t *dns_zone_getorigin(dns_zone_t *zone);/* * Returns the value of the origin. * * Require: * 'zone' to be a valid zone. */isc_result_tdns_zone_setfile(dns_zone_t *zone, const char *file);/* * Sets the name of the master file from which the zone * loads its database to 'file'. For zones that have * no associated master file, 'file' will be NULL. * * For zones with persistent databases, the file name * setting is ignored. * * Require: * 'zone' to be a valid zone. * * Returns: * ISC_R_NOMEMORY * ISC_R_SUCCESS */const char *dns_zone_getfile(dns_zone_t *zone);/* * Gets the name of the zone's master file, if any. * * Requires: * 'zone' to be valid initialised zone. * * Returns: * Pointer to null-terminated file name, or NULL. */isc_result_tdns_zone_load(dns_zone_t *zone);isc_result_tdns_zone_loadnew(dns_zone_t *zone);/* * Cause the database to be loaded from its backing store. * Confirm that the minimum requirements for the zone type are * met, otherwise DNS_R_BADZONE is returned. * * dns_zone_loadnew() only loads zones that are not yet loaded. * dns_zone_load() also loads zones that are already loaded and * and whose master file has changed since the last load. * * Require: * 'zone' to be a valid zone. * * Returns: * ISC_R_UNEXPECTED * ISC_R_SUCCESS * DNS_R_BADZONE * Any result value from dns_db_load(). */voiddns_zone_attach(dns_zone_t *source, dns_zone_t **target);/* * Attach '*target' to 'source' incrementing its external * reference count. * * Require: * 'zone' to be a valid zone. * 'target' to be non NULL and '*target' to be NULL. */voiddns_zone_detach(dns_zone_t **zonep);/* * Detach from a zone decrementing its external reference count. * If this was the last external reference to the zone it will be * shut down and eventually freed. * * Require: * 'zonep' to point to a valid zone. */voiddns_zone_iattach(dns_zone_t *source, dns_zone_t **target);/* * Attach '*target' to 'source' incrementing its internal * reference count. This is intended for use by operations * such as zone transfers that need to prevent the zone * object from being freed but not from shutting down. * * Require: * The caller is running in the context of the zone's task. * 'zone' to be a valid zone. * 'target' to be non NULL and '*target' to be NULL. */voiddns_zone_idetach(dns_zone_t **zonep);/* * Detach from a zone decrementing its internal reference count. * If there are no more internal or external references to the * zone, it will be freed. * * Require: * The caller is running in the context of the zone's task. * 'zonep' to point to a valid zone. */voiddns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value);/* * Sets ('value' == 'ISC_TRUE') / clears ('value' == 'IS_FALSE') * zone flags. Valid flag bits are DNS_ZONE_F_*. * * Requires * 'zone' to be a valid zone. */isc_result_tdns_zone_getdb(dns_zone_t *zone, dns_db_t **dbp);/* * Attach '*dbp' to the database to if it exists otherwise * return DNS_R_NOTLOADED. * * Require: * 'zone' to be a valid zone. * 'dbp' to be != NULL && '*dbp' == NULL. * * Returns: * ISC_R_SUCCESS * DNS_R_NOTLOADED */isc_result_tdns_zone_setdbtype(dns_zone_t *zone, unsigned int dbargc, const char * const *dbargv);/* * Sets the database type to dbargv[0] and database arguments * to subsequent dbargv elements. * 'db_type' is not checked to see if it is a valid database type. * * Require: * 'zone' to be a valid zone. * 'database' to be non NULL. * 'dbargc' to be >= 1 * 'dbargv' to point to dbargc NULL-terminated strings * * Returns: * ISC_R_NOMEMORY * ISC_R_SUCCESS */voiddns_zone_markdirty(dns_zone_t *zone);/* * Mark a zone as 'dirty'. * * Require: * 'zone' to be a valid zone. */voiddns_zone_expire(dns_zone_t *zone);/* * Mark the zone as expired. If the zone requires dumping cause it to * be initiated. Set the refresh and retry intervals to there default * values and unload the zone. * * Require * 'zone' to be a valid zone. */voiddns_zone_refresh(dns_zone_t *zone);/* * Initiate zone up to date checks. The zone must already be being * managed. * * Require * 'zone' to be a valid zone. */isc_result_tdns_zone_flush(dns_zone_t *zone);/* * Write the zone to database if there are uncommited changes. * * Require: * 'zone' to be a valid zone. */isc_result_tdns_zone_dump(dns_zone_t *zone);/* * Write the zone to database. * * Require: * 'zone' to be a valid zone. */isc_result_tdns_zone_dumptostream(dns_zone_t *zone, FILE *fd);/* * Write the zone to stream 'fd'. * * Require: * 'zone' to be a valid zone. * 'fd' to be a stream open for writing. */voiddns_zone_maintenance(dns_zone_t *zone);/* * Perform regular maintenace on the zone. This is called as a * result of a zone being managed. * * Require * 'zone' to be a valid zone. */isc_result_tdns_zone_setmasters(dns_zone_t *zone, isc_sockaddr_t *masters, isc_uint32_t count);isc_result_tdns_zone_setmasterswithkeys(dns_zone_t *zone, isc_sockaddr_t *masters, dns_name_t **keynames, isc_uint32_t count);/* * Set the list of master servers for the zone. * * Require: * 'zone' to be a valid zone. * 'masters' array of isc_sockaddr_t with port set or NULL. * 'count' the number of masters. * 'keynames' array of dns_name_t's for tsig keys or NULL. * * dns_zone_setmasters() is just a wrapper to setmasterswithkeys(), * passing NULL in the keynames field. * * If 'masters' is NULL then 'count' must be zero. * * Returns: * ISC_R_SUCCESS * ISC_R_NOMEMORY * Any result dns_name_dup() can return, if keynames!=NULL */isc_result_tdns_zone_setalsonotify(dns_zone_t *zone, isc_sockaddr_t *notify, isc_uint32_t count);/* * Set the list of additional servers to be notified when * a zone changes. To clear the list use 'count = 0'. * * Require: * 'zone' to be a valid zone. * 'notify' to be non-NULL if count != 0. * 'count' to be the number of notifyees * * Returns: * ISC_R_SUCCESS * ISC_R_NOMEMORY */voiddns_zone_unload(dns_zone_t *zone);/* * detach the database from the zone structure. * * Require: * 'zone' to be a valid zone. */voiddns_zone_setoption(dns_zone_t *zone, unsigned int option, isc_boolean_t value);/* * Set given options on ('value' == ISC_TRUE) or off ('value' == * ISC_FALSE). * * Require: * 'zone' to be a valid zone. */unsigned intdns_zone_getoptions(dns_zone_t *zone);/* * Returns the current zone options. * * Require: * 'zone' to be a valid zone. */voiddns_zone_setminrefreshtime(dns_zone_t *zone, isc_uint32_t val);/* * Set the minimum refresh time. * * Requires: * 'zone' is valid. * val > 0. */voiddns_zone_setmaxrefreshtime(dns_zone_t *zone, isc_uint32_t val);/* * Set the maximum refresh time. * * Requires: * 'zone' is valid. * val > 0. */voiddns_zone_setminretrytime(dns_zone_t *zone, isc_uint32_t val);/* * Set the minimum retry time. * * Requires: * 'zone' is valid. * val > 0. */voiddns_zone_setmaxretrytime(dns_zone_t *zone, isc_uint32_t val);/* * Set the maximum retry time. * * Requires: * 'zone' is valid. * val > 0. */isc_result_tdns_zone_setxfrsource4(dns_zone_t *zone, isc_sockaddr_t *xfrsource);/* * Set the source address to be used in IPv4 zone transfers. * * Require: * 'zone' to be a valid zone. * 'xfrsource' to contain the address. * * Returns: * ISC_R_SUCCESS */isc_sockaddr_t *dns_zone_getxfrsource4(dns_zone_t *zone);/* * Returns the source address set by a previous dns_zone_setxfrsource4 * call, or the default of inaddr_any, port 0. * * Require: * 'zone' to be a valid zone. */isc_result_tdns_zone_setxfrsource6(dns_zone_t *zone, isc_sockaddr_t *xfrsource);/* * Set the source address to be used in IPv6 zone transfers. * * Require: * 'zone' to be a valid zone. * 'xfrsource' to contain the address. * * Returns: * ISC_R_SUCCESS */isc_sockaddr_t *dns_zone_getxfrsource6(dns_zone_t *zone);/* * Returns the source address set by a previous dns_zone_setxfrsource6 * call, or the default of in6addr_any, port 0. * * Require: * 'zone' to be a valid zone. */isc_result_tdns_zone_setnotifysrc4(dns_zone_t *zone, isc_sockaddr_t *notifysrc);/* * Set the source address to be used with IPv4 NOTIFY messages. * * Require: * 'zone' to be a valid zone. * 'notifysrc' to contain the address. * * Returns: * ISC_R_SUCCESS */isc_sockaddr_t *dns_zone_getnotifysrc4(dns_zone_t *zone);/* * Returns the source address set by a previous dns_zone_setnotifysrc4 * call, or the default of inaddr_any, port 0. * * Require: * 'zone' to be a valid zone. */isc_result_tdns_zone_setnotifysrc6(dns_zone_t *zone, isc_sockaddr_t *notifysrc);/* * Set the source address to be used with IPv6 NOTIFY messages. * * Require: * 'zone' to be a valid zone. * 'notifysrc' to contain the address. * * Returns: * ISC_R_SUCCESS */isc_sockaddr_t *dns_zone_getnotifysrc6(dns_zone_t *zone);/* * Returns the source address set by a previous dns_zone_setnotifysrc6 * call, or the default of in6addr_any, port 0. * * Require: * 'zone' to be a valid zone. */voiddns_zone_setnotifyacl(dns_zone_t *zone, dns_acl_t *acl);/* * Sets the notify acl list for the zone. * * Require: * 'zone' to be a valid zone. * 'acl' to be a valid acl. */voiddns_zone_setqueryacl(dns_zone_t *zone, dns_acl_t *acl);/* * Sets the query acl list for the zone. * * Require: * 'zone' to be a valid zone. * 'acl' to be a valid acl. */voiddns_zone_setupdateacl(dns_zone_t *zone, dns_acl_t *acl);/* * Sets the update acl list for the zone. * * Require: * 'zone' to be a valid zone. * 'acl' to be valid acl. */voiddns_zone_setforwardacl(dns_zone_t *zone, dns_acl_t *acl);/* * Sets the forward unsigned updates acl list for the zone. * * Require: * 'zone' to be a valid zone. * 'acl' to be valid acl. */voiddns_zone_setxfracl(dns_zone_t *zone, dns_acl_t *acl);/* * Sets the transfer acl list for the zone. * * Require: * 'zone' to be a valid zone. * 'acl' to be valid acl. */dns_acl_t *dns_zone_getnotifyacl(dns_zone_t *zone);/* * Returns the current notify acl or NULL. * * Require: * 'zone' to be a valid zone. * * Returns: * acl a pointer to the acl. * NULL */dns_acl_t *dns_zone_getqueryacl(dns_zone_t *zone);/* * Returns the current query acl or NULL.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -