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 chunks 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

uint32_t csp_sfp_opts_max_mtu(uint32_t opts)
[source]

Get the maximum MTU (Maximum Transmission Unit) for options.

Parameters:
  • opts – Options indicating required protocol features (RDP, CRC, etc.).

Returns:

The maximum MTU in bytes.

uint32_t csp_sfp_conn_max_mtu(const csp_conn_t *conn)
[source]

Get the maximum MTU (Maximum Transmission Unit) for a connection.

Parameters:
  • conn – Connection indicating required protocol features (RDP, CRC, etc.).

Returns:

The maximum MTU in bytes.

int csp_sfp_send(csp_conn_t *conn, const csp_sfp_read_t *user, uint32_t datasize, uint32_t mtu, uint32_t timeout)
[source]

Send data over a CSP connection.

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

  • user – User-defined read function and data pointer.

  • datasize – Total size to send.

  • 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, const csp_sfp_recv_t *user, 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.

  • user – User-defined data with write function and data pointer.

  • 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, const csp_sfp_recv_t *user, uint32_t timeout)
[source]

Receive data over a CSP connection.

This is the counterpart to the csp_sfp_send()

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

  • user – User-defined data with write function and data pointer.

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

Returns:

#CSP_ERR_NONE on success, otherwise an error.