diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-03-23 19:04:49 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-03-23 19:04:49 +0100 |
commit | 45d573ab617136670223de5e271f8e7398007c1c (patch) | |
tree | dee4d89c4646f9497dcd61ac4fe900371071a076 /src/iface.c | |
parent | 1602e36635ad9523ae7dc4f7ab93b6a89b8741fd (diff) | |
download | fastd-45d573ab617136670223de5e271f8e7398007c1c.tar fastd-45d573ab617136670223de5e271f8e7398007c1c.zip |
Move ifname logic from peer to iface
Diffstat (limited to 'src/iface.c')
-rw-r--r-- | src/iface.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/iface.c b/src/iface.c index d7caa30..6cad96d 100644 --- a/src/iface.c +++ b/src/iface.c @@ -33,7 +33,8 @@ Management of the TUN/TAP interface */ -#include "fastd.h" +#include "config.h" +#include "peer.h" #include "poll.h" #include <net/if.h> @@ -462,10 +463,19 @@ void fastd_iface_write(fastd_iface_t *iface, fastd_buffer_t buffer) { } /** Opens a new TUN/TAP interface, optionally associated with a specific peer */ -fastd_iface_t * fastd_iface_open(const char *ifname, fastd_peer_t *peer) { +fastd_iface_t * fastd_iface_open(fastd_peer_t *peer) { fastd_iface_t *iface = fastd_new(fastd_iface_t); iface->peer = peer; + const char *ifname = conf.ifname; + + if (peer) { + if (peer->ifname) + ifname = peer->ifname; + else if (!fastd_config_single_iface()) + ifname = NULL; + } + pr_debug("initializing TUN/TAP device..."); open_iface(iface, ifname); |