Small Fragmentation Protocol (SFP)

File: csp/csp_sfp.h

Description: Simple Fragmentation Protocol (SFP).

The SFP API can transfer a blob of data across an established CSP connection, by chopping the data into smaller chuncks of data, that can fit into a single CSP message.

SFP will add a small header to each packet, containing information about the transfer. SFP is usually sent over a RDP connection (which also adds a header),

Interface Functions

int csp_sfp_send_own_memcpy(csp_conn_t *conn, const void *data, unsigned int datasize, unsigned int mtu, uint32_t timeout, csp_memcpy_fnc_t memcpyfcn)
[source]

Send data over a CSP connection.

Data will be send in chunks of mtu bytes. The MTU must be small enough to fit into a CSP packat + SFP header + other transport headers.

csp_sfp_recv() or csp_sfp_recv_fp() can be used at the other end to receive data.

This is usefull if you wish to send data stored in flash memory or another location, where standard memcpy() doesn’t work.

Parameters:
  • conn – established connection for sending SFP packets.

  • data – data to send

  • datasize – tsize of data

  • mtu – maximum transfer unit (bytes), max data chunk to send.

  • timeout – unused as of CSP version 1.6

  • memcpyfcn – memory copy function.

Returns:

#CSP_ERR_NONE on success, otherwise an error.

static inline int csp_sfp_send(csp_conn_t *conn, const void *data, unsigned int datasize, unsigned int mtu, uint32_t timeout)
[source]

Send data over a CSP connection.

Uses csp_sfp_send_own_memcpy() with standard memcpy().

Parameters:
  • conn – established connection for sending SFP packets.

  • data – data to send

  • datasize – size of data

  • mtu – maximum transfer unit (bytes), max data chunk to send.

  • timeout – unused as of CSP version 1.6

Returns:

#CSP_ERR_NONE on success, otherwise an error.

int csp_sfp_recv_fp(csp_conn_t *conn, void **dataout, int *datasize, uint32_t timeout, csp_packet_t *first_packet)
[source]

Receive data over a CSP connection.

This is the counterpart to the csp_sfp_send() and csp_sfp_send_own_memcpy().

Parameters:
  • conn – established connection for receiving SFP packets.

  • dataout – received data on success. Allocated with malloc(), so should be freed with free(). The pointer will be NULL on failure.

  • datasize – size of received data.

  • timeout – timeout in ms to wait for csp_read()

  • first_packet – First packet of a SFP transfer. Use NULL to receive first packet on the connection.

Returns:

#CSP_ERR_NONE on success, otherwise an error.

static inline int csp_sfp_recv(csp_conn_t *conn, void **dataout, int *datasize, uint32_t timeout)
[source]

Receive data over a CSP connection.

This is the counterpart to the csp_sfp_send() and csp_sfp_send_own_memcpy().

Parameters:
  • conn – established connection for receiving SFP packets.

  • dataout – received data on success. Allocated with malloc(), so should be freed with free(). The pointer will be NULL on failure.

  • datasize – size of received data.

  • timeout – timeout in ms to wait for csp_read()

Returns:

#CSP_ERR_NONE on success, otherwise an error.