Lines Matching defs:mgr
83 purge_old_interfaces(ns_interfacemgr_t *mgr);
86 clearlistenon(ns_interfacemgr_t *mgr);
92 ns_interfacemgr_t *mgr = NULL;
101 mgr = event->ev_arg;
110 ns_interfacemgr_detach(&mgr);
115 rtm = (struct MSGHDR *)mgr->buf;
123 ns_interfacemgr_detach(&mgr);
132 if (mgr->route != NULL && ns_g_server->interface_auto)
139 LOCK(&mgr->lock);
140 if (mgr->route != NULL) {
144 r.base = mgr->buf;
145 r.length = sizeof(mgr->buf);
146 result = isc_socket_recv(mgr->route, &r, 1, mgr->task,
147 route_event, mgr);
151 UNLOCK(&mgr->lock);
154 ns_interfacemgr_detach(&mgr);
167 ns_interfacemgr_t *mgr;
177 mgr = isc_mem_get(mctx, sizeof(*mgr));
178 if (mgr == NULL)
181 mgr->mctx = NULL;
182 isc_mem_attach(mctx, &mgr->mctx);
184 result = isc_mutex_init(&mgr->lock);
188 mgr->taskmgr = taskmgr;
189 mgr->socketmgr = socketmgr;
190 mgr->dispatchmgr = dispatchmgr;
191 mgr->generation = 1;
192 mgr->listenon4 = NULL;
193 mgr->listenon6 = NULL;
195 ISC_LIST_INIT(mgr->interfaces);
196 ISC_LIST_INIT(mgr->listenon);
201 result = ns_listenlist_create(mctx, &mgr->listenon4);
204 ns_listenlist_attach(mgr->listenon4, &mgr->listenon6);
206 result = dns_aclenv_init(mctx, &mgr->aclenv);
210 mgr->aclenv.geoip = ns_g_geoip;
214 mgr->route = NULL;
215 result = isc_socket_create(mgr->socketmgr, ROUTE_SOCKET_PROTOCOL,
216 isc_sockettype_raw, &mgr->route);
227 mgr->task = NULL;
228 if (mgr->route != NULL)
229 isc_task_attach(task, &mgr->task);
230 mgr->references = (mgr->route != NULL) ? 2 : 1;
232 mgr->references = 1;
234 mgr->magic = IFMGR_MAGIC;
235 *mgrp = mgr;
238 if (mgr->route != NULL) {
239 isc_region_t r = { mgr->buf, sizeof(mgr->buf) };
241 result = isc_socket_recv(mgr->route, &r, 1, mgr->task,
242 route_event, mgr);
244 isc_task_detach(&mgr->task);
245 isc_socket_detach(&mgr->route);
246 ns_interfacemgr_detach(&mgr);
254 dns_aclenv_destroy(&mgr->aclenv);
257 ns_listenlist_detach(&mgr->listenon4);
258 ns_listenlist_detach(&mgr->listenon6);
260 isc_mem_putanddetach(&mgr->mctx, mgr, sizeof(*mgr));
265 ns_interfacemgr_destroy(ns_interfacemgr_t *mgr) {
266 REQUIRE(NS_INTERFACEMGR_VALID(mgr));
269 if (mgr->route != NULL)
270 isc_socket_detach(&mgr->route);
271 if (mgr->task != NULL)
272 isc_task_detach(&mgr->task);
274 dns_aclenv_destroy(&mgr->aclenv);
275 ns_listenlist_detach(&mgr->listenon4);
276 ns_listenlist_detach(&mgr->listenon6);
277 clearlistenon(mgr);
278 DESTROYLOCK(&mgr->lock);
279 mgr->magic = 0;
280 isc_mem_putanddetach(&mgr->mctx, mgr, sizeof(*mgr));
284 ns_interfacemgr_getaclenv(ns_interfacemgr_t *mgr) {
285 return (&mgr->aclenv);
316 ns_interfacemgr_shutdown(ns_interfacemgr_t *mgr) {
317 REQUIRE(NS_INTERFACEMGR_VALID(mgr));
324 mgr->generation++;
326 LOCK(&mgr->lock);
327 if (mgr->route != NULL) {
328 isc_socket_cancel(mgr->route, mgr->task, ISC_SOCKCANCEL_RECV);
329 isc_socket_detach(&mgr->route);
330 isc_task_detach(&mgr->task);
332 UNLOCK(&mgr->lock);
334 purge_old_interfaces(mgr);
339 ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
346 REQUIRE(NS_INTERFACEMGR_VALID(mgr));
348 ifp = isc_mem_get(mgr->mctx, sizeof(*ifp));
352 ifp->mgr = NULL;
353 ifp->generation = mgr->generation;
363 result = ns_clientmgr_create(mgr->mctx, mgr->taskmgr,
392 ns_interfacemgr_attach(mgr, &ifp->mgr);
393 ISC_LIST_APPEND(mgr->interfaces, ifp, link);
406 isc_mem_put(mgr->mctx, ifp, sizeof(*ifp));
431 result = dns_dispatch_getudp_dup(ifp->mgr->dispatchmgr,
480 result = isc_socket_create(ifp->mgr->socketmgr,
540 ns_interface_setup(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
550 result = ns_interface_create(mgr, addr, name, &ifp);
583 ISC_LIST_UNLINK(ifp->mgr->interfaces, ifp, link);
596 isc_mem_t *mctx = ifp->mgr->mctx;
615 ns_interfacemgr_detach(&ifp->mgr);
653 find_matching_interface(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr) {
655 for (ifp = ISC_LIST_HEAD(mgr->interfaces); ifp != NULL;
667 purge_old_interfaces(ns_interfacemgr_t *mgr) {
669 for (ifp = ISC_LIST_HEAD(mgr->interfaces); ifp != NULL; ifp = next) {
672 if (ifp->generation != mgr->generation) {
674 ISC_LIST_UNLINK(ifp->mgr->interfaces, ifp, link);
705 setup_locals(ns_interfacemgr_t *mgr, isc_interface_t *interface) {
714 result = dns_iptable_addprefix(mgr->aclenv.localhost->iptable,
744 result = dns_iptable_addprefix(mgr->aclenv.localnets->iptable,
753 setup_listenon(ns_interfacemgr_t *mgr, isc_interface_t *interface,
759 addr = isc_mem_get(mgr->mctx, sizeof(*addr));
765 for (old = ISC_LIST_HEAD(mgr->listenon);
772 isc_mem_put(mgr->mctx, addr, sizeof(*addr));
774 ISC_LIST_APPEND(mgr->listenon, addr, link);
778 clearlistenon(ns_interfacemgr_t *mgr) {
781 old = ISC_LIST_HEAD(mgr->listenon);
783 ISC_LIST_UNLINK(mgr->listenon, old, link);
784 isc_mem_put(mgr->mctx, old, sizeof(*old));
785 old = ISC_LIST_HEAD(mgr->listenon);
790 do_scan(ns_interfacemgr_t *mgr, ns_listenlist_t *ext_listen,
850 for (le = ISC_LIST_HEAD(mgr->listenon6->elts);
861 ifp = find_matching_interface(mgr, &listen_addr);
863 ifp->generation = mgr->generation;
882 result = ns_interface_setup(mgr, &listen_addr,
902 result = isc_interfaceiter_create(mgr->mctx, &iter);
907 result = clearacl(mgr->mctx, &mgr->aclenv.localhost);
910 result = clearacl(mgr->mctx, &mgr->aclenv.localnets);
913 clearlistenon(mgr);
965 result = setup_locals(mgr, &interface);
971 ll = (family == AF_INET) ? mgr->listenon4 : mgr->listenon6;
1004 &mgr->aclenv, &match, NULL);
1009 setup_listenon(mgr, &interface, le->port);
1049 ifp = find_matching_interface(mgr, &listen_sockaddr);
1051 ifp->generation = mgr->generation;
1095 result = ns_interface_setup(mgr,
1145 ns_interfacemgr_scan0(ns_interfacemgr_t *mgr, ns_listenlist_t *ext_listen,
1151 REQUIRE(NS_INTERFACEMGR_VALID(mgr));
1153 mgr->generation++; /* Increment the generation count. */
1155 result = do_scan(mgr, ext_listen, verbose);
1166 purge_old_interfaces(mgr);
1174 ISC_LIST_EMPTY(mgr->interfaces) && ! ns_g_lwresdonly) {
1183 ns_interfacemgr_islistening(ns_interfacemgr_t *mgr) {
1184 REQUIRE(NS_INTERFACEMGR_VALID(mgr));
1186 return (ISC_LIST_EMPTY(mgr->interfaces) ? ISC_FALSE : ISC_TRUE);
1190 ns_interfacemgr_scan(ns_interfacemgr_t *mgr, isc_boolean_t verbose) {
1191 return (ns_interfacemgr_scan0(mgr, NULL, verbose));
1195 ns_interfacemgr_adjust(ns_interfacemgr_t *mgr, ns_listenlist_t *list,
1198 return (ns_interfacemgr_scan0(mgr, list, verbose));
1202 ns_interfacemgr_setlistenon4(ns_interfacemgr_t *mgr, ns_listenlist_t *value) {
1203 LOCK(&mgr->lock);
1204 ns_listenlist_detach(&mgr->listenon4);
1205 ns_listenlist_attach(value, &mgr->listenon4);
1206 UNLOCK(&mgr->lock);
1210 ns_interfacemgr_setlistenon6(ns_interfacemgr_t *mgr, ns_listenlist_t *value) {
1211 LOCK(&mgr->lock);
1212 ns_listenlist_detach(&mgr->listenon6);
1213 ns_listenlist_attach(value, &mgr->listenon6);
1214 UNLOCK(&mgr->lock);
1218 ns_interfacemgr_dumprecursing(FILE *f, ns_interfacemgr_t *mgr) {
1221 LOCK(&mgr->lock);
1222 interface = ISC_LIST_HEAD(mgr->interfaces);
1228 UNLOCK(&mgr->lock);
1232 ns_interfacemgr_listeningon(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr) {
1235 for (old = ISC_LIST_HEAD(mgr->listenon);