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 "netio.h" 14 struct buffer; 15 struct nsd; 16 struct nsd_child; 17 struct xfrd_tcp; 18 struct xfrd_state; 19 struct nsdst; 20 struct event; 21 22 /* 23 * Data for the server_main IPC handler 24 * Used by parent side to listen to children, and write to children. 25 */ 26 struct main_ipc_handler_data 27 { 28 struct nsd *nsd; 29 struct nsd_child *child; 30 }; 31 32 /* 33 * Data for ipc handler, nsd and a conn for reading ipc msgs. 34 * Used by children to listen to parent. 35 * Used by parent to listen to xfrd. 36 */ 37 struct ipc_handler_conn_data 38 { 39 struct nsd *nsd; 40 struct xfrd_tcp *conn; 41 }; 42 43 /* 44 * Routine used by server_main. 45 * Handle a command received from the xfrdaemon processes. 46 */ 47 void parent_handle_xfrd_command(netio_type *netio, 48 netio_handler_type *handler, netio_event_types_type event_types); 49 50 /* 51 * Routine used by server_main. 52 * Handle a command received from the reload process. 53 */ 54 void parent_handle_reload_command(netio_type *netio, 55 netio_handler_type *handler, netio_event_types_type event_types); 56 57 /* 58 * Routine used by server_main. 59 * Handle a command received from the children processes. 60 * Send commands and forwarded xfrd packets when writable. 61 */ 62 void parent_handle_child_command(netio_type *netio, 63 netio_handler_type *handler, netio_event_types_type event_types); 64 65 /* 66 * Routine used by server_child. 67 * Handle a command received from the parent process. 68 */ 69 void child_handle_parent_command(int fd, short event, void* arg); 70 71 /* 72 * Routine used by xfrd 73 * Handle interprocess communication with parent process, read and write. 74 */ 75 void xfrd_handle_ipc(int fd, short event, void* arg); 76 77 /* receive incoming notifies received by and from the serve processes */ 78 void xfrd_handle_notify(int fd, short event, void* arg); 79 80 /* check if all children have exited in an orderly fashion and set mode */ 81 void parent_check_all_children_exited(struct nsd* nsd); 82 83 /** add stats to total */ 84 void stats_add(struct nsdst* total, struct nsdst* s); 85 /** subtract stats from total */ 86 void stats_subtract(struct nsdst* total, struct nsdst* s); 87 88 /** set event to listen to given mode, no timeout, must be added already */ 89 void ipc_xfrd_set_listening(struct xfrd_state* xfrd, short mode); 90 91 #endif /* NSD_IPC_H */ 92