Server Wait On Clients System - Full Internal Documentation  v1.4.2
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  * *
36  ************************************************************************
37  */
38 
39 #ifndef LIBSWOCCOMMON_H
40 #define LIBSWOCCOMMON_H
41 
42 #include <netdb.h>
43 #include <netinet/in.h>
44 #include <sys/types.h>
45 
46 #include <mgemessage.h>
47 #include <portability.h>
48 
49 BEGIN_C_DECLS
50 
51 extern int pollint;
52 extern int ssh;
53 extern char server[];
54 extern int srvportno;
55 extern int sshportno;
56 extern char sshuser[];
57 
59 #define SOCK_BUF_SIZE 256
60 
62 #define SOCK_Q_LEN 10
63 
65 #define SSH_CHAN_POLL_TIMEOUT 10000
66 
69 
86 };
87 
90 
93 
94 int swcom_validate_config(void);
95 
96 int prep_recv_sock(int *sockfd, int *portno);
97 
98 int init_conn(int *sockfd, int *portno, char *srv);
99 
100 int est_connect(int *sfd, char *serv, int *portno, struct addrinfo *hints,
101  enum comms_mode *mode);
102 
103 int listen_sock(const int *sfd);
104 
105 int close_sock(const int *sockfd);
106 
107 void parse_msg(struct mgemessage *msg, enum msg_arguments *msg_args,
108  enum msg_source *msg_src, enum msg_request *msg_req);
109 
110 int send_outgoing_msg(char *outgoing_msg, size_t outgoing_msg_length,
111  int *newsockfd);
112 
113 int exch_msg(char *outgoing_msg, size_t om_length, struct mgemessage *msg);
114 
115 int open_ssh_tunnel(void);
116 
117 int close_ssh_tunnel(void);
118 
120 
122 
124 
126 
127 END_C_DECLS
128 
129 #endif /* ndef LIBSWOCCOMMON_H */
130 
int est_connect(int *sfd, char *serv, int *portno, struct addrinfo *hints, enum comms_mode *mode)
Establish send or receive connection.
Definition: tcp.c:127
Definition: libswoccommon.h:80
Definition: libswoccommon.h:81
msg_request
enum identifying the message request.
Definition: libswoccommon.h:71
int swcom_validate_config(void)
Parse and validate the config file.
Definition: validateconfig.c:68
Definition: libswoccommon.h:89
Definition: libswoccommon.h:68
Definition: libswoccommon.h:77
Definition: libswoccommon.h:89
Definition: libswoccommon.h:73
int init_conn(int *sockfd, int *portno, char *srv)
Initiate TCP stream socket connection.
Definition: tcp.c:97
char * libswoccommon_get_pkg_version(void)
Get the git-describe based package version.
Definition: version.c:41
Definition: libswoccommon.h:84
Definition: libswoccommon.h:85
msg_arguments
enum specifying error status of arguments.
Definition: libswoccommon.h:89
char sshuser[]
Server username for SSH.
Definition: validateconfig.c:61
int close_sock(const int *sockfd)
Close TCP socket.
Definition: tcp.c:239
Definition: libswoccommon.h:72
Definition: libswoccommon.h:76
Definition: libswoccommon.h:68
msg_source
enum identifying the source of a message.
Definition: libswoccommon.h:68
int exch_msg(char *outgoing_msg, size_t om_length, struct mgemessage *msg)
Exchange messages.
Definition: messages.c:166
Definition: libswoccommon.h:83
void libswoccommon_print_pkg_version(void)
Print the package version string to stdout.
Definition: version.c:58
Definition: libswoccommon.h:78
char * libswoccommon_get_src_version(void)
Get the source version.
Definition: version.c:50
Definition: libswoccommon.h:79
int listen_sock(const int *sfd)
Set TCP socket to listen.
Definition: tcp.c:210
char server[]
Server name.
Definition: validateconfig.c:58
int sshportno
Local port to use if using SSH.
Definition: validateconfig.c:60
int close_ssh_tunnel(void)
Disconnect and close an SSH session.
Definition: ssh.c:143
Definition: libswoccommon.h:92
Definition: libswoccommon.h:92
int prep_recv_sock(int *sockfd, int *portno)
Prepare TCP socket to receive connections.
Definition: tcp.c:58
int open_ssh_tunnel(void)
Establish SSH connection.
Definition: ssh.c:73
Definition: libswoccommon.h:82
Definition: libswoccommon.h:68
BEGIN_C_DECLS int pollint
Polling interval.
Definition: validateconfig.c:56
int srvportno
Server port number.
Definition: validateconfig.c:59
comms_mode
enum indentify send or receive mode.
Definition: libswoccommon.h:92
void libswoccommon_print_src_version(void)
Print the source version string to stdout.
Definition: version.c:67
int ssh
Use SSH false == 0, true == 1.
Definition: validateconfig.c:57
Definition: libswoccommon.h:74
int send_outgoing_msg(char *outgoing_msg, size_t outgoing_msg_length, int *newsockfd)
Send a message.
Definition: messages.c:139
Definition: libswoccommon.h:68
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:79
Definition: libswoccommon.h:75