aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tun.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tun.c')
-rw-r--r--lib/tun.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/tun.c b/lib/tun.c
index 6ca9be7..bf95630 100644
--- a/lib/tun.c
+++ b/lib/tun.c
@@ -713,7 +713,7 @@ int tun_delroute(struct tun_t *this,
return tun_route(this, dst, gateway, mask, 1);
}
-int tun_new(struct tun_t **tun)
+int tun_new(struct tun_t **tun, const char *dev_name)
{
#if defined(__linux__)
@@ -754,6 +754,8 @@ int tun_new(struct tun_t **tun)
/* Set device flags. For some weird reason this is also the method
used to obtain the network interface name */
memset(&ifr, 0, sizeof(ifr));
+ if (dev_name)
+ strcpy(ifr.ifr_name, dev_name);
ifr.ifr_flags = IFF_TUN | IFF_NO_PI; /* Tun device, no packet info */
if (ioctl((*tun)->fd, TUNSETIFF, (void *)&ifr) < 0) {
SYS_ERR(DTUN, LOGL_ERROR, errno, "ioctl() failed");