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_os_socket_ops_t Struct Reference

Vtable of low-level OS socket operations implemented by an OSAdapter. More...

#include <rte_osadapter_socket.h>

Data Fields

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, OSA rule R5).
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(*) 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(*) 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(*) 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(*) 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(*) 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(*) 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(*) set_nonblocking (rte_os_socket_handle_t handle, bool nonblocking)
 Configures non-blocking mode on socket.
rte_status_t(*) close (rte_os_socket_handle_t handle)
 Closes a socket handle.

Detailed Description

Vtable of low-level OS socket operations implemented by an OSAdapter.

Definition at line 60 of file rte_osadapter_socket.h.

Field Documentation

◆ open

rte_status_t(*) rte_os_socket_ops_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, OSA rule R5).

Post-condition of RTE_STATUS_OK: *out_handle holds a non-blocking socket, so an I/O call that cannot complete at once returns instead of waiting; set_nonblocking(false) can still switch it to blocking. An OSAdapter that cannot make the socket non-blocking releases it and never hands out a blocking socket.

Parameters
typeRTE_OS_SOCKET_TYPE_UDP or RTE_OS_SOCKET_TYPE_TCP.
out_handleOutput socket handle. Must not be NULL. Written only on RTE_STATUS_OK.
Returns
RTE_STATUS_OK with a non-blocking socket in *out_handle; RTE_STATUS_INVALID_PARAM if out_handle is NULL; RTE_STATUS_NOT_SUPPORTED for an unknown type; RTE_STATUS_INTERNAL_ERROR if the platform cannot create the socket or cannot make it non-blocking (the socket is then released). On every error *out_handle is not written.

Definition at line 76 of file rte_osadapter_socket.h.

◆ bind

rte_status_t(*) rte_os_socket_ops_t::bind(rte_os_socket_handle_t handle, const char *host, uint16_t port)

Binds a socket to a local host and port.

Parameters
handleValid socket handle.
hostLocal IP address string (e.g. "127.0.0.1" or NULL for INADDR_ANY).
portLocal port in host byte order.

Definition at line 84 of file rte_osadapter_socket.h.

◆ connect

rte_status_t(*) rte_os_socket_ops_t::connect(rte_os_socket_handle_t handle, const char *host, uint16_t port)

Connects a socket to a remote host and port.

Parameters
handleValid socket handle.
hostRemote IP address string (e.g. "127.0.0.1"). Must not be NULL.
portRemote port in host byte order.

Definition at line 92 of file rte_osadapter_socket.h.

◆ send

rte_status_t(*) rte_os_socket_ops_t::send(rte_os_socket_handle_t handle, const void *buf, size_t len, size_t *out_sent)

Sends data on a connected socket.

Parameters
handleValid connected socket handle.
bufBuffer containing data to send. Must not be NULL.
lenNumber of bytes to send.
out_sentOptional output parameter receiving bytes actually sent.

Definition at line 101 of file rte_osadapter_socket.h.

◆ sendto

rte_status_t(*) rte_os_socket_ops_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.

Parameters
handleValid socket handle.
bufBuffer containing datagram to send. Must not be NULL.
lenNumber of bytes to send.
hostDestination IP address string. Must not be NULL.
portDestination port in host byte order.
out_sentOptional output parameter receiving bytes actually sent.

Definition at line 112 of file rte_osadapter_socket.h.

◆ recv

rte_status_t(*) rte_os_socket_ops_t::recv(rte_os_socket_handle_t handle, void *buf, size_t len, size_t *out_recv)

Receives data from a connected socket.

Parameters
handleValid connected socket handle.
bufBuffer receiving data. Must not be NULL.
lenMaximum bytes to receive.
out_recvOutput parameter receiving bytes actually received. Must not be NULL.

Definition at line 122 of file rte_osadapter_socket.h.

◆ recvfrom

rte_status_t(*) rte_os_socket_ops_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.

Parameters
handleValid socket handle.
bufBuffer receiving datagram. Must not be NULL.
lenMaximum bytes to receive.
out_hostBuffer to store sender IP address string (may be NULL).
host_lenCapacity of out_host buffer.
out_portPointer to store sender port (may be NULL).
out_recvOutput parameter receiving bytes actually received. Must not be NULL.

Definition at line 134 of file rte_osadapter_socket.h.

◆ poll

rte_status_t(*) rte_os_socket_ops_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.

Parameters
handleValid socket handle.
eventsBitmask of RTE_OS_SOCKET_EVENT_* to monitor.
timeout_msMaximum time to wait in milliseconds.
out_reventsOutput bitmask of events ready. Must not be NULL.

Definition at line 144 of file rte_osadapter_socket.h.

◆ set_nonblocking

rte_status_t(*) rte_os_socket_ops_t::set_nonblocking(rte_os_socket_handle_t handle, bool nonblocking)

Configures non-blocking mode on socket.

open() already delivers a non-blocking socket (REQ-OAL-SOCKET-001); set_nonblocking(true) on a fresh socket confirms that mode, set_nonblocking(false) switches it to blocking.

Parameters
handleValid socket handle.
nonblockingTrue for non-blocking, false for blocking.
Returns
RTE_STATUS_OK when the requested mode is set; otherwise the OSAdapter's error status (e.g. RTE_STATUS_INVALID_PARAM for an invalid handle, RTE_STATUS_INTERNAL_ERROR for a platform failure).

Definition at line 157 of file rte_osadapter_socket.h.

◆ close

rte_status_t(*) rte_os_socket_ops_t::close(rte_os_socket_handle_t handle)

Closes a socket handle.

Parameters
handleValid socket handle.

Definition at line 163 of file rte_osadapter_socket.h.


The documentation for this struct was generated from the following file: