diff --git a/CHANGES b/CHANGES index c79de7e5c4..750c42e7b3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,6 @@ + 710. [func] The forwarders statement now takes an optional port. + 709. [bug] ANY or SIG queries for data with a TTL of 0 would return SERVFAIL. [RT #620] diff --git a/bin/named/lwresd.c b/bin/named/lwresd.c index 053160d2bd..a912e05c5e 100644 --- a/bin/named/lwresd.c +++ b/bin/named/lwresd.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lwresd.c,v 1.29 2001/01/19 01:20:00 bwelling Exp $ */ +/* $Id: lwresd.c,v 1.30 2001/01/25 02:33:39 bwelling Exp $ */ /* * Main program for the Lightweight Resolver Daemon. @@ -218,9 +218,8 @@ ns_lwresd_parseresolvconf(isc_mem_t *mctx, dns_c_ctx_t **ctxp) { } if (forwarders->nextidx != 0) { - CHECK(dns_c_ctx_setforwarders(ctx, ISC_FALSE, - forwarders)); - forwarders = NULL; + CHECK(dns_c_ctx_setforwarders(ctx, forwarders)); + dns_c_iplist_detach(&forwarders); CHECK(dns_c_ctx_setforward(ctx, dns_c_forw_first)); } } diff --git a/bin/named/server.c b/bin/named/server.c index bbb0ee86cf..16ba016bcc 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.284 2001/01/23 01:50:26 bwelling Exp $ */ +/* $Id: server.c,v 1.285 2001/01/25 02:33:40 bwelling Exp $ */ #include @@ -1000,7 +1000,6 @@ configure_forward(dns_c_ctx_t *cctx, dns_c_zone_t *czone, dns_c_view_t *cview, goto cleanup; } *sa = forwarders->ips[i]; - isc_sockaddr_setport(sa, port); ISC_LINK_INIT(sa, link); ISC_LIST_APPEND(addresses, sa, link); } diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 9e904c2d3c..0938485cca 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zoneconf.c,v 1.79 2001/01/09 21:40:10 bwelling Exp $ */ +/* $Id: zoneconf.c,v 1.80 2001/01/25 02:33:42 bwelling Exp $ */ #include @@ -420,7 +420,7 @@ ns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview, case dns_c_zone_stub: iplist = NULL; result = dns_c_zone_getmasterips(czone, &iplist); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { #ifndef NOMINUM_PUBLIC result = dns_zone_setmasterswithkeys(zone, iplist->ips, @@ -430,7 +430,8 @@ ns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview, result = dns_zone_setmasters(zone, iplist->ips, iplist->nextidx); #endif /* NOMINUM_PUBLIC */ - else + dns_c_iplist_detach(&iplist); + } else result = dns_zone_setmasters(zone, NULL, 0); RETERR(result); diff --git a/lib/dns/config/confctx.c b/lib/dns/config/confctx.c index c05ba8dd55..18b6709e4f 100644 --- a/lib/dns/config/confctx.c +++ b/lib/dns/config/confctx.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confctx.c,v 1.116 2001/01/22 03:59:12 gson Exp $ */ +/* $Id: confctx.c,v 1.117 2001/01/25 02:33:43 bwelling Exp $ */ #include @@ -311,18 +311,10 @@ PVT_CONCAT(dns_c_ctx_unset, FUNC)(dns_c_ctx_t *cfg) \ -static isc_result_t cfg_set_iplist(dns_c_options_t *options, - dns_c_iplist_t **fieldaddr, - dns_c_iplist_t *newval, - isc_boolean_t copy); static isc_result_t cfg_set_string(dns_c_options_t *options, char **field, const char *newval); - -static isc_result_t cfg_get_iplist(dns_c_options_t *options, - dns_c_iplist_t *field, - dns_c_iplist_t **resval); static isc_result_t acl_init(dns_c_ctx_t *cfg); static isc_result_t logging_init (dns_c_ctx_t *cfg); static isc_result_t make_options(dns_c_ctx_t *cfg); @@ -2407,8 +2399,8 @@ dns_c_ctx_getv6listenlist(dns_c_ctx_t *cfg, dns_c_lstnlist_t **ll) isc_result_t -dns_c_ctx_setforwarders(dns_c_ctx_t *cfg, isc_boolean_t copy, - dns_c_iplist_t *ipl) +dns_c_ctx_setforwarders(dns_c_ctx_t *cfg, + dns_c_iplist_t *iml) { isc_result_t res; @@ -2419,26 +2411,31 @@ dns_c_ctx_setforwarders(dns_c_ctx_t *cfg, isc_boolean_t copy, return (res); } - res = cfg_set_iplist(cfg->options, &cfg->options->forwarders, - ipl, copy); + REQUIRE(iml != NULL); - return (res); + if (cfg->options->forwarders != NULL) + return (ISC_R_EXISTS); + + dns_c_iplist_attach(iml, &cfg->options->forwarders); + + return (ISC_R_SUCCESS); } isc_result_t -dns_c_ctx_getforwarders(dns_c_ctx_t *cfg, dns_c_iplist_t **list) +dns_c_ctx_getforwarders(dns_c_ctx_t *cfg, dns_c_iplist_t **ret) { REQUIRE(DNS_C_CONFCTX_VALID(cfg)); - if (cfg->options == NULL) { + if (cfg->options == NULL || cfg->options->forwarders == NULL) { return (ISC_R_NOTFOUND); } - REQUIRE(list != NULL); + REQUIRE(ret != NULL); - return (cfg_get_iplist(cfg->options, - cfg->options->forwarders, list)); + dns_c_iplist_attach(cfg->options->forwarders, ret); + + return (ISC_R_SUCCESS); } @@ -2551,7 +2548,7 @@ dns_c_ctx_setalsonotify(dns_c_ctx_t *cfg, REQUIRE(iml != NULL); if (cfg->options->also_notify != NULL) - dns_c_iplist_detach(&cfg->options->also_notify); + return (ISC_R_EXISTS); dns_c_iplist_attach(iml, &cfg->options->also_notify); @@ -2671,83 +2668,6 @@ cfg_set_string(dns_c_options_t *options, char **field, const char *newval) } -static isc_result_t -cfg_set_iplist(dns_c_options_t *options, - dns_c_iplist_t **fieldaddr, - dns_c_iplist_t *newval, - isc_boolean_t copy) -{ - isc_result_t res; - isc_boolean_t existed = ISC_FALSE; - - REQUIRE(DNS_C_CONFOPT_VALID(options)); - REQUIRE(fieldaddr != NULL); - - if (*fieldaddr != NULL) { - existed = ISC_TRUE; - } - - if (newval == NULL) { - res = dns_c_iplist_new(options->mem, - newval->size, - fieldaddr); - } else if (copy) { - if (*fieldaddr != NULL) { - dns_c_iplist_detach(fieldaddr); - } - - res = dns_c_iplist_copy(options->mem, fieldaddr, - newval); - } else { - if (*fieldaddr != NULL) { - res = dns_c_iplist_detach(fieldaddr); - if (res != ISC_R_SUCCESS) { - return (res); - } - } - - res = ISC_R_SUCCESS; - - *fieldaddr = newval; - } - - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } - - return (res); -} - - - - - - - -static isc_result_t -cfg_get_iplist(dns_c_options_t *options, - dns_c_iplist_t *field, - dns_c_iplist_t **resval) -{ - isc_result_t res; - - UNUSED(options); - - REQUIRE(DNS_C_CONFOPT_VALID(options)); - REQUIRE(resval != NULL); - - if (field != NULL && field->nextidx != 0) { - dns_c_iplist_attach(field, resval); - res = ISC_R_SUCCESS; - } else { - *resval = NULL; - res = ISC_R_NOTFOUND; - } - - return (res); -} - - static isc_result_t acl_init(dns_c_ctx_t *cfg) diff --git a/lib/dns/config/confparser.y.dirty b/lib/dns/config/confparser.y.dirty index 9b1adca0d0..c9259df2df 100644 --- a/lib/dns/config/confparser.y.dirty +++ b/lib/dns/config/confparser.y.dirty @@ -33,7 +33,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confparser.y.dirty,v 1.50 2001/01/22 03:59:19 gson Exp $ */ +/* $Id: confparser.y.dirty,v 1.51 2001/01/25 02:33:44 bwelling Exp $ */ #include @@ -458,7 +458,6 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult); %type address_match_simple %type address_name %type address_match_list -%type in_addr_elem %type ip4_address %type ip4_prefix %type ip6_address @@ -470,9 +469,6 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult); %type query_source_v4 %type query_source_v6 %type ip_and_port_element -%type in_addr_list -%type opt_in_addr_list -%type opt_zone_forwarders_list %type port_ip_list %type ip_and_port_list %type facility_name @@ -1040,31 +1036,21 @@ option: /* Empty */ YYABORT; } } - | L_FORWARDERS { - dns_c_iplist_t *forwarders; + | L_FORWARDERS port_ip_list + { + replace_zero_ports($2, default_port); + tmpres = dns_c_ctx_setforwarders(currcfg, $2); + dns_c_iplist_detach(&$2); - tmpres = dns_c_ctx_getforwarders(currcfg, &forwarders); - if (tmpres != ISC_R_NOTFOUND) { - parser_warning(ISC_FALSE, - "cannot redefine options forwarders"); - dns_c_iplist_detach(&forwarders); - } - - tmpres = dns_c_iplist_new(currcfg->mem, 5, &forwarders); - if (tmpres != ISC_R_SUCCESS) { + if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, - "failed to create forwarders list"); + "cannot redefine forwarders"); + YYABORT; + } else if (tmpres != ISC_R_SUCCESS) { + parser_error(ISC_FALSE, "failed to set forwarders"); YYABORT; } - - tmpres = dns_c_ctx_setforwarders(currcfg, ISC_FALSE, - forwarders); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_FALSE, - "failed to set forwarders list"); - YYABORT; - } - } L_LBRACE opt_forwarders_list L_RBRACE + } | L_QUERY_SOURCE query_source_v4 { tmpres = dns_c_ctx_setquerysource(currcfg, $2); @@ -2050,7 +2036,7 @@ ip_and_port_element: ip_address maybe_zero_port }; -ip_and_port_list: ip_and_port_element maybe_key L_EOS +ip_and_port_list: /* empty */ { dns_c_iplist_t *list; @@ -2061,17 +2047,6 @@ ip_and_port_list: ip_and_port_element maybe_key L_EOS YYABORT; } - tmpres = dns_c_iplist_append(list, $1, $2); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_TRUE, - "failed to append master address"); - YYABORT; - } - - if ($2 != NULL) { - isc_mem_free(memctx, $2); - } - $$ = list; } | ip_and_port_list ip_and_port_element maybe_key L_EOS @@ -2442,29 +2417,6 @@ transfer_clause: L_TRANSFERS_IN L_INTEGER ; -opt_forwarders_list: /* nothing */ { - } - | forwarders_in_addr_list - ; - -forwarders_in_addr_list: forwarders_in_addr L_EOS - | forwarders_in_addr_list forwarders_in_addr L_EOS - ; - -forwarders_in_addr: ip_address - { - tmpres = dns_c_iplist_append(currcfg->options->forwarders, - $1, NULL); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_FALSE, - "failed to add forwarders " - "address element"); - YYABORT; - } - } - ; - - /* * Logging */ @@ -3722,14 +3674,14 @@ view_option: L_FORWARD zone_forward_opt YYABORT; } } - | L_FORWARDERS L_LBRACE opt_in_addr_list L_RBRACE + | L_FORWARDERS port_ip_list { dns_c_view_t *view = dns_c_ctx_getcurrview(currcfg); INSIST(view != NULL); - tmpres = dns_c_view_setforwarders(view, - $3, ISC_FALSE); + tmpres = dns_c_view_setforwarders(view, $2); + dns_c_iplist_detach(&$2); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine view forwarders"); @@ -3739,7 +3691,6 @@ view_option: L_FORWARD zone_forward_opt "failed to set view forwarders"); YYABORT; } - dns_c_iplist_detach(&$3); } | L_ALLOW_NOTIFY L_LBRACE address_match_list L_RBRACE { @@ -4667,9 +4618,6 @@ zone_ssu_stmt: grant_stmt { "ssutable"); ok = ISC_FALSE; } - } - - if (ok) { dns_c_zone_setssuauth(zone, ssutable); } } @@ -4679,6 +4627,7 @@ zone_ssu_stmt: grant_stmt { $1.name, $1.rdatatypes.idx, $1.rdatatypes.types); + dns_ssutable_detach(&ssutable); if (tmpres != ISC_R_SUCCESS) { parser_error(ISC_FALSE, "error creating ssu " @@ -5137,7 +5086,8 @@ zone_option: L_FILE L_QSTRING replace_zero_ports($2, default_port); - tmpres = dns_c_zone_setmasterips(zone, $2, ISC_FALSE); + tmpres = dns_c_zone_setmasterips(zone, $2); + dns_c_iplist_detach(&$2); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone masters ips"); @@ -5315,8 +5265,8 @@ zone_option: L_FILE L_QSTRING INSIST(zone != NULL); - tmpres = dns_c_zone_setallowupd(zone, - $3, ISC_FALSE); + tmpres = dns_c_zone_setallowupd(zone, $3); + dns_c_ipmatchlist_detach(&$3); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone allow-update"); @@ -5333,8 +5283,8 @@ zone_option: L_FILE L_QSTRING INSIST(zone != NULL); - tmpres = dns_c_zone_setallowupdateforwarding(zone, - $3, ISC_FALSE); + tmpres = dns_c_zone_setallowupdateforwarding(zone, $3); + dns_c_ipmatchlist_detach(&$3); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone " @@ -5353,8 +5303,8 @@ zone_option: L_FILE L_QSTRING INSIST(zone != NULL); - tmpres = dns_c_zone_setallownotify(zone, - $3, ISC_FALSE); + tmpres = dns_c_zone_setallownotify(zone, $3); + dns_c_ipmatchlist_detach(&$3); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone allow-notify"); @@ -5371,8 +5321,8 @@ zone_option: L_FILE L_QSTRING INSIST(zone != NULL); - tmpres = dns_c_zone_setallowquery(zone, - $3, ISC_FALSE); + tmpres = dns_c_zone_setallowquery(zone, $3); + dns_c_ipmatchlist_detach(&$3); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone allow-query"); @@ -5389,8 +5339,8 @@ zone_option: L_FILE L_QSTRING INSIST(zone != NULL); - tmpres = dns_c_zone_setallowtransfer(zone, - $3, ISC_FALSE); + tmpres = dns_c_zone_setallowtransfer(zone, $3); + dns_c_ipmatchlist_detach(&$3); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone allow-transfer"); @@ -5418,28 +5368,14 @@ zone_option: L_FILE L_QSTRING YYABORT; } } - | L_FORWARDERS L_LBRACE opt_zone_forwarders_list L_RBRACE + | L_FORWARDERS port_ip_list { dns_c_zone_t *zone = dns_c_ctx_getcurrzone(currcfg); - dns_c_iplist_t *iplist; INSIST(zone != NULL); - if ($3 == NULL) { /* user defined empty list */ - tmpres = dns_c_iplist_new(currcfg->mem, - 5, &iplist); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_TRUE, - "failed to create new zone " - "iplist"); - YYABORT; - } - } else { - iplist = $3; - } - - tmpres = dns_c_zone_setforwarders(zone, - iplist, ISC_FALSE); + tmpres = dns_c_zone_setforwarders(zone, $2); + dns_c_iplist_detach(&$2); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone forwarders"); @@ -5749,7 +5685,8 @@ zone_option: L_FILE L_QSTRING replace_zero_ports($2, default_port); - tmpres = dns_c_zone_setalsonotify(zone, $2, ISC_FALSE); + tmpres = dns_c_zone_setalsonotify(zone, $2); + dns_c_iplist_detach(&$2); if (tmpres == ISC_R_EXISTS) { parser_error(ISC_FALSE, "cannot redefine zone also-notify"); @@ -5859,58 +5796,6 @@ ip_prefix: ip4_address | ip4_prefix | ip6_address ip_address: ip4_address | ip6_address ; -in_addr_elem: ip_address - ; - -opt_in_addr_list: /* nothing */ - { - dns_c_iplist_t *list; - - tmpres = dns_c_iplist_new(currcfg->mem, 5, &list); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_TRUE, - "failed to create new iplist"); - YYABORT; - } - - $$ = list; - } - | in_addr_list - ; - -in_addr_list: in_addr_elem L_EOS - { - dns_c_iplist_t *list; - - tmpres = dns_c_iplist_new(currcfg->mem, 5, &list); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_TRUE, - "failed to create new iplist"); - YYABORT; - } - - tmpres = dns_c_iplist_append(list, $1, NULL); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_TRUE, - "failed to append master address"); - YYABORT; - } - - $$ = list; - } - | in_addr_list in_addr_elem L_EOS - { - tmpres = dns_c_iplist_append($1, $2, NULL); - if (tmpres != ISC_R_SUCCESS) { - parser_error(ISC_TRUE, - "failed to append master address"); - YYABORT; - } - - $$ = $1; - } - ; - zone_forward_opt: L_ONLY { $$ = dns_c_forw_only; @@ -5921,9 +5806,6 @@ zone_forward_opt: L_ONLY } ; -opt_zone_forwarders_list: opt_in_addr_list - ; - /* * Trusted Key statement */ diff --git a/lib/dns/config/confview.c b/lib/dns/config/confview.c index 2bcf39388a..230476ec8c 100644 --- a/lib/dns/config/confview.c +++ b/lib/dns/config/confview.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confview.c,v 1.70 2001/01/22 03:59:20 gson Exp $ */ +/* $Id: confview.c,v 1.71 2001/01/25 02:33:46 bwelling Exp $ */ #include @@ -1132,33 +1132,17 @@ BYTYPE_FUNCS(dns_c_forw_t, forward, forward) */ isc_result_t -dns_c_view_setforwarders(dns_c_view_t *view, - dns_c_iplist_t *ipl, - isc_boolean_t deepcopy) +dns_c_view_setforwarders(dns_c_view_t *view, dns_c_iplist_t *ipl) { - isc_boolean_t existed = ISC_FALSE; - isc_result_t res; - REQUIRE(DNS_C_VIEW_VALID(view)); REQUIRE(DNS_C_IPLIST_VALID(ipl)); - if (view->forwarders != NULL) { - existed = ISC_TRUE; - dns_c_iplist_detach(&view->forwarders); - } + if (view->forwarders != NULL) + return (ISC_R_EXISTS); - if (deepcopy) { - res = dns_c_iplist_copy(view->mem, &view->forwarders, ipl); - } else { - dns_c_iplist_attach(ipl, &view->forwarders); - res = ISC_R_SUCCESS; - } + dns_c_iplist_attach(ipl, &view->forwarders); - if (res == ISC_R_SUCCESS) { - return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS); - } else { - return (res); - } + return (ISC_R_SUCCESS); } @@ -1197,22 +1181,17 @@ dns_c_view_getforwarders(dns_c_view_t *view, */ isc_result_t -dns_c_view_setalsonotify(dns_c_view_t *view, - dns_c_iplist_t *ipl) +dns_c_view_setalsonotify(dns_c_view_t *view, dns_c_iplist_t *ipl) { - isc_boolean_t existed = ISC_FALSE; - REQUIRE(DNS_C_VIEW_VALID(view)); REQUIRE(DNS_C_IPLIST_VALID(ipl)); - if (view->also_notify != NULL) { - existed = ISC_TRUE; - dns_c_iplist_detach(&view->also_notify); - } + if (view->also_notify != NULL) + return (ISC_R_EXISTS); dns_c_iplist_attach(ipl, &view->also_notify); - return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS); + return (ISC_R_SUCCESS); } diff --git a/lib/dns/config/confzone.c b/lib/dns/config/confzone.c index bfaf18d119..191e60e9c8 100644 --- a/lib/dns/config/confzone.c +++ b/lib/dns/config/confzone.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confzone.c,v 1.75 2001/01/22 03:59:21 gson Exp $ */ +/* $Id: confzone.c,v 1.76 2001/01/25 02:33:47 bwelling Exp $ */ #include @@ -146,14 +146,6 @@ static void hint_zone_print(FILE *fp, int indent, dns_c_hintzone_t *hzone); static void forward_zone_print(FILE *fp, int indent, dns_c_forwardzone_t *fzone); -static isc_result_t set_iplist_field(isc_mem_t *mem, - dns_c_iplist_t **dest, - dns_c_iplist_t *src, - isc_boolean_t deepcopy); -static isc_result_t set_ipmatch_list_field(isc_mem_t *mem, - dns_c_ipmatchlist_t **dest, - dns_c_ipmatchlist_t *src, - isc_boolean_t deepcopy); static const char * dialup_totext(dns_dialuptype_t dialup) { @@ -661,6 +653,7 @@ dns_c_zone_validate(dns_c_zone_t *zone) ISC_LOG_WARNING, autherr, zone->name); dns_c_zone_unsetallowupd(zone); + dns_ssutable_detach(&ssutable); } dns_c_ipmatchlist_detach(&ipmlist); } @@ -680,8 +673,10 @@ dns_c_zone_validate(dns_c_zone_t *zone) DNS_LOGMODULE_CONFIG, ISC_LOG_WARNING, emptymasterserr, zone->name); + dns_c_iplist_detach(&iplist); result = ISC_R_FAILURE; - } + } else + dns_c_iplist_detach(&iplist); } /* @@ -1024,12 +1019,9 @@ dns_c_zone_getchecknames(dns_c_zone_t *zone, dns_severity_t *retval) { isc_result_t dns_c_zone_setallowupdateforwarding(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy) + dns_c_ipmatchlist_t *ipml) { dns_c_ipmatchlist_t **p = NULL; - isc_result_t res; - isc_boolean_t existed; REQUIRE(DNS_C_ZONE_VALID(zone)); REQUIRE(DNS_C_IPMLIST_VALID(ipml)); @@ -1062,15 +1054,12 @@ dns_c_zone_setallowupdateforwarding(dns_c_zone_t *zone, return (ISC_R_FAILURE); } - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); + if (*p != NULL) + return (ISC_R_EXISTS); - res = set_ipmatch_list_field(zone->mem, p, - ipml, deepcopy); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + dns_c_ipmatchlist_attach(ipml, p); - return (res); + return (ISC_R_SUCCESS); } @@ -1134,7 +1123,6 @@ dns_c_zone_getallowupdateforwarding(dns_c_zone_t *zone, isc_result_t dns_c_zone_setssuauth(dns_c_zone_t *zone, dns_ssutable_t *ssu) { dns_ssutable_t **p = NULL; - isc_boolean_t existed; REQUIRE(DNS_C_ZONE_VALID(zone)); @@ -1170,11 +1158,12 @@ dns_c_zone_setssuauth(dns_c_zone_t *zone, dns_ssutable_t *ssu) { return (ISC_R_FAILURE); } - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); + if (*p != NULL) + return (ISC_R_EXISTS); - *p = ssu; + dns_ssutable_attach(ssu, p); - return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS); + return (ISC_R_SUCCESS); } @@ -1223,7 +1212,7 @@ dns_c_zone_getssuauth(dns_c_zone_t *zone, dns_ssutable_t **retval) { } if (p != NULL) { - *retval = p; + dns_ssutable_attach(p, retval); res = ISC_R_SUCCESS; } else { res = ISC_R_NOTFOUND; @@ -1234,13 +1223,8 @@ dns_c_zone_getssuauth(dns_c_zone_t *zone, dns_ssutable_t **retval) { isc_result_t -dns_c_zone_setallownotify(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy) -{ +dns_c_zone_setallownotify(dns_c_zone_t *zone, dns_c_ipmatchlist_t *ipml) { dns_c_ipmatchlist_t **p = NULL; - isc_boolean_t existed; - isc_result_t res; REQUIRE(DNS_C_ZONE_VALID(zone)); REQUIRE(DNS_C_IPMLIST_VALID(ipml)); @@ -1276,15 +1260,12 @@ dns_c_zone_setallownotify(dns_c_zone_t *zone, return (ISC_R_FAILURE); } - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); + if (*p != NULL) + return (ISC_R_EXISTS); - res = set_ipmatch_list_field(zone->mem, p, - ipml, deepcopy); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + dns_c_ipmatchlist_attach(ipml, p); - return (res); + return (ISC_R_SUCCESS); } @@ -1342,13 +1323,8 @@ dns_c_zone_getallownotify(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval) { } isc_result_t -dns_c_zone_setallowquery(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy) -{ +dns_c_zone_setallowquery(dns_c_zone_t *zone, dns_c_ipmatchlist_t *ipml) { dns_c_ipmatchlist_t **p = NULL; - isc_boolean_t existed; - isc_result_t res; REQUIRE(DNS_C_ZONE_VALID(zone)); REQUIRE(DNS_C_IPMLIST_VALID(ipml)); @@ -1380,15 +1356,12 @@ dns_c_zone_setallowquery(dns_c_zone_t *zone, return (ISC_R_FAILURE); } - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); + if (*p != NULL) + return (ISC_R_EXISTS); - res = set_ipmatch_list_field(zone->mem, p, - ipml, deepcopy); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + dns_c_ipmatchlist_attach(ipml, p); - return (res); + return (ISC_R_SUCCESS); } @@ -1447,13 +1420,8 @@ dns_c_zone_getallowquery(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval) { */ isc_result_t -dns_c_zone_setallowtransfer(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy) -{ +dns_c_zone_setallowtransfer(dns_c_zone_t *zone, dns_c_ipmatchlist_t *ipml) { dns_c_ipmatchlist_t **p = NULL; - isc_boolean_t existed; - isc_result_t res; REQUIRE(DNS_C_ZONE_VALID(zone)); REQUIRE(DNS_C_IPMLIST_VALID(ipml)); @@ -1486,15 +1454,12 @@ dns_c_zone_setallowtransfer(dns_c_zone_t *zone, return (ISC_R_FAILURE); } - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); - res = set_ipmatch_list_field(zone->mem, p, - ipml, deepcopy); + if (*p != NULL) + return (ISC_R_EXISTS); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + dns_c_ipmatchlist_attach(ipml, p); - return (res); + return (ISC_R_SUCCESS); } @@ -1883,12 +1848,7 @@ dns_c_zone_getnotify(dns_c_zone_t *zone, dns_notifytype_t *retval) { */ isc_result_t -dns_c_zone_setalsonotify(dns_c_zone_t *zone, - dns_c_iplist_t *newval, - isc_boolean_t deepcopy) -{ - isc_boolean_t existed; - isc_result_t res; +dns_c_zone_setalsonotify(dns_c_zone_t *zone, dns_c_iplist_t *newval) { dns_c_iplist_t **p = NULL; REQUIRE(zone != NULL); @@ -1922,13 +1882,12 @@ dns_c_zone_setalsonotify(dns_c_zone_t *zone, return (ISC_R_FAILURE); } - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); - res = set_iplist_field(zone->mem, p, newval, deepcopy); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + if (*p != NULL) + return (ISC_R_EXISTS); - return (res); + dns_c_iplist_attach(newval, p); + + return (ISC_R_SUCCESS); } @@ -2581,12 +2540,7 @@ dns_c_zone_getmasterport(dns_c_zone_t *zone, in_port_t *retval) { */ isc_result_t -dns_c_zone_setmasterips(dns_c_zone_t *zone, - dns_c_iplist_t *newval, - isc_boolean_t deepcopy) -{ - isc_boolean_t existed; - isc_result_t res = ISC_R_SUCCESS; +dns_c_zone_setmasterips(dns_c_zone_t *zone, dns_c_iplist_t *newval) { dns_c_iplist_t **p; REQUIRE(DNS_C_ZONE_VALID(zone)); @@ -2600,19 +2554,11 @@ dns_c_zone_setmasterips(dns_c_zone_t *zone, return (ISC_R_FAILURE); case dns_c_zone_slave: - case dns_c_zone_stub: - if (zone->ztype == dns_c_zone_slave) { - p = &zone->u.szone.master_ips ; - } else { - p = &zone->u.tzone.master_ips ; - } + p = &zone->u.szone.master_ips; + break; - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); - res = set_iplist_field(zone->mem, p, - newval, deepcopy); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + case dns_c_zone_stub: + p = &zone->u.tzone.master_ips ; break; case dns_c_zone_hint: @@ -2628,7 +2574,12 @@ dns_c_zone_setmasterips(dns_c_zone_t *zone, return (ISC_R_FAILURE); } - return (res); + if (*p != NULL) + return (ISC_R_EXISTS); + + dns_c_iplist_attach(newval, p); + + return (ISC_R_SUCCESS); } @@ -2638,6 +2589,7 @@ dns_c_zone_setmasterips(dns_c_zone_t *zone, isc_result_t dns_c_zone_getmasterips(dns_c_zone_t *zone, dns_c_iplist_t **retval) { + dns_c_iplist_t *p; isc_result_t res = ISC_R_SUCCESS; REQUIRE(DNS_C_ZONE_VALID(zone)); @@ -2651,21 +2603,11 @@ dns_c_zone_getmasterips(dns_c_zone_t *zone, dns_c_iplist_t **retval) { return (ISC_R_FAILURE); case dns_c_zone_slave: - if (zone->u.szone.master_ips != NULL) { - *retval = zone->u.szone.master_ips; - res = ISC_R_SUCCESS; - } else { - res = ISC_R_NOTFOUND; - } + p = zone->u.szone.master_ips; break; case dns_c_zone_stub: - if (zone->u.tzone.master_ips != NULL) { - *retval = zone->u.tzone.master_ips; - res = ISC_R_SUCCESS; - } else { - res = ISC_R_NOTFOUND; - } + p = zone->u.tzone.master_ips; break; case dns_c_zone_hint: @@ -2681,6 +2623,13 @@ dns_c_zone_getmasterips(dns_c_zone_t *zone, dns_c_iplist_t **retval) { return (ISC_R_FAILURE); } + if (p != NULL) { + dns_c_iplist_attach(p, retval); + res = ISC_R_SUCCESS; + } else { + res = ISC_R_NOTFOUND; + } + return (res); } @@ -4377,12 +4326,8 @@ dns_c_zone_getforward(dns_c_zone_t *zone, dns_c_forw_t *retval) { */ isc_result_t -dns_c_zone_setforwarders(dns_c_zone_t *zone, - dns_c_iplist_t *ipl, - isc_boolean_t deepcopy) +dns_c_zone_setforwarders(dns_c_zone_t *zone, dns_c_iplist_t *ipl) { - isc_boolean_t existed = ISC_FALSE; - isc_result_t res; dns_c_iplist_t **p = NULL; REQUIRE(DNS_C_ZONE_VALID(zone)); @@ -4391,17 +4336,14 @@ dns_c_zone_setforwarders(dns_c_zone_t *zone, switch (zone->ztype) { case dns_c_zone_master: p = &zone->u.mzone.forwarders; - existed = (*p == NULL ? ISC_FALSE : ISC_TRUE); break; case dns_c_zone_slave: p = &zone->u.szone.forwarders; - existed = (*p == NULL ? ISC_FALSE : ISC_TRUE); break; case dns_c_zone_stub: p = &zone->u.tzone.forwarders; - existed = (*p == NULL ? ISC_FALSE : ISC_TRUE); break; case dns_c_zone_hint: @@ -4412,16 +4354,15 @@ dns_c_zone_setforwarders(dns_c_zone_t *zone, case dns_c_zone_forward: p = &zone->u.fzone.forwarders; - existed = (*p == NULL ? ISC_FALSE : ISC_TRUE); break; } - res = set_iplist_field(zone->mem, p, ipl, deepcopy); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + if (*p != NULL) + return (ISC_R_EXISTS); - return (res); + dns_c_iplist_attach(ipl, p); + + return (ISC_R_SUCCESS); } @@ -4440,7 +4381,7 @@ dns_c_zone_getforwarders(dns_c_zone_t *zone, dns_c_iplist_t **retval) { case dns_c_zone_master: if (zone->u.mzone.forwarders != NULL && zone->u.mzone.forwarders->nextidx > 0) { - *retval = zone->u.mzone.forwarders; + dns_c_iplist_attach(zone->u.mzone.forwarders, retval); res = ISC_R_SUCCESS; } else { res = ISC_R_NOTFOUND; @@ -4450,7 +4391,7 @@ dns_c_zone_getforwarders(dns_c_zone_t *zone, dns_c_iplist_t **retval) { case dns_c_zone_slave: if (zone->u.szone.forwarders != NULL && zone->u.szone.forwarders->nextidx > 0) { - *retval = zone->u.szone.forwarders; + dns_c_iplist_attach(zone->u.szone.forwarders, retval); res = ISC_R_SUCCESS; } else { res = ISC_R_NOTFOUND; @@ -4460,7 +4401,7 @@ dns_c_zone_getforwarders(dns_c_zone_t *zone, dns_c_iplist_t **retval) { case dns_c_zone_stub: if (zone->u.tzone.forwarders != NULL && zone->u.tzone.forwarders->nextidx > 0) { - *retval = zone->u.tzone.forwarders; + dns_c_iplist_attach(zone->u.tzone.forwarders, retval); res = ISC_R_SUCCESS; } else { res = ISC_R_NOTFOUND; @@ -4476,7 +4417,7 @@ dns_c_zone_getforwarders(dns_c_zone_t *zone, dns_c_iplist_t **retval) { case dns_c_zone_forward: if (zone->u.fzone.forwarders != NULL && zone->u.fzone.forwarders->nextidx > 0) { - *retval = zone->u.fzone.forwarders; + dns_c_iplist_attach(zone->u.fzone.forwarders, retval); res = ISC_R_SUCCESS; } else { res = ISC_R_NOTFOUND; @@ -4493,13 +4434,8 @@ dns_c_zone_getforwarders(dns_c_zone_t *zone, dns_c_iplist_t **retval) { */ isc_result_t -dns_c_zone_setallowupd(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy) -{ +dns_c_zone_setallowupd(dns_c_zone_t *zone, dns_c_ipmatchlist_t *ipml) { dns_c_ipmatchlist_t **p = NULL; - isc_result_t res; - isc_boolean_t existed; REQUIRE(DNS_C_ZONE_VALID(zone)); REQUIRE(DNS_C_IPMLIST_VALID(ipml)); @@ -4531,15 +4467,12 @@ dns_c_zone_setallowupd(dns_c_zone_t *zone, return (ISC_R_FAILURE); } - existed = (*p != NULL ? ISC_TRUE : ISC_FALSE); + if (*p != NULL) + return (ISC_R_EXISTS); - res = set_ipmatch_list_field(zone->mem, p, - ipml, deepcopy); - if (res == ISC_R_SUCCESS && existed) { - res = ISC_R_EXISTS; - } + dns_c_ipmatchlist_attach(ipml, p); - return (res); + return (ISC_R_SUCCESS); } @@ -5810,64 +5743,3 @@ hint_zone_clear(isc_mem_t *mem, dns_c_hintzone_t *hzone) { return (ISC_R_SUCCESS); } - - -/* - * - */ - -/**************************************************/ - -static isc_result_t -set_ipmatch_list_field(isc_mem_t *mem, - dns_c_ipmatchlist_t **dest, dns_c_ipmatchlist_t *src, - isc_boolean_t deepcopy) -{ - isc_result_t res; - - if (*dest != NULL) { - res = dns_c_ipmatchlist_detach(dest); - if (res != ISC_R_SUCCESS) { - return (res); - } - } - - if (deepcopy) { - res = dns_c_ipmatchlist_copy(mem, dest, src); - } else { - *dest = src; - res = ISC_R_SUCCESS; - } - - return (res); -} - - -/* - * - */ - -static isc_result_t -set_iplist_field(isc_mem_t *mem, - dns_c_iplist_t **dest, dns_c_iplist_t *src, - isc_boolean_t deepcopy) -{ - isc_result_t res; - - if (*dest != NULL) { - res = dns_c_iplist_detach(dest); - if (res != ISC_R_SUCCESS) { - return (res); - } - } - - if (deepcopy) { - res = dns_c_iplist_copy(mem, dest, src); - } else { - *dest = src; - res = ISC_R_SUCCESS; - } - - return (res); -} - diff --git a/lib/dns/include/dns/confctx.h b/lib/dns/include/dns/confctx.h index 37538a1d25..55dfe755f9 100644 --- a/lib/dns/include/dns/confctx.h +++ b/lib/dns/include/dns/confctx.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confctx.h,v 1.62 2001/01/09 21:52:28 bwelling Exp $ */ +/* $Id: confctx.h,v 1.63 2001/01/25 02:33:48 bwelling Exp $ */ #ifndef DNS_CONFCTX_H #define DNS_CONFCTX_H 1 @@ -810,9 +810,8 @@ isc_result_t dns_c_ctx_getallowupdateforwarding(dns_c_ctx_t *cfg, isc_result_t dns_c_ctx_unsetallowupdateforwarding(dns_c_ctx_t *cfg); -isc_result_t dns_c_ctx_setforwarders(dns_c_ctx_t *cfg, isc_boolean_t copy, - dns_c_iplist_t *iml); -isc_result_t dns_c_ctx_getforwarders(dns_c_ctx_t *cfg, dns_c_iplist_t **list); +isc_result_t dns_c_ctx_setforwarders(dns_c_ctx_t *cfg, dns_c_iplist_t *iml); +isc_result_t dns_c_ctx_getforwarders(dns_c_ctx_t *cfg, dns_c_iplist_t **ret); isc_result_t dns_c_ctx_unsetforwarders(dns_c_ctx_t *cfg); diff --git a/lib/dns/include/dns/confview.h b/lib/dns/include/dns/confview.h index c458502dff..1db0b1e841 100644 --- a/lib/dns/include/dns/confview.h +++ b/lib/dns/include/dns/confview.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confview.h,v 1.50 2001/01/09 21:52:40 bwelling Exp $ */ +/* $Id: confview.h,v 1.51 2001/01/25 02:33:52 bwelling Exp $ */ #ifndef DNS_CONFVIEW_H #define DNS_CONFVIEW_H 1 @@ -231,8 +231,7 @@ isc_result_t dns_c_view_unsetforward(dns_c_view_t *view); -isc_result_t dns_c_view_setforwarders(dns_c_view_t *view, dns_c_iplist_t *ipl, - isc_boolean_t deepcopy); +isc_result_t dns_c_view_setforwarders(dns_c_view_t *view, dns_c_iplist_t *ipl); isc_result_t dns_c_view_unsetforwarders(dns_c_view_t *view); isc_result_t dns_c_view_getforwarders(dns_c_view_t *view, dns_c_iplist_t **ipl); diff --git a/lib/dns/include/dns/confzone.h b/lib/dns/include/dns/confzone.h index 5913a11379..6e6e3ca246 100644 --- a/lib/dns/include/dns/confzone.h +++ b/lib/dns/include/dns/confzone.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confzone.h,v 1.51 2001/01/09 21:52:41 bwelling Exp $ */ +/* $Id: confzone.h,v 1.52 2001/01/25 02:33:53 bwelling Exp $ */ #ifndef DNS_CONFZONE_H #define DNS_CONFZONE_H 1 @@ -305,8 +305,7 @@ isc_result_t dns_c_zone_getchecknames(dns_c_zone_t *zone, isc_result_t dns_c_zone_setallowupdateforwarding(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy); + dns_c_ipmatchlist_t *ipml); isc_result_t dns_c_zone_getallowupdateforwarding(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval); @@ -318,21 +317,18 @@ isc_result_t dns_c_zone_getssuauth(dns_c_zone_t *zone, isc_result_t dns_c_zone_setallownotify(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy); + dns_c_ipmatchlist_t *ipml); isc_result_t dns_c_zone_getallownotify(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval); isc_result_t dns_c_zone_setallowquery(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy); + dns_c_ipmatchlist_t *ipml); isc_result_t dns_c_zone_getallowquery(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval); isc_result_t dns_c_zone_setallowtransfer(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy); + dns_c_ipmatchlist_t *ipml); isc_result_t dns_c_zone_getallowtransfer(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval); @@ -360,8 +356,7 @@ isc_result_t dns_c_zone_getnotify(dns_c_zone_t *zone, isc_result_t dns_c_zone_setalsonotify(dns_c_zone_t *zone, - dns_c_iplist_t *newval, - isc_boolean_t deepcopy); + dns_c_iplist_t *newval); isc_result_t dns_c_zone_getalsonotify(dns_c_zone_t *zone, dns_c_iplist_t **retval); @@ -389,8 +384,7 @@ isc_result_t dns_c_zone_getmasterport(dns_c_zone_t *zone, in_port_t *retval); isc_result_t dns_c_zone_setmasterips(dns_c_zone_t *zone, - dns_c_iplist_t *newval, - isc_boolean_t deepcopy); + dns_c_iplist_t *newval); isc_result_t dns_c_zone_getmasterips(dns_c_zone_t *zone, dns_c_iplist_t **retval); @@ -484,15 +478,14 @@ isc_result_t dns_c_zone_setforward(dns_c_zone_t *zone, isc_result_t dns_c_zone_getforward(dns_c_zone_t *zone, dns_c_forw_t *retval); -isc_result_t dns_c_zone_setforwarders(dns_c_zone_t *zone, dns_c_iplist_t *ipml, - isc_boolean_t deepcopy); +isc_result_t dns_c_zone_setforwarders(dns_c_zone_t *zone, + dns_c_iplist_t *ipml); isc_result_t dns_c_zone_getforwarders(dns_c_zone_t *zone, dns_c_iplist_t **retval); isc_result_t dns_c_zone_setallowupd(dns_c_zone_t *zone, - dns_c_ipmatchlist_t *ipml, - isc_boolean_t deepcopy); + dns_c_ipmatchlist_t *ipml); isc_result_t dns_c_zone_getallowupd(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval); isc_result_t dns_c_zone_unsetallowupd(dns_c_zone_t *zone);