/contrib/bind9/lib/dns/include/dns/master.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 307 lines · 157 code · 32 blank · 118 comment · 0 complexity · b3ba6530eb71a3715530c04d37c2bf18 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2009, 2012 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 1999-2002 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$ */
  18. #ifndef DNS_MASTER_H
  19. #define DNS_MASTER_H 1
  20. /*! \file dns/master.h */
  21. /***
  22. *** Imports
  23. ***/
  24. #include <stdio.h>
  25. #include <isc/lang.h>
  26. #include <dns/types.h>
  27. /*
  28. * Flags to be passed in the 'options' argument in the functions below.
  29. */
  30. #define DNS_MASTER_AGETTL 0x00000001 /*%< Age the ttl based on $DATE. */
  31. #define DNS_MASTER_MANYERRORS 0x00000002 /*%< Continue processing on errors. */
  32. #define DNS_MASTER_NOINCLUDE 0x00000004 /*%< Disallow $INCLUDE directives. */
  33. #define DNS_MASTER_ZONE 0x00000008 /*%< Loading a zone master file. */
  34. #define DNS_MASTER_HINT 0x00000010 /*%< Loading a hint master file. */
  35. #define DNS_MASTER_SLAVE 0x00000020 /*%< Loading a slave master file. */
  36. #define DNS_MASTER_CHECKNS 0x00000040 /*%<
  37. * Check NS records to see
  38. * if they are an address
  39. */
  40. #define DNS_MASTER_FATALNS 0x00000080 /*%<
  41. * Treat DNS_MASTER_CHECKNS
  42. * matches as fatal
  43. */
  44. #define DNS_MASTER_CHECKNAMES 0x00000100
  45. #define DNS_MASTER_CHECKNAMESFAIL 0x00000200
  46. #define DNS_MASTER_CHECKWILDCARD 0x00000400 /* Check for internal wildcards. */
  47. #define DNS_MASTER_CHECKMX 0x00000800
  48. #define DNS_MASTER_CHECKMXFAIL 0x00001000
  49. #define DNS_MASTER_RESIGN 0x00002000
  50. #define DNS_MASTER_KEY 0x00004000 /*%< Loading a key zone master file. */
  51. ISC_LANG_BEGINDECLS
  52. /*
  53. * Structures that implement the "raw" format for master dump.
  54. * These are provided for a reference purpose only; in the actual
  55. * encoding, we directly read/write each field so that the encoded data
  56. * is always "packed", regardless of the hardware architecture.
  57. */
  58. #define DNS_RAWFORMAT_VERSION 0
  59. /* Common header */
  60. typedef struct {
  61. isc_uint32_t format; /* must be
  62. * dns_masterformat_raw */
  63. isc_uint32_t version; /* compatibility for future
  64. * extensions */
  65. isc_uint32_t dumptime; /* timestamp on creation
  66. * (currently unused)
  67. */
  68. } dns_masterrawheader_t;
  69. /* The structure for each RRset */
  70. typedef struct {
  71. isc_uint32_t totallen; /* length of the data for this
  72. * RRset, including the
  73. * "header" part */
  74. dns_rdataclass_t rdclass; /* 16-bit class */
  75. dns_rdatatype_t type; /* 16-bit type */
  76. dns_rdatatype_t covers; /* same as type */
  77. dns_ttl_t ttl; /* 32-bit TTL */
  78. isc_uint32_t nrdata; /* number of RRs in this set */
  79. /* followed by encoded owner name, and then rdata */
  80. } dns_masterrawrdataset_t;
  81. /***
  82. *** Function
  83. ***/
  84. isc_result_t
  85. dns_master_loadfile(const char *master_file,
  86. dns_name_t *top,
  87. dns_name_t *origin,
  88. dns_rdataclass_t zclass,
  89. unsigned int options,
  90. dns_rdatacallbacks_t *callbacks,
  91. isc_mem_t *mctx);
  92. isc_result_t
  93. dns_master_loadfile2(const char *master_file,
  94. dns_name_t *top,
  95. dns_name_t *origin,
  96. dns_rdataclass_t zclass,
  97. unsigned int options,
  98. dns_rdatacallbacks_t *callbacks,
  99. isc_mem_t *mctx,
  100. dns_masterformat_t format);
  101. isc_result_t
  102. dns_master_loadfile3(const char *master_file,
  103. dns_name_t *top,
  104. dns_name_t *origin,
  105. dns_rdataclass_t zclass,
  106. unsigned int options,
  107. isc_uint32_t resign,
  108. dns_rdatacallbacks_t *callbacks,
  109. isc_mem_t *mctx,
  110. dns_masterformat_t format);
  111. isc_result_t
  112. dns_master_loadstream(FILE *stream,
  113. dns_name_t *top,
  114. dns_name_t *origin,
  115. dns_rdataclass_t zclass,
  116. unsigned int options,
  117. dns_rdatacallbacks_t *callbacks,
  118. isc_mem_t *mctx);
  119. isc_result_t
  120. dns_master_loadbuffer(isc_buffer_t *buffer,
  121. dns_name_t *top,
  122. dns_name_t *origin,
  123. dns_rdataclass_t zclass,
  124. unsigned int options,
  125. dns_rdatacallbacks_t *callbacks,
  126. isc_mem_t *mctx);
  127. isc_result_t
  128. dns_master_loadlexer(isc_lex_t *lex,
  129. dns_name_t *top,
  130. dns_name_t *origin,
  131. dns_rdataclass_t zclass,
  132. unsigned int options,
  133. dns_rdatacallbacks_t *callbacks,
  134. isc_mem_t *mctx);
  135. isc_result_t
  136. dns_master_loadfileinc(const char *master_file,
  137. dns_name_t *top,
  138. dns_name_t *origin,
  139. dns_rdataclass_t zclass,
  140. unsigned int options,
  141. dns_rdatacallbacks_t *callbacks,
  142. isc_task_t *task,
  143. dns_loaddonefunc_t done, void *done_arg,
  144. dns_loadctx_t **ctxp, isc_mem_t *mctx);
  145. isc_result_t
  146. dns_master_loadfileinc2(const char *master_file,
  147. dns_name_t *top,
  148. dns_name_t *origin,
  149. dns_rdataclass_t zclass,
  150. unsigned int options,
  151. dns_rdatacallbacks_t *callbacks,
  152. isc_task_t *task,
  153. dns_loaddonefunc_t done, void *done_arg,
  154. dns_loadctx_t **ctxp, isc_mem_t *mctx,
  155. dns_masterformat_t format);
  156. isc_result_t
  157. dns_master_loadfileinc3(const char *master_file,
  158. dns_name_t *top,
  159. dns_name_t *origin,
  160. dns_rdataclass_t zclass,
  161. unsigned int options,
  162. isc_uint32_t resign,
  163. dns_rdatacallbacks_t *callbacks,
  164. isc_task_t *task,
  165. dns_loaddonefunc_t done, void *done_arg,
  166. dns_loadctx_t **ctxp, isc_mem_t *mctx,
  167. dns_masterformat_t format);
  168. isc_result_t
  169. dns_master_loadstreaminc(FILE *stream,
  170. dns_name_t *top,
  171. dns_name_t *origin,
  172. dns_rdataclass_t zclass,
  173. unsigned int options,
  174. dns_rdatacallbacks_t *callbacks,
  175. isc_task_t *task,
  176. dns_loaddonefunc_t done, void *done_arg,
  177. dns_loadctx_t **ctxp, isc_mem_t *mctx);
  178. isc_result_t
  179. dns_master_loadbufferinc(isc_buffer_t *buffer,
  180. dns_name_t *top,
  181. dns_name_t *origin,
  182. dns_rdataclass_t zclass,
  183. unsigned int options,
  184. dns_rdatacallbacks_t *callbacks,
  185. isc_task_t *task,
  186. dns_loaddonefunc_t done, void *done_arg,
  187. dns_loadctx_t **ctxp, isc_mem_t *mctx);
  188. isc_result_t
  189. dns_master_loadlexerinc(isc_lex_t *lex,
  190. dns_name_t *top,
  191. dns_name_t *origin,
  192. dns_rdataclass_t zclass,
  193. unsigned int options,
  194. dns_rdatacallbacks_t *callbacks,
  195. isc_task_t *task,
  196. dns_loaddonefunc_t done, void *done_arg,
  197. dns_loadctx_t **ctxp, isc_mem_t *mctx);
  198. /*%<
  199. * Loads a RFC1305 master file from a file, stream, buffer, or existing
  200. * lexer into rdatasets and then calls 'callbacks->commit' to commit the
  201. * rdatasets. Rdata memory belongs to dns_master_load and will be
  202. * reused / released when the callback completes. dns_load_master will
  203. * abort if callbacks->commit returns any value other than ISC_R_SUCCESS.
  204. *
  205. * If 'DNS_MASTER_AGETTL' is set and the master file contains one or more
  206. * $DATE directives, the TTLs of the data will be aged accordingly.
  207. *
  208. * 'callbacks->commit' is assumed to call 'callbacks->error' or
  209. * 'callbacks->warn' to generate any error messages required.
  210. *
  211. * 'done' is called with 'done_arg' and a result code when the loading
  212. * is completed or has failed. If the initial setup fails 'done' is
  213. * not called.
  214. *
  215. * 'resign' the number of seconds before a RRSIG expires that it should
  216. * be re-signed. 0 is used if not provided.
  217. *
  218. * Requires:
  219. *\li 'master_file' points to a valid string.
  220. *\li 'lexer' points to a valid lexer.
  221. *\li 'top' points to a valid name.
  222. *\li 'origin' points to a valid name.
  223. *\li 'callbacks->commit' points to a valid function.
  224. *\li 'callbacks->error' points to a valid function.
  225. *\li 'callbacks->warn' points to a valid function.
  226. *\li 'mctx' points to a valid memory context.
  227. *\li 'task' and 'done' to be valid.
  228. *\li 'lmgr' to be valid.
  229. *\li 'ctxp != NULL && ctxp == NULL'.
  230. *
  231. * Returns:
  232. *\li ISC_R_SUCCESS upon successfully loading the master file.
  233. *\li ISC_R_SEENINCLUDE upon successfully loading the master file with
  234. * a $INCLUDE statement.
  235. *\li ISC_R_NOMEMORY out of memory.
  236. *\li ISC_R_UNEXPECTEDEND expected to be able to read a input token and
  237. * there was not one.
  238. *\li ISC_R_UNEXPECTED
  239. *\li DNS_R_NOOWNER failed to specify a ownername.
  240. *\li DNS_R_NOTTL failed to specify a ttl.
  241. *\li DNS_R_BADCLASS record class did not match zone class.
  242. *\li DNS_R_CONTINUE load still in progress (dns_master_load*inc() only).
  243. *\li Any dns_rdata_fromtext() error code.
  244. *\li Any error code from callbacks->commit().
  245. */
  246. void
  247. dns_loadctx_detach(dns_loadctx_t **ctxp);
  248. /*%<
  249. * Detach from the load context.
  250. *
  251. * Requires:
  252. *\li '*ctxp' to be valid.
  253. *
  254. * Ensures:
  255. *\li '*ctxp == NULL'
  256. */
  257. void
  258. dns_loadctx_attach(dns_loadctx_t *source, dns_loadctx_t **target);
  259. /*%<
  260. * Attach to the load context.
  261. *
  262. * Requires:
  263. *\li 'source' to be valid.
  264. *\li 'target != NULL && *target == NULL'.
  265. */
  266. void
  267. dns_loadctx_cancel(dns_loadctx_t *ctx);
  268. /*%<
  269. * Cancel loading the zone file associated with this load context.
  270. *
  271. * Requires:
  272. *\li 'ctx' to be valid
  273. */
  274. ISC_LANG_ENDDECLS
  275. #endif /* DNS_MASTER_H */