Crinit -- Configurable Rootfs Init
|
Implementation of socket communication functions for the crinit-client library. More...
#include "sockcom.h"
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include "logio.h"
Functions | |
static int | crinitConnect (int *sockFd, const char *sockFile) |
static int | crinitSend (int sockFd, const crinitRtimCmd_t *cmd) |
static int | crinitRecv (int sockFd, crinitRtimCmd_t *res) |
static int | crinitWaitForRtr (int sockFd) |
int | crinitXfer (const char *sockFile, crinitRtimCmd_t *res, const crinitRtimCmd_t *cmd) |
Implementation of socket communication functions for the crinit-client library.
|
static |
Connect to Crinit and wait for a ready-to-receive message.
sockFd | Return pointer for the connected socket. |
sockFile | Path to the AF_UNIX socket file to connect to. |
|
static |
Receive a response from Crinit.
Receives a string using the same protocol as sendStr()/recvStr() in notiserv.c and then uses crinitParseRtimCmd() to generate an equivalent crinitRtimCmd_t.
First, a binary size_t with the string size is received, memory allocation made accordingly, and then the string itself in a second message/packet is received.
The following diagram illustrates the low-level protocol:
sockFd | The connected socket from which to receive. |
res | Return pointer for the response/result. |
|
static |
Send a command/request to Crinit.
Uses crinitRtimCmdToMsgStr() to generate a string and sends it using the same protocol as sendStr()/recvStr() in notiserv.c. First, a binary size_t with the string size is sent, then the string itself in a second message/packet.
The following diagram illustrates the low-level protocol:
sockFd | The connected socket over which to send. |
cmd | The command/request to send. |
|
static |
Wait for a ready-to-receive message from Crinit.
sockFd | The socket file descriptor connected to Crinit. |
int crinitXfer | ( | const char * | sockFile, |
crinitRtimCmd_t * | res, | ||
const crinitRtimCmd_t * | cmd | ||
) |
Perform a request/response transfer with Crinit
Will connect to Crinit and send a request/command, then receive the result/response. The server side equivalent is crinitConnThread() in notiserv.c.
The following image shows the high level communication sequence. For the lower level, refer to the internal functions crinitSend() and crinitRecv().
sockFile | Path to the AF_UNIX socket file to connect to. |
res | Return pointer for response/result. |
cmd | The command/request to send. |