Sensible defaults for $INTERFACE.
authorGuus Sliepen <guus@tinc-vpn.org>
Mon, 11 Feb 2002 12:33:01 +0000 (12:33 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 11 Feb 2002 12:33:01 +0000 (12:33 +0000)
src/freebsd/device.c
src/linux/device.c
src/openbsd/device.c
src/solaris/device.c

index 492ba33d3f95db5154808cfadf4b614e29963217..e75076a99d3da25a01e502981ce5ba0c08b8d4ec 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: device.c,v 1.1.2.2 2002/02/10 21:57:54 guus Exp $
+    $Id: device.c,v 1.1.2.3 2002/02/11 12:33:01 guus Exp $
 */
 
 #include "config.h"
@@ -62,7 +62,7 @@ cp
     device = DEFAULT_DEVICE;
 
   if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
-    interface = netname;
+    interface = rindex(device, '/')?rindex(device, '/')+1:device;
 cp
   if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0)
     {
index a54647ec98c97393002ffdfd43aca8c2ba557e82..88355caabdfa80799558d55d4c6e274db9a491cf 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: device.c,v 1.1.2.5 2002/02/10 21:57:54 guus Exp $
+    $Id: device.c,v 1.1.2.6 2002/02/11 12:33:01 guus Exp $
 */
 
 #include "config.h"
@@ -77,7 +77,11 @@ cp
     device = DEFAULT_DEVICE;
 
   if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
+#ifdef HAVE_TUNTAP
     interface = netname;
+#else
+    interface = rindex(device, '/')?rindex(device, '/')+1:device;
+#endif
 cp
   if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0)
     {
index 1fccd14f18fc8db8dc7876008e68909348b35dd5..a24d2d0d36bea6e41c690fed41b2a3cbb2a9c8ce 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: device.c,v 1.1.2.3 2002/02/10 21:57:54 guus Exp $
+    $Id: device.c,v 1.1.2.4 2002/02/11 12:33:01 guus Exp $
 */
 
 #include "config.h"
@@ -66,7 +66,7 @@ int setup_device(void)
     device = DEFAULT_DEVICE;
 
   if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
-    interface = netname;
+    interface = rindex(device, '/')?rindex(device, '/')+1:device;
 cp
   if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0)
     {
index dcfd8c4477c423674da883f39632ecb99613e4e0..5aacf3e57b2cc1641b1963f6456e6c1b92bd816b 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: device.c,v 1.1.2.4 2002/02/10 21:57:54 guus Exp $
+    $Id: device.c,v 1.1.2.5 2002/02/11 12:33:01 guus Exp $
 */
 
 
@@ -113,6 +113,9 @@ cp
      return -1;
   }
 
+  if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
+    asprintf(interface, "tun%d", ppa);
+
   device_info = _("Solaris tun device");
 
   /* Set default MAC address for ethertap devices */