Documentation
Includes
lwip/opt.h
#include "lwip/opt.h"
lwip/tcp.h
#include "lwip/tcp.h"
lwip/mem.h
#include "lwip/mem.h"
lwip/pbuf.h
#include "lwip/pbuf.h"
lwip/ip.h
#include "lwip/ip.h"
lwip/icmp.h
#include "lwip/icmp.h"
lwip/err.h
#include "lwip/err.h"
lwip/ip6.h
#include "lwip/ip6.h"
lwip/ip6_addr.h
#include "lwip/ip6_addr.h"
lwip/prot/tcp.h
#include "lwip/prot/tcp.h"
Macros
Marco LWIP_HDR_TCP_PRIV_H
#define LWIP_HDR_TCP_PRIV_H
Marco tcp_do_output_nagle(tpcb)
#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \
((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \
(((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \
((tpcb)->unsent->len >= (tpcb)->mss))) || \
((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \
) ? 1 : 0)
Marco tcp_output_nagle(tpcb)
#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK)
Marco TCP_SEQ_LT(a,b)
#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0)
Marco TCP_SEQ_LEQ(a,b)
#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0)
Marco TCP_SEQ_GT(a,b)
#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0)
Marco TCP_SEQ_GEQ(a,b)
#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0)
Marco TCP_SEQ_BETWEEN(a,b,c)
#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b))
Marco TCP_SEQ_BETWEEN(a,b,c)
#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c))
Marco TCP_TMR_INTERVAL
#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */
Marco TCP_FAST_INTERVAL
#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */
Marco TCP_SLOW_INTERVAL
#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */
Marco TCP_FIN_WAIT_TIMEOUT
#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */
Marco TCP_SYN_RCVD_TIMEOUT
#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */
Marco TCP_OOSEQ_TIMEOUT
#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */
Marco TCP_MSL
#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */
Marco TCP_KEEPIDLE_DEFAULT
#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */
Marco TCP_KEEPINTVL_DEFAULT
#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */
Marco TCP_KEEPCNT_DEFAULT
#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */
Marco TCP_MAXIDLE
#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */
Marco TCP_TCPLEN(seg)
#define TCP_TCPLEN(seg) ((seg)->len + (((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0) ? 1U : 0U))
Marco TF_RESET
#define TF_RESET (u8_t)0x08U /* Connection was reset. */
Marco TF_CLOSED
#define TF_CLOSED (u8_t)0x10U /* Connection was successfully closed. */
Marco TF_GOT_FIN
#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */
Marco TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret)
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) ret = lwip_tcp_event(arg, (pcb),\
LWIP_EVENT_ACCEPT, NULL, 0, err)
Marco TCP_EVENT_SENT(pcb,space,ret)
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_SENT, NULL, space, ERR_OK)
Marco TCP_EVENT_RECV(pcb,p,err,ret)
#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_RECV, (p), 0, (err))
Marco TCP_EVENT_CLOSED(pcb,ret)
#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_RECV, NULL, 0, ERR_OK)
Marco TCP_EVENT_CONNECTED(pcb,err,ret)
#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_CONNECTED, NULL, 0, (err))
Marco TCP_EVENT_POLL(pcb,ret)
#define TCP_EVENT_POLL(pcb,ret) do { if ((pcb)->state != SYN_RCVD) { \
ret = lwip_tcp_event((pcb)->callback_arg, (pcb), LWIP_EVENT_POLL, NULL, 0, ERR_OK); \
} else { \
ret = ERR_ARG; } } while(0)
Marco TCP_EVENT_ERR(last_state,errf,arg,err)
#define TCP_EVENT_ERR(last_state,errf,arg,err) do { if (last_state != SYN_RCVD) { \
lwip_tcp_event((arg), NULL, LWIP_EVENT_ERR, NULL, 0, (err)); } } while(0)
Marco TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret)
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \
do { \
if((lpcb)->accept != NULL) \
(ret) = (lpcb)->accept((arg),(pcb),(err)); \
else (ret) = ERR_ARG; \
} while (0)
Marco TCP_EVENT_SENT(pcb,space,ret)
#define TCP_EVENT_SENT(pcb,space,ret) \
do { \
if((pcb)->sent != NULL) \
(ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \
else (ret) = ERR_OK; \
} while (0)
Marco TCP_EVENT_RECV(pcb,p,err,ret)
#define TCP_EVENT_RECV(pcb,p,err,ret) \
do { \
if((pcb)->recv != NULL) { \
(ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\
} else { \
(ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \
} \
} while (0)
Marco TCP_EVENT_CLOSED(pcb,ret)
#define TCP_EVENT_CLOSED(pcb,ret) \
do { \
if(((pcb)->recv != NULL)) { \
(ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\
} else { \
(ret) = ERR_OK; \
} \
} while (0)
Marco TCP_EVENT_CONNECTED(pcb,err,ret)
#define TCP_EVENT_CONNECTED(pcb,err,ret) \
do { \
if((pcb)->connected != NULL) \
(ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \
else (ret) = ERR_OK; \
} while (0)
Marco TCP_EVENT_POLL(pcb,ret)
#define TCP_EVENT_POLL(pcb,ret) \
do { \
if((pcb)->poll != NULL) \
(ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \
else (ret) = ERR_OK; \
} while (0)
Marco TCP_EVENT_ERR(last_state,errf,arg,err)
#define TCP_EVENT_ERR(last_state,errf,arg,err) \
do { \
LWIP_UNUSED_ARG(last_state); \
if((errf) != NULL) \
(errf)((arg),(err)); \
} while (0)
Marco TCP_OVERSIZE_DBGCHECK
#define TCP_OVERSIZE_DBGCHECK 1
Marco TCP_OVERSIZE_DBGCHECK
#define TCP_OVERSIZE_DBGCHECK 0
Marco TCP_CHECKSUM_ON_COPY
#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP)
Marco LWIP_TCP_OPT_EOL
#define LWIP_TCP_OPT_EOL 0
Marco LWIP_TCP_OPT_NOP
#define LWIP_TCP_OPT_NOP 1
Marco LWIP_TCP_OPT_MSS
#define LWIP_TCP_OPT_MSS 2
Marco LWIP_TCP_OPT_WS
#define LWIP_TCP_OPT_WS 3
Marco LWIP_TCP_OPT_SACK_PERM
#define LWIP_TCP_OPT_SACK_PERM 4
Marco LWIP_TCP_OPT_TS
#define LWIP_TCP_OPT_TS 8
Marco LWIP_TCP_OPT_LEN_MSS
#define LWIP_TCP_OPT_LEN_MSS 4
Marco LWIP_TCP_OPT_LEN_TS
#define LWIP_TCP_OPT_LEN_TS 10
Marco LWIP_TCP_OPT_LEN_TS_OUT
#define LWIP_TCP_OPT_LEN_TS_OUT 12 /* aligned for output (includes NOP padding) */
Marco LWIP_TCP_OPT_LEN_TS_OUT
#define LWIP_TCP_OPT_LEN_TS_OUT 0
Marco LWIP_TCP_OPT_LEN_WS
#define LWIP_TCP_OPT_LEN_WS 3
Marco LWIP_TCP_OPT_LEN_WS_OUT
#define LWIP_TCP_OPT_LEN_WS_OUT 4 /* aligned for output (includes NOP padding) */
Marco LWIP_TCP_OPT_LEN_WS_OUT
#define LWIP_TCP_OPT_LEN_WS_OUT 0
Marco LWIP_TCP_OPT_LEN_SACK_PERM
#define LWIP_TCP_OPT_LEN_SACK_PERM 2
Marco LWIP_TCP_OPT_LEN_SACK_PERM_OUT
#define LWIP_TCP_OPT_LEN_SACK_PERM_OUT 4 /* aligned for output (includes NOP padding) */
Marco LWIP_TCP_OPT_LEN_SACK_PERM_OUT
#define LWIP_TCP_OPT_LEN_SACK_PERM_OUT 0
Marco LWIP_TCP_OPT_LENGTH(flags)
#define LWIP_TCP_OPT_LENGTH(flags) \
((flags) & TF_SEG_OPTS_MSS ? LWIP_TCP_OPT_LEN_MSS : 0) + \
((flags) & TF_SEG_OPTS_TS ? LWIP_TCP_OPT_LEN_TS_OUT : 0) + \
((flags) & TF_SEG_OPTS_WND_SCALE ? LWIP_TCP_OPT_LEN_WS_OUT : 0) + \
((flags) & TF_SEG_OPTS_SACK_PERM ? LWIP_TCP_OPT_LEN_SACK_PERM_OUT : 0)
Marco TCP_BUILD_MSS_OPTION(mss)
#define TCP_BUILD_MSS_OPTION(mss) lwip_htonl(33816576 | ((mss) & 65535))
Marco TCPWNDSIZE_F
#define TCPWNDSIZE_F U32_F
Marco TCPWND_MAX
#define TCPWND_MAX 0xFFFFFFFFU
Marco TCPWND_CHECK16(x)
#define TCPWND_CHECK16(x) LWIP_ASSERT("window size > 0xFFFF", (x) <= 65535)
Marco TCPWND_MIN16(x)
#define TCPWND_MIN16(x) ((u16_t)LWIP_MIN((x), 65535))
Marco TCPWNDSIZE_F
#define TCPWNDSIZE_F U16_F
Marco TCPWND_MAX
#define TCPWND_MAX 0xFFFFU
Marco TCPWND_CHECK16
#define TCPWND_CHECK16(x)
Marco TCPWND_MIN16(x)
#define TCPWND_MIN16(x) x
Marco NUM_TCP_PCB_LISTS_NO_TIME_WAIT
#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3
Marco NUM_TCP_PCB_LISTS
#define NUM_TCP_PCB_LISTS 4
Marco TCP_DEBUG_PCB_LISTS
#define TCP_DEBUG_PCB_LISTS 0
Marco TCP_REG(pcbs, npcb)
#define TCP_REG(pcbs, npcb) do {\
struct tcp_pcb *tcp_tmp_pcb; \
LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %"U16_F"\n", (void *)(npcb), (npcb)->local_port)); \
for (tcp_tmp_pcb = *(pcbs); \
tcp_tmp_pcb != NULL; \
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \
} \
LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \
(npcb)->next = *(pcbs); \
LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \
*(pcbs) = (npcb); \
LWIP_ASSERT("TCP_REG: tcp_pcbs sane", tcp_pcbs_sane()); \
tcp_timer_needed(); \
} while(0)
Marco TCP_RMV(pcbs, npcb)
#define TCP_RMV(pcbs, npcb) do { \
struct tcp_pcb *tcp_tmp_pcb; \
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (void *)(npcb), (void *)(*(pcbs)))); \
if(*(pcbs) == (npcb)) { \
*(pcbs) = (*pcbs)->next; \
} else for (tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
if(tcp_tmp_pcb->next == (npcb)) { \
tcp_tmp_pcb->next = (npcb)->next; \
break; \
} \
} \
(npcb)->next = NULL; \
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (void *)(npcb), (void *)(*(pcbs)))); \
} while(0)
Marco TCP_REG(pcbs, npcb)
#define TCP_REG(pcbs, npcb) \
do { \
(npcb)->next = *pcbs; \
*(pcbs) = (npcb); \
tcp_timer_needed(); \
} while (0)
Marco TCP_RMV(pcbs, npcb)
#define TCP_RMV(pcbs, npcb) \
do { \
if(*(pcbs) == (npcb)) { \
(*(pcbs)) = (*pcbs)->next; \
} \
else { \
struct tcp_pcb *tcp_tmp_pcb; \
for (tcp_tmp_pcb = *pcbs; \
tcp_tmp_pcb != NULL; \
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
if(tcp_tmp_pcb->next == (npcb)) { \
tcp_tmp_pcb->next = (npcb)->next; \
break; \
} \
} \
} \
(npcb)->next = NULL; \
} while(0)
Marco TCP_REG_ACTIVE(npcb)
#define TCP_REG_ACTIVE(npcb) \
do { \
TCP_REG(&tcp_active_pcbs, npcb); \
tcp_active_pcbs_changed = 1; \
} while (0)
Marco TCP_RMV_ACTIVE(npcb)
#define TCP_RMV_ACTIVE(npcb) \
do { \
TCP_RMV(&tcp_active_pcbs, npcb); \
tcp_active_pcbs_changed = 1; \
} while (0)
Marco TCP_PCB_REMOVE_ACTIVE(pcb)
#define TCP_PCB_REMOVE_ACTIVE(pcb) \
do { \
tcp_pcb_remove(&tcp_active_pcbs, pcb); \
tcp_active_pcbs_changed = 1; \
} while (0)
Marco tcp_ack(pcb)
#define tcp_ack(pcb) \
do { \
if((pcb)->flags & TF_ACK_DELAY) { \
tcp_clear_flags(pcb, TF_ACK_DELAY); \
tcp_ack_now(pcb); \
} \
else { \
tcp_set_flags(pcb, TF_ACK_DELAY); \
} \
} while (0)
Marco tcp_ack_now(pcb)
#define tcp_ack_now(pcb) \
tcp_set_flags(pcb, TF_ACK_NOW)
Marco tcp_eff_send_mss(sendmss, src, dest)
#define tcp_eff_send_mss(sendmss, src, dest) \
tcp_eff_send_mss_netif(sendmss, ip_route(src, dest), dest)
Functions
Func tcp_slowtmr
void tcp_slowtmr (void);
Func tcp_fasttmr
void tcp_fasttmr (void);
Func tcp_abandon
void tcp_abandon (struct tcp_pcb *pcb, int reset);
Func tcp_send_empty_ack
err_t tcp_send_empty_ack(struct tcp_pcb *pcb);
Func tcp_rexmit
err_t tcp_rexmit (struct tcp_pcb *pcb);
Func tcp_rexmit_rto_prepare
err_t tcp_rexmit_rto_prepare(struct tcp_pcb *pcb);
Func tcp_rexmit_rto_commit
void tcp_rexmit_rto_commit(struct tcp_pcb *pcb);
Func tcp_rexmit_rto
void tcp_rexmit_rto (struct tcp_pcb *pcb);
Func tcp_rexmit_fast
void tcp_rexmit_fast (struct tcp_pcb *pcb);
Func tcp_update_rcv_ann_wnd
u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb);
Func tcp_process_refused_data
err_t tcp_process_refused_data(struct tcp_pcb *pcb);
Func tcp_pcb_purge
void tcp_pcb_purge(struct tcp_pcb *pcb);
Func tcp_pcb_remove
void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);
Func tcp_segs_free
void tcp_segs_free(struct tcp_seg *seg);
Func tcp_seg_free
void tcp_seg_free(struct tcp_seg *seg);
Func tcp_send_fin
err_t tcp_send_fin(struct tcp_pcb *pcb);
Func tcp_enqueue_flags
err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags);
Func tcp_rexmit_seg
void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
Func tcp_rst
void tcp_rst(const struct tcp_pcb* pcb, u32_t seqno, u32_t ackno,
const ip_addr_t *local_ip, const ip_addr_t *remote_ip,
u16_t local_port, u16_t remote_port);
Func tcp_next_iss
u32_t tcp_next_iss(struct tcp_pcb *pcb);
Func tcp_keepalive
err_t tcp_keepalive(struct tcp_pcb *pcb);
Func tcp_split_unsent_seg
err_t tcp_split_unsent_seg(struct tcp_pcb *pcb, u16_t split);
Func tcp_zero_window_probe
err_t tcp_zero_window_probe(struct tcp_pcb *pcb);
void tcp_trigger_input_pcb_close(void);
Func tcp_eff_send_mss_netif
u16_t tcp_eff_send_mss_netif(u16_t sendmss, struct netif *outif,
const ip_addr_t *dest);
Func tcp_recv_null
err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
Func tcp_debug_print
void tcp_debug_print(struct tcp_hdr *tcphdr);
Func tcp_debug_print_flags
void tcp_debug_print_flags(u8_t flags);
Func tcp_debug_print_state
void tcp_debug_print_state(enum tcp_state s);
Func tcp_debug_print_pcbs
void tcp_debug_print_pcbs(void);
Func tcp_pcbs_sane
s16_t tcp_pcbs_sane(void);
Func tcp_timer_needed
void tcp_timer_needed(void);
Func tcp_netif_ip_addr_changed
void tcp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr);
Func tcp_free_ooseq
void tcp_free_ooseq(struct tcp_pcb *pcb);
Func tcp_ext_arg_invoke_callbacks_passive_open
err_t tcp_ext_arg_invoke_callbacks_passive_open(struct tcp_pcb_listen *lpcb, struct tcp_pcb *cpcb);
Vars
Variable tcp_init
void tcp_init (void);
Variable tcp_tmr
void tcp_tmr (void);
Variable tcp_txnow
void tcp_txnow (void);
void tcp_input (struct pbuf *p, struct netif *inp);
Variable tcp_pcb
struct tcp_pcb * tcp_alloc (u8_t prio);
Variable tcp_free
void tcp_free (struct tcp_pcb *pcb);
Variable tcp_pcb
struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);
Variable tcp_seg
struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);
Consts
Types
Typedefs