diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-14 18:51:26 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-14 18:51:26 +0200 |
commit | fe451b37c89207b44442dcf01ec17b787af7d4d0 (patch) | |
tree | deb4f3296a1201133918f58053ac45847de58e84 | |
parent | a1fa80a4f8e747b31b999035729b7871ae072817 (diff) |
WIP send in tx hook
-rw-r--r-- | sysdep/unix/wg_user.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/sysdep/unix/wg_user.c b/sysdep/unix/wg_user.c index 21c05a77..22933b5a 100644 --- a/sysdep/unix/wg_user.c +++ b/sysdep/unix/wg_user.c @@ -63,6 +63,24 @@ static void user_tx_hook(struct birdsock *bs) { log(L_TRACE "WG: TX %p %d", bs, bs->tpos - bs->ttx); + + uint size = (uint)bs->user; + + 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->user = NULL; + } } /* errno or zero if EOF */ @@ -263,12 +281,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 */ - log(L_TRACE "WG: send %d", res); - if (res != 0) { - //shutdown(sock->fd, SHUT_WR); - } + sock->user = (void*)size; /* abort(); */ return -1; |