2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Remove old config stuff from build.

This commit is contained in:
James Brister
1999-07-13 14:24:29 +00:00
parent 1e0134b61e
commit eabad792eb
11 changed files with 2 additions and 3993 deletions

View File

@@ -38,7 +38,7 @@ LIBS = ${DEPLIBS} \
TARGETS = named
OBJS = server.o udpclient.o tcpclient.o printmsg.o \
zone.o configctx.o confparser.o interfacemgr.o
interfacemgr.o
@BIND9_MAKE_RULES@
@@ -50,17 +50,4 @@ named: ${OBJS} ${DEPLIBS}
${LIBTOOL} ${CC} -o $@ ${OBJS} ${LIBS}
clean distclean::
rm -f ${TARGETS} confparser.c confparser_p.h
confparser.c: ${srcdir}/confparser.y
${YACC} -d ${srcdir}/confparser.y
mv y.tab.c confparser.c
mv y.tab.h confparser_p.h
##confparser.c: confparser.y
## ${YACC} -d confparser.y
## rm -f confparser.c
## sed -e '/^\#line/d' < y.tab.c > confparser.c
## rm -f y.tab.c
## chmod a-w confparser.c
## mv y.tab.h confparser_p.h
rm -f ${TARGETS}

View File

@@ -1,559 +0,0 @@
/*
* Copyright (C) 1998, 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.
*/
#include <config.h>
#include <string.h>
#include <limits.h>
#include <isc/assertions.h>
#include "configctx.h"
/* these are the bit definitions for the flag set 1 */
#define NCACHE_TTL_BIT (1 << 1)
#define TRANSFERS_IN_BIT (1 << 2)
#define TRANSFERS_PER_NS_BIT (1 << 3)
#define TRANSFERS_OUT_BIT (1 << 4)
#define MAX_LOG_BIT (1 << 5)
#define CLEAN_INT_BIT (1 << 6)
#define INTERFACE_INT_BIT (1 << 7)
#define STATS_INT_BIT (1 << 8)
#define HEARDBEAT_INT_BIT (1 << 9)
#define MAX_TRANS_TIME_BIT (1 << 10)
#define DATA_SIZE_BIT (1 << 11)
#define STACK_SIZE_BIT (1 << 12)
#define CORE_SIZE_BIT (1 << 13)
#define FILES_BIT (1 << 14)
#define QUERY_SOURCE_BIT (1 << 15)
#define QUERY_ACL_BIT (1 << 16)
#define TRANSFER_ACL_BIT (1 << 17)
#define BLOCKHOLE_ACL_BIT (1 << 18)
#define TOPOLOGY_BIT (1 << 19)
#define TRANSFER_FORMAT_BIT (1 << 20)
#define FAKE_IQUERY_BIT (1 << 21)
#define RECURSION_BIT (1 << 22)
#define FETCH_GLUE_BIT (1 << 23)
#define NOTIFY_BIT (1 << 24)
#define HOSTSTATS_BIT (1 << 25)
#define DEALLOC_ON_EXIT_BIT (1 << 26)
#define USE_IXFR_BIT (1 << 27)
#define MAINTAIN_IXFR_BASE_BIT (1 << 28)
#define HAS_OLD_CLIENTS_BIT (1 << 29)
#define AUTH_NX_DOMAIN_BIT (1 << 30)
#define MULTIPLE_CNAMES_BIT (1 << 0)
/* these are the bit definitions for the flag set 2 */
#define CHECK_NAMES_BIT (1 << 1)
#define USE_ID_POOL_BIT (1 << 2)
#define DIALUP_BIT (1 << 3)
#define CHECKBIT(bit,flags) (((flags) & (bit)) == (bit))
#define SETBIT(bit, flags) ((flags) |= (bit))
#define CLEARBIT(bit, flags) ((flags) &= ~(bit))
#define CHECKREGION(r) \
INSIST(((r)->base == NULL && (r)->length == 0) || \
((r)->base != NULL && (r)->length > 0))
#define FREE_TEXT_REGION(r,m) \
do { CHECKREGION(r) ; \
if ((r)->base != NULL) { \
isc_mem_put(m,(r)->base,(r)->length); \
(r)->base = NULL; (r)->length = 0; \
} \
} while(0)
/* I don't much like this, but there's a huge amount of code duplication
* that these macros eliminate
*/
#define FUNC_SET_FIELD(field, bit, bitset, type) \
isc_result_t \
isc_cfg_set_ ## field (isc_cfgctx_t *ctx, type value) \
{ \
INSIST(ctx != NULL); \
INSIST(ctx->options != NULL); \
\
ctx->options->field = value; \
\
SETBIT(bit, ctx->options->bitset); \
\
return (ISC_R_SUCCESS); \
}
#define FUNC_GET_FIELD(field, bit, bitset, type) \
isc_result_t \
isc_cfg_get_ ## field (isc_cfgctx_t *ctx, type *result) \
{ \
INSIST(ctx != NULL); \
INSIST(ctx->options != NULL); \
INSIST(result != NULL); \
\
if (CHECKBIT(bit,ctx->options->bitset)) { \
*result = ctx->options->field; \
return (ISC_R_SUCCESS); \
} else { \
return (ISC_R_NOTFOUND); \
} \
}
#define FUNC_SET_TEXTFIELD(field) \
isc_result_t \
isc_cfg_set_ ## field(isc_cfgctx_t *ctx, const char *value) \
{ \
isc_result_t res; \
\
INSIST(ctx != NULL); \
\
res = set_text_region(ctx->mem, &ctx->options->field, value); \
\
return (res); \
}
#define FUNC_GET_TEXTFIELD(field) \
isc_result_t \
isc_cfg_get_ ## field(isc_cfgctx_t *ctx, const char **result) \
{ \
INSIST(ctx != NULL); \
INSIST(ctx->options != NULL); \
INSIST(result != NULL); \
\
if (ctx->options->field.base != NULL) { \
*result = ctx->options->field.base; \
return (ISC_R_SUCCESS); \
} else { \
return (ISC_R_NOTFOUND); \
} \
}
static void freeoptions(isc_cfgoptions_t *opts, isc_mem_t *mem);
static isc_result_t set_text_region(isc_mem_t *mem,
isc_textregion_t *region,
const char *value);
static void opt_print_textregion(FILE *fp, const char *name,
isc_textregion_t r);
/***
*** PUBLIC
***/
isc_result_t
isc_cfg_newctx(isc_mem_t *mem, isc_cfgctx_t **ctx)
{
isc_cfgctx_t *cfg = NULL;
isc_cfgoptions_t *opts = NULL;
isc_zonectx_t *zonectx = NULL;
isc_result_t res;
INSIST(mem != NULL);
cfg = isc_mem_get(mem, sizeof *cfg);
if (cfg == NULL) {
return (ISC_R_NOMEMORY);
}
memset(cfg, 0x0, sizeof *cfg);
cfg->mem = mem;
opts = isc_mem_get(mem, sizeof *opts);
if (opts == NULL) {
isc_mem_put(mem, cfg, sizeof *cfg);
return (ISC_R_NOMEMORY);
}
memset (opts, 0x0, sizeof *opts);
cfg->options = opts;
if ((res = isc_zone_newcontext(mem, &zonectx)) != ISC_R_SUCCESS) {
isc_mem_put(mem, opts, sizeof *opts);
isc_mem_put(mem, cfg, sizeof *cfg);
return (res);
}
cfg->zonecontext = zonectx;
*ctx = cfg ;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_cfg_freectx(isc_cfgctx_t **ctx)
{
isc_cfgctx_t *c ;
INSIST(ctx != NULL);
c = *ctx;
INSIST(c->mem != NULL);
if (c->options != NULL) {
freeoptions(c->options, c->mem);
}
isc_mem_put(c->mem, c, sizeof *c);
*ctx = NULL;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_cfg_erase_options(isc_cfgctx_t *ctx)
{
INSIST(ctx != NULL);
INSIST(ctx->options != NULL);
freeoptions(ctx->options, ctx->mem);
ctx->options = isc_mem_get(ctx->mem, sizeof *ctx->options);
if (ctx->options == NULL) {
return (ISC_R_NOMEMORY);
}
memset (ctx->options, 0x0, sizeof *ctx->options);
return (ISC_R_SUCCESS);
}
void
isc_cfg_dump_config(FILE *fp, isc_cfgctx_t *cfg)
{
INSIST(cfg != NULL);
INSIST(fp != NULL);
isc_cfg_dump_options(fp, cfg->options);
if (cfg->zonecontext != NULL) {
isc_zonectx_dump(fp, cfg->zonecontext);
}
}
static void
print_in_units(FILE *fp, unsigned long val)
{
unsigned long one_gig = (1024 * 1024 * 1024);
unsigned long one_meg = (1024 * 1024);
unsigned long one_k = 1024;
if ((val % one_gig) == 0)
fprintf(fp, "%luG", val / one_gig);
else if ((val % one_meg) == 0)
fprintf(fp, "%luM", val / one_meg);
else if ((val % one_k) == 0)
fprintf(fp, "%luK", val / one_k);
else if (val == ULONG_MAX)
fprintf(fp, "unlimited");
else
fprintf(fp, "%lu", val);
}
void
isc_cfg_dump_options(FILE *fp, isc_cfgoptions_t *options)
{
INSIST(options != NULL);
INSIST(fp != NULL);
#define PRINT_AS_MINUTES(field, bit, name, bitfield) \
if (CHECKBIT(bit, options->bitfield)) { \
fprintf(fp, "\t%s %lu;\n",name, \
(unsigned long)options->field / 60); \
}
#define PRINT_AS_BOOLEAN(field, bit, name, bitfield) \
if (CHECKBIT(bit, options->bitfield)) { \
fprintf(fp, "\t%s %s;\n",name, \
(options->field ? "true" : "false")); \
}
#define PRINT_AS_SIZE_CLAUSE(field, bit, name, bitfield) \
if (CHECKBIT(bit,options->bitfield)) { \
fprintf(fp, "\t%s ",name); \
if (options->field == 0) { \
fprintf(fp, "default"); \
} else { \
print_in_units(fp,options->data_size); \
} \
fprintf(fp, ";\n"); \
}
fprintf (fp, "options {\n");
opt_print_textregion(fp, "version", options->version);
opt_print_textregion(fp, "directory", options->directory);
opt_print_textregion(fp, "named-xfer", options->named_xfer);
opt_print_textregion(fp, "pid-file", options->pid_filename);
opt_print_textregion(fp, "statistics-file", options->stats_filename);
opt_print_textregion(fp, "memstatistics-file",
options->memstats_filename);
opt_print_textregion(fp, "dump-file", options->dump_filename);
PRINT_AS_BOOLEAN(fake_iquery, FAKE_IQUERY_BIT,
"fake-iquery", set_flags1);
PRINT_AS_BOOLEAN(recursion, RECURSION_BIT,
"recursion", set_flags1);
PRINT_AS_BOOLEAN(fetch_glue, FETCH_GLUE_BIT,
"fetch-glue", set_flags1);
PRINT_AS_BOOLEAN(notify, NOTIFY_BIT,
"notify", set_flags1);
PRINT_AS_BOOLEAN(hoststats, HOSTSTATS_BIT,
"hoststats", set_flags1);
PRINT_AS_BOOLEAN(dealloc_on_exit, DEALLOC_ON_EXIT_BIT,
"deallocate-on-exit", set_flags1);
PRINT_AS_BOOLEAN(use_ixfr, USE_IXFR_BIT,
"use_ixfr", set_flags1);
PRINT_AS_BOOLEAN(maintain_ixfr_base, MAINTAIN_IXFR_BASE_BIT,
"maintain-ixfr-base", set_flags1);
PRINT_AS_BOOLEAN(has_old_clients, HAS_OLD_CLIENTS_BIT,
"has-old-clients", set_flags1);
PRINT_AS_BOOLEAN(auth_nx_domain, AUTH_NX_DOMAIN_BIT,
"auth-nxdomain", set_flags1);
PRINT_AS_BOOLEAN(multiple_cnames, MULTIPLE_CNAMES_BIT,
"multiple-cnames", set_flags1);
PRINT_AS_BOOLEAN(use_id_pool, USE_ID_POOL_BIT,
"use-id-pool", set_flags2);
PRINT_AS_BOOLEAN(dialup, DIALUP_BIT,
"dialup", set_flags2);
PRINT_AS_SIZE_CLAUSE(data_size, DATA_SIZE_BIT, "datasize",
set_flags1);
PRINT_AS_SIZE_CLAUSE(stack_size, STACK_SIZE_BIT, "stacksize",
set_flags1);
PRINT_AS_SIZE_CLAUSE(core_size, CORE_SIZE_BIT, "coresize",
set_flags1);
PRINT_AS_SIZE_CLAUSE(files, FILES_BIT, "files",
set_flags1);
PRINT_AS_MINUTES(max_transfer_time_in, MAX_TRANS_TIME_BIT,
"max-transfer-time-in", set_flags1);
PRINT_AS_MINUTES(clean_interval, CLEAN_INT_BIT,
"cleaning-interval", set_flags1);
PRINT_AS_MINUTES(interface_interval, INTERFACE_INT_BIT,
"interface-interval", set_flags1);
PRINT_AS_MINUTES(stats_interval, STATS_INT_BIT,
"statistics-interval", set_flags1);
fprintf(fp,"};\n");
}
/****
**** ACCESSORS/MODIFIERS
****/
/* This is seriously ugly, but we have nothing like C++ templates here.... */
FUNC_SET_TEXTFIELD(directory)
FUNC_GET_TEXTFIELD(directory)
FUNC_SET_TEXTFIELD(version)
FUNC_GET_TEXTFIELD(version)
FUNC_SET_TEXTFIELD(dump_filename)
FUNC_GET_TEXTFIELD(dump_filename)
FUNC_SET_TEXTFIELD(pid_filename)
FUNC_GET_TEXTFIELD(pid_filename)
FUNC_SET_TEXTFIELD(stats_filename)
FUNC_GET_TEXTFIELD(stats_filename)
FUNC_SET_TEXTFIELD(memstats_filename)
FUNC_GET_TEXTFIELD(memstats_filename)
FUNC_SET_TEXTFIELD(named_xfer)
FUNC_GET_TEXTFIELD(named_xfer)
FUNC_SET_FIELD(max_ncache_ttl, NCACHE_TTL_BIT, set_flags1, unsigned int)
FUNC_GET_FIELD(max_ncache_ttl, NCACHE_TTL_BIT, set_flags1, unsigned int)
FUNC_SET_FIELD(transfers_in, TRANSFERS_IN_BIT, set_flags1, int)
FUNC_GET_FIELD(transfers_in, TRANSFERS_IN_BIT, set_flags1, int)
FUNC_SET_FIELD(transfers_per_ns, TRANSFERS_PER_NS_BIT, set_flags1, int)
FUNC_GET_FIELD(transfers_per_ns, TRANSFERS_PER_NS_BIT, set_flags1, int)
FUNC_SET_FIELD(transfers_out, TRANSFERS_OUT_BIT, set_flags1, int)
FUNC_GET_FIELD(transfers_out, TRANSFERS_OUT_BIT, set_flags1, int)
FUNC_SET_FIELD(max_log_size_ixfr, MAX_LOG_BIT, set_flags1, int)
FUNC_GET_FIELD(max_log_size_ixfr, MAX_LOG_BIT, set_flags1, int)
FUNC_SET_FIELD(clean_interval, CLEAN_INT_BIT, set_flags1, int)
FUNC_GET_FIELD(clean_interval, CLEAN_INT_BIT, set_flags1, int)
FUNC_SET_FIELD(interface_interval, INTERFACE_INT_BIT, set_flags1, int)
FUNC_GET_FIELD(interface_interval, INTERFACE_INT_BIT, set_flags1, int)
FUNC_SET_FIELD(stats_interval, STATS_INT_BIT, set_flags1, int)
FUNC_GET_FIELD(stats_interval, STATS_INT_BIT, set_flags1, int)
FUNC_SET_FIELD(heartbeat_interval, HEARDBEAT_INT_BIT, set_flags1, int)
FUNC_GET_FIELD(heartbeat_interval, HEARDBEAT_INT_BIT, set_flags1, int)
FUNC_SET_FIELD(max_transfer_time_in,MAX_TRANS_TIME_BIT, set_flags1, long)
FUNC_GET_FIELD(max_transfer_time_in,MAX_TRANS_TIME_BIT, set_flags1, long)
FUNC_SET_FIELD(data_size, DATA_SIZE_BIT, set_flags1, unsigned long)
FUNC_GET_FIELD(data_size, DATA_SIZE_BIT, set_flags1, unsigned long)
FUNC_SET_FIELD(stack_size, STACK_SIZE_BIT, set_flags1, unsigned long)
FUNC_GET_FIELD(stack_size, STACK_SIZE_BIT, set_flags1, unsigned long)
FUNC_SET_FIELD(core_size, CORE_SIZE_BIT, set_flags1, unsigned long)
FUNC_GET_FIELD(core_size, CORE_SIZE_BIT, set_flags1, unsigned long)
FUNC_SET_FIELD(files, FILES_BIT, set_flags1, unsigned long)
FUNC_GET_FIELD(files, FILES_BIT, set_flags1, unsigned long)
FUNC_SET_FIELD(fake_iquery, FAKE_IQUERY_BIT, set_flags1, isc_boolean_t)
FUNC_GET_FIELD(fake_iquery, FAKE_IQUERY_BIT, set_flags1, isc_boolean_t)
FUNC_SET_FIELD(recursion, RECURSION_BIT, set_flags1, isc_boolean_t)
FUNC_GET_FIELD(recursion, RECURSION_BIT, set_flags1, isc_boolean_t)
FUNC_SET_FIELD(fetch_glue, FETCH_GLUE_BIT, set_flags1, isc_boolean_t)
FUNC_GET_FIELD(fetch_glue, FETCH_GLUE_BIT, set_flags1, isc_boolean_t)
FUNC_SET_FIELD(notify, NOTIFY_BIT, set_flags1, isc_boolean_t)
FUNC_GET_FIELD(notify, NOTIFY_BIT, set_flags1, isc_boolean_t)
FUNC_SET_FIELD(hoststats, HOSTSTATS_BIT, set_flags1, isc_boolean_t)
FUNC_GET_FIELD(hoststats, HOSTSTATS_BIT, set_flags1, isc_boolean_t)
FUNC_SET_FIELD(dealloc_on_exit, DEALLOC_ON_EXIT_BIT, set_flags1,
isc_boolean_t)
FUNC_GET_FIELD(dealloc_on_exit, DEALLOC_ON_EXIT_BIT, set_flags1,
isc_boolean_t)
FUNC_SET_FIELD(use_ixfr, USE_IXFR_BIT, set_flags1, isc_boolean_t)
FUNC_GET_FIELD(use_ixfr, USE_IXFR_BIT, set_flags1, isc_boolean_t)
FUNC_SET_FIELD(maintain_ixfr_base, MAINTAIN_IXFR_BASE_BIT, set_flags1,
isc_boolean_t)
FUNC_GET_FIELD(maintain_ixfr_base, MAINTAIN_IXFR_BASE_BIT, set_flags1,
isc_boolean_t)
FUNC_SET_FIELD(has_old_clients, HAS_OLD_CLIENTS_BIT, set_flags1,
isc_boolean_t)
FUNC_GET_FIELD(has_old_clients, HAS_OLD_CLIENTS_BIT, set_flags1,
isc_boolean_t)
FUNC_SET_FIELD(auth_nx_domain, AUTH_NX_DOMAIN_BIT, set_flags1, isc_boolean_t)
FUNC_GET_FIELD(auth_nx_domain, AUTH_NX_DOMAIN_BIT, set_flags1, isc_boolean_t)
FUNC_SET_FIELD(multiple_cnames, MULTIPLE_CNAMES_BIT, set_flags1,
isc_boolean_t)
FUNC_GET_FIELD(multiple_cnames, MULTIPLE_CNAMES_BIT, set_flags1,
isc_boolean_t)
FUNC_SET_FIELD(use_id_pool, USE_ID_POOL_BIT, set_flags2, isc_boolean_t)
FUNC_GET_FIELD(use_id_pool, USE_ID_POOL_BIT, set_flags2, isc_boolean_t)
FUNC_SET_FIELD(dialup, DIALUP_BIT, set_flags2, isc_boolean_t)
FUNC_GET_FIELD(dialup, DIALUP_BIT, set_flags2, isc_boolean_t)
/***
*** PRIVATE
***/
static isc_result_t
set_text_region(isc_mem_t *mem, isc_textregion_t *region, const char *value)
{
size_t len;
INSIST(mem != NULL);
INSIST(value != NULL);
INSIST(region != NULL);
len = strlen(value) + 1;
INSIST(len > 1);
CHECKREGION(region);
if (region->base != NULL && region->length < len) {
isc_mem_put(mem, region->base, region->length);
region->base = NULL;
region->length = 0;
}
if (region->base == NULL) {
region->base = isc_mem_get(mem, len);
if (region->base == NULL) {
return (ISC_R_NOMEMORY);
}
region->length = len;
}
strcpy(region->base, value);
return (ISC_R_SUCCESS);
}
static void
freeoptions(isc_cfgoptions_t *opts, isc_mem_t *mem)
{
INSIST(opts != NULL);
FREE_TEXT_REGION(&opts->directory, mem);
FREE_TEXT_REGION(&opts->version, mem);
FREE_TEXT_REGION(&opts->dump_filename, mem);
FREE_TEXT_REGION(&opts->pid_filename, mem);
FREE_TEXT_REGION(&opts->stats_filename, mem);
FREE_TEXT_REGION(&opts->memstats_filename, mem);
FREE_TEXT_REGION(&opts->named_xfer, mem);
isc_mem_put(mem, opts, sizeof *opts);
}
static void
opt_print_textregion(FILE *fp, const char *name, isc_textregion_t r)
{
CHECKREGION(&r);
if (r.length > 0) {
fprintf(fp,"\t%s \"%s\";\n", name, r.base);
}
}

View File

@@ -1,246 +0,0 @@
/*
* Copyright (C) 1998, 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.
*/
/****
**** MODULE INFO
****/
/*
* Top level Data structure and accessors for the data defined in the
* config file.
*
* MP:
*
* Caller must do necessary locking.
*
* Reliability:
*
*
* Resources:
*
*
* Security:
*
*
* Standards:
*
*/
#if !defined(CONFIGCTX_H)
#define CONFIGCTX_H 1
#include <isc/mem.h>
#include "zone.h"
/* Data from an 'options' config file statement */
typedef struct isc_cfgoptions
{
isc_textregion_t directory;
isc_textregion_t version;
isc_textregion_t dump_filename;
isc_textregion_t pid_filename;
isc_textregion_t stats_filename;
isc_textregion_t memstats_filename;
isc_textregion_t named_xfer;
unsigned int flags;
unsigned int max_ncache_ttl;
int transfers_in;
int transfers_per_ns;
int transfers_out;
int max_log_size_ixfr;
int clean_interval;
int interface_interval;
int stats_interval;
int heartbeat_interval;
isc_boolean_t fake_iquery;
isc_boolean_t recursion;
isc_boolean_t fetch_glue;
isc_boolean_t notify;
isc_boolean_t hoststats;
isc_boolean_t dealloc_on_exit;
isc_boolean_t use_ixfr;
isc_boolean_t maintain_ixfr_base;
isc_boolean_t has_old_clients;
isc_boolean_t auth_nx_domain;
isc_boolean_t multiple_cnames;
isc_boolean_t use_id_pool;
isc_boolean_t dialup;
long max_transfer_time_in;
unsigned long data_size;
unsigned long stack_size;
unsigned long core_size;
unsigned long files;
#if 0
struct sockaddr_in query_source;
ip_match_list query_acl;
ip_match_list transfer_acl;
ip_match_list blackhole_acl;
ip_match_list topology;
#ifdef SORT_RESPONSE
ip_match_list sortlist;
#endif /* SORT_RESPONSE */
enum axfr_format transfer_format;
enum severity check_names[num_trans];
listen_info_list listen_list;
struct fwdinfo *fwdtab;
rrset_order_list ordering;
#endif
/* For the non-pointer members of the struct a bit will be set in
* this field if a value was explicitly set.
*/
isc_uint64_t set_flags1;
isc_uint64_t set_flags2;
} isc_cfgoptions_t;
/* Master config structure. All the information defined in a config file is
* reachable through here.
*/
typedef struct isc_cfgctx
{
int warnings; /* number of parse warnings */
int errors; /* number of parse semantic errors */
isc_mem_t *mem; /* where we get our memory from */
isc_cfgoptions_t *options;
isc_zonectx_t *zonecontext;
/* XXX other config stuff like trusted keys, acls, logging etc. */
} isc_cfgctx_t;
isc_result_t isc_cfg_newctx(isc_mem_t *mem, isc_cfgctx_t **ctx);
isc_result_t isc_cfg_freectx(isc_cfgctx_t **ctx);
/* Reset the options back to virgin state. */
isc_result_t isc_cfg_erase_options(isc_cfgctx_t *ctx);
/* Send a properly formatted context to the given stream */
void isc_cfg_dump_config(FILE *fp, isc_cfgctx_t *ctx);
void isc_cfg_dump_options(FILE *fp, isc_cfgoptions_t *options);
/* Set functions for all the options fields. */
isc_result_t isc_cfg_set_directory(isc_cfgctx_t *ctx, const char *directory);
isc_result_t isc_cfg_set_version(isc_cfgctx_t *ctx, const char *directory);
isc_result_t isc_cfg_set_dump_filename(isc_cfgctx_t *ctx,
const char *directory);
isc_result_t isc_cfg_set_pid_filename(isc_cfgctx_t *ctx,
const char *directory);
isc_result_t isc_cfg_set_stats_filename(isc_cfgctx_t *ctx,
const char *directory);
isc_result_t isc_cfg_set_memstats_filename(isc_cfgctx_t *ctx,
const char *directory);
isc_result_t isc_cfg_set_named_xfer(isc_cfgctx_t *ctx, const char *directory);
isc_result_t isc_cfg_set_max_ncache_ttl(isc_cfgctx_t*ctx, unsigned int value);
isc_result_t isc_cfg_set_transfers_in(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_transfers_per_ns(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_transfers_out(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_max_log_size_ixfr(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_clean_interval(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_interface_interval(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_stats_interval(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_heartbeat_interval(isc_cfgctx_t*ctx, int value);
isc_result_t isc_cfg_set_max_transfer_time_in(isc_cfgctx_t*ctx, long value);
isc_result_t isc_cfg_set_data_size(isc_cfgctx_t *ctx, unsigned long value);
isc_result_t isc_cfg_set_stack_size(isc_cfgctx_t *ctx, unsigned long value);
isc_result_t isc_cfg_set_core_size(isc_cfgctx_t *ctx, unsigned long value);
isc_result_t isc_cfg_set_files(isc_cfgctx_t *ctx, unsigned long value);
isc_result_t isc_cfg_set_fake_iquery(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_recursion(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_fetch_glue(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_notify(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_hoststats(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_dealloc_on_exit(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_use_ixfr(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_maintain_ixfr_base(isc_cfgctx_t *ctx,
isc_boolean_t bv);
isc_result_t isc_cfg_set_has_old_clients(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_auth_nx_domain(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_multiple_cnames(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_use_id_pool(isc_cfgctx_t *ctx, isc_boolean_t bv);
isc_result_t isc_cfg_set_dialup(isc_cfgctx_t *ctx, isc_boolean_t bv);
/* Get functions for all the option fields. Caller must not modify the
* results. If the fields was not set, the ISC_R_NOTFOUND is returned,
* otherwise ISC_R_SUCCESS
*/
isc_result_t isc_cfg_get_named_xfer(isc_cfgctx_t *ctx, const char **result);
isc_result_t isc_cfg_get_directory(isc_cfgctx_t *ctx, const char **result);
isc_result_t isc_cfg_get_version(isc_cfgctx_t *ctx, const char **result);
isc_result_t isc_cfg_get_dump_filename(isc_cfgctx_t *ctx,
const char **result);
isc_result_t isc_cfg_get_pid_filename(isc_cfgctx_t *ctx,
const char **result);
isc_result_t isc_cfg_get_stats_filename(isc_cfgctx_t *ctx,
const char **result);
isc_result_t isc_cfg_get_memstats_filename(isc_cfgctx_t *ctx,
const char **result);
isc_result_t isc_cfg_get_max_ncache_ttl(isc_cfgctx_t *ctx,
unsigned int *result);
isc_result_t isc_cfg_get_transfers_in(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_transfers_per_ns(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_transfers_out(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_max_log_size_ixfr(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_clean_interval(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_interface_interval(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_stats_interval(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_heartbeat_interval(isc_cfgctx_t *ctx, int *result);
isc_result_t isc_cfg_get_max_transfer_time_in(isc_cfgctx_t *ctx, long *result);
isc_result_t isc_cfg_get_data_size(isc_cfgctx_t *ctx, unsigned long *result);
isc_result_t isc_cfg_get_stack_size(isc_cfgctx_t *ctx, unsigned long *result);
isc_result_t isc_cfg_get_core_size(isc_cfgctx_t *ctx, unsigned long *result);
isc_result_t isc_cfg_get_files(isc_cfgctx_t *ctx, unsigned long *result);
isc_result_t isc_cfg_get_fake_iquery(isc_cfgctx_t *ctx, isc_boolean_t *result);
isc_result_t isc_cfg_get_recursion(isc_cfgctx_t *ctx, isc_boolean_t *result);
isc_result_t isc_cfg_get_fetch_glue(isc_cfgctx_t *ctx, isc_boolean_t *result);
isc_result_t isc_cfg_get_notify(isc_cfgctx_t *ctx, isc_boolean_t *result);
isc_result_t isc_cfg_get_hoststats(isc_cfgctx_t *ctx, isc_boolean_t *result);
isc_result_t isc_cfg_get_dealloc_on_exit(isc_cfgctx_t *ctx,
isc_boolean_t *result);
isc_result_t isc_cfg_get_use_ixfr(isc_cfgctx_t *ctx, isc_boolean_t *result);
isc_result_t isc_cfg_get_maintain_ixfr_base(isc_cfgctx_t *ctx,
isc_boolean_t *result);
isc_result_t isc_cfg_get_has_old_clients(isc_cfgctx_t *ctx,
isc_boolean_t *result);
isc_result_t isc_cfg_get_auth_nx_domain(isc_cfgctx_t *ctx,
isc_boolean_t *result);
isc_result_t isc_cfg_get_multiple_cnames(isc_cfgctx_t *ctx,
isc_boolean_t *result);
isc_result_t isc_cfg_get_use_id_pool(isc_cfgctx_t *ctx, isc_boolean_t *result);
isc_result_t isc_cfg_get_dialup(isc_cfgctx_t *ctx, isc_boolean_t *result);
#endif

View File

@@ -1,107 +0,0 @@
/*
* Copyright (C) 1998, 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.
*/
/*****
***** Module Info
*****/
/*
* Parser
*
* The parser module handles the parsing of config files. Two entry points
* are provided:
*
* parser_init()
*
* parse_configuration(const char *filename,
* isc_mem_t *mem, isc_cfgctx_t **configctx);
*
*
* MP:
* Only a single thread is let through the module at once.
*
* The program *MUST* first call parser_init() one time. Calling
* parser_init() more than once may result in abort() dump (best case)
* or undefined behaviour (worst case).
*
* Reliability:
* No anticipated impact.
*
* Resources:
* <TBS>
*
* Security:
* <TBS>
*
* Standards:
* None.
*/
/***
*** Imports
***/
#include <config.h>
#include "configctx.h"
/***
*** Functions
***/
isc_result_t parser_init(void);
/*
* Does parser intitialization. Must be called before
* isc_parse_configuration() is called
*
* Requires:
* The caller do necessary locking to prevent multiple threads from
* calling it at once.
*
* Ensures:
* Nothing.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_FAILURE something broke
*/
isc_result_t parse_configuration(const char *filename, isc_mem_t *mem,
isc_cfgctx_t **configctx);
/*
* Parse the confile file. Fills up the config context with the new config
* data. All memory allocations for the contents of configctx are done
* using the MEM argument.
*
* Requires:
* *filename is a valid filename.
* *mem is a valid memory manager.
* *configctx is a valid isc_config_ctx_t pointer
*
* Ensures:
* On success, *configctx is attached to the newly created config context.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOMEMORY
* ISC_R_INVALIDFILE file doesn't exist or is unreadable
* ISC_R_FAILURE file contains errors.
*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,72 +0,0 @@
%{
#if !defined(lint) && !defined(SABER)
static char rcsid[] = "$Id: lexer.l,v 1.1 1999/01/30 00:50:10 brister Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996-1999 by 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.
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include "zone.h"
#include "parser_p.h"
int yylex(void);
%}
qstring \"[^\"\n]*[\"\n]
intnum -?[0-9]+
ws [ \t]+
%%
"{" { return (L_LBRACE); }
"}" { return (L_RBRACE); }
";" { return (L_EOS); }
"options" { return (L_OPTIONS); }
"directory" { return (L_DIRECTORY); }
"zone" { return (L_ZONE); }
"type" { return (L_TYPE); }
"file" { return (L_FILE); }
"master" { return (L_MASTER); }
"slave" { return (L_SLAVE); }
"hint" { return (L_HINT); }
"stub" { return (L_STUB); }
"forward" { return (L_FORWARD); }
{intnum} {
yylval.num = strtol(yytext, NULL, 10);
return (L_INTEGER);
}
{qstring} {
yylval.cp = strdup(yytext + 1); /* skip open quote */
if (yylval.cp[yyleng - 2] != '"') {
/* XXX use an isc log function. */
fprintf(stderr, "Unterminated string");
} else {
yylval.cp[yyleng - 2] = '\0';
return L_QSTRING;
}
}

View File

@@ -1,100 +0,0 @@
/*
* Copyright (C) 1998, 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.
*/
/*****
***** Module Info
*****/
/*
* Parser
*
* The parser module handles the parsing of config files.
*
* MP:
* Only a single thread is let through the modules at once.
* access.
*
* Reliability:
* No anticipated impact.
*
* Resources:
* <TBS>
*
* Security:
* <TBS>
*
* Standards:
* None.
*/
/***
*** Imports
***/
#include <config.h>
#include "configctx.h"
/***
*** Functions
***/
isc_result_t
isc_parser_init(void);
/*
* Does parser intitialization. Must be called before
* isc_parse_configuration() is called
*
* Requires:
* The caller do necessary locking to prevent multiple threads from
* calling it at once.
*
* Ensures:
* Nothing.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_FAILURE something broke
*/
isc_result_t
isc_parse_configuration(const char *filename,
isc_mem_t *mem,
isc_cfgctx_t **configctx);
/*
* Parse the confile file. Fills up the config context with the new config
* data. All memory allocations for the contents of configctx are done
* using the MEM argument.
*
* Requires:
* *filename is a valid filename.
* *mem is a valid memory manager.
* *configctx is a valid isc_config_ctx_t pointer
*
* Ensures:
* On success, *configctx is attached to the newly created config context.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOMEMORY
* ISC_R_INVALIDFILE file doesn't exist or is unreadable
* ISC_R_FAILURE file contains errors.
*/

View File

@@ -1,304 +0,0 @@
%{
#if !defined(lint) && !defined(SABER)
static char rcsid[] = "$Id: parser.y,v 1.1 1999/01/30 00:50:10 brister Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996-1999 by 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.
*/
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <isc/assertions.h>
#include <isc/mutex.h>
#include "parser.h"
#include "zone.h"
#include "configctx.h"
static int onetime ;
static isc_mutex_t yacc_mutex;
static isc_zonectx_t *currzonectx;
static isc_zoneinfo_t *currzone;
static isc_cfgctx_t *currcfg;
static const char *currfile;
static void parser_cleanup(void);
static void print_msg(char *fmt, va_list args);
static void parser_warning(char *fmt, ...);
static void parser_error(char *fmt, ...);
int yyparse(void);
void yyerror(const char *);
int yylex(void);
%}
%union {
char * cp;
long num;
isc_zonet_t ztype;
}
%token L_LBRACE
%token L_RBRACE
%token L_EOS
%token L_MASTER
%token L_SLAVE
%token L_HINT
%token L_STUB
%token L_FORWARD
/* options statement */
%token L_OPTIONS
%token L_DIRECTORY
/* Zone statements */
%token L_ZONE
%type <ztype> zone_type
%token L_TYPE
%token L_FILE
/* Misc */
%token <cp> L_STRING
%token <cp> L_QSTRING
%token <num> L_INTEGER
%%
config_file: statement_list
{
/* XXX Do post-read validations etc. */
}
;
statement_list: statement
| statement_list statement
;
statement: options_stmt L_EOS
| zone L_EOS
;
options_stmt: L_OPTIONS L_LBRACE options_list L_RBRACE
;
options_list: option L_EOS
| options_list option L_EOS
;
option: /* Empty */
| L_DIRECTORY L_QSTRING
{
printf("doing the option\n");
if (isc_cfg_setdirectory(currcfg, $2) != ISC_R_SUCCESS) {
parser_cleanup();
fprintf(stderr, "setdirectory error\n");
return (1);
}
}
;
zone: L_ZONE L_QSTRING
{
isc_zoneinfo_t *zi = NULL;
if (isc_zone_newinfo(currzonectx, &zi) != ISC_R_SUCCESS) {
parser_cleanup();
fprintf(stderr, "newzone error\n");
return (1);
}
isc_zone_setorigin(zi, $2);
currzone = zi;
} optional_zone_options_list {
/* XXX install zone if parsed correctly and remove
it if not. */
}
;
optional_zone_options_list: /* Empty */
| L_LBRACE zone_option_list L_RBRACE
;
zone_option_list: zone_option L_EOS
| zone_option_list zone_option L_EOS
;
zone_option: L_TYPE zone_type
{
}
| L_FILE L_QSTRING
{
INSIST(currzone != NULL);
if (currzone->source != NULL) {
parser_warning("zone filename already set; skipping");
} else {
isc_zone_setsource(currzone, $2);
}
}
;
zone_type: L_MASTER
{
$$ = zone_master;
}
| L_SLAVE
{
$$ = zone_slave;
}
| L_HINT
{
$$ = zone_hint;
}
| L_STUB
{
$$ = zone_stub;
}
| L_FORWARD
{
$$ = zone_forward;
}
;
%%
isc_result_t
isc_parser_init()
{
isc_result_t res = ISC_R_SUCCESS;
if (onetime == 0) {
/* our caller is locking us */
res = isc_mutex_init(&yacc_mutex);
onetime++;
}
return (res);
}
isc_result_t
isc_parse_configuration(const char *filename,
isc_mem_t *mem,
isc_cfgctx_t **configctx) {
isc_result_t res ;
isc_result_t t;
FILE *fp;
extern FILE *yyin;
/* Take out mutex on whole parser. */
if (isc_mutex_lock(&yacc_mutex) != ISC_R_SUCCESS) {
return (ISC_R_UNEXPECTED);
}
INSIST(currcfg == NULL);
if ((res = isc_cfg_newctx(mem, &currcfg)) != ISC_R_SUCCESS) {
isc_mutex_unlock(&yacc_mutex);
return (res);
}
if ((fp = fopen(filename, "r")) == NULL) {
isc_mutex_unlock(&yacc_mutex);
return (ISC_R_INVALIDFILE);
}
yyin = fp ;
currfile = filename;
currzonectx = currcfg->zonecontext;
if (yyparse() != 0) {
res = ISC_R_FAILURE;
}
fclose(fp);
*configctx = currcfg;
currcfg = NULL;
if ((t = isc_mutex_unlock(&yacc_mutex)) != ISC_R_SUCCESS) {
res = t;
}
return (res);
}
/***
*** PRIVATE
***/
static void
parser_cleanup(void)
{
/* XXX destroy the config context */
}
static void
print_msg(char *fmt, va_list args)
{
fprintf(stderr," %s: \n", currfile);
vfprintf(stderr, fmt, args);
}
static void
parser_warning(char *fmt, ...)
{
va_list args;
va_start(args, fmt);
print_msg(fmt, args);
va_end(args);
currcfg->warnings++;
}
static void
parser_error(char *fmt, ...)
{
va_list args;
va_start(args, fmt);
print_msg(fmt, args);
va_end(args);
currcfg->errors++;
}

View File

@@ -52,7 +52,6 @@
#include <arpa/inet.h>
#include "confparser.h"
#include "udpclient.h"
#include "tcpclient.h"
#include "interfacemgr.h"
@@ -430,11 +429,6 @@ main(int argc, char *argv[])
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
#if 0 /* brister */
isc_cfgctx_t *configctx = NULL;
const char *conffile = "/etc/named.conf"; /* XXX hardwired */
#endif
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_dbtable_create(mctx, dns_rdataclass_in, &dbtable) ==
DNS_R_SUCCESS);
@@ -482,12 +476,6 @@ main(int argc, char *argv[])
workers = 2;
printf("%d workers\n", workers);
#if 0 /* brister */
parser_init();
RUNTIME_CHECK(parse_configuration(conffile, mctx, &configctx) ==
ISC_R_SUCCESS);
#endif
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
ISC_R_SUCCESS);

View File

@@ -1,292 +0,0 @@
/*
* Copyright (C) 1998, 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.
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <dns/types.h>
#include <isc/mem.h>
#include <isc/assertions.h>
#include "zone.h"
/*
* NOTE: we do not 'realloc' to keep all the zones in contiguous memory.
*
*/
#define ZONECHUNK 50 /* how many zone structs we make at once.*/
#define ZONE_USED_MAGIC 0x7fffffff
#define ZONE_FREE_MAGIC 0x0
isc_result_t
isc_zone_newcontext(isc_mem_t *memctx, isc_zonectx_t **zctx)
{
isc_zonectx_t *zc ;
INSIST(zctx != NULL);
INSIST(memctx != NULL);
zc = isc_mem_get(memctx, sizeof *zc);
INSIST(zc != NULL);
memset(zc, 0x0, sizeof *zc);
zc->memctx = memctx;
*zctx = zc;
return ISC_R_SUCCESS;
}
isc_result_t
isc_zone_freecontext(isc_zonectx_t *zonectx)
{
isc_zoneinfo_t *zi;
isc_zoneinfo_t *zp;
zi = ISC_LIST_HEAD(zonectx->freezones);
while (zi != NULL ) {
zp = zi;
zi = ISC_LIST_NEXT(zi, chainlink);
isc_zone_release_zone(zp);
}
return (ISC_R_SUCCESS);
}
isc_result_t
isc_zone_newinfo(isc_zonectx_t *zctx, isc_zoneinfo_t **zone)
{
struct isc_zoneinfo *zp;
INSIST(zctx != NULL);
INSIST(zone != NULL);
if (ISC_LIST_EMPTY(zctx->freezones)) {
int bytes = sizeof (*zp) * ZONECHUNK;
int idx;
zp = isc_mem_get(zctx->memctx, bytes);
INSIST(zp != NULL);
memset(zp, 0x0, bytes);
zp->magic = ZONE_FREE_MAGIC;
for (idx = 0 ; idx < ZONECHUNK ; idx++) {
zp[idx].magic = ZONE_FREE_MAGIC;
ISC_LIST_APPEND(zctx->freezones, &zp[idx], chainlink);
}
}
INSIST(!ISC_LIST_EMPTY(zctx->freezones));
zp = ISC_LIST_HEAD(zctx->freezones);
ISC_LIST_UNLINK(zctx->freezones, zp, chainlink);
ISC_LIST_APPEND(zctx->usedzones, zp, chainlink);
zp->magic = ZONE_USED_MAGIC;
zp->zctx = zctx;
*zone = zp;
return ISC_R_SUCCESS;
}
isc_result_t
isc_zone_freezone(isc_zoneinfo_t *zone)
{
INSIST(zone != NULL);
INSIST(zone->magic == ZONE_USED_MAGIC);
INSIST(zone->zctx != NULL);
ISC_LIST_UNLINK(zone->zctx->usedzones, zone, chainlink);
zone->magic = ZONE_FREE_MAGIC;
ISC_LIST_APPEND(zone->zctx->freezones, zone, chainlink);
return ISC_R_SUCCESS;
}
isc_result_t
isc_zone_release_zone(isc_zoneinfo_t *zone)
{
isc_mem_put(zone->zctx->memctx, zone, sizeof *zone);
return (ISC_R_SUCCESS);
}
isc_result_t
isc_zone_setsource(isc_zoneinfo_t *zone, const char *source)
{
size_t len;
INSIST(zone != NULL);
INSIST(source != NULL);
len = strlen(source) + 1;
INSIST(len > 1);
zone->source.base = isc_mem_get(zone->zctx->memctx, len);
if (zone->source.base == NULL) {
return (ISC_R_NOMEMORY);
}
zone->source.length = len;
strcpy(zone->source.base, source);
return (ISC_R_SUCCESS);
}
isc_result_t
isc_zone_setorigin(isc_zoneinfo_t *zone, const char *origin)
{
size_t len;
INSIST(zone != NULL);
INSIST(origin != NULL);
len = strlen(origin) + 1;
INSIST(len > 1);
zone->origin.base = isc_mem_get(zone->zctx->memctx, len);
if (zone->origin.base == NULL) {
return (ISC_R_NOMEMORY);
}
zone->origin.length = len;
strcpy(zone->origin.base, origin);
return (ISC_R_SUCCESS);
}
const char *
isc_zonetype_to_string(isc_zonet_t zone_type)
{
const char *res = NULL;
switch (zone_type) {
case zone_master:
res = "master";
break;
case zone_slave:
res = "slave";
break;
case zone_hint:
res = "hint";
break;
case zone_stub:
res = "stub";
break;
case zone_forward:
res = "forward";
break;
}
INSIST (res != NULL);
return (res);
}
void
isc_zonectx_dump(FILE *fp, isc_zonectx_t *ctx)
{
isc_zoneinfo_t *zi;
INSIST(ctx != NULL);
zi = ISC_LIST_HEAD(ctx->usedzones);
while (zi != NULL ) {
isc_zone_dump(fp, zi);
zi = ISC_LIST_NEXT(zi, chainlink);
}
}
void
isc_zone_dump(FILE *fp, isc_zoneinfo_t *zone)
{
INSIST(fp != NULL);
INSIST(zone != NULL);
fprintf(fp, "zone \"%s\" %s {\n", zone->origin.base,
rrclass_to_string(zone->zone_class));
fprintf(fp, "\ttype %s;\n",isc_zonetype_to_string(zone->type));
/* XXX this will get more complicated */
fprintf(fp, "\tfile \"%s\";\n",zone->source.base);
fprintf(fp, "}\n");
}
isc_result_t
isc_zone_setclass(isc_zoneinfo_t *zone, isc_rrclass_t rrclass)
{
INSIST(zone != NULL);
zone->zone_class = rrclass;
return (ISC_R_SUCCESS);
}
const char *
rrclass_to_string(isc_rrclass_t rrclass)
{
const char *res;
switch (rrclass) {
case class_none:
res = "NONE";
break;
case class_any:
res = "ANY";
break;
case class_in:
res = "IN";
break;
case class_chaos:
res = "CHAOS";
break;
case class_hesiod:
res = "HESIOD";
break;
case class_hs:
res = "HS";
break;
default:
res = NULL;
break;
}
INSIST(res != NULL);
return (res);
}

View File

@@ -1,134 +0,0 @@
/*
* Copyright (C) 1998, 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.
*/
#if ! defined(ZONE_H)
#define ZONE_H
#include <config.h>
#include <sys/types.h>
#include <isc/list.h>
#include <isc/result.h>
#include <isc/mem.h>
#include <isc/types.h>
#include <dns/types.h>
/* Zone context structures contain a set of zones and related information
(like isc_mem_t contexts to allocate memory from). */
typedef struct isc_zonectx isc_zonectx_t;
/* The zone. All access is through function API */
typedef struct isc_zoneinfo isc_zoneinfo_t;
typedef enum {
zone_master, zone_slave, zone_hint, zone_stub, zone_forward
} isc_zonet_t ;
typedef enum {
class_any, class_none, class_in, class_chaos, class_hesiod,
class_hs
} isc_rrclass_t;
/* This structure contains all the run-time information about a zone. */
struct isc_zoneinfo
{
isc_int32_t magic; /* private magic stamp for valid'ng */
isc_textregion_t origin;
isc_textregion_t source;
isc_zonet_t type; /* master, slave etc. */
isc_rrclass_t zone_class; /* IN, CHAOS etc. */
dns_db_t *thedb;
/* The rest below aren't implmented yet */
time_t filemodtime; /* mod time of zone file */
time_t lastupdate; /* time last soa serial increment */
isc_uint32_t refresh; /* refresh interval */
isc_uint32_t retry; /* refresh retry interval */
isc_uint32_t expire; /* expiration time for cached info */
isc_uint32_t minimum; /* minimum TTL value */
isc_uint32_t serial; /* SOA serial number */
unsigned int options; /* zone specific options */
int zoneclass; /* zone class type */
struct isc_zonectx *zctx; /* contect zone came from. */
ISC_LINK(struct isc_zoneinfo) chainlink;
};
/* This structure contains context information about a set of
zones. Presumamable there'd only be one of these passed around the
various threads, but separating out zones might be useful in some way */
struct isc_zonectx
{
ISC_LIST(isc_zoneinfo_t) freezones;
ISC_LIST(isc_zoneinfo_t) usedzones;
isc_mem_t *memctx; /* where we get all our memory from */
};
/* Allocate a zone context from the memctx pool. All zone-private data
* structures will be will be made from that same pool.
*/
isc_result_t isc_zone_newcontext(isc_mem_t *memctx, isc_zonectx_t **ctx);
/* Allocate a zone from the give zone context. */
isc_result_t isc_zone_newinfo(isc_zonectx_t *zctx, isc_zoneinfo_t **zone);
isc_result_t isc_zone_release_zone(isc_zoneinfo_t *zone);
/* write named.conf-type format */
void isc_zone_dump(FILE *fp, isc_zoneinfo_t *zone);
/* Free up a zone and all associated data structures. The zone knows which
*zone context to go back to
*/
isc_result_t isc_zone_freezone(isc_zoneinfo_t *zone);
isc_result_t isc_zone_freecontext(isc_zonectx_t *ctx);
/* These functions copy the data they're given. */
isc_result_t isc_zone_setsource(isc_zoneinfo_t *zone,
const char *source);
isc_result_t isc_zone_setorigin(isc_zoneinfo_t *zone,
const char *origin);
isc_result_t isc_zone_setclass(isc_zoneinfo_t *zone, isc_rrclass_t class);
const char * isc_zonetype_to_string(isc_zonet_t zont_type);
void isc_zonectx_dump(FILE *fp, isc_zonectx_t *ctx);
void isc_zone_dump(FILE *fp, isc_zoneinfo_t *zone);
const char * rrclass_to_string(isc_rrclass_t rrclass);
#endif