13typedef struct rte_protocol_tcp_state_s
21static rte_status_t tcp_adapter_open(
void *storage,
size_t storage_size,
31 if ((storage == NULL) || (config == NULL) || (out_handle == NULL))
44 if ((ops == NULL) || (ops->
open == NULL) || (ops->
close == NULL))
52 state->os_sockets = ops;
53 state->config = *config;
69 (void)ops->
close(sock);
77 if (ops->
bind == NULL)
79 (void)ops->
close(sock);
83 status = ops->
bind(sock, config->
host[0] !=
'\0' ? config->
host : NULL, config->
port);
86 (void)ops->
close(sock);
95 (void)ops->
close(sock);
102 state->is_connected =
true;
116 uint32_t revents = 0U;
119 if ((state == NULL) || (data == NULL) || (size == 0U))
128 ops = state->os_sockets;
129 if ((ops == NULL) || (ops->
send == NULL))
134 if (ops->
poll != NULL)
147 return ops->
send(state->sock, data, size, &sent);
156 uint32_t revents = 0U;
159 if ((state == NULL) || (out_buf == NULL) || (buffer_size == 0U))
168 ops = state->os_sockets;
169 if ((ops == NULL) || (ops->
recv == NULL))
174 if (ops->
poll != NULL)
187 return ops->
recv(state->sock, out_buf, buffer_size, &recvd);
197 if ((state->os_sockets != NULL) && (state->os_sockets->
close != NULL))
199 (void)state->os_sockets->
close(state->sock);
202 state->is_connected =
false;
const rte_os_socket_ops_t * rte_osadapter_get_socket_ops(void)
Retrieves the active OSAdapter's raw socket operations.
intptr_t rte_os_socket_handle_t
Socket handle representation (pointer or file descriptor).
#define RTE_OS_SOCKET_INVALID_HANDLE
Invalid socket handle sentinel.
@ RTE_OS_SOCKET_EVENT_WRITE
@ RTE_OS_SOCKET_EVENT_READ
const rte_protocol_adapter_ops_t * rte_protocol_adapter_get_tcp(void)
Returns the built-in raw TCP ProtocolAdapter vtable.
struct rte_protocol_impl_s * rte_protocol_handle_t
Opaque protocol handle pointer.
@ RTE_PROTOCOL_ROLE_CONNECT
@ RTE_PROTOCOL_ROLE_LISTEN
rte_status_t
Common result/status codes.
@ RTE_STATUS_INVALID_STATE
@ RTE_STATUS_INVALID_PARAM
@ RTE_STATUS_NOT_SUPPORTED
@ RTE_STATUS_NOT_INITIALIZED
@ RTE_STATUS_RESOURCE_EXHAUSTED
uint32_t rte_duration_ms_t
Thin, MISRA-visible wrappers over the three raw memory-block primitives (fill/copy/compare) every oth...
static void rte_mem_set(void *dest, int value, size_t count)
Fills count bytes starting at dest with value - the one sanctioned call site for libc memset() in thi...
Communication Protocol Adapter Interface (UDP, TCP, DDS).
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(*) 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.
Operations vtable implemented by a concrete ProtocolAdapter.
Configuration passed to open a protocol adapter instance.
uint16_t port
Port (UDP/TCP).
char host[RTE_PROTOCOL_ENDPOINT_STR_MAX]
Host address (UDP/TCP) or domain partition.