X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=utcp.c;h=ce056904169c6923baa95a0e5435626e5da75fd5;hb=f268b8518415a5cf896e1b3518c2a0141d1364d4;hp=e347bb7165209b284409c6f92fca724993c05c04;hpb=7109995777c654016784a11fdebe3b26e6a0002a;p=utcp diff --git a/utcp.c b/utcp.c index e347bb7..ce05690 100644 --- a/utcp.c +++ b/utcp.c @@ -282,7 +282,12 @@ static struct utcp_connection *allocate_connection(struct utcp *utcp, uint16_t s c->src = src; c->dst = dst; +#ifdef UTCP_DEBUG +#warning debugging + c->snd.iss = 0; +#else c->snd.iss = rand(); +#endif c->snd.una = c->snd.iss; c->snd.nxt = c->snd.iss + 1; c->rcv.wnd = utcp->mtu; @@ -360,7 +365,7 @@ static void ack(struct utcp_connection *c, bool sendatleastone) { } *pkt; pkt = malloc(sizeof pkt->hdr + c->utcp->mtu); - if(!pkt->data) + if(!pkt) return; pkt->hdr.src = c->src; @@ -500,6 +505,7 @@ static void retransmit(struct utcp_connection *c) { len--; pkt->hdr.ctl |= FIN; } + c->snd.nxt = c->snd.una + len; buffer_copy(&c->sndbuf, pkt->data, 0, len); print_packet(c->utcp, "rtrx", pkt, sizeof pkt->hdr + len); utcp->send(utcp, pkt, sizeof pkt->hdr + len);