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