Safe API Framework
0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_protocol_adapter.c
Go to the documentation of this file.
1
7
8
#include "
rte/oal/protocol/rte_protocol_adapter.h
"
9
10
static
const
rte_protocol_adapter_ops_t
*s_udp_adapter = NULL;
11
static
const
rte_protocol_adapter_ops_t
*s_tcp_adapter = NULL;
12
static
const
rte_protocol_adapter_ops_t
*s_dds_adapter = NULL;
13
14
rte_status_t
rte_protocol_adapter_register
(
rte_protocol_type_t
type,
15
const
rte_protocol_adapter_ops_t
*ops)
16
{
17
if
(ops == NULL)
18
{
19
return
RTE_STATUS_INVALID_PARAM
;
20
}
21
22
switch
(type)
23
{
24
case
RTE_PROTOCOL_TYPE_RAW_UDP
:
25
s_udp_adapter = ops;
26
break
;
27
28
case
RTE_PROTOCOL_TYPE_RAW_TCP
:
29
s_tcp_adapter = ops;
30
break
;
31
32
case
RTE_PROTOCOL_TYPE_DDS
:
33
s_dds_adapter = ops;
34
break
;
35
36
default
:
37
return
RTE_STATUS_INVALID_PARAM
;
38
}
39
40
return
RTE_STATUS_OK
;
41
}
42
43
const
rte_protocol_adapter_ops_t
*
rte_protocol_adapter_get
(
rte_protocol_type_t
type)
44
{
45
switch
(type)
46
{
47
case
RTE_PROTOCOL_TYPE_RAW_UDP
:
48
return
(s_udp_adapter != NULL) ? s_udp_adapter :
rte_protocol_adapter_get_udp
();
49
50
case
RTE_PROTOCOL_TYPE_RAW_TCP
:
51
return
(s_tcp_adapter != NULL) ? s_tcp_adapter :
rte_protocol_adapter_get_tcp
();
52
53
case
RTE_PROTOCOL_TYPE_DDS
:
54
return
s_dds_adapter;
55
56
default
:
57
return
NULL;
58
}
59
}
rte_protocol_adapter_get
const rte_protocol_adapter_ops_t * rte_protocol_adapter_get(rte_protocol_type_t type)
Retrieves the registered ProtocolAdapter for a given protocol type.
Definition
rte_protocol_adapter.c:43
rte_protocol_adapter_get_udp
const rte_protocol_adapter_ops_t * rte_protocol_adapter_get_udp(void)
Returns the built-in raw UDP ProtocolAdapter vtable.
Definition
rte_protocol_adapter_udp.c:253
rte_protocol_adapter_get_tcp
const rte_protocol_adapter_ops_t * rte_protocol_adapter_get_tcp(void)
Returns the built-in raw TCP ProtocolAdapter vtable.
Definition
rte_protocol_adapter_tcp.c:213
rte_protocol_adapter_register
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.
Definition
rte_protocol_adapter.c:14
rte_protocol_type_t
rte_protocol_type_t
Protocol transport identifier.
Definition
rte_protocol_adapter.h:42
RTE_PROTOCOL_TYPE_RAW_UDP
@ RTE_PROTOCOL_TYPE_RAW_UDP
Definition
rte_protocol_adapter.h:43
RTE_PROTOCOL_TYPE_DDS
@ RTE_PROTOCOL_TYPE_DDS
Definition
rte_protocol_adapter.h:45
RTE_PROTOCOL_TYPE_RAW_TCP
@ RTE_PROTOCOL_TYPE_RAW_TCP
Definition
rte_protocol_adapter.h:44
rte_status_t
rte_status_t
Common result/status codes.
Definition
rte_status.h:27
RTE_STATUS_OK
@ RTE_STATUS_OK
Definition
rte_status.h:28
RTE_STATUS_INVALID_PARAM
@ RTE_STATUS_INVALID_PARAM
Definition
rte_status.h:29
rte_protocol_adapter.h
Communication Protocol Adapter Interface (UDP, TCP, DDS).
rte_protocol_adapter_ops_t
Operations vtable implemented by a concrete ProtocolAdapter.
Definition
rte_protocol_adapter.h:99
src
oal
protocol
rte_protocol_adapter.c
Generated by
1.18.0