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_config.h File Reference

Zero-dependency, statically-allocated configuration parser for Role A/B. More...

#include <stdbool.h>
#include <stdint.h>
#include "rte/oal/netlink/rte_netlink.h"
#include "rte/utils/types/rte_types.h"
#include "../../common/site_config.h"
Include dependency graph for ab_gp_config.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ab_gp_config_channel_t
struct  ab_gp_config_timers_t
struct  ab_gp_config_t

Macros

#define AB_GP_CONFIG_MAX_CHANNELS   16U
#define AB_GP_CONFIG_NAME_MAX_LEN   32U
#define AB_GP_CONFIG_HOST_MAX_LEN   64U

Functions

rte_status_t ab_gp_config_init_defaults (rte_example_site_t site, bool is_role_a, ab_gp_config_t *out_cfg)
 Initializes default configuration in memory based on site and role.
rte_status_t ab_gp_config_load_file (const char *filepath, ab_gp_config_t *out_cfg)
 Parses an INI-style configuration file into the static ab_gp_config_t structure.
rte_status_t ab_gp_config_find_channel (const ab_gp_config_t *cfg, const char *channel_name, rte_netlink_config_t *out_netlink_cfg)
 Resolves netlink configuration for a named channel from the parsed config.
rte_status_t ab_gp_config_find_channel_by_id (const ab_gp_config_t *cfg, uint32_t channel_id, rte_netlink_config_t *out_netlink_cfg)
 Resolves netlink configuration for a channel by numeric ID from the parsed config.

Detailed Description

Zero-dependency, statically-allocated configuration parser for Role A/B.

Compliant with CENELEC EN 50128 SIL 4 and MISRA C:2012. Strictly no dynamic memory allocation.

Definition in file ab_gp_config.h.

Macro Definition Documentation

◆ AB_GP_CONFIG_MAX_CHANNELS

#define AB_GP_CONFIG_MAX_CHANNELS   16U

Definition at line 19 of file ab_gp_config.h.

◆ AB_GP_CONFIG_NAME_MAX_LEN

#define AB_GP_CONFIG_NAME_MAX_LEN   32U

Definition at line 20 of file ab_gp_config.h.

◆ AB_GP_CONFIG_HOST_MAX_LEN

#define AB_GP_CONFIG_HOST_MAX_LEN   64U

Definition at line 21 of file ab_gp_config.h.

Function Documentation

◆ ab_gp_config_init_defaults()

rte_status_t ab_gp_config_init_defaults ( rte_example_site_t site,
bool is_role_a,
ab_gp_config_t * out_cfg )

Initializes default configuration in memory based on site and role.

Definition at line 79 of file ab_gp_config.c.

◆ ab_gp_config_load_file()

rte_status_t ab_gp_config_load_file ( const char * filepath,
ab_gp_config_t * out_cfg )

Parses an INI-style configuration file into the static ab_gp_config_t structure.

Parameters
filepathPath to the configuration file.
out_cfgTarget configuration struct.
Returns
RTE_STATUS_OK on success, or error status code on failure.

Definition at line 228 of file ab_gp_config.c.

◆ ab_gp_config_find_channel()

rte_status_t ab_gp_config_find_channel ( const ab_gp_config_t * cfg,
const char * channel_name,
rte_netlink_config_t * out_netlink_cfg )

Resolves netlink configuration for a named channel from the parsed config.

Parameters
cfgParsed configuration.
channel_nameChannel identifier string (e.g. "ab-peer", "ab-relay-train-0").
out_netlink_cfgReceives resolved netlink configuration.
Returns
RTE_STATUS_OK if found, RTE_STATUS_NOT_FOUND otherwise.

Definition at line 316 of file ab_gp_config.c.

◆ ab_gp_config_find_channel_by_id()

rte_status_t ab_gp_config_find_channel_by_id ( const ab_gp_config_t * cfg,
uint32_t channel_id,
rte_netlink_config_t * out_netlink_cfg )

Resolves netlink configuration for a channel by numeric ID from the parsed config.

Parameters
cfgParsed configuration.
channel_idChannel numeric ID (e.g. 1 for ab-peer).
out_netlink_cfgReceives resolved netlink configuration.
Returns
RTE_STATUS_OK if found, RTE_STATUS_NOT_FOUND otherwise.

Definition at line 345 of file ab_gp_config.c.