X-Git-Url: http://git.meshlink.io/?p=utcp;a=blobdiff_plain;f=utcp.c;h=0cb68b9da7195495602c1c196c835f2cab46d7b2;hp=6b882c6f4cd4a0a888aff9dfafe18d080681dc5c;hb=8df47165e536daa4ff37e657476850ac94dafc69;hpb=ff52b8b4f37eeb4e0bfafb00d403f28395c2c957 diff --git a/utcp.c b/utcp.c index 6b882c6..0cb68b9 100644 --- a/utcp.c +++ b/utcp.c @@ -890,14 +890,15 @@ ssize_t utcp_recv(struct utcp *utcp, const void *data, size_t len) { // cut already accepted front overlapping if(rcv_offset < 0) { - acceptable = rcv_offset + len >= 0; + acceptable = len > -rcv_offset; if(acceptable) { data -= rcv_offset; len += rcv_offset; + hdr.seq -= rcv_offset; } + } else { + acceptable = seqdiff(hdr.seq, c->rcv.nxt) >= 0 && seqdiff(hdr.seq, c->rcv.nxt) + len <= c->rcvbuf.maxsize; } - - acceptable = seqdiff(hdr.seq, c->rcv.nxt) >= 0 && seqdiff(hdr.seq, c->rcv.nxt) + len <= c->rcvbuf.maxsize; } if(!acceptable) { @@ -905,9 +906,8 @@ ssize_t utcp_recv(struct utcp *utcp, const void *data, size_t len) { // Ignore unacceptable RST packets. if(hdr.ctl & RST) return 0; - // Otherwise, send an ACK back in the hope things improve. - ack(c, true); - return 0; + // Otherwise, continue processing. + len = 0; } c->snd.wnd = hdr.wnd; // TODO: move below