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