oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
Networking

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.
 

Detailed Description

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).

Note
Requires CONFIG_OVE_NET. When the option is disabled every function is replaced by a no-op stub that returns OVE_ERR_NOT_SUPPORTED.

Enumeration Type Documentation

◆ ove_sock_type_t

Socket type.

Enumerator
OVE_SOCK_STREAM 

Reliable byte-stream (TCP).

OVE_SOCK_DGRAM 

Connectionless datagrams (UDP).

◆ ove_af_t

enum ove_af_t

Address family.

Enumerator
OVE_AF_INET 

IPv4.

OVE_AF_INET6 

IPv6.

Function Documentation

◆ ove_netif_init()

int ove_netif_init ( ove_netif_t netif,
ove_netif_storage_t *  storage 
)

Initialise a network interface from caller-supplied storage.

Parameters
[out]netifHandle written on success.
[in]storageCaller-allocated storage.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_netif_deinit()

void ove_netif_deinit ( ove_netif_t  netif)

De-initialise a network interface.

Parameters
[in]netifHandle returned by ove_netif_init().

◆ ove_netif_up()

int ove_netif_up ( ove_netif_t  netif,
const ove_netif_config_t cfg 
)

Bring the network interface up.

Parameters
[in]netifHandle returned by ove_netif_init().
[in]cfgInterface configuration (DHCP or static).
Returns
OVE_OK on success, negative error code on failure.

◆ ove_netif_down()

void ove_netif_down ( ove_netif_t  netif)

Tear down the network interface.

Parameters
[in]netifHandle returned by ove_netif_init().

◆ ove_netif_get_addr()

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.

Parameters
[in]netifHandle returned by ove_netif_init().
[out]ipCurrent IPv4 address (may be NULL).
[out]gatewayCurrent gateway address (may be NULL).
[out]netmaskCurrent subnet mask (may be NULL).
Returns
OVE_OK on success, negative error code on failure.

◆ ove_netif_create()

int ove_netif_create ( ove_netif_t netif)

Heap-allocate and initialise a network interface.

Parameters
[out]netifHandle written on success.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_netif_destroy()

void ove_netif_destroy ( ove_netif_t  netif)

Destroy a heap-allocated network interface.

Parameters
[in]netifHandle returned by ove_netif_create().

◆ ove_socket_open()

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.

Parameters
[out]sockHandle written on success.
[in]storageCaller-allocated storage.
[in]afAddress family.
[in]typeSocket type (TCP or UDP).
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_close()

void ove_socket_close ( ove_socket_t  sock)

Close a socket.

Parameters
[in]sockHandle returned by ove_socket_open().

◆ ove_socket_connect()

int ove_socket_connect ( ove_socket_t  sock,
const ove_sockaddr_t addr,
uint64_t  timeout_ns 
)

Connect a socket to a remote address.

Parameters
[in]sockSocket handle.
[in]addrRemote address.
[in]timeout_nsTimeout in nanoseconds (OVE_WAIT_FOREVER to block).
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_bind()

int ove_socket_bind ( ove_socket_t  sock,
const ove_sockaddr_t addr 
)

Bind a socket to a local address.

Parameters
[in]sockSocket handle.
[in]addrLocal address to bind.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_listen()

int ove_socket_listen ( ove_socket_t  sock,
int  backlog 
)

Mark a bound socket as listening for incoming connections.

Parameters
[in]sockSocket handle.
[in]backlogMaximum pending connection queue length.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_accept()

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.

Parameters
[in]sockListening socket handle.
[out]clientHandle for the accepted connection.
[in]client_storageCaller-allocated storage for the new socket.
[in]timeout_nsTimeout in nanoseconds.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_send()

int ove_socket_send ( ove_socket_t  sock,
const void *  data,
size_t  len,
size_t *  sent 
)

Send data on a connected socket.

Parameters
[in]sockSocket handle.
[in]dataPointer to data to send.
[in]lenNumber of bytes to send.
[out]sentNumber of bytes actually sent (may be NULL).
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_recv()

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.

Parameters
[in]sockSocket handle.
[out]bufBuffer to receive into.
[in]lenBuffer size in bytes.
[out]receivedNumber of bytes received (may be NULL).
[in]timeout_nsTimeout in nanoseconds.
Returns
OVE_OK on success, OVE_ERR_NET_CLOSED if peer closed.

◆ ove_socket_sendto()

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.

Parameters
[in]sockSocket handle (UDP).
[in]dataPointer to data to send.
[in]lenNumber of bytes to send.
[out]sentNumber of bytes actually sent (may be NULL).
[in]destDestination address.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_recvfrom()

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.

Parameters
[in]sockSocket handle (UDP).
[out]bufBuffer to receive into.
[in]lenBuffer size in bytes.
[out]receivedNumber of bytes received (may be NULL).
[out]srcFilled with sender's address (may be NULL).
[in]timeout_nsTimeout in nanoseconds.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_create()

int ove_socket_create ( ove_socket_t sock,
ove_af_t  af,
ove_sock_type_t  type 
)

Heap-allocate and open a socket.

Parameters
[out]sockHandle written on success.
[in]afAddress family.
[in]typeSocket type.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_socket_destroy()

void ove_socket_destroy ( ove_socket_t  sock)

Destroy a heap-allocated socket.

Parameters
[in]sockHandle returned by ove_socket_create().

◆ ove_dns_resolve()

int ove_dns_resolve ( const char *  hostname,
ove_sockaddr_t addr,
uint64_t  timeout_ns 
)

Resolve a hostname to an address.

Parameters
[in]hostnameNull-terminated hostname string.
[out]addrResolved address written here.
[in]timeout_nsTimeout in nanoseconds.
Returns
OVE_OK on success, negative error code on failure.

◆ ove_sockaddr_ipv4()

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.

Parameters
[out]addrDestination sockaddr.
[in]aFirst octet.
[in]bSecond octet.
[in]cThird octet.
[in]dFourth octet.
[in]portPort number in host byte order.