37#ifndef SAPI_SAFECHANNEL_H
38#define SAPI_SAFECHANNEL_H
57#define SAPI_SAFECHANNEL_MAX_LINKS 4U
60typedef enum sapi_safechannel_type_e
71typedef enum sapi_safechannel_link_status_e
82typedef struct sapi_safechannel_endpoint_s
94typedef struct sapi_safechannel_dual_config_s
115typedef struct sapi_safechannel_vital_config_s
142typedef struct sapi_safechannel_config_s
160typedef struct sapi_safechannel_s
void(*) sapi_dual_channel_status_callback_t(sapi_dual_channel_status_t new_status, sapi_dual_channel_status_t old_status, void *user_ctx)
Optional callback invoked whenever sapi_dual_channel_get_status()'s value changes (ADR-020 section 2'...
struct sapi_netlink_impl_s * sapi_netlink_handle_t
Opaque handle to an established link, returned by sapi_netlink_open().
sapi_netlink_role_t
Which side of the connection this link instance plays.
sapi_safechannel_type_t
Which underlying channel implementation a sapi_safechannel_t wraps.
#define SAPI_SAFECHANNEL_MAX_LINKS
Maximum number of redundant endpoints one sapi_safechannel_t may be configured with,...
sapi_status_t sapi_safechannel_send(sapi_safechannel_t *channel, const uint8_t *payload, size_t payload_size)
Sends payload on the underlying channel - broadcast-with-ACK- wait for DUAL_REDUNDANT (sapi_dual_chan...
sapi_safechannel_link_status_t sapi_safechannel_get_status(const sapi_safechannel_t *channel)
Aggregate status across every configured endpoint - DOWN before the first send/receive.
sapi_status_t sapi_safechannel_open(sapi_safechannel_t *channel, const sapi_safechannel_config_t *config)
Opens a channel: opens every configured endpoint via the registered sapi_netlink backend,...
sapi_status_t sapi_safechannel_receive(sapi_safechannel_t *channel, uint8_t *out_payload, size_t max_size, sapi_duration_ms_t timeout_ms, size_t *out_size)
Returns the most recent inbound payload, actively polling the underlying channel if nothing was alrea...
sapi_safechannel_link_status_t
Aggregate link status, uniform across both wrapped types.
sapi_status_t sapi_safechannel_close(sapi_safechannel_t *channel)
Closes every endpoint this instance opened and releases the wrapped channel. Safe to call on an alrea...
@ SAPI_SAFECHANNEL_TYPE_VITAL_VOTED
@ SAPI_SAFECHANNEL_TYPE_DUAL_REDUNDANT
@ SAPI_SAFECHANNEL_LINK_DEGRADED
@ SAPI_SAFECHANNEL_LINK_DOWN
@ SAPI_SAFECHANNEL_LINK_FULL
sapi_status_t
Common result/status codes.
uint32_t sapi_duration_ms_t
sapi_channel_storage_t sapi_channel_t
Opaque handle to a vital channel instance.
sapi_voter_storage_t sapi_voter_t
Opaque handle to a voter instance.
sapi_voting_result_t
Outcome of one sapi_voter_receive() call.
sapi_voting_strategy_t
Voting strategy: how many registered channels must agree.
A single redundant "channel": an opaque transport handle plus send/receive callbacks,...
"DualChannel" layer of ADR-020: wraps 1..N redundant sapi_dual_msgchannel_t links for fault-tolerant,...
OS Abstraction Layer - Point-to-point network link service.
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
N-way voting across registered sapi_channel_t links (2oo2/2oo3/NMR).
One sapi_dual_channel_t instance's state. Caller-owned storage; every field is private - reach it onl...
Configuration for sapi_safechannel_open().
sapi_safechannel_type_t type
Configuration specific to SAPI_SAFECHANNEL_TYPE_DUAL_REDUNDANT.
sapi_duration_ms_t connect_timeout_ms
sapi_safechannel_endpoint_t endpoints[SAPI_SAFECHANNEL_MAX_LINKS]
void * status_callback_ctx
uint32_t expected_peer_id
sapi_dual_channel_status_callback_t status_callback
sapi_duration_ms_t ack_timeout_ms
One remote endpoint to open internally - replaces a caller- supplied sapi_netlink_handle_t (ADR-022 s...
sapi_channel_t channels[SAPI_SAFECHANNEL_MAX_LINKS]
Caller-owned storage for one sapi_safechannel_t instance. Every field is private - reach it only thro...
sapi_netlink_storage_t links[SAPI_SAFECHANNEL_MAX_LINKS]
Configuration specific to SAPI_SAFECHANNEL_TYPE_VITAL_VOTED.
sapi_duration_ms_t connect_timeout_ms
sapi_duration_ms_t channel_timeout_ms
void(*) on_disagreement(void *context, sapi_voting_result_t result)
sapi_safechannel_endpoint_t endpoints[SAPI_SAFECHANNEL_MAX_LINKS]
sapi_voting_strategy_t voting_strategy