X-Git-Url: http://git.meshlink.io/?p=utcp;a=blobdiff_plain;f=utcp.c;h=ca3c132f60c9132da69b019e3583d83db11974df;hp=5962820805d60f822a3a16d28b4098c604bb380f;hb=5d4cf9d0eb85c7322298a2a0526132197e3bf633;hpb=153fb78c9727b4ab60ad8cdbf6a994ea2f9611c8 diff --git a/utcp.c b/utcp.c index 5962820..ca3c132 100644 --- a/utcp.c +++ b/utcp.c @@ -1022,6 +1022,9 @@ int utcp_timeout(struct utcp *utcp) { retransmit(c); } + if(c->poll && c->sndbufsize < c->maxsndbufsize / 2) + c->poll(c, c->maxsndbufsize - c->sndbufsize); + if(timerisset(&c->conn_timeout) && timercmp(&c->conn_timeout, &next, <)) next = c->conn_timeout; @@ -1097,6 +1100,10 @@ size_t utcp_get_sndbuf(struct utcp_connection *c) { return c->maxsndbufsize; } +size_t utcp_get_sndbuf_free(struct utcp_connection *c) { + return c->maxsndbufsize - c->sndbufsize; +} + void utcp_set_sndbuf(struct utcp_connection *c, size_t size) { c->maxsndbufsize = size; if(c->maxsndbufsize != size) @@ -1122,3 +1129,11 @@ void utcp_set_keepalive(struct utcp_connection *c, bool keepalive) { size_t utcp_get_outq(struct utcp_connection *c) { return seqdiff(c->snd.nxt, c->snd.una); } + +void utcp_set_recv_cb(struct utcp_connection *c, utcp_recv_t recv) { + c->recv = recv; +} + +void utcp_set_poll_cb(struct utcp_connection *c, utcp_poll_t poll) { + c->poll = poll; +}