memmove(cp + i, cp + i + 1, (utcp->nconnections - i - 1) * sizeof *cp);
utcp->nconnections--;
+ free(c->sndbuf);
free(c);
}
hdr.dst = c->dst;
hdr.seq = c->snd.iss;
hdr.ack = 0;
- hdr.ctl = SYN;
hdr.wnd = c->rcv.wnd;
+ hdr.ctl = SYN;
+ hdr.aux = 0;
set_state(c, SYN_SENT);
pkt.hdr.ack = c->rcv.nxt;
pkt.hdr.wnd = c->snd.wnd;
pkt.hdr.ctl = ACK;
+ pkt.hdr.aux = 0;
do {
uint32_t seglen = left > c->utcp->mtu ? c->utcp->mtu : left;
// FIN counts as one sequence number
c->rcv.nxt++;
+ len++;
// Inform the application that the peer closed the connection.
if(c->recv) {
void utcp_exit(struct utcp *utcp) {
if(!utcp)
return;
- for(int i = 0; i < utcp->nconnections; i++)
- free_connection(utcp->connections[i]);
+ for(int i = 0; i < utcp->nconnections; i++) {
+ if(!utcp->connections[i]->reapable)
+ debug("Warning, freeing unclosed connection %p\n", utcp->connections[i]);
+ free(utcp->connections[i]->sndbuf);
+ free(utcp->connections[i]);
+ }
+ free(utcp->connections);
free(utcp);
}