STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
tcp_priv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 #ifndef LWIP_HDR_TCP_IMPL_H
33 #define LWIP_HDR_TCP_IMPL_H
34 
35 #include "lwip/opt.h"
36 
37 #if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
38 
39 #include "lwip/tcp.h"
40 #include "lwip/mem.h"
41 #include "lwip/pbuf.h"
42 #include "lwip/ip.h"
43 #include "lwip/icmp.h"
44 #include "lwip/err.h"
45 #include "lwip/ip6.h"
46 #include "lwip/ip6_addr.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /* Functions for interfacing with TCP: */
53 
54 /* Lower layer interface to TCP: */
55 void tcp_init (void); /* Initialize this module. */
56 void tcp_tmr (void); /* Must be called every
57  TCP_TMR_INTERVAL
58  ms. (Typically 250 ms). */
59 /* It is also possible to call these two functions at the right
60  intervals (instead of calling tcp_tmr()). */
61 void tcp_slowtmr (void);
62 void tcp_fasttmr (void);
63 
64 /* Call this from a netif driver (watch out for threading issues!) that has
65  returned a memory error on transmit and now has free buffers to send more.
66  This iterates all active pcbs that had an error and tries to call
67  tcp_output, so use this with care as it might slow down the system. */
68 void tcp_txnow (void);
69 
70 /* Only used by IP to pass a TCP segment to TCP: */
71 void tcp_input (struct pbuf *p, struct netif *inp);
72 /* Used within the TCP code only: */
73 struct tcp_pcb * tcp_alloc (u8_t prio);
74 void tcp_abandon (struct tcp_pcb *pcb, int reset);
75 err_t tcp_send_empty_ack(struct tcp_pcb *pcb);
76 void tcp_rexmit (struct tcp_pcb *pcb);
77 void tcp_rexmit_rto (struct tcp_pcb *pcb);
78 void tcp_rexmit_fast (struct tcp_pcb *pcb);
79 u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb);
80 err_t tcp_process_refused_data(struct tcp_pcb *pcb);
81 
91 #define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \
92  ((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \
93  (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \
94  ((tpcb)->unsent->len >= (tpcb)->mss))) || \
95  ((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \
96  ) ? 1 : 0)
97 #define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK)
98 
99 
100 #define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0)
101 #define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0)
102 #define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0)
103 #define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0)
104 /* is b<=a<=c? */
105 #if 0 /* see bug #10548 */
106 #define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b))
107 #endif
108 #define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c))
109 #define TCP_FIN 0x01U
110 #define TCP_SYN 0x02U
111 #define TCP_RST 0x04U
112 #define TCP_PSH 0x08U
113 #define TCP_ACK 0x10U
114 #define TCP_URG 0x20U
115 #define TCP_ECE 0x40U
116 #define TCP_CWR 0x80U
117 
118 #define TCP_FLAGS 0x3fU
119 
120 /* Length of the TCP header, excluding options. */
121 #define TCP_HLEN 20
122 
123 #ifndef TCP_TMR_INTERVAL
124 #define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */
125 #endif /* TCP_TMR_INTERVAL */
126 
127 #ifndef TCP_FAST_INTERVAL
128 #define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */
129 #endif /* TCP_FAST_INTERVAL */
130 
131 #ifndef TCP_SLOW_INTERVAL
132 #define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */
133 #endif /* TCP_SLOW_INTERVAL */
134 
135 #define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */
136 #define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */
137 
138 #define TCP_OOSEQ_TIMEOUT 6U /* x RTO */
139 
140 #ifndef TCP_MSL
141 #define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */
142 #endif
143 
144 /* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */
145 #ifndef TCP_KEEPIDLE_DEFAULT
146 #define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */
147 #endif
148 
149 #ifndef TCP_KEEPINTVL_DEFAULT
150 #define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */
151 #endif
152 
153 #ifndef TCP_KEEPCNT_DEFAULT
154 #define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */
155 #endif
156 
157 #define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */
158 
159 /* Fields are (of course) in network byte order.
160  * Some fields are converted to host byte order in tcp_input().
161  */
162 #ifdef PACK_STRUCT_USE_INCLUDES
163 # include "arch/bpstruct.h"
164 #endif
166 struct tcp_hdr {
168  PACK_STRUCT_FIELD(u16_t dest);
169  PACK_STRUCT_FIELD(u32_t seqno);
170  PACK_STRUCT_FIELD(u32_t ackno);
171  PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags);
173  PACK_STRUCT_FIELD(u16_t chksum);
174  PACK_STRUCT_FIELD(u16_t urgp);
177 #ifdef PACK_STRUCT_USE_INCLUDES
178 # include "arch/epstruct.h"
179 #endif
180 
181 #define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)
182 #define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)
183 
184 #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr))
185 #define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | htons(flags))
186 #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags))
187 
188 #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags))
189 #define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~htons(flags))
190 
191 #define TCP_TCPLEN(seg) ((seg)->len + (((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0) ? 1U : 0U))
192 
195 #define TF_RESET (u8_t)0x08U /* Connection was reset. */
196 #define TF_CLOSED (u8_t)0x10U /* Connection was successfully closed. */
197 #define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */
198 
199 
200 #if LWIP_EVENT_API
201 
202 #define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
203  LWIP_EVENT_ACCEPT, NULL, 0, err)
204 #define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
205  LWIP_EVENT_SENT, NULL, space, ERR_OK)
206 #define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
207  LWIP_EVENT_RECV, (p), 0, (err))
208 #define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
209  LWIP_EVENT_RECV, NULL, 0, ERR_OK)
210 #define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
211  LWIP_EVENT_CONNECTED, NULL, 0, (err))
212 #define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
213  LWIP_EVENT_POLL, NULL, 0, ERR_OK)
214 #define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \
215  LWIP_EVENT_ERR, NULL, 0, (err))
216 
217 #else /* LWIP_EVENT_API */
218 
219 #define TCP_EVENT_ACCEPT(pcb,err,ret) \
220  do { \
221  if((pcb)->accept != NULL) \
222  (ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \
223  else (ret) = ERR_ARG; \
224  } while (0)
225 
226 #define TCP_EVENT_SENT(pcb,space,ret) \
227  do { \
228  if((pcb)->sent != NULL) \
229  (ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \
230  else (ret) = ERR_OK; \
231  } while (0)
232 
233 #define TCP_EVENT_RECV(pcb,p,err,ret) \
234  do { \
235  if((pcb)->recv != NULL) { \
236  (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\
237  } else { \
238  (ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \
239  } \
240  } while (0)
241 
242 #define TCP_EVENT_CLOSED(pcb,ret) \
243  do { \
244  if(((pcb)->recv != NULL)) { \
245  (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\
246  } else { \
247  (ret) = ERR_OK; \
248  } \
249  } while (0)
250 
251 #define TCP_EVENT_CONNECTED(pcb,err,ret) \
252  do { \
253  if((pcb)->connected != NULL) \
254  (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \
255  else (ret) = ERR_OK; \
256  } while (0)
257 
258 #define TCP_EVENT_POLL(pcb,ret) \
259  do { \
260  if((pcb)->poll != NULL) \
261  (ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \
262  else (ret) = ERR_OK; \
263  } while (0)
264 
265 #define TCP_EVENT_ERR(errf,arg,err) \
266  do { \
267  if((errf) != NULL) \
268  (errf)((arg),(err)); \
269  } while (0)
270 
271 #endif /* LWIP_EVENT_API */
272 
274 #if TCP_OVERSIZE && defined(LWIP_DEBUG)
275 #define TCP_OVERSIZE_DBGCHECK 1
276 #else
277 #define TCP_OVERSIZE_DBGCHECK 0
278 #endif
279 
281 #define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP)
282 
283 /* This structure represents a TCP segment on the unsent, unacked and ooseq queues */
284 struct tcp_seg {
285  struct tcp_seg *next; /* used when putting segments on a queue */
286  struct pbuf *p; /* buffer containing data + TCP header */
287  u16_t len; /* the TCP length of this segment */
288 #if TCP_OVERSIZE_DBGCHECK
289  u16_t oversize_left; /* Extra bytes available at the end of the last
290  pbuf in unsent (used for asserting vs.
291  tcp_pcb.unsent_oversized only) */
292 #endif /* TCP_OVERSIZE_DBGCHECK */
293 #if TCP_CHECKSUM_ON_COPY
294  u16_t chksum;
295  u8_t chksum_swapped;
296 #endif /* TCP_CHECKSUM_ON_COPY */
297  u8_t flags;
298 #define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */
299 #define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */
300 #define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is
301  checksummed into 'chksum' */
302 #define TF_SEG_OPTS_WND_SCALE (u8_t)0x08U /* Include WND SCALE option */
303  struct tcp_hdr *tcphdr; /* the TCP header */
304 };
305 
306 #define LWIP_TCP_OPT_EOL 0
307 #define LWIP_TCP_OPT_NOP 1
308 #define LWIP_TCP_OPT_MSS 2
309 #define LWIP_TCP_OPT_WS 3
310 #define LWIP_TCP_OPT_TS 8
311 
312 #define LWIP_TCP_OPT_LEN_MSS 4
313 #if LWIP_TCP_TIMESTAMPS
314 #define LWIP_TCP_OPT_LEN_TS 10
315 #define LWIP_TCP_OPT_LEN_TS_OUT 12 /* aligned for output (includes NOP padding) */
316 #else
317 #define LWIP_TCP_OPT_LEN_TS_OUT 0
318 #endif
319 #if LWIP_WND_SCALE
320 #define LWIP_TCP_OPT_LEN_WS 3
321 #define LWIP_TCP_OPT_LEN_WS_OUT 4 /* aligned for output (includes NOP padding) */
322 #else
323 #define LWIP_TCP_OPT_LEN_WS_OUT 0
324 #endif
325 
326 #define LWIP_TCP_OPT_LENGTH(flags) \
327  (flags & TF_SEG_OPTS_MSS ? LWIP_TCP_OPT_LEN_MSS : 0) + \
328  (flags & TF_SEG_OPTS_TS ? LWIP_TCP_OPT_LEN_TS_OUT : 0) + \
329  (flags & TF_SEG_OPTS_WND_SCALE ? LWIP_TCP_OPT_LEN_WS_OUT : 0)
330 
332 #define TCP_BUILD_MSS_OPTION(mss) htonl(0x02040000 | ((mss) & 0xFFFF))
333 
334 #if LWIP_WND_SCALE
335 #define TCPWNDSIZE_F U32_F
336 #define TCPWND_MAX 0xFFFFFFFFU
337 #define TCPWND_CHECK16(x) LWIP_ASSERT("window size > 0xFFFF", (x) <= 0xFFFF)
338 #define TCPWND_MIN16(x) ((u16_t)LWIP_MIN((x), 0xFFFF))
339 #else /* LWIP_WND_SCALE */
340 #define TCPWNDSIZE_F U16_F
341 #define TCPWND_MAX 0xFFFFU
342 #define TCPWND_CHECK16(x)
343 #define TCPWND_MIN16(x) x
344 #endif /* LWIP_WND_SCALE */
345 
346 /* Global variables: */
347 extern struct tcp_pcb *tcp_input_pcb;
348 extern u32_t tcp_ticks;
349 extern u8_t tcp_active_pcbs_changed;
350 
351 /* The TCP PCB lists. */
352 union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */
353  struct tcp_pcb_listen *listen_pcbs;
354  struct tcp_pcb *pcbs;
355 };
356 extern struct tcp_pcb *tcp_bound_pcbs;
357 extern union tcp_listen_pcbs_t tcp_listen_pcbs;
358 extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
359  state in which they accept or send
360  data. */
361 extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
362 
363 #define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3
364 #define NUM_TCP_PCB_LISTS 4
365 extern struct tcp_pcb ** const tcp_pcb_lists[NUM_TCP_PCB_LISTS];
366 
367 /* Axioms about the above lists:
368  1) Every TCP PCB that is not CLOSED is in one of the lists.
369  2) A PCB is only in one of the lists.
370  3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.
371  4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state.
372 */
373 /* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
374  with a PCB list or removes a PCB from a list, respectively. */
375 #ifndef TCP_DEBUG_PCB_LISTS
376 #define TCP_DEBUG_PCB_LISTS 0
377 #endif
378 #if TCP_DEBUG_PCB_LISTS
379 #define TCP_REG(pcbs, npcb) do {\
380  struct tcp_pcb *tcp_tmp_pcb; \
381  LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \
382  for (tcp_tmp_pcb = *(pcbs); \
383  tcp_tmp_pcb != NULL; \
384  tcp_tmp_pcb = tcp_tmp_pcb->next) { \
385  LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \
386  } \
387  LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \
388  (npcb)->next = *(pcbs); \
389  LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \
390  *(pcbs) = (npcb); \
391  LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
392  tcp_timer_needed(); \
393  } while(0)
394 #define TCP_RMV(pcbs, npcb) do { \
395  struct tcp_pcb *tcp_tmp_pcb; \
396  LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
397  LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
398  if(*(pcbs) == (npcb)) { \
399  *(pcbs) = (*pcbs)->next; \
400  } else for (tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
401  if(tcp_tmp_pcb->next == (npcb)) { \
402  tcp_tmp_pcb->next = (npcb)->next; \
403  break; \
404  } \
405  } \
406  (npcb)->next = NULL; \
407  LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
408  LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \
409  } while(0)
410 
411 #else /* LWIP_DEBUG */
412 
413 #define TCP_REG(pcbs, npcb) \
414  do { \
415  (npcb)->next = *pcbs; \
416  *(pcbs) = (npcb); \
417  tcp_timer_needed(); \
418  } while (0)
419 
420 #define TCP_RMV(pcbs, npcb) \
421  do { \
422  if(*(pcbs) == (npcb)) { \
423  (*(pcbs)) = (*pcbs)->next; \
424  } \
425  else { \
426  struct tcp_pcb *tcp_tmp_pcb; \
427  for (tcp_tmp_pcb = *pcbs; \
428  tcp_tmp_pcb != NULL; \
429  tcp_tmp_pcb = tcp_tmp_pcb->next) { \
430  if(tcp_tmp_pcb->next == (npcb)) { \
431  tcp_tmp_pcb->next = (npcb)->next; \
432  break; \
433  } \
434  } \
435  } \
436  (npcb)->next = NULL; \
437  } while(0)
438 
439 #endif /* LWIP_DEBUG */
440 
441 #define TCP_REG_ACTIVE(npcb) \
442  do { \
443  TCP_REG(&tcp_active_pcbs, npcb); \
444  tcp_active_pcbs_changed = 1; \
445  } while (0)
446 
447 #define TCP_RMV_ACTIVE(npcb) \
448  do { \
449  TCP_RMV(&tcp_active_pcbs, npcb); \
450  tcp_active_pcbs_changed = 1; \
451  } while (0)
452 
453 #define TCP_PCB_REMOVE_ACTIVE(pcb) \
454  do { \
455  tcp_pcb_remove(&tcp_active_pcbs, pcb); \
456  tcp_active_pcbs_changed = 1; \
457  } while (0)
458 
459 
460 /* Internal functions: */
461 struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);
462 void tcp_pcb_purge(struct tcp_pcb *pcb);
463 void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);
464 
465 void tcp_segs_free(struct tcp_seg *seg);
466 void tcp_seg_free(struct tcp_seg *seg);
467 struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);
468 
469 #define tcp_ack(pcb) \
470  do { \
471  if((pcb)->flags & TF_ACK_DELAY) { \
472  (pcb)->flags &= ~TF_ACK_DELAY; \
473  (pcb)->flags |= TF_ACK_NOW; \
474  } \
475  else { \
476  (pcb)->flags |= TF_ACK_DELAY; \
477  } \
478  } while (0)
479 
480 #define tcp_ack_now(pcb) \
481  do { \
482  (pcb)->flags |= TF_ACK_NOW; \
483  } while (0)
484 
485 err_t tcp_send_fin(struct tcp_pcb *pcb);
486 err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags);
487 
488 void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
489 
490 void tcp_rst(u32_t seqno, u32_t ackno,
491  const ip_addr_t *local_ip, const ip_addr_t *remote_ip,
492  u16_t local_port, u16_t remote_port);
493 
494 u32_t tcp_next_iss(void);
495 
496 err_t tcp_keepalive(struct tcp_pcb *pcb);
497 err_t tcp_zero_window_probe(struct tcp_pcb *pcb);
498 void tcp_trigger_input_pcb_close(void);
499 
500 #if TCP_CALCULATE_EFF_SEND_MSS
501 u16_t tcp_eff_send_mss_impl(u16_t sendmss, const ip_addr_t *dest
502 #if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING
503  , const ip_addr_t *src
504 #endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */
505 #if LWIP_IPV6 && LWIP_IPV4
506  , u8_t isipv6
507 #endif /* LWIP_IPV6 && LWIP_IPV4 */
508  );
509 #if LWIP_IPV4 && LWIP_IPV6
510 #define tcp_eff_send_mss(sendmss, src, dest, isipv6) tcp_eff_send_mss_impl(sendmss, dest, src, isipv6)
511 #elif LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING
512 #define tcp_eff_send_mss(sendmss, src, dest, isipv6) tcp_eff_send_mss_impl(sendmss, dest, src)
513 #else /* LWIP_IPV4 && LWIP_IPV6 */
514 #define tcp_eff_send_mss(sendmss, src, dest, isipv6) tcp_eff_send_mss_impl(sendmss, dest)
515 #endif /* LWIP_IPV4 && LWIP_IPV6 */
516 #endif /* TCP_CALCULATE_EFF_SEND_MSS */
517 
518 #if LWIP_CALLBACK_API
519 err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
520 #endif /* LWIP_CALLBACK_API */
521 
522 #if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
523 void tcp_debug_print(struct tcp_hdr *tcphdr);
524 void tcp_debug_print_flags(u8_t flags);
525 void tcp_debug_print_state(enum tcp_state s);
526 void tcp_debug_print_pcbs(void);
527 s16_t tcp_pcbs_sane(void);
528 #else
529 # define tcp_debug_print(tcphdr)
530 # define tcp_debug_print_flags(flags)
531 # define tcp_debug_print_state(s)
532 # define tcp_debug_print_pcbs()
533 # define tcp_pcbs_sane() 1
534 #endif /* TCP_DEBUG */
535 
538 void tcp_timer_needed(void);
539 
540 #if LWIP_IPV4
541 void tcp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* new_addr);
542 #endif /* LWIP_IPV4 */
543 
544 #ifdef __cplusplus
545 }
546 #endif
547 
548 #endif /* LWIP_TCP */
549 
550 #endif /* LWIP_HDR_TCP_H */
551 
552 
#define PACK_STRUCT_STRUCT
Definition: arch.h:68
signed short s16_t
Definition: cc.h:41
void tcp_timer_needed(void)
Definition: lwip_timers.c:580
#define LWIP_IPV4
Definition: opt.h:549
#define PACK_STRUCT_FIELD(x)
Definition: arch.h:72
u16_t len
Definition: pbuf.h:125
u8_t flags
Definition: pbuf.h:131
unsigned long u32_t
Definition: cc.h:42
Definition: pbuf.h:108
s8_t err_t
Definition: err.h:47
Definition: netif.h:182
#define PACK_STRUCT_BEGIN
Definition: arch.h:60
unsigned char u8_t
Definition: cc.h:38
ip6_addr_t ip_addr_t
Definition: ip_addr.h:194
#define PACK_STRUCT_END
Definition: arch.h:64
#define LWIP_IPV6
Definition: opt.h:2444
unsigned short u16_t
Definition: cc.h:40