RIOT's TCP implementation for the GNRC network stack. More...
RIOT's TCP implementation for the GNRC network stack.
Modules | |
GNRC TCP compile configurations | |
Files | |
file | tcp.h |
GNRC TCP API. | |
file | config.h |
GNRC TCP configuration. | |
file | tcb.h |
GNRC TCP transmission control block (TCB) | |
file | gnrc_tcp_common.h |
Internally used defines, macros and variable declarations. | |
file | gnrc_tcp_eventloop.h |
TCP event loop declarations. | |
file | gnrc_tcp_fsm.h |
TCP finite state machine declarations. | |
file | gnrc_tcp_option.h |
TCP option handling declarations. | |
file | gnrc_tcp_pkt.h |
TCP packet handling declarations. | |
file | gnrc_tcp_rcvbuf.h |
Functions for allocating and freeing the receive buffer. | |
Data Structures | |
struct | gnrc_tcp_ep_t |
Address information for a single TCP connection endpoint. More... | |
Macros | |
#define | GNRC_TCP_NO_TIMEOUT (UINT32_MAX) |
Special timeout value representing no timeout. | |
Functions | |
int | gnrc_tcp_ep_init (gnrc_tcp_ep_t *ep, int family, const uint8_t *addr, size_t addr_size, uint16_t port, uint16_t netif) |
Initialize TCP connection endpoint. | |
int | gnrc_tcp_ep_from_str (gnrc_tcp_ep_t *ep, const char *str) |
Construct TCP connection endpoint from string. | |
int | gnrc_tcp_init (void) |
Initialize TCP. | |
void | gnrc_tcp_tcb_init (gnrc_tcp_tcb_t *tcb) |
Initialize Transmission Control Block (TCB) | |
void | gnrc_tcp_tcb_queue_init (gnrc_tcp_tcb_queue_t *queue) |
Initialize Transmission Control Block (TCB) queue. | |
int | gnrc_tcp_open (gnrc_tcp_tcb_t *tcb, const gnrc_tcp_ep_t *remote, uint16_t local_port) |
Opens a connection. | |
int | gnrc_tcp_listen (gnrc_tcp_tcb_queue_t *queue, gnrc_tcp_tcb_t *tcbs, size_t tcbs_len, const gnrc_tcp_ep_t *local) |
Configures a sequence of TCBs to wait for incoming connections. | |
int | gnrc_tcp_accept (gnrc_tcp_tcb_queue_t *queue, gnrc_tcp_tcb_t **tcb, const uint32_t user_timeout_duration_ms) |
Accept TCP connection from listening queue. | |
ssize_t | gnrc_tcp_send (gnrc_tcp_tcb_t *tcb, const void *data, const size_t len, const uint32_t user_timeout_duration_ms) |
Transmit data to connected peer. | |
ssize_t | gnrc_tcp_recv (gnrc_tcp_tcb_t *tcb, void *data, const size_t max_len, const uint32_t user_timeout_duration_ms) |
Receive Data from the peer. | |
void | gnrc_tcp_close (gnrc_tcp_tcb_t *tcb) |
Close a TCP connection. | |
void | gnrc_tcp_abort (gnrc_tcp_tcb_t *tcb) |
Abort a TCP connection. | |
void | gnrc_tcp_stop_listen (gnrc_tcp_tcb_queue_t *queue) |
Close connections and stop listening on TCB queue. | |
int | gnrc_tcp_get_local (gnrc_tcp_tcb_t *tcb, gnrc_tcp_ep_t *ep) |
Get the local end point of a connected TCB. | |
int | gnrc_tcp_get_remote (gnrc_tcp_tcb_t *tcb, gnrc_tcp_ep_t *ep) |
Get the remote end point of a connected TCB. | |
int | gnrc_tcp_queue_get_local (gnrc_tcp_tcb_queue_t *queue, gnrc_tcp_ep_t *ep) |
Gets the local end point of a TCB queue. | |
int | gnrc_tcp_calc_csum (const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr) |
Calculate and set checksum in TCP header. | |
gnrc_pktsnip_t * | gnrc_tcp_hdr_build (gnrc_pktsnip_t *payload, uint16_t src, uint16_t dst) |
Adds a TCP header to a given payload. | |
#define GNRC_TCP_NO_TIMEOUT (UINT32_MAX) |
void gnrc_tcp_abort | ( | gnrc_tcp_tcb_t * | tcb | ) |
Abort a TCP connection.
tcb
must not be NULL.[in,out] | tcb | TCB holding the connection information. |
int gnrc_tcp_accept | ( | gnrc_tcp_tcb_queue_t * | queue, |
gnrc_tcp_tcb_t ** | tcb, | ||
const uint32_t | user_timeout_duration_ms | ||
) |
Accept TCP connection from listening queue.
queue
must not be NULL tcb
must not be NULL[in] | queue | Listening queue to accept connection from. |
[out] | tcb | Pointer to TCB associated with a established connection. |
[in] | user_timeout_duration_ms | User specified timeout in milliseconds. If GNRC_TCP_NO_TIMEOUT the function blocks until a connection was established or an error occurred. |
queue
were already accepted. user_timeout_duration_ms
was 0 and no connection is ready to accept. user_timeout_duration_ms
was not 0 and no connection could be established. int gnrc_tcp_calc_csum | ( | const gnrc_pktsnip_t * | hdr, |
const gnrc_pktsnip_t * | pseudo_hdr | ||
) |
Calculate and set checksum in TCP header.
[in] | hdr | Gnrc_pktsnip that contains TCP header. |
[in] | pseudo_hdr | Gnrc_pktsnip that contains network layer header. |
hdr
or pseudo_hdr were NULL hdr
is not of type GNRC_NETTYPE_TCP pseudo_hdr
protocol is unsupported. void gnrc_tcp_close | ( | gnrc_tcp_tcb_t * | tcb | ) |
Close a TCP connection.
tcb
must not be NULL.[in,out] | tcb | TCB holding the connection information. |
int gnrc_tcp_ep_from_str | ( | gnrc_tcp_ep_t * | ep, |
const char * | str | ||
) |
Construct TCP connection endpoint from string.
str
in the IPv6 "URL" notation. The following strings specify a valid endpoint:[in,out] | ep | Endpoint to initialize. |
[in] | str | String containing IPv6-Address to parse. |
str
failed. int gnrc_tcp_ep_init | ( | gnrc_tcp_ep_t * | ep, |
int | family, | ||
const uint8_t * | addr, | ||
size_t | addr_size, | ||
uint16_t | port, | ||
uint16_t | netif | ||
) |
Initialize TCP connection endpoint.
[in,out] | ep | Endpoint to initialize. |
[in] | family | Address family of addr . |
[in] | addr | Address for endpoint. |
[in] | addr_size | Size of addr . |
[in] | port | Port number for endpoint. |
[in] | netif | Network interface to use. |
address_family
is not supported. addr_size
does not match family
. int gnrc_tcp_get_local | ( | gnrc_tcp_tcb_t * | tcb, |
gnrc_tcp_ep_t * | ep | ||
) |
Get the local end point of a connected TCB.
[in] | tcb | TCB holding the connection information. |
[out] | ep | The local end point. |
tcb
in not in a connected state. int gnrc_tcp_get_remote | ( | gnrc_tcp_tcb_t * | tcb, |
gnrc_tcp_ep_t * | ep | ||
) |
Get the remote end point of a connected TCB.
[in] | tcb | TCB holding the connection information. |
[out] | ep | The remote end point. |
tcb
in not in a connected state. gnrc_pktsnip_t * gnrc_tcp_hdr_build | ( | gnrc_pktsnip_t * | payload, |
uint16_t | src, | ||
uint16_t | dst | ||
) |
Adds a TCP header to a given payload.
[in] | payload | Payload that follows the TCP header. |
[in] | src | Source port number. |
[in] | dst | Destination port number. |
int gnrc_tcp_init | ( | void | ) |
Initialize TCP.
int gnrc_tcp_listen | ( | gnrc_tcp_tcb_queue_t * | queue, |
gnrc_tcp_tcb_t * | tcbs, | ||
size_t | tcbs_len, | ||
const gnrc_tcp_ep_t * | local | ||
) |
Configures a sequence of TCBs to wait for incoming connections.
tcbs
must have been initialized via gnrc_tcp_tcb_init(). queue
must not be NULL. tcbs
must not be NULL. tcbs_len
must be greater 0. local
len must be NULL. local->port
must not be 0.[in,out] | queue | Listening queue for incoming connections. |
[in] | tcbs | TCBs associated with queue . |
[in] | tcbs_len | Number of TCBs behind tcbs . |
[in] | local | Endpoint specifying address and port to listen on. |
local
is not supported. tcbs
and local
do not match. tcbs
is already connected. int gnrc_tcp_open | ( | gnrc_tcp_tcb_t * | tcb, |
const gnrc_tcp_ep_t * | remote, | ||
uint16_t | local_port | ||
) |
Opens a connection.
tcb
must not be NULL remote
must not be NULL. remote->port
must not be 0.[in,out] | tcb | TCB for this connection. |
[in] | remote | Remote endpoint to connect to. |
[in] | local_port | If zero or PORT_UNSPEC, the connections source port is randomly selected. If local_port is non-zero it is used as source port. |
remote
address_family is not supported. remote
and tcb
address_family do not match or target_addr
is invalid. tcb
is already connected. tcb
. local_port
is already in use. int gnrc_tcp_queue_get_local | ( | gnrc_tcp_tcb_queue_t * | queue, |
gnrc_tcp_ep_t * | ep | ||
) |
Gets the local end point of a TCB queue.
[in] | queue | TCB queue to stop listening |
[out] | ep | The local end point. |
queue
has no local end point. ssize_t gnrc_tcp_recv | ( | gnrc_tcp_tcb_t * | tcb, |
void * | data, | ||
const size_t | max_len, | ||
const uint32_t | user_timeout_duration_ms | ||
) |
Receive Data from the peer.
tcb
must not be NULL. data
must not be NULL.[in,out] | tcb | TCB holding the connection information. |
[out] | data | Pointer to the buffer where the received data should be copied into. |
[in] | max_len | Maximum amount to bytes that should be read into data . |
[in] | user_timeout_duration_ms | Timeout for receive in milliseconds. If zero and no data is available, the function returns immediately. If not zero the function blocks until data is available or user_timeout_duration_ms milliseconds passed. If GNRC_TCP_NO_TIMEOUT, causing the function to block until some data was available or an error occurred. |
data
. max_len
was 0. user_timeout_duration_ms
expired. ssize_t gnrc_tcp_send | ( | gnrc_tcp_tcb_t * | tcb, |
const void * | data, | ||
const size_t | len, | ||
const uint32_t | user_timeout_duration_ms | ||
) |
Transmit data to connected peer.
tcb
must not be NULL. data
must not be NULL.len
bytes were transmitted or an error occurred.[in,out] | tcb | TCB holding the connection information. |
[in] | data | Pointer to the data that should be transmitted. |
[in] | len | Number of bytes that should be transmitted. |
[in] | user_timeout_duration_ms | If not zero and there was not data transmitted the function returns after user_timeout_duration_ms. If zero, no timeout will be triggered. If GNRC_TCP_NO_TIMEOUT the timeout is disabled causing the function to block until some data was transmitted or and error occurred. |
user_timeout_duration_ms
expired. void gnrc_tcp_stop_listen | ( | gnrc_tcp_tcb_queue_t * | queue | ) |
Close connections and stop listening on TCB queue.
queue
must not be NULLqueue
were closed.[in,out] | queue | TCB queue to stop listening |
void gnrc_tcp_tcb_init | ( | gnrc_tcp_tcb_t * | tcb | ) |
Initialize Transmission Control Block (TCB)
tcb
must not be NULL.[in,out] | tcb | TCB that should be initialized. |
void gnrc_tcp_tcb_queue_init | ( | gnrc_tcp_tcb_queue_t * | queue | ) |
Initialize Transmission Control Block (TCB) queue.
queue
must not be NULL.[in,out] | queue | TCB queue to initialize. |