server.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2015  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2003  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: server.h,v 1.118 2012/01/31 23:47:31 tbox Exp $ */
00019 
00020 #ifndef NAMED_SERVER_H
00021 #define NAMED_SERVER_H 1
00022 
00023 /*! \file */
00024 
00025 #include <isc/log.h>
00026 #include <isc/magic.h>
00027 #include <isc/quota.h>
00028 #include <isc/sockaddr.h>
00029 #include <isc/types.h>
00030 #include <isc/xml.h>
00031 
00032 #include <dns/acl.h>
00033 #include <dns/types.h>
00034 
00035 #include <named/types.h>
00036 
00037 #define NS_EVENTCLASS           ISC_EVENTCLASS(0x4E43)
00038 #define NS_EVENT_RELOAD         (NS_EVENTCLASS + 0)
00039 #define NS_EVENT_CLIENTCONTROL  (NS_EVENTCLASS + 1)
00040 
00041 /*%
00042  * Name server state.  Better here than in lots of separate global variables.
00043  */
00044 struct ns_server {
00045         unsigned int            magic;
00046         isc_mem_t *             mctx;
00047 
00048         isc_task_t *            task;
00049 
00050         /* Configurable data. */
00051         isc_quota_t             xfroutquota;
00052         isc_quota_t             tcpquota;
00053         isc_quota_t             recursionquota;
00054         dns_acl_t               *blackholeacl;
00055         dns_acl_t               *keepresporder;
00056         char *                  statsfile;      /*%< Statistics file name */
00057         char *                  dumpfile;       /*%< Dump file name */
00058         char *                  secrootsfile;   /*%< Secroots file name */
00059         char *                  bindkeysfile;   /*%< bind.keys file name */
00060         char *                  recfile;        /*%< Recursive file name */
00061         isc_boolean_t           version_set;    /*%< User has set version */
00062         char *                  version;        /*%< User-specified version */
00063         isc_boolean_t           hostname_set;   /*%< User has set hostname */
00064         char *                  hostname;       /*%< User-specified hostname */
00065         /*% Use hostname for server id */
00066         isc_boolean_t           server_usehostname;
00067         char *                  server_id;      /*%< User-specified server id */
00068 
00069         /*%
00070          * Current ACL environment.  This defines the
00071          * current values of the localhost and localnets
00072          * ACLs.
00073          */
00074         dns_aclenv_t            aclenv;
00075 
00076         /* Server data structures. */
00077         dns_loadmgr_t *         loadmgr;
00078         dns_zonemgr_t *         zonemgr;
00079         dns_viewlist_t          viewlist;
00080         ns_interfacemgr_t *     interfacemgr;
00081         dns_db_t *              in_roothints;
00082         dns_tkeyctx_t *         tkeyctx;
00083 
00084         isc_timer_t *           interface_timer;
00085         isc_timer_t *           heartbeat_timer;
00086         isc_timer_t *           pps_timer;
00087 
00088         isc_uint32_t            interface_interval;
00089         isc_uint32_t            heartbeat_interval;
00090 
00091         isc_mutex_t             reload_event_lock;
00092         isc_event_t *           reload_event;
00093 
00094         isc_boolean_t           flushonshutdown;
00095         isc_boolean_t           log_queries;    /*%< For BIND 8 compatibility */
00096 
00097         ns_cachelist_t          cachelist;      /*%< Possibly shared caches */
00098         isc_stats_t *           nsstats;        /*%< Server stats */
00099         dns_stats_t *           rcvquerystats;  /*% Incoming query stats */
00100         dns_stats_t *           opcodestats;    /*%< Incoming message stats */
00101         isc_stats_t *           zonestats;      /*% Zone management stats */
00102         isc_stats_t  *          resolverstats;  /*% Resolver stats */
00103         isc_stats_t *           sockstats;      /*%< Socket stats */
00104 
00105         ns_controls_t *         controls;       /*%< Control channels */
00106         unsigned int            dispatchgen;
00107         ns_dispatchlist_t       dispatches;
00108 
00109         dns_acache_t            *acache;
00110 
00111         ns_statschannellist_t   statschannels;
00112 
00113         dns_tsigkey_t           *sessionkey;
00114         char                    *session_keyfile;
00115         dns_name_t              *session_keyname;
00116         unsigned int            session_keyalg;
00117         isc_uint16_t            session_keybits;
00118         isc_boolean_t           interface_auto;
00119         unsigned char           secret[32];     /*%< Source Identity Token */
00120 
00121         char *                  lockfile;
00122 };
00123 
00124 #define NS_SERVER_MAGIC                 ISC_MAGIC('S','V','E','R')
00125 #define NS_SERVER_VALID(s)              ISC_MAGIC_VALID(s, NS_SERVER_MAGIC)
00126 
00127 /*%
00128  * Server statistics counters.  Used as isc_statscounter_t values.
00129  */
00130 enum {
00131         dns_nsstatscounter_requestv4 = 0,
00132         dns_nsstatscounter_requestv6 = 1,
00133         dns_nsstatscounter_edns0in = 2,
00134         dns_nsstatscounter_badednsver = 3,
00135         dns_nsstatscounter_tsigin = 4,
00136         dns_nsstatscounter_sig0in = 5,
00137         dns_nsstatscounter_invalidsig = 6,
00138         dns_nsstatscounter_requesttcp = 7,
00139 
00140         dns_nsstatscounter_authrej = 8,
00141         dns_nsstatscounter_recurserej = 9,
00142         dns_nsstatscounter_xfrrej = 10,
00143         dns_nsstatscounter_updaterej = 11,
00144 
00145         dns_nsstatscounter_response = 12,
00146         dns_nsstatscounter_truncatedresp = 13,
00147         dns_nsstatscounter_edns0out = 14,
00148         dns_nsstatscounter_tsigout = 15,
00149         dns_nsstatscounter_sig0out = 16,
00150 
00151         dns_nsstatscounter_success = 17,
00152         dns_nsstatscounter_authans = 18,
00153         dns_nsstatscounter_nonauthans = 19,
00154         dns_nsstatscounter_referral = 20,
00155         dns_nsstatscounter_nxrrset = 21,
00156         dns_nsstatscounter_servfail = 22,
00157         dns_nsstatscounter_formerr = 23,
00158         dns_nsstatscounter_nxdomain = 24,
00159         dns_nsstatscounter_recursion = 25,
00160         dns_nsstatscounter_duplicate = 26,
00161         dns_nsstatscounter_dropped = 27,
00162         dns_nsstatscounter_failure = 28,
00163 
00164         dns_nsstatscounter_xfrdone = 29,
00165 
00166         dns_nsstatscounter_updatereqfwd = 30,
00167         dns_nsstatscounter_updaterespfwd = 31,
00168         dns_nsstatscounter_updatefwdfail = 32,
00169         dns_nsstatscounter_updatedone = 33,
00170         dns_nsstatscounter_updatefail = 34,
00171         dns_nsstatscounter_updatebadprereq = 35,
00172 
00173         dns_nsstatscounter_recursclients = 36,
00174 
00175         dns_nsstatscounter_dns64 = 37,
00176 
00177         dns_nsstatscounter_ratedropped = 38,
00178         dns_nsstatscounter_rateslipped = 39,
00179 
00180         dns_nsstatscounter_rpz_rewrites = 40,
00181 
00182         dns_nsstatscounter_udp = 41,
00183         dns_nsstatscounter_tcp = 42,
00184 
00185         dns_nsstatscounter_nsidopt = 43,
00186         dns_nsstatscounter_expireopt = 44,
00187         dns_nsstatscounter_otheropt = 45,
00188         dns_nsstatscounter_ecsopt = 46,
00189 
00190 #ifdef ISC_PLATFORM_USESIT
00191         dns_nsstatscounter_sitopt = 47,
00192         dns_nsstatscounter_sitbadsize = 48,
00193         dns_nsstatscounter_sitbadtime = 49,
00194         dns_nsstatscounter_sitnomatch = 50,
00195         dns_nsstatscounter_sitmatch = 51,
00196         dns_nsstatscounter_sitnew = 52,
00197 
00198         dns_nsstatscounter_max = 53
00199 #else
00200         dns_nsstatscounter_max = 47
00201 #endif
00202 };
00203 
00204 void
00205 ns_server_create(isc_mem_t *mctx, ns_server_t **serverp);
00206 /*%<
00207  * Create a server object with default settings.
00208  * This function either succeeds or causes the program to exit
00209  * with a fatal error.
00210  */
00211 
00212 void
00213 ns_server_destroy(ns_server_t **serverp);
00214 /*%<
00215  * Destroy a server object, freeing its memory.
00216  */
00217 
00218 void
00219 ns_server_reloadwanted(ns_server_t *server);
00220 /*%<
00221  * Inform a server that a reload is wanted.  This function
00222  * may be called asynchronously, from outside the server's task.
00223  * If a reload is already scheduled or in progress, the call
00224  * is ignored.
00225  */
00226 
00227 void
00228 ns_server_scan_interfaces(ns_server_t *server);
00229 /*%<
00230  * Trigger a interface scan.
00231  * Must only be called when running under server->task.
00232  */
00233 
00234 void
00235 ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
00236 /*%<
00237  * Inform the server that the zones should be flushed to disk on shutdown.
00238  */
00239 
00240 isc_result_t
00241 ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t **text);
00242 /*%<
00243  * Act on a "reload" command from the command channel.
00244  */
00245 
00246 isc_result_t
00247 ns_server_reconfigcommand(ns_server_t *server, char *args);
00248 /*%<
00249  * Act on a "reconfig" command from the command channel.
00250  */
00251 
00252 isc_result_t
00253 ns_server_notifycommand(ns_server_t *server, char *args, isc_buffer_t **text);
00254 /*%<
00255  * Act on a "notify" command from the command channel.
00256  */
00257 
00258 isc_result_t
00259 ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t **text);
00260 /*%<
00261  * Act on a "refresh" command from the command channel.
00262  */
00263 
00264 isc_result_t
00265 ns_server_retransfercommand(ns_server_t *server, char *args,
00266                             isc_buffer_t **text);
00267 /*%<
00268  * Act on a "retransfer" command from the command channel.
00269  */
00270 
00271 isc_result_t
00272 ns_server_togglequerylog(ns_server_t *server, char *args);
00273 /*%<
00274  * Enable/disable logging of queries.  (Takes "yes" or "no" argument,
00275  * but can also be used as a toggle for backward comptibility.)
00276  */
00277 
00278 /*%
00279  * Save the current NTAs for all views to files.
00280  */
00281 isc_result_t
00282 ns_server_saventa(ns_server_t *server);
00283 
00284 /*%
00285  * Load NTAs for all views from files.
00286  */
00287 isc_result_t
00288 ns_server_loadnta(ns_server_t *server);
00289 
00290 /*%
00291  * Dump the current statistics to the statistics file.
00292  */
00293 isc_result_t
00294 ns_server_dumpstats(ns_server_t *server);
00295 
00296 /*%
00297  * Dump the current cache to the dump file.
00298  */
00299 isc_result_t
00300 ns_server_dumpdb(ns_server_t *server, char *args);
00301 
00302 /*%
00303  * Dump the current security roots to the secroots file.
00304  */
00305 isc_result_t
00306 ns_server_dumpsecroots(ns_server_t *server, char *args, isc_buffer_t **text);
00307 
00308 /*%
00309  * Change or increment the server debug level.
00310  */
00311 isc_result_t
00312 ns_server_setdebuglevel(ns_server_t *server, char *args);
00313 
00314 /*%
00315  * Flush the server's cache(s)
00316  */
00317 isc_result_t
00318 ns_server_flushcache(ns_server_t *server, char *args);
00319 
00320 /*%
00321  * Flush a particular name from the server's cache.  If 'tree' is false,
00322  * also flush the name from the ADB and badcache.  If 'tree' is true, also
00323  * flush all the names under the specified name.
00324  */
00325 isc_result_t
00326 ns_server_flushnode(ns_server_t *server, char *args, isc_boolean_t tree);
00327 
00328 /*%
00329  * Report the server's status.
00330  */
00331 isc_result_t
00332 ns_server_status(ns_server_t *server, isc_buffer_t **text);
00333 
00334 /*%
00335  * Report a list of dynamic and static tsig keys, per view.
00336  */
00337 isc_result_t
00338 ns_server_tsiglist(ns_server_t *server, isc_buffer_t **text);
00339 
00340 /*%
00341  * Delete a specific key (with optional view).
00342  */
00343 isc_result_t
00344 ns_server_tsigdelete(ns_server_t *server, char *command, isc_buffer_t **text);
00345 
00346 /*%
00347  * Enable or disable updates for a zone.
00348  */
00349 isc_result_t
00350 ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args,
00351                  isc_buffer_t **text);
00352 
00353 /*%
00354  * Dump zone updates to disk, optionally removing the journal file
00355  */
00356 isc_result_t
00357 ns_server_sync(ns_server_t *server, char *args, isc_buffer_t **text);
00358 
00359 /*%
00360  * Update a zone's DNSKEY set from the key repository.  If
00361  * the command that triggered the call to this function was "sign",
00362  * then force a full signing of the zone.  If it was "loadkeys",
00363  * then don't sign the zone; any needed changes to signatures can
00364  * take place incrementally.
00365  */
00366 isc_result_t
00367 ns_server_rekey(ns_server_t *server, char *args, isc_buffer_t **text);
00368 
00369 /*%
00370  * Dump the current recursive queries.
00371  */
00372 isc_result_t
00373 ns_server_dumprecursing(ns_server_t *server);
00374 
00375 /*%
00376  * Maintain a list of dispatches that require reserved ports.
00377  */
00378 void
00379 ns_add_reserved_dispatch(ns_server_t *server, const isc_sockaddr_t *addr);
00380 
00381 /*%
00382  * Enable or disable dnssec validation.
00383  */
00384 isc_result_t
00385 ns_server_validation(ns_server_t *server, char *args, isc_buffer_t **text);
00386 
00387 /*%
00388  * Add a zone to a running process, or modify an existing zone
00389  */
00390 isc_result_t
00391 ns_server_changezone(ns_server_t *server, char *args, isc_buffer_t **text);
00392 
00393 /*%
00394  * Deletes a zone from a running process
00395  */
00396 isc_result_t
00397 ns_server_delzone(ns_server_t *server, char *args, isc_buffer_t **text);
00398 
00399 /*%
00400  * Show current configuration for a given zone
00401  */
00402 isc_result_t
00403 ns_server_showzone(ns_server_t *server, char *args, isc_buffer_t **text);
00404 
00405 /*%
00406  * Lists the status of the signing records for a given zone.
00407  */
00408 isc_result_t
00409 ns_server_signing(ns_server_t *server, char *args, isc_buffer_t **text);
00410 
00411 /*%
00412  * Lists status information for a given zone (e.g., name, type, files,
00413  * load time, expiry, etc).
00414  */
00415 isc_result_t
00416 ns_server_zonestatus(ns_server_t *server, char *args, isc_buffer_t **text);
00417 
00418 /*%
00419  * Adds a Negative Trust Anchor (NTA) for a specified name and
00420  * duration, in a particular view if specified, or in all views.
00421  */
00422 isc_result_t
00423 ns_server_nta(ns_server_t *server, char *args, isc_buffer_t **text);
00424 
00425 /*%
00426  * Generates a test sequence that is only for use in system tests. The
00427  * argument is the size of required output in bytes.
00428  */
00429 isc_result_t
00430 ns_server_testgen(char *args, isc_buffer_t **text);
00431 
00432 /*%
00433  * Force fefresh or print status for managed keys zones.
00434  */
00435 isc_result_t
00436 ns_server_mkeys(ns_server_t *server, char *args, isc_buffer_t **text);
00437 
00438 #endif /* NAMED_SERVER_H */

Generated on Tue Apr 28 17:40:54 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha