forked from NLnetLabs/nsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ipc.h
98 lines (84 loc) · 2.44 KB
/
ipc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* ipc.h - Interprocess communication routines. Handlers read and write.
*
* Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
*
* See LICENSE for the license.
*
*/
#ifndef NSD_IPC_H
#define NSD_IPC_H
#include "netio.h"
struct buffer;
struct nsd;
struct nsd_child;
struct xfrd_tcp;
struct xfrd_state;
struct nsdst;
struct event;
/*
* Data for the server_main IPC handler
* Used by parent side to listen to children, and write to children.
*/
struct main_ipc_handler_data
{
struct nsd *nsd;
struct nsd_child *child;
int child_num;
/* pointer to the socket, as it may change if it is restarted */
int *xfrd_sock;
struct buffer *packet;
int forward_mode;
size_t got_bytes;
uint16_t total_bytes;
uint32_t acl_num;
int32_t acl_xfr;
};
/*
* Data for ipc handler, nsd and a conn for reading ipc msgs.
* Used by children to listen to parent.
* Used by parent to listen to xfrd.
*/
struct ipc_handler_conn_data
{
struct nsd *nsd;
struct xfrd_tcp *conn;
};
/*
* Routine used by server_main.
* Handle a command received from the xfrdaemon processes.
*/
void parent_handle_xfrd_command(netio_type *netio,
netio_handler_type *handler, netio_event_types_type event_types);
/*
* Routine used by server_main.
* Handle a command received from the reload process.
*/
void parent_handle_reload_command(netio_type *netio,
netio_handler_type *handler, netio_event_types_type event_types);
/*
* Routine used by server_main.
* Handle a command received from the children processes.
* Send commands and forwarded xfrd packets when writable.
*/
void parent_handle_child_command(netio_type *netio,
netio_handler_type *handler, netio_event_types_type event_types);
/*
* Routine used by server_child.
* Handle a command received from the parent process.
*/
void child_handle_parent_command(int fd, short event, void* arg);
/*
* Routine used by xfrd
* Handle interprocess communication with parent process, read and write.
*/
void xfrd_handle_ipc(int fd, short event, void* arg);
/* check if all children have exited in an orderly fashion and set mode */
void parent_check_all_children_exited(struct nsd* nsd);
/** add stats to total */
void stats_add(struct nsdst* total, struct nsdst* s);
/** subtract stats from total */
void stats_subtract(struct nsdst* total, struct nsdst* s);
/** set event to listen to given mode, no timeout, must be added already */
void ipc_xfrd_set_listening(struct xfrd_state* xfrd, short mode);
#endif /* NSD_IPC_H */