1
1
/*
2
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,
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification,
6
6
* are permitted provided that the following conditions are met:
7
7
*
8
8
* 1. Redistributions of source code must retain the above copyright notice,
11
11
* this list of conditions and the following disclaimer in the documentation
12
12
* and/or other materials provided with the distribution.
13
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.
14
+ * derived from this software without specific prior written permission.
15
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
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
25
* OF SUCH DAMAGE.
26
26
*
27
27
* This file is part of the lwIP TCP/IP stack.
28
- *
28
+ *
29
29
* Author: Adam Dunkels <[email protected] >
30
30
*
31
31
*/
@@ -284,7 +284,7 @@ struct tcp_seg {
284
284
u16_t oversize_left ; /* Extra bytes available at the end of the last
285
285
pbuf in unsent (used for asserting vs.
286
286
tcp_pcb.unsent_oversized only) */
287
- #endif /* TCP_OVERSIZE_DBGCHECK */
287
+ #endif /* TCP_OVERSIZE_DBGCHECK */
288
288
#if TCP_CHECKSUM_ON_COPY
289
289
u16_t chksum ;
290
290
u8_t chksum_swapped ;
@@ -313,7 +313,7 @@ extern u32_t tcp_ticks;
313
313
314
314
/* The TCP PCB lists. */
315
315
union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */
316
- struct tcp_pcb_listen * listen_pcbs ;
316
+ struct tcp_pcb_listen * listen_pcbs ;
317
317
struct tcp_pcb * pcbs ;
318
318
};
319
319
extern struct tcp_pcb * tcp_bound_pcbs ;
@@ -325,7 +325,7 @@ extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. *
325
325
326
326
extern struct tcp_pcb * tcp_tmp_pcb ; /* Only used for temporary storage. */
327
327
328
- /* Axioms about the above lists:
328
+ /* Axioms about the above lists:
329
329
1) Every TCP PCB that is not CLOSED is in one of the lists.
330
330
2) A PCB is only in one of the lists.
331
331
3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.
@@ -396,6 +396,26 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
396
396
397
397
#endif /* LWIP_DEBUG */
398
398
399
+ #define TCP_TW_LIMIT (l ) \
400
+ do { \
401
+ u32_t tcp_tmp_pcbs_count = 0; \
402
+ tcp_tmp_pcb = tcp_tw_pcbs; \
403
+ while(tcp_tmp_pcb != NULL) { \
404
+ if(++tcp_tmp_pcbs_count == (l)) { \
405
+ struct tcp_pcb *_tcp_tmp_pcb = tcp_tmp_pcb->next; \
406
+ tcp_tmp_pcb->next = NULL; \
407
+ tcp_tmp_pcb = _tcp_tmp_pcb; \
408
+ while(tcp_tmp_pcb != NULL) { \
409
+ _tcp_tmp_pcb = tcp_tmp_pcb; \
410
+ tcp_pcb_purge(tcp_tmp_pcb); \
411
+ tcp_tmp_pcb = tcp_tmp_pcb->next; \
412
+ memp_free(MEMP_TCP_PCB, _tcp_tmp_pcb); \
413
+ } \
414
+ break; \
415
+ } \
416
+ tcp_tmp_pcb = tcp_tmp_pcb->next; \
417
+ } \
418
+ } while(0)
399
419
400
420
/* Internal functions: */
401
421
struct tcp_pcb * tcp_pcb_copy (struct tcp_pcb * pcb )ICACHE_FLASH_ATTR ;
0 commit comments