Expand description
This crate provides FFI bindings for the libcsp
library.
Generally, you probably do not want to use this library directly and instead use the
libcsp
Rust crate which provides a safe and ergonomic Rust
API.
You can find some more high-level information and examples in the main repository.
§Compile-time configuration
This library requires some compile-time configuration file to be included to work
properly. You can see an example version of the file for the workspace
here.
The user has to provide the path to a directory containing this autoconfig.rs
file using the
CSP_CONFIG_DIR
environmental variable.
Modules§
Structs§
- csp_
conn_ s - @brief Connection struct
- csp_
id_ t - CSP identifier/header.
- csp_
if_ udp_ conf_ t - csp_
iface_ s - This struct is referenced in documentation. Update doc when you change this.
- csp_
packet_ s - CSP Packet.
- csp_
packet_ s_ anon_ union_ field_ rdp_ only - csp_
packet_ s_ anon_ union_ field_ rx_ tx_ only - csp_
rdp_ t - RDP Connection
- csp_
socket_ s - @brief Connection struct
- csp_
timestamp_ t
Constants§
- CSP_
BUFFER_ COUNT - CSP_
BUFFER_ SIZE - CSP_
CONN_ MAX - CSP_
CONN_ RXQUEUE_ LEN - CSP_
PORT_ MAX_ BIND - CSP_
QFIFO_ LEN - CSP_
RDP_ MAX_ WINDOW - CSP_
RTABLE_ SIZE
Statics§
- csp_
dbg_ ⚠buffer_ out - Error counters
- csp_
dbg_ ⚠can_ errno - csp_
dbg_ ⚠conn_ noroute - csp_
dbg_ ⚠conn_ out - csp_
dbg_ ⚠conn_ ovf - csp_
dbg_ ⚠errno - csp_
dbg_ ⚠eth_ errno - csp_
dbg_ ⚠inval_ reply - csp_
dbg_ ⚠packet_ print - csp_
dbg_ ⚠rdp_ print
Functions§
- csp_
accept ⚠ - Wait/accept a new connection.
- csp_
bind ⚠ - Bind port to socket.
- csp_
buf_ ⚠free - Request free buffers and print to stdout.
- csp_
buffer_ ⚠free - Free buffer (from task context).
- csp_
buffer_ ⚠get - Get free buffer from task context.
- csp_
close ⚠ - Close an open connection. Any packets in the RX queue will be freed.
- csp_
conn_ ⚠dport - Return destination port of connection.
- csp_
conn_ ⚠dst - Return destination address of connection.
- csp_
conn_ ⚠flags - Return flags of connection.
- csp_
conn_ ⚠print_ table - Print connection table to stdout.
- csp_
conn_ ⚠sport - Return source port of connection.
- csp_
conn_ ⚠src - Return source address of connection.
- csp_
connect ⚠ - Establish outgoing connection. The call will return immediately, unless it is a RDP connection (#CSP_O_RDP) in which case it will wait until the other end acknowleges the connection (timeout is determined by the current connection timeout set by csp_rdp_set_opt()).
- csp_
get_ ⚠buf_ free - Request free buffers.
- csp_
get_ ⚠memfree - Request free memory.
- csp_
get_ ⚠uptime - Request uptime
- csp_
init ⚠ - Initialize CSP. This will configure basic structures.
- csp_
listen ⚠ - Set socket to listen for incoming connections.
- csp_
memfree ⚠ - Request free memory and print to stdout.
- csp_
ping ⚠ - Send a single ping/echo packet.
- csp_
ping_ ⚠noreply - Send a single ping/echo packet without waiting for reply. Payload is 1 byte.
- csp_
print_ ⚠func - csp_ps⚠
- Request process list.
- csp_
read ⚠ - Read packet from a connection. This fuction will wait on the connection’s RX queue for the specified timeout.
- csp_
reboot ⚠ - Reboot subsystem. If handled by the standard CSP service handler, the reboot handler set by csp_sys_set_reboot() on the subsystem, will be invoked.
- csp_
recvfrom ⚠ - Read data from a connection-less server socket.
- csp_
route_ ⚠work - Route packet from the incoming router queue and check RDP timeouts. In order for incoming packets to routed and RDP timeouts to be checked, this function must be called reguarly. @return #CSP_ERR_NONE on success, otherwise an error code.
- csp_
send ⚠ - Send packet on a connection. The packet buffer is automatically freed, and cannot be used after the call to csp_send()
- csp_
send_ ⚠prio - Change the default priority of the connection and send a packet.
- csp_
sendto_ ⚠reply - Send a packet as a reply to a request (without a connection). Calls csp_sendto() with the source address and port from the request.
- csp_
service_ ⚠handler - Handle CSP service request. If the given packet is a service-request (the destination port matches one of CSP service ports #csp_service_port_t), the packet will be processed by the specific CSP service handler. The packet will either process it or free it, so this function is typically called in the last “default” clause of a switch/case statement in a CSP listener task. In order to listen to csp service ports, bind your listener to the specific services ports #csp_service_port_t or use #CSP_ANY to all ports.
- csp_
shutdown ⚠ - Shutdown subsystem. If handled by the standard CSP service handler, the shutdown handler set by csp_sys_set_shutdown() on the subsystem, will be invoked.
- csp_
socket_ ⚠close - Close a socket, freeing it’s RX queue and unbinding it from the associated port.
- csp_
transaction_ ⚠persistent - Perform an entire request & reply transaction on an existing connection. Send \a outbuf, wait for reply and copy reply to \a inbuf.
- csp_
transaction_ ⚠w_ opts - Perform an entire request & reply transaction. Creates a connection, send \a outbuf, wait for reply, copy reply to \a inbuf and close the connection.
- csp_
uptime ⚠ - Request uptime and print to stdout.
Type Aliases§
- atomic_
int - csp_
bin_ sem_ t Unix - csp_
conn_ state_ t - Connection states
- csp_
conn_ t - Forward declaration of connection structure
- csp_
conn_ type_ t - Connection types
- csp_
iface_ t - Forward declaration of CSP interface, see #csp_iface_s for details.
- csp_
packet_ t - CSP Packet.
- csp_
queue_ handle_ t - csp_
rdp_ state_ t - RDP Connection states
- csp_
socket_ t - Forward declaration of socket structure
- csp_
static_ queue_ t - nexthop_
t - Interface Tx function.
Unions§
- csp_
packet_ s_ anon_ union - csp_
packet_ s_ data_ union - Data part of packet: