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_protocol_adapter.c
Go to the documentation of this file.
1
7
9
10static const rte_protocol_adapter_ops_t *s_udp_adapter = NULL;
11static const rte_protocol_adapter_ops_t *s_tcp_adapter = NULL;
12static const rte_protocol_adapter_ops_t *s_dds_adapter = NULL;
13
16{
17 if (ops == NULL)
18 {
20 }
21
22 switch (type)
23 {
25 s_udp_adapter = ops;
26 break;
27
29 s_tcp_adapter = ops;
30 break;
31
33 s_dds_adapter = ops;
34 break;
35
36 default:
38 }
39
40 return RTE_STATUS_OK;
41}
42
44{
45 switch (type)
46 {
48 return (s_udp_adapter != NULL) ? s_udp_adapter : rte_protocol_adapter_get_udp();
49
51 return (s_tcp_adapter != NULL) ? s_tcp_adapter : rte_protocol_adapter_get_tcp();
52
54 return s_dds_adapter;
55
56 default:
57 return NULL;
58 }
59}
const rte_protocol_adapter_ops_t * rte_protocol_adapter_get(rte_protocol_type_t type)
Retrieves the registered ProtocolAdapter for a given protocol type.
const rte_protocol_adapter_ops_t * rte_protocol_adapter_get_udp(void)
Returns the built-in raw UDP ProtocolAdapter vtable.
const rte_protocol_adapter_ops_t * rte_protocol_adapter_get_tcp(void)
Returns the built-in raw TCP ProtocolAdapter vtable.
rte_status_t rte_protocol_adapter_register(rte_protocol_type_t type, const rte_protocol_adapter_ops_t *ops)
Registers a ProtocolAdapter implementation for a given protocol type.
rte_protocol_type_t
Protocol transport identifier.
@ RTE_PROTOCOL_TYPE_RAW_UDP
@ RTE_PROTOCOL_TYPE_DDS
@ RTE_PROTOCOL_TYPE_RAW_TCP
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
Communication Protocol Adapter Interface (UDP, TCP, DDS).
Operations vtable implemented by a concrete ProtocolAdapter.