summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2020-05-14 18:51:26 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2020-09-13 18:06:16 +0200
commitad138801838ed4b7e992bbb7a03c503b7edd7de4 (patch)
tree06a3f2c64bedc70627fa6676aa7f5487977f2f05
parent52c4fdca5b62da95cd171e89b1a3ace338f65356 (diff)
WIP send in tx hook
-rw-r--r--sysdep/unix/wg_user.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/sysdep/unix/wg_user.c b/sysdep/unix/wg_user.c
index 052522db..94060585 100644
--- a/sysdep/unix/wg_user.c
+++ b/sysdep/unix/wg_user.c
@@ -58,7 +58,25 @@ int user_rx_hook(struct birdsock *sk UNUSED, uint size UNUSED)
static
void user_tx_hook(struct birdsock *bs)
{
- DBG(L_TRACE "WG: TX %p %d", bs, s->tpos - s->ttx);
+ DBG(L_TRACE "WG: TX %p %d", bs, bs->tpos - bs->ttx);
+
+ uint size = (uint)bs->data;
+
+ if (size > 0)
+ {
+ int res = sk_send(bs, bs->tbsize - size);
+
+ /* Send data, <0=err, >0=ok, 0=sleep */
+ log(L_TRACE "WG: send %d", res);
+
+ if (res != 0)
+ {
+ //rfree(sock);
+ //shutdown(sock->fd, SHUT_WR);
+ }
+
+ bs->data = NULL;
+ }
}
/* errno or zero if EOF */
@@ -258,9 +276,7 @@ wg_user_set_device(struct pool *pool,
rfree(sock);
return -1;
}
- res = sk_send(sock, tbsize - size);
- /* Send data, <0=err, >0=ok, 0=sleep */
- DBG(L_TRACE "WG: send %d", res);
+ sock->data = (void*)size;
/* abort(); */
return -1;