/contrib/bind9/bin/named/include/named/server.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 337 lines · 162 code · 56 blank · 119 comment · 0 complexity · 28c8e22446169b2901d54341c3904595 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2010 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: server.h,v 1.110 2010/08/16 23:46:52 tbox Exp $ */
  18. #ifndef NAMED_SERVER_H
  19. #define NAMED_SERVER_H 1
  20. /*! \file */
  21. #include <isc/log.h>
  22. #include <isc/magic.h>
  23. #include <isc/quota.h>
  24. #include <isc/sockaddr.h>
  25. #include <isc/types.h>
  26. #include <isc/xml.h>
  27. #include <dns/acl.h>
  28. #include <dns/types.h>
  29. #include <named/types.h>
  30. #define NS_EVENTCLASS ISC_EVENTCLASS(0x4E43)
  31. #define NS_EVENT_RELOAD (NS_EVENTCLASS + 0)
  32. #define NS_EVENT_CLIENTCONTROL (NS_EVENTCLASS + 1)
  33. /*%
  34. * Name server state. Better here than in lots of separate global variables.
  35. */
  36. struct ns_server {
  37. unsigned int magic;
  38. isc_mem_t * mctx;
  39. isc_task_t * task;
  40. /* Configurable data. */
  41. isc_quota_t xfroutquota;
  42. isc_quota_t tcpquota;
  43. isc_quota_t recursionquota;
  44. dns_acl_t *blackholeacl;
  45. char * statsfile; /*%< Statistics file name */
  46. char * dumpfile; /*%< Dump file name */
  47. char * secrootsfile; /*%< Secroots file name */
  48. char * bindkeysfile; /*%< bind.keys file name */
  49. char * recfile; /*%< Recursive file name */
  50. isc_boolean_t version_set; /*%< User has set version */
  51. char * version; /*%< User-specified version */
  52. isc_boolean_t hostname_set; /*%< User has set hostname */
  53. char * hostname; /*%< User-specified hostname */
  54. /*% Use hostname for server id */
  55. isc_boolean_t server_usehostname;
  56. char * server_id; /*%< User-specified server id */
  57. /*%
  58. * Current ACL environment. This defines the
  59. * current values of the localhost and localnets
  60. * ACLs.
  61. */
  62. dns_aclenv_t aclenv;
  63. /* Server data structures. */
  64. dns_loadmgr_t * loadmgr;
  65. dns_zonemgr_t * zonemgr;
  66. dns_viewlist_t viewlist;
  67. ns_interfacemgr_t * interfacemgr;
  68. dns_db_t * in_roothints;
  69. dns_tkeyctx_t * tkeyctx;
  70. isc_timer_t * interface_timer;
  71. isc_timer_t * heartbeat_timer;
  72. isc_timer_t * pps_timer;
  73. isc_uint32_t interface_interval;
  74. isc_uint32_t heartbeat_interval;
  75. isc_mutex_t reload_event_lock;
  76. isc_event_t * reload_event;
  77. isc_boolean_t flushonshutdown;
  78. isc_boolean_t log_queries; /*%< For BIND 8 compatibility */
  79. ns_cachelist_t cachelist; /*%< Possibly shared caches */
  80. isc_stats_t * nsstats; /*%< Server stats */
  81. dns_stats_t * rcvquerystats; /*% Incoming query stats */
  82. dns_stats_t * opcodestats; /*%< Incoming message stats */
  83. isc_stats_t * zonestats; /*% Zone management stats */
  84. isc_stats_t * resolverstats; /*% Resolver stats */
  85. isc_stats_t * sockstats; /*%< Socket stats */
  86. ns_controls_t * controls; /*%< Control channels */
  87. unsigned int dispatchgen;
  88. ns_dispatchlist_t dispatches;
  89. dns_acache_t *acache;
  90. ns_statschannellist_t statschannels;
  91. dns_tsigkey_t *sessionkey;
  92. char *session_keyfile;
  93. dns_name_t *session_keyname;
  94. unsigned int session_keyalg;
  95. isc_uint16_t session_keybits;
  96. };
  97. #define NS_SERVER_MAGIC ISC_MAGIC('S','V','E','R')
  98. #define NS_SERVER_VALID(s) ISC_MAGIC_VALID(s, NS_SERVER_MAGIC)
  99. /*%
  100. * Server statistics counters. Used as isc_statscounter_t values.
  101. */
  102. enum {
  103. dns_nsstatscounter_requestv4 = 0,
  104. dns_nsstatscounter_requestv6 = 1,
  105. dns_nsstatscounter_edns0in = 2,
  106. dns_nsstatscounter_badednsver = 3,
  107. dns_nsstatscounter_tsigin = 4,
  108. dns_nsstatscounter_sig0in = 5,
  109. dns_nsstatscounter_invalidsig = 6,
  110. dns_nsstatscounter_tcp = 7,
  111. dns_nsstatscounter_authrej = 8,
  112. dns_nsstatscounter_recurserej = 9,
  113. dns_nsstatscounter_xfrrej = 10,
  114. dns_nsstatscounter_updaterej = 11,
  115. dns_nsstatscounter_response = 12,
  116. dns_nsstatscounter_truncatedresp = 13,
  117. dns_nsstatscounter_edns0out = 14,
  118. dns_nsstatscounter_tsigout = 15,
  119. dns_nsstatscounter_sig0out = 16,
  120. dns_nsstatscounter_success = 17,
  121. dns_nsstatscounter_authans = 18,
  122. dns_nsstatscounter_nonauthans = 19,
  123. dns_nsstatscounter_referral = 20,
  124. dns_nsstatscounter_nxrrset = 21,
  125. dns_nsstatscounter_servfail = 22,
  126. dns_nsstatscounter_formerr = 23,
  127. dns_nsstatscounter_nxdomain = 24,
  128. dns_nsstatscounter_recursion = 25,
  129. dns_nsstatscounter_duplicate = 26,
  130. dns_nsstatscounter_dropped = 27,
  131. dns_nsstatscounter_failure = 28,
  132. dns_nsstatscounter_xfrdone = 29,
  133. dns_nsstatscounter_updatereqfwd = 30,
  134. dns_nsstatscounter_updaterespfwd = 31,
  135. dns_nsstatscounter_updatefwdfail = 32,
  136. dns_nsstatscounter_updatedone = 33,
  137. dns_nsstatscounter_updatefail = 34,
  138. dns_nsstatscounter_updatebadprereq = 35,
  139. dns_nsstatscounter_max = 36
  140. };
  141. void
  142. ns_server_create(isc_mem_t *mctx, ns_server_t **serverp);
  143. /*%<
  144. * Create a server object with default settings.
  145. * This function either succeeds or causes the program to exit
  146. * with a fatal error.
  147. */
  148. void
  149. ns_server_destroy(ns_server_t **serverp);
  150. /*%<
  151. * Destroy a server object, freeing its memory.
  152. */
  153. void
  154. ns_server_reloadwanted(ns_server_t *server);
  155. /*%<
  156. * Inform a server that a reload is wanted. This function
  157. * may be called asynchronously, from outside the server's task.
  158. * If a reload is already scheduled or in progress, the call
  159. * is ignored.
  160. */
  161. void
  162. ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
  163. /*%<
  164. * Inform the server that the zones should be flushed to disk on shutdown.
  165. */
  166. isc_result_t
  167. ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text);
  168. /*%<
  169. * Act on a "reload" command from the command channel.
  170. */
  171. isc_result_t
  172. ns_server_reconfigcommand(ns_server_t *server, char *args);
  173. /*%<
  174. * Act on a "reconfig" command from the command channel.
  175. */
  176. isc_result_t
  177. ns_server_notifycommand(ns_server_t *server, char *args, isc_buffer_t *text);
  178. /*%<
  179. * Act on a "notify" command from the command channel.
  180. */
  181. isc_result_t
  182. ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text);
  183. /*%<
  184. * Act on a "refresh" command from the command channel.
  185. */
  186. isc_result_t
  187. ns_server_retransfercommand(ns_server_t *server, char *args);
  188. /*%<
  189. * Act on a "retransfer" command from the command channel.
  190. */
  191. isc_result_t
  192. ns_server_togglequerylog(ns_server_t *server);
  193. /*%<
  194. * Toggle logging of queries, as in BIND 8.
  195. */
  196. /*%
  197. * Dump the current statistics to the statistics file.
  198. */
  199. isc_result_t
  200. ns_server_dumpstats(ns_server_t *server);
  201. /*%
  202. * Dump the current cache to the dump file.
  203. */
  204. isc_result_t
  205. ns_server_dumpdb(ns_server_t *server, char *args);
  206. /*%
  207. * Dump the current security roots to the secroots file.
  208. */
  209. isc_result_t
  210. ns_server_dumpsecroots(ns_server_t *server, char *args);
  211. /*%
  212. * Change or increment the server debug level.
  213. */
  214. isc_result_t
  215. ns_server_setdebuglevel(ns_server_t *server, char *args);
  216. /*%
  217. * Flush the server's cache(s)
  218. */
  219. isc_result_t
  220. ns_server_flushcache(ns_server_t *server, char *args);
  221. /*%
  222. * Flush a particular name from the server's cache(s)
  223. */
  224. isc_result_t
  225. ns_server_flushname(ns_server_t *server, char *args);
  226. /*%
  227. * Report the server's status.
  228. */
  229. isc_result_t
  230. ns_server_status(ns_server_t *server, isc_buffer_t *text);
  231. /*%
  232. * Report a list of dynamic and static tsig keys, per view.
  233. */
  234. isc_result_t
  235. ns_server_tsiglist(ns_server_t *server, isc_buffer_t *text);
  236. /*%
  237. * Delete a specific key (with optional view).
  238. */
  239. isc_result_t
  240. ns_server_tsigdelete(ns_server_t *server, char *command, isc_buffer_t *text);
  241. /*%
  242. * Enable or disable updates for a zone.
  243. */
  244. isc_result_t
  245. ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args,
  246. isc_buffer_t *text);
  247. /*%
  248. * Update a zone's DNSKEY set from the key repository. If
  249. * the command that triggered the call to this function was "sign",
  250. * then force a full signing of the zone. If it was "loadkeys",
  251. * then don't sign the zone; any needed changes to signatures can
  252. * take place incrementally.
  253. */
  254. isc_result_t
  255. ns_server_rekey(ns_server_t *server, char *args);
  256. /*%
  257. * Dump the current recursive queries.
  258. */
  259. isc_result_t
  260. ns_server_dumprecursing(ns_server_t *server);
  261. /*%
  262. * Maintain a list of dispatches that require reserved ports.
  263. */
  264. void
  265. ns_add_reserved_dispatch(ns_server_t *server, const isc_sockaddr_t *addr);
  266. /*%
  267. * Enable or disable dnssec validation.
  268. */
  269. isc_result_t
  270. ns_server_validation(ns_server_t *server, char *args);
  271. /*%
  272. * Add a zone to a running process
  273. */
  274. isc_result_t
  275. ns_server_add_zone(ns_server_t *server, char *args);
  276. /*%
  277. * Deletes a zone from a running process
  278. */
  279. isc_result_t
  280. ns_server_del_zone(ns_server_t *server, char *args);
  281. #endif /* NAMED_SERVER_H */