master.c revision fdd04623a6a36aad8449ef0877d8801a558873b8
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/* $Id: master.c,v 1.11 1999/02/10 05:25:36 marka Exp $ */
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
dns_name_t *);
isc_mem_t *);
do { \
unsigned int __o; \
isc_result_t __r; \
!= ISC_R_SUCCESS) { \
switch (__r) { \
case ISC_R_NOMEMORY: \
result = DNS_R_NOMEMORY; \
break; \
default: \
"isc_lex_gettoken() failed: %s\n", \
isc_result_totext(__r)); \
result = DNS_R_UNEXPECTED; \
goto cleanup; \
} \
goto error_cleanup; \
} \
"dns_load_master: %s:%d unexpected end of %s\n", \
master_file, \
"line" : "file"); \
goto cleanup; \
} \
} while (0)
{
isc_uint32_t ttl = 0;
isc_uint32_t default_ttl = 0;
char *include_file = NULL;
int rdlcount = 0;
int rdlcount_save = 0;
int rdatalist_size = 0;
int rdcount = 0;
int rdcount_save = 0;
int rdata_size = 0;
unsigned char *target_mem = NULL;
int glue_in_use = -1;
int current_in_use = -1;
int origin_in_use = -1;
int new_in_use;
if (iresult != ISC_R_SUCCESS) {
"isc_lex_create() failed: %s\n",
goto cleanup;
}
if (iresult != ISC_R_SUCCESS) {
"isc_lex_openfile(%s) failed: %s\n",
goto cleanup;
}
if (target_mem == NULL) {
goto error_cleanup;
}
do {
continue;
}
continue; /* blank line */
}
if (read_till_eol)
continue;
if (!current_known) {
"%s: %s:%d: No current owner name\n",
"dns_load_master",
goto cleanup;
}
/* still working on the same name */
/* "$" Support */
"$ORIGIN") == 0) {
"$TTL") == 0) {
if (ttl > 0x7fffffff) {
"dns_load_master: %s:%d $TTL %lu > MAXTLL, setting TTL to 0\n",
ttl);
ttl = 0;
}
default_ttl = ttl;
continue;
"$INCLUDE") == 0) {
if (include_file != NULL)
if (include_file == NULL) {
goto error_cleanup;
}
top,
mctx);
if (result != DNS_R_SUCCESS)
goto cleanup;
continue;
}
}
if (!name_in_use[new_in_use])
break;
if (result != DNS_R_SUCCESS)
goto error_cleanup;
if (finish_origin) {
if (origin_in_use != -1)
continue;
}
if (finish_include) {
top,
&new_name,
mctx);
if (result != DNS_R_SUCCESS)
goto cleanup;
continue;
}
/*
* commit glue and pop stacks
*/
&new_name) != 0) {
&glue_name);
if (result != DNS_R_SUCCESS)
goto cleanup;
if (glue_in_use != -1)
glue_in_use = -1;
}
if (!in_glue && (!current_known ||
if (current_has_delegation &&
} else {
¤t_name);
if (result != DNS_R_SUCCESS)
goto cleanup;
rdcount = 0;
rdlcount = 0;
if (current_in_use != -1)
= ISC_FALSE;
}
}
} else {
"%s:%d: isc_lex_gettoken() returned unexpeced token type (%d)\n",
goto cleanup;
}
type = 0;
class = 0;
if (ttl > 0x7fffffff) {
"dns_load_master: %s:%d TTL %lu > maxtll, setting ttl to 0\n",
ttl);
ttl = 0;
}
} else if (!ttl_known && !default_ttl_known) {
"%s: %s:%d no TTL specified\n",
"dns_load_master", master_file,
goto cleanup;
} else if (default_ttl_known)
ttl = default_ttl;
"isc_lex_gettoken() returned unexpected token type\n");
goto cleanup;
}
== DNS_R_SUCCESS)
"isc_lex_gettoken() returned unexpected token type\n");
goto cleanup;
}
if (result != DNS_R_SUCCESS)
goto cleanup;
char buf1[32];
char buf2[32];
if (result != DNS_R_SUCCESS) {
"dns_rdataclass_totext() failed: %s",
goto cleanup;
}
if (result != DNS_R_SUCCESS) {
"dns_rdataclass_totext() failed: %s",
goto cleanup;
}
"%s: %s:%d class (%*s) != zone class (%*s)\n",
"dns_load_master", master_file,
goto cleanup;
}
(*soacount)++;
}
(*nscount)++;
}
if (in_glue)
else
break;
}
if (rdlcount == rdatalist_size) {
mctx);
if (new_rdatalist == NULL) {
goto error_cleanup;
}
rdatalist_size += 32;
}
if (in_glue)
else
"%s: %s:%d: TTL set to ealier TTL (%lu)\n",
"dns_load_master", master_file,
}
if (rdcount == rdata_size) {
goto error_cleanup;
}
rdata_size += 512;
}
if (result != DNS_R_SUCCESS)
goto cleanup;
rdcount++;
/* We must have at least 64k as rdlen is 16 bits. */
¤t_name);
if (result != DNS_R_SUCCESS)
goto cleanup;
if (result != DNS_R_SUCCESS)
goto cleanup;
rdcount = 0;
rdlcount = 0;
if (glue_in_use != -1)
glue_in_use = -1;
}
} while (!done);
if (result != DNS_R_SUCCESS)
goto cleanup;
if (result != DNS_R_SUCCESS)
goto cleanup;
else
goto cleanup;
}
rdatalist_size * sizeof *rdatalist);
if (target_mem != NULL)
if (include_file != NULL)
return (result);
}
static dns_rdatalist_t *
{
int rdlcount = 0;
return (NULL);
}
rdlcount++;
}
}
rdlcount++;
}
return (new);
}
static dns_rdata_t *
{
int rdcount = 0;
return (NULL);
/* copy current relinking */
}
rdcount++;
}
}
/* copy glue relinking */
}
rdcount++;
}
}
return (new);
}
static dns_result_t
{
if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
static isc_boolean_t
/* find NS rrset */
break;
}
return (ISC_FALSE);
return (ISC_TRUE);
}
return (ISC_FALSE);
}