Commit 9d794b52 authored by Brian Wellington's avatar Brian Wellington
Browse files

Added lwres{} statement to named.conf.

parent 55bf97a1
......@@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.105 2000/09/28 20:29:22 bwelling Exp $
# $Id: Makefile.in,v 1.106 2000/10/04 18:47:15 bwelling Exp $
srcdir = @srcdir@
VPATH = @srcdir@
......@@ -38,6 +38,7 @@ CONFOBJS = config/confacl.@O@ config/confcache.@O@ config/confcommon.@O@ \
config/confctl.@O@ config/confctx.@O@ \
config/confip.@O@ config/confkeys.@O@ \
config/conflog.@O@ config/conflsn.@O@ \
config/conflwres.@O@ \
config/confndc.@O@ config/confparser.@O@ \
config/confresolv.@O@ config/confrrset.@O@ \
config/confview.@O@ config/confzone.@O@
......
......@@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.23 2000/09/29 21:31:00 mws Exp $
# $Id: Makefile.in,v 1.24 2000/10/04 18:47:21 bwelling Exp $
srcdir = @srcdir@
VPATH = @srcdir@
......@@ -37,13 +37,13 @@ LIBS = @LIBS@
OBJS = confparser.@O@ confcommon.@O@ confacl.@O@ confcache.@O@ \
confctl.@O@ confctx.@O@ confip.@O@ confkeys.@O@ conflog.@O@ \
conflsn.@O@ confndc.@O@ confresolv.@O@ confrrset.@O@ \
confview.@O@ confzone.@O@
conflsn.@O@ conflwres.@O@ confndc.@O@ confresolv.@O@ \
confrrset.@O@ confview.@O@ confzone.@O@
SRCS = confparser.c confcommon.c confacl.c confcache.c \
confctl.c confctx.c confip.c confkeys.c conflog.c \
conflsn.c confndc.c confresolv.c confrrset.c \
confview.c confzone.c
conflsn.c conflwres.c confndc.c confresolv.c \
confrrset.c confview.c confzone.c
SUBDIRS =
TARGETS = ${OBJS}
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: confctx.c,v 1.90 2000/09/15 23:02:07 gson Exp $ */
/* $Id: confctx.c,v 1.91 2000/10/04 18:47:23 bwelling Exp $ */
#include <config.h>
......@@ -630,6 +630,7 @@ dns_c_ctx_new(isc_mem_t *mem, dns_c_ctx_t **cfg)
tmpcfg->resolver = NULL;
tmpcfg->cache = NULL;
tmpcfg->views = NULL;
tmpcfg->lwres = NULL;
tmpcfg->currview = NULL;
tmpcfg->currzone = NULL;
......@@ -701,6 +702,9 @@ dns_c_ctx_delete(dns_c_ctx_t **cfg)
if (c->views != NULL)
dns_c_viewtable_delete(&c->views);
if (c->lwres != NULL)
dns_c_lwreslist_delete(&c->lwres);
c->magic = 0;
isc_mem_put(c->mem, c, sizeof *c);
*cfg = NULL;
......@@ -2483,6 +2487,50 @@ dns_c_ctx_gettrustedkeys(dns_c_ctx_t *cfg, dns_c_tkeylist_t **retval)
}
isc_result_t
dns_c_ctx_getlwres(dns_c_ctx_t *cfg,
dns_c_lwreslist_t **retval)
{
REQUIRE(DNS_C_CONFCTX_VALID(cfg));
REQUIRE(retval != NULL);
*retval = cfg->lwres;
if (cfg->lwres == NULL) {
return (ISC_R_NOTFOUND);
} else {
return (ISC_R_SUCCESS);
}
}
isc_result_t
dns_c_ctx_setlwres(dns_c_ctx_t *cfg,
dns_c_lwreslist_t *newval, isc_boolean_t deepcopy)
{
isc_result_t res;
REQUIRE(DNS_C_CONFCTX_VALID(cfg));
if (cfg->lwres != NULL) {
dns_c_lwreslist_delete(&cfg->lwres);
}
if (newval == NULL) {
cfg->lwres = NULL;
res = ISC_R_SUCCESS;
} else if (deepcopy) {
res = dns_c_lwreslist_copy(cfg->mem,
&cfg->lwres, newval);
} else {
cfg->lwres = newval;
res = ISC_R_SUCCESS;
}
return (res);
}
/*
**
*/
......
/*
* Copyright (C) 2000 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: conflwres.c,v 1.1 2000/10/04 18:47:24 bwelling Exp $ */
#include <config.h>
#include <isc/mem.h>
#include <isc/string.h> /* Required for HP/UX (and others?) */
#include <isc/util.h>
#include <dns/conflwres.h>
#include <dns/confcommon.h>
isc_result_t
dns_c_lwreslist_new(isc_mem_t *mem, dns_c_lwreslist_t **list) {
dns_c_lwreslist_t *newlist;
REQUIRE(mem != NULL);
REQUIRE(list != NULL);
newlist = isc_mem_get(mem, sizeof *newlist);
if (newlist == NULL) {
return (ISC_R_NOMEMORY);
}
newlist->mem = mem;
newlist->magic = DNS_C_LWLIST_MAGIC;
ISC_LIST_INIT(newlist->lwreslist);
*list = newlist;
return (ISC_R_SUCCESS);
}
isc_result_t
dns_c_lwreslist_delete(dns_c_lwreslist_t **list)
{
dns_c_lwreslist_t *l;
dns_c_lwres_t *lwres;
isc_result_t res;
REQUIRE(list != NULL);
REQUIRE(DNS_C_LWLIST_VALID(*list));
l = *list;
while (!ISC_LIST_EMPTY(l->lwreslist)) {
lwres = ISC_LIST_HEAD(l->lwreslist);
ISC_LIST_UNLINK(l->lwreslist, lwres, next);
res = dns_c_lwres_delete(&lwres);
if (res != ISC_R_SUCCESS) {
return (res);
}
}
l->magic = 0;
isc_mem_put(l->mem, l, sizeof *l);
*list = NULL;
return (ISC_R_SUCCESS);
}
isc_result_t
dns_c_lwreslist_append(dns_c_lwreslist_t *list,
dns_c_lwres_t *lwres, isc_boolean_t copy)
{
dns_c_lwres_t *newe;
isc_result_t res;
REQUIRE(DNS_C_LWLIST_VALID(list));
REQUIRE(DNS_C_LWRES_VALID(lwres));
if (copy) {
res = dns_c_lwres_copy(list->mem, &newe, lwres);
if (res != ISC_R_SUCCESS) {
return (res);
}
} else {
newe = lwres;
}
ISC_LIST_APPEND(list->lwreslist, newe, next);
return (ISC_R_SUCCESS);
}
isc_result_t
dns_c_lwreslist_copy(isc_mem_t *mem, dns_c_lwreslist_t **dest,
dns_c_lwreslist_t *src)
{
dns_c_lwreslist_t *newlist;
dns_c_lwres_t *lwres;
isc_result_t res;
REQUIRE(dest != NULL);
REQUIRE(DNS_C_LWLIST_VALID(src));
res = dns_c_lwreslist_new(mem, &newlist);
if (res != ISC_R_SUCCESS) {
return (res);
}
lwres = ISC_LIST_HEAD(src->lwreslist);
while (lwres != NULL) {
res = dns_c_lwreslist_append(newlist, lwres, ISC_TRUE);
if (res != ISC_R_SUCCESS) {
dns_c_lwreslist_delete(&newlist);
return (res);
}
lwres = ISC_LIST_NEXT(lwres, next);
}
*dest = newlist;
return (ISC_R_SUCCESS);
}
isc_result_t
dns_c_lwreslist_addlwres(dns_c_lwreslist_t *list, dns_c_lwres_t *lwres) {
REQUIRE(DNS_C_LWLIST_VALID(list));
REQUIRE(DNS_C_LWRES_VALID(lwres));
ISC_LIST_APPEND(list->lwreslist, lwres, next);
return (ISC_R_SUCCESS);
}
dns_c_lwres_t *
dns_c_lwreslist_head (dns_c_lwreslist_t *list) {
REQUIRE(DNS_C_LWLIST_VALID(list));
return (ISC_LIST_HEAD(list->lwreslist));
}
dns_c_lwres_t *
dns_c_lwreslist_next(dns_c_lwres_t *lwres) {
REQUIRE(DNS_C_LWRES_VALID(lwres));
return (ISC_LIST_NEXT(lwres, next));
}
void
dns_c_lwreslist_print(FILE *fp, int indent, dns_c_lwreslist_t *list)
{
dns_c_lwres_t *lwres;
REQUIRE(fp != NULL);
REQUIRE(indent >= 0);
if (list == NULL)
return;
else
REQUIRE(DNS_C_LWLIST_VALID(list));
lwres = ISC_LIST_HEAD(list->lwreslist);
while (lwres != NULL) {
dns_c_lwres_print(fp, indent, lwres);
fprintf(fp, "\n");
lwres = ISC_LIST_NEXT(lwres, next);
}
}
isc_result_t
dns_c_lwres_new(isc_mem_t *mem, dns_c_lwres_t **lwresp)
{
dns_c_lwres_t *lwres;
REQUIRE(lwresp != NULL);
lwres = isc_mem_get(mem, sizeof *lwres);
if (lwres == NULL) {
return (ISC_R_NOMEMORY);
}
lwres->magic = DNS_C_LWRES_MAGIC;
lwres->mem = mem;
lwres->listeners = NULL;
lwres->view = NULL;
lwres->viewclass = dns_rdataclass_in;
ISC_LINK_INIT(lwres, next);
*lwresp = lwres;
return (ISC_R_SUCCESS);
}
isc_result_t
dns_c_lwres_delete(dns_c_lwres_t **lwresp)
{
dns_c_lwres_t *lwres;
isc_mem_t *mem;
REQUIRE(lwresp != NULL);
REQUIRE(DNS_C_LWRES_VALID(*lwresp));
lwres = *lwresp;
mem = lwres->mem;
lwres->magic = 0;
if (lwres->view != NULL)
isc_mem_free(mem, lwres->view);
if (lwres->listeners != NULL)
dns_c_iplist_detach(&lwres->listeners);
lwres->mem = NULL;
ISC_LINK_INIT(lwres, next);
isc_mem_put(mem, lwres, sizeof *lwres);
*lwresp = NULL;
return (ISC_R_SUCCESS);
}
isc_result_t dns_c_lwres_copy(isc_mem_t *mem, dns_c_lwres_t **dest,
dns_c_lwres_t *src)
{
dns_c_lwres_t *newlwres;
REQUIRE(dest != NULL);
REQUIRE(DNS_C_LWRES_VALID(src));
newlwres = isc_mem_get(mem, sizeof *newlwres);
if (newlwres == NULL) {
return (ISC_R_NOMEMORY);
}
newlwres->magic = DNS_C_LWRES_MAGIC;
newlwres->listeners = NULL;
newlwres->view = NULL;
if (src->view != NULL) {
newlwres->view = isc_mem_strdup(mem, src->view);
if (newlwres->view == NULL) {
dns_c_lwres_delete(&newlwres);
return (ISC_R_NOMEMORY);
}
}
if (src->listeners != NULL)
dns_c_iplist_attach(src->listeners, &newlwres->listeners);
newlwres->viewclass = lwres->viewclass;
*dest = newlwres;
return (ISC_R_SUCCESS);
}
isc_result_t
dns_c_lwres_setlistenon(dns_c_lwres_t *lwres, dns_c_iplist_t *listeners) {
if (lwres->listeners != NULL)
return (ISC_R_EXISTS);
dns_c_iplist_attach(listeners, &lwres->listeners);
return (ISC_R_SUCCESS);
}
isc_result_t
dns_c_lwres_setview(dns_c_lwres_t *lwres, char *view,
dns_rdataclass_t rdclass)
{
if (lwres->view != NULL)
return (ISC_R_EXISTS);
lwres->view = isc_mem_strdup(lwres->mem, view);
if (lwres->view == NULL)
return (ISC_R_NOMEMORY);
lwres->viewclass = rdclass;
return (ISC_R_SUCCESS);
}
void
dns_c_lwres_print(FILE *fp, int indent, dns_c_lwres_t *lwres)
{
REQUIRE(fp != NULL);
REQUIRE(DNS_C_LWRES_VALID(lwres));
dns_c_printtabs(fp, indent);
fprintf(fp, "lwres {\n");
if (lwres->listeners != NULL) {
dns_c_printtabs(fp, indent + 1);
fprintf(fp, "listen-on ");
dns_c_iplist_printfully(fp, indent + 2, ISC_TRUE,
lwres->listeners);
}
if (lwres->view != NULL) {
dns_c_printtabs(fp, indent + 1);
fprintf(fp, "view \"%s\"", lwres->view);
if (lwres->viewclass != dns_rdataclass_in) {
char classtext[10];
isc_buffer_t b;
isc_buffer_init(&b, classtext, sizeof(classtext));
(void)dns_rdataclass_totext(lwres->viewclass, &b);
fprintf(" %.*s", dns_buffer_usedlength(&b),
dns_buffer_base(&b));
}
fprintf(fp, ";\n", lwres->view);
}
dns_c_printtabs(fp, indent);
fprintf(fp, "};\n");
}
%{
/*
* Copyright (C) 1996-2000 Internet Software Consortium.
*
......@@ -16,7 +17,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: confparser.y.dirty,v 1.17 2000/09/15 00:26:35 gson Exp $ */
/* $Id: confparser.y.dirty,v 1.18 2000/10/04 18:47:24 bwelling Exp $ */
#include <config.h>
......@@ -309,6 +310,7 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult);
%token L_LISTEN_ON
%token L_LISTEN_ON_V6
%token L_LOGGING
%token L_LWRES
%token L_MAINTAIN_IXFR_BASE
%token L_MANY_ANSWERS
%token L_MASTER
......@@ -499,6 +501,7 @@ statement: include_stmt
| acl_stmt L_EOS
| key_stmt L_EOS
| view_stmt L_EOS
| lwres_stmt L_EOS
| L_END_INCLUDE
;
......@@ -5574,6 +5577,67 @@ trusted_key: any_string L_INTEGER L_INTEGER L_INTEGER L_QSTRING
}
;
/*
* Lightweight resolver daemon
*/
lwres_stmt: L_LWRES
{
dns_c_lwres_t *lwres = NULL;
tmpres = dns_c_lwres_new(currcfg->mem, &lwres);
if (tmpres != ISC_R_SUCCESS) {
YYABORT;
}
if (currcfg->lwres == NULL) {
tmpres = dns_c_lwreslist_new(currcfg->mem,
&currcfg->lwres);
if (tmpres != ISC_R_SUCCESS) {
YYABORT;
}
}
ISC_LIST_APPEND(currcfg->lwres->lwreslist, lwres, next);
} L_LBRACE optional_lwres_options_list L_RBRACE
;
optional_lwres_options_list: /* empty */
| lwres_options_list
;
lwres_options_list: lwres_option L_EOS
| lwres_options_list lwres_option L_EOS;
lwres_option: L_LISTEN_ON port_ip_list
{
dns_c_lwres_t *lwres;
lwres = ISC_LIST_TAIL(currcfg->lwres->lwreslist);
tmpres = dns_c_lwres_setlistenon(lwres, $2);
dns_c_iplist_detach(&$2);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE, "cannot redefine listen-on");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE, "failed to set listen-on");
YYABORT;
}
}
| L_VIEW any_string optional_class
{
dns_c_lwres_t *lwres;
lwres = ISC_LIST_TAIL(currcfg->lwres->lwreslist);
tmpres = dns_c_lwres_setview(lwres, $2, $3);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE, "cannot redefine view");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE, "failed to set view");
YYABORT;
}
isc_mem_free(memctx, $2);
}
;
/*
......@@ -5703,6 +5767,7 @@ static struct token keyword_tokens [] = {
{ "listen-on", L_LISTEN_ON },
{ "listen-on-v6", L_LISTEN_ON_V6 },
{ "logging", L_LOGGING },
{ "lwres", L_LWRES },
{ "maintain-ixfr-base", L_MAINTAIN_IXFR_BASE },
{ "many-answers", L_MANY_ANSWERS },
{ "master", L_MASTER },
......@@ -5957,7 +6022,8 @@ dns_c_parse_namedconf(const char *filename, isc_mem_t *mem,
if (res != ISC_R_SUCCESS) {
dns_c_ctx_delete(&currcfg);
}
}
} else
dns_c_ctx_delete(&currcfg);
*configctx = currcfg;
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: confctx.h,v 1.52 2000/08/22 17:36:29 gson Exp $ */
/* $Id: confctx.h,v 1.53 2000/10/04 18:47:17 bwelling Exp $ */
#ifndef DNS_CONFCTX_H
#define DNS_CONFCTX_H 1
......@@ -59,6 +59,7 @@
#include <dns/confctl.h>
#include <dns/conflog.h>
#include <dns/conflsn.h>
#include <dns/conflwres.h>
#include <dns/confresolv.h>
#include <dns/confview.h>
......@@ -97,6 +98,7 @@ struct dns_c_ctx {
dns_c_tkeylist_t *trusted_keys;
dns_c_logginglist_t *logging;
dns_c_viewtable_t *views;
dns_c_lwreslist_t *lwres;
dns_c_zone_t *currzone;
dns_c_view_t *currview;
......@@ -814,6 +816,10 @@ isc_result_t dns_c_ctx_gettrustedkeys(dns_c_ctx_t *cfg,
isc_result_t dns_c_ctx_settrustedkeys(dns_c_ctx_t *cfg, dns_c_tkeylist_t *list,
isc_boolean_t copy);
isc_result_t dns_c_ctx_getlwres(dns_c_ctx_t *cfg, dns_c_lwreslist_t **retval);
isc_result_t dns_c_ctx_setlwres(dns_c_ctx_t *cfg, dns_c_lwreslist_t *list,
isc_boolean_t copy);
ISC_LANG_ENDDECLS
......
/*
* Copyright (C) 2000 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: conflwres.h,v 1.1 2000/10/04 18:47:18 bwelling Exp $ */
#ifndef DNS_CONFLWRES_H
#define DNS_CONFLWRES_H 1
/*****
***** Module Info
*****/
/*
* The ADTs for the lwres statement in a named.conf config file.
*/
/*
*
* MP:
*
* Caller must to all necessary locking.
*
* Reliability:
*
* Not applicable.
*
* Resources: