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_osadapter_socket.h
Go to the documentation of this file.
1
18#ifndef RTE_OSADAPTER_SOCKET_H
19#define RTE_OSADAPTER_SOCKET_H
20
21#include <stddef.h>
22#include <stdint.h>
23#include <stdbool.h>
24
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
33#define RTE_OS_SOCKET_INVALID_HANDLE ((intptr_t)(-1))
34
36typedef intptr_t rte_os_socket_handle_t;
37
41typedef enum rte_os_socket_type_e
42{
46
56
60typedef struct rte_os_socket_ops_s
61{
77
84 rte_status_t (*bind)(rte_os_socket_handle_t handle, const char *host, uint16_t port);
85
92 rte_status_t (*connect)(rte_os_socket_handle_t handle, const char *host, uint16_t port);
93
101 rte_status_t (*send)(rte_os_socket_handle_t handle, const void *buf, size_t len, size_t *out_sent);
102
112 rte_status_t (*sendto)(rte_os_socket_handle_t handle, const void *buf, size_t len,
113 const char *host, uint16_t port, size_t *out_sent);
114
122 rte_status_t (*recv)(rte_os_socket_handle_t handle, void *buf, size_t len, size_t *out_recv);
123
134 rte_status_t (*recvfrom)(rte_os_socket_handle_t handle, void *buf, size_t len,
135 char *out_host, size_t host_len, uint16_t *out_port, size_t *out_recv);
136
144 rte_status_t (*poll)(rte_os_socket_handle_t handle, uint32_t events,
145 rte_duration_ms_t timeout_ms, uint32_t *out_revents);
146
158
164
166
173
179
180#ifdef __cplusplus
181}
182#endif
183
184#endif /* RTE_OSADAPTER_SOCKET_H */
185
const rte_os_socket_ops_t * rte_osadapter_get_socket_ops(void)
Retrieves the active OSAdapter's raw socket operations.
rte_os_socket_type_t
Socket transport type.
intptr_t rte_os_socket_handle_t
Socket handle representation (pointer or file descriptor).
rte_status_t rte_osadapter_register_socket_ops(const rte_os_socket_ops_t *ops)
Registers the active OSAdapter's raw socket operations.
rte_os_socket_event_t
Polling events bitmask.
@ RTE_OS_SOCKET_TYPE_TCP
@ RTE_OS_SOCKET_TYPE_UDP
@ RTE_OS_SOCKET_EVENT_ERROR
@ RTE_OS_SOCKET_EVENT_WRITE
@ RTE_OS_SOCKET_EVENT_READ
rte_status_t
Common result/status codes.
Definition rte_status.h:27
uint32_t rte_duration_ms_t
Definition rte_types.h:27
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
Vtable of low-level OS socket operations implemented by an OSAdapter.
rte_status_t(*) open(rte_os_socket_type_t type, rte_os_socket_handle_t *out_handle)
Creates a raw socket of the specified type, non-blocking from creation (REQ-OAL-SOCKET-001,...
rte_status_t(*) recv(rte_os_socket_handle_t handle, void *buf, size_t len, size_t *out_recv)
Receives data from a connected socket.
rte_status_t(*) sendto(rte_os_socket_handle_t handle, const void *buf, size_t len, const char *host, uint16_t port, size_t *out_sent)
Sends a datagram to a specific remote host and port.
rte_status_t(*) recvfrom(rte_os_socket_handle_t handle, void *buf, size_t len, char *out_host, size_t host_len, uint16_t *out_port, size_t *out_recv)
Receives a datagram and captures sender endpoint.
rte_status_t(*) set_nonblocking(rte_os_socket_handle_t handle, bool nonblocking)
Configures non-blocking mode on socket.
rte_status_t(*) connect(rte_os_socket_handle_t handle, const char *host, uint16_t port)
Connects a socket to a remote host and port.
rte_status_t(*) bind(rte_os_socket_handle_t handle, const char *host, uint16_t port)
Binds a socket to a local host and port.
rte_status_t(*) poll(rte_os_socket_handle_t handle, uint32_t events, rte_duration_ms_t timeout_ms, uint32_t *out_revents)
Polls a socket for I/O readiness with timeout.
rte_status_t(*) send(rte_os_socket_handle_t handle, const void *buf, size_t len, size_t *out_sent)
Sends data on a connected socket.
rte_status_t(*) close(rte_os_socket_handle_t handle)
Closes a socket handle.