"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.16.7/lib/dns/include/dns/masterdump.h" (4 Sep 2020, 10425 Bytes) of package /linux/misc/dns/bind9/9.16.7/bind-9.16.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "masterdump.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #ifndef DNS_MASTERDUMP_H
   13 #define DNS_MASTERDUMP_H 1
   14 
   15 /*! \file dns/masterdump.h */
   16 
   17 /***
   18  ***    Imports
   19  ***/
   20 
   21 #include <stdio.h>
   22 
   23 #include <isc/lang.h>
   24 
   25 #include <dns/types.h>
   26 
   27 /***
   28  *** Types
   29  ***/
   30 
   31 typedef struct dns_master_style dns_master_style_t;
   32 
   33 /***
   34  *** Definitions
   35  ***/
   36 
   37 /*
   38  * Flags affecting master file formatting.  Flags 0x0000FFFF
   39  * define the formatting of the rdata part and are defined in
   40  * rdata.h.
   41  */
   42 
   43 /*% Omit the owner name when possible. */
   44 #define DNS_STYLEFLAG_OMIT_OWNER 0x000010000ULL
   45 
   46 /*%
   47  * Omit the TTL when possible.  If DNS_STYLEFLAG_TTL is
   48  * also set, this means no TTLs are ever printed
   49  * because $TTL directives are generated before every
   50  * change in the TTL.  In this case, no columns need to
   51  * be reserved for the TTL.  Master files generated with
   52  * these options will be rejected by BIND 4.x because it
   53  * does not recognize the $TTL directive.
   54  *
   55  * If DNS_STYLEFLAG_TTL is not also set, the TTL will be
   56  * omitted when it is equal to the previous TTL.
   57  * This is correct according to RFC1035, but the
   58  * TTLs may be silently misinterpreted by older
   59  * versions of BIND which use the SOA MINTTL as a
   60  * default TTL value.
   61  */
   62 #define DNS_STYLEFLAG_OMIT_TTL 0x000020000ULL
   63 
   64 /*% Omit the class when possible. */
   65 #define DNS_STYLEFLAG_OMIT_CLASS 0x000040000ULL
   66 
   67 /*% Output $TTL directives. */
   68 #define DNS_STYLEFLAG_TTL 0x000080000ULL
   69 
   70 /*%
   71  * Output $ORIGIN directives and print owner names relative to
   72  * the origin when possible.
   73  */
   74 #define DNS_STYLEFLAG_REL_OWNER 0x000100000ULL
   75 
   76 /*% Print domain names in RR data in relative form when possible.
   77  * For this to take effect, DNS_STYLEFLAG_REL_OWNER must also be set. */
   78 #define DNS_STYLEFLAG_REL_DATA 0x000200000ULL
   79 
   80 /*% Print the trust level of each rdataset. */
   81 #define DNS_STYLEFLAG_TRUST 0x000400000ULL
   82 
   83 /*% Print negative caching entries. */
   84 #define DNS_STYLEFLAG_NCACHE 0x000800000ULL
   85 
   86 /*% Never print the TTL. */
   87 #define DNS_STYLEFLAG_NO_TTL 0x001000000ULL
   88 
   89 /*% Never print the CLASS. */
   90 #define DNS_STYLEFLAG_NO_CLASS 0x002000000ULL
   91 
   92 /*% Report re-signing time. */
   93 #define DNS_STYLEFLAG_RESIGN 0x004000000ULL
   94 
   95 /*% Don't printout the cryptographic parts of DNSSEC records. */
   96 #define DNS_STYLEFLAG_NOCRYPTO 0x008000000ULL
   97 
   98 /*% Comment out data by prepending with ";" */
   99 #define DNS_STYLEFLAG_COMMENTDATA 0x010000000ULL
  100 
  101 /*% Print TTL with human-readable units. */
  102 #define DNS_STYLEFLAG_TTL_UNITS 0x020000000ULL
  103 
  104 /*% Indent output. */
  105 #define DNS_STYLEFLAG_INDENT 0x040000000ULL
  106 
  107 /*% Output in YAML style. */
  108 #define DNS_STYLEFLAG_YAML 0x080000000ULL
  109 
  110 /*% Print ECS cache entries as comments (reserved for future use). */
  111 #define DNS_STYLEFLAG_ECSCACHE 0x100000000ULL
  112 
  113 ISC_LANG_BEGINDECLS
  114 
  115 /***
  116  ***    Constants
  117  ***/
  118 
  119 /*%
  120  * The default master file style.
  121  *
  122  * This uses $TTL directives to avoid the need to dedicate a
  123  * tab stop for the TTL.  The class is only printed for the first
  124  * rrset in the file and shares a tab stop with the RR type.
  125  */
  126 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_default;
  127 
  128 /*%
  129  * A master file style that dumps zones to a very generic format easily
  130  * imported/checked with external tools.
  131  */
  132 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_full;
  133 
  134 /*%
  135  * A master file style that prints explicit TTL values on each
  136  * record line, never using $TTL statements.  The TTL has a tab
  137  * stop of its own, but the class and type share one.
  138  */
  139 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t
  140     dns_master_style_explicitttl;
  141 
  142 /*%
  143  * A master style format designed for cache files.  It prints explicit TTL
  144  * values on each record line and never uses $ORIGIN or relative names.
  145  */
  146 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_cache;
  147 
  148 /*%
  149  * A master style that prints name, ttl, class, type, and value on
  150  * every line.  Similar to explicitttl above, but more verbose.
  151  * Intended for generating master files which can be easily parsed
  152  * by perl scripts and similar applications.
  153  */
  154 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_simple;
  155 
  156 /*%
  157  * The style used for debugging, "dig" output, etc.
  158  */
  159 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_debug;
  160 
  161 /*%
  162  * Similar to dns_master_style_debug but data is prepended with ";"
  163  */
  164 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_comment;
  165 
  166 /*%
  167  * Similar to dns_master_style_debug but data is indented with "\t" (tab)
  168  */
  169 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_indent;
  170 
  171 /*%
  172  * The style used for dumping "key" zones.
  173  */
  174 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_keyzone;
  175 
  176 /*%
  177  * YAML-compatible output
  178  */
  179 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_yaml;
  180 
  181 /***
  182  ***    Functions
  183  ***/
  184 
  185 void
  186 dns_dumpctx_attach(dns_dumpctx_t *source, dns_dumpctx_t **target);
  187 /*%<
  188  * Attach to a dump context.
  189  *
  190  * Require:
  191  *\li   'source' to be valid.
  192  *\li   'target' to be non NULL and '*target' to be NULL.
  193  */
  194 
  195 void
  196 dns_dumpctx_detach(dns_dumpctx_t **dctxp);
  197 /*%<
  198  * Detach from a dump context.
  199  *
  200  * Require:
  201  *\li   'dctxp' to point to a valid dump context.
  202  *
  203  * Ensures:
  204  *\li   '*dctxp' is NULL.
  205  */
  206 
  207 void
  208 dns_dumpctx_cancel(dns_dumpctx_t *dctx);
  209 /*%<
  210  * Cancel a in progress dump.
  211  *
  212  * Require:
  213  *\li   'dctx' to be valid.
  214  */
  215 
  216 dns_dbversion_t *
  217 dns_dumpctx_version(dns_dumpctx_t *dctx);
  218 /*%<
  219  * Return the version handle (if any) of the database being dumped.
  220  *
  221  * Require:
  222  *\li   'dctx' to be valid.
  223  */
  224 
  225 dns_db_t *
  226 dns_dumpctx_db(dns_dumpctx_t *dctx);
  227 /*%<
  228  * Return the database being dumped.
  229  *
  230  * Require:
  231  *\li   'dctx' to be valid.
  232  */
  233 
  234 /*@{*/
  235 isc_result_t
  236 dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
  237                dns_dbversion_t *         version,
  238                const dns_master_style_t *style, FILE *f,
  239                isc_task_t *task, dns_dumpdonefunc_t done,
  240                void *done_arg, dns_dumpctx_t **dctxp);
  241 
  242 isc_result_t
  243 dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
  244             const dns_master_style_t *style,
  245             dns_masterformat_t    format,
  246             dns_masterrawheader_t *header, FILE *f);
  247 /*%<
  248  * Dump the database 'db' to the steam 'f' in the specified format by
  249  * 'format'.  If the format is dns_masterformat_text (the RFC1035 format),
  250  * 'style' specifies the file style (e.g., &dns_master_style_default).
  251  *
  252  * dns_master_dumptostream() is an old form of dns_master_dumptostream3(),
  253  * which always specifies the dns_masterformat_text format.
  254  * dns_master_dumptostream2() is an old form which always specifies
  255  * a NULL header.
  256  *
  257  * If 'format' is dns_masterformat_raw, then 'header' can contain
  258  * information to be written to the file header.
  259  *
  260  * Temporary dynamic memory may be allocated from 'mctx'.
  261  *
  262  * Require:
  263  *\li   'task' to be valid.
  264  *\li   'done' to be non NULL.
  265  *\li   'dctxp' to be non NULL && '*dctxp' to be NULL.
  266  *
  267  * Returns:
  268  *\li   ISC_R_SUCCESS
  269  *\li   ISC_R_CONTINUE  dns_master_dumptostreaminc() only.
  270  *\li   ISC_R_NOMEMORY
  271  *\li   Any database or rrset iterator error.
  272  *\li   Any dns_rdata_totext() error code.
  273  */
  274 /*@}*/
  275 
  276 /*@{*/
  277 
  278 isc_result_t
  279 dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
  280            const dns_master_style_t *style, const char *filename,
  281            isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
  282            dns_dumpctx_t **dctxp, dns_masterformat_t format,
  283            dns_masterrawheader_t *header);
  284 
  285 isc_result_t
  286 dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
  287         const dns_master_style_t *style, const char *filename,
  288         dns_masterformat_t format, dns_masterrawheader_t *header);
  289 
  290 /*%<
  291  * Dump the database 'db' to the file 'filename' in the specified format by
  292  * 'format'.  If the format is dns_masterformat_text (the RFC1035 format),
  293  * 'style' specifies the file style (e.g., &dns_master_style_default).
  294  *
  295  * dns_master_dumpinc() and dns_master_dump() are old forms of _dumpinc3()
  296  * and _dump3(), respectively, which always specify the dns_masterformat_text
  297  * format.  dns_master_dumpinc2() and dns_master_dump2() are old forms which
  298  * always specify a NULL header.
  299  *
  300  * If 'format' is dns_masterformat_raw, then 'header' can contain
  301  * information to be written to the file header.
  302  *
  303  * Temporary dynamic memory may be allocated from 'mctx'.
  304  *
  305  * Returns:
  306  *\li   ISC_R_SUCCESS
  307  *\li   ISC_R_CONTINUE  dns_master_dumpinc() only.
  308  *\li   ISC_R_NOMEMORY
  309  *\li   Any database or rrset iterator error.
  310  *\li   Any dns_rdata_totext() error code.
  311  */
  312 /*@}*/
  313 
  314 isc_result_t
  315 dns_master_rdatasettotext(const dns_name_t *        owner_name,
  316               dns_rdataset_t *      rdataset,
  317               const dns_master_style_t *style, dns_indent_t *indent,
  318               isc_buffer_t *target);
  319 /*%<
  320  * Convert 'rdataset' to text format, storing the result in 'target'.
  321  *
  322  * Notes:
  323  *\li   The rdata cursor position will be changed.
  324  *
  325  * Requires:
  326  *\li   'rdataset' is a valid non-question rdataset.
  327  *
  328  *\li   'rdataset' is not empty.
  329  */
  330 
  331 isc_result_t
  332 dns_master_questiontotext(const dns_name_t *        owner_name,
  333               dns_rdataset_t *      rdataset,
  334               const dns_master_style_t *style,
  335               isc_buffer_t *        target);
  336 
  337 isc_result_t
  338 dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
  339                 dns_dbversion_t *version, dns_dbnode_t *node,
  340                 const dns_name_t *        name,
  341                 const dns_master_style_t *style, FILE *f);
  342 
  343 isc_result_t
  344 dns_master_dumpnode(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
  345             dns_dbnode_t *node, const dns_name_t *name,
  346             const dns_master_style_t *style, const char *filename);
  347 
  348 dns_masterstyle_flags_t
  349 dns_master_styleflags(const dns_master_style_t *style);
  350 
  351 isc_result_t
  352 dns_master_stylecreate(dns_master_style_t **   style,
  353                dns_masterstyle_flags_t flags, unsigned int ttl_column,
  354                unsigned int class_column, unsigned int type_column,
  355                unsigned int rdata_column, unsigned int line_length,
  356                unsigned int tab_width, unsigned int split_width,
  357                isc_mem_t *mctx);
  358 
  359 void
  360 dns_master_styledestroy(dns_master_style_t **style, isc_mem_t *mctx);
  361 
  362 ISC_LANG_ENDDECLS
  363 
  364 #endif /* DNS_MASTERDUMP_H */