57 #ifndef LWIP_HDR_TCP_H 58 #define LWIP_HDR_TCP_H 87 typedef err_t (*tcp_accept_fn)(
void *arg,
struct tcp_pcb *newpcb,
err_t err);
99 typedef err_t (*tcp_recv_fn)(
void *arg,
struct tcp_pcb *tpcb,
113 typedef err_t (*tcp_sent_fn)(
void *arg,
struct tcp_pcb *tpcb,
125 typedef err_t (*tcp_poll_fn)(
void *arg,
struct tcp_pcb *tpcb);
137 typedef void (*tcp_err_fn)(
void *arg,
err_t err);
151 typedef err_t (*tcp_connected_fn)(
void *arg,
struct tcp_pcb *tpcb,
err_t err);
154 #define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale)) 155 #define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale)) 156 #define TCPWND16(x) ((u16_t)LWIP_MIN((x), 0xFFFF)) 157 #define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND))) 158 typedef u32_t tcpwnd_size_t;
160 #define RCV_WND_SCALE(pcb, wnd) (wnd) 161 #define SND_WND_SCALE(pcb, wnd) (wnd) 162 #define TCPWND16(x) (x) 163 #define TCP_WND_MAX(pcb) TCP_WND 164 typedef u16_t tcpwnd_size_t;
167 #if LWIP_WND_SCALE || TCP_LISTEN_BACKLOG || LWIP_TCP_TIMESTAMPS 168 typedef u16_t tcpflags_t;
170 typedef u8_t tcpflags_t;
190 #define TCP_PCB_COMMON(type) \ 192 void *callback_arg; \ 193 enum tcp_state state; \ 200 struct tcp_pcb_listen {
204 TCP_PCB_COMMON(
struct tcp_pcb_listen);
206 #if LWIP_CALLBACK_API 208 tcp_accept_fn accept;
211 #if TCP_LISTEN_BACKLOG 213 u8_t accepts_pending;
223 TCP_PCB_COMMON(
struct tcp_pcb);
229 #define TF_ACK_DELAY 0x01U 230 #define TF_ACK_NOW 0x02U 231 #define TF_INFR 0x04U 232 #define TF_CLOSEPEND 0x08U 233 #define TF_RXCLOSED 0x10U 235 #define TF_NODELAY 0x40U 236 #define TF_NAGLEMEMERR 0x80U 238 #define TF_WND_SCALE 0x0100U 240 #if TCP_LISTEN_BACKLOG 241 #define TF_BACKLOGPEND 0x0200U 243 #if LWIP_TCP_TIMESTAMPS 244 #define TF_TIMESTAMP 0x0400U 251 u8_t polltmr, pollinterval;
257 tcpwnd_size_t rcv_wnd;
258 tcpwnd_size_t rcv_ann_wnd;
259 u32_t rcv_ann_right_edge;
280 tcpwnd_size_t ssthresh;
284 u32_t snd_wl1, snd_wl2;
287 tcpwnd_size_t snd_wnd;
288 tcpwnd_size_t snd_wnd_max;
290 tcpwnd_size_t snd_buf;
291 #define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) 296 u16_t unsent_oversize;
300 struct tcp_seg *unsent;
301 struct tcp_seg *unacked;
303 struct tcp_seg *ooseq;
306 struct pbuf *refused_data;
308 #if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG 309 struct tcp_pcb_listen* listener;
312 #if LWIP_CALLBACK_API 318 tcp_connected_fn connected;
325 #if LWIP_TCP_TIMESTAMPS 326 u32_t ts_lastacksent;
332 #if LWIP_TCP_KEEPALIVE 340 u8_t persist_backoff;
357 LWIP_EVENT_CONNECTED,
362 err_t lwip_tcp_event(
void *arg,
struct tcp_pcb *pcb,
371 struct tcp_pcb * tcp_new (
void);
372 struct tcp_pcb * tcp_new_ip_type (u8_t type);
374 void tcp_arg (
struct tcp_pcb *pcb,
void *arg);
375 #if LWIP_CALLBACK_API 376 void tcp_recv (
struct tcp_pcb *pcb, tcp_recv_fn recv);
377 void tcp_sent (
struct tcp_pcb *pcb, tcp_sent_fn sent);
378 void tcp_err (
struct tcp_pcb *pcb, tcp_err_fn err);
379 void tcp_accept (
struct tcp_pcb *pcb, tcp_accept_fn accept);
381 void tcp_poll (
struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval);
383 #if LWIP_TCP_TIMESTAMPS 384 #define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss) 386 #define tcp_mss(pcb) ((pcb)->mss) 388 #define tcp_sndbuf(pcb) (TCPWND16((pcb)->snd_buf)) 389 #define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen) 391 #define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) 393 #define tcp_nagle_enable(pcb) ((pcb)->flags = (tcpflags_t)((pcb)->flags & ~TF_NODELAY)) 395 #define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) 397 #if TCP_LISTEN_BACKLOG 398 #define tcp_backlog_set(pcb, new_backlog) do { \ 399 LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", (pcb)->state == LISTEN); \ 400 ((struct tcp_pcb_listen *)(pcb))->backlog = ((new_backlog) ? (new_backlog) : 1); } while(0) 401 void tcp_backlog_delayed(
struct tcp_pcb* pcb);
402 void tcp_backlog_accepted(
struct tcp_pcb* pcb);
404 #define tcp_backlog_set(pcb, new_backlog) 405 #define tcp_backlog_delayed(pcb) 406 #define tcp_backlog_accepted(pcb) 408 #define tcp_accepted(pcb) 410 void tcp_recved (
struct tcp_pcb *pcb, u16_t len);
411 err_t tcp_bind (
struct tcp_pcb *pcb,
const ip_addr_t *ipaddr,
413 err_t tcp_connect (
struct tcp_pcb *pcb,
const ip_addr_t *ipaddr,
414 u16_t port, tcp_connected_fn connected);
416 struct tcp_pcb * tcp_listen_with_backlog_and_err(
struct tcp_pcb *pcb, u8_t backlog,
err_t *err);
417 struct tcp_pcb * tcp_listen_with_backlog(
struct tcp_pcb *pcb, u8_t backlog);
419 #define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) 421 void tcp_abort (
struct tcp_pcb *pcb);
422 err_t tcp_close (
struct tcp_pcb *pcb);
423 err_t tcp_shutdown(
struct tcp_pcb *pcb,
int shut_rx,
int shut_tx);
426 #define TCP_WRITE_FLAG_COPY 0x01 427 #define TCP_WRITE_FLAG_MORE 0x02 429 err_t tcp_write (
struct tcp_pcb *pcb,
const void *dataptr, u16_t len,
432 void tcp_setprio (
struct tcp_pcb *pcb, u8_t prio);
434 #define TCP_PRIO_MIN 1 435 #define TCP_PRIO_NORMAL 64 436 #define TCP_PRIO_MAX 127 438 err_t tcp_output (
struct tcp_pcb *pcb);
441 const char* tcp_debug_state_str(
enum tcp_state s);
444 #define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6)