masterdump.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2008, 2011, 2013, 2014  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2002  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: masterdump.h,v 1.47 2011/12/08 23:46:49 tbox Exp $ */
00019 
00020 #ifndef DNS_MASTERDUMP_H
00021 #define DNS_MASTERDUMP_H 1
00022 
00023 /*! \file dns/masterdump.h */
00024 
00025 /***
00026  ***    Imports
00027  ***/
00028 
00029 #include <stdio.h>
00030 
00031 #include <isc/lang.h>
00032 
00033 #include <dns/types.h>
00034 
00035 /***
00036  *** Types
00037  ***/
00038 
00039 typedef struct dns_master_style dns_master_style_t;
00040 
00041 /***
00042  *** Definitions
00043  ***/
00044 
00045 /*
00046  * Flags affecting master file formatting.  Flags 0x0000FFFF
00047  * define the formatting of the rdata part and are defined in
00048  * rdata.h.
00049  */
00050 
00051 /*% Omit the owner name when possible. */
00052 #define DNS_STYLEFLAG_OMIT_OWNER        0x00010000U
00053 
00054 /*%
00055  * Omit the TTL when possible.  If DNS_STYLEFLAG_TTL is
00056  * also set, this means no TTLs are ever printed
00057  * because $TTL directives are generated before every
00058  * change in the TTL.  In this case, no columns need to
00059  * be reserved for the TTL.  Master files generated with
00060  * these options will be rejected by BIND 4.x because it
00061  * does not recognize the $TTL directive.
00062  *
00063  * If DNS_STYLEFLAG_TTL is not also set, the TTL will be
00064  * omitted when it is equal to the previous TTL.
00065  * This is correct according to RFC1035, but the
00066  * TTLs may be silently misinterpreted by older
00067  * versions of BIND which use the SOA MINTTL as a
00068  * default TTL value.
00069  */
00070 #define DNS_STYLEFLAG_OMIT_TTL          0x00020000U
00071 
00072 /*% Omit the class when possible. */
00073 #define DNS_STYLEFLAG_OMIT_CLASS        0x00040000U
00074 
00075 /*% Output $TTL directives. */
00076 #define DNS_STYLEFLAG_TTL               0x00080000U
00077 
00078 /*%
00079  * Output $ORIGIN directives and print owner names relative to
00080  * the origin when possible.
00081  */
00082 #define DNS_STYLEFLAG_REL_OWNER         0x00100000U
00083 
00084 /*% Print domain names in RR data in relative form when possible.
00085    For this to take effect, DNS_STYLEFLAG_REL_OWNER must also be set. */
00086 #define DNS_STYLEFLAG_REL_DATA          0x00200000U
00087 
00088 /*% Print the trust level of each rdataset. */
00089 #define DNS_STYLEFLAG_TRUST             0x00400000U
00090 
00091 /*% Print negative caching entries. */
00092 #define DNS_STYLEFLAG_NCACHE            0x00800000U
00093 
00094 /*% Never print the TTL. */
00095 #define DNS_STYLEFLAG_NO_TTL            0x01000000U
00096 
00097 /*% Never print the CLASS. */
00098 #define DNS_STYLEFLAG_NO_CLASS          0x02000000U
00099 
00100 /*% Report re-signing time. */
00101 #define DNS_STYLEFLAG_RESIGN            0x04000000U
00102 
00103 /*% Don't printout the cryptographic parts of DNSSEC records. */
00104 #define DNS_STYLEFLAG_NOCRYPTO          0x08000000U
00105 
00106 /*% Comment out data by prepending with ";" */
00107 #define DNS_STYLEFLAG_COMMENTDATA       0x10000000U
00108 
00109 /*% Print TTL with human-readable units. */
00110 #define DNS_STYLEFLAG_TTL_UNITS         0x20000000U
00111 
00112 ISC_LANG_BEGINDECLS
00113 
00114 /***
00115  ***    Constants
00116  ***/
00117 
00118 /*%
00119  * The default master file style.
00120  *
00121  * This uses $TTL directives to avoid the need to dedicate a
00122  * tab stop for the TTL.  The class is only printed for the first
00123  * rrset in the file and shares a tab stop with the RR type.
00124  */
00125 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_default;
00126 
00127 /*%
00128  * A master file style that dumps zones to a very generic format easily
00129  * imported/checked with external tools.
00130  */
00131 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_full;
00132 
00133 /*%
00134  * A master file style that prints explicit TTL values on each
00135  * record line, never using $TTL statements.  The TTL has a tab
00136  * stop of its own, but the class and type share one.
00137  */
00138 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t
00139                                         dns_master_style_explicitttl;
00140 
00141 /*%
00142  * A master style format designed for cache files.  It prints explicit TTL
00143  * values on each record line and never uses $ORIGIN or relative names.
00144  */
00145 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_cache;
00146 
00147 /*%
00148  * A master style that prints name, ttl, class, type, and value on
00149  * every line.  Similar to explicitttl above, but more verbose.
00150  * Intended for generating master files which can be easily parsed
00151  * by perl scripts and similar applications.
00152  */
00153 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_simple;
00154 
00155 /*%
00156  * The style used for debugging, "dig" output, etc.
00157  */
00158 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_debug;
00159 
00160 /*%
00161  * Similar to dns_master_style_debug but data is prepended with ";"
00162  */
00163 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_comment;
00164 
00165 /*%
00166  * The style used for dumping "key" zones.
00167  */
00168 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_keyzone;
00169 
00170 /***
00171  ***    Functions
00172  ***/
00173 
00174 void
00175 dns_dumpctx_attach(dns_dumpctx_t *source, dns_dumpctx_t **target);
00176 /*%<
00177  * Attach to a dump context.
00178  *
00179  * Require:
00180  *\li   'source' to be valid.
00181  *\li   'target' to be non NULL and '*target' to be NULL.
00182  */
00183 
00184 void
00185 dns_dumpctx_detach(dns_dumpctx_t **dctxp);
00186 /*%<
00187  * Detach from a dump context.
00188  *
00189  * Require:
00190  *\li   'dctxp' to point to a valid dump context.
00191  *
00192  * Ensures:
00193  *\li   '*dctxp' is NULL.
00194  */
00195 
00196 void
00197 dns_dumpctx_cancel(dns_dumpctx_t *dctx);
00198 /*%<
00199  * Cancel a in progress dump.
00200  *
00201  * Require:
00202  *\li   'dctx' to be valid.
00203  */
00204 
00205 dns_dbversion_t *
00206 dns_dumpctx_version(dns_dumpctx_t *dctx);
00207 /*%<
00208  * Return the version handle (if any) of the database being dumped.
00209  *
00210  * Require:
00211  *\li   'dctx' to be valid.
00212  */
00213 
00214 dns_db_t *
00215 dns_dumpctx_db(dns_dumpctx_t *dctx);
00216 /*%<
00217  * Return the database being dumped.
00218  *
00219  * Require:
00220  *\li   'dctx' to be valid.
00221  */
00222 
00223 
00224 /*@{*/
00225 isc_result_t
00226 dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
00227                            dns_dbversion_t *version,
00228                            const dns_master_style_t *style, FILE *f,
00229                            isc_task_t *task, dns_dumpdonefunc_t done,
00230                            void *done_arg, dns_dumpctx_t **dctxp);
00231 
00232 isc_result_t
00233 dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db,
00234                         dns_dbversion_t *version,
00235                         const dns_master_style_t *style, FILE *f);
00236 
00237 isc_result_t
00238 dns_master_dumptostream2(isc_mem_t *mctx, dns_db_t *db,
00239                          dns_dbversion_t *version,
00240                          const dns_master_style_t *style,
00241                          dns_masterformat_t format, FILE *f);
00242 
00243 isc_result_t
00244 dns_master_dumptostream3(isc_mem_t *mctx, dns_db_t *db,
00245                          dns_dbversion_t *version,
00246                          const dns_master_style_t *style,
00247                          dns_masterformat_t format,
00248                          dns_masterrawheader_t *header, FILE *f);
00249 /*%<
00250  * Dump the database 'db' to the steam 'f' in the specified format by
00251  * 'format'.  If the format is dns_masterformat_text (the RFC1035 format),
00252  * 'style' specifies the file style (e.g., &dns_master_style_default).
00253  *
00254  * dns_master_dumptostream() is an old form of dns_master_dumptostream3(),
00255  * which always specifies the dns_masterformat_text format.
00256  * dns_master_dumptostream2() is an old form which always specifies
00257  * a NULL header.
00258  *
00259  * If 'format' is dns_masterformat_raw, then 'header' can contain
00260  * information to be written to the file header.
00261  *
00262  * Temporary dynamic memory may be allocated from 'mctx'.
00263  *
00264  * Require:
00265  *\li   'task' to be valid.
00266  *\li   'done' to be non NULL.
00267  *\li   'dctxp' to be non NULL && '*dctxp' to be NULL.
00268  *
00269  * Returns:
00270  *\li   ISC_R_SUCCESS
00271  *\li   ISC_R_CONTINUE  dns_master_dumptostreaminc() only.
00272  *\li   ISC_R_NOMEMORY
00273  *\li   Any database or rrset iterator error.
00274  *\li   Any dns_rdata_totext() error code.
00275  */
00276 /*@}*/
00277 
00278 /*@{*/
00279 isc_result_t
00280 dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
00281                    const dns_master_style_t *style, const char *filename,
00282                    isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
00283                    dns_dumpctx_t **dctxp);
00284 
00285 isc_result_t
00286 dns_master_dumpinc2(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
00287                     const dns_master_style_t *style, const char *filename,
00288                     isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,                      dns_dumpctx_t **dctxp, dns_masterformat_t format);
00289 
00290 isc_result_t
00291 dns_master_dumpinc3(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
00292                     const dns_master_style_t *style, const char *filename,
00293                     isc_task_t *task, dns_dumpdonefunc_t done, void
00294                     *done_arg, dns_dumpctx_t **dctxp,
00295                     dns_masterformat_t format, dns_masterrawheader_t *header);
00296 
00297 isc_result_t
00298 dns_master_dump(isc_mem_t *mctx, dns_db_t *db,
00299                 dns_dbversion_t *version,
00300                 const dns_master_style_t *style, const char *filename);
00301 
00302 isc_result_t
00303 dns_master_dump2(isc_mem_t *mctx, dns_db_t *db,
00304                  dns_dbversion_t *version,
00305                  const dns_master_style_t *style, const char *filename,
00306                  dns_masterformat_t format);
00307 
00308 isc_result_t
00309 dns_master_dump3(isc_mem_t *mctx, dns_db_t *db,
00310                  dns_dbversion_t *version,
00311                  const dns_master_style_t *style, const char *filename,
00312                  dns_masterformat_t format, dns_masterrawheader_t *header);
00313 
00314 /*%<
00315  * Dump the database 'db' to the file 'filename' in the specified format by
00316  * 'format'.  If the format is dns_masterformat_text (the RFC1035 format),
00317  * 'style' specifies the file style (e.g., &dns_master_style_default).
00318  *
00319  * dns_master_dumpinc() and dns_master_dump() are old forms of _dumpinc3()
00320  * and _dump3(), respectively, which always specify the dns_masterformat_text
00321  * format.  dns_master_dumpinc2() and dns_master_dump2() are old forms which
00322  * always specify a NULL header.
00323  *
00324  * If 'format' is dns_masterformat_raw, then 'header' can contain
00325  * information to be written to the file header.
00326  *
00327  * Temporary dynamic memory may be allocated from 'mctx'.
00328  *
00329  * Returns:
00330  *\li   ISC_R_SUCCESS
00331  *\li   ISC_R_CONTINUE  dns_master_dumpinc() only.
00332  *\li   ISC_R_NOMEMORY
00333  *\li   Any database or rrset iterator error.
00334  *\li   Any dns_rdata_totext() error code.
00335  */
00336 /*@}*/
00337 
00338 isc_result_t
00339 dns_master_rdatasettotext(dns_name_t *owner_name,
00340                           dns_rdataset_t *rdataset,
00341                           const dns_master_style_t *style,
00342                           isc_buffer_t *target);
00343 /*%<
00344  * Convert 'rdataset' to text format, storing the result in 'target'.
00345  *
00346  * Notes:
00347  *\li   The rdata cursor position will be changed.
00348  *
00349  * Requires:
00350  *\li   'rdataset' is a valid non-question rdataset.
00351  *
00352  *\li   'rdataset' is not empty.
00353  */
00354 
00355 isc_result_t
00356 dns_master_questiontotext(dns_name_t *owner_name,
00357                           dns_rdataset_t *rdataset,
00358                           const dns_master_style_t *style,
00359                           isc_buffer_t *target);
00360 
00361 isc_result_t
00362 dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
00363                             dns_dbversion_t *version,
00364                             dns_dbnode_t *node, dns_name_t *name,
00365                             const dns_master_style_t *style,
00366                             FILE *f);
00367 
00368 isc_result_t
00369 dns_master_dumpnode(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
00370                     dns_dbnode_t *node, dns_name_t *name,
00371                     const dns_master_style_t *style, const char *filename);
00372 
00373 isc_result_t
00374 dns_master_stylecreate(dns_master_style_t **style, unsigned int flags,
00375                        unsigned int ttl_column, unsigned int class_column,
00376                        unsigned int type_column, unsigned int rdata_column,
00377                        unsigned int line_length, unsigned int tab_width,
00378                        isc_mem_t *mctx);
00379 
00380 isc_result_t
00381 dns_master_stylecreate2(dns_master_style_t **style, unsigned int flags,
00382                        unsigned int ttl_column, unsigned int class_column,
00383                        unsigned int type_column, unsigned int rdata_column,
00384                        unsigned int line_length, unsigned int tab_width,
00385                        unsigned int split_width, isc_mem_t *mctx);
00386 void
00387 dns_master_styledestroy(dns_master_style_t **style, isc_mem_t *mctx);
00388 
00389 ISC_LANG_ENDDECLS
00390 
00391 #endif /* DNS_MASTERDUMP_H */

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