xref: /openbsd/usr.sbin/nsd/remote.h (revision fc61954a)
1 /*
2  * remote.h - remote control for the NSD daemon.
3  *
4  * Copyright (c) 2008, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 /**
37  * \file
38  *
39  * This file contains the remote control functionality for the daemon.
40  * The remote control can be performed using either the commandline
41  * nsd-control tool, or a SSLv3/TLS capable web browser.
42  * The channel is secured using SSLv3 or TLSv1, and certificates.
43  * Both the server and the client(control tool) have their own keys.
44  */
45 
46 #ifndef DAEMON_REMOTE_H
47 #define DAEMON_REMOTE_H
48 struct xfrd_state;
49 struct nsd_options;
50 
51 /* private, defined in remote.c to keep ssl.h out of this header */
52 struct daemon_remote;
53 struct rc_state;
54 
55 /* the remote control needs less backlog than the tcp53 service */
56 #define TCP_BACKLOG_REMOTE 16 /* listen() tcp backlog */
57 
58 /**
59  * Create new remote control state for the daemon.
60  * Also setups the control port.
61  * @param cfg: config file with key file settings.
62  * @return new state, or NULL on failure.
63  */
64 struct daemon_remote* daemon_remote_create(struct nsd_options* cfg);
65 
66 /**
67  * remote control state to delete.
68  * @param rc: state to delete.
69  */
70 void daemon_remote_delete(struct daemon_remote* rc);
71 
72 /**
73  * Close remote control ports.  Clears up busy connections.
74  * Does not delete the rc itself, or the ssl context (with its keys).
75  * @param rc: state to close.
76  */
77 void daemon_remote_close(struct daemon_remote* rc);
78 
79 /**
80  * Open and create listening ports for remote control.
81  * @param rc: rc state that contains list of accept port sockets.
82  * @param cfg: config options.
83  * @return false on failure.
84  */
85 int daemon_remote_open_ports(struct daemon_remote* rc,
86 	struct nsd_options* cfg);
87 
88 /**
89  * Setup comm points for accepting remote control connections.
90  * @param rc: state
91  * @param xfrd: the process that hosts the control connection.
92  *	The rc is attached to its event base.
93  */
94 void daemon_remote_attach(struct daemon_remote* rc, struct xfrd_state* xfrd);
95 
96 /**
97  * Process statistic results and send them
98  * @param rc: state.
99  */
100 void daemon_remote_process_stats(struct daemon_remote* rc);
101 
102 #endif /* DAEMON_REMOTE_H */
103