Server Wait On Clients System - API Documentation  v1.3.2
Server Wait On Clients System.
messages.c File Reference

Message processing functions common to swoc programs. More...

#include <errno.h>
#include <ifaddrs.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <syslog.h>
#include <libswoccommon.h>
#include <mge-errno.h>
#include <mgebuffer.h>
#include <mgemessage.h>
Include dependency graph for messages.c:

Functions

static int get_reply_msg (int sockfd, struct mgemessage *recv_msg)
 
static int host_id (int sockfd, char *orig_outgoing_msg)
 
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 (char *outgoing_msg, size_t outgoing_msg_length, int *newsockfd)
 Send a message. More...
 
int exch_msg (char *outgoing_msg, size_t om_length, struct mgemessage *msg)
 Exchange messages. More...
 

Detailed Description

Message processing functions common to swoc programs.

Author
Copyright (C) 2017-2020 Mark Grant

Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0

Version
v1.1.12 ==== 21/03/2020

Function Documentation

◆ exch_msg()

int exch_msg ( 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.

Parameters
outgoing_msgThe message to send.
om_lengthThe length of the outgoing message.
msgThe received message.
Returns
0 on success, -1 on error.

◆ get_reply_msg()

static int get_reply_msg ( int  sockfd,
struct mgemessage *  recv_msg 
)
static

◆ host_id()

static int host_id ( int  sockfd,
char *  orig_outgoing_msg 
)
static

◆ parse_msg()

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.

Parameters
msgThe message to process.
msg_argsThe arguments to the message.
msg_srcThe source of the message.
msg_reqThe request contained in the message.

◆ send_outgoing_msg()

int send_outgoing_msg ( char *  outgoing_msg,
size_t  outgoing_msg_length,
int *  newsockfd 
)

Send a message.

On error mge_errno will be set.

Parameters
outgoing_msgThe message to send.
outgoing_msg_lengthThe length of the message.
newsockfdThe socket file descriptor.
Returns
0 on success, non-zero on error.