Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_flow.c
Go to the documentation of this file.
1
11
13
15
18static const rte_osadapter_flow_t *s_osadapter = NULL;
19
21
23static bool oflags_select_exactly_one_role(uint32_t oflags);
24
30static bool oflags_select_exactly_one_role(uint32_t oflags)
31{
32 uint32_t role_bits = oflags & ((uint32_t)RTE_FLOW_O_REQUESTER | (uint32_t)RTE_FLOW_O_RESPONDER |
33 (uint32_t)RTE_FLOW_O_PUBLISHER | (uint32_t)RTE_FLOW_O_SUBSCRIBER);
34
35 return (role_bits != 0U) && ((role_bits & (role_bits - 1U)) == 0U);
36}
37
40{
41 rte_status_t lifecycle_status;
42
43 if (osadapter == NULL)
44 {
46 }
47 /* REQ-LIFECYCLE-001 (ADR-026): registering an OSAdapter is a setup-only
48 * action - refuse once the application's setup phase has been locked. */
49 lifecycle_status = rte_lifecycle_check_setup_allowed();
50 if (lifecycle_status != RTE_STATUS_OK)
51 {
52 return lifecycle_status;
53 }
54 s_osadapter = osadapter;
55 return RTE_STATUS_OK;
56}
57
58rte_status_t rte_flow_open(rte_flow_storage_t *storage,
59 const rte_flow_config_t *config,
60 rte_flow_handle_t *out_handle)
61{
62 if ((storage == NULL) || (config == NULL) || (out_handle == NULL))
63 {
65 }
66 if ((config->name == NULL) || (config->message_size == 0U))
67 {
69 }
71 {
73 }
74 *out_handle = NULL;
75 if (s_osadapter == NULL)
76 {
78 }
79 if (s_osadapter->open == NULL)
80 {
82 }
83 return s_osadapter->open(storage, config, out_handle);
84}
85
87 const void *data,
88 size_t data_size,
89 rte_flow_channel_t channel,
90 rte_duration_ms_t timeout_ms)
91{
92 if ((handle == NULL) || (data == NULL) || (data_size == 0U))
93 {
95 }
96 if ((channel != RTE_FLOW_CHANNEL_USER) && (channel != RTE_FLOW_CHANNEL_CTRL))
97 {
99 }
100 if (s_osadapter == NULL)
101 {
103 }
104 if (s_osadapter->send == NULL)
105 {
107 }
108 return s_osadapter->send(handle, data, data_size, channel, timeout_ms);
109}
110
112 void *out_data,
113 size_t buffer_size,
114 rte_flow_channel_t *out_channel,
115 rte_duration_ms_t timeout_ms)
116{
117 if ((handle == NULL) || (out_data == NULL) || (buffer_size == 0U))
118 {
120 }
121 if (s_osadapter == NULL)
122 {
124 }
125 if (s_osadapter->receive == NULL)
126 {
128 }
129 return s_osadapter->receive(handle, out_data, buffer_size, out_channel, timeout_ms);
130}
131
133{
134 if (handle == NULL)
135 {
137 }
138 if (s_osadapter == NULL)
139 {
141 }
142 if (s_osadapter->close == NULL)
143 {
145 }
146 return s_osadapter->close(handle);
147}
148
150{
151 if ((handle == NULL) || (out_attr == NULL))
152 {
154 }
155 if (s_osadapter == NULL)
156 {
158 }
159 if (s_osadapter->getattr == NULL)
160 {
162 }
163 return s_osadapter->getattr(handle, out_attr);
164}
165
167 const rte_flow_attr_t *new_attr,
168 rte_flow_attr_t *out_old_attr)
169{
170 if ((handle == NULL) || (new_attr == NULL))
171 {
173 }
174 if (s_osadapter == NULL)
175 {
177 }
178 if (s_osadapter->setattr == NULL)
179 {
181 }
182 return s_osadapter->setattr(handle, new_attr, out_old_attr);
183}
rte_status_t rte_flow_send(rte_flow_handle_t handle, const void *data, size_t data_size, rte_flow_channel_t channel, rte_duration_ms_t timeout_ms)
Sends one fixed-size message on the given channel, blocking at most timeout_ms.
Definition rte_flow.c:86
rte_status_t rte_flow_close(rte_flow_handle_t handle)
Closes (leaves/unregisters/unsubscribes from) a Flow.
Definition rte_flow.c:132
rte_status_t rte_flow_receive(rte_flow_handle_t handle, void *out_data, size_t buffer_size, rte_flow_channel_t *out_channel, rte_duration_ms_t timeout_ms)
Receives one fixed-size message, blocking at most timeout_ms.
Definition rte_flow.c:111
rte_status_t rte_flow_getattr(rte_flow_handle_t handle, rte_flow_attr_t *out_attr)
Reads this Flow's current (static and dynamic) attributes.
Definition rte_flow.c:149
rte_status_t rte_flow_open(rte_flow_storage_t *storage, const rte_flow_config_t *config, rte_flow_handle_t *out_handle)
Opens (joins/registers/subscribes to, per OCORA's own fl_open() doc) a named Flow.
Definition rte_flow.c:58
rte_flow_channel_t
Message-channel discriminator, matching OCORA PI API Annex A.1's e_fl_channels: a Flow can carry ordi...
Definition rte_flow.h:97
struct rte_flow_impl_s * rte_flow_handle_t
Opaque handle to an opened Flow, returned by rte_flow_open().
Definition rte_flow.h:71
rte_status_t rte_flow_setattr(rte_flow_handle_t handle, const rte_flow_attr_t *new_attr, rte_flow_attr_t *out_old_attr)
Sets this Flow's mutable (dynamic) attributes.
Definition rte_flow.c:166
@ RTE_FLOW_CHANNEL_CTRL
Definition rte_flow.h:99
@ RTE_FLOW_CHANNEL_USER
Definition rte_flow.h:98
@ RTE_FLOW_O_RESPONDER
Definition rte_flow.h:82
@ RTE_FLOW_O_SUBSCRIBER
Definition rte_flow.h:84
@ RTE_FLOW_O_PUBLISHER
Definition rte_flow.h:83
@ RTE_FLOW_O_REQUESTER
Definition rte_flow.h:81
rte_status_t rte_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
rte_status_t
Common result/status codes.
Definition rte_status.h:27
@ RTE_STATUS_OK
Definition rte_status.h:28
@ RTE_STATUS_INVALID_PARAM
Definition rte_status.h:29
@ RTE_STATUS_NOT_SUPPORTED
Definition rte_status.h:34
@ RTE_STATUS_NOT_INITIALIZED
Definition rte_status.h:30
uint32_t rte_duration_ms_t
Definition rte_types.h:27
static const rte_osadapter_clocksync_t * s_osadapter
static bool oflags_select_exactly_one_role(uint32_t oflags)
Exactly one of PUBLISHER/SUBSCRIBER/REQUESTER/RESPONDER must be set - a Flow has one,...
Definition rte_flow.c:30
OS Abstraction Layer - OCORA PI-API-compatible Flow service.
Process-wide application setup-phase lock (ADR-026).
OSAdapter interface for OCORA PI-API Flow communication.
rte_status_t rte_osadapter_flow_register(const rte_osadapter_flow_t *adapter)
Registers the OSAdapter Flow implementation.
Definition rte_flow.c:39
Flow attributes (OCORA PI API Annex A.1 leaves fl_attr's content as "to be defined" - this is this fr...
Definition rte_flow.h:109
Configuration for rte_flow_open().
Definition rte_flow.h:119
const char * name
Definition rte_flow.h:124
size_t message_size
Definition rte_flow.h:129
uint32_t oflags
Definition rte_flow.h:127
OSAdapter Flow operations vtable.