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

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 337 lines · 98 code · 53 blank · 186 comment · 0 complexity · dcdfa43886bf0194a8956c346bca449c MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2008, 2011, 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_MASTERDUMP_H
  19. #define DNS_MASTERDUMP_H 1
  20. /*! \file dns/masterdump.h */
  21. /***
  22. *** Imports
  23. ***/
  24. #include <stdio.h>
  25. #include <isc/lang.h>
  26. #include <dns/types.h>
  27. /***
  28. *** Types
  29. ***/
  30. typedef struct dns_master_style dns_master_style_t;
  31. /***
  32. *** Definitions
  33. ***/
  34. /*
  35. * Flags affecting master file formatting. Flags 0x0000FFFF
  36. * define the formatting of the rdata part and are defined in
  37. * rdata.h.
  38. */
  39. /*% Omit the owner name when possible. */
  40. #define DNS_STYLEFLAG_OMIT_OWNER 0x00010000U
  41. /*%
  42. * Omit the TTL when possible. If DNS_STYLEFLAG_TTL is
  43. * also set, this means no TTLs are ever printed
  44. * because $TTL directives are generated before every
  45. * change in the TTL. In this case, no columns need to
  46. * be reserved for the TTL. Master files generated with
  47. * these options will be rejected by BIND 4.x because it
  48. * does not recognize the $TTL directive.
  49. *
  50. * If DNS_STYLEFLAG_TTL is not also set, the TTL will be
  51. * omitted when it is equal to the previous TTL.
  52. * This is correct according to RFC1035, but the
  53. * TTLs may be silently misinterpreted by older
  54. * versions of BIND which use the SOA MINTTL as a
  55. * default TTL value.
  56. */
  57. #define DNS_STYLEFLAG_OMIT_TTL 0x00020000U
  58. /*% Omit the class when possible. */
  59. #define DNS_STYLEFLAG_OMIT_CLASS 0x00040000U
  60. /*% Output $TTL directives. */
  61. #define DNS_STYLEFLAG_TTL 0x00080000U
  62. /*%
  63. * Output $ORIGIN directives and print owner names relative to
  64. * the origin when possible.
  65. */
  66. #define DNS_STYLEFLAG_REL_OWNER 0x00100000U
  67. /*% Print domain names in RR data in relative form when possible.
  68. For this to take effect, DNS_STYLEFLAG_REL_OWNER must also be set. */
  69. #define DNS_STYLEFLAG_REL_DATA 0x00200000U
  70. /*% Print the trust level of each rdataset. */
  71. #define DNS_STYLEFLAG_TRUST 0x00400000U
  72. /*% Print negative caching entries. */
  73. #define DNS_STYLEFLAG_NCACHE 0x00800000U
  74. /*% Never print the TTL. */
  75. #define DNS_STYLEFLAG_NO_TTL 0x01000000U
  76. /*% Never print the CLASS. */
  77. #define DNS_STYLEFLAG_NO_CLASS 0x02000000U
  78. /*% Report re-signing time. */
  79. #define DNS_STYLEFLAG_RESIGN 0x04000000U
  80. ISC_LANG_BEGINDECLS
  81. /***
  82. *** Constants
  83. ***/
  84. /*%
  85. * The default master file style.
  86. *
  87. * This uses $TTL directives to avoid the need to dedicate a
  88. * tab stop for the TTL. The class is only printed for the first
  89. * rrset in the file and shares a tab stop with the RR type.
  90. */
  91. LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_default;
  92. /*%
  93. * A master file style that dumps zones to a very generic format easily
  94. * imported/checked with external tools.
  95. */
  96. LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_full;
  97. /*%
  98. * A master file style that prints explicit TTL values on each
  99. * record line, never using $TTL statements. The TTL has a tab
  100. * stop of its own, but the class and type share one.
  101. */
  102. LIBDNS_EXTERNAL_DATA extern const dns_master_style_t
  103. dns_master_style_explicitttl;
  104. /*%
  105. * A master style format designed for cache files. It prints explicit TTL
  106. * values on each record line and never uses $ORIGIN or relative names.
  107. */
  108. LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_cache;
  109. /*%
  110. * A master style that prints name, ttl, class, type, and value on
  111. * every line. Similar to explicitttl above, but more verbose.
  112. * Intended for generating master files which can be easily parsed
  113. * by perl scripts and similar applications.
  114. */
  115. LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_simple;
  116. /*%
  117. * The style used for debugging, "dig" output, etc.
  118. */
  119. LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_debug;
  120. /***
  121. *** Functions
  122. ***/
  123. void
  124. dns_dumpctx_attach(dns_dumpctx_t *source, dns_dumpctx_t **target);
  125. /*%<
  126. * Attach to a dump context.
  127. *
  128. * Require:
  129. *\li 'source' to be valid.
  130. *\li 'target' to be non NULL and '*target' to be NULL.
  131. */
  132. void
  133. dns_dumpctx_detach(dns_dumpctx_t **dctxp);
  134. /*%<
  135. * Detach from a dump context.
  136. *
  137. * Require:
  138. *\li 'dctxp' to point to a valid dump context.
  139. *
  140. * Ensures:
  141. *\li '*dctxp' is NULL.
  142. */
  143. void
  144. dns_dumpctx_cancel(dns_dumpctx_t *dctx);
  145. /*%<
  146. * Cancel a in progress dump.
  147. *
  148. * Require:
  149. *\li 'dctx' to be valid.
  150. */
  151. dns_dbversion_t *
  152. dns_dumpctx_version(dns_dumpctx_t *dctx);
  153. /*%<
  154. * Return the version handle (if any) of the database being dumped.
  155. *
  156. * Require:
  157. *\li 'dctx' to be valid.
  158. */
  159. dns_db_t *
  160. dns_dumpctx_db(dns_dumpctx_t *dctx);
  161. /*%<
  162. * Return the database being dumped.
  163. *
  164. * Require:
  165. *\li 'dctx' to be valid.
  166. */
  167. /*@{*/
  168. isc_result_t
  169. dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
  170. dns_dbversion_t *version,
  171. const dns_master_style_t *style, FILE *f,
  172. isc_task_t *task, dns_dumpdonefunc_t done,
  173. void *done_arg, dns_dumpctx_t **dctxp);
  174. isc_result_t
  175. dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db,
  176. dns_dbversion_t *version,
  177. const dns_master_style_t *style, FILE *f);
  178. isc_result_t
  179. dns_master_dumptostream2(isc_mem_t *mctx, dns_db_t *db,
  180. dns_dbversion_t *version,
  181. const dns_master_style_t *style,
  182. dns_masterformat_t format, FILE *f);
  183. /*%<
  184. * Dump the database 'db' to the steam 'f' in the specified format by
  185. * 'format'. If the format is dns_masterformat_text (the RFC1035 format),
  186. * 'style' specifies the file style (e.g., &dns_master_style_default).
  187. *
  188. * dns_master_dumptostream() is an old form of dns_master_dumptostream2(),
  189. * which always specifies the dns_masterformat_text format.
  190. *
  191. * Temporary dynamic memory may be allocated from 'mctx'.
  192. *
  193. * Require:
  194. *\li 'task' to be valid.
  195. *\li 'done' to be non NULL.
  196. *\li 'dctxp' to be non NULL && '*dctxp' to be NULL.
  197. *
  198. * Returns:
  199. *\li ISC_R_SUCCESS
  200. *\li ISC_R_CONTINUE dns_master_dumptostreaminc() only.
  201. *\li ISC_R_NOMEMORY
  202. *\li Any database or rrset iterator error.
  203. *\li Any dns_rdata_totext() error code.
  204. */
  205. /*@}*/
  206. /*@{*/
  207. isc_result_t
  208. dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
  209. const dns_master_style_t *style, const char *filename,
  210. isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
  211. dns_dumpctx_t **dctxp);
  212. isc_result_t
  213. dns_master_dumpinc2(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
  214. const dns_master_style_t *style, const char *filename,
  215. isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg, dns_dumpctx_t **dctxp, dns_masterformat_t format);
  216. isc_result_t
  217. dns_master_dump(isc_mem_t *mctx, dns_db_t *db,
  218. dns_dbversion_t *version,
  219. const dns_master_style_t *style, const char *filename);
  220. isc_result_t
  221. dns_master_dump2(isc_mem_t *mctx, dns_db_t *db,
  222. dns_dbversion_t *version,
  223. const dns_master_style_t *style, const char *filename,
  224. dns_masterformat_t format);
  225. /*%<
  226. * Dump the database 'db' to the file 'filename' in the specified format by
  227. * 'format'. If the format is dns_masterformat_text (the RFC1035 format),
  228. * 'style' specifies the file style (e.g., &dns_master_style_default).
  229. *
  230. * dns_master_dumpinc() and dns_master_dump() are old forms of _dumpinc2()
  231. * and _dump2(), respectively, which always specify the dns_masterformat_text
  232. * format.
  233. *
  234. * Temporary dynamic memory may be allocated from 'mctx'.
  235. *
  236. * Returns:
  237. *\li ISC_R_SUCCESS
  238. *\li ISC_R_CONTINUE dns_master_dumpinc() only.
  239. *\li ISC_R_NOMEMORY
  240. *\li Any database or rrset iterator error.
  241. *\li Any dns_rdata_totext() error code.
  242. */
  243. /*@}*/
  244. isc_result_t
  245. dns_master_rdatasettotext(dns_name_t *owner_name,
  246. dns_rdataset_t *rdataset,
  247. const dns_master_style_t *style,
  248. isc_buffer_t *target);
  249. /*%<
  250. * Convert 'rdataset' to text format, storing the result in 'target'.
  251. *
  252. * Notes:
  253. *\li The rdata cursor position will be changed.
  254. *
  255. * Requires:
  256. *\li 'rdataset' is a valid non-question rdataset.
  257. *
  258. *\li 'rdataset' is not empty.
  259. */
  260. isc_result_t
  261. dns_master_questiontotext(dns_name_t *owner_name,
  262. dns_rdataset_t *rdataset,
  263. const dns_master_style_t *style,
  264. isc_buffer_t *target);
  265. isc_result_t
  266. dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
  267. dns_dbversion_t *version,
  268. dns_dbnode_t *node, dns_name_t *name,
  269. const dns_master_style_t *style,
  270. FILE *f);
  271. isc_result_t
  272. dns_master_dumpnode(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
  273. dns_dbnode_t *node, dns_name_t *name,
  274. const dns_master_style_t *style, const char *filename);
  275. isc_result_t
  276. dns_master_stylecreate(dns_master_style_t **style, unsigned int flags,
  277. unsigned int ttl_column, unsigned int class_column,
  278. unsigned int type_column, unsigned int rdata_column,
  279. unsigned int line_length, unsigned int tab_width,
  280. isc_mem_t *mctx);
  281. void
  282. dns_master_styledestroy(dns_master_style_t **style, isc_mem_t *mctx);
  283. ISC_LANG_ENDDECLS
  284. #endif /* DNS_MASTERDUMP_H */