Server Wait On Clients System - API Documentation v1.7.2
Server Wait On Clients System.
|
Internal header file for Server Wait on Client common library. More...
#include <netdb.h>
#include <sys/types.h>
#include <libmgec/mge-message.h>
#include <libmgec/mge-portability.h>
Go to the source code of this file.
Macros | |
#define | SOCK_BUF_SIZE 256 |
Socket buffer size. More... | |
#define | SOCK_Q_LEN 10 |
Queue length for listen backlog. More... | |
#define | SSH_CHAN_POLL_TIMEOUT 10000 |
Timeout for SSH channel read (in ms). More... | |
Enumerations | |
enum | msg_source { swocclient , swocserver , swocserverd , src_err } |
enum identifying the source of a message. More... | |
enum | msg_request { swocallow , swocblock , swocblocklist , swocblockstatus , swocdisallow , swocend , swocid , swoclock , swocrelease , swocreload , swocreset , swocstatus , swocunblock , req_err } |
enum identifying the message request. More... | |
enum | msg_arguments { args_ok , args_err } |
enum specifying error status of arguments. More... | |
enum | comms_mode { recv_mode , send_mode } |
enum indentify send or receive mode. More... | |
Functions | |
int | swcom_validate_config (void) |
Parse and validate the config file. More... | |
int | prep_recv_sock (int *sockfd, int *portno) |
Prepare TCP socket to receive connections. More... | |
int | init_conn (int *sockfd, int *portno, const char *srv) |
Initiate TCP stream socket connection. More... | |
int | est_connect (int *sfd, const char *serv, int *portno, struct addrinfo *hints, enum comms_mode *mode) |
Establish send or receive connection. More... | |
int | listen_sock (const int *sfd) |
Set TCP socket to listen. More... | |
int | close_sock (const int *sockfd) |
Close TCP socket. More... | |
void | parse_msg (struct mgemessage *msg, enum msg_arguments *msg_args, enum msg_source *msg_src, enum msg_request *msg_req) |
Parse a message. More... | |
int | send_outgoing_msg (const char *outgoing_msg, size_t outgoing_msg_length, int *newsockfd) |
Send a message. More... | |
int | exch_msg (const char *outgoing_msg, size_t om_length, struct mgemessage *msg) |
Exchange messages. More... | |
int | open_ssh_tunnel (void) |
Establish SSH connection. More... | |
int | close_ssh_tunnel (void) |
Disconnect and close an SSH session. More... | |
__attribute__ ((const)) const char *libswoccommon_get_pkg_version(void) | |
Get the git-describe based package version. More... | |
void | libswoccommon_print_pkg_version (void) |
Print the package version string to stdout. More... | |
void | libswoccommon_print_src_version (void) |
Print the source version string to stdout. More... | |
Variables | |
BEGIN_C_DECLS int | pollint |
Polling interval. More... | |
int | ssh |
Use SSH false == 0, true == 1. More... | |
char | server [] |
Server name. More... | |
int | srvportno |
Server port number. More... | |
int | sshportno |
Local port to use if using SSH. More... | |
char | sshuser [] |
Server username for SSH. More... | |
Internal header file for Server Wait on Client common library.
Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0-only
#define SOCK_BUF_SIZE 256 |
Socket buffer size.
#define SOCK_Q_LEN 10 |
Queue length for listen backlog.
#define SSH_CHAN_POLL_TIMEOUT 10000 |
Timeout for SSH channel read (in ms).
enum comms_mode |
enum msg_arguments |
enum msg_request |
enum msg_source |
__attribute__ | ( | (const) | ) | const |
Get the git-describe based package version.
Get the source version.
int close_sock | ( | const int * | sockfd | ) |
Close TCP socket.
Equivalent to close() with error handling. On error mge_errno is set.
sockfd | The socket file descriptor. |
int close_ssh_tunnel | ( | void | ) |
Disconnect and close an SSH session.
Join data relay thread, free channel and disconnect session. On error mge_errno will be set.
int est_connect | ( | int * | sfd, |
const char * | serv, | ||
int * | portno, | ||
struct addrinfo * | hints, | ||
enum comms_mode * | mode | ||
) |
Establish send or receive connection.
Bind or connect depending on mode - listen or send. On error mge_errno is set.
sfd | The socket file descriptor. |
serv | The server name. |
portno | The port number. |
hints | The hints for getaddrinfo(). |
mode | send_mode or recv_mode. |
int exch_msg | ( | const char * | outgoing_msg, |
size_t | om_length, | ||
struct mgemessage * | msg | ||
) |
Exchange messages.
Send and receive 1 requested message after sending ID message. On error mge_errno will be set.
outgoing_msg | The message to send. |
om_length | The length of the outgoing message. |
msg | The received message. |
int init_conn | ( | int * | sockfd, |
int * | portno, | ||
const char * | srv | ||
) |
Initiate TCP stream socket connection.
On error mge_errno is set.
sockfd | The socket file descriptor. |
portno | The port number. |
srv | The server name. |
void libswoccommon_print_pkg_version | ( | void | ) |
Print the package version string to stdout.
void libswoccommon_print_src_version | ( | void | ) |
Print the source version string to stdout.
int listen_sock | ( | const int * | sfd | ) |
Set TCP socket to listen.
Equivalent to listen() with error handling. A race is possible with other swoc invocations to listen on that socket, so if it is in use do a few retries. On error mge_errno is set.
sfd | The socket file descriptor. |
int open_ssh_tunnel | ( | void | ) |
Establish SSH connection.
Create session, connect to server, create a tunnel and spawn a thread to relay data through the tunnel. On error mge_errno will be set.
void parse_msg | ( | struct mgemessage * | msg, |
enum msg_arguments * | msg_args, | ||
enum msg_source * | msg_src, | ||
enum msg_request * | msg_req | ||
) |
Parse a message.
Identify message source and request.
msg | The message to process. |
msg_args | The arguments to the message. |
msg_src | The source of the message. |
msg_req | The request contained in the message. |
int prep_recv_sock | ( | int * | sockfd, |
int * | portno | ||
) |
Prepare TCP socket to receive connections.
On error mge_errno is set.
sockfd | The socket file descriptor. |
portno | The port number. |
int send_outgoing_msg | ( | const char * | outgoing_msg, |
size_t | outgoing_msg_length, | ||
int * | newsockfd | ||
) |
Send a message.
On error mge_errno will be set.
outgoing_msg | The message to send. |
outgoing_msg_length | The length of the message. |
newsockfd | The socket file descriptor. |
int swcom_validate_config | ( | void | ) |
Parse and validate the config file.
On error mge_errno is set.
|
extern |
Polling interval.
|
extern |
Server name.
|
extern |
Server port number.
|
extern |
Use SSH false == 0, true == 1.
|
extern |
Local port to use if using SSH.
|
extern |
Server username for SSH.