Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / bin / named / include / named / interfacemgr.h
blobf0e339993aec03b43ca427c5f0eeb5bf8cd64242
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: interfacemgr.h,v 1.23.2.1 2004/03/09 06:09:21 marka Exp $ */
20 #ifndef NAMED_INTERFACEMGR_H
21 #define NAMED_INTERFACEMGR_H 1
23 /*****
24 ***** Module Info
25 *****/
28 * Interface manager
30 * The interface manager monitors the operating system's list
31 * of network interfaces, creating and destroying listeners
32 * as needed.
34 * Reliability:
35 * No impact expected.
37 * Resources:
39 * Security:
40 * The server will only be able to bind to the DNS port on
41 * newly discovered interfaces if it is running as root.
43 * Standards:
44 * The API for scanning varies greatly among operating systems.
45 * This module attempts to hide the differences.
48 /***
49 *** Imports
50 ***/
52 #include <isc/magic.h>
53 #include <isc/mem.h>
54 #include <isc/socket.h>
56 #include <dns/result.h>
58 #include <named/listenlist.h>
59 #include <named/types.h>
61 /***
62 *** Types
63 ***/
65 #define IFACE_MAGIC ISC_MAGIC('I',':','-',')')
66 #define NS_INTERFACE_VALID(t) ISC_MAGIC_VALID(t, IFACE_MAGIC)
68 struct ns_interface {
69 unsigned int magic; /* Magic number. */
70 ns_interfacemgr_t * mgr; /* Interface manager. */
71 isc_mutex_t lock;
72 int references; /* Locked */
73 unsigned int generation; /* Generation number. */
74 isc_sockaddr_t addr; /* Address and port. */
75 char name[32]; /* Null terminated. */
76 dns_dispatch_t * udpdispatch; /* UDP dispatcher. */
77 isc_socket_t * tcpsocket; /* TCP socket. */
78 int ntcptarget; /* Desired number of concurrent
79 TCP accepts */
80 int ntcpcurrent; /* Current ditto, locked */
81 ns_clientmgr_t * clientmgr; /* Client manager. */
82 ISC_LINK(ns_interface_t) link;
85 /***
86 *** Functions
87 ***/
89 isc_result_t
90 ns_interfacemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
91 isc_socketmgr_t *socketmgr,
92 dns_dispatchmgr_t *dispatchmgr,
93 ns_interfacemgr_t **mgrp);
95 * Create a new interface manager.
97 * Initially, the new manager will not listen on any interfaces.
98 * Call ns_interfacemgr_setlistenon() and/or ns_interfacemgr_setlistenon6()
99 * to set nonempty listen-on lists.
102 void
103 ns_interfacemgr_attach(ns_interfacemgr_t *source, ns_interfacemgr_t **target);
105 void
106 ns_interfacemgr_detach(ns_interfacemgr_t **targetp);
108 void
109 ns_interfacemgr_shutdown(ns_interfacemgr_t *mgr);
111 void
112 ns_interfacemgr_scan(ns_interfacemgr_t *mgr, isc_boolean_t verbose);
114 * Scan the operatings system's list of network interfaces
115 * and create listeners when new interfaces are discovered.
116 * Shut down the sockets for interfaces that go away.
118 * This should be called once on server startup and then
119 * periodically according to the 'interface-interval' option
120 * in named.conf.
123 void
124 ns_interfacemgr_setlistenon4(ns_interfacemgr_t *mgr, ns_listenlist_t *value);
126 * Set the IPv4 "listen-on" list of 'mgr' to 'value'.
127 * The previous IPv4 listen-on list is freed.
130 void
131 ns_interfacemgr_setlistenon6(ns_interfacemgr_t *mgr, ns_listenlist_t *value);
133 * Set the IPv6 "listen-on" list of 'mgr' to 'value'.
134 * The previous IPv6 listen-on list is freed.
137 dns_aclenv_t *
138 ns_interfacemgr_getaclenv(ns_interfacemgr_t *mgr);
140 void
141 ns_interface_attach(ns_interface_t *source, ns_interface_t **target);
143 void
144 ns_interface_detach(ns_interface_t **targetp);
146 void
147 ns_interface_shutdown(ns_interface_t *ifp);
149 * Stop listening for queries on interface 'ifp'.
150 * May safely be called multiple times.
153 #endif /* NAMED_INTERFACEMGR_H */