lwIP  2.0.2
Lightweight IP stack
tcp.h File Reference
#include "lwip/opt.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/ip.h"
#include "lwip/icmp.h"
#include "lwip/err.h"
#include "lwip/ip6.h"
#include "lwip/ip6_addr.h"

Data Structures

struct  tcp_pcb_listen
 
struct  tcp_pcb
 

Macros

#define TCP_PCB_COMMON(type)
 
#define tcp_nagle_disable(pcb)   ((pcb)->flags |= TF_NODELAY)
 
#define tcp_nagle_enable(pcb)   ((pcb)->flags = (tcpflags_t)((pcb)->flags & ~TF_NODELAY))
 
#define tcp_nagle_disabled(pcb)   (((pcb)->flags & TF_NODELAY) != 0)
 
#define tcp_listen(pcb)   tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG)
 

Typedefs

typedef err_t(* tcp_accept_fn) (void *arg, struct tcp_pcb *newpcb, err_t err)
 
typedef err_t(* tcp_recv_fn) (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
 
typedef err_t(* tcp_sent_fn) (void *arg, struct tcp_pcb *tpcb, u16_t len)
 
typedef err_t(* tcp_poll_fn) (void *arg, struct tcp_pcb *tpcb)
 
typedef void(* tcp_err_fn) (void *arg, err_t err)
 
typedef err_t(* tcp_connected_fn) (void *arg, struct tcp_pcb *tpcb, err_t err)
 

Functions

struct tcp_pcbtcp_new (void)
 
struct tcp_pcbtcp_new_ip_type (u8_t type)
 
void tcp_arg (struct tcp_pcb *pcb, void *arg)
 
void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv)
 
void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent)
 
void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err)
 
void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept)
 
void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)
 
void tcp_backlog_delayed (struct tcp_pcb *pcb)
 
void tcp_backlog_accepted (struct tcp_pcb *pcb)
 
void tcp_recved (struct tcp_pcb *pcb, u16_t len)
 
err_t tcp_bind (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
 
err_t tcp_connect (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port, tcp_connected_fn connected)
 
struct tcp_pcbtcp_listen_with_backlog_and_err (struct tcp_pcb *pcb, u8_t backlog, err_t *err)
 
struct tcp_pcbtcp_listen_with_backlog (struct tcp_pcb *pcb, u8_t backlog)
 
void tcp_abort (struct tcp_pcb *pcb)
 
err_t tcp_close (struct tcp_pcb *pcb)
 
err_t tcp_shutdown (struct tcp_pcb *pcb, int shut_rx, int shut_tx)
 
err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len, u8_t apiflags)
 
void tcp_setprio (struct tcp_pcb *pcb, u8_t prio)
 
err_t tcp_output (struct tcp_pcb *pcb)
 

Detailed Description

TCP API (to be used from TCPIP thread)
See also TCP

Macro Definition Documentation

◆ TCP_PCB_COMMON

#define TCP_PCB_COMMON (   type)
Value:
type *next; /* for the linked list */ \
void *callback_arg; \
enum tcp_state state; /* TCP state */ \
u8_t prio; \
/* ports are in host byte order */ \
u16_t local_port

members common to struct tcp_pcb and struct tcp_listen_pcb

Typedef Documentation

◆ tcp_accept_fn

typedef err_t(* tcp_accept_fn) (void *arg, struct tcp_pcb *newpcb, err_t err)

Function prototype for tcp accept callback functions. Called when a new connection can be accepted on a listening pcb.

Parameters
argAdditional argument to pass to the callback function (
See also
tcp_arg())
Parameters
newpcbThe new connection pcb
errAn error code if there has been an error accepting. Only return ERR_ABRT if you have called tcp_abort from within the callback function!

◆ tcp_connected_fn

typedef err_t(* tcp_connected_fn) (void *arg, struct tcp_pcb *tpcb, err_t err)

Function prototype for tcp connected callback functions. Called when a pcb is connected to the remote side after initiating a connection attempt by calling tcp_connect().

Parameters
argAdditional argument to pass to the callback function (
See also
tcp_arg())
Parameters
tpcbThe connection pcb which is connected
errAn unused error code, always ERR_OK currently ;-)
Note
When a connection attempt fails, the error callback is currently called!

◆ tcp_err_fn

typedef void(* tcp_err_fn) (void *arg, err_t err)

Function prototype for tcp error callback functions. Called when the pcb receives a RST or is unexpectedly closed for any other reason.

Note
The corresponding pcb is already freed when this callback is called!
Parameters
argAdditional argument to pass to the callback function (
See also
tcp_arg())
Parameters
errError code to indicate why the pcb has been closed ERR_ABRT: aborted through tcp_abort or by a TCP timer ERR_RST: the connection was reset by the remote host

◆ tcp_poll_fn

typedef err_t(* tcp_poll_fn) (void *arg, struct tcp_pcb *tpcb)

Function prototype for tcp poll callback functions. Called periodically as specified by

See also
tcp_poll.
Parameters
argAdditional argument to pass to the callback function (
See also
tcp_arg())
Parameters
tpcbtcp pcb
Returns
ERR_OK: try to send some data by calling tcp_output Only return ERR_ABRT if you have called tcp_abort from within the callback function!

◆ tcp_recv_fn

typedef err_t(* tcp_recv_fn) (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)

Function prototype for tcp receive callback functions. Called when data has been received.

Parameters
argAdditional argument to pass to the callback function (
See also
tcp_arg())
Parameters
tpcbThe connection pcb which received data
pThe received data (or NULL when the connection has been closed!)
errAn error code if there has been an error receiving Only return ERR_ABRT if you have called tcp_abort from within the callback function!

◆ tcp_sent_fn

typedef err_t(* tcp_sent_fn) (void *arg, struct tcp_pcb *tpcb, u16_t len)

Function prototype for tcp sent callback functions. Called when sent data has been acknowledged by the remote side. Use it to free corresponding resources. This also means that the pcb has now space available to send new data.

Parameters
argAdditional argument to pass to the callback function (
See also
tcp_arg())
Parameters
tpcbThe connection pcb for which data has been acknowledged
lenThe amount of bytes acknowledged
Returns
ERR_OK: try to send some data by calling tcp_output Only return ERR_ABRT if you have called tcp_abort from within the callback function!

Function Documentation

◆ tcp_setprio()

void tcp_setprio ( struct tcp_pcb pcb,
u8_t  prio 
)

Sets the priority of a connection.

Parameters
pcbthe tcp_pcb to manipulate
prionew priority