[pisa-src] r2272 - trunk/libpisa/sysdep_tun.c

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 15 Apr 2010 11:51:20 +0200

Author: biurrun
Date: Thu Apr 15 11:51:20 2010
New Revision: 2272

Log:
Factorize common parts of pisa_tunnel_open_tundev() implementations.

Modified:
   trunk/libpisa/sysdep_tun.c

Modified: trunk/libpisa/sysdep_tun.c
==============================================================================
--- trunk/libpisa/sysdep_tun.c  Thu Apr 15 11:49:36 2010        (r2271)
+++ trunk/libpisa/sysdep_tun.c  Thu Apr 15 11:51:20 2010        (r2272)
@@ -37,8 +37,8 @@
 int pisa_tunnel_open_tundev(char *devicename, size_t len)
 {
 /* systems like Linux and FreeBSD use a common tunneling interface */
-#ifdef IFF_TUN
     int fd_tun;
+#ifdef IFF_TUN
     struct ifreq ifr;
 
     if ((fd_tun = open("/dev/net/tun", O_RDWR)) < 0) {
@@ -54,10 +54,8 @@
     }
 
     strncpy(devicename, ifr.ifr_name, len);
-
-    return fd_tun;
 #else
-    int i, fd_tun;
+    int i;
     char name[32];
 
     for (i = 0; i < 255; i++) {
@@ -69,7 +67,6 @@
     }
 
     pisa_die("Could not open tunnel device.", EXIT_FAILURE);
-    return -1;
 #endif /* IFF_TUN */
+    return fd_tun;
 }
-

Other related posts:

  • » [pisa-src] r2272 - trunk/libpisa/sysdep_tun.c - Diego Biurrun