Hi,
When TCP_WND is set to (for example) 1MiB, the initially advertised window in SYN packets ends up being 0. Would the fix below be sufficient?
Note: It should be 32KiB if we want to be cautious about (rare cases?) TCP stacks interpreting 'window-size' as a signed value. However, I see that setting TCP_WND to values bigger than 32KiB is supported even without window scaling (according to existing checks for TCP_WND in src/core/init.c), hence I used 64KiB.
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -1141,7 +1141,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
if (seg->flags & TF_SEG_OPTS_WND_SCALE) {
/* The Window field in a SYN segment itself (the only type where we send
the window scale option) is never scaled. */
- seg->tcphdr->wnd = htons(pcb->rcv_ann_wnd);
+ seg->tcphdr->wnd = htons(LWIP_MIN(pcb->rcv_ann_wnd, 65535U));
} else
#endif /* LWIP_WND_SCALE */
{
-- Dmitry