38 #ifndef LWIP_HDR_TCP_H    39 #define LWIP_HDR_TCP_H    59 struct tcp_pcb_listen;
    70 typedef err_t (*tcp_accept_fn)(
void *arg, 
struct tcp_pcb *newpcb, err_t err);
    82 typedef err_t (*tcp_recv_fn)(
void *arg, 
struct tcp_pcb *tpcb,
    83                              struct pbuf *p, err_t err);
    96 typedef err_t (*tcp_sent_fn)(
void *arg, 
struct tcp_pcb *tpcb,
   108 typedef err_t (*tcp_poll_fn)(
void *arg, 
struct tcp_pcb *tpcb);
   120 typedef void  (*tcp_err_fn)(
void *arg, err_t err);
   134 typedef err_t (*tcp_connected_fn)(
void *arg, 
struct tcp_pcb *tpcb, err_t err);
   137 #define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale))   138 #define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale))   139 #define TCPWND16(x)             ((u16_t)LWIP_MIN((x), 0xFFFF))   140 #define TCP_WND_MAX(pcb)        ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND)))   142 #define RCV_WND_SCALE(pcb, wnd) (wnd)   143 #define SND_WND_SCALE(pcb, wnd) (wnd)   144 #define TCPWND16(x)             (x)   145 #define TCP_WND_MAX(pcb)        TCP_WND   148 #define TCP_WND_INC(wnd, inc)   do { \   149                                   if ((tcpwnd_size_t)(wnd + inc) >= wnd) { \   150                                     wnd = (tcpwnd_size_t)(wnd + inc); \   152                                     wnd = (tcpwnd_size_t)-1; \   156 #if LWIP_TCP_SACK_OUT   159 struct tcp_sack_range {
   173 typedef void (*tcp_extarg_callback_pcb_destroyed_fn)(u8_t id, 
void *data);
   182 typedef err_t (*tcp_extarg_callback_passive_open_fn)(u8_t id, 
struct tcp_pcb_listen *lpcb, 
struct tcp_pcb *cpcb);
   185 struct tcp_ext_arg_callbacks {
   187   tcp_extarg_callback_pcb_destroyed_fn destroy;
   189   tcp_extarg_callback_passive_open_fn passive_open;
   192 #define LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID 0xFF   194 #if LWIP_TCP_PCB_NUM_EXT_ARGS   196 struct tcp_pcb_ext_args {
   197   const struct tcp_ext_arg_callbacks *callbacks;
   201 #define TCP_PCB_EXTARGS struct tcp_pcb_ext_args ext_args[LWIP_TCP_PCB_NUM_EXT_ARGS];   203 #define TCP_PCB_EXTARGS   206 typedef u16_t tcpflags_t;
   207 #define TCP_ALLFLAGS 0xffffU   212 #define TCP_PCB_COMMON(type) \   214   void *callback_arg; \   216   enum tcp_state state;  \   223 struct tcp_pcb_listen {
   227   TCP_PCB_COMMON(
struct tcp_pcb_listen);
   229 #if LWIP_CALLBACK_API   231   tcp_accept_fn accept;
   234 #if TCP_LISTEN_BACKLOG   236   u8_t accepts_pending;
   246   TCP_PCB_COMMON(
struct tcp_pcb);
   252 #define TF_ACK_DELAY   0x01U      253 #define TF_ACK_NOW     0x02U      254 #define TF_INFR        0x04U      255 #define TF_CLOSEPEND   0x08U      256 #define TF_RXCLOSED    0x10U      258 #define TF_NODELAY     0x40U      259 #define TF_NAGLEMEMERR 0x80U      261 #define TF_WND_SCALE   0x0100U    263 #if TCP_LISTEN_BACKLOG   264 #define TF_BACKLOGPEND 0x0200U    266 #if LWIP_TCP_TIMESTAMPS   267 #define TF_TIMESTAMP   0x0400U      269 #define TF_RTO         0x0800U    270 #if LWIP_TCP_SACK_OUT   271 #define TF_SACK        0x1000U    278   u8_t polltmr, pollinterval;
   284   tcpwnd_size_t rcv_wnd;   
   285   tcpwnd_size_t rcv_ann_wnd; 
   286   u32_t rcv_ann_right_edge; 
   288 #if LWIP_TCP_SACK_OUT   291 #define LWIP_TCP_SACK_VALID(pcb, idx) ((pcb)->rcv_sacks[idx].left != (pcb)->rcv_sacks[idx].right)   313   tcpwnd_size_t ssthresh;
   320   u32_t snd_wl1, snd_wl2; 
   323   tcpwnd_size_t snd_wnd;   
   324   tcpwnd_size_t snd_wnd_max; 
   326   tcpwnd_size_t snd_buf;   
   327 #define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3)   332   u16_t unsent_oversize;
   335   tcpwnd_size_t bytes_acked;
   338   struct tcp_seg *unsent;   
   339   struct tcp_seg *unacked;  
   341   struct tcp_seg *ooseq;    
   344   struct pbuf *refused_data; 
   346 #if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG   347   struct tcp_pcb_listen* listener;
   350 #if LWIP_CALLBACK_API   356   tcp_connected_fn connected;
   363 #if LWIP_TCP_TIMESTAMPS   364   u32_t ts_lastacksent;
   370 #if LWIP_TCP_KEEPALIVE   378   u8_t persist_backoff;
   397   LWIP_EVENT_CONNECTED,
   402 err_t lwip_tcp_event(
void *arg, 
struct tcp_pcb *pcb,
   411 struct tcp_pcb * tcp_new     (
void);
   412 struct tcp_pcb * tcp_new_ip_type (u8_t type);
   414 void             tcp_arg     (
struct tcp_pcb *pcb, 
void *arg);
   415 #if LWIP_CALLBACK_API   416 void             tcp_recv    (
struct tcp_pcb *pcb, tcp_recv_fn recv);
   417 void             tcp_sent    (
struct tcp_pcb *pcb, tcp_sent_fn sent);
   418 void             tcp_err     (
struct tcp_pcb *pcb, tcp_err_fn err);
   419 void             tcp_accept  (
struct tcp_pcb *pcb, tcp_accept_fn accept);
   421 void             tcp_poll    (
struct tcp_pcb *pcb, tcp_poll_fn 
poll, u8_t interval);
   423 #define          tcp_set_flags(pcb, set_flags)     do { (pcb)->flags = (tcpflags_t)((pcb)->flags |  (set_flags)); } while(0)   424 #define          tcp_clear_flags(pcb, clr_flags)   do { (pcb)->flags = (tcpflags_t)((pcb)->flags & (tcpflags_t)(~(clr_flags) & TCP_ALLFLAGS)); } while(0)   425 #define          tcp_is_flag_set(pcb, flag)        (((pcb)->flags & (flag)) != 0)   427 #if LWIP_TCP_TIMESTAMPS   428 #define          tcp_mss(pcb)             (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12)  : (pcb)->mss)   431 #define          tcp_mss(pcb)             ((pcb)->mss)   434 #define          tcp_sndbuf(pcb)          (TCPWND16((pcb)->snd_buf))   436 #define          tcp_sndqueuelen(pcb)     ((pcb)->snd_queuelen)   438 #define          tcp_nagle_disable(pcb)   tcp_set_flags(pcb, TF_NODELAY)   440 #define          tcp_nagle_enable(pcb)    tcp_clear_flags(pcb, TF_NODELAY)   442 #define          tcp_nagle_disabled(pcb)  tcp_is_flag_set(pcb, TF_NODELAY)   444 #if TCP_LISTEN_BACKLOG   445 #define          tcp_backlog_set(pcb, new_backlog) do { \   446   LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", (pcb)->state == LISTEN); \   447   ((struct tcp_pcb_listen *)(pcb))->backlog = ((new_backlog) ? (new_backlog) : 1); } while(0)   448 void             tcp_backlog_delayed(
struct tcp_pcb* pcb);
   449 void             tcp_backlog_accepted(
struct tcp_pcb* pcb);
   451 #define          tcp_backlog_set(pcb, new_backlog)   452 #define          tcp_backlog_delayed(pcb)   453 #define          tcp_backlog_accepted(pcb)   455 #define          tcp_accepted(pcb) do { LWIP_UNUSED_ARG(pcb); } while(0)    457 void             tcp_recved  (
struct tcp_pcb *pcb, u16_t len);
   458 err_t            tcp_bind    (
struct tcp_pcb *pcb, 
const ip_addr_t *ipaddr,
   460 void             tcp_bind_netif(
struct tcp_pcb *pcb, 
const struct netif *
netif);
   461 err_t            tcp_connect (
struct tcp_pcb *pcb, 
const ip_addr_t *ipaddr,
   462                               u16_t port, tcp_connected_fn connected);
   464 struct tcp_pcb * tcp_listen_with_backlog_and_err(
struct tcp_pcb *pcb, u8_t backlog, err_t *err);
   465 struct tcp_pcb * tcp_listen_with_backlog(
struct tcp_pcb *pcb, u8_t backlog);
   467 #define          tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG)   469 void             tcp_abort (
struct tcp_pcb *pcb);
   470 err_t            tcp_close   (
struct tcp_pcb *pcb);
   471 err_t            tcp_shutdown(
struct tcp_pcb *pcb, 
int shut_rx, 
int shut_tx);
   473 err_t            tcp_write   (
struct tcp_pcb *pcb, 
const void *dataptr, u16_t len,
   476 void             tcp_setprio (
struct tcp_pcb *pcb, u8_t prio);
   478 err_t            tcp_output  (
struct tcp_pcb *pcb);
   480 err_t            tcp_tcp_get_tcp_addrinfo(
struct tcp_pcb *pcb, 
int local, 
ip_addr_t *addr, u16_t *port);
   482 #define tcp_dbg_get_tcp_state(pcb) ((pcb)->state)   485 #define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6)   487 #if LWIP_TCP_PCB_NUM_EXT_ARGS   488 u8_t tcp_ext_arg_alloc_id(
void);
   489 void tcp_ext_arg_set_callbacks(
struct tcp_pcb *pcb, uint8_t 
id, 
const struct tcp_ext_arg_callbacks * 
const callbacks);
   490 void tcp_ext_arg_set(
struct tcp_pcb *pcb, uint8_t 
id, 
void *arg);
   491 void *tcp_ext_arg_get(
const struct tcp_pcb *pcb, uint8_t 
id);
 
#define IP_PCB
This is the common part of all PCB types. 
lwIP Options Configuration 
Main packet buffer struct. 
Generic data structure used for all lwIP network interfaces. 
s8_t err_t
Define LWIP_ERR_T in cc.h if you want to use a different type for your platform (must be signed)...
IP address structure for passing IP addresses by value. 
#define LWIP_TCP_MAX_SACK_NUM
LWIP_TCP_MAX_SACK_NUM: The maximum number of SACK values to include in TCP segments. 
Base TCP API definitions shared by TCP and ALTCP See also tcp_raw.