From 08e782b27d47c4b5e74d505aecfee661ff9df4e0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 23 Mar 2015 00:38:14 +0100 Subject: Set the default interface for all peers --- src/peer.c | 4 +++- src/protocols/ec25519_fhmqvc/handshake.c | 1 + src/receive.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/peer.c b/src/peer.c index 417e213..35eae28 100644 --- a/src/peer.c +++ b/src/peer.c @@ -44,7 +44,7 @@ void fastd_peer_set_shell_env(fastd_shell_env_t *env, const fastd_peer_t *peer, fastd_shell_env_set(env, "PEER_NAME", peer ? peer->name : NULL); - fastd_shell_env_set_iface(env, peer->iface ?: ctx.iface); + fastd_shell_env_set_iface(env, peer->iface); switch(local_addr ? local_addr->sa.sa_family : AF_UNSPEC) { case AF_INET: @@ -378,6 +378,8 @@ static void setup_peer(fastd_peer_t *peer) { peer->verify_valid_timeout = ctx.now; #endif + peer->iface = ctx.iface; + if (!fastd_peer_is_enabled(peer)) /* Keep the peer in STATE_INACTIVE */ return; diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c index 27e4894..246336b 100644 --- a/src/protocols/ec25519_fhmqvc/handshake.c +++ b/src/protocols/ec25519_fhmqvc/handshake.c @@ -562,6 +562,7 @@ static fastd_peer_t * add_dynamic(fastd_socket_t *sock, const fastd_peer_address fastd_peer_t *peer = fastd_new0(fastd_peer_t); peer->group = conf.peer_group; + peer->iface = ctx.iface; peer->config_state = CONFIG_DYNAMIC; peer->key = fastd_new(fastd_protocol_key_t); diff --git a/src/receive.c b/src/receive.c index c1f962c..df25364 100644 --- a/src/receive.c +++ b/src/receive.c @@ -306,7 +306,7 @@ void fastd_handle_receive(fastd_peer_t *peer, fastd_buffer_t buffer, bool reorde if (reordered) fastd_stats_add(peer, STAT_RX_REORDERED, buffer.len); - fastd_iface_write(peer->iface ?: ctx.iface, buffer); + fastd_iface_write(peer->iface, buffer); if (conf.mode == MODE_TAP && conf.forward) { fastd_send_data(buffer, peer, NULL); -- cgit v1.2.3