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

See site_config.h. More...

#include <stdlib.h>
#include <string.h>
#include "site_config.h"
#include "common_config.h"
Include dependency graph for site_config.c:

Go to the source code of this file.

Functions

static uint16_t site_port_base (rte_example_site_t site)
static uint16_t relay_port_offset (rte_example_relay_kind_t kind, uint16_t train_base, uint16_t il_base, uint16_t ctc_base, uint16_t util_base)
bool site_config_parse (const char *arg, rte_example_site_t *out_site)
 Parses a site name argument ("WEST"/"EAST", case-insensitive).
const char * site_config_name (rte_example_site_t site)
uint16_t site_config_ab_port (rte_example_site_t site)
uint16_t site_config_ab_crosscompare_port (rte_example_site_t site)
uint16_t site_config_c_port_for_a (rte_example_site_t site, rte_example_relay_kind_t kind)
 C's listen port for A's dedicated kind relay link, for this site (rte_example_relay_kind_t's own doc) - ONE real TCP link per {kind}, so routing between C and A/B is purely structural (which channel a byte arrived on), never by inspecting message content. ADR-036: Train and IL are no longer per-instance - every train's traffic multiplexes onto the one link and A/B route by the envelope's own train_id.
uint16_t site_config_c_port_for_b (rte_example_site_t site, rte_example_relay_kind_t kind)
uint16_t site_config_c_port_for_train (rte_example_site_t site)
 C's single listen port for the Train sim, for this site (ADR-036: one multiplexed connection carries every train, demuxed by the envelope's train_id).
uint16_t site_config_c_port_for_il (rte_example_site_t site)
uint16_t site_config_c_port_for_ctc (rte_example_site_t site)
uint16_t site_config_c_port_for_broker (rte_example_site_t site, rte_example_relay_kind_t gw_kind)
 ADR-038: the status/broker service's LISTEN port for one local gateway service to CONNECT and publish status on.
const char * site_config_host (const char *env_var_name)
 Resolves a CONNECT-role link's target host for this process.

Detailed Description

See site_config.h.

Definition in file site_config.c.

Function Documentation

◆ site_port_base()

uint16_t site_port_base ( rte_example_site_t site)
static

Local makros Local types declarations Local variables declarations Global variables declarations Local function declarations

Definition at line 130 of file site_config.c.

◆ relay_port_offset()

uint16_t relay_port_offset ( rte_example_relay_kind_t kind,
uint16_t train_base,
uint16_t il_base,
uint16_t ctc_base,
uint16_t util_base )
static
Returns
the port OFFSET (not yet added to a site base) for one {kind} relay link, given that PEER's own three block bases - the per-kind arithmetic both site_config_c_port_for_a()/_for_b() share (each supplies its own three RTE_EXAMPLE_C_FOR_{A,B}_{TRAIN,IL,CTC}_PORT_OFFSET bases). ADR-036: every kind is a single port now (Train/IL are multiplexed, not per-instance).

Definition at line 136 of file site_config.c.

◆ site_config_parse()

bool site_config_parse ( const char * arg,
rte_example_site_t * out_site )

Parses a site name argument ("WEST"/"EAST", case-insensitive).

Global functions

Parameters
argNull-terminated argument string. Must not be NULL.
out_siteReceives the parsed site. Must not be NULL.
Returns
true if arg was a recognized site name; false otherwise (out_site is left unmodified on failure).

Definition at line 33 of file site_config.c.

◆ site_config_name()

const char * site_config_name ( rte_example_site_t site)
Returns
"WEST" or "EAST" - used for logging and as the NVM region name suffix; never NULL.

Definition at line 52 of file site_config.c.

◆ site_config_ab_port()

uint16_t site_config_ab_port ( rte_example_site_t site)
Returns
The A<->B peer/checkpoint link port for this site.

Definition at line 57 of file site_config.c.

◆ site_config_ab_crosscompare_port()

uint16_t site_config_ab_crosscompare_port ( rte_example_site_t site)
Returns
The A<->B dedicated cross-compare link port for this site.

Definition at line 62 of file site_config.c.

◆ site_config_c_port_for_a()

uint16_t site_config_c_port_for_a ( rte_example_site_t site,
rte_example_relay_kind_t kind )

C's listen port for A's dedicated kind relay link, for this site (rte_example_relay_kind_t's own doc) - ONE real TCP link per {kind}, so routing between C and A/B is purely structural (which channel a byte arrived on), never by inspecting message content. ADR-036: Train and IL are no longer per-instance - every train's traffic multiplexes onto the one link and A/B route by the envelope's own train_id.

Definition at line 67 of file site_config.c.

◆ site_config_c_port_for_b()

uint16_t site_config_c_port_for_b ( rte_example_site_t site,
rte_example_relay_kind_t kind )
Returns
C's listen port for B's dedicated kind relay link, for this site - same contract as site_config_c_port_for_a().

Definition at line 76 of file site_config.c.

◆ site_config_c_port_for_train()

uint16_t site_config_c_port_for_train ( rte_example_site_t site)

C's single listen port for the Train sim, for this site (ADR-036: one multiplexed connection carries every train, demuxed by the envelope's train_id).

Parameters
siteWEST or EAST.
Returns
The port the Train sim connects to.

Definition at line 85 of file site_config.c.

◆ site_config_c_port_for_il()

uint16_t site_config_c_port_for_il ( rte_example_site_t site)
Returns
C's single listen port for the IL sim, for this site - same one-multiplexed-link model as site_config_c_port_for_train().

Definition at line 90 of file site_config.c.

◆ site_config_c_port_for_ctc()

uint16_t site_config_c_port_for_ctc ( rte_example_site_t site)
Returns
C's listen port for the single CTC sim instance, for this site.

Definition at line 95 of file site_config.c.

◆ site_config_c_port_for_broker()

uint16_t site_config_c_port_for_broker ( rte_example_site_t site,
rte_example_relay_kind_t gw_kind )

ADR-038: the status/broker service's LISTEN port for one local gateway service to CONNECT and publish status on.

Parameters
gw_kindRELAY_KIND_TRAIN / _IL / _CTC. Any other value -> the TRAIN broker port.

Definition at line 100 of file site_config.c.

◆ site_config_host()

const char * site_config_host ( const char * env_var_name)

Resolves a CONNECT-role link's target host for this process.

Every CONNECT-role endpoint in this example (B's own peer link to A, C-forwarding links, and each channel's own EAST->WEST inter-site negotiation link) used to hardcode RTE_EXAMPLE_LOCALHOST - fine when every role ran as a plain OS process on one host, not once A, B, and C become genuinely separate containers/machines. Each of this example's env vars (RTE_EXAMPLE_C_HOST_ENV etc. - see common_config.h) overrides ONE specific link's target host; unset (the default for etc/run_all.sh/.claude/skills/run-safeAPIRBC2oo2/ smoke.sh, both still fully localhost-based) falls back to RTE_EXAMPLE_LOCALHOST, so the existing local/manual launch path needs zero changes. Docker Compose sets these per-service to the peer container's own service-DNS name (see docker-compose.yml).

Parameters
env_var_nameName of the environment variable to consult (one of the RTE_EXAMPLE_*_HOST_ENV constants). Must not be NULL.
Returns
The env var's value if set and non-empty; RTE_EXAMPLE_LOCALHOST otherwise. Never NULL.

Definition at line 120 of file site_config.c.