Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added debugs functions to mini-tun device

  • Loading branch information...
commit 40561b319fd9b7d3b7e730cc36610ec7629a1e10 1 parent 8ec67d7
@EXio4 authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 libs/net/tun.c
View
10 libs/net/tun.c
@@ -4,16 +4,20 @@
#include <net/if.h>
#include <linux/if_tun.h>
#include <sys/ioctl.h>
+#include <libs/debug/debug.h>
int TUN_ALLOCATE(char *name, char *interfacename,int mode) {
struct ifreq ifr;
int fd;
- if ( (fd = open("/dev/net/tun",O_RDWR)) < 0) return -1;
+
+ DEBUG("opening tun device .... \n");
+ if ( (fd = open("/dev/net/tun",O_RDWR)) < 0) { DEBUG("[%s] error in [open]\n",name); return -1; }
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = mode;
strncpy(ifr.ifr_name, name, IFNAMSIZ);
- if (ioctl(fd, TUNSETIFF, (void *)&ifr) < 0) return -2;
-
+ DEBUG("ok! allocating tun device\n");
+ if (ioctl(fd, TUNSETIFF, (void *)&ifr) < 0) { DEBUG("[%s] error in [ioctl]\n",name); return -2; }
+ DEBUG("tun device allocated..n");
interfacename=malloc(strlen(ifr.ifr_name+1));
strcpy(interfacename,ifr.ifr_name);
return fd;
Please sign in to comment.
Something went wrong with that request. Please try again.