From d2accfd480e58c67da672c92868724eb66cbce77 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 23 Mar 2015 00:21:58 +0100 Subject: Fix sending data from peer-specific interfaces --- src/fastd.h | 2 +- src/iface.c | 2 +- src/receive.c | 2 +- src/send.c | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/fastd.h b/src/fastd.h index 296f3b1..d901554 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -347,7 +347,7 @@ extern fastd_config_t conf; void fastd_send(const fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer, fastd_buffer_t buffer, size_t stat_size); void fastd_send_handshake(const fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_peer_t *peer, fastd_buffer_t buffer); -void fastd_send_data(fastd_buffer_t buffer, fastd_peer_t *source); +void fastd_send_data(fastd_buffer_t buffer, fastd_peer_t *source, fastd_peer_t *dest); void fastd_receive_unknown_init(void); void fastd_receive_unknown_free(void); diff --git a/src/iface.c b/src/iface.c index be0af40..5d6fb27 100644 --- a/src/iface.c +++ b/src/iface.c @@ -407,7 +407,7 @@ void fastd_iface_handle(fastd_iface_t *iface) { if (multiaf_tun && get_iface_type() == IFACE_TYPE_TUN) fastd_buffer_push_head(&buffer, 4); - fastd_send_data(buffer, iface->peer); + fastd_send_data(buffer, NULL, iface->peer); } /** Writes a packet to the TUN/TAP device */ diff --git a/src/receive.c b/src/receive.c index 2f0c87c..c1f962c 100644 --- a/src/receive.c +++ b/src/receive.c @@ -309,7 +309,7 @@ void fastd_handle_receive(fastd_peer_t *peer, fastd_buffer_t buffer, bool reorde fastd_iface_write(peer->iface ?: ctx.iface, buffer); if (conf.mode == MODE_TAP && conf.forward) { - fastd_send_data(buffer, peer); + fastd_send_data(buffer, peer, NULL); return; } diff --git a/src/send.c b/src/send.c index c340daf..f0ba2f7 100644 --- a/src/send.c +++ b/src/send.c @@ -242,7 +242,12 @@ static inline bool send_data_tap_single(fastd_buffer_t buffer, fastd_peer_t *sou } /** Sends a buffer of payload data to other peers */ -void fastd_send_data(fastd_buffer_t buffer, fastd_peer_t *source) { +void fastd_send_data(fastd_buffer_t buffer, fastd_peer_t *source, fastd_peer_t *dest) { + if (dest) { + conf.protocol->send(dest, buffer); + return; + } + if (send_data_tap_single(buffer, source)) return; -- cgit v1.2.3