|
nros platform-cffi
Canonical C ABI for porting the nros platform abstraction
|
Canonical C ABI for the nros platform networking surface. More...

Go to the source code of this file.
Macros | |
| #define | NROS_PLATFORM_NET_SOCKET_ERROR ((size_t) -1) |
Functions | |
| void | nros_platform_network_poll (void) |
| int8_t | nros_platform_socket_accept (const void *sock_in, void *sock_out) |
| void | nros_platform_socket_close (void *sock) |
| static int | nros_platform_socket_get_fd (const void *sock) |
| int8_t | nros_platform_socket_set_non_blocking (const void *sock) |
| int8_t | nros_platform_socket_wait_event (void *peers, void *mutex) |
| void | nros_platform_tcp_close (void *sock) |
| int8_t | nros_platform_tcp_create_endpoint (void *ep, const uint8_t *address, const uint8_t *port) |
| void | nros_platform_tcp_free_endpoint (void *ep) |
| int8_t | nros_platform_tcp_listen (void *sock, const void *endpoint) |
| int8_t | nros_platform_tcp_open (void *sock, const void *endpoint, uint32_t timeout_ms) |
| size_t | nros_platform_tcp_read (const void *sock, uint8_t *buf, size_t len) |
| size_t | nros_platform_tcp_read_exact (const void *sock, uint8_t *buf, size_t len) |
| size_t | nros_platform_tcp_send (const void *sock, const uint8_t *buf, size_t len) |
| void | nros_platform_udp_close (void *sock) |
| int8_t | nros_platform_udp_create_endpoint (void *ep, const uint8_t *address, const uint8_t *port) |
| void | nros_platform_udp_free_endpoint (void *ep) |
| int8_t | nros_platform_udp_listen (void *sock, const void *endpoint, uint32_t timeout_ms) |
| void | nros_platform_udp_mcast_close (void *sockrecv, void *socksend, const void *rep, const void *lep) |
| int8_t | nros_platform_udp_mcast_listen (void *sock, const void *endpoint, uint32_t timeout_ms, const uint8_t *iface, const uint8_t *join) |
| int8_t | nros_platform_udp_mcast_open (void *sock, const void *endpoint, void *lep, uint32_t timeout_ms, const uint8_t *iface) |
| size_t | nros_platform_udp_mcast_read (const void *sock, uint8_t *buf, size_t len, const void *lep, void *addr) |
| size_t | nros_platform_udp_mcast_read_exact (const void *sock, uint8_t *buf, size_t len, const void *lep, void *addr) |
| size_t | nros_platform_udp_mcast_send (const void *sock, const uint8_t *buf, size_t len, const void *endpoint) |
| int8_t | nros_platform_udp_open (void *sock, const void *endpoint, uint32_t timeout_ms) |
| size_t | nros_platform_udp_read (const void *sock, uint8_t *buf, size_t len) |
| size_t | nros_platform_udp_read_exact (const void *sock, uint8_t *buf, size_t len) |
| size_t | nros_platform_udp_send (const void *sock, const uint8_t *buf, size_t len, const void *endpoint) |
| void | nros_platform_udp_set_recv_timeout (const void *sock, uint32_t timeout_ms) |
Canonical C ABI for the nros platform networking surface.
Companion to <nros/platform.h>; sits beside the core 39-symbol platform ABI as the network interface zenoh-pico and the XRCE-DDS transports use. Carved into a separate header because bare-metal targets without a network stack can omit it.
Sockets and endpoints are opaque storage pointers. The application allocates the bytes (size known to the implementor; matches zenoh-pico's _z_sys_net_socket_t / _z_sys_net_endpoint_t). The implementation writes its handle into the supplied storage. read_* and send return (size_t) -1 on error, otherwise the number of bytes transferred (zero is a valid short-read result).
Read functions inherit the socket's recv timeout (set via set_recv_timeout). 0 ms means block indefinitely; non-zero is an upper bound on per-call duration.
udp_listen and udp_multicast_* are optional. A platform that doesn't implement them supplies a stub that returns -1 (or (size_t) -1 on the read/send variants); higher layers detect the failure and fall back. network_poll exists for platforms with a non-OS network stack (smoltcp on bare-metal) — POSIX / Zephyr / NuttX / FreeRTOS+lwIP / ThreadX+NetXDuo provide a no-op stub.
| #define NROS_PLATFORM_NET_SOCKET_ERROR ((size_t) -1) |
| void nros_platform_network_poll | ( | void | ) |
Pump the underlying network stack to process pending I/O. No-op on platforms with a kernel-driven socket layer (POSIX, Zephyr, lwIP, NetX Duo). Bare-metal smoltcp targets advance the stack from this entry point.
| int8_t nros_platform_socket_accept | ( | const void * | sock_in, |
| void * | sock_out | ||
| ) |
Accept a pending connection from sock_in into sock_out.
| void nros_platform_socket_close | ( | void * | sock | ) |
Socket-layer shutdown + close. Distinct from nros_platform_tcp_close because zenoh-pico's helper layer exposes both.
|
inlinestatic |
| int8_t nros_platform_socket_set_non_blocking | ( | const void * | sock | ) |
Switch a socket to non-blocking mode.
| int8_t nros_platform_socket_wait_event | ( | void * | peers, |
| void * | mutex | ||
| ) |
Wait for socket events on a multi-peer set. Optional on platforms without a poll/select primitive.
| void nros_platform_tcp_close | ( | void * | sock | ) |
Close a TCP socket.
| int8_t nros_platform_tcp_create_endpoint | ( | void * | ep, |
| const uint8_t * | address, | ||
| const uint8_t * | port | ||
| ) |
Resolve (address, port) strings into the caller-allocated endpoint storage at ep. Both strings are NUL-terminated.
| void nros_platform_tcp_free_endpoint | ( | void * | ep | ) |
Release any resources held by the endpoint at ep.
| int8_t nros_platform_tcp_listen | ( | void * | sock, |
| const void * | endpoint | ||
| ) |
Open a listening TCP socket bound to endpoint.
| int8_t nros_platform_tcp_open | ( | void * | sock, |
| const void * | endpoint, | ||
| uint32_t | timeout_ms | ||
| ) |
Open a TCP client connection to endpoint.
| size_t nros_platform_tcp_read | ( | const void * | sock, |
| uint8_t * | buf, | ||
| size_t | len | ||
| ) |
Read up to len bytes. Returns bytes received, or NROS_PLATFORM_NET_SOCKET_ERROR on error.
| size_t nros_platform_tcp_read_exact | ( | const void * | sock, |
| uint8_t * | buf, | ||
| size_t | len | ||
| ) |
Read exactly len bytes. Returns len on success, or NROS_PLATFORM_NET_SOCKET_ERROR on error.
| size_t nros_platform_tcp_send | ( | const void * | sock, |
| const uint8_t * | buf, | ||
| size_t | len | ||
| ) |
Send len bytes. Returns bytes sent, or NROS_PLATFORM_NET_SOCKET_ERROR on error.
| void nros_platform_udp_close | ( | void * | sock | ) |
| int8_t nros_platform_udp_create_endpoint | ( | void * | ep, |
| const uint8_t * | address, | ||
| const uint8_t * | port | ||
| ) |
| void nros_platform_udp_free_endpoint | ( | void * | ep | ) |
| int8_t nros_platform_udp_listen | ( | void * | sock, |
| const void * | endpoint, | ||
| uint32_t | timeout_ms | ||
| ) |
Bind a UDP socket in listen / server mode. Optional — return -1 on platforms that don't expose a UDP-server primitive.
| void nros_platform_udp_mcast_close | ( | void * | sockrecv, |
| void * | socksend, | ||
| const void * | rep, | ||
| const void * | lep | ||
| ) |
| int8_t nros_platform_udp_mcast_listen | ( | void * | sock, |
| const void * | endpoint, | ||
| uint32_t | timeout_ms, | ||
| const uint8_t * | iface, | ||
| const uint8_t * | join | ||
| ) |
| int8_t nros_platform_udp_mcast_open | ( | void * | sock, |
| const void * | endpoint, | ||
| void * | lep, | ||
| uint32_t | timeout_ms, | ||
| const uint8_t * | iface | ||
| ) |
| size_t nros_platform_udp_mcast_read | ( | const void * | sock, |
| uint8_t * | buf, | ||
| size_t | len, | ||
| const void * | lep, | ||
| void * | addr | ||
| ) |
| size_t nros_platform_udp_mcast_read_exact | ( | const void * | sock, |
| uint8_t * | buf, | ||
| size_t | len, | ||
| const void * | lep, | ||
| void * | addr | ||
| ) |
| size_t nros_platform_udp_mcast_send | ( | const void * | sock, |
| const uint8_t * | buf, | ||
| size_t | len, | ||
| const void * | endpoint | ||
| ) |
| int8_t nros_platform_udp_open | ( | void * | sock, |
| const void * | endpoint, | ||
| uint32_t | timeout_ms | ||
| ) |
| size_t nros_platform_udp_read | ( | const void * | sock, |
| uint8_t * | buf, | ||
| size_t | len | ||
| ) |
| size_t nros_platform_udp_read_exact | ( | const void * | sock, |
| uint8_t * | buf, | ||
| size_t | len | ||
| ) |
| size_t nros_platform_udp_send | ( | const void * | sock, |
| const uint8_t * | buf, | ||
| size_t | len, | ||
| const void * | endpoint | ||
| ) |
Send len bytes to endpoint.
| void nros_platform_udp_set_recv_timeout | ( | const void * | sock, |
| uint32_t | timeout_ms | ||
| ) |
Set the recv timeout in milliseconds; 0 means block indefinitely.