Server Wait On Clients System - Full Internal Documentation  v1.6.4
Server Wait On Clients System.
internal.h
Go to the documentation of this file.
1 
14 /* **********************************************************************
15  * *
16  * Changelog *
17  * *
18  * Date Author Version Description *
19  * *
20  * 19/11/2016 MG 1.0.0 First release. *
21  * 17/12/2016 MG 1.0.1 Re-distribute over libswoccommon and *
22  * libswocserver. *
23  * 13/02/2017 MG 1.0.2 Implement config file reload *
24  * functionality in daemon. *
25  * 22/04/2017 MG 1.0.3 Change to use new bstree struct. *
26  * 04/06/2017 MG 1.0.4 Use more meaningful name for client *
27  * lock bstree. *
28  * 07/06/2017 MG 1.0.5 Implement epoll controlled use of *
29  * multiple ports. *
30  * 14/09/2017 MG 1.0.6 Change 'force unlock' to just 'unlock'. *
31  * 29/10/2017 MG 1.0.7 Remove references to TLS. Security now *
32  * implemented from client side via SSH *
33  * tunnelling. *
34  * 17/11/2017 MG 1.0.8 Add Doxygen comments. *
35  * Add SPDX license tag. *
36  * 10/05/2018 MG 1.0.9 Add support for blocked clients list. *
37  * Add server client block and unblock. *
38  * Add server block and unblock. *
39  * 18/05/2018 MG 1.0.10 Add client show server block status. *
40  * 22/05/2018 MG 1.0.11 Change from swocserverd.h to internal.h *
41  * 05/08/2018 MG 1.0.12 Remove spurious include of sys/types.h *
42  * 25/08/2018 MG 1.0.13 Add prototype for swsd_reload_config. *
43  * 18/05/2019 MG 1.0.14 Merge sub-projects into one. *
44  * 08/11/2019 MG 1.0.15 Use standard GNU ifdeffery around use *
45  * of AC_HEADER_STDBOOL. *
46  * 14/03/2020 MG 1.0.16 Add support for id_req. *
47  * 10/10/2021 MG 1.0.17 Use newly internalised common header. *
48  * 08/12/2021 MG 1.0.18 Tighten SPDX tag. *
49  * 17/09/2022 MG 1.0.19 Rename portability.h *
50  * Rename mgemessage.h *
51  * Rename bstree.h *
52  * Use pkginclude location. *
53  * *
54  ************************************************************************
55  */
56 
57 #ifndef SWOCSERVERD_INTERNAL_H
58 #define SWOCSERVERD_INTERNAL_H
59 
60 #include <limits.h>
61 
62 /* Standard GNU AC_HEADER_STDBOOL ifdeffery. */
63 #ifdef HAVE_STDBOOL_H
64  #include <stdbool.h>
65 #else
66  #ifndef HAVE__BOOL
67  #ifdef __cplusplus /* clang-format off */
68  typedef bool _Bool; /* clang-format on */
69  #else
70  #define _Bool signed char
71  #endif
72  #endif
73  #define bool _Bool
74  #define false 0
75  #define true 1
76  #define __bool_true_false_are_defined 1
77 #endif
78 
79 #include <libmgec/mge-bstree.h>
80 #include <libmgec/mge-message.h>
81 #include <libmgec/mge-portability.h>
82 #include <swoc/libswoccommon.h>
83 
84 BEGIN_C_DECLS
85 
86 #define MAX_LISTEN_PORTS 10
87 #define MAX_EPOLL_EVENTS 64
92 struct comm_spec {
93  int portno;
94  int socketfd;
95 };
96 
97 extern int swsd_err;
98 extern char client[_POSIX_HOST_NAME_MAX];
99 extern int debug;
100 extern int end;
101 extern int cursockfd;
102 extern struct comm_spec *port_spec;
103 extern bool srv_blocked;
104 extern struct bstree *cli_locks, *cli_blocked, *port_sock;
105 
106 int swsd_validate_config(void);
107 
108 int prepare_sockets(void);
109 
110 int process_comms(void);
111 
112 int srv_end_req(struct mgemessage *msg, enum msg_arguments *msg_args);
113 
114 int srv_status_req(struct mgemessage *msg, enum msg_arguments *msg_args);
115 
116 int srv_cli_blocklist_req(struct mgemessage *msg, enum msg_arguments *msg_args);
117 
118 int srv_cli_block_req(struct mgemessage *msg, enum msg_arguments *msg_args);
119 
120 int srv_cli_unblock_req(struct mgemessage *msg, enum msg_arguments *msg_args);
121 
122 int srv_block_req(struct mgemessage *msg, enum msg_arguments *msg_args);
123 
124 int srv_unblock_req(struct mgemessage *msg, enum msg_arguments *msg_args);
125 
126 int srv_block_status_req(struct mgemessage *msg, enum msg_arguments *msg_args);
127 
128 int cli_block_req(struct mgemessage *msg, enum msg_arguments *msg_args);
129 
130 int cli_unblock_req(struct mgemessage *msg, enum msg_arguments *msg_args);
131 
132 int cli_srv_block_status_req(struct mgemessage *msg,
133  enum msg_arguments *msg_args);
134 
135 int srv_cli_rel_req(struct mgemessage *msg, enum msg_arguments *msg_args);
136 
137 int cli_lock_req(struct mgemessage *msg, enum msg_arguments *msg_args);
138 
139 int cli_rel_req(struct mgemessage *msg, enum msg_arguments *msg_args);
140 
141 int srv_reload_req(struct mgemessage *msg, enum msg_arguments *msg_args);
142 
143 int swsd_reload_config(void);
144 
145 int cli_status_req(struct mgemessage *msg, enum msg_arguments *msg_args);
146 
147 int cli_reset_req(struct mgemessage *msg, enum msg_arguments *msg_args);
148 
149 void id_req(struct mgemessage *msg, enum msg_arguments *msg_args);
150 
151 char *swocserverd_get_pkg_version(void);
152 
153 char *swocserverd_get_src_version(void);
154 
156 
158 
159 END_C_DECLS
160 
161 #endif /* ndef SWOCSERVERD_INTERNAL_H */
Internal header file for Server Wait on Client common library.
msg_arguments
enum specifying error status of arguments.
Definition: libswoccommon.h:94
int srv_reload_req(struct mgemessage *msg, enum msg_arguments *msg_args)
swocserver request to reload config file.
Definition: request.c:158
int cli_block_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Client block further locks request.
Definition: request.c:557
int cli_reset_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Reset request from client.
Definition: request.c:819
int cli_srv_block_status_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Client requests status of server level blocking.
Definition: request.c:651
int srv_cli_rel_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server requests client lock release.
Definition: request.c:332
int srv_cli_unblock_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server requests client to be unblocked.
Definition: request.c:426
void id_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server or client submits id.
Definition: request.c:866
struct bstree * cli_blocked
Definition: internal.h:104
int swsd_validate_config(void)
Parse and validate the config file.
Definition: validateconfig.c:64
int srv_cli_blocklist_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server client block list request.
Definition: request.c:280
bool srv_blocked
Server is blocked?
Definition: main.c:117
char client[_POSIX_HOST_NAME_MAX]
Client name.
Definition: main.c:112
int cli_status_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Status request from client.
Definition: request.c:762
int srv_status_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server status request.
Definition: request.c:213
struct bstree * cli_locks
Clients and locks.
Definition: main.c:118
struct comm_spec * port_spec
Port / socket config mappings.
Definition: main.c:116
int srv_block_status_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server requests status of server level blocking.
Definition: request.c:527
int cursockfd
Socket file descriptor in use.
Definition: main.c:115
int swsd_reload_config(void)
Reload the config file.
Definition: request.c:186
struct bstree * port_sock
Definition: internal.h:104
int srv_block_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server requests server level blocking.
Definition: request.c:472
int srv_cli_block_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server requests client to be blocked.
Definition: request.c:378
char * swocserverd_get_src_version(void)
Get the source version.
Definition: version.c:50
int cli_unblock_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Client unblock further locks request.
Definition: request.c:606
int cli_lock_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Client lock request.
Definition: request.c:664
int srv_unblock_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Server requests removal of server level blocking.
Definition: request.c:499
int end
End pending.
Definition: main.c:114
int debug
Debug - 0 false, 1 true.
Definition: main.c:113
void swocserverd_print_src_version(void)
Print the source version string to stdout.
Definition: version.c:67
int cli_rel_req(struct mgemessage *msg, enum msg_arguments *msg_args)
Release request from client.
Definition: request.c:718
int srv_end_req(struct mgemessage *msg, enum msg_arguments *msg_args)
swocserver requesting the daemon to terminate.
Definition: request.c:123
void swocserverd_print_pkg_version(void)
Print the package version string to stdout.
Definition: version.c:58
int swsd_err
swoc daemon error number.
Definition: main.c:111
#define _Bool
Definition: internal.h:70
int process_comms(void)
Wait and then process communications.
Definition: comms.c:223
int prepare_sockets(void)
Prepare all sockets.
Definition: comms.c:125
char * swocserverd_get_pkg_version(void)
Get the git-describe based package version.
Definition: version.c:41
Map sockets to ports.
Definition: internal.h:92
int socketfd
Socket file descriptor.
Definition: internal.h:94
int portno
Port number.
Definition: internal.h:93