2 * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2002 Internet Software Consortium.
5 * Permission to use, copy, modify, and 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.
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.
18 /* $Id: masterdump.h,v 1.22.12.10 2005/09/06 02:12:41 marka Exp $ */
20 #ifndef DNS_MASTERDUMP_H
21 #define DNS_MASTERDUMP_H 1
31 #include <dns/types.h>
37 typedef struct dns_master_style dns_master_style_t;
44 * Flags affecting master file formatting. Flags 0x0000FFFF
45 * define the formatting of the rdata part and are defined in
49 /* Omit the owner name when possible. */
50 #define DNS_STYLEFLAG_OMIT_OWNER 0x00010000U
53 * Omit the TTL when possible. If DNS_STYLEFLAG_TTL is
54 * also set, this means no TTLs are ever printed
55 * because $TTL directives are generated before every
56 * change in the TTL. In this case, no columns need to
57 * be reserved for the TTL. Master files generated with
58 * these options will be rejected by BIND 4.x because it
59 * does not recognize the $TTL directive.
61 * If DNS_STYLEFLAG_TTL is not also set, the TTL will be
62 * omitted when it is equal to the previous TTL.
63 * This is correct according to RFC1035, but the
64 * TTLs may be silently misinterpreted by older
65 * versions of BIND which use the SOA MINTTL as a
68 #define DNS_STYLEFLAG_OMIT_TTL 0x00020000U
70 /* Omit the class when possible. */
71 #define DNS_STYLEFLAG_OMIT_CLASS 0x00040000U
73 /* Output $TTL directives. */
74 #define DNS_STYLEFLAG_TTL 0x00080000U
77 * Output $ORIGIN directives and print owner names relative to
78 * the origin when possible.
80 #define DNS_STYLEFLAG_REL_OWNER 0x00100000U
82 /* Print domain names in RR data in relative form when possible.
83 For this to take effect, DNS_STYLEFLAG_REL_OWNER must also be set. */
84 #define DNS_STYLEFLAG_REL_DATA 0x00200000U
86 /* Print the trust level of each rdataset. */
87 #define DNS_STYLEFLAG_TRUST 0x00400000U
89 /* Print negative caching entries. */
90 #define DNS_STYLEFLAG_NCACHE 0x00800000U
92 /* Never print the TTL */
93 #define DNS_STYLEFLAG_NO_TTL 0x01000000U
95 /* Never print the CLASS */
96 #define DNS_STYLEFLAG_NO_CLASS 0x02000000U
105 * The default master file style.
107 * This uses $TTL directives to avoid the need to dedicate a
108 * tab stop for the TTL. The class is only printed for the first
109 * rrset in the file and shares a tab stop with the RR type.
111 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_default;
114 * A master file style that dumps zones to a very generic format easily
115 * imported/checked with external tools.
117 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_full;
120 * A master file style that prints explicit TTL values on each
121 * record line, never using $TTL statements. The TTL has a tab
122 * stop of its own, but the class and type share one.
124 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t
125 dns_master_style_explicitttl;
128 * A master style format designed for cache files. It prints explicit TTL
129 * values on each record line and never uses $ORIGIN or relative names.
131 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_cache;
134 * A master style that prints name, ttl, class, type, and value on
135 * every line. Similar to explicitttl above, but more verbose.
136 * Intended for generating master files which can be easily parsed
137 * by perl scripts and similar applications.
139 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_simple;
142 * The style used for debugging, "dig" output, etc.
144 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_debug;
151 dns_dumpctx_attach(dns_dumpctx_t *source, dns_dumpctx_t **target);
153 * Attach to a dump context.
156 * 'source' to be valid.
157 * 'target' to be non NULL and '*target' to be NULL.
161 dns_dumpctx_detach(dns_dumpctx_t **dctxp);
163 * Detach from a dump context.
166 * 'dctxp' to point to a valid dump context.
173 dns_dumpctx_cancel(dns_dumpctx_t *dctx);
175 * Cancel a in progress dump.
178 * 'dctx' to be valid.
182 dns_dumpctx_version(dns_dumpctx_t *dctx);
184 * Return the version handle (if any) of the database being dumped.
187 * 'dctx' to be valid.
191 dns_dumpctx_db(dns_dumpctx_t *dctx);
193 * Return the database being dumped.
196 * 'dctx' to be valid.
201 dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
202 dns_dbversion_t *version,
203 const dns_master_style_t *style, FILE *f,
204 isc_task_t *task, dns_dumpdonefunc_t done,
205 void *done_arg, dns_dumpctx_t **dctxp);
208 dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db,
209 dns_dbversion_t *version,
210 const dns_master_style_t *style, FILE *f);
212 * Dump the database 'db' to the steam 'f' in RFC1035 master
213 * file format, in the style defined by 'style'
214 * (e.g., &dns_default_master_style_default)
216 * Temporary dynamic memory may be allocated from 'mctx'.
219 * 'task' to be valid.
220 * 'done' to be non NULL.
221 * 'dctxp' to be non NULL && '*dctxp' to be NULL.
225 * DNS_R_CONTINUE dns_master_dumptostreaminc() only.
227 * Any database or rrset iterator error.
228 * Any dns_rdata_totext() error code.
232 dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
233 const dns_master_style_t *style, const char *filename,
234 isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
235 dns_dumpctx_t **dctxp);
238 dns_master_dump(isc_mem_t *mctx, dns_db_t *db,
239 dns_dbversion_t *version,
240 const dns_master_style_t *style, const char *filename);
242 * Dump the database 'db' to the file 'filename' in RFC1035 master
243 * file format, in the style defined by 'style'
244 * (e.g., &dns_default_master_style_default)
246 * Temporary dynamic memory may be allocated from 'mctx'.
250 * DNS_R_CONTINUE dns_master_dumpinc() only.
252 * Any database or rrset iterator error.
253 * Any dns_rdata_totext() error code.
257 dns_master_rdatasettotext(dns_name_t *owner_name,
258 dns_rdataset_t *rdataset,
259 const dns_master_style_t *style,
260 isc_buffer_t *target);
262 * Convert 'rdataset' to text format, storing the result in 'target'.
265 * The rdata cursor position will be changed.
268 * 'rdataset' is a valid non-question rdataset.
270 * 'rdataset' is not empty.
274 dns_master_questiontotext(dns_name_t *owner_name,
275 dns_rdataset_t *rdataset,
276 const dns_master_style_t *style,
277 isc_buffer_t *target);
280 dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
281 dns_dbversion_t *version,
282 dns_dbnode_t *node, dns_name_t *name,
283 const dns_master_style_t *style,
287 dns_master_dumpnode(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
288 dns_dbnode_t *node, dns_name_t *name,
289 const dns_master_style_t *style, const char *filename);
292 dns_master_stylecreate(dns_master_style_t **style, unsigned int flags,
293 unsigned int ttl_column, unsigned int class_column,
294 unsigned int type_column, unsigned int rdata_column,
295 unsigned int line_length, unsigned int tab_width,
299 dns_master_styledestroy(dns_master_style_t **style, isc_mem_t *mctx);
303 #endif /* DNS_MASTERDUMP_H */