diff options
-rw-r--r-- | src/main.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -28,6 +28,17 @@ static void setup_tundev(const char *in_ifname) debug("setup_tundev: created tuntap interface: %s", in_ifname); + struct ifreq ifr2; + memset(&ifr2, 0, sizeof(ifr2)); + ifr2.ifr_flags = IFF_UP|IFF_RUNNING; + strncpy(ifr2.ifr_name, in_ifname, IFNAMSIZ - 1); + int tmpfd = socket(AF_INET, SOCK_DGRAM, 0); + if (tmpfd < 0) + fatal("setup_tundev: socket(): %s", strerror(errno)); + if (ioctl(tmpfd, SIOCSIFFLAGS, &ifr2) < 0) + fatal("setup_tundev: ioctl(SIOCSIFFLAGS): %s", strerror(errno)); + close(tmpfd); + tun_fd = fd; } |