|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
BSD-like socket API, DNS resolution, and network interface control. More...
Data Structures | |
| struct | ove_sockaddr_t |
| Generic socket address (large enough for IPv4 or IPv6). More... | |
| struct | ove_netif_config_t |
| Network interface configuration. More... | |
Enumerations | |
| enum | ove_sock_type_t { OVE_SOCK_STREAM = 1 , OVE_SOCK_DGRAM = 2 } |
| Socket type. More... | |
| enum | ove_af_t { OVE_AF_INET = 2 , OVE_AF_INET6 = 10 } |
| Address family. More... | |
Functions | |
| int | ove_netif_init (ove_netif_t *netif, ove_netif_storage_t *storage) |
| Initialise a network interface from caller-supplied storage. | |
| void | ove_netif_deinit (ove_netif_t netif) |
| De-initialise a network interface. | |
| int | ove_netif_up (ove_netif_t netif, const ove_netif_config_t *cfg) |
| Bring the network interface up. | |
| void | ove_netif_down (ove_netif_t netif) |
| Tear down the network interface. | |
| int | ove_netif_get_addr (ove_netif_t netif, ove_sockaddr_t *ip, ove_sockaddr_t *gateway, ove_sockaddr_t *netmask) |
| Query the current addresses of a network interface. | |
| int | ove_netif_create (ove_netif_t *netif) |
| Heap-allocate and initialise a network interface. | |
| void | ove_netif_destroy (ove_netif_t netif) |
| Destroy a heap-allocated network interface. | |
| int | ove_socket_open (ove_socket_t *sock, ove_socket_storage_t *storage, ove_af_t af, ove_sock_type_t type) |
| Open a socket from caller-supplied storage. | |
| void | ove_socket_close (ove_socket_t sock) |
| Close a socket. | |
| int | ove_socket_connect (ove_socket_t sock, const ove_sockaddr_t *addr, uint64_t timeout_ns) |
| Connect a socket to a remote address. | |
| int | ove_socket_bind (ove_socket_t sock, const ove_sockaddr_t *addr) |
| Bind a socket to a local address. | |
| int | ove_socket_listen (ove_socket_t sock, int backlog) |
| Mark a bound socket as listening for incoming connections. | |
| int | ove_socket_accept (ove_socket_t sock, ove_socket_t *client, ove_socket_storage_t *client_storage, uint64_t timeout_ns) |
| Accept an incoming connection on a listening socket. | |
| int | ove_socket_send (ove_socket_t sock, const void *data, size_t len, size_t *sent) |
| Send data on a connected socket. | |
| int | ove_socket_recv (ove_socket_t sock, void *buf, size_t len, size_t *received, uint64_t timeout_ns) |
| Receive data from a connected socket. | |
| int | ove_socket_sendto (ove_socket_t sock, const void *data, size_t len, size_t *sent, const ove_sockaddr_t *dest) |
| Send a datagram to a specific destination. | |
| int | ove_socket_recvfrom (ove_socket_t sock, void *buf, size_t len, size_t *received, ove_sockaddr_t *src, uint64_t timeout_ns) |
| Receive a datagram and the sender's address. | |
| int | ove_socket_create (ove_socket_t *sock, ove_af_t af, ove_sock_type_t type) |
| Heap-allocate and open a socket. | |
| void | ove_socket_destroy (ove_socket_t sock) |
| Destroy a heap-allocated socket. | |
| int | ove_dns_resolve (const char *hostname, ove_sockaddr_t *addr, uint64_t timeout_ns) |
| Resolve a hostname to an address. | |
| void | ove_sockaddr_ipv4 (ove_sockaddr_t *addr, uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint16_t port) |
| Fill a sockaddr from IPv4 address components. | |
BSD-like socket API, DNS resolution, and network interface control.
Provides TCP/UDP sockets, DNS name resolution, and network interface management. Each RTOS backend implements the socket layer using its native TCP/IP stack (POSIX sockets, lwIP, Zephyr net, NuttX sockets).
CONFIG_OVE_NET. When the option is disabled every function is replaced by a no-op stub that returns OVE_ERR_NOT_SUPPORTED. | enum ove_sock_type_t |
| enum ove_af_t |
| int ove_netif_init | ( | ove_netif_t * | netif, |
| ove_netif_storage_t * | storage | ||
| ) |
Initialise a network interface from caller-supplied storage.
| [out] | netif | Handle written on success. |
| [in] | storage | Caller-allocated storage. |
| void ove_netif_deinit | ( | ove_netif_t | netif | ) |
De-initialise a network interface.
| [in] | netif | Handle returned by ove_netif_init(). |
| int ove_netif_up | ( | ove_netif_t | netif, |
| const ove_netif_config_t * | cfg | ||
| ) |
Bring the network interface up.
| [in] | netif | Handle returned by ove_netif_init(). |
| [in] | cfg | Interface configuration (DHCP or static). |
| void ove_netif_down | ( | ove_netif_t | netif | ) |
Tear down the network interface.
| [in] | netif | Handle returned by ove_netif_init(). |
| int ove_netif_get_addr | ( | ove_netif_t | netif, |
| ove_sockaddr_t * | ip, | ||
| ove_sockaddr_t * | gateway, | ||
| ove_sockaddr_t * | netmask | ||
| ) |
Query the current addresses of a network interface.
| [in] | netif | Handle returned by ove_netif_init(). |
| [out] | ip | Current IPv4 address (may be NULL). |
| [out] | gateway | Current gateway address (may be NULL). |
| [out] | netmask | Current subnet mask (may be NULL). |
| int ove_netif_create | ( | ove_netif_t * | netif | ) |
Heap-allocate and initialise a network interface.
| [out] | netif | Handle written on success. |
| void ove_netif_destroy | ( | ove_netif_t | netif | ) |
Destroy a heap-allocated network interface.
| [in] | netif | Handle returned by ove_netif_create(). |
| int ove_socket_open | ( | ove_socket_t * | sock, |
| ove_socket_storage_t * | storage, | ||
| ove_af_t | af, | ||
| ove_sock_type_t | type | ||
| ) |
Open a socket from caller-supplied storage.
| [out] | sock | Handle written on success. |
| [in] | storage | Caller-allocated storage. |
| [in] | af | Address family. |
| [in] | type | Socket type (TCP or UDP). |
| void ove_socket_close | ( | ove_socket_t | sock | ) |
Close a socket.
| [in] | sock | Handle returned by ove_socket_open(). |
| int ove_socket_connect | ( | ove_socket_t | sock, |
| const ove_sockaddr_t * | addr, | ||
| uint64_t | timeout_ns | ||
| ) |
Connect a socket to a remote address.
| [in] | sock | Socket handle. |
| [in] | addr | Remote address. |
| [in] | timeout_ns | Timeout in nanoseconds (OVE_WAIT_FOREVER to block). |
| int ove_socket_bind | ( | ove_socket_t | sock, |
| const ove_sockaddr_t * | addr | ||
| ) |
Bind a socket to a local address.
| [in] | sock | Socket handle. |
| [in] | addr | Local address to bind. |
| int ove_socket_listen | ( | ove_socket_t | sock, |
| int | backlog | ||
| ) |
Mark a bound socket as listening for incoming connections.
| [in] | sock | Socket handle. |
| [in] | backlog | Maximum pending connection queue length. |
| int ove_socket_accept | ( | ove_socket_t | sock, |
| ove_socket_t * | client, | ||
| ove_socket_storage_t * | client_storage, | ||
| uint64_t | timeout_ns | ||
| ) |
Accept an incoming connection on a listening socket.
| [in] | sock | Listening socket handle. |
| [out] | client | Handle for the accepted connection. |
| [in] | client_storage | Caller-allocated storage for the new socket. |
| [in] | timeout_ns | Timeout in nanoseconds. |
| int ove_socket_send | ( | ove_socket_t | sock, |
| const void * | data, | ||
| size_t | len, | ||
| size_t * | sent | ||
| ) |
Send data on a connected socket.
| [in] | sock | Socket handle. |
| [in] | data | Pointer to data to send. |
| [in] | len | Number of bytes to send. |
| [out] | sent | Number of bytes actually sent (may be NULL). |
| int ove_socket_recv | ( | ove_socket_t | sock, |
| void * | buf, | ||
| size_t | len, | ||
| size_t * | received, | ||
| uint64_t | timeout_ns | ||
| ) |
Receive data from a connected socket.
| [in] | sock | Socket handle. |
| [out] | buf | Buffer to receive into. |
| [in] | len | Buffer size in bytes. |
| [out] | received | Number of bytes received (may be NULL). |
| [in] | timeout_ns | Timeout in nanoseconds. |
| int ove_socket_sendto | ( | ove_socket_t | sock, |
| const void * | data, | ||
| size_t | len, | ||
| size_t * | sent, | ||
| const ove_sockaddr_t * | dest | ||
| ) |
Send a datagram to a specific destination.
| [in] | sock | Socket handle (UDP). |
| [in] | data | Pointer to data to send. |
| [in] | len | Number of bytes to send. |
| [out] | sent | Number of bytes actually sent (may be NULL). |
| [in] | dest | Destination address. |
| int ove_socket_recvfrom | ( | ove_socket_t | sock, |
| void * | buf, | ||
| size_t | len, | ||
| size_t * | received, | ||
| ove_sockaddr_t * | src, | ||
| uint64_t | timeout_ns | ||
| ) |
Receive a datagram and the sender's address.
| [in] | sock | Socket handle (UDP). |
| [out] | buf | Buffer to receive into. |
| [in] | len | Buffer size in bytes. |
| [out] | received | Number of bytes received (may be NULL). |
| [out] | src | Filled with sender's address (may be NULL). |
| [in] | timeout_ns | Timeout in nanoseconds. |
| int ove_socket_create | ( | ove_socket_t * | sock, |
| ove_af_t | af, | ||
| ove_sock_type_t | type | ||
| ) |
Heap-allocate and open a socket.
| [out] | sock | Handle written on success. |
| [in] | af | Address family. |
| [in] | type | Socket type. |
| void ove_socket_destroy | ( | ove_socket_t | sock | ) |
Destroy a heap-allocated socket.
| [in] | sock | Handle returned by ove_socket_create(). |
| int ove_dns_resolve | ( | const char * | hostname, |
| ove_sockaddr_t * | addr, | ||
| uint64_t | timeout_ns | ||
| ) |
Resolve a hostname to an address.
| [in] | hostname | Null-terminated hostname string. |
| [out] | addr | Resolved address written here. |
| [in] | timeout_ns | Timeout in nanoseconds. |
| void ove_sockaddr_ipv4 | ( | ove_sockaddr_t * | addr, |
| uint8_t | a, | ||
| uint8_t | b, | ||
| uint8_t | c, | ||
| uint8_t | d, | ||
| uint16_t | port | ||
| ) |
Fill a sockaddr from IPv4 address components.
| [out] | addr | Destination sockaddr. |
| [in] | a | First octet. |
| [in] | b | Second octet. |
| [in] | c | Third octet. |
| [in] | d | Fourth octet. |
| [in] | port | Port number in host byte order. |