Server Wait On Clients System - Full Internal Documentation v1.7.0
Server Wait On Clients System.
libswoccommon.h
Go to the documentation of this file.
1
14/* **********************************************************************
15 * *
16 * Changelog *
17 * *
18 * Date Author Version Description *
19 * *
20 * 24/10/2017 MG 1.0.1 This ChangeLog introduced. *
21 * 29/10/2017 MG 1.0.2 Move port / socket mapping struct to *
22 * swocserverd.h. *
23 * 10/11/2017 MG 1.0.3 Add Doxygen comments. *
24 * Add SPDX license tag. *
25 * 07/03/2018 MG 1.0.4 Remove redundant global variable portno *
26 * 01/05/2018 MG 1.0.5 Add support for blocked clients list. *
27 * 10/05/2018 MG 1.0.6 Add support for server list of blocked *
28 * clients. *
29 * Improve function name consistency, *
30 * unlock -> release. *
31 * Add support for server blocking. *
32 * 15/08/2018 MG 1.0.7 Change parameter name to prevent shadow.*
33 * 18/05/2019 MG 1.0.8 Merge sub-projects into one. *
34 * 15/03/2020 MG 1.0.9 Add swocid request type. *
35 * 10/10/2021 MG 1.1.0 Make file internal, tightening API. *
36 * 11/10/2021 MG 1.1.1 Move to internal directory. *
37 * 08/12/2021 MG 1.1.2 Tighten SPDX tag. *
38 * 17/09/2022 MG 1.1.3 Rename portability.h *
39 * Rename mgemessage.h *
40 * Use pkginclude location. *
41 * *
42 ************************************************************************
43 */
44
45#ifndef LIBSWOCCOMMON_H
46#define LIBSWOCCOMMON_H
47
48#include <netdb.h>
49#include <sys/types.h>
50
51#include <libmgec/mge-message.h>
52#include <libmgec/mge-portability.h>
53
54BEGIN_C_DECLS
55
56extern int pollint;
57extern int ssh;
58extern char server[];
59extern int srvportno;
60extern int sshportno;
61extern char sshuser[];
62
64#define SOCK_BUF_SIZE 256
65
67#define SOCK_Q_LEN 10
68
70#define SSH_CHAN_POLL_TIMEOUT 10000
71
74
91};
92
95
98
99int swcom_validate_config(void);
100
101int prep_recv_sock(int *sockfd, int *portno);
102
103int init_conn(int *sockfd, int *portno, char *srv);
104
105int est_connect(int *sfd, char *serv, int *portno, struct addrinfo *hints,
106 enum comms_mode *mode);
107
108int listen_sock(const int *sfd);
109
110int close_sock(const int *sockfd);
111
112void parse_msg(struct mgemessage *msg, enum msg_arguments *msg_args,
113 enum msg_source *msg_src, enum msg_request *msg_req);
114
115int send_outgoing_msg(char *outgoing_msg, size_t outgoing_msg_length,
116 int *newsockfd);
117
118int exch_msg(char *outgoing_msg, size_t om_length, struct mgemessage *msg);
119
120int open_ssh_tunnel(void);
121
122int close_ssh_tunnel(void);
123
125
127
129
131
132END_C_DECLS
133
134#endif /* ndef LIBSWOCCOMMON_H */
msg_arguments
enum specifying error status of arguments.
Definition: libswoccommon.h:94
@ args_ok
Definition: libswoccommon.h:94
@ args_err
Definition: libswoccommon.h:94
int ssh
Use SSH false == 0, true == 1.
Definition: validateconfig.c:61
BEGIN_C_DECLS int pollint
Polling interval.
Definition: validateconfig.c:60
comms_mode
enum indentify send or receive mode.
Definition: libswoccommon.h:97
@ recv_mode
Definition: libswoccommon.h:97
@ send_mode
Definition: libswoccommon.h:97
msg_request
enum identifying the message request.
Definition: libswoccommon.h:76
@ swocstatus
Definition: libswoccommon.h:88
@ swocallow
Definition: libswoccommon.h:77
@ swocid
Definition: libswoccommon.h:83
@ swocblock
Definition: libswoccommon.h:78
@ swoclock
Definition: libswoccommon.h:84
@ swocreload
Definition: libswoccommon.h:86
@ swocrelease
Definition: libswoccommon.h:85
@ swocblocklist
Definition: libswoccommon.h:79
@ req_err
Definition: libswoccommon.h:90
@ swocunblock
Definition: libswoccommon.h:89
@ swocdisallow
Definition: libswoccommon.h:81
@ swocreset
Definition: libswoccommon.h:87
@ swocend
Definition: libswoccommon.h:82
@ swocblockstatus
Definition: libswoccommon.h:80
void parse_msg(struct mgemessage *msg, enum msg_arguments *msg_args, enum msg_source *msg_src, enum msg_request *msg_req)
Parse a message.
Definition: messages.c:101
void libswoccommon_print_src_version(void)
Print the source version string to stdout.
Definition: version.c:71
int srvportno
Server port number.
Definition: validateconfig.c:63
int sshportno
Local port to use if using SSH.
Definition: validateconfig.c:64
char * libswoccommon_get_pkg_version(void)
Get the git-describe based package version.
Definition: version.c:45
int prep_recv_sock(int *sockfd, int *portno)
Prepare TCP socket to receive connections.
Definition: tcp.c:65
int close_sock(const int *sockfd)
Close TCP socket.
Definition: tcp.c:242
int exch_msg(char *outgoing_msg, size_t om_length, struct mgemessage *msg)
Exchange messages.
Definition: messages.c:188
int open_ssh_tunnel(void)
Establish SSH connection.
Definition: ssh.c:85
char server[]
Server name.
Definition: validateconfig.c:62
int init_conn(int *sockfd, int *portno, char *srv)
Initiate TCP stream socket connection.
Definition: tcp.c:103
char sshuser[]
Server username for SSH.
Definition: validateconfig.c:65
int swcom_validate_config(void)
Parse and validate the config file.
Definition: validateconfig.c:72
msg_source
enum identifying the source of a message.
Definition: libswoccommon.h:73
@ src_err
Definition: libswoccommon.h:73
@ swocserver
Definition: libswoccommon.h:73
@ swocserverd
Definition: libswoccommon.h:73
@ swocclient
Definition: libswoccommon.h:73
int est_connect(int *sfd, char *serv, int *portno, struct addrinfo *hints, enum comms_mode *mode)
Establish send or receive connection.
Definition: tcp.c:131
char * libswoccommon_get_src_version(void)
Get the source version.
Definition: version.c:54
int listen_sock(const int *sfd)
Set TCP socket to listen.
Definition: tcp.c:214
int send_outgoing_msg(char *outgoing_msg, size_t outgoing_msg_length, int *newsockfd)
Send a message.
Definition: messages.c:161
int close_ssh_tunnel(void)
Disconnect and close an SSH session.
Definition: ssh.c:159
void libswoccommon_print_pkg_version(void)
Print the package version string to stdout.
Definition: version.c:62