Documentation

Documentation

Includes

lwip/opt.h

#include "lwip/opt.h"
#include "lwip/opt.h"

lwip/tcpbase.h

#include "lwip/tcpbase.h"
#include "lwip/tcpbase.h"

lwip/mem.h

#include "lwip/mem.h"
#include "lwip/mem.h"

lwip/pbuf.h

#include "lwip/pbuf.h"
#include "lwip/pbuf.h"

lwip/ip.h

#include "lwip/ip.h"
#include "lwip/ip.h"

lwip/icmp.h

#include "lwip/icmp.h"
#include "lwip/icmp.h"

lwip/err.h

#include "lwip/err.h"
#include "lwip/err.h"

lwip/ip6.h

#include "lwip/ip6.h"
#include "lwip/ip6.h"

lwip/ip6_addr.h

#include "lwip/ip6_addr.h"
#include "lwip/ip6_addr.h"

Macros

Marco LWIP_HDR_TCP_H

#define LWIP_HDR_TCP_H


      

Marco RCV_WND_SCALE(pcb, wnd)

#define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale))


      

Marco SND_WND_SCALE(pcb, wnd)

#define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale))


      

Marco TCPWND16(x)

#define TCPWND16(x)            ((u16_t)LWIP_MIN((x), 65535))


      

Marco TCP_WND_MAX(pcb)

#define TCP_WND_MAX(pcb)       ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND)))


      

Marco RCV_WND_SCALE(pcb, wnd)

#define RCV_WND_SCALE(pcb, wnd) (wnd)


      

Marco SND_WND_SCALE(pcb, wnd)

#define SND_WND_SCALE(pcb, wnd) (wnd)


      

Marco TCPWND16(x)

#define TCPWND16(x)            (x)


      

Marco TCP_WND_MAX(pcb)

#define TCP_WND_MAX(pcb)       TCP_WND


      

Marco TCP_WND_INC(wnd, inc)

#define TCP_WND_INC(wnd, inc)  do { \
                                 if ((tcpwnd_size_t)(wnd + inc) >= wnd) { \
                                   wnd = (tcpwnd_size_t)(wnd + inc); \
                                 } else { \
                                   wnd = (tcpwnd_size_t)-1; \
                                 } \
                               } while(0)
/* Increments a tcpwnd_size_t and holds at max value rather than rollover */

Marco LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID

#define LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID 255


      

Marco TCP_PCB_EXTARGS

#define TCP_PCB_EXTARGS struct tcp_pcb_ext_args ext_args[LWIP_TCP_PCB_NUM_EXT_ARGS];
/* This is a helper define to prevent zero size arrays if disabled */

Marco TCP_PCB_EXTARGS

#define TCP_PCB_EXTARGS


      

Marco TCP_PCB_COMMON(type)

#define TCP_PCB_COMMON(type) \
 type *next; /* for the linked list */ \
 void *callback_arg; \
 TCP_PCB_EXTARGS \
 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
 */

Marco tcp_set_flags(pcb, set_flags)

#define         tcp_set_flags(pcb, set_flags)    do { (pcb)->flags = (tcpflags_t)((pcb)->flags | (set_flags)); } while(0)


      

Marco tcp_clear_flags(pcb, clr_flags)

#define         tcp_clear_flags(pcb, clr_flags)  do { (pcb)->flags = (tcpflags_t)((pcb)->flags & (tcpflags_t)(~(clr_flags) & TCP_ALLFLAGS)); } while(0)


      

Marco tcp_is_flag_set(pcb, flag)

#define         tcp_is_flag_set(pcb, flag)       (((pcb)->flags & (flag)) != 0)


      

Marco tcp_mss(pcb)

#define         tcp_mss(pcb)            (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss)


      

Marco tcp_mss(pcb)

#define         tcp_mss(pcb)            ((pcb)->mss)
/** @ingroup tcp_raw */

Marco tcp_sndbuf(pcb)

#define         tcp_sndbuf(pcb)         (TCPWND16((pcb)->snd_buf))
/** @ingroup tcp_raw */

Marco tcp_sndqueuelen(pcb)

#define         tcp_sndqueuelen(pcb)    ((pcb)->snd_queuelen)
/** @ingroup tcp_raw */

Marco tcp_nagle_disable(pcb)

#define         tcp_nagle_disable(pcb)  tcp_set_flags(pcb, TF_NODELAY)
/** @ingroup tcp_raw */

Marco tcp_nagle_enable(pcb)

#define         tcp_nagle_enable(pcb)   tcp_clear_flags(pcb, TF_NODELAY)
/** @ingroup tcp_raw */

Marco tcp_nagle_disabled(pcb)

#define         tcp_nagle_disabled(pcb) tcp_is_flag_set(pcb, TF_NODELAY)
/** @ingroup tcp_raw */

Marco tcp_backlog_set(pcb, new_backlog)

#define         tcp_backlog_set(pcb, new_backlog) do { \
 LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", (pcb)->state == LISTEN); \
 ((struct tcp_pcb_listen *)(pcb))->backlog = ((new_backlog) ? (new_backlog) : 1); } while(0)


      

Marco tcp_backlog_set

#define         tcp_backlog_set(pcb, new_backlog)


      

Marco tcp_backlog_delayed

#define         tcp_backlog_delayed(pcb)


      

Marco tcp_backlog_accepted

#define         tcp_backlog_accepted(pcb)


      

Marco tcp_accepted(pcb)

#define         tcp_accepted(pcb) do { LWIP_UNUSED_ARG(pcb); } while(0) /* compatibility define, not needed any more */


      

Marco tcp_listen(pcb)

#define         tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG)
/** @ingroup tcp_raw */

Marco tcp_dbg_get_tcp_state(pcb)

#define tcp_dbg_get_tcp_state(pcb) ((pcb)->state)


      

Marco tcp_new_ip6()

#define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6)
/* for compatibility with older implementation */

Functions

Func lwip_tcp_event

err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
        enum lwip_event,
        struct pbuf *p,
        u16_t size,
        err_t err);


      

Func tcp_accept

void            tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept);


      

Func tcp_backlog_delayed

void            tcp_backlog_delayed(struct tcp_pcb* pcb);


      

Func tcp_backlog_accepted

void            tcp_backlog_accepted(struct tcp_pcb* pcb);


      

Func tcp_recved

void            tcp_recved (struct tcp_pcb *pcb, u16_t len);


      

Func tcp_bind_netif

void            tcp_bind_netif(struct tcp_pcb *pcb, const struct netif *netif);


      

Func tcp_connect

err_t           tcp_connect (struct tcp_pcb *pcb, const ip_addr_t *ipaddr,
                             u16_t port, tcp_connected_fn connected);


      

Func tcp_abort

void            tcp_abort (struct tcp_pcb *pcb);


      

Func tcp_shutdown

err_t           tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx);


      

Func tcp_setprio

void            tcp_setprio (struct tcp_pcb *pcb, u8_t prio);


      

Func tcp_output

err_t           tcp_output (struct tcp_pcb *pcb);


      

Func tcp_tcp_get_tcp_addrinfo

err_t           tcp_tcp_get_tcp_addrinfo(struct tcp_pcb *pcb, int local, ip_addr_t *addr, u16_t *port);


      

Func tcp_ext_arg_alloc_id

u8_t tcp_ext_arg_alloc_id(void);


      

Func tcp_ext_arg_set_callbacks

void tcp_ext_arg_set_callbacks(struct tcp_pcb *pcb, uint8_t id, const struct tcp_ext_arg_callbacks * const callbacks);


      

Func tcp_ext_arg_set

void tcp_ext_arg_set(struct tcp_pcb *pcb, uint8_t id, void *arg);


      

Func tcp_ext_arg_get

void *tcp_ext_arg_get(const struct tcp_pcb *pcb, uint8_t id);

      

Vars

Variable tcp_pcb

struct tcp_pcb;


      

Variable tcp_pcb_listen

struct tcp_pcb_listen;


      

Variable tcp_pcb

struct tcp_pcb * tcp_new    (void);
/* Application program's interface: */

Variable tcp_pcb

struct tcp_pcb * tcp_new_ip_type (u8_t type);


      

Variable tcp_arg

void            tcp_arg    (struct tcp_pcb *pcb, void *arg);


      

Variable tcp_recv

void            tcp_recv   (struct tcp_pcb *pcb, tcp_recv_fn recv);


      

Variable tcp_sent

void            tcp_sent   (struct tcp_pcb *pcb, tcp_sent_fn sent);


      

Variable tcp_err

void            tcp_err    (struct tcp_pcb *pcb, tcp_err_fn err);


      

Variable tcp_poll

void            tcp_poll   (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval);


      

Variable tcp_bind

err_t           tcp_bind   (struct tcp_pcb *pcb, const ip_addr_t *ipaddr,
                             u16_t port);


      

Variable tcp_pcb

struct tcp_pcb * tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err);


      

Variable tcp_pcb

struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog);


      

Variable tcp_close

err_t           tcp_close  (struct tcp_pcb *pcb);


      

Variable tcp_write

err_t           tcp_write  (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
                             u8_t apiflags);

      

Consts

Types

Typedefs

Typedef 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.
 *
 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
 * @param newpcb The new connection pcb
 * @param err An error code if there has been an error accepting.
 *            Only return ERR_ABRT if you have called tcp_abort from within the
 *            callback function!
 */

Typedef 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.
 *
 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
 * @param tpcb The connection pcb which received data
 * @param p The received data (or NULL when the connection has been closed!)
 * @param err An error code if there has been an error receiving
 *            Only return ERR_ABRT if you have called tcp_abort from within the
 *            callback function!
 */

Typedef 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.
 *
 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
 * @param tpcb The connection pcb for which data has been acknowledged
 * @param len The amount of bytes acknowledged
 * @return 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!
 */

Typedef 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 tcp_poll.
 *
 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
 * @param tpcb tcp pcb
 * @return 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!
 */

Typedef 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!
 *
 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
 * @param err Error 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
 */

Typedef 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().
 *
 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
 * @param tpcb The connection pcb which is connected
 * @param err An unused error code, always ERR_OK currently ;-) @todo!
 *            Only return ERR_ABRT if you have called tcp_abort from within the
 *            callback function!
 *
 * @note When a connection attempt fails, the error callback is currently called!
 */

Typedef tcp_extarg_callback_pcb_destroyed_fn

typedef void (*tcp_extarg_callback_pcb_destroyed_fn)(u8_t id, void *data);
/** Function prototype for deallocation of arguments. Called *just before* the
 * pcb is freed, so don't expect to be able to do anything with this pcb!
 *
 * @param id ext arg id (allocated via @ref tcp_ext_arg_alloc_id)
 * @param data pointer to the data (set via @ref tcp_ext_arg_set before)
 */

Typedef tcp_extarg_callback_passive_open_fn

typedef err_t (*tcp_extarg_callback_passive_open_fn)(u8_t id, struct tcp_pcb_listen *lpcb, struct tcp_pcb *cpcb);
/** Function prototype to transition arguments from a listening pcb to an accepted pcb
 *
 * @param id ext arg id (allocated via @ref tcp_ext_arg_alloc_id)
 * @param lpcb the listening pcb accepting a connection
 * @param cpcb the newly allocated connection pcb
 * @return ERR_OK if OK, any error if connection should be dropped
 */

Typedef tcpflags_t

typedef u16_t tcpflags_t;
#define TCP_ALLFLAGS 0xffffU