home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / dns / master.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-09-17  |  8.3 KB  |  278 lines

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