]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/bind9/lib/dns/include/dns/master.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / bind9 / lib / dns / include / dns / master.h
1 /*
2  * Copyright (C) 2004-2008  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
18 /* $Id: master.h,v 1.51 2008/04/02 02:37:42 marka Exp $ */
19
20 #ifndef DNS_MASTER_H
21 #define DNS_MASTER_H 1
22
23 /*! \file dns/master.h */
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 #define DNS_MASTER_RESIGN       0x00002000
59
60 ISC_LANG_BEGINDECLS
61
62 /*
63  * Structures that implement the "raw" format for master dump.
64  * These are provided for a reference purpose only; in the actual
65  * encoding, we directly read/write each field so that the encoded data
66  * is always "packed", regardless of the hardware architecture.
67  */
68 #define DNS_RAWFORMAT_VERSION 0
69
70 /* Common header */
71 typedef struct {
72         isc_uint32_t            format;         /* must be
73                                                  * dns_masterformat_raw */
74         isc_uint32_t            version;        /* compatibility for future
75                                                  * extensions */
76         isc_uint32_t            dumptime;       /* timestamp on creation
77                                                  * (currently unused)
78                                                  */
79 } dns_masterrawheader_t;
80
81 /* The structure for each RRset */
82 typedef struct {
83         isc_uint32_t            totallen;       /* length of the data for this
84                                                  * RRset, including the
85                                                  * "header" part */
86         dns_rdataclass_t        rdclass;        /* 16-bit class */
87         dns_rdatatype_t         type;           /* 16-bit type */
88         dns_rdatatype_t         covers;         /* same as type */
89         dns_ttl_t               ttl;            /* 32-bit TTL */
90         isc_uint32_t            nrdata;         /* number of RRs in this set */
91         /* followed by encoded owner name, and then rdata */
92 } dns_masterrawrdataset_t;
93
94 /***
95  ***    Function
96  ***/
97
98 isc_result_t
99 dns_master_loadfile(const char *master_file,
100                     dns_name_t *top,
101                     dns_name_t *origin,
102                     dns_rdataclass_t zclass,
103                     unsigned int options,
104                     dns_rdatacallbacks_t *callbacks,
105                     isc_mem_t *mctx);
106
107 isc_result_t
108 dns_master_loadfile2(const char *master_file,
109                      dns_name_t *top,
110                      dns_name_t *origin,
111                      dns_rdataclass_t zclass,
112                      unsigned int options,
113                      dns_rdatacallbacks_t *callbacks,
114                      isc_mem_t *mctx,
115                      dns_masterformat_t format);
116
117 isc_result_t
118 dns_master_loadfile3(const char *master_file,
119                      dns_name_t *top,
120                      dns_name_t *origin,
121                      dns_rdataclass_t zclass,
122                      unsigned int options,
123                      isc_uint32_t resign,
124                      dns_rdatacallbacks_t *callbacks,
125                      isc_mem_t *mctx,
126                      dns_masterformat_t format);
127
128 isc_result_t
129 dns_master_loadstream(FILE *stream,
130                       dns_name_t *top,
131                       dns_name_t *origin,
132                       dns_rdataclass_t zclass,
133                       unsigned int options,
134                       dns_rdatacallbacks_t *callbacks,
135                       isc_mem_t *mctx);
136
137 isc_result_t
138 dns_master_loadbuffer(isc_buffer_t *buffer,
139                       dns_name_t *top,
140                       dns_name_t *origin,
141                       dns_rdataclass_t zclass,
142                       unsigned int options,
143                       dns_rdatacallbacks_t *callbacks,
144                       isc_mem_t *mctx);
145
146 isc_result_t
147 dns_master_loadlexer(isc_lex_t *lex,
148                      dns_name_t *top,
149                      dns_name_t *origin,
150                      dns_rdataclass_t zclass,
151                      unsigned int options,
152                      dns_rdatacallbacks_t *callbacks,
153                      isc_mem_t *mctx);
154
155 isc_result_t
156 dns_master_loadfileinc(const char *master_file,
157                        dns_name_t *top,
158                        dns_name_t *origin,
159                        dns_rdataclass_t zclass,
160                        unsigned int options,
161                        dns_rdatacallbacks_t *callbacks,
162                        isc_task_t *task,
163                        dns_loaddonefunc_t done, void *done_arg,
164                        dns_loadctx_t **ctxp, isc_mem_t *mctx);
165
166 isc_result_t
167 dns_master_loadfileinc2(const char *master_file,
168                         dns_name_t *top,
169                         dns_name_t *origin,
170                         dns_rdataclass_t zclass,
171                         unsigned int options,
172                         dns_rdatacallbacks_t *callbacks,
173                         isc_task_t *task,
174                         dns_loaddonefunc_t done, void *done_arg,
175                         dns_loadctx_t **ctxp, isc_mem_t *mctx,
176                         dns_masterformat_t format);
177
178 isc_result_t
179 dns_master_loadfileinc3(const char *master_file,
180                         dns_name_t *top,
181                         dns_name_t *origin,
182                         dns_rdataclass_t zclass,
183                         unsigned int options,
184                         isc_uint32_t resign,
185                         dns_rdatacallbacks_t *callbacks,
186                         isc_task_t *task,
187                         dns_loaddonefunc_t done, void *done_arg,
188                         dns_loadctx_t **ctxp, isc_mem_t *mctx,
189                         dns_masterformat_t format);
190
191 isc_result_t
192 dns_master_loadstreaminc(FILE *stream,
193                          dns_name_t *top,
194                          dns_name_t *origin,
195                          dns_rdataclass_t zclass,
196                          unsigned int options,
197                          dns_rdatacallbacks_t *callbacks,
198                          isc_task_t *task,
199                          dns_loaddonefunc_t done, void *done_arg,
200                          dns_loadctx_t **ctxp, isc_mem_t *mctx);
201
202 isc_result_t
203 dns_master_loadbufferinc(isc_buffer_t *buffer,
204                          dns_name_t *top,
205                          dns_name_t *origin,
206                          dns_rdataclass_t zclass,
207                          unsigned int options,
208                          dns_rdatacallbacks_t *callbacks,
209                          isc_task_t *task,
210                          dns_loaddonefunc_t done, void *done_arg,
211                          dns_loadctx_t **ctxp, isc_mem_t *mctx);
212
213 isc_result_t
214 dns_master_loadlexerinc(isc_lex_t *lex,
215                         dns_name_t *top,
216                         dns_name_t *origin,
217                         dns_rdataclass_t zclass,
218                         unsigned int options,
219                         dns_rdatacallbacks_t *callbacks,
220                         isc_task_t *task,
221                         dns_loaddonefunc_t done, void *done_arg,
222                         dns_loadctx_t **ctxp, isc_mem_t *mctx);
223
224 /*%<
225  * Loads a RFC1305 master file from a file, stream, buffer, or existing
226  * lexer into rdatasets and then calls 'callbacks->commit' to commit the
227  * rdatasets.  Rdata memory belongs to dns_master_load and will be
228  * reused / released when the callback completes.  dns_load_master will
229  * abort if callbacks->commit returns any value other than ISC_R_SUCCESS.
230  *
231  * If 'DNS_MASTER_AGETTL' is set and the master file contains one or more
232  * $DATE directives, the TTLs of the data will be aged accordingly.
233  *
234  * 'callbacks->commit' is assumed to call 'callbacks->error' or
235  * 'callbacks->warn' to generate any error messages required.
236  *
237  * 'done' is called with 'done_arg' and a result code when the loading
238  * is completed or has failed.  If the initial setup fails 'done' is
239  * not called.
240  *
241  * 'resign' the number of seconds before a RRSIG expires that it should
242  * be re-signed.  0 is used if not provided.
243  *
244  * Requires:
245  *\li   'master_file' points to a valid string.
246  *\li   'lexer' points to a valid lexer.
247  *\li   'top' points to a valid name.
248  *\li   'origin' points to a valid name.
249  *\li   'callbacks->commit' points to a valid function.
250  *\li   'callbacks->error' points to a valid function.
251  *\li   'callbacks->warn' points to a valid function.
252  *\li   'mctx' points to a valid memory context.
253  *\li   'task' and 'done' to be valid.
254  *\li   'lmgr' to be valid.
255  *\li   'ctxp != NULL && ctxp == NULL'.
256  *
257  * Returns:
258  *\li   ISC_R_SUCCESS upon successfully loading the master file.
259  *\li   ISC_R_SEENINCLUDE upon successfully loading the master file with
260  *              a $INCLUDE statement.
261  *\li   ISC_R_NOMEMORY out of memory.
262  *\li   ISC_R_UNEXPECTEDEND expected to be able to read a input token and
263  *              there was not one.
264  *\li   ISC_R_UNEXPECTED
265  *\li   DNS_R_NOOWNER failed to specify a ownername.
266  *\li   DNS_R_NOTTL failed to specify a ttl.
267  *\li   DNS_R_BADCLASS record class did not match zone class.
268  *\li   DNS_R_CONTINUE load still in progress (dns_master_load*inc() only).
269  *\li   Any dns_rdata_fromtext() error code.
270  *\li   Any error code from callbacks->commit().
271  */
272
273 void
274 dns_loadctx_detach(dns_loadctx_t **ctxp);
275 /*%<
276  * Detach from the load context.
277  *
278  * Requires:
279  *\li   '*ctxp' to be valid.
280  *
281  * Ensures:
282  *\li   '*ctxp == NULL'
283  */
284
285 void
286 dns_loadctx_attach(dns_loadctx_t *source, dns_loadctx_t **target);
287 /*%<
288  * Attach to the load context.
289  *
290  * Requires:
291  *\li   'source' to be valid.
292  *\li   'target != NULL && *target == NULL'.
293  */
294
295 void
296 dns_loadctx_cancel(dns_loadctx_t *ctx);
297 /*%<
298  * Cancel loading the zone file associated with this load context.
299  *
300  * Requires:
301  *\li   'ctx' to be valid
302  */
303
304 ISC_LANG_ENDDECLS
305
306 #endif /* DNS_MASTER_H */