|
RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
|
Lightweight JSON configuration parser for Role C Gateway. More...
#include "gateway_c_config.h"#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "rte/oal/memory/rte_mem_util.h"#include "common/common_config.h"#include "common/rbc_wire_types.h"Go to the source code of this file.
Macros | |
| #define | MAX_CONFIG_FILE_SIZE 8192U |
Functions | |
| static const char * | skip_whitespace (const char *p) |
| static const char * | extract_string (const char *p, char *out, size_t out_size) |
| static const char * | extract_uint32 (const char *p, uint32_t *out_val) |
| static const char * | extract_uint32_checked (const char *p, uint32_t *out_val) |
| Checked unsigned decimal parse, used for the socket buffer keys (REQ-OAL-NETLINK-015). | |
| rte_status_t | gateway_c_config_init_defaults (rte_example_site_t site, gateway_c_config_t *out_cfg) |
| static const char * | skip_separator (const char *p) |
| static const char * | extract_into (const char *p, char *dest, size_t dest_size) |
| static const char * | extract_number_into (const char *p, uint32_t *field) |
| static const char * | extract_buffer_size_into (const char *p, uint32_t *field) |
| static const char * | parse_channel_prop (const char *p, const char *key, gateway_c_config_channel_t *ch, bool allow_identity) |
Parses the value of one channel property into ch. | |
| static const char * | parse_channel_object (const char *p, gateway_c_config_t *cfg, const char *fixed_name) |
Parses one channel object; p points at its '{'. | |
| static const char * | parse_channels_array (const char *p, gateway_c_config_t *cfg) |
| static const char * | parse_channels_object (const char *p, gateway_c_config_t *cfg) |
| static const char * | parse_top_level_value (const char *p, const char *key, gateway_c_config_t *cfg) |
| rte_status_t | gateway_c_config_load_file (const char *filepath, gateway_c_config_t *out_cfg) |
| rte_status_t | gateway_c_config_find_channel (const gateway_c_config_t *cfg, const char *channel_name, rte_netlink_config_t *out_netlink_cfg) |
| rte_status_t | gateway_c_config_find_channel_by_id (const gateway_c_config_t *cfg, uint32_t channel_id, rte_netlink_config_t *out_netlink_cfg) |
Lightweight JSON configuration parser for Role C Gateway.
Definition in file gateway_c_config.c.
| #define MAX_CONFIG_FILE_SIZE 8192U |
Definition at line 17 of file gateway_c_config.c.
|
static |
Definition at line 19 of file gateway_c_config.c.
|
static |
Definition at line 32 of file gateway_c_config.c.
|
static |
Definition at line 60 of file gateway_c_config.c.
|
static |
Checked unsigned decimal parse, used for the socket buffer keys (REQ-OAL-NETLINK-015).
extract_uint32() relies on strtoul(), which accepts a sign ("-1" becomes UINT32_MAX), truncates a value above UINT32_MAX and stops at the first non-digit ("262144 KB" reads as 262144). It is kept unchanged for the older keys; this one rejects instead.
| p | First character of the value (leading whitespace is skipped). |
| out_val | Written only on success. |
Definition at line 87 of file gateway_c_config.c.
| rte_status_t gateway_c_config_init_defaults | ( | rte_example_site_t | site, |
| gateway_c_config_t * | out_cfg ) |
Definition at line 122 of file gateway_c_config.c.
|
static |
Skips whitespace and one optional ',' separator.
Definition at line 140 of file gateway_c_config.c.
|
static |
Copies a string value into a fixed-size channel field (truncating).
Definition at line 151 of file gateway_c_config.c.
|
static |
Parses one numeric channel property; field may be NULL (value is consumed and dropped).
Definition at line 164 of file gateway_c_config.c.
|
static |
Parses one socket buffer size through extract_uint32_checked(); field may be NULL (value checked, dropped).
Definition at line 177 of file gateway_c_config.c.
|
static |
Parses the value of one channel property into ch.
| ch | Target channel, or NULL when the channel table is full (value is consumed and dropped). |
| allow_identity | True for the array form, where "id" and "name" are properties; false for the object form, where the channel name is the enclosing key. |
Definition at line 196 of file gateway_c_config.c.
|
static |
Parses one channel object; p points at its '{'.
| fixed_name | Channel name taken from the enclosing key (object form), or NULL (array form). |
Definition at line 267 of file gateway_c_config.c.
|
static |
Parses "channels": [ {...}, ... ]; p points at '['. Returns pointer past ']' or NULL if malformed.
Definition at line 319 of file gateway_c_config.c.
|
static |
Parses "channels": { "<name>": {...}, ... }; p points at '{'. Returns pointer past '}' or NULL.
Definition at line 351 of file gateway_c_config.c.
|
static |
Dispatches one top-level "key": value pair. Returns pointer past the value, or NULL if malformed.
Definition at line 392 of file gateway_c_config.c.
| rte_status_t gateway_c_config_load_file | ( | const char * | filepath, |
| gateway_c_config_t * | out_cfg ) |
Definition at line 435 of file gateway_c_config.c.
| rte_status_t gateway_c_config_find_channel | ( | const gateway_c_config_t * | cfg, |
| const char * | channel_name, | ||
| rte_netlink_config_t * | out_netlink_cfg ) |
Definition at line 491 of file gateway_c_config.c.
| rte_status_t gateway_c_config_find_channel_by_id | ( | const gateway_c_config_t * | cfg, |
| uint32_t | channel_id, | ||
| rte_netlink_config_t * | out_netlink_cfg ) |
Definition at line 522 of file gateway_c_config.c.