RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Loading...
Searching...
No Matches
ab_gp_jru_forward.c File Reference

See ab_gp_jru_forward.h. More...

Include dependency graph for ab_gp_jru_forward.c:

Go to the source code of this file.

Functions

static rte_status_t osadapter_init (void)
static void osadapter_write (rte_log_level_t level, const char *tag, const char *message)
rte_status_t ab_gp_jru_forward_install (const rte_osadapter_log_t *delegate)
 Wraps delegate (the real local log OSAdapter, e.g. rte_posix_osadapter_log()) and registers the wrapper as THE log OSAdapter (rte_osadapter_log_register()). Call once, right after the delegate would otherwise have been registered.
void ab_gp_jru_forward_set_channel (ab_gp_channel_handle_t handle, uint8_t source_id)
 Attaches the open AB<->C relay channel: from this call on, write() also republishes INFO+ events to Gateway. Before this is called, write() only delegates locally (same as if forwarding were never installed) - there is no channel to publish over yet during app_main_common_init()'s early OSAdapter bring-up.

Variables

static const rte_osadapter_log_t s_forward_osadapter = { osadapter_init, osadapter_write }
static const rte_osadapter_log_t * s_delegate
static ab_gp_channel_handle_t s_handle
static uint8_t s_source_id
static uint8_t s_seq
static __thread bool s_in_forward

Detailed Description

See ab_gp_jru_forward.h.

Definition in file ab_gp_jru_forward.c.

Function Documentation

◆ osadapter_init()

rte_status_t osadapter_init ( void )
static

Local makros Local types declarations Local function declarations

Definition at line 58 of file ab_gp_jru_forward.c.

◆ osadapter_write()

void osadapter_write ( rte_log_level_t level,
const char * tag,
const char * message )
static

Definition at line 63 of file ab_gp_jru_forward.c.

◆ ab_gp_jru_forward_install()

rte_status_t ab_gp_jru_forward_install ( const rte_osadapter_log_t * delegate)

Wraps delegate (the real local log OSAdapter, e.g. rte_posix_osadapter_log()) and registers the wrapper as THE log OSAdapter (rte_osadapter_log_register()). Call once, right after the delegate would otherwise have been registered.

Global variables declarations Global functions

Parameters
delegateNon-NULL vtable to delegate every write() to.
Returns
RTE_STATUS_OK, or RTE_STATUS_INVALID_PARAM if delegate is NULL.

Definition at line 33 of file ab_gp_jru_forward.c.

◆ ab_gp_jru_forward_set_channel()

void ab_gp_jru_forward_set_channel ( ab_gp_channel_handle_t handle,
uint8_t source_id )

Attaches the open AB<->C relay channel: from this call on, write() also republishes INFO+ events to Gateway. Before this is called, write() only delegates locally (same as if forwarding were never installed) - there is no channel to publish over yet during app_main_common_init()'s early OSAdapter bring-up.

Parameters
handleChannel opened by ab_gp_channel_open_link().
source_idRBC_UTIL_SRC_A or RBC_UTIL_SRC_B (rbc_util_frame.h).

Definition at line 50 of file ab_gp_jru_forward.c.

Variable Documentation

◆ s_forward_osadapter

const rte_osadapter_log_t s_forward_osadapter = { osadapter_init, osadapter_write }
static

Local variables declarations

Definition at line 20 of file ab_gp_jru_forward.c.

◆ s_delegate

const rte_osadapter_log_t* s_delegate
static

Definition at line 21 of file ab_gp_jru_forward.c.

◆ s_handle

ab_gp_channel_handle_t s_handle
static

Definition at line 22 of file ab_gp_jru_forward.c.

◆ s_source_id

uint8_t s_source_id
static

Definition at line 23 of file ab_gp_jru_forward.c.

◆ s_seq

uint8_t s_seq
static

Definition at line 24 of file ab_gp_jru_forward.c.

◆ s_in_forward

__thread bool s_in_forward
static

Per-thread reentrancy guard: forwarding sends over a relay channel, and that send can itself log (e.g. the lazy netlink open logs INFO), which would forward again without end (found live: unbounded recursion, one leaked socket per level, then a stack-overflow SIGSEGV).

Definition at line 28 of file ab_gp_jru_forward.c.