|
Safe Communication Framework 0.1.0 build feea4f9
ERTMS/ETCS safe communication (Subset-037 EuroRadio, Subset-098 RBC/RBC), CENELEC EN 50128 SIL 4 oriented
|
Safe Application Intermediate (SAI) sub-layer, EC-counter variant (Subset-098 v4.0.0 §5.4.7/§5.4.9). More...
Go to the source code of this file.
Macros | |
| #define | SAI_MSG_EC_START 0x81U |
| #define | SAI_MSG_EC_DATA 0x86U |
| #define | SAI_HEADER_LEN 19U |
| #define | SAI_START_EXTRA_LEN 6U |
Functions | |
| static void | pack_u16_be (uint16_t v, uint8_t buf[2]) |
| static uint16_t | unpack_u16_be (const uint8_t buf[2]) |
| static void | pack_u32_be (uint32_t v, uint8_t buf[4]) |
| static uint32_t | unpack_u32_be (const uint8_t buf[4]) |
| static int | ec_state_from_delta (int32_t delta) |
| safecomm_status_t | safecomm_sai_init (safecomm_sai_conn_t *conn, safecomm_saf_conn_t *saf, const safecomm_sai_config_t *cfg) |
| Initialise a SAI connection object over an already-initialised SaF connection. | |
| safecomm_status_t | safecomm_sai_start (safecomm_sai_conn_t *conn) |
Run the EC initialisation exchange (§5.4.9.3): send our ExecutionCycleStart, wait for the peer's, and compute the EC ratio. saf must already be in DATA (its own AU1-3/AR handshake done). | |
| safecomm_status_t | safecomm_sai_send (safecomm_sai_conn_t *conn, const uint8_t *pdu, size_t pdu_len) |
| Wrap one user PDU in a SAI header (message type, sequence number, our EC counter) and send it through the underlying SaF connection. | |
| safecomm_status_t | safecomm_sai_recv (safecomm_sai_conn_t *conn, uint8_t *out, size_t out_cap, size_t *out_len) |
| Receive, unwrap and check one SAI-protected PDU. | |
| void | safecomm_sai_tick (safecomm_sai_conn_t *conn) |
Advance our own EC by one: call this once per cfg.ec_period_ms elapsed on the caller's clock. Updates the expected-EC estimate and the freshness state (§5.4.9.4.4-7) even if no message arrived in this cycle (using the last one received). | |
Safe Application Intermediate (SAI) sub-layer, EC-counter variant (Subset-098 v4.0.0 §5.4.7/§5.4.9).
See sai.h for what is and is not implemented.
Definition in file sai.c.
| safecomm_status_t safecomm_sai_init | ( | safecomm_sai_conn_t * | conn, |
| safecomm_saf_conn_t * | saf, | ||
| const safecomm_sai_config_t * | cfg ) |
Initialise a SAI connection object over an already-initialised SaF connection.
| conn | caller-allocated, will be fully overwritten. Non-NULL. |
| saf | the underlying SaF connection (kept by reference; not copied, not owned). Non-NULL. |
| cfg | static configuration, copied. Non-NULL. |
| safecomm_status_t safecomm_sai_start | ( | safecomm_sai_conn_t * | conn | ) |
Run the EC initialisation exchange (§5.4.9.3): send our ExecutionCycleStart, wait for the peer's, and compute the EC ratio. saf must already be in DATA (its own AU1-3/AR handshake done).
| conn | an initialised SAI connection. Non-NULL. |
| safecomm_status_t safecomm_sai_send | ( | safecomm_sai_conn_t * | conn, |
| const uint8_t * | pdu, | ||
| size_t | pdu_len ) |
Wrap one user PDU in a SAI header (message type, sequence number, our EC counter) and send it through the underlying SaF connection.
| conn | a started SAI connection. Non-NULL. |
| pdu | user bytes. Non-NULL when pdu_len > 0. |
| pdu_len | length of pdu. |
| safecomm_status_t safecomm_sai_recv | ( | safecomm_sai_conn_t * | conn, |
| uint8_t * | out, | ||
| size_t | out_cap, | ||
| size_t * | out_len ) |
Receive, unwrap and check one SAI-protected PDU.
| conn | a started SAI connection. Non-NULL. |
| out | destination for the user bytes. Non-NULL. |
| out_cap | capacity of out. |
| out_len | receives the user-byte count. Non-NULL. |
| void safecomm_sai_tick | ( | safecomm_sai_conn_t * | conn | ) |
Advance our own EC by one: call this once per cfg.ec_period_ms elapsed on the caller's clock. Updates the expected-EC estimate and the freshness state (§5.4.9.4.4-7) even if no message arrived in this cycle (using the last one received).
| conn | a started SAI connection. Non-NULL. |