From 8e3796f586b0b3b4415c248cb0614e6d2dcb9f82 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sun, 18 Jul 2021 19:23:02 +0200 Subject: [PATCH] Added interface request options and ioctl'd it (confirmed working) --- source/libtun/tunctl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/libtun/tunctl.c b/source/libtun/tunctl.c index 12f074a..e2b7093 100644 --- a/source/libtun/tunctl.c +++ b/source/libtun/tunctl.c @@ -17,16 +17,26 @@ #include #include #include +#include +#include -int createTun(char* interfaceName, short iffFlags) +int createTun(char* interfaceName, int iffFlags) { /* TODO: Add all required error checking */ int tunFD = open("/dev/net/tun", O_RDWR); + /* TUN properties */ struct ifreq interfaceReqData; + /* Set the flags for the tun adapter */ interfaceReqData.ifr_flags = iffFlags; + /* Set the requested interface's name */ + strcpy(interfaceReqData.ifr_name, interfaceName); + + /* Attempt to bring up the tun device node */ + tunFD = ioctl(tunFD, TUNSETIFF, &interfaceReqData); + return tunFD; }