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
Redundancy topology config

Data Structures

struct  rte_channel_def_t
struct  rte_redundancy_config_t

Macros

#define RTE_REDUNDANCY_CONFIG_MAX_ROLE_NAME_LEN   16U
#define RTE_REDUNDANCY_CONFIG_MAX_REPLICAS   5U
#define RTE_REDUNDANCY_CONFIG_MAX_FILE_SIZE   8192U
#define RTE_CHANNEL_CONFIG_MAX_CHANNELS   32U
#define RTE_CHANNEL_CONFIG_MAX_NAME_LEN   32U
#define RTE_CHANNEL_CONFIG_MAX_HOST_LEN   64U

Typedefs

typedef bool(*) rte_redundancy_capability_fn(rte_redundancy_topology_t topology, uint32_t replica_count, void *context)
 Integrator-supplied capability query: can THIS application actually run the given topology/replica_count combination? This is how an integrator (e.g. RBC_GP) declares what it supports to the Platform, instead of the Platform (or the integrator's own call site) hardcoding a topology allowlist - matches OCORA's own "Platform decides" posture already used throughout this module and rte_voter/rte_cross_comparator's own safestate-transition ownership.

Enumerations

enum  rte_channel_transport_t { RTE_CHANNEL_TRANSPORT_FLOW = 0 , RTE_CHANNEL_TRANSPORT_POSIX_NETLINK = 1 , RTE_CHANNEL_TRANSPORT_DDS = 2 }
enum  rte_channel_role_t { RTE_CHANNEL_ROLE_LISTEN = 0 , RTE_CHANNEL_ROLE_CONNECT = 1 }
enum  rte_redundancy_topology_t { RTE_REDUNDANCY_TOPOLOGY_2OO2 = 0 , RTE_REDUNDANCY_TOPOLOGY_2OO2_REDUNDANT = 1 , RTE_REDUNDANCY_TOPOLOGY_2OO3 = 2 , RTE_REDUNDANCY_TOPOLOGY_NMR = 3 }
enum  rte_standby_mode_t { RTE_STANDBY_MODE_HOT = 0 , RTE_STANDBY_MODE_WARM = 1 , RTE_STANDBY_MODE_COLD = 2 }
 How a non-active replica ("standby") keeps itself ready to take over, and how rte_state_transfer (redundancy/state_transfer/ rte_state_transfer.h) gets used, if at all. This is a CADENCE policy only - it says nothing about WHAT data is registered (that stays the integrator's own rte_state_transfer_register_field() calls) or how a promotion is detected (that stays e.g. rte_dual_negotiator_t's own job). More...

Functions

rte_status_t rte_redundancy_config_standby_mode_from_string (const char *name, rte_standby_mode_t *out_mode)
 Parse a standby-mode name string ("hot", "warm", "cold") into its enum value.
const char * rte_redundancy_config_standby_mode_to_string (rte_standby_mode_t mode)
 Inverse of rte_redundancy_config_standby_mode_from_string() - for logging/diagnostics.
rte_status_t rte_redundancy_config_topology_from_string (const char *name, rte_redundancy_topology_t *out_topology)
 Parse a topology name string ("2oo2", "2oo2_redundant", "2oo3", "nmr") into its enum value.
const char * rte_redundancy_config_topology_to_string (rte_redundancy_topology_t topology)
 Inverse of rte_redundancy_config_topology_from_string() - for logging/diagnostics.
rte_status_t rte_redundancy_config_register_capability (rte_redundancy_capability_fn fn, void *context)
 Registers the capability callback rte_redundancy_config_load() consults after successfully parsing a file, before returning RTE_STATUS_OK. Call once at startup, before load(). No callback registered (the default) means load() accepts any successfully-parsed, internally-consistent config - the same behavior this module had before this function existed.
rte_status_t rte_redundancy_config_load (const char *path, rte_redundancy_config_t *out_config)
 Load a redundancy topology config from a JSON file.
rte_status_t rte_redundancy_config_apply_to_voter (const rte_redundancy_config_t *config, rte_voter_config_t *voter_cfg)
 Copy the resolved quorum from a loaded redundancy config into a rte_voter_config_t, leaving every other field of voter_cfg untouched (compare()/context/timeouts/safestate fields remain the caller's own responsibility to set).
rte_status_t rte_channel_config_transport_from_string (const char *name, rte_channel_transport_t *out_transport)
 Parse transport name string ("flow", "netlink", "posix", "dds") into enum.
rte_status_t rte_channel_config_role_from_string (const char *name, rte_channel_role_t *out_role)
 Parse channel role name string ("listen", "connect", "publisher", "subscriber") into enum.
rte_status_t rte_redundancy_config_find_channel_by_name (const rte_redundancy_config_t *config, const char *name, rte_channel_def_t *out_channel)
 Find channel definition by name in the given configuration.
rte_status_t rte_redundancy_config_find_channel_by_id (const rte_redundancy_config_t *config, uint32_t id, rte_channel_def_t *out_channel)
 Find channel definition by ID in the given configuration.
const rte_redundancy_config_t * rte_redundancy_config_get_active (void)
 Get the currently active loaded redundancy/channel configuration (if any).
void rte_redundancy_config_set_active (const rte_redundancy_config_t *config)
 Set the active configuration explicitly (or automatically by rte_redundancy_config_load).

Detailed Description

Macro Definition Documentation

◆ RTE_REDUNDANCY_CONFIG_MAX_ROLE_NAME_LEN

#define RTE_REDUNDANCY_CONFIG_MAX_ROLE_NAME_LEN   16U

Longest role name (including terminator) accepted in the "roles" array.

Definition at line 67 of file rte_redundancy_config.h.

◆ RTE_REDUNDANCY_CONFIG_MAX_REPLICAS

#define RTE_REDUNDANCY_CONFIG_MAX_REPLICAS   5U

Largest replica count (and "roles" array length) this module accepts.

Definition at line 70 of file rte_redundancy_config.h.

◆ RTE_REDUNDANCY_CONFIG_MAX_FILE_SIZE

#define RTE_REDUNDANCY_CONFIG_MAX_FILE_SIZE   8192U

Largest config file this loader will read - a bounded, static buffer, no dynamic allocation; a larger file is rejected as invalid.

Definition at line 74 of file rte_redundancy_config.h.

◆ RTE_CHANNEL_CONFIG_MAX_CHANNELS

#define RTE_CHANNEL_CONFIG_MAX_CHANNELS   32U

Largest channel count accepted in the "channels" array.

Definition at line 77 of file rte_redundancy_config.h.

◆ RTE_CHANNEL_CONFIG_MAX_NAME_LEN

#define RTE_CHANNEL_CONFIG_MAX_NAME_LEN   32U

Longest channel name (including terminator).

Definition at line 80 of file rte_redundancy_config.h.

◆ RTE_CHANNEL_CONFIG_MAX_HOST_LEN

#define RTE_CHANNEL_CONFIG_MAX_HOST_LEN   64U

Longest host name (including terminator).

Definition at line 83 of file rte_redundancy_config.h.

Typedef Documentation

◆ rte_redundancy_capability_fn

typedef bool(*) rte_redundancy_capability_fn(rte_redundancy_topology_t topology, uint32_t replica_count, void *context)

Integrator-supplied capability query: can THIS application actually run the given topology/replica_count combination? This is how an integrator (e.g. RBC_GP) declares what it supports to the Platform, instead of the Platform (or the integrator's own call site) hardcoding a topology allowlist - matches OCORA's own "Platform decides" posture already used throughout this module and rte_voter/rte_cross_comparator's own safestate-transition ownership.

Parameters
[in]topologyThe loaded config's topology.
[in]replica_countThe loaded config's replica_count.
[in]contextWhatever rte_redundancy_config_register_capability() was given.
Returns
true if this application can run this combination; false otherwise (rte_redundancy_config_load() then fails with RTE_STATUS_NOT_SUPPORTED instead of returning RTE_STATUS_OK).

Definition at line 242 of file rte_redundancy_config.h.

Enumeration Type Documentation

◆ rte_channel_transport_t

Channel transport type.

Definition at line 86 of file rte_redundancy_config.h.

◆ rte_channel_role_t

Channel endpoint role.

Definition at line 93 of file rte_redundancy_config.h.

◆ rte_redundancy_topology_t

Voting/replication topology, matching the OCORA/RCA-discussed options.

Enumerator
RTE_REDUNDANCY_TOPOLOGY_2OO2 

Two replicas, pairwise 2-way comparison (rte_cross_comparator).

RTE_REDUNDANCY_TOPOLOGY_2OO2_REDUNDANT 

Two active replicas plus one or more hot-standby/redundant replicas not in the voting quorum today - replica_count may exceed 2, but quorum_size stays 2 unless the file overrides it.

RTE_REDUNDANCY_TOPOLOGY_2OO3 

Three replicas, 2-out-of-3 quorum voting (rte_voter). OCORA's own recommended topology for RBC use-cases over plain 2oo2.

RTE_REDUNDANCY_TOPOLOGY_NMR 

N-modular redundancy: replica_count is N, quorum_size is whatever the file specifies (no implicit majority default - see load()'s doc).

Definition at line 121 of file rte_redundancy_config.h.

◆ rte_standby_mode_t

How a non-active replica ("standby") keeps itself ready to take over, and how rte_state_transfer (redundancy/state_transfer/ rte_state_transfer.h) gets used, if at all. This is a CADENCE policy only - it says nothing about WHAT data is registered (that stays the integrator's own rte_state_transfer_register_field() calls) or how a promotion is detected (that stays e.g. rte_dual_negotiator_t's own job).

Enumerator
RTE_STANDBY_MODE_HOT 

Standby computes independently every cycle from the same live inputs as the active replica, so it is never behind - no transfer is needed at all, ever. The integrator simply never calls rte_state_transfer_encode()/_decode() in this mode.

RTE_STANDBY_MODE_WARM 

Standby is periodically refreshed (an integrator-chosen interval, not specified by this module) so a promotion only needs a short catch-up, not a full cold transfer.

RTE_STANDBY_MODE_COLD 

Standby is not refreshed until the moment of promotion - the default. RBC_GP implements it and runs WARM and HOT alike as a snapshot sync before each commit (rte_site_role standby_sync, no independent computation; see that product's ab_gp_channel_negotiate.c).

Definition at line 145 of file rte_redundancy_config.h.

Function Documentation

◆ rte_redundancy_config_standby_mode_from_string()

rte_status_t rte_redundancy_config_standby_mode_from_string ( const char * name,
rte_standby_mode_t * out_mode )

Parse a standby-mode name string ("hot", "warm", "cold") into its enum value.

Parameters
[in]nameNUL-terminated; case-sensitive.
[out]out_modeSet on success; untouched on failure.
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM (NULL pointer or unrecognized name).

Definition at line 476 of file rte_redundancy_config.c.

◆ rte_redundancy_config_standby_mode_to_string()

const char * rte_redundancy_config_standby_mode_to_string ( rte_standby_mode_t mode)

Inverse of rte_redundancy_config_standby_mode_from_string() - for logging/diagnostics.

Parameters
[in]modeAny value of rte_standby_mode_t.
Returns
A static, NUL-terminated string; "unknown" for an out-of-range value.

Definition at line 496 of file rte_redundancy_config.c.

◆ rte_redundancy_config_topology_from_string()

rte_status_t rte_redundancy_config_topology_from_string ( const char * name,
rte_redundancy_topology_t * out_topology )

Parse a topology name string ("2oo2", "2oo2_redundant", "2oo3", "nmr") into its enum value.

Parameters
[in]nameNUL-terminated topology name; case-sensitive, exactly one of the four strings above.
[out]out_topologySet on success; untouched on failure.
Returns
RTE_STATUS_OK, RTE_STATUS_INVALID_PARAM (NULL pointer or unrecognized name).

Definition at line 428 of file rte_redundancy_config.c.

◆ rte_redundancy_config_topology_to_string()

const char * rte_redundancy_config_topology_to_string ( rte_redundancy_topology_t topology)

Inverse of rte_redundancy_config_topology_from_string() - for logging/diagnostics.

Parameters
[in]topologyAny value of rte_redundancy_topology_t.
Returns
A static, NUL-terminated string; "unknown" for an out-of-range value.

Definition at line 452 of file rte_redundancy_config.c.

◆ rte_redundancy_config_register_capability()

rte_status_t rte_redundancy_config_register_capability ( rte_redundancy_capability_fn fn,
void * context )

Registers the capability callback rte_redundancy_config_load() consults after successfully parsing a file, before returning RTE_STATUS_OK. Call once at startup, before load(). No callback registered (the default) means load() accepts any successfully-parsed, internally-consistent config - the same behavior this module had before this function existed.

Parameters
[in]fnMay be NULL to clear a previously registered callback (load() then accepts any config again).
[in]contextPassed verbatim to fn on every call; may be NULL.
Returns
RTE_STATUS_OK always.

Definition at line 21 of file rte_redundancy_config.c.

◆ rte_redundancy_config_load()

rte_status_t rte_redundancy_config_load ( const char * path,
rte_redundancy_config_t * out_config )

Load a redundancy topology config from a JSON file.

Parameters
[in]pathNUL-terminated filesystem path.
[out]out_configFilled on success; untouched on failure.
Returns
RTE_STATUS_OK on success. RTE_STATUS_INVALID_PARAM - path or out_config is NULL. RTE_STATUS_INTERNAL_ERROR - file could not be opened/read, or exceeds RTE_REDUNDANCY_CONFIG_MAX_FILE_SIZE. RTE_STATUS_INVALID_STATE - file content does not match the expected schema (missing/malformed "topology" or "replicas", a "roles" array longer than RTE_REDUNDANCY_CONFIG_MAX_REPLICAS, a role name longer than RTE_REDUNDANCY_CONFIG_MAX_ROLE_NAME_LEN-1, replica_count/quorum_size that fail sanity checks below, or a channel whose "rcvbuf_bytes"/"sndbuf_bytes" is present but not an unsigned decimal integer of at most UINT32_MAX - REQ-REDCFG-001). RTE_STATUS_NOT_SUPPORTED - the file parsed and validated fine, but a registered rte_redundancy_capability_fn returned false for it (see rte_redundancy_config_register_capability()).
Postcondition
On success: 1 <= replica_count <= RTE_REDUNDANCY_CONFIG_MAX_REPLICAS, 1 <= quorum_size <= replica_count.

Default quorum_size when "quorum" is absent from the file:

  • RTE_REDUNDANCY_TOPOLOGY_2OO2 / _2OO2_REDUNDANT: 2 (rejected if replica_count < 2).
  • RTE_REDUNDANCY_TOPOLOGY_2OO3: 2 (rejected if replica_count != 3).
  • RTE_REDUNDANCY_TOPOLOGY_NMR: no default - "quorum" is REQUIRED in the file for this topology (RTE_STATUS_INVALID_STATE if absent), since NMR's whole point is a deployment-chosen quorum, not an implicit majority.

"standby_mode" ("hot"/"warm"/"cold") is optional; defaults to RTE_STANDBY_MODE_COLD when absent (see that enum's own doc).

Per channel, "rcvbuf_bytes" and "sndbuf_bytes" are optional; absent gives 0 (OS default) in rte_channel_def_t (REQ-REDCFG-001).

Definition at line 660 of file rte_redundancy_config.c.

◆ rte_redundancy_config_apply_to_voter()

rte_status_t rte_redundancy_config_apply_to_voter ( const rte_redundancy_config_t * config,
rte_voter_config_t * voter_cfg )

Copy the resolved quorum from a loaded redundancy config into a rte_voter_config_t, leaving every other field of voter_cfg untouched (compare()/context/timeouts/safestate fields remain the caller's own responsibility to set).

Parameters
[in]configA config previously filled by rte_redundancy_config_load(), non-NULL.
[in,out]voter_cfgNon-NULL; only ::quorum_size is written.
Returns
RTE_STATUS_OK, RTE_STATUS_INVALID_PARAM (either pointer is NULL).

Definition at line 716 of file rte_redundancy_config.c.

◆ rte_channel_config_transport_from_string()

rte_status_t rte_channel_config_transport_from_string ( const char * name,
rte_channel_transport_t * out_transport )

Parse transport name string ("flow", "netlink", "posix", "dds") into enum.

Definition at line 245 of file rte_redundancy_config.c.

◆ rte_channel_config_role_from_string()

rte_status_t rte_channel_config_role_from_string ( const char * name,
rte_channel_role_t * out_role )

Parse channel role name string ("listen", "connect", "publisher", "subscriber") into enum.

Definition at line 265 of file rte_redundancy_config.c.

◆ rte_redundancy_config_find_channel_by_name()

rte_status_t rte_redundancy_config_find_channel_by_name ( const rte_redundancy_config_t * config,
const char * name,
rte_channel_def_t * out_channel )

Find channel definition by name in the given configuration.

Definition at line 726 of file rte_redundancy_config.c.

◆ rte_redundancy_config_find_channel_by_id()

rte_status_t rte_redundancy_config_find_channel_by_id ( const rte_redundancy_config_t * config,
uint32_t id,
rte_channel_def_t * out_channel )

Find channel definition by ID in the given configuration.

Definition at line 744 of file rte_redundancy_config.c.

◆ rte_redundancy_config_get_active()

const rte_redundancy_config_t * rte_redundancy_config_get_active ( void )

Get the currently active loaded redundancy/channel configuration (if any).

Definition at line 765 of file rte_redundancy_config.c.

◆ rte_redundancy_config_set_active()

void rte_redundancy_config_set_active ( const rte_redundancy_config_t * config)

Set the active configuration explicitly (or automatically by rte_redundancy_config_load).

Definition at line 770 of file rte_redundancy_config.c.