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

Shared skeleton for the three Role C gateway service binaries - see gateway_c_common.h. Lifted verbatim from the old single gateway_c.c: only the "call all three handlers" sites became "call this service's one handler" (via gateway_c_service_def_t), and the version-banner / arg-parse from the old main_c.c folded into gateway_c_main(). More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "rte/app/appmanager/rte_appmanager.h"
#include "rte/core/rte_core_version.h"
#include "rte/oal/log/rte_log.h"
#include "rte/oal/memory/rte_mem_util.h"
#include "rte/posix_osadapter/rte_posix_osadapter_channel_service.h"
#include "rte/utils/safestate/rte_safestate.h"
#include "common/app_main_common.h"
#include "common/common_config.h"
#include "common/rbc_util_frame.h"
#include "gateway_c_common.h"
#include "gateway_c_selfstatus.h"
#include "gateway_c_config.h"
#include "gateway_c_types.h"
#include "gateway_c_util.h"
#include "rte_rbc2oo2_version.h"
Include dependency graph for gateway_c_common.c:

Go to the source code of this file.

Functions

static rte_status_t gateway_c_shutdown (void *context)
static rte_status_t resolve_channel_c (const char *name, rte_netlink_config_t *config, void *context)
static void cycle_tick_callback (rte_timer_handle_t handle, void *user_ctx)
static rte_status_t gateway_c_init (void *context)
static void gateway_c_check_channel_down_reboot (gateway_c_context_t *ctx, rte_timestamp_ms_t now_ms)
static rte_status_t gateway_c_execute (void *context)
static const char * gateway_c_get_name (void)
static const char * gateway_c_get_version (void)
static rte_appmanager_config_t gateway_c_common_make_config (rte_example_site_t site, const gateway_c_service_def_t *svc)
int gateway_c_main (int argc, char **argv, const gateway_c_service_def_t *svc)
 Full process entry for a Role C gateway service: prints the version banner, parses argv[1] as {WEST|EAST}, runs app_main_common_init(), then rte_appmanager_run() with a config built from svc. Call once from main().
static uint64_t gateway_c_hash_bytes (const uint8_t *bytes, size_t size)
void gateway_c_dedup_init (gateway_c_dedup_t *dedup)
 Initialize a first-arrival deduplication tracker.
bool gateway_c_dedup_check_and_record (gateway_c_dedup_t *dedup, const uint8_t *bytes, size_t size)
 Check if bytes was already forwarded within the expiry window. If not seen, records bytes with current monotonic timestamp.

Variables

static gateway_c_context_t g_c_ctx
static const gateway_c_service_def_t * g_svc

Detailed Description

Shared skeleton for the three Role C gateway service binaries - see gateway_c_common.h. Lifted verbatim from the old single gateway_c.c: only the "call all three handlers" sites became "call this service's one handler" (via gateway_c_service_def_t), and the version-banner / arg-parse from the old main_c.c folded into gateway_c_main().

Definition in file gateway_c_common.c.

Function Documentation

◆ gateway_c_shutdown()

rte_status_t gateway_c_shutdown ( void * context)
static

Definition at line 321 of file gateway_c_common.c.

◆ resolve_channel_c()

rte_status_t resolve_channel_c ( const char * name,
rte_netlink_config_t * config,
void * context )
static

Definition at line 39 of file gateway_c_common.c.

◆ cycle_tick_callback()

void cycle_tick_callback ( rte_timer_handle_t handle,
void * user_ctx )
static

Definition at line 174 of file gateway_c_common.c.

◆ gateway_c_init()

rte_status_t gateway_c_init ( void * context)
static

Definition at line 181 of file gateway_c_common.c.

◆ gateway_c_check_channel_down_reboot()

void gateway_c_check_channel_down_reboot ( gateway_c_context_t * ctx,
rte_timestamp_ms_t now_ms )
static

Definition at line 262 of file gateway_c_common.c.

◆ gateway_c_execute()

rte_status_t gateway_c_execute ( void * context)
static

Definition at line 279 of file gateway_c_common.c.

◆ gateway_c_get_name()

const char * gateway_c_get_name ( void )
static

Definition at line 340 of file gateway_c_common.c.

◆ gateway_c_get_version()

const char * gateway_c_get_version ( void )
static

Definition at line 345 of file gateway_c_common.c.

◆ gateway_c_common_make_config()

rte_appmanager_config_t gateway_c_common_make_config ( rte_example_site_t site,
const gateway_c_service_def_t * svc )
static

Definition at line 350 of file gateway_c_common.c.

◆ gateway_c_main()

int gateway_c_main ( int argc,
char ** argv,
const gateway_c_service_def_t * svc )

Full process entry for a Role C gateway service: prints the version banner, parses argv[1] as {WEST|EAST}, runs app_main_common_init(), then rte_appmanager_run() with a config built from svc. Call once from main().

Parameters
argcFrom main().
argvFrom main(); argv[1] must be "WEST" or "EAST".
svcThis service's definition. Must not be NULL; all its mandatory function-pointer fields must be set.
Returns
Process exit code (0 on clean shutdown, 1 on any setup failure).

Definition at line 376 of file gateway_c_common.c.

◆ gateway_c_hash_bytes()

uint64_t gateway_c_hash_bytes ( const uint8_t * bytes,
size_t size )
static

Definition at line 418 of file gateway_c_common.c.

◆ gateway_c_dedup_init()

void gateway_c_dedup_init ( gateway_c_dedup_t * dedup)

Initialize a first-arrival deduplication tracker.

Definition at line 430 of file gateway_c_common.c.

◆ gateway_c_dedup_check_and_record()

bool gateway_c_dedup_check_and_record ( gateway_c_dedup_t * dedup,
const uint8_t * bytes,
size_t size )

Check if bytes was already forwarded within the expiry window. If not seen, records bytes with current monotonic timestamp.

Returns
true if duplicate (drop it); false if first arrival (forward it).

Definition at line 438 of file gateway_c_common.c.

Variable Documentation

◆ g_c_ctx

gateway_c_context_t g_c_ctx
static

Definition at line 31 of file gateway_c_common.c.

◆ g_svc

const gateway_c_service_def_t* g_svc
static

The service this process runs as - set once by gateway_c_common_make_config() before rte_appmanager_run(), read by every ops callback and the channel-down check below.

Definition at line 35 of file gateway_c_common.c.