]> git.meshlink.io Git - utcp/commitdiff
Handle FIN_WAIT_1 state when retransmitting.
authorGuus Sliepen <guus@meshlink.io>
Sat, 16 Aug 2014 15:48:45 +0000 (17:48 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sat, 16 Aug 2014 15:48:45 +0000 (17:48 +0200)
utcp.c

diff --git a/utcp.c b/utcp.c
index a65eb145a5477b860ee7c2663cfc0793a4fece92..65885287f599631b045c563b2564ef3301a893d3 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -954,12 +954,19 @@ static void retransmit(struct utcp_connection *c) {
                        break;
 
                case ESTABLISHED:
+               case FIN_WAIT_1:
                        pkt.hdr.seq = c->snd.una;
                        pkt.hdr.ack = c->rcv.nxt;
                        pkt.hdr.ctl = ACK;
                        uint32_t len = seqdiff(c->snd.nxt, c->snd.una);
+                       if(c->state == FIN_WAIT_1)
+                               len--;
                        if(len > utcp->mtu)
                                len = utcp->mtu;
+                       else {
+                               if(c->state == FIN_WAIT_1)
+                                       pkt.hdr.ctl |= FIN;
+                       }
                        memcpy(pkt.data, c->sndbuf, len);
                        print_packet(c->utcp, "rtrx", &pkt, sizeof pkt.hdr + len);
                        utcp->send(utcp, &pkt, sizeof pkt.hdr + len);