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_voter.c File Reference

N-way voting engine (ADR-025): validates parameters, dispatches send/receive to every registered healthy channel, and - for receive - groups the responses by mutual agreement and picks the largest group meeting quorum. More...

Include dependency graph for rte_voter.c:

Go to the source code of this file.

Functions

static bool voter_channel_count_matches_strategy (const rte_voter_t *voter, uint32_t channel_count)
static uint32_t voter_required_quorum (const rte_voter_t *voter)
static bool voter_data_equal (const rte_voter_t *voter, const void *a, const void *b, size_t size)
static uint32_t voter_count_healthy (const rte_voter_t *voter)
static uint32_t voter_receive_from_healthy_channels (rte_voter_t *voter, size_t data_size, uint8_t buffers[][RTE_VOTER_MAX_MESSAGE_SIZE], bool responded[], bool *out_saw_timeout)
static void voter_group_matching_responses (const rte_voter_t *voter, uint32_t channel_count, const uint8_t buffers[][RTE_VOTER_MAX_MESSAGE_SIZE], const bool responded[], size_t data_size, uint32_t group_id[], uint32_t group_count[], uint32_t *out_num_groups)
rte_status_t rte_voter_init (rte_voter_storage_t *storage, const rte_voter_config_t *config)
 Initializes a voter with zero registered channels.
rte_status_t rte_voter_register_channel (rte_voter_t *voter, rte_channel_t *channel)
 Registers one already-initialized channel with this voter.
rte_status_t rte_voter_send (rte_voter_t *voter, const void *data, size_t data_size)
 Broadcasts data to every registered, healthy channel.
rte_status_t rte_voter_receive (rte_voter_t *voter, void *data, size_t data_size, rte_voting_result_t *result, size_t *bytes_received)
 Receives from every registered, healthy channel and votes.
rte_status_t rte_voter_vote_buffers (rte_voter_t *voter, const void *const *buffers, uint32_t buffer_count, size_t data_size, rte_voting_result_t *result, void *out_data, size_t *out_size)
 N-way vote on caller-collected buffers, without any registered-channel I/O (ADR-039's N-way cross-compare half: rte_voter used directly, buffer-based, matching rte_cross_comparator_execute_buffers()'s existing shape - decided over building a separate primitive). Same grouping/quorum logic as rte_voter_receive() (REQ-VOTER-004), applied to buffers instead of polling registered channels - this function performs no I/O and ignores any channels registered on voter (same posture rte_cross_comparator_execute_buffers() already established for its own module: a Voter (N-way channel voting) with zero registered channels is a legitimate, expected call shape here).
rte_status_t rte_voter_get_aggregated_health (const rte_voter_t *voter, uint32_t *healthy_count, uint32_t *total_disagreements)
 Aggregated health across every registered channel.
uint32_t rte_voter_get_channel_count (const rte_voter_t *voter)
 Number of channels currently registered with this voter.
rte_channel_t * rte_voter_get_channel (const rte_voter_t *voter, uint32_t index)
 Direct access to one registered channel, by index.
rte_channel_t * rte_voter_get_channel_by_name (const rte_voter_t *voter, const char *name)
 Direct access to one registered channel, by name (e.g. "ChannelAtoB") - the name each channel was given via rte_channel_config_t::name at its own rte_channel_init() time.
rte_status_t rte_voter_destroy (rte_voter_t *voter)
 Destroys a voter instance.

Detailed Description

N-way voting engine (ADR-025): validates parameters, dispatches send/receive to every registered healthy channel, and - for receive - groups the responses by mutual agreement and picks the largest group meeting quorum.

Definition in file rte_voter.c.

Function Documentation

◆ voter_channel_count_matches_strategy()

bool voter_channel_count_matches_strategy ( const rte_voter_t * voter,
uint32_t channel_count )
static

Definition at line 21 of file rte_voter.c.

◆ voter_required_quorum()

uint32_t voter_required_quorum ( const rte_voter_t * voter)
static

Definition at line 45 of file rte_voter.c.

◆ voter_data_equal()

bool voter_data_equal ( const rte_voter_t * voter,
const void * a,
const void * b,
size_t size )
static

Definition at line 70 of file rte_voter.c.

◆ voter_count_healthy()

uint32_t voter_count_healthy ( const rte_voter_t * voter)
static

Definition at line 85 of file rte_voter.c.

◆ voter_receive_from_healthy_channels()

uint32_t voter_receive_from_healthy_channels ( rte_voter_t * voter,
size_t data_size,
uint8_t buffers[][RTE_VOTER_MAX_MESSAGE_SIZE],
bool responded[],
bool * out_saw_timeout )
static

Definition at line 108 of file rte_voter.c.

◆ voter_group_matching_responses()

void voter_group_matching_responses ( const rte_voter_t * voter,
uint32_t channel_count,
const uint8_t buffers[][RTE_VOTER_MAX_MESSAGE_SIZE],
const bool responded[],
size_t data_size,
uint32_t group_id[],
uint32_t group_count[],
uint32_t * out_num_groups )
static

Definition at line 159 of file rte_voter.c.