X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=utcp.c;h=0cb68b9da7195495602c1c196c835f2cab46d7b2;hb=8df47165e536daa4ff37e657476850ac94dafc69;hp=b0ba05428926ba1dd11c7b91c942d27d1fae97e7;hpb=7271cf87721ab667a03f50bd40b4a8ec83b989d3;p=utcp diff --git a/utcp.c b/utcp.c index b0ba054..0cb68b9 100644 --- a/utcp.c +++ b/utcp.c @@ -142,9 +142,6 @@ static int32_t seqdiff(uint32_t a, uint32_t b) { // Store data into the buffer static ssize_t buffer_put_at(struct buffer *buf, size_t offset, const void *data, size_t len) { - if(buf->maxsize <= buf->used) - return 0; - debug("buffer_put_at %lu %lu %lu\n", (unsigned long)buf->used, (unsigned long)offset, (unsigned long)len); size_t required = offset + len; @@ -893,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) { @@ -908,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