diff --git a/src/core/tcp.c b/src/core/tcp.c index f418f4c5..dde0632a 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -919,7 +919,7 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len) pcb->rcv_wnd = TCP_WND_MAX(pcb); } else if (pcb->rcv_wnd == 0) { /* rcv_wnd overflowed */ - if ((pcb->state == CLOSE_WAIT) || (pcb->state == LAST_ACK)) { + if (TCP_STATE_IS_CLOSING(pcb->state)) { /* In passive close, we allow this, since the FIN bit is added to rcv_wnd by the stack itself, since it is not mandatory for an application to call tcp_recved() for the FIN bit, but e.g. the netconn API does so. */ diff --git a/src/include/lwip/tcpbase.h b/src/include/lwip/tcpbase.h index 50c28536..00230746 100644 --- a/src/include/lwip/tcpbase.h +++ b/src/include/lwip/tcpbase.h @@ -66,6 +66,8 @@ enum tcp_state { LAST_ACK = 9, TIME_WAIT = 10 }; +/* ATTENTION: this depends on state number ordering! */ +#define TCP_STATE_IS_CLOSING(state) ((state) >= FIN_WAIT_1) /* Flags for "apiflags" parameter in tcp_write */ #define TCP_WRITE_FLAG_COPY 0x01