📄 zone.h
字号:
/* * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * 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 ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS. IN NO EVENT SHALL ISC 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.126.18.19 2006/08/01 03:45:21 marka Exp $ */#ifndef DNS_ZONE_H#define DNS_ZONE_H 1/*! \file *//*** *** Imports ***/#include <stdio.h>#include <isc/formatcheck.h>#include <isc/lang.h>#include <isc/rwlock.h>#include <dns/masterdump.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_IXFRFROMDIFFS 0x00000020U /*%< calculate differences */#define DNS_ZONEOPT_NOMERGE 0x00000040U /*%< don't merge journal */#define DNS_ZONEOPT_CHECKNS 0x00000080U /*%< check if NS's are addresses */#define DNS_ZONEOPT_FATALNS 0x00000100U /*%< DNS_ZONEOPT_CHECKNS is fatal */#define DNS_ZONEOPT_MULTIMASTER 0x00000200U /*%< this zone has multiple masters */#define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /*%< use alternate transfer sources */#define DNS_ZONEOPT_CHECKNAMES 0x00000800U /*%< check-names */#define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /*%< fatal check-name failures */#define DNS_ZONEOPT_CHECKWILDCARD 0x00002000U /*%< check for internal wildcards */#define DNS_ZONEOPT_CHECKMX 0x00004000U /*%< check-mx */#define DNS_ZONEOPT_CHECKMXFAIL 0x00008000U /*%< fatal check-mx failures */#define DNS_ZONEOPT_CHECKINTEGRITY 0x00010000U /*%< perform integrity checks */#define DNS_ZONEOPT_CHECKSIBLING 0x00020000U /*%< perform sibling glue checks */#define DNS_ZONEOPT_NOCHECKNS 0x00040000U /*%< disable IN NS address checks */#define DNS_ZONEOPT_WARNMXCNAME 0x00080000U /*%< warn on MX CNAME check */#define DNS_ZONEOPT_IGNOREMXCNAME 0x00100000U /*%< ignore MX CNAME check */#define DNS_ZONEOPT_WARNSRVCNAME 0x00200000U /*%< warn on SRV CNAME check */#define DNS_ZONEOPT_IGNORESRVCNAME 0x00400000U /*%< ignore SRV CNAME check */#define DNS_ZONEOPT_UPDATECHECKKSK 0x00800000U /*%< check dnskey KSK flag */#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: *\li 'zonep' to point to a NULL pointer. *\li 'mctx' to be a valid memory context. * * Ensures: *\li '*zonep' refers to a valid zone. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOMEMORY *\li #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: *\li 'zone' to be a valid zone. *\li dns_zone_setclass() not to have been called since the zone was * created. *\li 'rdclass' != dns_rdataclass_none. */dns_rdataclass_tdns_zone_getclass(dns_zone_t *zone);/*%< * Returns the current zone class. * * Requires: *\li '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: *\li 'zone' to be a valid zone. *\li dns_zone_settype() not to have been called since the zone was * created. *\li 'type' != dns_zone_none */voiddns_zone_setview(dns_zone_t *zone, dns_view_t *view);/*%< * Associate the zone with a view. * * Require: *\li 'zone' to be a valid zone. */dns_view_t *dns_zone_getview(dns_zone_t *zone);/*%< * Returns the zone's associated view. * * Requires: *\li 'zone' to be a valid zone. */isc_result_tdns_zone_setorigin(dns_zone_t *zone, const dns_name_t *origin);/*%< * Sets the zones origin to 'origin'. * * Require: *\li 'zone' to be a valid zone. *\li 'origin' to be non NULL. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOMEMORY */dns_name_t *dns_zone_getorigin(dns_zone_t *zone);/*%< * Returns the value of the origin. * * Require: *\li 'zone' to be a valid zone. */isc_result_tdns_zone_setfile(dns_zone_t *zone, const char *file);isc_result_tdns_zone_setfile2(dns_zone_t *zone, const char *file, dns_masterformat_t format);/*%< * Sets the name of the master file in the format of 'format' 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. * * dns_zone_setfile() is a backward-compatible form of * dns_zone_setfile2(), which always specifies the * dns_masterformat_text (RFC1035) format. * * Require: *\li 'zone' to be a valid zone. * * Returns: *\li #ISC_R_NOMEMORY *\li #ISC_R_SUCCESS */const char *dns_zone_getfile(dns_zone_t *zone);/*%< * Gets the name of the zone's master file, if any. * * Requires: *\li 'zone' to be valid initialised zone. * * Returns: *\li 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: *\li 'zone' to be a valid zone. * * Returns: *\li #ISC_R_UNEXPECTED *\li #ISC_R_SUCCESS *\li DNS_R_CONTINUE Incremental load has been queued. *\li DNS_R_UPTODATE The zone has already been loaded based on * file system timestamps. *\li DNS_R_BADZONE *\li 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: *\li 'zone' to be a valid zone. *\li '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: *\li '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: *\li The caller is running in the context of the zone's task. *\li 'zone' to be a valid zone. *\li '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: *\li The caller is running in the context of the zone's task. *\li '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 *\li '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: *\li 'zone' to be a valid zone. *\li 'dbp' to be != NULL && '*dbp' == NULL. * * Returns: *\li #ISC_R_SUCCESS *\li 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: *\li 'zone' to be a valid zone. *\li 'database' to be non NULL. *\li 'dbargc' to be >= 1 *\li 'dbargv' to point to dbargc NULL-terminated strings * * Returns: *\li #ISC_R_NOMEMORY *\li #ISC_R_SUCCESS */isc_result_tdns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx);/*%< * Returns the current dbtype. isc_mem_free() should be used * to free 'argv' after use. * * Require: *\li 'zone' to be a valid zone. *\li 'argv' to be non NULL and *argv to be NULL. *\li 'mctx' to be valid. * * Returns: *\li #ISC_R_NOMEMORY *\li #ISC_R_SUCCESS */voiddns_zone_markdirty(dns_zone_t *zone);/*%< * Mark a zone as 'dirty'. * * Require: *\li '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 *\li '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 *\li '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: *\li 'zone' to be a valid zone. */isc_result_tdns_zone_dump(dns_zone_t *zone);/*%< * Write the zone to database. * * Require: *\li 'zone' to be a valid zone. */isc_result_tdns_zone_dumptostream(dns_zone_t *zone, FILE *fd);isc_result_tdns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, const dns_master_style_t *style);/*%< * Write the zone to stream 'fd' in the specified 'format'. * If the 'format' is dns_masterformat_text (RFC1035), 'style' also * specifies the file style (e.g., &dns_master_style_default). * * dns_zone_dumptostream() is a backward-compatible form of * dns_zone_dumptostream2(), which always uses the dns_masterformat_text * format and the dns_master_style_default style. * * Note that dns_zone_dumptostream2() is the most flexible form. It * can also provide the functionality of dns_zone_fulldumptostream(). * * Require: *\li 'zone' to be a valid zone. *\li 'fd' to be a stream open for writing. */isc_result_tdns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd);/*%< * The same as dns_zone_dumptostream, but dumps the zone with * different dump settings (dns_master_style_full). * * Require: *\li 'zone' to be a valid zone. *\li '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 *\li 'zone' to be a valid zone. */isc_result_tdns_zone_setmasters(dns_zone_t *zone, const isc_sockaddr_t *masters, isc_uint32_t count);isc_result_tdns_zone_setmasterswithkeys(dns_zone_t *zone, const isc_sockaddr_t *masters, dns_name_t **keynames, isc_uint32_t count);/*%< * Set the list of master servers for the zone. * * Require: *\li 'zone' to be a valid zone. *\li 'masters' array of isc_sockaddr_t with port set or NULL. *\li 'count' the number of masters. *\li 'keynames' array of dns_name_t's for tsig keys or NULL. * * \li dns_zone_setmasters() is just a wrapper to setmasterswithkeys(), * passing NULL in the keynames field. * * \li If 'masters' is NULL then 'count' must be zero. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOMEMORY *\li Any result dns_name_dup() can return, if keynames!=NULL */isc_result_tdns_zone_setalsonotify(dns_zone_t *zone, const 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: *\li 'zone' to be a valid zone. *\li 'notify' to be non-NULL if count != 0. *\li 'count' to be the number of notifyees. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOMEMORY */voiddns_zone_unload(dns_zone_t *zone);/*%< * detach the database from the zone structure. * * Require: *\li '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: *\li 'zone' to be a valid zone.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -