mirror of
https://github.com/isc-projects/bind9.git
synced 2026-07-16 14:12:51 -04:00
Misc changes due to views
This commit is contained in:
parent
df82fed5c2
commit
f7a00c14fd
7 changed files with 504 additions and 142 deletions
|
|
@ -148,7 +148,12 @@ dns_c_ctx_new(isc_log_t *lctx,
|
|||
cfg->keydefs = NULL;
|
||||
cfg->trusted_keys = NULL;
|
||||
cfg->logging = NULL;
|
||||
|
||||
cfg->resolver = NULL;
|
||||
cfg->cache = NULL;
|
||||
cfg->views = NULL;
|
||||
|
||||
cfg->currview = NULL;
|
||||
cfg->currzone = NULL;
|
||||
|
||||
r = acl_init(lctx, cfg);
|
||||
if (r != ISC_R_SUCCESS) {
|
||||
|
|
@ -195,6 +200,7 @@ dns_c_ctx_delete(isc_log_t *lctx,
|
|||
dns_c_zonelist_delete(lctx, &c->zlist);
|
||||
dns_c_tkeylist_delete(lctx, &c->trusted_keys);
|
||||
dns_c_logginglist_delete(lctx, &c->logging);
|
||||
dns_c_viewtable_delete(lctx, &c->views);
|
||||
|
||||
isc_mem_put(c->mem, c, sizeof *c);
|
||||
*cfg = NULL;
|
||||
|
|
@ -284,6 +290,65 @@ dns_c_ctx_getoptions(isc_log_t *lctx,
|
|||
}
|
||||
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_ctx_setcurrzone(isc_log_t *lctx, dns_c_ctx_t *cfg,
|
||||
dns_c_zone_t *zone)
|
||||
{
|
||||
(void) lctx;
|
||||
|
||||
CHECK_CONFIG(cfg);
|
||||
|
||||
cfg->currzone = zone;
|
||||
|
||||
/* XXX should we validate that the zone is in our table? */
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
dns_c_zone_t *
|
||||
dns_c_ctx_getcurrzone(isc_log_t *lctx, dns_c_ctx_t *cfg)
|
||||
{
|
||||
(void) lctx;
|
||||
|
||||
CHECK_CONFIG(cfg);
|
||||
|
||||
return (cfg->currzone);
|
||||
}
|
||||
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_ctx_setcurrview(isc_log_t *lctx, dns_c_ctx_t *cfg,
|
||||
dns_c_view_t *view)
|
||||
{
|
||||
(void) lctx;
|
||||
|
||||
CHECK_CONFIG(cfg);
|
||||
|
||||
cfg->currview = view;
|
||||
|
||||
/* XXX should we validate that the zone is in our table? */
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
dns_c_view_t *
|
||||
dns_c_ctx_getcurrview(isc_log_t *lctx, dns_c_ctx_t *cfg)
|
||||
{
|
||||
(void) lctx;
|
||||
|
||||
CHECK_CONFIG(cfg);
|
||||
|
||||
return (cfg->currview);
|
||||
}
|
||||
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_ctx_getlogging(isc_log_t *lctx,
|
||||
dns_c_ctx_t *cfg, dns_c_logginglist_t **retval)
|
||||
|
|
|
|||
|
|
@ -15,9 +15,16 @@
|
|||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#if 0
|
||||
/*
|
||||
TODO:
|
||||
use log context for yyerror if appropriate.
|
||||
handle the L_VIEW options
|
||||
*/
|
||||
#endif
|
||||
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: confparser.y,v 1.8 1999/10/08 23:05:00 tale Exp $";
|
||||
static char rcsid[] = "$Id: confparser.y,v 1.9 1999/10/10 17:16:04 brister Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -2304,12 +2311,11 @@ secret: L_SECRET any_string L_EOS
|
|||
|
||||
view_stmt: L_VIEW any_string L_LBRACE
|
||||
{
|
||||
#if 0
|
||||
dns_c_view_t *view;
|
||||
|
||||
if (currcfg->viewlist == NULL) {
|
||||
if (currcfg->views == NULL) {
|
||||
tmpres = dns_c_viewtable_new(logcontext, currcfg->mem,
|
||||
&currcfg->viewlist);
|
||||
&currcfg->views);
|
||||
if (tmpres != ISC_R_SUCCESS) {
|
||||
parser_error(ISC_FALSE,
|
||||
"Failed to create viewtable");
|
||||
|
|
@ -2324,12 +2330,17 @@ view_stmt: L_VIEW any_string L_LBRACE
|
|||
YYABORT;
|
||||
}
|
||||
|
||||
dns_c_viewtable_addview(logcontext, currcfg->viewlist, view);
|
||||
#endif
|
||||
} view_options_list L_RBRACE {
|
||||
isc_mem_free(memctx, $2);
|
||||
dns_c_viewtable_addview(logcontext, currcfg->views, view);
|
||||
dns_c_ctx_setcurrview(logcontext, currcfg, view);
|
||||
|
||||
isc_mem_free(memctx, $2);
|
||||
} optional_view_options_list L_RBRACE L_EOS {
|
||||
dns_c_ctx_setcurrview(logcontext, currcfg, NULL);
|
||||
};
|
||||
|
||||
optional_view_options_list:
|
||||
| view_options_list
|
||||
;
|
||||
|
||||
view_options_list: view_option L_EOS
|
||||
| view_options_list view_option L_EOS;
|
||||
|
|
@ -2337,8 +2348,8 @@ view_options_list: view_option L_EOS
|
|||
|
||||
view_option: L_ALLOW_QUERY L_LBRACE address_match_list L_RBRACE
|
||||
{
|
||||
#if 0
|
||||
dns_c_view_t *view = ISC_LIST_TAIL(currcfg->viewlist->views);
|
||||
dns_c_view_t *view = dns_c_ctx_getcurrview(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(view != NULL);
|
||||
|
||||
|
|
@ -2358,7 +2369,6 @@ view_option: L_ALLOW_QUERY L_LBRACE address_match_list L_RBRACE
|
|||
parser_error(ISC_FALSE,
|
||||
"Failed to set view allow-query.");
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/* XXX other view statements need to go in here???. */
|
||||
|
|
@ -2423,8 +2433,9 @@ zone_stmt: L_ZONE domain_name optional_class L_LBRACE L_TYPE zone_type L_EOS
|
|||
}
|
||||
}
|
||||
|
||||
tmpres = dns_c_zone_new(logcontext, currcfg->zlist,
|
||||
$6, $3, $2, &zone);
|
||||
/* XXX internal name support needed! */
|
||||
tmpres = dns_c_zone_new(logcontext, currcfg->mem,
|
||||
$6, $3, $2, $2, &zone);
|
||||
if (tmpres != ISC_R_SUCCESS) {
|
||||
isc_log_write(logcontext, DNS_LOGCATEGORY_CONFIG,
|
||||
DNS_LOGMODULE_CONFIG,
|
||||
|
|
@ -2436,13 +2447,28 @@ zone_stmt: L_ZONE domain_name optional_class L_LBRACE L_TYPE zone_type L_EOS
|
|||
if (currcfg->options != NULL) {
|
||||
zone->afteropts = ISC_TRUE;
|
||||
}
|
||||
|
||||
|
||||
tmpres = dns_c_zonelist_addzone(logcontext,
|
||||
currcfg->zlist, zone);
|
||||
if (tmpres != ISC_R_SUCCESS) {
|
||||
dns_c_zone_delete(logcontext, &zone);
|
||||
isc_log_write(logcontext, DNS_LOGCATEGORY_CONFIG,
|
||||
DNS_LOGMODULE_CONFIG,
|
||||
ISC_LOG_CRITICAL,
|
||||
"Error adding new zone to list.");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
dns_c_ctx_setcurrzone(logcontext, currcfg, zone);
|
||||
|
||||
isc_mem_free(memctx, $2);
|
||||
} optional_zone_options_list L_RBRACE L_EOS {
|
||||
dns_c_zone_t *zone;
|
||||
|
||||
dns_c_ctx_setcurrzone(logcontext, currcfg, NULL);
|
||||
|
||||
if (callbacks != NULL && callbacks->zonecbk != NULL) {
|
||||
zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
zone = dns_c_ctx_getcurrzone(logcontext, currcfg);
|
||||
tmpres = callbacks->zonecbk(currcfg,
|
||||
zone,
|
||||
callbacks->zonecbkuap);
|
||||
|
|
@ -2536,7 +2562,8 @@ zone_non_type_keywords: L_FILE | L_FILE_IXFR | L_IXFR_TMP | L_MASTERS |
|
|||
|
||||
zone_option: L_FILE L_QSTRING
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2552,7 +2579,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_FILE_IXFR L_QSTRING
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2568,7 +2596,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_IXFR_TMP L_QSTRING
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2584,7 +2613,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_MASTERS maybe_zero_port L_LBRACE master_in_addr_list L_RBRACE
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2623,7 +2653,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_TRANSFER_SOURCE maybe_wild_addr
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2645,7 +2676,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_CHECK_NAMES check_names_opt
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2667,7 +2699,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_ALLOW_UPDATE L_LBRACE address_match_list L_RBRACE
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2690,7 +2723,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_ALLOW_QUERY L_LBRACE address_match_list L_RBRACE
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2713,7 +2747,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_ALLOW_TRANSFER L_LBRACE address_match_list L_RBRACE
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2736,7 +2771,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_FORWARD zone_forward_opt
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2758,7 +2794,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_FORWARDERS L_LBRACE opt_zone_forwarders_list L_RBRACE
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
dns_c_iplist_t *iplist;
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
|
@ -2795,7 +2832,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_MAX_TRANSFER_TIME_IN L_INTEGER
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2819,7 +2857,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_MAX_LOG_SIZE_IXFR L_INTEGER
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2841,7 +2880,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_NOTIFY yea_or_nay
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2863,7 +2903,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_MAINTAIN_IXFR_BASE yea_or_nay
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2885,7 +2926,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_PUBKEY L_INTEGER L_INTEGER L_INTEGER L_QSTRING
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
dns_c_pubkey_t *pubkey;
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
|
@ -2920,7 +2962,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_ALSO_NOTIFY L_LBRACE notify_in_addr_list L_RBRACE
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -2943,7 +2986,8 @@ zone_option: L_FILE L_QSTRING
|
|||
}
|
||||
| L_DIALUP yea_or_nay
|
||||
{
|
||||
dns_c_zone_t *zone = ISC_LIST_TAIL(currcfg->zlist->zones);
|
||||
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(logcontext,
|
||||
currcfg);
|
||||
|
||||
INSIST(zone != NULL);
|
||||
|
||||
|
|
@ -3319,6 +3363,7 @@ static struct token keyword_tokens [] = {
|
|||
{ "use-ixfr", L_USE_IXFR },
|
||||
{ "version", L_VERSION },
|
||||
{ "versions", L_VERSIONS },
|
||||
{ "view", L_VIEW },
|
||||
{ "warn", L_WARN },
|
||||
{ "yes", L_YES },
|
||||
{ "zone", L_ZONE },
|
||||
|
|
@ -3688,6 +3733,9 @@ parser_complain(isc_boolean_t is_warning, isc_boolean_t print_last_token,
|
|||
|
||||
(void) is_warning; /* lint happiness */
|
||||
|
||||
/* XXXJAB when isc_log_vwrite becomes public use that insead and drop
|
||||
* the above vsprintf
|
||||
*/
|
||||
if (print_last_token) {
|
||||
fprintf(stderr, "%s%s near ``%s''\n", where, message,
|
||||
token_to_text(lasttoken, lastyylval));
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_viewtable_new(isc_mem_t *mem, dns_c_viewtable_t **viewtable)
|
||||
dns_c_viewtable_new(isc_log_t *lctx,
|
||||
isc_mem_t *mem, dns_c_viewtable_t **viewtable)
|
||||
{
|
||||
dns_c_viewtable_t *table;
|
||||
|
||||
|
|
@ -57,7 +58,8 @@ dns_c_viewtable_new(isc_mem_t *mem, dns_c_viewtable_t **viewtable)
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_viewtable_delete(dns_c_viewtable_t **viewtable)
|
||||
dns_c_viewtable_delete(isc_log_t *lctx,
|
||||
dns_c_viewtable_t **viewtable)
|
||||
{
|
||||
dns_c_viewtable_t *table;
|
||||
|
||||
|
|
@ -67,8 +69,9 @@ dns_c_viewtable_delete(dns_c_viewtable_t **viewtable)
|
|||
if (table == NULL) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
dns_c_viewtable_clear(table);
|
||||
*viewtable = NULL;
|
||||
|
||||
dns_c_viewtable_clear(lctx, table);
|
||||
|
||||
isc_mem_put(table->mem, table, sizeof *table);
|
||||
|
||||
|
|
@ -77,8 +80,11 @@ dns_c_viewtable_delete(dns_c_viewtable_t **viewtable)
|
|||
|
||||
|
||||
void
|
||||
dns_c_viewtable_addview(dns_c_viewtable_t *viewtable, dns_c_view_t *view)
|
||||
dns_c_viewtable_addview(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *viewtable, dns_c_view_t *view)
|
||||
{
|
||||
(void) lctx; /* lint */
|
||||
|
||||
REQUIRE(viewtable != NULL);
|
||||
REQUIRE(view != NULL);
|
||||
|
||||
|
|
@ -88,8 +94,11 @@ dns_c_viewtable_addview(dns_c_viewtable_t *viewtable, dns_c_view_t *view)
|
|||
|
||||
|
||||
void
|
||||
dns_c_viewtable_rmview(dns_c_viewtable_t *viewtable, dns_c_view_t *view)
|
||||
dns_c_viewtable_rmview(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *viewtable, dns_c_view_t *view)
|
||||
{
|
||||
(void) lctx; /* lint */
|
||||
|
||||
REQUIRE(viewtable != NULL);
|
||||
REQUIRE(view != NULL);
|
||||
|
||||
|
|
@ -99,7 +108,8 @@ dns_c_viewtable_rmview(dns_c_viewtable_t *viewtable, dns_c_view_t *view)
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_viewtable_clear(dns_c_viewtable_t *table)
|
||||
dns_c_viewtable_clear(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *table)
|
||||
{
|
||||
dns_c_view_t *elem;
|
||||
dns_c_view_t *tmpelem;
|
||||
|
|
@ -112,7 +122,7 @@ dns_c_viewtable_clear(dns_c_viewtable_t *table)
|
|||
tmpelem = ISC_LIST_NEXT(elem, next);
|
||||
ISC_LIST_UNLINK(table->views, elem, next);
|
||||
|
||||
r = dns_c_view_delete(&elem);
|
||||
r = dns_c_view_delete(lctx, &elem);
|
||||
if (r != ISC_R_SUCCESS) {
|
||||
isc_log_write(lctx, DNS_LOGCATEGORY_CONFIG,
|
||||
DNS_LOGMODULE_CONFIG,
|
||||
|
|
@ -130,12 +140,15 @@ dns_c_viewtable_clear(dns_c_viewtable_t *table)
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_viewtable_viewbyname(dns_c_viewtable_t *viewtable,
|
||||
dns_c_viewtable_viewbyname(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *viewtable,
|
||||
const char *viewname,
|
||||
dns_c_view_t **retval)
|
||||
{
|
||||
dns_c_view_t *elem;
|
||||
|
||||
(void) lctx; /* lint */
|
||||
|
||||
REQUIRE(viewtable != NULL);
|
||||
REQUIRE(retval != NULL);
|
||||
REQUIRE(viewname != NULL);
|
||||
|
|
@ -160,16 +173,17 @@ dns_c_viewtable_viewbyname(dns_c_viewtable_t *viewtable,
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_viewtable_rmviewbyname(dns_c_viewtable_t *viewtable,
|
||||
dns_c_viewtable_rmviewbyname(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *viewtable,
|
||||
const char *name)
|
||||
{
|
||||
dns_c_view_t *view;
|
||||
isc_result_t res;
|
||||
|
||||
res = dns_c_viewtable_viewbyname(viewtable, name, &view);
|
||||
res = dns_c_viewtable_viewbyname(lctx, viewtable, name, &view);
|
||||
if (res == ISC_R_SUCCESS) {
|
||||
ISC_LIST_UNLINK(viewtable->views, view, next);
|
||||
dns_c_view_delete(&view);
|
||||
dns_c_view_delete(lctx, &view);
|
||||
}
|
||||
|
||||
return (res);
|
||||
|
|
@ -178,7 +192,8 @@ dns_c_viewtable_rmviewbyname(dns_c_viewtable_t *viewtable,
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_view_new(isc_mem_t *mem, const char *name, dns_c_view_t **newview)
|
||||
dns_c_view_new(isc_log_t *lctx,
|
||||
isc_mem_t *mem, const char *name, dns_c_view_t **newview)
|
||||
{
|
||||
dns_c_view_t *view;
|
||||
|
||||
|
|
@ -191,6 +206,9 @@ dns_c_view_new(isc_mem_t *mem, const char *name, dns_c_view_t **newview)
|
|||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
/* XXXJAB not portable -- should set each field */
|
||||
memset(view, 0x0, sizeof *view);
|
||||
|
||||
view->mem = mem;
|
||||
view->name = isc_mem_strdup(mem, name);
|
||||
if (view->name == NULL) {
|
||||
|
|
@ -207,7 +225,8 @@ dns_c_view_new(isc_mem_t *mem, const char *name, dns_c_view_t **newview)
|
|||
|
||||
|
||||
void
|
||||
dns_c_viewtable_print(FILE *fp, int indent,
|
||||
dns_c_viewtable_print(isc_log_t *lctx,
|
||||
FILE *fp, int indent,
|
||||
dns_c_viewtable_t *table)
|
||||
{
|
||||
dns_c_view_t *view;
|
||||
|
|
@ -221,7 +240,7 @@ dns_c_viewtable_print(FILE *fp, int indent,
|
|||
|
||||
view = ISC_LIST_HEAD(table->views);
|
||||
while (view != NULL) {
|
||||
dns_c_view_print(fp, indent, view);
|
||||
dns_c_view_print(lctx, fp, indent, view);
|
||||
fprintf(fp, "\n");
|
||||
|
||||
view = ISC_LIST_NEXT(view, next);
|
||||
|
|
@ -229,26 +248,28 @@ dns_c_viewtable_print(FILE *fp, int indent,
|
|||
}
|
||||
|
||||
void
|
||||
dns_c_view_print(FILE *fp, int indent, dns_c_view_t *view)
|
||||
dns_c_view_print(isc_log_t *lctx,
|
||||
FILE *fp, int indent, dns_c_view_t *view)
|
||||
{
|
||||
dns_c_printtabs(fp, indent);
|
||||
dns_c_printtabs(lctx, fp, indent);
|
||||
fprintf(fp, "view \"%s\" {\n", view->name);
|
||||
|
||||
if (view->allowquery != NULL) {
|
||||
dns_c_printtabs(fp, indent + 1);
|
||||
dns_c_printtabs(lctx, fp, indent + 1);
|
||||
fprintf(fp, "allow-query ");
|
||||
dns_c_ipmatchlist_print(fp, indent + 1,
|
||||
dns_c_ipmatchlist_print(lctx, fp, indent + 1,
|
||||
view->allowquery);
|
||||
}
|
||||
/* XXX rest of view fields */
|
||||
|
||||
dns_c_printtabs(fp, indent);
|
||||
dns_c_printtabs(lctx, fp, indent);
|
||||
fprintf(fp, "};\n");
|
||||
}
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_view_setallowquery(dns_c_view_t *view,
|
||||
dns_c_view_setallowquery(isc_log_t *lctx,
|
||||
dns_c_view_t *view,
|
||||
dns_c_ipmatchlist_t *ipml,
|
||||
isc_boolean_t deepcopy)
|
||||
{
|
||||
|
|
@ -258,11 +279,11 @@ dns_c_view_setallowquery(dns_c_view_t *view,
|
|||
REQUIRE(ipml != NULL);
|
||||
|
||||
if (view->allowquery != NULL) {
|
||||
dns_c_ipmatchlist_delete(&view->allowquery);
|
||||
dns_c_ipmatchlist_delete(lctx, &view->allowquery);
|
||||
}
|
||||
|
||||
if (deepcopy) {
|
||||
res = dns_c_ipmatchlist_copy(view->mem,
|
||||
res = dns_c_ipmatchlist_copy(lctx, view->mem,
|
||||
&view->allowquery, ipml);
|
||||
} else {
|
||||
view->allowquery = ipml;
|
||||
|
|
@ -274,7 +295,8 @@ dns_c_view_setallowquery(dns_c_view_t *view,
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_view_getallowqueryexpanded(isc_mem_t *mem,
|
||||
dns_c_view_getallowqueryexpanded(isc_log_t *lctx,
|
||||
isc_mem_t *mem,
|
||||
dns_c_view_t *view,
|
||||
dns_c_acltable_t *acltable,
|
||||
dns_c_ipmatchlist_t **retval)
|
||||
|
|
@ -286,12 +308,12 @@ dns_c_view_getallowqueryexpanded(isc_mem_t *mem,
|
|||
newlist = NULL;
|
||||
r = ISC_R_SUCCESS;
|
||||
} else {
|
||||
r = dns_c_ipmatchlist_copy(mem, &newlist, view->allowquery);
|
||||
r = dns_c_ipmatchlist_copy(lctx, mem, &newlist, view->allowquery);
|
||||
if (r != ISC_R_SUCCESS) {
|
||||
return (r);
|
||||
}
|
||||
|
||||
r = dns_c_acl_expandacls(acltable, newlist);
|
||||
r = dns_c_acl_expandacls(lctx, acltable, newlist);
|
||||
}
|
||||
|
||||
*retval = newlist;
|
||||
|
|
@ -302,7 +324,8 @@ dns_c_view_getallowqueryexpanded(isc_mem_t *mem,
|
|||
|
||||
|
||||
isc_result_t
|
||||
dns_c_view_delete(dns_c_view_t **viewptr)
|
||||
dns_c_view_delete(isc_log_t *lctx,
|
||||
dns_c_view_t **viewptr)
|
||||
{
|
||||
dns_c_view_t *view;
|
||||
|
||||
|
|
@ -313,9 +336,13 @@ dns_c_view_delete(dns_c_view_t **viewptr)
|
|||
}
|
||||
|
||||
view = *viewptr;
|
||||
isc_mem_free(view->mem, view->name);
|
||||
dns_c_ipmatchlist_delete(&view->allowquery);
|
||||
|
||||
isc_mem_free(view->mem, view->name);
|
||||
|
||||
dns_c_ipmatchlist_delete(lctx, &view->allowquery);
|
||||
|
||||
isc_mem_put(view->mem, view, sizeof *view);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,9 @@ isc_result_t
|
|||
dns_c_zonelist_delete(isc_log_t *lctx, dns_c_zonelist_t **zlist)
|
||||
{
|
||||
dns_c_zonelist_t *list;
|
||||
dns_c_zone_t *zone, *tmpzone;
|
||||
dns_c_zonelem_t *zoneelem;
|
||||
dns_c_zonelem_t *tmpelem;
|
||||
dns_c_zone_t *zone;
|
||||
isc_result_t res;
|
||||
|
||||
REQUIRE(zlist != NULL);
|
||||
|
|
@ -152,17 +154,20 @@ dns_c_zonelist_delete(isc_log_t *lctx, dns_c_zonelist_t **zlist)
|
|||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
zone = ISC_LIST_HEAD(list->zones);
|
||||
while (zone != NULL) {
|
||||
tmpzone = ISC_LIST_NEXT(zone, next);
|
||||
ISC_LIST_UNLINK(list->zones, zone, next);
|
||||
zoneelem = ISC_LIST_HEAD(list->zones);
|
||||
while (zoneelem != NULL) {
|
||||
tmpelem = ISC_LIST_NEXT(zoneelem, next);
|
||||
ISC_LIST_UNLINK(list->zones, zoneelem, next);
|
||||
|
||||
zone = zoneelem->thezone;
|
||||
isc_mem_put(list->mem, zoneelem, sizeof *zoneelem);
|
||||
|
||||
res = zone_delete(lctx, &zone);
|
||||
if (res != ISC_R_SUCCESS) {
|
||||
return (res);
|
||||
}
|
||||
|
||||
zone = tmpzone;
|
||||
zoneelem = tmpelem;
|
||||
}
|
||||
|
||||
isc_mem_put(list->mem, list, sizeof *list);
|
||||
|
|
@ -170,12 +175,56 @@ dns_c_zonelist_delete(isc_log_t *lctx, dns_c_zonelist_t **zlist)
|
|||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_c_zonelist_addzone(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
||||
dns_c_zone_t *zone)
|
||||
{
|
||||
dns_c_zonelem_t *zoneelem;
|
||||
|
||||
(void) lctx;
|
||||
|
||||
REQUIRE(zlist != NULL);
|
||||
REQUIRE(zone != NULL);
|
||||
REQUIRE(zone->refcount > 0);
|
||||
|
||||
zoneelem = isc_mem_get(zlist->mem, sizeof *zoneelem);
|
||||
if (zoneelem == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
dns_c_zone_attach(lctx, zone, &zoneelem->thezone);
|
||||
ISC_LINK_INIT(zoneelem, next);
|
||||
|
||||
ISC_LIST_APPEND(zlist->zones, zoneelem, next);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* XXXJAB drop this function */
|
||||
dns_c_zone_t *
|
||||
dns_c_zonelist_currzone(isc_log_t *lctx, dns_c_zonelist_t *zlist)
|
||||
{
|
||||
dns_c_zonelem_t *zelem;
|
||||
|
||||
REQUIRE(zlist != NULL);
|
||||
REQUIRE(!ISC_LIST_EMPTY(zlist->zones));
|
||||
|
||||
zelem = ISC_LIST_TAIL(zlist->zones);
|
||||
|
||||
INSIST(zelem->thezone != NULL);
|
||||
|
||||
return (zelem->thezone);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_zonelist_find(isc_log_t *lctx, dns_c_zonelist_t *zlist, const char *name,
|
||||
dns_c_zone_t **retval)
|
||||
{
|
||||
dns_c_zone_t *zone;
|
||||
dns_c_zonelem_t *zoneelem;
|
||||
|
||||
(void)lctx;
|
||||
|
||||
|
|
@ -184,18 +233,20 @@ dns_c_zonelist_find(isc_log_t *lctx, dns_c_zonelist_t *zlist, const char *name,
|
|||
REQUIRE(strlen(name) > 0);
|
||||
REQUIRE(retval != NULL);
|
||||
|
||||
zone = ISC_LIST_HEAD(zlist->zones);
|
||||
while (zone != NULL) {
|
||||
if (strcmp(name, zone->name) == 0) {
|
||||
zoneelem = ISC_LIST_HEAD(zlist->zones);
|
||||
while (zoneelem != NULL) {
|
||||
REQUIRE(zoneelem->thezone != NULL);
|
||||
|
||||
if (strcmp(name, zoneelem->thezone->name) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (zone != NULL) {
|
||||
*retval = zone;
|
||||
if (zoneelem != NULL) {
|
||||
*retval = zoneelem->thezone;
|
||||
}
|
||||
|
||||
return (zone == NULL ? ISC_R_NOTFOUND : ISC_R_SUCCESS);
|
||||
return (zoneelem == NULL ? ISC_R_NOTFOUND : ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -203,13 +254,29 @@ isc_result_t
|
|||
dns_c_zonelist_rmbyname(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
||||
const char *name)
|
||||
{
|
||||
dns_c_zone_t *zone;
|
||||
dns_c_zonelem_t *zoneelem;
|
||||
isc_result_t res;
|
||||
|
||||
res = dns_c_zonelist_find(lctx, zlist, name, &zone);
|
||||
if (res == ISC_R_SUCCESS) {
|
||||
ISC_LIST_UNLINK(zlist->zones, zone, next);
|
||||
res = zone_delete(lctx, &zone);
|
||||
(void) lctx;
|
||||
|
||||
REQUIRE(zlist != NULL);
|
||||
REQUIRE(name != NULL);
|
||||
|
||||
zoneelem = ISC_LIST_HEAD(zlist->zones);
|
||||
while (zoneelem != NULL) {
|
||||
REQUIRE(zoneelem->thezone != NULL);
|
||||
|
||||
if (strcmp(name, zoneelem->thezone->name) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (zoneelem != NULL) {
|
||||
ISC_LIST_UNLINK(zlist->zones, zoneelem, next);
|
||||
res = dns_c_zone_delete(lctx, &zoneelem->thezone);
|
||||
isc_mem_put(zlist->mem, zoneelem, sizeof *zoneelem);
|
||||
} else {
|
||||
res = ISC_R_NOTFOUND;
|
||||
}
|
||||
|
||||
return (res);
|
||||
|
|
@ -220,13 +287,28 @@ isc_result_t
|
|||
dns_c_zonelist_rmzone(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
||||
dns_c_zone_t *zone)
|
||||
{
|
||||
dns_c_zonelem_t *zoneelem;
|
||||
isc_result_t res;
|
||||
|
||||
REQUIRE(zlist != NULL);
|
||||
REQUIRE(zone != NULL);
|
||||
|
||||
ISC_LIST_UNLINK(zlist->zones, zone, next);
|
||||
res = zone_delete(lctx, &zone);
|
||||
zoneelem = ISC_LIST_HEAD(zlist->zones);
|
||||
while (zoneelem != NULL) {
|
||||
REQUIRE(zoneelem->thezone != NULL);
|
||||
|
||||
if (zone == zoneelem->thezone) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (zoneelem != NULL) {
|
||||
ISC_LIST_UNLINK(zlist->zones, zoneelem, next);
|
||||
res = dns_c_zone_delete(lctx, &zoneelem->thezone);
|
||||
isc_mem_put(zlist->mem, zoneelem, sizeof *zoneelem);
|
||||
} else {
|
||||
res = ISC_R_NOTFOUND;
|
||||
}
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
|
@ -261,7 +343,7 @@ static void
|
|||
zone_list_print(isc_log_t *lctx, zone_print_type zpt, FILE *fp, int indent,
|
||||
dns_c_zonelist_t *list)
|
||||
{
|
||||
dns_c_zone_t *zone;
|
||||
dns_c_zonelem_t *zoneelem;
|
||||
|
||||
REQUIRE(fp != NULL);
|
||||
REQUIRE(indent >= 0);
|
||||
|
|
@ -275,14 +357,14 @@ zone_list_print(isc_log_t *lctx, zone_print_type zpt, FILE *fp, int indent,
|
|||
(zpt == zones_postopts && zone->afteropts == ISC_TRUE) || \
|
||||
zpt == zones_all)
|
||||
|
||||
zone = ISC_LIST_HEAD(list->zones);
|
||||
while (zone != NULL) {
|
||||
if (PRINTIT(zone, zpt)) {
|
||||
dns_c_zone_print(lctx, fp, indent, zone);
|
||||
zoneelem = ISC_LIST_HEAD(list->zones);
|
||||
while (zoneelem != NULL) {
|
||||
if (PRINTIT(zoneelem->thezone, zpt)) {
|
||||
dns_c_zone_print(lctx, fp, indent, zoneelem->thezone);
|
||||
}
|
||||
|
||||
zone = ISC_LIST_NEXT(zone, next);
|
||||
if (zone != NULL && PRINTIT(zone, zpt)) {
|
||||
zoneelem = ISC_LIST_NEXT(zoneelem, next);
|
||||
if (zoneelem != NULL && PRINTIT(zoneelem->thezone, zpt)) {
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -298,27 +380,32 @@ zone_list_print(isc_log_t *lctx, zone_print_type zpt, FILE *fp, int indent,
|
|||
/* ************************************************************************ */
|
||||
|
||||
isc_result_t
|
||||
dns_c_zone_new(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
||||
dns_c_zonetype_t ztype,
|
||||
dns_rdataclass_t zclass, const char *name, dns_c_zone_t **zone)
|
||||
dns_c_zone_new(isc_log_t *lctx, isc_mem_t *mem,
|
||||
dns_c_zonetype_t ztype, dns_rdataclass_t zclass,
|
||||
const char *name, const char *internalname,
|
||||
dns_c_zone_t **zone)
|
||||
{
|
||||
dns_c_zone_t *newzone;
|
||||
isc_result_t res;
|
||||
|
||||
REQUIRE(zlist != NULL);
|
||||
REQUIRE(mem != NULL);
|
||||
REQUIRE(name != NULL);
|
||||
REQUIRE(strlen(name) > 0);
|
||||
|
||||
newzone = isc_mem_get(zlist->mem, sizeof *newzone);
|
||||
newzone = isc_mem_get(mem, sizeof *newzone);
|
||||
if (newzone == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
newzone->mylist = zlist;
|
||||
newzone->mem = mem;
|
||||
newzone->refcount = 1;
|
||||
newzone->ztype = ztype;
|
||||
newzone->zclass = zclass;
|
||||
newzone->afteropts = ISC_FALSE;
|
||||
newzone->name = isc_mem_strdup(zlist->mem, name);
|
||||
newzone->name = isc_mem_strdup(mem, name);
|
||||
newzone->internalname = (internalname == NULL ?
|
||||
isc_mem_strdup(mem, name) :
|
||||
isc_mem_strdup(mem, internalname));
|
||||
|
||||
switch (ztype) {
|
||||
case dns_c_zone_master:
|
||||
|
|
@ -342,14 +429,47 @@ dns_c_zone_new(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
|||
break;
|
||||
}
|
||||
|
||||
ISC_LIST_APPEND(zlist->zones, newzone, next);
|
||||
|
||||
*zone = newzone;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_zone_delete(isc_log_t *lctx, dns_c_zone_t **zone)
|
||||
{
|
||||
dns_c_zone_t *zoneptr = *zone;
|
||||
isc_result_t res = ISC_R_SUCCESS;
|
||||
|
||||
*zone = NULL;
|
||||
|
||||
REQUIRE(zoneptr->refcount > 0);
|
||||
zoneptr->refcount--;
|
||||
|
||||
if (zoneptr->refcount == 0) {
|
||||
res = zone_delete(lctx, &zoneptr);
|
||||
}
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
dns_c_zone_attach(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
dns_c_zone_t **newzone)
|
||||
{
|
||||
REQUIRE(zone != NULL);
|
||||
REQUIRE(newzone != NULL);
|
||||
|
||||
(void) lctx;
|
||||
|
||||
zone->refcount++;
|
||||
|
||||
*newzone = zone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
dns_c_zone_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_zone_t *zone)
|
||||
{
|
||||
|
|
@ -438,13 +558,13 @@ dns_c_zone_setfile(isc_log_t *lctx, dns_c_zone_t *zone, const char *newfile)
|
|||
}
|
||||
|
||||
if (*p != NULL) {
|
||||
isc_mem_free(zone->mylist->mem, *p);
|
||||
isc_mem_free(zone->mem, *p);
|
||||
res = ISC_R_EXISTS;
|
||||
} else {
|
||||
res = ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
*p = isc_mem_strdup(zone->mylist->mem, newfile);
|
||||
*p = isc_mem_strdup(zone->mem, newfile);
|
||||
if (*p == NULL) {
|
||||
res = ISC_R_NOMEMORY;
|
||||
}
|
||||
|
|
@ -552,7 +672,7 @@ dns_c_zone_setallowupd(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
|
||||
existed = (*p != NULL ? ISC_TRUE : ISC_FALSE);
|
||||
|
||||
res = set_ipmatch_list_field(lctx, zone->mylist->mem, p,
|
||||
res = set_ipmatch_list_field(lctx, zone->mem, p,
|
||||
ipml, deepcopy);
|
||||
if (res == ISC_R_SUCCESS && existed) {
|
||||
res = ISC_R_EXISTS;
|
||||
|
|
@ -603,7 +723,7 @@ dns_c_zone_setallowquery(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
|
||||
existed = (*p != NULL ? ISC_TRUE : ISC_FALSE);
|
||||
|
||||
res = set_ipmatch_list_field(lctx, zone->mylist->mem, p,
|
||||
res = set_ipmatch_list_field(lctx, zone->mem, p,
|
||||
ipml, deepcopy);
|
||||
if (res == ISC_R_SUCCESS && existed) {
|
||||
res = ISC_R_EXISTS;
|
||||
|
|
@ -654,7 +774,7 @@ dns_c_zone_setallowtransfer(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
}
|
||||
|
||||
existed = (*p != NULL ? ISC_TRUE : ISC_FALSE);
|
||||
res = set_ipmatch_list_field(lctx, zone->mylist->mem, p,
|
||||
res = set_ipmatch_list_field(lctx, zone->mem, p,
|
||||
ipml, deepcopy);
|
||||
|
||||
if (res == ISC_R_SUCCESS && existed) {
|
||||
|
|
@ -843,7 +963,7 @@ dns_c_zone_setalsonotify(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
}
|
||||
|
||||
existed = (*p != NULL ? ISC_TRUE : ISC_FALSE);
|
||||
res = set_iplist_field(lctx, zone->mylist->mem, p, newval, deepcopy);
|
||||
res = set_iplist_field(lctx, zone->mem, p, newval, deepcopy);
|
||||
if (res == ISC_R_SUCCESS && existed) {
|
||||
res = ISC_R_EXISTS;
|
||||
}
|
||||
|
|
@ -890,12 +1010,12 @@ dns_c_zone_setixfrbase(isc_log_t *lctx, dns_c_zone_t *zone, const char *newval)
|
|||
|
||||
if (*p != NULL) {
|
||||
existed = ISC_TRUE;
|
||||
isc_mem_free(zone->mylist->mem, *p);
|
||||
isc_mem_free(zone->mem, *p);
|
||||
} else {
|
||||
existed = ISC_FALSE;
|
||||
}
|
||||
|
||||
*p = isc_mem_strdup(zone->mylist->mem, newval);
|
||||
*p = isc_mem_strdup(zone->mem, newval);
|
||||
if (*p == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
|
@ -942,12 +1062,12 @@ dns_c_zone_setixfrtmp(isc_log_t *lctx, dns_c_zone_t *zone, const char *newval)
|
|||
|
||||
if (*p != NULL) {
|
||||
existed = ISC_TRUE;
|
||||
isc_mem_free(zone->mylist->mem, *p);
|
||||
isc_mem_free(zone->mem, *p);
|
||||
} else {
|
||||
existed = ISC_FALSE;
|
||||
}
|
||||
|
||||
*p = isc_mem_strdup(zone->mylist->mem, newval);
|
||||
*p = isc_mem_strdup(zone->mem, newval);
|
||||
if (*p == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
|
@ -1001,7 +1121,7 @@ dns_c_zone_setpubkey(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
}
|
||||
|
||||
if (deepcopy) {
|
||||
res = dns_c_pubkey_copy(lctx, zone->mylist->mem, p, pubkey);
|
||||
res = dns_c_pubkey_copy(lctx, zone->mem, p, pubkey);
|
||||
} else {
|
||||
*p = pubkey;
|
||||
res = ISC_R_SUCCESS;
|
||||
|
|
@ -1087,7 +1207,7 @@ dns_c_zone_setmasterips(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
}
|
||||
|
||||
existed = (*p != NULL ? ISC_TRUE : ISC_FALSE);
|
||||
res = set_iplist_field(lctx, zone->mylist->mem, p,
|
||||
res = set_iplist_field(lctx, zone->mem, p,
|
||||
newval, deepcopy);
|
||||
if (res == ISC_R_SUCCESS && existed) {
|
||||
res = ISC_R_EXISTS;
|
||||
|
|
@ -1353,7 +1473,7 @@ dns_c_zone_setforwarders(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
break;
|
||||
}
|
||||
|
||||
res = set_iplist_field(lctx, zone->mylist->mem, p, ipl, deepcopy);
|
||||
res = set_iplist_field(lctx, zone->mem, p, ipl, deepcopy);
|
||||
if (res == ISC_R_SUCCESS && existed) {
|
||||
res = ISC_R_EXISTS;
|
||||
}
|
||||
|
|
@ -1376,6 +1496,21 @@ dns_c_zone_getname(isc_log_t *lctx, dns_c_zone_t *zone, const char **retval)
|
|||
}
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_zone_getinternalname(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
const char **retval)
|
||||
{
|
||||
(void) lctx;
|
||||
|
||||
REQUIRE(zone != NULL);
|
||||
REQUIRE(retval != NULL);
|
||||
|
||||
*retval = zone->internalname;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_c_zone_getfile(isc_log_t *lctx, dns_c_zone_t *zone, const char **retval)
|
||||
{
|
||||
|
|
@ -2733,30 +2868,32 @@ zone_delete(isc_log_t *lctx, dns_c_zone_t **zone)
|
|||
|
||||
z = *zone;
|
||||
|
||||
isc_mem_free(z->mylist->mem, z->name);
|
||||
isc_mem_free(z->mem, z->name);
|
||||
isc_mem_free(z->mem, z->internalname);
|
||||
|
||||
switch(z->ztype) {
|
||||
case dns_c_zone_master:
|
||||
res = master_zone_clear(lctx, z->mylist->mem, &z->u.mzone);
|
||||
res = master_zone_clear(lctx, z->mem, &z->u.mzone);
|
||||
break;
|
||||
|
||||
case dns_c_zone_slave:
|
||||
res = slave_zone_clear(lctx, z->mylist->mem, &z->u.szone);
|
||||
res = slave_zone_clear(lctx, z->mem, &z->u.szone);
|
||||
break;
|
||||
|
||||
case dns_c_zone_stub:
|
||||
res = stub_zone_clear(lctx, z->mylist->mem, &z->u.tzone);
|
||||
res = stub_zone_clear(lctx, z->mem, &z->u.tzone);
|
||||
break;
|
||||
|
||||
case dns_c_zone_hint:
|
||||
res = hint_zone_clear(lctx, z->mylist->mem, &z->u.hzone);
|
||||
res = hint_zone_clear(lctx, z->mem, &z->u.hzone);
|
||||
break;
|
||||
|
||||
case dns_c_zone_forward:
|
||||
res = forward_zone_clear(lctx, z->mylist->mem, &z->u.fzone);
|
||||
res = forward_zone_clear(lctx, z->mem, &z->u.fzone);
|
||||
break;
|
||||
}
|
||||
|
||||
isc_mem_put(z->mylist->mem, z, sizeof *z);
|
||||
isc_mem_put(z->mem, z, sizeof *z);
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@
|
|||
#include <dns/confctl.h>
|
||||
#include <dns/confserv.h>
|
||||
#include <dns/confview.h>
|
||||
#include <dns/confcache.h>
|
||||
#include <dns/confresolv.h>
|
||||
|
||||
|
||||
/***
|
||||
|
|
@ -89,6 +91,8 @@ struct dns_c_ctx
|
|||
int errors; /* semantic error count */
|
||||
|
||||
dns_c_options_t *options;
|
||||
dns_c_cache_t *cache;
|
||||
dns_c_resolv_t *resolver;
|
||||
dns_c_ctrllist_t *controls;
|
||||
dns_c_srvlist_t *servers;
|
||||
dns_c_acltable_t *acls;
|
||||
|
|
@ -96,7 +100,10 @@ struct dns_c_ctx
|
|||
dns_c_zonelist_t *zlist;
|
||||
dns_c_tkeylist_t *trusted_keys;
|
||||
dns_c_logginglist_t *logging;
|
||||
dns_c_viewtable_t *viewlist;
|
||||
dns_c_viewtable_t *views;
|
||||
|
||||
dns_c_zone_t *currzone;
|
||||
dns_c_view_t *currview;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -132,6 +139,8 @@ struct dns_c_options
|
|||
isc_int32_t heartbeat_interval;
|
||||
|
||||
isc_int32_t max_transfer_time_in;
|
||||
isc_int32_t lamettl; /* XXX not implemented yet */
|
||||
|
||||
|
||||
isc_uint32_t data_size;
|
||||
isc_uint32_t stack_size;
|
||||
|
|
@ -152,6 +161,7 @@ struct dns_c_options
|
|||
isc_boolean_t multiple_cnames;
|
||||
isc_boolean_t use_id_pool;
|
||||
isc_boolean_t dialup;
|
||||
isc_boolean_t rfc2038type1; /* XXX not implemented yet */
|
||||
|
||||
isc_sockaddr_t query_source_addr;
|
||||
short query_source_port;
|
||||
|
|
@ -260,6 +270,10 @@ void dns_c_ctx_forwarderprint(isc_log_t *lctx,
|
|||
* functions.
|
||||
*
|
||||
*/
|
||||
isc_result_t dns_c_ctx_setcurrzone(isc_log_t *lctx,
|
||||
dns_c_ctx_t *cfg, dns_c_zone_t *zone);
|
||||
isc_result_t dns_c_ctx_setcurrview(isc_log_t *lctx,
|
||||
dns_c_ctx_t *cfg, dns_c_view_t *view);
|
||||
isc_result_t dns_c_ctx_setdirectory(isc_log_t *lctx,
|
||||
dns_c_ctx_t *cfg, const char *newval);
|
||||
isc_result_t dns_c_ctx_setversion(isc_log_t *lctx,
|
||||
|
|
@ -425,6 +439,8 @@ isc_result_t dns_c_ctx_settrustedkeys(isc_log_t *lctx,
|
|||
*/
|
||||
|
||||
|
||||
dns_c_zone_t *dns_c_ctx_getcurrzone(isc_log_t *lctx, dns_c_ctx_t *cfg);
|
||||
dns_c_view_t *dns_c_ctx_getcurrview(isc_log_t *lctx, dns_c_ctx_t *cfg);
|
||||
isc_result_t dns_c_ctx_getdirectory(isc_log_t *lctx,
|
||||
dns_c_ctx_t *cfg, char **retval);
|
||||
isc_result_t dns_c_ctx_getversion(isc_log_t *lctx,
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@
|
|||
#include <dns/confkeys.h>
|
||||
#include <dns/confacl.h>
|
||||
#include <dns/confip.h>
|
||||
#include <dns/conflsn.h>
|
||||
#include <dns/confrrset.h>
|
||||
|
||||
|
||||
/***
|
||||
|
|
@ -93,7 +95,47 @@ struct dns_c_view
|
|||
isc_mem_t *mem;
|
||||
|
||||
char *name;
|
||||
|
||||
dns_c_forw_t forward;
|
||||
|
||||
dns_c_ipmatchlist_t *allowquery;
|
||||
dns_c_ipmatchlist_t *blackhole;
|
||||
dns_c_ipmatchlist_t *forwarders;
|
||||
dns_c_ipmatchlist_t *queryacl;
|
||||
dns_c_ipmatchlist_t *sortlist;
|
||||
dns_c_ipmatchlist_t *topology;
|
||||
dns_c_ipmatchlist_t *transferacl;
|
||||
|
||||
dns_c_lstnlist_t *listens;
|
||||
|
||||
dns_c_rrsolist_t *ordering;
|
||||
|
||||
dns_c_severity_t check_names[DNS_C_TRANSCOUNT];
|
||||
|
||||
dns_transfer_format_t transfer_format;
|
||||
|
||||
isc_boolean_t auth_nx_domain;
|
||||
isc_boolean_t dialup;
|
||||
isc_boolean_t expert_mode;
|
||||
isc_boolean_t fetch_glue;
|
||||
isc_boolean_t has_old_clients;
|
||||
isc_boolean_t host_statistics;
|
||||
isc_boolean_t maintain_ixfr_base;
|
||||
isc_boolean_t multiple_cnames;
|
||||
isc_boolean_t notify;
|
||||
isc_boolean_t recursion;
|
||||
isc_boolean_t rfc2038type1;
|
||||
isc_boolean_t use_id_pool;
|
||||
|
||||
isc_int32_t clean_interval;
|
||||
isc_int32_t lamettl;
|
||||
isc_int32_t max_log_size_ixfr;
|
||||
isc_int32_t max_ncache_ttl;
|
||||
isc_int32_t max_transfer_time_in;
|
||||
isc_int32_t stats_interval;
|
||||
isc_int32_t transfers_in;
|
||||
isc_int32_t transfers_out;
|
||||
isc_int32_t transfers_per_ns;
|
||||
|
||||
dns_c_setbits_t setflags;
|
||||
|
||||
|
|
@ -106,7 +148,7 @@ struct dns_c_view
|
|||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t dns_c_viewtable_new(isc_mem_t *mem,
|
||||
isc_result_t dns_c_viewtable_new(isc_log_t *lctx, isc_mem_t *mem,
|
||||
dns_c_viewtable_t **viewtable);
|
||||
|
||||
/*
|
||||
|
|
@ -124,7 +166,8 @@ isc_result_t dns_c_viewtable_new(isc_mem_t *mem,
|
|||
*
|
||||
*/
|
||||
|
||||
isc_result_t dns_c_viewtable_delete(dns_c_viewtable_t **viewtable);
|
||||
isc_result_t dns_c_viewtable_delete(isc_log_t *lctx,
|
||||
dns_c_viewtable_t **viewtable);
|
||||
/*
|
||||
* Destroys the table pointed to by *VIEWTABLE and all the views in it. The
|
||||
* value of *VIEWTABLE can be NULL (which is a no-op).
|
||||
|
|
@ -139,7 +182,7 @@ isc_result_t dns_c_viewtable_delete(dns_c_viewtable_t **viewtable);
|
|||
*/
|
||||
|
||||
|
||||
void dns_c_viewtable_addview(dns_c_viewtable_t *viewtable,
|
||||
void dns_c_viewtable_addview(isc_log_t *lctx, dns_c_viewtable_t *viewtable,
|
||||
dns_c_view_t *view);
|
||||
|
||||
/*
|
||||
|
|
@ -152,7 +195,8 @@ void dns_c_viewtable_addview(dns_c_viewtable_t *viewtable,
|
|||
*
|
||||
*/
|
||||
|
||||
void dns_c_viewtable_rmview(dns_c_viewtable_t *viewtable, dns_c_view_t *view);
|
||||
void dns_c_viewtable_rmview(isc_log_t *lctx, dns_c_viewtable_t *viewtable,
|
||||
dns_c_view_t *view);
|
||||
|
||||
/*
|
||||
* Removes the view from the given table. Does not memory
|
||||
|
|
@ -164,7 +208,8 @@ void dns_c_viewtable_rmview(dns_c_viewtable_t *viewtable, dns_c_view_t *view);
|
|||
*
|
||||
*/
|
||||
|
||||
isc_result_t dns_c_viewtable_viewbyname(dns_c_viewtable_t *viewtable,
|
||||
isc_result_t dns_c_viewtable_viewbyname(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *viewtable,
|
||||
const char *viewname,
|
||||
dns_c_view_t **retval);
|
||||
|
||||
|
|
@ -181,7 +226,8 @@ isc_result_t dns_c_viewtable_viewbyname(dns_c_viewtable_t *viewtable,
|
|||
*
|
||||
*/
|
||||
|
||||
isc_result_t dns_c_viewtable_rmviewbyname(dns_c_viewtable_t *viewtable,
|
||||
isc_result_t dns_c_viewtable_rmviewbyname(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *viewtable,
|
||||
const char *name);
|
||||
/*
|
||||
* Removes a view from a view table. The view is looked up by name.
|
||||
|
|
@ -197,7 +243,8 @@ isc_result_t dns_c_viewtable_rmviewbyname(dns_c_viewtable_t *viewtable,
|
|||
*/
|
||||
|
||||
|
||||
isc_result_t dns_c_viewtable_clear(dns_c_viewtable_t *viewtable);
|
||||
isc_result_t dns_c_viewtable_clear(isc_log_t *lctx,
|
||||
dns_c_viewtable_t *viewtable);
|
||||
/*
|
||||
* Removes (and deletes) all the views in the viewtable.
|
||||
*
|
||||
|
|
@ -208,7 +255,7 @@ isc_result_t dns_c_viewtable_clear(dns_c_viewtable_t *viewtable);
|
|||
* ISC_R_SUCCESS -- all is well
|
||||
*/
|
||||
|
||||
void dns_c_viewtable_print(FILE *fp, int indent,
|
||||
void dns_c_viewtable_print(isc_log_t *lctx, FILE *fp, int indent,
|
||||
dns_c_viewtable_t *table);
|
||||
|
||||
/*
|
||||
|
|
@ -221,7 +268,7 @@ void dns_c_viewtable_print(FILE *fp, int indent,
|
|||
*/
|
||||
|
||||
|
||||
isc_result_t dns_c_view_new(isc_mem_t *mem, const char *name,
|
||||
isc_result_t dns_c_view_new(isc_log_t *lctx, isc_mem_t *mem, const char *name,
|
||||
dns_c_view_t **newview);
|
||||
/*
|
||||
* Creates a new view. The view is placed in the given viewtable.
|
||||
|
|
@ -238,9 +285,9 @@ isc_result_t dns_c_view_new(isc_mem_t *mem, const char *name,
|
|||
*
|
||||
*/
|
||||
|
||||
isc_result_t dns_c_view_delete(dns_c_view_t **view);
|
||||
isc_result_t dns_c_view_delete(isc_log_t *lctx, dns_c_view_t **view);
|
||||
/*
|
||||
* Deletes the view and it's contents.
|
||||
* Deletes the view and its contents.
|
||||
*
|
||||
* Requires:
|
||||
* view be a pointer to a valid view.
|
||||
|
|
@ -250,7 +297,7 @@ isc_result_t dns_c_view_delete(dns_c_view_t **view);
|
|||
*
|
||||
*/
|
||||
|
||||
isc_result_t dns_c_view_setallowquery(dns_c_view_t *view,
|
||||
isc_result_t dns_c_view_setallowquery(isc_log_t *lctx, dns_c_view_t *view,
|
||||
dns_c_ipmatchlist_t *ipml,
|
||||
isc_boolean_t deepcopy);
|
||||
/*
|
||||
|
|
@ -272,7 +319,7 @@ isc_result_t dns_c_view_setallowquery(dns_c_view_t *view,
|
|||
*
|
||||
*/
|
||||
|
||||
isc_result_t dns_c_view_getallowqueryexpanded(isc_mem_t *mem,
|
||||
isc_result_t dns_c_view_getallowqueryexpanded(isc_log_t *lctx, isc_mem_t *mem,
|
||||
dns_c_view_t *view,
|
||||
dns_c_acltable_t *acltable,
|
||||
dns_c_ipmatchlist_t **retval);
|
||||
|
|
@ -297,7 +344,8 @@ isc_result_t dns_c_view_getallowqueryexpanded(isc_mem_t *mem,
|
|||
*/
|
||||
|
||||
|
||||
void dns_c_view_print(FILE *fp, int indent, dns_c_view_t *view);
|
||||
void dns_c_view_print(isc_log_t *lctx, FILE *fp, int indent,
|
||||
dns_c_view_t *view);
|
||||
|
||||
/*
|
||||
* Prints the view VIEW to the stdio stream FP. An INDENT number of
|
||||
|
|
|
|||
|
|
@ -80,12 +80,20 @@ typedef struct dns_c_forward_zone dns_c_forwardzone_t;
|
|||
typedef struct dns_c_hint_zone dns_c_hintzone_t;
|
||||
typedef struct dns_c_zone dns_c_zone_t;
|
||||
typedef struct dns_c_zone_list dns_c_zonelist_t;
|
||||
typedef struct dns_c_zonelem dns_c_zonelem_t;
|
||||
|
||||
struct dns_c_zonelem
|
||||
{
|
||||
dns_c_zone_t *thezone;
|
||||
ISC_LINK(dns_c_zonelem_t) next;
|
||||
};
|
||||
|
||||
|
||||
struct dns_c_zone_list
|
||||
{
|
||||
isc_mem_t *mem;
|
||||
|
||||
ISC_LIST(dns_c_zone_t) zones;
|
||||
ISC_LIST(dns_c_zonelem_t) zones;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -173,9 +181,11 @@ struct dns_c_hint_zone
|
|||
|
||||
struct dns_c_zone
|
||||
{
|
||||
dns_c_zonelist_t *mylist;
|
||||
|
||||
char *name;
|
||||
isc_mem_t *mem;
|
||||
isc_uint8_t refcount;
|
||||
|
||||
char *name; /* e.g. "foo.com" */
|
||||
char *internalname; /* e.g. "foo.com.ext" */
|
||||
dns_rdataclass_t zclass;
|
||||
|
||||
dns_c_zonetype_t ztype;
|
||||
|
|
@ -189,8 +199,6 @@ struct dns_c_zone
|
|||
} u;
|
||||
|
||||
isc_boolean_t afteropts;
|
||||
|
||||
ISC_LINK(dns_c_zone_t) next;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -202,11 +210,19 @@ isc_result_t dns_c_zonelist_new(isc_log_t *lctx, isc_mem_t *mem,
|
|||
dns_c_zonelist_t **zlist);
|
||||
isc_result_t dns_c_zonelist_delete(isc_log_t *lctx,
|
||||
dns_c_zonelist_t **zlist);
|
||||
#if 0
|
||||
dns_c_zone_t *dns_c_zonelist_currzone(isc_log_t *lctx,
|
||||
dns_c_zonelist_t *zlist);
|
||||
#endif
|
||||
|
||||
isc_result_t dns_c_zonelist_find(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
||||
const char *name, dns_c_zone_t **retval);
|
||||
isc_result_t dns_c_zonelist_rmbyname(isc_log_t *lctx,
|
||||
dns_c_zonelist_t *zlist,
|
||||
const char *name);
|
||||
isc_result_t dns_c_zonelist_addzone(isc_log_t *lctx,
|
||||
dns_c_zonelist_t *zlist,
|
||||
dns_c_zone_t *zone);
|
||||
isc_result_t dns_c_zonelist_rmzone(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
||||
dns_c_zone_t *zone);
|
||||
void dns_c_zonelist_print(isc_log_t *lctx, FILE *fp, int indent,
|
||||
|
|
@ -217,10 +233,13 @@ void dns_c_zonelist_printpostopts(isc_log_t *lctx, FILE *fp,
|
|||
void dns_c_zonelist_printpreopts(isc_log_t *lctx, FILE *fp,
|
||||
int indent,
|
||||
dns_c_zonelist_t *list);
|
||||
isc_result_t dns_c_zone_new(isc_log_t *lctx, dns_c_zonelist_t *zlist,
|
||||
isc_result_t dns_c_zone_new(isc_log_t *lctx, isc_mem_t *mem,
|
||||
dns_c_zonetype_t ztype, dns_rdataclass_t zclass,
|
||||
const char *name,
|
||||
const char *name, const char *internalname,
|
||||
dns_c_zone_t **zone);
|
||||
isc_result_t dns_c_zone_delete(isc_log_t *lctx, dns_c_zone_t **zone);
|
||||
void dns_c_zone_attach(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
dns_c_zone_t **newzone);
|
||||
void dns_c_zone_print(isc_log_t *lctx, FILE *fp, int indent,
|
||||
dns_c_zone_t *zone);
|
||||
isc_result_t dns_c_zone_setfile(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
|
|
@ -274,6 +293,8 @@ isc_result_t dns_c_zone_setforwarders(isc_log_t *lctx, dns_c_zone_t *zone,
|
|||
isc_boolean_t deepcopy);
|
||||
isc_result_t dns_c_zone_getname(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
const char **retval);
|
||||
isc_result_t dns_c_zone_getinternalname(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
const char **retval);
|
||||
isc_result_t dns_c_zone_getfile(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
const char **retval);
|
||||
isc_result_t dns_c_zone_getchecknames(isc_log_t *lctx, dns_c_zone_t *zone,
|
||||
|
|
|
|||
Loading…
Reference in a new issue