mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
Added soacount and nscount
This commit is contained in:
@@ -13,16 +13,19 @@
|
|||||||
#include <dns/result.h>
|
#include <dns/result.h>
|
||||||
#include <dns/types.h>
|
#include <dns/types.h>
|
||||||
|
|
||||||
dns_result_t print_dataset(dns_name_t *owner, dns_rdataset_t *dataset);
|
dns_result_t print_dataset(dns_name_t *owner, dns_rdataset_t *dataset,
|
||||||
|
isc_mem_t *mctx);
|
||||||
|
|
||||||
isc_mem_t *mctx;
|
isc_mem_t *mctx;
|
||||||
|
|
||||||
dns_result_t
|
dns_result_t
|
||||||
print_dataset(dns_name_t *owner, dns_rdataset_t *dataset) {
|
print_dataset(dns_name_t *owner, dns_rdataset_t *dataset, isc_mem_t *mctx) {
|
||||||
char buf[64*1024];
|
char buf[64*1024];
|
||||||
isc_buffer_t target;
|
isc_buffer_t target;
|
||||||
dns_result_t result;
|
dns_result_t result;
|
||||||
|
|
||||||
|
mctx = mctx;
|
||||||
|
|
||||||
isc_buffer_init(&target, buf, 64*1024, ISC_BUFFERTYPE_TEXT);
|
isc_buffer_init(&target, buf, 64*1024, ISC_BUFFERTYPE_TEXT);
|
||||||
result = dns_rdataset_totext(dataset, owner, ISC_FALSE, &target);
|
result = dns_rdataset_totext(dataset, owner, ISC_FALSE, &target);
|
||||||
if (result == DNS_R_SUCCESS)
|
if (result == DNS_R_SUCCESS)
|
||||||
@@ -42,6 +45,8 @@ main(int argc, char *argv[]) {
|
|||||||
isc_buffer_t source;
|
isc_buffer_t source;
|
||||||
isc_buffer_t target;
|
isc_buffer_t target;
|
||||||
unsigned char name_buf[255];
|
unsigned char name_buf[255];
|
||||||
|
int soacount = 0;
|
||||||
|
int nscount = 0;
|
||||||
|
|
||||||
argc = argc;
|
argc = argc;
|
||||||
|
|
||||||
@@ -63,10 +68,14 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result = dns_load_master(argv[1], &origin, 1,
|
result = dns_load_master(argv[1], &origin, &origin, 1,
|
||||||
|
&soacount, &nscount,
|
||||||
print_dataset, mctx);
|
print_dataset, mctx);
|
||||||
fprintf(stdout, "dns_load_master: %s\n",
|
fprintf(stdout, "dns_load_master: %s\n",
|
||||||
dns_result_totext(result));
|
dns_result_totext(result));
|
||||||
|
if (result == DNS_R_SUCCESS)
|
||||||
|
fprintf(stdout, "soacount = %d, nscount = %d\n",
|
||||||
|
soacount, nscount);
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: gen.c,v 1.10 1999/01/27 13:38:18 marka Exp $ */
|
/* $Id: gen.c,v 1.11 1999/01/28 05:03:23 marka Exp $ */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
#define FROMTEXTDECL "dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target"
|
#define FROMTEXTDECL "dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target"
|
||||||
@@ -303,9 +304,26 @@ main(int argc, char **argv) {
|
|||||||
time_t now;
|
time_t now;
|
||||||
char year[11];
|
char year[11];
|
||||||
int lasttype;
|
int lasttype;
|
||||||
|
int code = 1;
|
||||||
|
int class_enum = 0;
|
||||||
|
int type_enum = 0;
|
||||||
|
int c;
|
||||||
|
|
||||||
argc = argc;
|
while ((c = getopt(argc, argv, "ct")) != -1)
|
||||||
argv = argv;
|
switch (c) {
|
||||||
|
case 'c':
|
||||||
|
code = 0;
|
||||||
|
type_enum = 0;
|
||||||
|
class_enum = 1;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
code = 0;
|
||||||
|
class_enum = 0;
|
||||||
|
type_enum = 1;
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if ((d = opendir("rdata")) == NULL)
|
if ((d = opendir("rdata")) == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -335,6 +353,7 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
fprintf(stdout, copyright, year);
|
fprintf(stdout, copyright, year);
|
||||||
|
|
||||||
|
if (code) {
|
||||||
dodecl("dns_result_t", "fromtext", FROMTEXTDECL);
|
dodecl("dns_result_t", "fromtext", FROMTEXTDECL);
|
||||||
dodecl("dns_result_t", "totext", TOTEXTDECL);
|
dodecl("dns_result_t", "totext", TOTEXTDECL);
|
||||||
dodecl("dns_result_t", "fromwire", FROMWIREDECL);
|
dodecl("dns_result_t", "fromwire", FROMWIREDECL);
|
||||||
@@ -365,7 +384,8 @@ main(int argc, char **argv) {
|
|||||||
for (tt = types; tt != NULL ; tt = tt->next)
|
for (tt = types; tt != NULL ; tt = tt->next)
|
||||||
if (tt->type != lasttype)
|
if (tt->type != lasttype)
|
||||||
fprintf(stdout, "\t{ %d, \"%s\" },%s\n",
|
fprintf(stdout, "\t{ %d, \"%s\" },%s\n",
|
||||||
lasttype = tt->type, upper(tt->typename),
|
lasttype = tt->type,
|
||||||
|
upper(tt->typename),
|
||||||
tt->next != NULL ? " \\" : "");
|
tt->next != NULL ? " \\" : "");
|
||||||
|
|
||||||
fputs("\n", stdout);
|
fputs("\n", stdout);
|
||||||
@@ -374,13 +394,41 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
for (cc = classes; cc != NULL; cc = cc->next)
|
for (cc = classes; cc != NULL; cc = cc->next)
|
||||||
fprintf(stdout, "\t{ %d, \"%s\" },%s\n", cc->class,
|
fprintf(stdout, "\t{ %d, \"%s\" },%s\n", cc->class,
|
||||||
upper(cc->classname), cc->next != NULL ? " \\" : "");
|
upper(cc->classname),
|
||||||
|
cc->next != NULL ? " \\" : "");
|
||||||
|
|
||||||
|
|
||||||
fputs("\n", stdout);
|
fputs("\n", stdout);
|
||||||
for (tt = types; tt != NULL ; tt = tt->next)
|
for (tt = types; tt != NULL ; tt = tt->next)
|
||||||
fprintf(stdout, "#include \"%s/%s_%d.h\"\n",
|
fprintf(stdout, "#include \"%s/%s_%d.h\"\n",
|
||||||
tt->dirname, tt->typename, tt->type);
|
tt->dirname, tt->typename, tt->type);
|
||||||
|
} else if (type_enum) {
|
||||||
|
fprintf(stdout, "#ifndef TYPEENUM\n");
|
||||||
|
fprintf(stdout, "#define TYPEENUM%s\n",
|
||||||
|
types != NULL ? " \\" : "");
|
||||||
|
|
||||||
|
lasttype = 0;
|
||||||
|
for (tt = types; tt != NULL ; tt = tt->next)
|
||||||
|
if (tt->type != lasttype)
|
||||||
|
fprintf(stdout, "\t ns_t_%s = %d,%s\n",
|
||||||
|
tt->typename,
|
||||||
|
lasttype = tt->type,
|
||||||
|
tt->next != NULL ? " \\" : "");
|
||||||
|
fprintf(stdout, "#endif /* TYPEENUM */\n");
|
||||||
|
} else if (class_enum) {
|
||||||
|
fprintf(stdout, "#ifndef CLASSENUM\n");
|
||||||
|
fprintf(stdout, "#define CLASSENUM%s\n",
|
||||||
|
classes != NULL ? " \\" : "");
|
||||||
|
|
||||||
|
for (cc = classes; cc != NULL; cc = cc->next)
|
||||||
|
fprintf(stdout, "\t ns_c_%s = %d,%s\n",
|
||||||
|
cc->classname,
|
||||||
|
cc->class,
|
||||||
|
cc->next != NULL ? " \\" : "");
|
||||||
|
fprintf(stdout, "#endif /* CLASSENUM */\n");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (ferror(stdout) != 0)
|
if (ferror(stdout) != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@@ -26,9 +26,13 @@
|
|||||||
#include <dns/rdataset.h>
|
#include <dns/rdataset.h>
|
||||||
|
|
||||||
dns_result_t dns_load_master(char *master_file,
|
dns_result_t dns_load_master(char *master_file,
|
||||||
|
dns_name_t *top,
|
||||||
dns_name_t *origin,
|
dns_name_t *origin,
|
||||||
dns_rdataclass_t class,
|
dns_rdataclass_t class,
|
||||||
|
int *soacount,
|
||||||
|
int *nscount,
|
||||||
dns_result_t (*callback)(dns_name_t *owner,
|
dns_result_t (*callback)(dns_name_t *owner,
|
||||||
dns_rdataset_t *dataset),
|
dns_rdataset_t *dataset,
|
||||||
|
isc_mem_t *mctx),
|
||||||
isc_mem_t *mctx);
|
isc_mem_t *mctx);
|
||||||
#endif /* DNS_MASTER_H */
|
#endif /* DNS_MASTER_H */
|
||||||
|
@@ -57,4 +57,17 @@ typedef enum {
|
|||||||
dns_bitlabel_1 = 1
|
dns_bitlabel_1 = 1
|
||||||
} dns_bitlabel_t;
|
} dns_bitlabel_t;
|
||||||
|
|
||||||
|
#include <dns/enumtype.h>
|
||||||
|
enum {
|
||||||
|
ns_t_none = 0,
|
||||||
|
TYPEENUM
|
||||||
|
ns_t_any = 255
|
||||||
|
} ns_type_t;
|
||||||
|
#include <dns/enumclass.h>
|
||||||
|
enum {
|
||||||
|
ns_c_none = 0,
|
||||||
|
CLASSENUM
|
||||||
|
ns_c_any = 255
|
||||||
|
} ns_class_t;
|
||||||
|
|
||||||
#endif /* DNS_TYPES_H */
|
#endif /* DNS_TYPES_H */
|
||||||
|
186
lib/dns/master.c
186
lib/dns/master.c
@@ -1,3 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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.5 1999/01/28 05:03:24 marka Exp $ */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -19,7 +40,9 @@ typedef ISC_LIST(dns_rdatalist_t) rdatalist_head_t;
|
|||||||
|
|
||||||
static dns_result_t commit(rdatalist_head_t *, dns_name_t *,
|
static dns_result_t commit(rdatalist_head_t *, dns_name_t *,
|
||||||
dns_result_t (*)(dns_name_t *,
|
dns_result_t (*)(dns_name_t *,
|
||||||
dns_rdataset_t *));
|
dns_rdataset_t *,
|
||||||
|
isc_mem_t *),
|
||||||
|
isc_mem_t *);
|
||||||
static isc_boolean_t is_glue(rdatalist_head_t *, dns_name_t *);
|
static isc_boolean_t is_glue(rdatalist_head_t *, dns_name_t *);
|
||||||
static dns_rdatalist_t *grow_rdatalist(int, dns_rdatalist_t *, int,
|
static dns_rdatalist_t *grow_rdatalist(int, dns_rdatalist_t *, int,
|
||||||
rdatalist_head_t *,
|
rdatalist_head_t *,
|
||||||
@@ -29,10 +52,32 @@ static dns_rdata_t *grow_rdata(int, dns_rdata_t *, int,
|
|||||||
rdatalist_head_t *, rdatalist_head_t *,
|
rdatalist_head_t *, rdatalist_head_t *,
|
||||||
isc_mem_t *);
|
isc_mem_t *);
|
||||||
|
|
||||||
|
#define GETTOKEN(lexer, options, token, eol) \
|
||||||
|
do { \
|
||||||
|
unsigned int __o; \
|
||||||
|
isc_token_t *__t = (token); \
|
||||||
|
__o = (options) | ISC_LEXOPT_EOL | ISC_LEXOPT_EOF | \
|
||||||
|
ISC_LEXOPT_DNSMULTILINE; \
|
||||||
|
if (isc_lex_gettoken(lexer, __o, __t) \
|
||||||
|
!= ISC_R_SUCCESS) { \
|
||||||
|
result = DNS_R_UNEXPECTED; \
|
||||||
|
goto cleanup; \
|
||||||
|
} \
|
||||||
|
if (eol != ISC_TRUE) \
|
||||||
|
if (__t->type == isc_tokentype_eol || \
|
||||||
|
__t->type == isc_tokentype_eof) { \
|
||||||
|
result = DNS_R_UNEXPECTEDEND; \
|
||||||
|
goto cleanup; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dns_result_t
|
dns_result_t
|
||||||
dns_load_master(char *master_file, dns_name_t *origin,
|
dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
|
||||||
dns_rdataclass_t zclass, dns_result_t (*callback)(),
|
dns_rdataclass_t zclass, int *soacount, int *nscount,
|
||||||
|
dns_result_t (*callback)(dns_name_t *, dns_rdataset_t *,
|
||||||
|
isc_mem_t *mctx),
|
||||||
isc_mem_t *mctx)
|
isc_mem_t *mctx)
|
||||||
{
|
{
|
||||||
dns_rdataclass_t class;
|
dns_rdataclass_t class;
|
||||||
@@ -42,7 +87,7 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
dns_name_t current_name;
|
dns_name_t current_name;
|
||||||
dns_name_t glue_name;
|
dns_name_t glue_name;
|
||||||
dns_name_t new_name;
|
dns_name_t new_name;
|
||||||
dns_name_t origin_name;
|
dns_name_t origin_name = *origin;
|
||||||
isc_boolean_t ttl_known = ISC_FALSE;
|
isc_boolean_t ttl_known = ISC_FALSE;
|
||||||
isc_boolean_t default_ttl_known = ISC_FALSE;
|
isc_boolean_t default_ttl_known = ISC_FALSE;
|
||||||
isc_boolean_t current_known = ISC_FALSE;
|
isc_boolean_t current_known = ISC_FALSE;
|
||||||
@@ -51,20 +96,19 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
isc_boolean_t done = ISC_FALSE;
|
isc_boolean_t done = ISC_FALSE;
|
||||||
isc_boolean_t finish_origin = ISC_FALSE;
|
isc_boolean_t finish_origin = ISC_FALSE;
|
||||||
isc_boolean_t finish_include = ISC_FALSE;
|
isc_boolean_t finish_include = ISC_FALSE;
|
||||||
|
isc_boolean_t read_till_eol = ISC_FALSE;
|
||||||
char *include_file = NULL;
|
char *include_file = NULL;
|
||||||
isc_token_t token;
|
isc_token_t token;
|
||||||
isc_lex_t *lex = NULL;
|
isc_lex_t *lex = NULL;
|
||||||
dns_result_t result = DNS_R_UNEXPECTED;
|
dns_result_t result = DNS_R_UNEXPECTED;
|
||||||
rdatalist_head_t glue_list;
|
rdatalist_head_t glue_list;
|
||||||
rdatalist_head_t current_list;
|
rdatalist_head_t current_list;
|
||||||
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
|
|
||||||
dns_rdatalist_t *this;
|
dns_rdatalist_t *this;
|
||||||
dns_rdatalist_t *rdatalist = NULL;
|
dns_rdatalist_t *rdatalist = NULL;
|
||||||
dns_rdatalist_t *new_rdatalist;
|
dns_rdatalist_t *new_rdatalist;
|
||||||
int rdlcount = 0;
|
int rdlcount = 0;
|
||||||
int rdlcount_save = 0;
|
int rdlcount_save = 0;
|
||||||
int rdatalist_size = 0;
|
int rdatalist_size = 0;
|
||||||
isc_result_t lexres;
|
|
||||||
isc_buffer_t buffer;
|
isc_buffer_t buffer;
|
||||||
isc_buffer_t target;
|
isc_buffer_t target;
|
||||||
isc_buffer_t target_save;
|
isc_buffer_t target_save;
|
||||||
@@ -114,21 +158,20 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
target_save = target;
|
target_save = target;
|
||||||
memset(name_in_use, 0, 5 * sizeof(isc_boolean_t));
|
memset(name_in_use, 0, 5 * sizeof(isc_boolean_t));
|
||||||
do {
|
do {
|
||||||
options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF |
|
GETTOKEN(lex, ISC_LEXOPT_INITIALWS, &token, ISC_TRUE);
|
||||||
ISC_LEXOPT_INITIALWS | ISC_LEXOPT_DNSMULTILINE;
|
|
||||||
lexres = isc_lex_gettoken(lex, options, &token);
|
|
||||||
if (lexres != ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token.type == isc_tokentype_eof) {
|
if (token.type == isc_tokentype_eof) {
|
||||||
done = ISC_TRUE;
|
done = ISC_TRUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.type == isc_tokentype_eol)
|
if (token.type == isc_tokentype_eol) {
|
||||||
|
read_till_eol = ISC_FALSE;
|
||||||
continue; /* blank line */
|
continue; /* blank line */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (read_till_eol)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (token.type == isc_tokentype_initialws) {
|
if (token.type == isc_tokentype_initialws) {
|
||||||
if (!current_known) {
|
if (!current_known) {
|
||||||
@@ -138,24 +181,16 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
/* still working on the same name */
|
/* still working on the same name */
|
||||||
} else if (token.type == isc_tokentype_string) {
|
} else if (token.type == isc_tokentype_string) {
|
||||||
|
|
||||||
/* XXX "$" Support */
|
/* "$" Support */
|
||||||
if (strcasecmp(token.value.as_pointer,
|
if (strcasecmp(token.value.as_pointer,
|
||||||
"$ORIGIN") == 0) {
|
"$ORIGIN") == 0) {
|
||||||
options = ISC_LEXOPT_DNSMULTILINE;
|
GETTOKEN(lex, 0, &token, ISC_FALSE);
|
||||||
lexres = isc_lex_gettoken(lex, options, &token);
|
read_till_eol = ISC_TRUE;
|
||||||
if (lexres != ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
finish_origin = ISC_TRUE;
|
finish_origin = ISC_TRUE;
|
||||||
} else if (strcasecmp(token.value.as_pointer,
|
} else if (strcasecmp(token.value.as_pointer,
|
||||||
"$TTL") == 0) {
|
"$TTL") == 0) {
|
||||||
options = ISC_LEXOPT_NUMBER;
|
GETTOKEN(lex, ISC_LEXOPT_NUMBER, &token,
|
||||||
lexres = isc_lex_gettoken(lex, options, &token);
|
ISC_FALSE);
|
||||||
if (lexres != ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
ttl = token.value.as_ulong;
|
ttl = token.value.as_ulong;
|
||||||
if (ttl > 0x7fffffff) {
|
if (ttl > 0x7fffffff) {
|
||||||
result = DNS_R_RANGE;
|
result = DNS_R_RANGE;
|
||||||
@@ -164,30 +199,24 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
default_ttl = ttl;
|
default_ttl = ttl;
|
||||||
ttl_known = ISC_TRUE;
|
ttl_known = ISC_TRUE;
|
||||||
default_ttl_known = ISC_TRUE;
|
default_ttl_known = ISC_TRUE;
|
||||||
|
read_till_eol = ISC_TRUE;
|
||||||
continue;
|
continue;
|
||||||
} else if (strcasecmp(token.value.as_pointer,
|
} else if (strcasecmp(token.value.as_pointer,
|
||||||
"$INCLUDE") == 0) {
|
"$INCLUDE") == 0) {
|
||||||
options = 0;
|
GETTOKEN(lex, 0, &token, ISC_FALSE);
|
||||||
lexres = isc_lex_gettoken(lex, options, &token);
|
|
||||||
if (lexres != ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (include_file != NULL)
|
if (include_file != NULL)
|
||||||
isc_mem_free(mctx, include_file);
|
isc_mem_free(mctx, include_file);
|
||||||
include_file = isc_mem_strdup(mctx,
|
include_file = isc_mem_strdup(mctx,
|
||||||
token.value.as_pointer);
|
token.value.as_pointer);
|
||||||
options = ISC_LEXOPT_EOF | ISC_LEXOPT_EOL;
|
GETTOKEN(lex, 0, &token, ISC_TRUE);
|
||||||
lexres = isc_lex_gettoken(lex, options, &token);
|
|
||||||
if (lexres != ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (token.type == isc_tokentype_eol ||
|
if (token.type == isc_tokentype_eol ||
|
||||||
token.type == isc_tokentype_eof) {
|
token.type == isc_tokentype_eof) {
|
||||||
result = dns_load_master(include_file,
|
result = dns_load_master(include_file,
|
||||||
origin,
|
top,
|
||||||
|
&origin_name,
|
||||||
zclass,
|
zclass,
|
||||||
|
soacount,
|
||||||
|
nscount,
|
||||||
callback,
|
callback,
|
||||||
mctx);
|
mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
@@ -195,6 +224,7 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
isc_lex_ungettoken(lex, &token);
|
isc_lex_ungettoken(lex, &token);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
read_till_eol = ISC_TRUE;
|
||||||
finish_include = ISC_TRUE;
|
finish_include = ISC_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +242,7 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
isc_buffer_setactive(&buffer,
|
isc_buffer_setactive(&buffer,
|
||||||
token.value.as_region.length);
|
token.value.as_region.length);
|
||||||
result = dns_name_fromtext(&new_name, &buffer,
|
result = dns_name_fromtext(&new_name, &buffer,
|
||||||
origin, ISC_FALSE, &name);
|
&origin_name, ISC_FALSE, &name);
|
||||||
|
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -222,14 +252,17 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
origin_in_use = new_in_use;
|
origin_in_use = new_in_use;
|
||||||
name_in_use[origin_in_use] = ISC_TRUE;
|
name_in_use[origin_in_use] = ISC_TRUE;
|
||||||
origin_name = new_name;
|
origin_name = new_name;
|
||||||
origin = &origin_name;
|
|
||||||
finish_origin =ISC_FALSE;
|
finish_origin =ISC_FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (finish_include) {
|
if (finish_include) {
|
||||||
result = dns_load_master(include_file,
|
result = dns_load_master(include_file,
|
||||||
|
top,
|
||||||
&new_name,
|
&new_name,
|
||||||
zclass, callback,
|
zclass,
|
||||||
|
soacount,
|
||||||
|
nscount,
|
||||||
|
callback,
|
||||||
mctx);
|
mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -242,7 +275,7 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
if (in_glue && dns_name_compare(&glue_name,
|
if (in_glue && dns_name_compare(&glue_name,
|
||||||
&new_name) != 0) {
|
&new_name) != 0) {
|
||||||
result = commit(&glue_list,
|
result = commit(&glue_list,
|
||||||
&glue_name, callback);
|
&glue_name, callback, mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (glue_in_use != -1)
|
if (glue_in_use != -1)
|
||||||
@@ -269,7 +302,7 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
} else {
|
} else {
|
||||||
result = commit(¤t_list,
|
result = commit(¤t_list,
|
||||||
¤t_name,
|
¤t_name,
|
||||||
callback);
|
callback, mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
rdcount = 0;
|
rdcount = 0;
|
||||||
@@ -295,12 +328,7 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
type = 0;
|
type = 0;
|
||||||
class = 0;
|
class = 0;
|
||||||
|
|
||||||
options = ISC_LEXOPT_NUMBER | ISC_LEXOPT_DNSMULTILINE;
|
GETTOKEN(lex, ISC_LEXOPT_NUMBER, &token, ISC_FALSE);
|
||||||
if (isc_lex_gettoken(lex, options, &token) != ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
options = ISC_LEXOPT_DNSMULTILINE;
|
|
||||||
|
|
||||||
if (token.type == isc_tokentype_number) {
|
if (token.type == isc_tokentype_number) {
|
||||||
ttl = token.value.as_ulong;
|
ttl = token.value.as_ulong;
|
||||||
@@ -309,11 +337,7 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ttl_known = ISC_TRUE;
|
ttl_known = ISC_TRUE;
|
||||||
if (isc_lex_gettoken(lex, options, &token) !=
|
GETTOKEN(lex, 0, &token, ISC_FALSE);
|
||||||
ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
} else if (!ttl_known && !default_ttl_known) {
|
} else if (!ttl_known && !default_ttl_known) {
|
||||||
result = DNS_R_UNEXPECTED;
|
result = DNS_R_UNEXPECTED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -326,33 +350,37 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dns_rdataclass_fromtext(&class, &token.value.as_textregion)
|
if (dns_rdataclass_fromtext(&class, &token.value.as_textregion)
|
||||||
== DNS_R_SUCCESS) {
|
== DNS_R_SUCCESS)
|
||||||
|
GETTOKEN(lex, 0, &token, ISC_FALSE);
|
||||||
if (isc_lex_gettoken(lex, options, &token) !=
|
|
||||||
ISC_R_SUCCESS) {
|
|
||||||
result = DNS_R_UNEXPECTED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token.type != isc_tokentype_string) {
|
if (token.type != isc_tokentype_string) {
|
||||||
result = DNS_R_UNEXPECTED;
|
result = DNS_R_UNEXPECTED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dns_rdatatype_fromtext(&type, &token.value.as_textregion)
|
result = dns_rdatatype_fromtext(&type,
|
||||||
!= DNS_R_SUCCESS) {
|
&token.value.as_textregion);
|
||||||
result = DNS_R_UNEXPECTED;
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (class != 0 && class != zclass) {
|
if (class != 0 && class != zclass) {
|
||||||
result = DNS_R_UNEXPECTED;
|
result = DNS_R_UNEXPECTED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 2 && !in_glue)
|
if (!in_glue && type == ns_t_soa &&
|
||||||
|
dns_name_compare(top, ¤t_name) == 0) {
|
||||||
|
(*soacount)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_glue && type == ns_t_ns &&
|
||||||
|
dns_name_compare(top, ¤t_name) == 0) {
|
||||||
|
(*nscount)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == ns_t_ns && !in_glue)
|
||||||
current_has_delegation = ISC_TRUE;
|
current_has_delegation = ISC_TRUE;
|
||||||
|
|
||||||
if (in_glue)
|
if (in_glue)
|
||||||
this = ISC_LIST_HEAD(glue_list);
|
this = ISC_LIST_HEAD(glue_list);
|
||||||
else
|
else
|
||||||
@@ -402,17 +430,19 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
rdata = new_rdata;
|
rdata = new_rdata;
|
||||||
}
|
}
|
||||||
result = dns_rdata_fromtext(&rdata[rdcount], class, type,
|
result = dns_rdata_fromtext(&rdata[rdcount], class, type,
|
||||||
lex, origin, ISC_FALSE, &target);
|
lex, &origin_name, ISC_FALSE, &target);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ISC_LIST_PREPEND(this->rdata, &rdata[rdcount], link);
|
ISC_LIST_PREPEND(this->rdata, &rdata[rdcount], link);
|
||||||
rdcount++;
|
rdcount++;
|
||||||
/* We must have at least 64k as rdlen is 16 bits. */
|
/* We must have at least 64k as rdlen is 16 bits. */
|
||||||
if (target.used > (64*1024)) {
|
if (target.used > (64*1024)) {
|
||||||
result = commit(¤t_list, ¤t_name, callback);
|
result = commit(¤t_list, ¤t_name,
|
||||||
|
callback, mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = commit(&glue_list, &glue_name, callback);
|
result = commit(&glue_list, &glue_name,
|
||||||
|
callback, mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
rdcount = 0;
|
rdcount = 0;
|
||||||
@@ -426,10 +456,10 @@ dns_load_master(char *master_file, dns_name_t *origin,
|
|||||||
ISC_BUFFERTYPE_BINARY);
|
ISC_BUFFERTYPE_BINARY);
|
||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
result = commit(¤t_list, ¤t_name, callback);
|
result = commit(¤t_list, ¤t_name, callback, mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = commit(&glue_list, &glue_name, callback);
|
result = commit(&glue_list, &glue_name, callback, mctx);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = DNS_R_SUCCESS;
|
result = DNS_R_SUCCESS;
|
||||||
@@ -555,7 +585,9 @@ grow_rdata(int new_len, dns_rdata_t *old, int old_len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static dns_result_t
|
static dns_result_t
|
||||||
commit(rdatalist_head_t *head, dns_name_t *owner, dns_result_t (*callback)()) {
|
commit(rdatalist_head_t *head, dns_name_t *owner,
|
||||||
|
dns_result_t (*callback)(), isc_mem_t *mctx)
|
||||||
|
{
|
||||||
dns_rdatalist_t *this;
|
dns_rdatalist_t *this;
|
||||||
dns_rdataset_t dataset;
|
dns_rdataset_t dataset;
|
||||||
dns_result_t result;
|
dns_result_t result;
|
||||||
@@ -564,7 +596,7 @@ commit(rdatalist_head_t *head, dns_name_t *owner, dns_result_t (*callback)()) {
|
|||||||
|
|
||||||
dns_rdataset_init(&dataset);
|
dns_rdataset_init(&dataset);
|
||||||
dns_rdatalist_tordataset(this, &dataset);
|
dns_rdatalist_tordataset(this, &dataset);
|
||||||
result = ((*callback)(owner, &dataset));
|
result = ((*callback)(owner, &dataset, mctx));
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
return (result);
|
return (result);
|
||||||
ISC_LIST_UNLINK(*head, this, link);
|
ISC_LIST_UNLINK(*head, this, link);
|
||||||
@@ -582,7 +614,7 @@ is_glue(rdatalist_head_t *head, dns_name_t *owner) {
|
|||||||
/* find NS rrset */
|
/* find NS rrset */
|
||||||
this = ISC_LIST_HEAD(*head);
|
this = ISC_LIST_HEAD(*head);
|
||||||
while (this != NULL) {
|
while (this != NULL) {
|
||||||
if (this->type == 2)
|
if (this->type == ns_t_ns)
|
||||||
break;
|
break;
|
||||||
this = ISC_LIST_NEXT(this, link);
|
this = ISC_LIST_NEXT(this, link);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user