Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_safechannel.c File Reference

Unified channel factory: opens netlink links internally, wraps rte_dual_channel_t or a rte_voter_t over N rte_channel_t links (ADR-025) - see rte_safechannel.h and ADR-022. More...

Include dependency graph for rte_safechannel.c:

Go to the source code of this file.

Functions

static void safechannel_close_links (rte_safechannel_t *channel, uint32_t count)
 Closes every already-opened link handles[0..count-1] and resets the caller's bookkeeping - used both for the normal close path and to unwind a partial open failure.
static rte_status_t safechannel_open_one_endpoint (rte_netlink_storage_t *storage, const rte_safechannel_endpoint_t *endpoint, size_t message_size, rte_duration_ms_t connect_timeout_ms, rte_netlink_handle_t *out_handle)
 Opens one endpoint, retrying rte_netlink_open() with a short fixed delay until connect_timeout_ms elapses - the same retry shape every current hand-rolled CONNECT-role caller in safeAPIRBC2oo2 already implements itself (site.c, etc.).
static rte_status_t safechannel_open_dual (rte_safechannel_t *channel, const rte_safechannel_dual_config_t *cfg)
static rte_status_t safechannel_vital_backend_send (void *channel_handle, const void *data, size_t data_size)
 rte_channel_config_t::send bridge: casts the opaque channel handle back to the rte_netlink_handle_t it actually is (this module is the only place that made that handle) and forwards to rte_netlink_send(). One of these is wired into each of the voter's N individual rte_channel_t links (ADR-025).
static rte_status_t safechannel_vital_backend_recv (void *channel_handle, void *data, size_t data_size, uint32_t timeout_ms)
 rte_channel_config_t::recv bridge - see safechannel_vital_backend_send().
static rte_status_t safechannel_open_vital (rte_safechannel_t *channel, const rte_safechannel_vital_config_t *cfg)
rte_status_t rte_safechannel_open (rte_safechannel_t *channel, const rte_safechannel_config_t *config)
 Opens a channel: opens every configured endpoint via the registered rte_netlink OSAdapter, then initializes the wrapped rte_dual_channel_t or rte_channel_t on top of the resulting links (ADR-022 section 2.2). Retries each endpoint's rte_netlink_open() internally up to config's own connect_timeout_ms, matching the retry pattern every current hand-rolled caller already implemented itself.
rte_status_t rte_safechannel_send (rte_safechannel_t *channel, const uint8_t *payload, size_t payload_size)
 Sends payload on the underlying channel - broadcast-with-ACK- wait for DUAL_REDUNDANT (rte_dual_channel_send()), atomic all-or-nothing broadcast to every registered channel for VITAL_VOTED (rte_voter_send()).
rte_status_t rte_safechannel_receive (rte_safechannel_t *channel, uint8_t *out_payload, size_t max_size, rte_duration_ms_t timeout_ms, size_t *out_size)
 Returns the most recent inbound payload, actively polling the underlying channel if nothing was already staged.
rte_safechannel_link_status_t rte_safechannel_get_status (const rte_safechannel_t *channel)
 Aggregate status across every configured endpoint - DOWN before the first send/receive.
rte_status_t rte_safechannel_close (rte_safechannel_t *channel)
 Closes every endpoint this instance opened and releases the wrapped channel. Safe to call on an already-closed/never-opened instance (no-op).

Detailed Description

Unified channel factory: opens netlink links internally, wraps rte_dual_channel_t or a rte_voter_t over N rte_channel_t links (ADR-025) - see rte_safechannel.h and ADR-022.

Definition in file rte_safechannel.c.

Function Documentation

◆ safechannel_close_links()

void safechannel_close_links ( rte_safechannel_t * channel,
uint32_t count )
static

Closes every already-opened link handles[0..count-1] and resets the caller's bookkeeping - used both for the normal close path and to unwind a partial open failure.

Definition at line 16 of file rte_safechannel.c.

◆ safechannel_open_one_endpoint()

rte_status_t safechannel_open_one_endpoint ( rte_netlink_storage_t * storage,
const rte_safechannel_endpoint_t * endpoint,
size_t message_size,
rte_duration_ms_t connect_timeout_ms,
rte_netlink_handle_t * out_handle )
static

Opens one endpoint, retrying rte_netlink_open() with a short fixed delay until connect_timeout_ms elapses - the same retry shape every current hand-rolled CONNECT-role caller in safeAPIRBC2oo2 already implements itself (site.c, etc.).

Definition at line 34 of file rte_safechannel.c.

◆ safechannel_open_dual()

rte_status_t safechannel_open_dual ( rte_safechannel_t * channel,
const rte_safechannel_dual_config_t * cfg )
static

Definition at line 59 of file rte_safechannel.c.

◆ safechannel_vital_backend_send()

rte_status_t safechannel_vital_backend_send ( void * channel_handle,
const void * data,
size_t data_size )
static

rte_channel_config_t::send bridge: casts the opaque channel handle back to the rte_netlink_handle_t it actually is (this module is the only place that made that handle) and forwards to rte_netlink_send(). One of these is wired into each of the voter's N individual rte_channel_t links (ADR-025).

Definition at line 117 of file rte_safechannel.c.

◆ safechannel_vital_backend_recv()

rte_status_t safechannel_vital_backend_recv ( void * channel_handle,
void * data,
size_t data_size,
uint32_t timeout_ms )
static

◆ safechannel_open_vital()

rte_status_t safechannel_open_vital ( rte_safechannel_t * channel,
const rte_safechannel_vital_config_t * cfg )
static

Definition at line 136 of file rte_safechannel.c.