Lines Matching refs:pcb

67 #define TCP_KEEP_DUR(pcb)   ((pcb)->keep_cnt * (pcb)->keep_intvl)
68 #define TCP_KEEP_INTVL(pcb) ((pcb)->keep_intvl)
70 #define TCP_KEEP_DUR(pcb) TCP_MAXIDLE
71 #define TCP_KEEP_INTVL(pcb) TCP_KEEPINTVL_DEFAULT
162 * The pcb is then automatically freed in tcp_slowtmr(). It is therefore
165 * @param pcb the tcp_pcb to close
167 * another err_t if closing failed and pcb is not freed
170 tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
174 if (rst_on_unacked_data && ((pcb->state == ESTABLISHED) || (pcb->state == CLOSE_WAIT))) {
175 if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) {
178 LWIP_ASSERT("pcb->flags & TF_RXCLOSED", pcb->flags & TF_RXCLOSED);
180 /* don't call tcp_abort here: we must not deallocate the pcb since
182 tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip,
183 pcb->local_port, pcb->remote_port);
185 tcp_pcb_purge(pcb);
186 TCP_RMV_ACTIVE(pcb);
187 if (pcb->state == ESTABLISHED) {
189 pcb->state = TIME_WAIT;
190 TCP_REG(&tcp_tw_pcbs, pcb);
192 /* CLOSE_WAIT: deallocate the pcb since we already sent a RST for it */
193 memp_free(MEMP_TCP_PCB, pcb);
199 switch (pcb->state) {
201 /* Closing a pcb in the CLOSED state might seem erroneous,
204 * Calling tcp_close() with a pcb that has already been closed, (i.e. twice)
205 * or for a pcb that has been used and then entered the CLOSED state
206 * is erroneous, but this should never happen as the pcb has in those cases
209 if (pcb->local_port != 0) {
210 TCP_RMV(&tcp_bound_pcbs, pcb);
212 memp_free(MEMP_TCP_PCB, pcb);
213 pcb = NULL;
217 tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb);
218 memp_free(MEMP_TCP_PCB_LISTEN, pcb);
219 pcb = NULL;
223 TCP_PCB_REMOVE_ACTIVE(pcb);
224 memp_free(MEMP_TCP_PCB, pcb);
225 pcb = NULL;
229 err = tcp_send_fin(pcb);
232 pcb->state = FIN_WAIT_1;
236 err = tcp_send_fin(pcb);
239 pcb->state = FIN_WAIT_1;
243 err = tcp_send_fin(pcb);
246 pcb->state = LAST_ACK;
252 pcb = NULL;
256 if (pcb != NULL && err == ERR_OK) {
265 tcp_output(pcb);
277 * The pcb is then automatically freed in tcp_slowtmr(). It is therefore
280 * @param pcb the tcp_pcb to close
282 * another err_t if closing failed and pcb is not freed
285 tcp_close(struct tcp_pcb *pcb)
289 tcp_debug_print_state(pcb->state);
292 if (pcb->state != LISTEN) {
294 pcb->flags |= TF_RXCLOSED;
297 return tcp_close_shutdown(pcb, 1);
306 * @param pcb PCB to shutdown
313 tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx)
315 if (pcb->state == LISTEN) {
320 pcb->flags |= TF_RXCLOSED;
323 return tcp_close_shutdown(pcb, 1);
326 if (pcb->refused_data != NULL) {
327 pbuf_free(pcb->refused_data);
328 pcb->refused_data = NULL;
332 /* This can't happen twice since if it succeeds, the pcb's state is changed.
334 switch (pcb->state) {
338 return tcp_close_shutdown(pcb, shut_rx);
353 * @param pcb the tcp_pcb to abort
357 tcp_abandon(struct tcp_pcb *pcb, int reset)
365 /* pcb->state LISTEN not allowed here */
367 pcb->state != LISTEN);
371 if (pcb->state == TIME_WAIT) {
372 tcp_pcb_remove(&tcp_tw_pcbs, pcb);
373 memp_free(MEMP_TCP_PCB, pcb);
375 seqno = pcb->snd_nxt;
376 ackno = pcb->rcv_nxt;
378 errf = pcb->errf;
380 errf_arg = pcb->callback_arg;
381 TCP_PCB_REMOVE_ACTIVE(pcb);
382 if (pcb->unacked != NULL) {
383 tcp_segs_free(pcb->unacked);
385 if (pcb->unsent != NULL) {
386 tcp_segs_free(pcb->unsent);
389 if (pcb->ooseq != NULL) {
390 tcp_segs_free(pcb->ooseq);
395 tcp_rst(seqno, ackno, &pcb->local_ip, &pcb->remote_ip, pcb->local_port, pcb->remote_port);
397 memp_free(MEMP_TCP_PCB, pcb);
404 * host. The pcb is deallocated. This function never fails.
410 * @param pcb the tcp pcb to abort
413 tcp_abort(struct tcp_pcb *pcb)
415 tcp_abandon(pcb, 1);
423 * @param pcb the tcp_pcb to bind (no check is done whether this pcb is
433 tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
439 LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_VAL);
444 We do not dump TIME_WAIT pcb's; they can still be matched by incoming
447 if (ip_get_option(pcb, SOF_REUSEADDR)) {
467 if (!ip_get_option(pcb, SOF_REUSEADDR) ||
482 pcb->local_ip = *ipaddr;
484 pcb->local_port = port;
485 TCP_REG(&tcp_bound_pcbs, pcb);
494 tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err)
497 LWIP_UNUSED_ARG(pcb);
510 * @param pcb the original tcp_pcb
519 tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
524 LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL);
527 if (pcb->state == LISTEN) {
528 return pcb;
531 if (ip_get_option(pcb, SOF_REUSEADDR)) {
532 /* Since SOF_REUSEADDR allows reusing a local address before the pcb's usage
533 is declared (listen-/connection-pcb), we have to make sure now that
536 if (lpcb->local_port == pcb->local_port) {
537 if (ip_addr_cmp(&lpcb->local_ip, &pcb->local_ip)) {
549 lpcb->callback_arg = pcb->callback_arg;
550 lpcb->local_port = pcb->local_port;
552 lpcb->prio = pcb->prio;
553 lpcb->so_options = pcb->so_options;
555 lpcb->ttl = pcb->ttl;
556 lpcb->tos = pcb->tos;
557 ip_addr_copy(lpcb->local_ip, pcb->local_ip);
558 if (pcb->local_port != 0) {
559 TCP_RMV(&tcp_bound_pcbs, pcb);
561 memp_free(MEMP_TCP_PCB, pcb);
579 u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb)
581 u32_t new_right_edge = pcb->rcv_nxt + pcb->rcv_wnd;
583 if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND / 2), pcb->mss))) {
585 pcb->rcv_ann_wnd = pcb->rcv_wnd;
586 return new_right_edge - pcb->rcv_ann_right_edge;
588 if (TCP_SEQ_GT(pcb->rcv_nxt, pcb->rcv_ann_right_edge)) {
591 pcb->rcv_ann_wnd = 0;
594 u32_t new_rcv_ann_wnd = pcb->rcv_ann_right_edge - pcb->rcv_nxt;
596 pcb->rcv_ann_wnd = (u16_t)new_rcv_ann_wnd;
607 * @param pcb the tcp_pcb for which data is read
611 tcp_recved(struct tcp_pcb *pcb, u16_t len)
615 /* pcb->state LISTEN not allowed here */
617 pcb->state != LISTEN);
619 len <= 0xffff - pcb->rcv_wnd );
621 pcb->rcv_wnd += len;
622 if (pcb->rcv_wnd > TCP_WND) {
623 pcb->rcv_wnd = TCP_WND;
626 wnd_inflation = tcp_update_rcv_ann_wnd(pcb);
633 tcp_ack_now(pcb);
634 tcp_output(pcb);
638 len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd));
651 struct tcp_pcb *pcb;
659 for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) {
660 if (pcb->local_port == tcp_port) {
675 * @param pcb the tcp_pcb used to establish the connection
684 tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
691 LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
695 pcb->remote_ip = *ipaddr;
699 pcb->remote_port = port;
702 if (ip_addr_isany(&(pcb->local_ip))) {
704 struct netif *netif = ip_route(&(pcb->remote_ip));
711 ip_addr_copy(pcb->local_ip, netif->ip_addr);
714 old_local_port = pcb->local_port;
715 if (pcb->local_port == 0) {
716 pcb->local_port = tcp_new_port();
717 if (pcb->local_port == 0) {
722 if (ip_get_option(pcb, SOF_REUSEADDR)) {
730 if ((cpcb->local_port == pcb->local_port) &&
732 ip_addr_cmp(&cpcb->local_ip, &pcb->local_ip) &&
742 pcb->rcv_nxt = 0;
743 pcb->snd_nxt = iss;
744 pcb->lastack = iss - 1;
745 pcb->snd_lbb = iss - 1;
746 pcb->rcv_wnd = TCP_WND;
747 pcb->rcv_ann_wnd = TCP_WND;
748 pcb->rcv_ann_right_edge = pcb->rcv_nxt;
749 pcb->snd_wnd = TCP_WND;
752 pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS;
754 pcb->mss = tcp_eff_send_mss(pcb->mss, ipaddr);
756 pcb->cwnd = 1;
757 pcb->ssthresh = pcb->mss * 10;
759 pcb->connected = connected;
765 ret = tcp_enqueue_flags(pcb, TCP_SYN);
768 pcb->state = SYN_SENT;
770 TCP_RMV(&tcp_bound_pcbs, pcb);
772 TCP_REG_ACTIVE(pcb);
775 tcp_output(pcb);
790 struct tcp_pcb *pcb, *prev;
804 pcb = tcp_active_pcbs;
805 if (pcb == NULL) {
808 while (pcb != NULL) {
809 LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n"));
810 LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED);
811 LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN);
812 LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT);
813 if (pcb->last_timer == tcp_timer_ctr) {
814 /* skip this pcb, we have already processed it */
815 pcb = pcb->next;
818 pcb->last_timer = tcp_timer_ctr;
823 if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
827 else if (pcb->nrtx == TCP_MAXRTX) {
831 if (pcb->persist_backoff > 0) {
834 pcb->persist_cnt++;
835 if (pcb->persist_cnt >= tcp_persist_backoff[pcb->persist_backoff-1]) {
836 pcb->persist_cnt = 0;
837 if (pcb->persist_backoff < sizeof(tcp_persist_backoff)) {
838 pcb->persist_backoff++;
840 tcp_zero_window_probe(pcb);
844 if(pcb->rtime >= 0) {
845 ++pcb->rtime;
848 if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
851 " pcb->rto %"S16_F"\n",
852 pcb->rtime, pcb->rto));
856 if (pcb->state != SYN_SENT) {
857 pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
861 pcb->rtime = 0;
864 eff_wnd = LWIP_MIN(pcb->cwnd, pcb->snd_wnd);
865 pcb->ssthresh = eff_wnd >> 1;
866 if (pcb->ssthresh < (pcb->mss << 1)) {
867 pcb->ssthresh = (pcb->mss << 1);
869 pcb->cwnd = pcb->mss;
872 pcb->cwnd, pcb->ssthresh));
876 tcp_rexmit_rto(pcb);
881 if (pcb->state == FIN_WAIT_2) {
883 if (pcb->flags & TF_RXCLOSED) {
886 if ((u32_t)(tcp_ticks - pcb->tmr) >
889 LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n"));
895 if(ip_get_option(pcb, SOF_KEEPALIVE) &&
896 ((pcb->state == ESTABLISHED) ||
897 (pcb->state == CLOSE_WAIT))) {
898 if((u32_t)(tcp_ticks - pcb->tmr) >
899 (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL)
902 ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip),
903 ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip)));
908 else if((u32_t)(tcp_ticks - pcb->tmr) >
909 (pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb))
912 tcp_keepalive(pcb);
913 pcb->keep_cnt_sent++;
921 if (pcb->ooseq != NULL &&
922 (u32_t)tcp_ticks - pcb->tmr >= pcb->rto * TCP_OOSEQ_TIMEOUT) {
923 tcp_segs_free(pcb->ooseq);
924 pcb->ooseq = NULL;
930 if (pcb->state == SYN_RCVD) {
931 if ((u32_t)(tcp_ticks - pcb->tmr) >
934 LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n"));
939 if (pcb->state == LAST_ACK) {
940 if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) {
942 LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in LAST-ACK\n"));
951 tcp_pcb_purge(pcb);
954 LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs);
955 prev->next = pcb->next;
958 LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", tcp_active_pcbs == pcb);
959 tcp_active_pcbs = pcb->next;
963 tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip,
964 pcb->local_port, pcb->remote_port);
967 err_fn = pcb->errf;
968 err_arg = pcb->callback_arg;
969 pcb2 = pcb;
970 pcb = pcb->next;
980 prev = pcb;
981 pcb = pcb->next;
1004 pcb = tcp_tw_pcbs;
1005 while (pcb != NULL) {
1006 LWIP_ASSERT("tcp_slowtmr: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);
1010 if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) {
1019 tcp_pcb_purge(pcb);
1022 LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
1023 prev->next = pcb->next;
1026 LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_tw_pcbs", tcp_tw_pcbs == pcb);
1027 tcp_tw_pcbs = pcb->next;
1029 pcb2 = pcb;
1030 pcb = pcb->next;
1033 prev = pcb;
1034 pcb = pcb->next;
1048 struct tcp_pcb *pcb;
1053 pcb = tcp_active_pcbs;
1055 while(pcb != NULL) {
1056 if (pcb->last_timer != tcp_timer_ctr) {
1058 pcb->last_timer = tcp_timer_ctr;
1060 if (pcb->flags & TF_ACK_DELAY) {
1062 tcp_ack_now(pcb);
1063 tcp_output(pcb);
1064 pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
1067 next = pcb->next;
1070 if (pcb->refused_data != NULL) {
1072 tcp_process_refused_data(pcb);
1074 /* application callback has changed the pcb list: restart the loop */
1078 pcb = next;
1083 /** Pass pcb->refused_data to the recv callback */
1085 tcp_process_refused_data(struct tcp_pcb *pcb)
1088 u8_t refused_flags = pcb->refused_data->flags;
1089 /* set pcb->refused_data to NULL in case the callback frees it and then
1090 closes the pcb */
1091 struct pbuf *refused_data = pcb->refused_data;
1092 pcb->refused_data = NULL;
1095 TCP_EVENT_RECV(pcb, refused_data, ERR_OK, err);
1101 if (pcb->rcv_wnd != TCP_WND) {
1102 pcb->rcv_wnd++;
1104 TCP_EVENT_CLOSED(pcb, err);
1110 /* if err == ERR_ABRT, 'pcb' is already deallocated */
1111 /* Drop incoming packets because pcb is "full" (only if the incoming
1113 LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: drop incoming packets, because pcb is \"full\"\n"));
1117 pcb->refused_data = refused_data;
1159 * @param pcb the tcp_pcb to manipulate
1163 tcp_setprio(struct tcp_pcb *pcb, u8_t prio)
1165 pcb->prio = prio;
1194 * a recv callback for the pcb.
1197 tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
1201 tcp_recved(pcb, p->tot_len);
1204 return tcp_close(pcb);
1219 struct tcp_pcb *pcb, *inactive;
1229 for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
1230 if (pcb->prio <= prio &&
1231 pcb->prio <= mprio &&
1232 (u32_t)(tcp_ticks - pcb->tmr) >= inactivity) {
1233 inactivity = tcp_ticks - pcb->tmr;
1234 inactive = pcb;
1235 mprio = pcb->prio;
1252 struct tcp_pcb *pcb, *inactive;
1257 /* Go through the list of TIME_WAIT pcbs and get the oldest pcb. */
1258 for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
1259 if ((u32_t)(tcp_ticks - pcb->tmr) >= inactivity) {
1260 inactivity = tcp_ticks - pcb->tmr;
1261 inactive = pcb;
1274 * @param prio priority for the new pcb
1280 struct tcp_pcb *pcb;
1283 pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
1284 if (pcb == NULL) {
1289 pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
1290 if (pcb == NULL) {
1295 pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
1296 if (pcb != NULL) {
1301 if (pcb != NULL) {
1306 if (pcb != NULL) {
1307 memset(pcb, 0, sizeof(struct tcp_pcb));
1308 pcb->prio = prio;
1309 pcb->snd_buf = TCP_SND_BUF;
1310 pcb->snd_queuelen = 0;
1311 pcb->rcv_wnd = TCP_WND;
1312 pcb->rcv_ann_wnd = TCP_WND;
1313 pcb->tos = 0;
1314 pcb->ttl = TCP_TTL;
1317 pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS;
1318 pcb->rto = 3000 / TCP_SLOW_INTERVAL;
1319 pcb->sa = 0;
1320 pcb->sv = 3000 / TCP_SLOW_INTERVAL;
1321 pcb->rtime = -1;
1322 pcb->cwnd = 1;
1324 pcb->snd_wl2 = iss;
1325 pcb->snd_nxt = iss;
1326 pcb->lastack = iss;
1327 pcb->snd_lbb = iss;
1328 pcb->tmr = tcp_ticks;
1329 pcb->last_timer = tcp_timer_ctr;
1331 pcb->polltmr = 0;
1334 pcb->recv = tcp_recv_null;
1338 pcb->keep_idle = TCP_KEEPIDLE_DEFAULT;
1341 pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT;
1342 pcb->keep_cnt = TCP_KEEPCNT_DEFAULT;
1345 pcb->keep_cnt_sent = 0;
1347 return pcb;
1353 * The pcb is not put on any list until binding using tcp_bind().
1358 * to allocate a pcb with higher prio (@see tcp_kill_prio())
1372 * @param pcb tcp_pcb to set the callback argument
1376 tcp_arg(struct tcp_pcb *pcb, void *arg)
1380 pcb->callback_arg = arg;
1388 * @param pcb tcp_pcb to set the recv callback
1389 * @param recv callback function to call for this pcb when data is received
1392 tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv)
1394 LWIP_ASSERT("invalid socket state for recv callback", pcb->state != LISTEN);
1395 pcb->recv = recv;
1402 * @param pcb tcp_pcb to set the sent callback
1403 * @param sent callback function to call for this pcb when data is successfully sent
1406 tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent)
1408 LWIP_ASSERT("invalid socket state for sent callback", pcb->state != LISTEN);
1409 pcb->sent = sent;
1416 * @param pcb tcp_pcb to set the err callback
1417 * @param err callback function to call for this pcb when a fatal error
1421 tcp_err(struct tcp_pcb *pcb, tcp_err_fn err)
1423 LWIP_ASSERT("invalid socket state for err callback", pcb->state != LISTEN);
1424 pcb->errf = err;
1431 * @param pcb tcp_pcb to set the accept callback
1432 * @param accept callback function to call for this pcb when LISTENing
1436 tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept)
1440 pcb->accept = accept;
1452 tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)
1454 LWIP_ASSERT("invalid socket state for poll", pcb->state != LISTEN);
1456 pcb->poll = poll;
1460 pcb->pollinterval = interval;
1465 * (pcb->ooseq, pcb->unsent and pcb->unacked are freed).
1467 * @param pcb tcp_pcb to purge. The pcb itself is not deallocated!
1470 tcp_pcb_purge(struct tcp_pcb *pcb)
1472 if (pcb->state != CLOSED &&
1473 pcb->state != TIME_WAIT &&
1474 pcb->state != LISTEN) {
1479 if (pcb->state == SYN_RCVD) {
1482 LWIP_ASSERT("tcp_pcb_purge: pcb->state == SYN_RCVD but tcp_listen_pcbs is NULL",
1485 if ((lpcb->local_port == pcb->local_port) &&
1487 ip_addr_cmp(&pcb->local_ip, &lpcb->local_ip))) {
1488 /* port and address of the listen pcb match the timed-out pcb */
1489 LWIP_ASSERT("tcp_pcb_purge: listen pcb does not have accepts pending",
1499 if (pcb->refused_data != NULL) {
1501 pbuf_free(pcb->refused_data);
1502 pcb->refused_data = NULL;
1504 if (pcb->unsent != NULL) {
1507 if (pcb->unacked != NULL) {
1511 if (pcb->ooseq != NULL) {
1514 tcp_segs_free(pcb->ooseq);
1515 pcb->ooseq = NULL;
1520 pcb->rtime = -1;
1522 tcp_segs_free(pcb->unsent);
1523 tcp_segs_free(pcb->unacked);
1524 pcb->unacked = pcb->unsent = NULL;
1526 pcb->unsent_oversize = 0;
1535 * @param pcb tcp_pcb to purge. The pcb itself is NOT deallocated!
1538 tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
1540 TCP_RMV(pcblist, pcb);
1542 tcp_pcb_purge(pcb);
1545 if (pcb->state != TIME_WAIT &&
1546 pcb->state != LISTEN &&
1547 pcb->flags & TF_ACK_DELAY) {
1548 pcb->flags |= TF_ACK_NOW;
1549 tcp_output(pcb);
1552 if (pcb->state != LISTEN) {
1553 LWIP_ASSERT("unsent segments leaking", pcb->unsent == NULL);
1554 LWIP_ASSERT("unacked segments leaking", pcb->unacked == NULL);
1556 LWIP_ASSERT("ooseq segments leaking", pcb->ooseq == NULL);
1560 pcb->state = CLOSED;
1699 struct tcp_pcb *pcb;
1701 for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
1703 pcb->local_port, pcb->remote_port,
1704 pcb->snd_nxt, pcb->rcv_nxt));
1705 tcp_debug_print_state(pcb->state);
1708 for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) {
1710 pcb->local_port, pcb->remote_port,
1711 pcb->snd_nxt, pcb->rcv_nxt));
1712 tcp_debug_print_state(pcb->state);
1715 for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
1717 pcb->local_port, pcb->remote_port,
1718 pcb->snd_nxt, pcb->rcv_nxt));
1719 tcp_debug_print_state(pcb->state);
1729 struct tcp_pcb *pcb;
1730 for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
1731 LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != CLOSED", pcb->state != CLOSED);
1732 LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != LISTEN", pcb->state != LISTEN);
1733 LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
1735 for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
1736 LWIP_ASSERT("tcp_pcbs_sane: tw pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);