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; }