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.h File Reference

Unified, transport-hiding channel factory (ADR-022). More...

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "rte/redundancy/dual/rte_dual_channel.h"
#include "rte/oal/netlink/rte_netlink.h"
#include "rte/utils/status/rte_status.h"
#include "rte/utils/types/rte_types.h"
#include "rte/redundancy/channel_link/rte_channel.h"
#include "rte/redundancy/voter/rte_voter.h"
Include dependency graph for rte_safechannel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rte_safechannel_endpoint_t
 One remote endpoint to open internally - replaces a caller- supplied rte_netlink_handle_t (ADR-022 section 2.2). More...
struct  rte_safechannel_dual_config_t
 Configuration specific to RTE_SAFECHANNEL_TYPE_DUAL_REDUNDANT. More...
struct  rte_safechannel_vital_config_t
 Configuration specific to RTE_SAFECHANNEL_TYPE_VITAL_VOTED. More...
struct  rte_safechannel_config_t
 Configuration for rte_safechannel_open(). More...
struct  rte_safechannel_t
 Caller-owned storage for one rte_safechannel_t instance. Every field is private - reach it only through the functions below. No dynamic allocation (REQ-SAFECHANNEL-002): sized to hold up to RTE_SAFECHANNEL_MAX_LINKS opened netlink links plus whichever of rte_dual_channel_t/rte_channel_t is in use. More...

Macros

#define RTE_SAFECHANNEL_MAX_LINKS   4U
 Maximum number of redundant endpoints one rte_safechannel_t may be configured with, for either type. Fixed, not dynamic.

Enumerations

enum  rte_safechannel_type_t { RTE_SAFECHANNEL_TYPE_DUAL_REDUNDANT = 0 , RTE_SAFECHANNEL_TYPE_VITAL_VOTED = 1 }
 Which underlying channel implementation a rte_safechannel_t wraps. More...
enum  rte_safechannel_link_status_t { RTE_SAFECHANNEL_LINK_DOWN = 0 , RTE_SAFECHANNEL_LINK_DEGRADED = 1 , RTE_SAFECHANNEL_LINK_FULL = 2 }
 Aggregate link status, uniform across both wrapped types. More...

Functions

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, transport-hiding channel factory (ADR-022).

The single entry point an application uses to open a communication channel: pick a rte_safechannel_type_t, describe the remote endpoint(s) as host/port/role, and get back one handle with uniform open/send/receive/close/status operations - regardless of whether it is backed by a redundant-link rte_dual_channel_t or a voting rte_voter_t (over N rte_channel_t links, ADR-025) underneath.

This header never requires the caller to include rte/netlink/rte_netlink.h or rte/ipc/rte_ipc.h, or to call rte_netlink_open()/rte_ipc_create() itself: rte_safechannel_open() opens every configured endpoint internally via the already-registered rte_netlink OSAdapter (ADR-005). Direct use of rte_netlink/rte_ipc is a osadapter-and-channel-layer-only concern from here on (ADR-022 section 2.3) - an application should not need those headers at all.

REQ-SAFECHANNEL-001: rte_safechannel_open() shall open every configured endpoint itself; the caller shall never need to call rte_netlink_open() or hold a rte_netlink_handle_t. REQ-SAFECHANNEL-002: no dynamic allocation; all storage is caller-owned and fixed-size. REQ-SAFECHANNEL-003: rte_safechannel_send()/_receive() behave identically to the caller regardless of config.type (uniform facade over rte_dual_channel_t / rte_channel_t).

Definition in file rte_safechannel.h.