diff --git a/bin/named/include/named/listenlist.h b/bin/named/include/named/listenlist.h index 928e2743d9..4eca218b43 100644 --- a/bin/named/include/named/listenlist.h +++ b/bin/named/include/named/listenlist.h @@ -30,10 +30,7 @@ *** Imports ***/ -#include -#include -#include -#include +#include /*** *** Types @@ -62,13 +59,20 @@ struct ns_listenlist { ISC_LANG_BEGINDECLS isc_result_t -ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx, - dns_aclconfctx_t *actx, - isc_mem_t *mctx, ns_listenlist_t **target); -/* - * Create a listen list from the corresponding configuration - * data structure. - */ +ns_listenelt_create(isc_mem_t *mctx, in_port_t port, + dns_acl_t *acl, ns_listenelt_t **target); + +void +ns_listenelt_destroy(ns_listenelt_t *elt); + +isc_result_t +ns_listenlist_create(isc_mem_t *mctx, ns_listenlist_t **target); + +void +ns_listenlist_attach(ns_listenlist_t *source, ns_listenlist_t **target); + +void +ns_listenlist_detach(ns_listenlist_t **listp); isc_result_t ns_listenlist_default(isc_mem_t *mctx, in_port_t port, @@ -78,12 +82,6 @@ ns_listenlist_default(isc_mem_t *mctx, in_port_t port, * all addresses with port 'port'. */ -void -ns_listenlist_attach(ns_listenlist_t *source, ns_listenlist_t **target); - -void -ns_listenlist_detach(ns_listenlist_t **listp); - ISC_LANG_ENDDECLS #endif /* NS_LISTENLIST_H */ diff --git a/bin/named/interfacemgr.c b/bin/named/interfacemgr.c index 365148916a..26b6e04c5e 100644 --- a/bin/named/interfacemgr.c +++ b/bin/named/interfacemgr.c @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/bin/named/listenlist.c b/bin/named/listenlist.c index e566863f2c..c9fd7c4671 100644 --- a/bin/named/listenlist.c +++ b/bin/named/listenlist.c @@ -21,11 +21,13 @@ #include #include +#include + #include static void destroy(ns_listenlist_t *list); -static isc_result_t +isc_result_t ns_listenelt_create(isc_mem_t *mctx, in_port_t port, dns_acl_t *acl, ns_listenelt_t **target) { @@ -42,35 +44,14 @@ ns_listenelt_create(isc_mem_t *mctx, in_port_t port, return (ISC_R_SUCCESS); } -static void +void ns_listenelt_destroy(ns_listenelt_t *elt) { if (elt->acl != NULL) dns_acl_detach(&elt->acl); isc_mem_put(elt->mctx, elt, sizeof(*elt)); } -static isc_result_t -ns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx, - dns_aclconfctx_t *actx, - isc_mem_t *mctx, ns_listenelt_t **target) -{ - isc_result_t result; - ns_listenelt_t *delt = NULL; - REQUIRE(target != NULL && *target == NULL); - result = ns_listenelt_create(mctx, celt->port, NULL, &delt); - if (result != ISC_R_SUCCESS) - return (result); - - result = dns_acl_fromconfig(celt->iml, cctx, actx, mctx, &delt->acl); - if (result != DNS_R_SUCCESS) { - ns_listenelt_destroy(delt); - return (result); - } - *target = delt; - return (ISC_R_SUCCESS); -} - -static isc_result_t +isc_result_t ns_listenlist_create(isc_mem_t *mctx, ns_listenlist_t **target) { ns_listenlist_t *list = NULL; REQUIRE(target != NULL && *target == NULL); @@ -84,39 +65,6 @@ ns_listenlist_create(isc_mem_t *mctx, ns_listenlist_t **target) { return (ISC_R_SUCCESS); } -isc_result_t -ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx, - dns_aclconfctx_t *actx, - isc_mem_t *mctx, ns_listenlist_t **target) -{ - dns_c_lstnon_t *ce; - isc_result_t result; - ns_listenlist_t *dlist = NULL; - - REQUIRE(target != NULL && *target == NULL); - - result = ns_listenlist_create(mctx, &dlist); - if (result != ISC_R_SUCCESS) - return (result); - - for (ce = ISC_LIST_HEAD(clist->elements); - ce != NULL; - ce = ISC_LIST_NEXT(ce, next)) - { - ns_listenelt_t *delt = NULL; - result = ns_listenelt_fromconfig(ce, cctx, actx, mctx, &delt); - if (result != DNS_R_SUCCESS) - goto cleanup; - ISC_LIST_APPEND(dlist->elts, delt, link); - } - *target = dlist; - return (ISC_R_SUCCESS); - - cleanup: - destroy(dlist); - return (result); -} - static void destroy(ns_listenlist_t *list) { ns_listenelt_t *elt, *next; diff --git a/bin/named/server.c b/bin/named/server.c index c1864e5a0f..a4b84b1c72 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -38,6 +38,9 @@ #include #include +#include +#include +#include #include #include #include @@ -98,6 +101,14 @@ typedef struct { static void fatal(char *msg, isc_result_t result); static void ns_server_reload(isc_task_t *task, isc_event_t *event); +static isc_result_t +ns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx, + dns_aclconfctx_t *actx, + isc_mem_t *mctx, ns_listenelt_t **target); +static isc_result_t +ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx, + dns_aclconfctx_t *actx, + isc_mem_t *mctx, ns_listenlist_t **target); /* * Configure 'view' according to 'cctx'. @@ -835,3 +846,62 @@ ns_server_reloadwanted(ns_server_t *server) { isc_task_send(server->task, &server->reload_event); UNLOCK(&server->reload_event_lock); } + +isc_result_t +ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx, + dns_aclconfctx_t *actx, + isc_mem_t *mctx, ns_listenlist_t **target) +{ + dns_c_lstnon_t *ce; + isc_result_t result; + ns_listenlist_t *dlist = NULL; + + REQUIRE(target != NULL && *target == NULL); + + result = ns_listenlist_create(mctx, &dlist); + if (result != ISC_R_SUCCESS) + return (result); + + for (ce = ISC_LIST_HEAD(clist->elements); + ce != NULL; + ce = ISC_LIST_NEXT(ce, next)) + { + ns_listenelt_t *delt = NULL; + result = ns_listenelt_fromconfig(ce, cctx, actx, mctx, &delt); + if (result != DNS_R_SUCCESS) + goto cleanup; + ISC_LIST_APPEND(dlist->elts, delt, link); + } + *target = dlist; + return (ISC_R_SUCCESS); + + cleanup: + ns_listenlist_detach(&dlist); + return (result); +} + +/* + * Create a listen list from the corresponding configuration + * data structure. + */ +static isc_result_t +ns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx, + dns_aclconfctx_t *actx, + isc_mem_t *mctx, ns_listenelt_t **target) +{ + isc_result_t result; + ns_listenelt_t *delt = NULL; + REQUIRE(target != NULL && *target == NULL); + result = ns_listenelt_create(mctx, celt->port, NULL, &delt); + if (result != ISC_R_SUCCESS) + return (result); + + result = dns_acl_fromconfig(celt->iml, cctx, actx, mctx, &delt->acl); + if (result != DNS_R_SUCCESS) { + ns_listenelt_destroy(delt); + return (result); + } + *target = delt; + return (ISC_R_SUCCESS); +} +