|
Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
|
Files | |
| file | src/redundancy/cross_comparator/rte_cross_comparator.c |
| Pairwise channel comparison (ADR-025): validates parameters, receives from both registered channels, and compares them. | |
Data Structures | |
| struct | rte_cross_comparator_config_t |
| Configuration for rte_cross_comparator_init(). More... | |
| struct | rte_cross_comparator_storage_t |
| Storage for one cross-comparator instance (opaque to caller). No dynamic memory. More... | |
Macros | |
| #define | RTE_CROSS_COMPARATOR_MAX_MESSAGE_SIZE 256U |
| Maximum payload size rte_cross_comparator_execute() supports. | |
Typedefs | |
| typedef rte_cross_comparator_storage_t | rte_cross_comparator_t |
| Opaque handle to a cross-comparator instance. | |
Functions | |
| rte_status_t | rte_cross_comparator_init (rte_cross_comparator_storage_t *storage, const rte_cross_comparator_config_t *config) |
| Initializes a cross-comparator with zero registered channels. | |
| rte_status_t | rte_cross_comparator_register_channel (rte_cross_comparator_t *cmp, rte_channel_t *channel) |
| Registers one already-initialized channel (channel A, then B). | |
| rte_status_t | rte_cross_comparator_execute (rte_cross_comparator_t *cmp, size_t data_size, rte_voting_result_t *result, void *out_data, size_t *out_size) |
| Receives from both registered channels and compares them. | |
| rte_status_t | rte_cross_comparator_execute_buffers (rte_cross_comparator_t *cmp, const void *local_data, const void *peer_data, size_t data_size, rte_voting_result_t *result, void *out_data, size_t *out_size) |
| Compares two already-in-hand data buffers directly, with the same on_disagreement-then-unconditional-safestate semantics as rte_cross_comparator_execute() - no rte_channel_t registration needed. Added per direct request as part of the RCA/OCORA compatibility initiative's Phase 2b (see docs/rca/ at the workspace root and TODO.dox): an integrator whose local/peer data already arrived through its own transport (e.g. RBC_GP's kind-multiplexed peer_channel, which carries cross-compare traffic alongside checkpoint/site-state frames on one shared link - not something a generic comparator API can transparently subsume) no longer needs to hand-wire two pure in-memory rte_channel_t "already arrived" adapters (send() that is never called, recv() that just returns a buffer) purely to satisfy rte_cross_comparator_execute()'s channel-based interface - this collapses that boilerplate to one call. | |
| rte_status_t | rte_cross_comparator_get_aggregated_health (const rte_cross_comparator_t *cmp, uint32_t *healthy_count, uint32_t *total_disagreements) |
| Aggregated health across both registered channels. | |
| rte_status_t | rte_cross_comparator_destroy (rte_cross_comparator_t *cmp) |
| Destroys a cross-comparator instance. | |
| #define RTE_CROSS_COMPARATOR_MAX_MESSAGE_SIZE 256U |
Maximum payload size rte_cross_comparator_execute() supports.
Definition at line 82 of file rte_cross_comparator.h.
Opaque handle to a cross-comparator instance.
Definition at line 98 of file rte_cross_comparator.h.
| rte_status_t rte_cross_comparator_init | ( | rte_cross_comparator_storage_t * | storage, |
| const rte_cross_comparator_config_t * | config ) |
Initializes a cross-comparator with zero registered channels.
| [out] | storage | Pre-allocated storage. Must not be NULL. |
| [in] | config | Configuration. Must not be NULL. |
REQ-CROSSCOMPARATOR-001: No dynamic allocation; exactly 2 channel slots.
Definition at line 30 of file rte_cross_comparator.c.
| rte_status_t rte_cross_comparator_register_channel | ( | rte_cross_comparator_t * | cmp, |
| rte_channel_t * | channel ) |
Registers one already-initialized channel (channel A, then B).
| [in] | cmp | Cross-comparator handle. Must not be NULL and must be initialized. |
| [in] | channel | Already rte_channel_init()'d channel. Must not be NULL. |
REQ-CROSSCOMPARATOR-002: A 3rd registration attempt is rejected without disturbing the 2 already-registered channels.
Definition at line 57 of file rte_cross_comparator.c.
| rte_status_t rte_cross_comparator_execute | ( | rte_cross_comparator_t * | cmp, |
| size_t | data_size, | ||
| rte_voting_result_t * | result, | ||
| void * | out_data, | ||
| size_t * | out_size ) |
Receives from both registered channels and compares them.
| [in] | cmp | Cross-comparator handle. Must not be NULL, initialized, with exactly 2 channels registered. |
| [in] | data_size | Bytes to receive/compare per channel; must be > 0 and <= RTE_CROSS_COMPARATOR_MAX_MESSAGE_SIZE. |
| [out] | result | Comparison outcome. Can be NULL. |
| [out] | out_data | Receives channel A's data on AGREED. Can be NULL if the caller only cares about result. |
| [out] | out_size | Bytes written to out_data. Can be NULL. |
REQ-CROSSCOMPARATOR-003: Both channels must be healthy and successfully receive data_size bytes before comparison is attempted; otherwise short-circuits to TIMEOUT/INSUFFICIENT_QUORUM. REQ-CROSSCOMPARATOR-004: Uses config->compare if registered, else a full memcmp() - CRC-64 transport integrity is a separate, already- applied concern, never itself treated as the comparison.
Definition at line 164 of file rte_cross_comparator.c.
| rte_status_t rte_cross_comparator_execute_buffers | ( | rte_cross_comparator_t * | cmp, |
| const void * | local_data, | ||
| const void * | peer_data, | ||
| size_t | data_size, | ||
| rte_voting_result_t * | result, | ||
| void * | out_data, | ||
| size_t * | out_size ) |
Compares two already-in-hand data buffers directly, with the same on_disagreement-then-unconditional-safestate semantics as rte_cross_comparator_execute() - no rte_channel_t registration needed. Added per direct request as part of the RCA/OCORA compatibility initiative's Phase 2b (see docs/rca/ at the workspace root and TODO.dox): an integrator whose local/peer data already arrived through its own transport (e.g. RBC_GP's kind-multiplexed peer_channel, which carries cross-compare traffic alongside checkpoint/site-state frames on one shared link - not something a generic comparator API can transparently subsume) no longer needs to hand-wire two pure in-memory rte_channel_t "already arrived" adapters (send() that is never called, recv() that just returns a buffer) purely to satisfy rte_cross_comparator_execute()'s channel-based interface - this collapses that boilerplate to one call.
A cross-comparator used with this function does not need rte_cross_comparator_register_channel() called on it at all - only rte_cross_comparator_init(). Mixing the two calling styles on the same rte_cross_comparator_t is allowed (this function ignores any registered channels; rte_cross_comparator_execute() ignores this function's own lack of them) but is not a pattern any current caller uses.
| [in] | cmp | Cross-comparator handle (rte_cross_comparator_init()'d). Must not be NULL. |
| [in] | local_data | This side's own data. Must not be NULL. |
| [in] | peer_data | The counterpart's data, already received via whatever transport the caller owns. Must not be NULL. |
| [in] | data_size | Bytes to compare; must be > 0 and <= RTE_CROSS_COMPARATOR_MAX_MESSAGE_SIZE. |
| [out] | result | Comparison outcome (always RTE_VOTING_AGREED or RTE_VOTING_DISAGREED - there is no I/O here, so TIMEOUT/INSUFFICIENT_QUORUM never occur). Can be NULL. |
| [out] | out_data | Receives local_data on AGREED. Can be NULL. |
| [out] | out_size | Bytes written to out_data. Can be NULL. |
Definition at line 224 of file rte_cross_comparator.c.
| rte_status_t rte_cross_comparator_get_aggregated_health | ( | const rte_cross_comparator_t * | cmp, |
| uint32_t * | healthy_count, | ||
| uint32_t * | total_disagreements ) |
Aggregated health across both registered channels.
| [in] | cmp | Cross-comparator handle. Must not be NULL. |
| [out] | healthy_count | Number of currently-healthy registered channels (0, 1, or 2). Can be NULL. |
| [out] | total_disagreements | Running count of DISAGREED results. Can be NULL. |
Definition at line 251 of file rte_cross_comparator.c.
| rte_status_t rte_cross_comparator_destroy | ( | rte_cross_comparator_t * | cmp | ) |
Destroys a cross-comparator instance.
| [in] | cmp | Cross-comparator handle. May be NULL. |
Definition at line 292 of file rte_cross_comparator.c.