DTNMA Reference Tools v2.1.0 - 27.ge2c7586
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
proxy_cli.c File Reference
#include "proxy_cli.h"
#include "msg.h"
#include "cace/ari/cbor.h"
#include "cace/ari/text.h"
#include "cace/ari/time_util.h"
#include "cace/util/logging.h"
#include "cace/util/defs.h"
#include <timespec.h>
#include <qcbor/qcbor.h>
#include <m-bstring.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <errno.h>
+ Include dependency graph for proxy_cli.c:

Functions

void cace_amp_proxy_cli_state_init (cace_amp_proxy_cli_state_t *state)
 Initialize an empty state.
 
void cace_amp_proxy_cli_state_deinit (cace_amp_proxy_cli_state_t *state)
 Deinitialize any resources.
 
static int cace_amp_proxy_cli_real_connect (cace_amp_proxy_cli_state_t *state, const struct timespec *timeout)
 Check socket state and reconnect if necessary.
 
static void cace_amp_proxy_cli_real_disconnect (cace_amp_proxy_cli_state_t *state)
 Disconnect without affecting the configured path.
 
int cace_amp_proxy_cli_state_connect (cace_amp_proxy_cli_state_t *state, const m_string_t sock_path, const struct timespec *timeout)
 Connect a unix domain SEQDATA socket to a specific filesystem path.
 
void cace_amp_proxy_cli_state_disconnect (cace_amp_proxy_cli_state_t *state)
 Disconnect any current socket and remove it if necessary.
 
int cace_amp_proxy_cli_state_getfd (cace_amp_proxy_cli_state_t *state)
 
int cace_amp_proxy_cli_send (const cace_ari_list_t data, const cace_amm_msg_if_metadata_t *meta, const struct timespec *timeout, void *ctx)
 Provider of cace_amm_msg_if_t::send interface for BP-proxy socket transport.
 
int cace_amp_proxy_cli_recv (cace_ari_list_t data, cace_amm_msg_if_metadata_t *meta, cace_daemon_run_t *running, void *ctx)
 Provider of cace_amm_msg_if_t::recv interface for BP-proxy socket transport.
 

Variables

static const struct timespec default_timeout = { .tv_sec = 1 }
 Limited internal timeout to avoid indefinite mutex blocking.
 

Function Documentation

◆ cace_amp_proxy_cli_real_connect()

static int cace_amp_proxy_cli_real_connect ( cace_amp_proxy_cli_state_t state,
const struct timespec *  timeout 
)
static

Check socket state and reconnect if necessary.

Precondition
This occurs while holding the mutex lock.
Parameters
stateThe state to check and connect for.
[in]timeoutThe total time to wait.
Returns
The socket FD to use outside of the mutex lock.

References CACE_LOG_ERR, CACE_LOG_INFO, CACE_LOG_WARNING, default_timeout, cace_amp_proxy_cli_state_t::path, and cace_amp_proxy_cli_state_t::sock_fd.

Referenced by cace_amp_proxy_cli_recv(), cace_amp_proxy_cli_send(), and cace_amp_proxy_cli_state_connect().

◆ cace_amp_proxy_cli_real_disconnect()

static void cace_amp_proxy_cli_real_disconnect ( cace_amp_proxy_cli_state_t state)
static

Disconnect without affecting the configured path.

Precondition
This occurs while holding the mutex lock.

References CACE_LOG_INFO, cace_amp_proxy_cli_state_t::path, and cace_amp_proxy_cli_state_t::sock_fd.

Referenced by cace_amp_proxy_cli_recv(), cace_amp_proxy_cli_send(), and cace_amp_proxy_cli_state_disconnect().

◆ cace_amp_proxy_cli_recv()

◆ cace_amp_proxy_cli_send()

◆ cace_amp_proxy_cli_state_connect()

int cace_amp_proxy_cli_state_connect ( cace_amp_proxy_cli_state_t state,
const m_string_t  sock_path,
const struct timespec *  timeout 
)

Connect a unix domain SEQDATA socket to a specific filesystem path.

Parameters
[in,out]stateThe state to bind.
[in]sock_pathThe file path to bind to.
[in]timeoutAn initial connection timeout, or null to default to a short timeout.
Returns
Zero if successful.

References cace_amp_proxy_cli_real_connect(), CHKERR1, cace_amp_proxy_cli_state_t::path, and cace_amp_proxy_cli_state_t::sock_mutex.

Referenced by main().

◆ cace_amp_proxy_cli_state_deinit()

void cace_amp_proxy_cli_state_deinit ( cace_amp_proxy_cli_state_t state)

Deinitialize any resources.

References CHKVOID, cace_amp_proxy_cli_state_t::path, and cace_amp_proxy_cli_state_t::sock_mutex.

Referenced by main().

◆ cace_amp_proxy_cli_state_disconnect()

void cace_amp_proxy_cli_state_disconnect ( cace_amp_proxy_cli_state_t state)

Disconnect any current socket and remove it if necessary.

Parameters
[in,out]stateThe state to bind.

References cace_amp_proxy_cli_real_disconnect(), CHKVOID, cace_amp_proxy_cli_state_t::path, and cace_amp_proxy_cli_state_t::sock_mutex.

◆ cace_amp_proxy_cli_state_getfd()

int cace_amp_proxy_cli_state_getfd ( cace_amp_proxy_cli_state_t state)

◆ cace_amp_proxy_cli_state_init()

void cace_amp_proxy_cli_state_init ( cace_amp_proxy_cli_state_t state)

Variable Documentation

◆ default_timeout

const struct timespec default_timeout = { .tv_sec = 1 }
static

Limited internal timeout to avoid indefinite mutex blocking.

Referenced by cace_amp_proxy_cli_real_connect().