X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=utcp.c;h=d2a777ce00ed9b1d9ea18a622f1ab1523dcc74b5;hb=d6f18182c43287c180e637046c044e8bff5e7064;hp=802d95a2ba87ea3de46d9235176f5273361e6ca7;hpb=eb85ec4ae5f32102430e0622e3855aaba110c032;p=utcp diff --git a/utcp.c b/utcp.c index 802d95a..d2a777c 100644 --- a/utcp.c +++ b/utcp.c @@ -382,7 +382,6 @@ static struct utcp_connection *allocate_connection(struct utcp *utcp, uint16_t s #endif c->snd.una = c->snd.iss; c->snd.nxt = c->snd.iss + 1; - c->rcv.wnd = utcp->mtu; c->snd.last = c->snd.nxt; c->snd.cwnd = utcp->mtu; c->utcp = utcp; @@ -468,7 +467,7 @@ struct utcp_connection *utcp_connect_ex(struct utcp *utcp, uint16_t dst, utcp_re pkt.hdr.dst = c->dst; pkt.hdr.seq = c->snd.iss; pkt.hdr.ack = 0; - pkt.hdr.wnd = c->rcv.wnd; + pkt.hdr.wnd = c->rcvbuf.maxsize; pkt.hdr.ctl = SYN; pkt.hdr.aux = 0x0101; pkt.init[0] = 1; @@ -538,7 +537,7 @@ static void ack(struct utcp_connection *c, bool sendatleastone) { pkt->hdr.src = c->src; pkt->hdr.dst = c->dst; pkt->hdr.ack = c->rcv.nxt; - pkt->hdr.wnd = c->snd.wnd; + pkt->hdr.wnd = c->rcvbuf.maxsize; pkt->hdr.ctl = ACK; pkt->hdr.aux = 0; @@ -629,6 +628,8 @@ ssize_t utcp_send(struct utcp_connection *c, const void *data, size_t len) { if(is_reliable(c) || (c->state != SYN_SENT && c->state != SYN_RECEIVED)) { len = buffer_put(&c->sndbuf, data, len); + } else { + return 0; } if(len <= 0) { @@ -695,7 +696,7 @@ static void retransmit(struct utcp_connection *c) { pkt->hdr.src = c->src; pkt->hdr.dst = c->dst; - pkt->hdr.wnd = c->rcv.wnd; + pkt->hdr.wnd = c->rcvbuf.maxsize; pkt->hdr.aux = 0; switch(c->state) { @@ -1071,7 +1072,7 @@ synack: pkt.hdr.dst = c->dst; pkt.hdr.ack = c->rcv.irs + 1; pkt.hdr.seq = c->snd.iss; - pkt.hdr.wnd = c->rcv.wnd; + pkt.hdr.wnd = c->rcvbuf.maxsize; pkt.hdr.ctl = SYN | ACK; if(init) { @@ -1314,8 +1315,10 @@ synack: assert(data_acked >= 0); +#ifndef NDEBUG int32_t bufused = seqdiff(c->snd.last, c->snd.una); assert(data_acked <= bufused); +#endif if(data_acked) { buffer_get(&c->sndbuf, NULL, data_acked);