Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
tcp_priv.h
00001 /** 00002 * @file 00003 * TCP internal implementations (do not use in application code) 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_TCP_PRIV_H 00038 #define LWIP_HDR_TCP_PRIV_H 00039 00040 #include "lwip/opt.h" 00041 00042 #if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ 00043 00044 #include "lwip/tcp.h" 00045 #include "lwip/mem.h" 00046 #include "lwip/pbuf.h" 00047 #include "lwip/ip.h" 00048 #include "lwip/icmp.h" 00049 #include "lwip/err.h" 00050 #include "lwip/ip6.h" 00051 #include "lwip/ip6_addr.h" 00052 #include "lwip/prot/tcp.h" 00053 00054 #ifdef __cplusplus 00055 extern "C" { 00056 #endif 00057 00058 /* Functions for interfacing with TCP: */ 00059 00060 /* Lower layer interface to TCP: */ 00061 void tcp_init (void); /* Initialize this module. */ 00062 void tcp_tmr (void); /* Must be called every 00063 TCP_TMR_INTERVAL 00064 ms. (Typically 250 ms). */ 00065 /* It is also possible to call these two functions at the right 00066 intervals (instead of calling tcp_tmr()). */ 00067 void tcp_slowtmr (void); 00068 void tcp_fasttmr (void); 00069 00070 /* Call this from a netif driver (watch out for threading issues!) that has 00071 returned a memory error on transmit and now has free buffers to send more. 00072 This iterates all active pcbs that had an error and tries to call 00073 tcp_output, so use this with care as it might slow down the system. */ 00074 void tcp_txnow (void); 00075 00076 /* Only used by IP to pass a TCP segment to TCP: */ 00077 void tcp_input (struct pbuf *p, struct netif *inp); 00078 /* Used within the TCP code only: */ 00079 struct tcp_pcb * tcp_alloc (u8_t prio); 00080 void tcp_free (struct tcp_pcb *pcb); 00081 void tcp_abandon (struct tcp_pcb *pcb, int reset); 00082 err_t tcp_send_empty_ack(struct tcp_pcb *pcb); 00083 err_t tcp_rexmit (struct tcp_pcb *pcb); 00084 err_t tcp_rexmit_rto_prepare(struct tcp_pcb *pcb); 00085 void tcp_rexmit_rto_commit(struct tcp_pcb *pcb); 00086 void tcp_rexmit_rto (struct tcp_pcb *pcb); 00087 void tcp_rexmit_fast (struct tcp_pcb *pcb); 00088 u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb); 00089 err_t tcp_process_refused_data(struct tcp_pcb *pcb); 00090 00091 /** 00092 * This is the Nagle algorithm: try to combine user data to send as few TCP 00093 * segments as possible. Only send if 00094 * - no previously transmitted data on the connection remains unacknowledged or 00095 * - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or 00096 * - the only unsent segment is at least pcb->mss bytes long (or there is more 00097 * than one unsent segment - with lwIP, this can happen although unsent->len < mss) 00098 * - or if we are in fast-retransmit (TF_INFR) 00099 */ 00100 #define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ 00101 ((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \ 00102 (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \ 00103 ((tpcb)->unsent->len >= (tpcb)->mss))) || \ 00104 ((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \ 00105 ) ? 1 : 0) 00106 #define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK) 00107 00108 00109 #define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) 00110 #define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) 00111 #define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) 00112 #define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) 00113 /* is b<=a<=c? */ 00114 #if 0 /* see bug #10548 */ 00115 #define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) 00116 #endif 00117 #define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) 00118 00119 #ifndef TCP_TMR_INTERVAL 00120 #define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ 00121 #endif /* TCP_TMR_INTERVAL */ 00122 00123 #ifndef TCP_FAST_INTERVAL 00124 #define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ 00125 #endif /* TCP_FAST_INTERVAL */ 00126 00127 #ifndef TCP_SLOW_INTERVAL 00128 #define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ 00129 #endif /* TCP_SLOW_INTERVAL */ 00130 00131 #define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */ 00132 #define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */ 00133 00134 #define TCP_OOSEQ_TIMEOUT 6U /* x RTO */ 00135 00136 #ifndef TCP_MSL 00137 #define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */ 00138 #endif 00139 00140 /* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */ 00141 #ifndef TCP_KEEPIDLE_DEFAULT 00142 #define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */ 00143 #endif 00144 00145 #ifndef TCP_KEEPINTVL_DEFAULT 00146 #define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */ 00147 #endif 00148 00149 #ifndef TCP_KEEPCNT_DEFAULT 00150 #define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */ 00151 #endif 00152 00153 #define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */ 00154 00155 #define TCP_TCPLEN(seg) ((seg)->len + (((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0) ? 1U : 0U)) 00156 00157 /** Flags used on input processing, not on pcb->flags 00158 */ 00159 #define TF_RESET (u8_t)0x08U /* Connection was reset. */ 00160 #define TF_CLOSED (u8_t)0x10U /* Connection was successfully closed. */ 00161 #define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */ 00162 00163 00164 #if LWIP_EVENT_API 00165 00166 #define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) ret = lwip_tcp_event(arg, (pcb),\ 00167 LWIP_EVENT_ACCEPT, NULL, 0, err) 00168 #define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ 00169 LWIP_EVENT_SENT, NULL, space, ERR_OK) 00170 #define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ 00171 LWIP_EVENT_RECV, (p), 0, (err)) 00172 #define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ 00173 LWIP_EVENT_RECV, NULL, 0, ERR_OK) 00174 #define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ 00175 LWIP_EVENT_CONNECTED, NULL, 0, (err)) 00176 #define TCP_EVENT_POLL(pcb,ret) do { if ((pcb)->state != SYN_RCVD) { \ 00177 ret = lwip_tcp_event((pcb)->callback_arg, (pcb), LWIP_EVENT_POLL, NULL, 0, ERR_OK); \ 00178 } else { \ 00179 ret = ERR_ARG; } } while(0) 00180 /* For event API, last state SYN_RCVD must be excluded here: the application 00181 has not seen this pcb, yet! */ 00182 #define TCP_EVENT_ERR(last_state,errf,arg,err) do { if (last_state != SYN_RCVD) { \ 00183 lwip_tcp_event((arg), NULL, LWIP_EVENT_ERR, NULL, 0, (err)); } } while(0) 00184 00185 #else /* LWIP_EVENT_API */ 00186 00187 #define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \ 00188 do { \ 00189 if((lpcb)->accept != NULL) \ 00190 (ret) = (lpcb)->accept((arg),(pcb),(err)); \ 00191 else (ret) = ERR_ARG; \ 00192 } while (0) 00193 00194 #define TCP_EVENT_SENT(pcb,space,ret) \ 00195 do { \ 00196 if((pcb)->sent != NULL) \ 00197 (ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \ 00198 else (ret) = ERR_OK; \ 00199 } while (0) 00200 00201 #define TCP_EVENT_RECV(pcb,p,err,ret) \ 00202 do { \ 00203 if((pcb)->recv != NULL) { \ 00204 (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\ 00205 } else { \ 00206 (ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \ 00207 } \ 00208 } while (0) 00209 00210 #define TCP_EVENT_CLOSED(pcb,ret) \ 00211 do { \ 00212 if(((pcb)->recv != NULL)) { \ 00213 (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\ 00214 } else { \ 00215 (ret) = ERR_OK; \ 00216 } \ 00217 } while (0) 00218 00219 #define TCP_EVENT_CONNECTED(pcb,err,ret) \ 00220 do { \ 00221 if((pcb)->connected != NULL) \ 00222 (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \ 00223 else (ret) = ERR_OK; \ 00224 } while (0) 00225 00226 #define TCP_EVENT_POLL(pcb,ret) \ 00227 do { \ 00228 if((pcb)->poll != NULL) \ 00229 (ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \ 00230 else (ret) = ERR_OK; \ 00231 } while (0) 00232 00233 #define TCP_EVENT_ERR(last_state,errf,arg,err) \ 00234 do { \ 00235 LWIP_UNUSED_ARG(last_state); \ 00236 if((errf) != NULL) \ 00237 (errf)((arg),(err)); \ 00238 } while (0) 00239 00240 #endif /* LWIP_EVENT_API */ 00241 00242 /** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */ 00243 #if TCP_OVERSIZE && defined(LWIP_DEBUG) 00244 #define TCP_OVERSIZE_DBGCHECK 1 00245 #else 00246 #define TCP_OVERSIZE_DBGCHECK 0 00247 #endif 00248 00249 /** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */ 00250 #define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) 00251 00252 /* This structure represents a TCP segment on the unsent, unacked and ooseq queues */ 00253 struct tcp_seg { 00254 struct tcp_seg *next; /* used when putting segments on a queue */ 00255 struct pbuf *p; /* buffer containing data + TCP header */ 00256 u16_t len; /* the TCP length of this segment */ 00257 #if TCP_OVERSIZE_DBGCHECK 00258 u16_t oversize_left; /* Extra bytes available at the end of the last 00259 pbuf in unsent (used for asserting vs. 00260 tcp_pcb.unsent_oversize only) */ 00261 #endif /* TCP_OVERSIZE_DBGCHECK */ 00262 #if TCP_CHECKSUM_ON_COPY 00263 u16_t chksum; 00264 u8_t chksum_swapped; 00265 #endif /* TCP_CHECKSUM_ON_COPY */ 00266 u8_t flags; 00267 #define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option (only used in SYN segments) */ 00268 #define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */ 00269 #define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is 00270 checksummed into 'chksum' */ 00271 #define TF_SEG_OPTS_WND_SCALE (u8_t)0x08U /* Include WND SCALE option (only used in SYN segments) */ 00272 #define TF_SEG_OPTS_SACK_PERM (u8_t)0x10U /* Include SACK Permitted option (only used in SYN segments) */ 00273 struct tcp_hdr *tcphdr; /* the TCP header */ 00274 }; 00275 00276 #define LWIP_TCP_OPT_EOL 0 00277 #define LWIP_TCP_OPT_NOP 1 00278 #define LWIP_TCP_OPT_MSS 2 00279 #define LWIP_TCP_OPT_WS 3 00280 #define LWIP_TCP_OPT_SACK_PERM 4 00281 #define LWIP_TCP_OPT_TS 8 00282 00283 #define LWIP_TCP_OPT_LEN_MSS 4 00284 #if LWIP_TCP_TIMESTAMPS 00285 #define LWIP_TCP_OPT_LEN_TS 10 00286 #define LWIP_TCP_OPT_LEN_TS_OUT 12 /* aligned for output (includes NOP padding) */ 00287 #else 00288 #define LWIP_TCP_OPT_LEN_TS_OUT 0 00289 #endif 00290 #if LWIP_WND_SCALE 00291 #define LWIP_TCP_OPT_LEN_WS 3 00292 #define LWIP_TCP_OPT_LEN_WS_OUT 4 /* aligned for output (includes NOP padding) */ 00293 #else 00294 #define LWIP_TCP_OPT_LEN_WS_OUT 0 00295 #endif 00296 00297 #if LWIP_TCP_SACK_OUT 00298 #define LWIP_TCP_OPT_LEN_SACK_PERM 2 00299 #define LWIP_TCP_OPT_LEN_SACK_PERM_OUT 4 /* aligned for output (includes NOP padding) */ 00300 #else 00301 #define LWIP_TCP_OPT_LEN_SACK_PERM_OUT 0 00302 #endif 00303 00304 #define LWIP_TCP_OPT_LENGTH(flags) \ 00305 ((flags) & TF_SEG_OPTS_MSS ? LWIP_TCP_OPT_LEN_MSS : 0) + \ 00306 ((flags) & TF_SEG_OPTS_TS ? LWIP_TCP_OPT_LEN_TS_OUT : 0) + \ 00307 ((flags) & TF_SEG_OPTS_WND_SCALE ? LWIP_TCP_OPT_LEN_WS_OUT : 0) + \ 00308 ((flags) & TF_SEG_OPTS_SACK_PERM ? LWIP_TCP_OPT_LEN_SACK_PERM_OUT : 0) 00309 00310 /** This returns a TCP header option for MSS in an u32_t */ 00311 #define TCP_BUILD_MSS_OPTION(mss) lwip_htonl(0x02040000 | ((mss) & 0xFFFF)) 00312 00313 #if LWIP_WND_SCALE 00314 #define TCPWNDSIZE_F U32_F 00315 #define TCPWND_MAX 0xFFFFFFFFU 00316 #define TCPWND_CHECK16(x) LWIP_ASSERT("window size > 0xFFFF", (x) <= 0xFFFF) 00317 #define TCPWND_MIN16(x) ((u16_t)LWIP_MIN((x), 0xFFFF)) 00318 #else /* LWIP_WND_SCALE */ 00319 #define TCPWNDSIZE_F U16_F 00320 #define TCPWND_MAX 0xFFFFU 00321 #define TCPWND_CHECK16(x) 00322 #define TCPWND_MIN16(x) x 00323 #endif /* LWIP_WND_SCALE */ 00324 00325 /* Global variables: */ 00326 extern struct tcp_pcb *tcp_input_pcb; 00327 extern u32_t tcp_ticks; 00328 extern u8_t tcp_active_pcbs_changed; 00329 00330 /* The TCP PCB lists. */ 00331 union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ 00332 struct tcp_pcb_listen *listen_pcbs; 00333 struct tcp_pcb *pcbs; 00334 }; 00335 extern struct tcp_pcb *tcp_bound_pcbs; 00336 extern union tcp_listen_pcbs_t tcp_listen_pcbs; 00337 extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a 00338 state in which they accept or send 00339 data. */ 00340 extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ 00341 00342 #define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 00343 #define NUM_TCP_PCB_LISTS 4 00344 extern struct tcp_pcb ** const tcp_pcb_lists[NUM_TCP_PCB_LISTS]; 00345 00346 /* Axioms about the above lists: 00347 1) Every TCP PCB that is not CLOSED is in one of the lists. 00348 2) A PCB is only in one of the lists. 00349 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. 00350 4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state. 00351 */ 00352 /* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB 00353 with a PCB list or removes a PCB from a list, respectively. */ 00354 #ifndef TCP_DEBUG_PCB_LISTS 00355 #define TCP_DEBUG_PCB_LISTS 0 00356 #endif 00357 #if TCP_DEBUG_PCB_LISTS 00358 #define TCP_REG(pcbs, npcb) do {\ 00359 struct tcp_pcb *tcp_tmp_pcb; \ 00360 LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %"U16_F"\n", (void *)(npcb), (npcb)->local_port)); \ 00361 for (tcp_tmp_pcb = *(pcbs); \ 00362 tcp_tmp_pcb != NULL; \ 00363 tcp_tmp_pcb = tcp_tmp_pcb->next) { \ 00364 LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \ 00365 } \ 00366 LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \ 00367 (npcb)->next = *(pcbs); \ 00368 LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \ 00369 *(pcbs) = (npcb); \ 00370 LWIP_ASSERT("TCP_REG: tcp_pcbs sane", tcp_pcbs_sane()); \ 00371 tcp_timer_needed(); \ 00372 } while(0) 00373 #define TCP_RMV(pcbs, npcb) do { \ 00374 struct tcp_pcb *tcp_tmp_pcb; \ 00375 LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \ 00376 LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (void *)(npcb), (void *)(*(pcbs)))); \ 00377 if(*(pcbs) == (npcb)) { \ 00378 *(pcbs) = (*pcbs)->next; \ 00379 } else for (tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ 00380 if(tcp_tmp_pcb->next == (npcb)) { \ 00381 tcp_tmp_pcb->next = (npcb)->next; \ 00382 break; \ 00383 } \ 00384 } \ 00385 (npcb)->next = NULL; \ 00386 LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ 00387 LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (void *)(npcb), (void *)(*(pcbs)))); \ 00388 } while(0) 00389 00390 #else /* LWIP_DEBUG */ 00391 00392 #define TCP_REG(pcbs, npcb) \ 00393 do { \ 00394 (npcb)->next = *pcbs; \ 00395 *(pcbs) = (npcb); \ 00396 tcp_timer_needed(); \ 00397 } while (0) 00398 00399 #define TCP_RMV(pcbs, npcb) \ 00400 do { \ 00401 if(*(pcbs) == (npcb)) { \ 00402 (*(pcbs)) = (*pcbs)->next; \ 00403 } \ 00404 else { \ 00405 struct tcp_pcb *tcp_tmp_pcb; \ 00406 for (tcp_tmp_pcb = *pcbs; \ 00407 tcp_tmp_pcb != NULL; \ 00408 tcp_tmp_pcb = tcp_tmp_pcb->next) { \ 00409 if(tcp_tmp_pcb->next == (npcb)) { \ 00410 tcp_tmp_pcb->next = (npcb)->next; \ 00411 break; \ 00412 } \ 00413 } \ 00414 } \ 00415 (npcb)->next = NULL; \ 00416 } while(0) 00417 00418 #endif /* LWIP_DEBUG */ 00419 00420 #define TCP_REG_ACTIVE(npcb) \ 00421 do { \ 00422 TCP_REG(&tcp_active_pcbs, npcb); \ 00423 tcp_active_pcbs_changed = 1; \ 00424 } while (0) 00425 00426 #define TCP_RMV_ACTIVE(npcb) \ 00427 do { \ 00428 TCP_RMV(&tcp_active_pcbs, npcb); \ 00429 tcp_active_pcbs_changed = 1; \ 00430 } while (0) 00431 00432 #define TCP_PCB_REMOVE_ACTIVE(pcb) \ 00433 do { \ 00434 tcp_pcb_remove(&tcp_active_pcbs, pcb); \ 00435 tcp_active_pcbs_changed = 1; \ 00436 } while (0) 00437 00438 00439 /* Internal functions: */ 00440 struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb); 00441 void tcp_pcb_purge(struct tcp_pcb *pcb); 00442 void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb); 00443 00444 void tcp_segs_free(struct tcp_seg *seg); 00445 void tcp_seg_free(struct tcp_seg *seg); 00446 struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); 00447 00448 #define tcp_ack(pcb) \ 00449 do { \ 00450 if((pcb)->flags & TF_ACK_DELAY) { \ 00451 tcp_clear_flags(pcb, TF_ACK_DELAY); \ 00452 tcp_ack_now(pcb); \ 00453 } \ 00454 else { \ 00455 tcp_set_flags(pcb, TF_ACK_DELAY); \ 00456 } \ 00457 } while (0) 00458 00459 #define tcp_ack_now(pcb) \ 00460 tcp_set_flags(pcb, TF_ACK_NOW) 00461 00462 err_t tcp_send_fin(struct tcp_pcb *pcb); 00463 err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags); 00464 00465 void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg); 00466 00467 void tcp_rst(const struct tcp_pcb* pcb, u32_t seqno, u32_t ackno, 00468 const ip_addr_t *local_ip, const ip_addr_t *remote_ip, 00469 u16_t local_port, u16_t remote_port); 00470 00471 u32_t tcp_next_iss(struct tcp_pcb *pcb); 00472 00473 err_t tcp_keepalive(struct tcp_pcb *pcb); 00474 err_t tcp_split_unsent_seg(struct tcp_pcb *pcb, u16_t split); 00475 err_t tcp_zero_window_probe(struct tcp_pcb *pcb); 00476 void tcp_trigger_input_pcb_close(void); 00477 00478 #if TCP_CALCULATE_EFF_SEND_MSS 00479 u16_t tcp_eff_send_mss_netif(u16_t sendmss, struct netif *outif, 00480 const ip_addr_t *dest); 00481 #define tcp_eff_send_mss(sendmss, src, dest) \ 00482 tcp_eff_send_mss_netif(sendmss, ip_route(src, dest), dest) 00483 #endif /* TCP_CALCULATE_EFF_SEND_MSS */ 00484 00485 #if LWIP_CALLBACK_API 00486 err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); 00487 #endif /* LWIP_CALLBACK_API */ 00488 00489 #if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG 00490 void tcp_debug_print(struct tcp_hdr *tcphdr); 00491 void tcp_debug_print_flags(u8_t flags); 00492 void tcp_debug_print_state(enum tcp_state s); 00493 void tcp_debug_print_pcbs(void); 00494 s16_t tcp_pcbs_sane(void); 00495 #else 00496 # define tcp_debug_print(tcphdr) 00497 # define tcp_debug_print_flags(flags) 00498 # define tcp_debug_print_state(s) 00499 # define tcp_debug_print_pcbs() 00500 # define tcp_pcbs_sane() 1 00501 #endif /* TCP_DEBUG */ 00502 00503 /** External function (implemented in timers.c), called when TCP detects 00504 * that a timer is needed (i.e. active- or time-wait-pcb found). */ 00505 void tcp_timer_needed(void); 00506 00507 void tcp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); 00508 00509 #if TCP_QUEUE_OOSEQ 00510 void tcp_free_ooseq(struct tcp_pcb *pcb); 00511 #endif 00512 00513 #if LWIP_TCP_PCB_NUM_EXT_ARGS 00514 err_t tcp_ext_arg_invoke_callbacks_passive_open(struct tcp_pcb_listen *lpcb, struct tcp_pcb *cpcb); 00515 #endif 00516 00517 #ifdef __cplusplus 00518 } 00519 #endif 00520 00521 #endif /* LWIP_TCP */ 00522 00523 #endif /* LWIP_HDR_TCP_PRIV_H */
Generated on Tue Jul 12 2022 13:54:55 by
