xref: /openbsd/usr.sbin/nsd/ipc.h (revision 3d8817e4)
1 /*
2  * ipc.h - Interprocess communication routines. Handlers read and write.
3  *
4  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
5  *
6  * See LICENSE for the license.
7  *
8  */
9 
10 #ifndef NSD_IPC_H
11 #define NSD_IPC_H
12 
13 #include <config.h>
14 #include "netio.h"
15 struct buffer;
16 struct nsd;
17 struct nsd_child;
18 struct xfrd_tcp;
19 
20 /*
21  * Data for the server_main IPC handler
22  * Used by parent side to listen to children, and write to children.
23  */
24 struct main_ipc_handler_data
25 {
26 	struct nsd	*nsd;
27 	struct nsd_child *child;
28 	int		child_num;
29 
30 	/* pointer to the socket, as it may change if it is restarted */
31 	int		*xfrd_sock;
32 	struct buffer	*packet;
33 	int		forward_mode;
34 	size_t		got_bytes;
35 	uint16_t	total_bytes;
36 	uint32_t	acl_num;
37 
38 	/* writing data, connection and state */
39 	uint8_t		busy_writing_zone_state;
40 	struct xfrd_tcp	*write_conn;
41 };
42 
43 /*
44  * Data for ipc handler, nsd and a conn for reading ipc msgs.
45  * Used by children to listen to parent.
46  * Used by parent to listen to xfrd.
47  */
48 struct ipc_handler_conn_data
49 {
50 	struct nsd	*nsd;
51 	struct xfrd_tcp	*conn;
52 };
53 
54 /*
55  * Routine used by server_main.
56  * Handle a command received from the xfrdaemon processes.
57  */
58 void parent_handle_xfrd_command(netio_type *netio,
59 	netio_handler_type *handler, netio_event_types_type event_types);
60 
61 /*
62  * Routine used by server_main.
63  * Handle a command received from the reload process.
64  */
65 void parent_handle_reload_command(netio_type *netio,
66 	netio_handler_type *handler, netio_event_types_type event_types);
67 
68 /*
69  * Routine used by server_main.
70  * Handle a command received from the children processes.
71  * Send commands and forwarded xfrd packets when writable.
72  */
73 void parent_handle_child_command(netio_type *netio,
74 	netio_handler_type *handler, netio_event_types_type event_types);
75 
76 /*
77  * Routine used by server_child.
78  * Handle a command received from the parent process.
79  */
80 void child_handle_parent_command(netio_type *netio,
81 	netio_handler_type *handler, netio_event_types_type event_types);
82 
83 /*
84  * Routine used by xfrd
85  * Handle interprocess communication with parent process, read and write.
86  */
87 void xfrd_handle_ipc(netio_type *netio,
88 	netio_handler_type *handler, netio_event_types_type event_types);
89 
90 /* check if all children have exited in an orderly fashion and set mode */
91 void parent_check_all_children_exited(struct nsd* nsd);
92 
93 #endif /* NSD_IPC_H */
94