From ec4c8bcb18c1f463cf4544126e027fc8ec9b3a39 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 12 Oct 2009 22:14:47 +0200 Subject: [PATCH] Allow the cloning /dev/tap interface to be used on FreeBSD and NetBSD. This device works like /dev/tun on Linux, automatically creating a new tap interface when a program opens it. We now pass the actual name of the newly created interface in $INTERFACE. --- src/bsd/device.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bsd/device.c b/src/bsd/device.c index fd1f35dd..06889e3c 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -150,6 +150,17 @@ bool setup_device(void) { if(routing_mode == RMODE_ROUTER) overwrite_mac = true; device_info = "Generic BSD tap device"; +#ifdef TAPGIFNAME + { + struct ifreq ifr; + if(ioctl(device_fd, TAPGIFNAME, (void*)&ifr) == 0) { + if(iface) + free(iface); + iface = xstrdup(ifr.ifr_name); + } + } + +#endif break; #ifdef HAVE_TUNEMU case DEVICE_TYPE_TUNEMU: -- 2.39.5