--- gvpe/src/device-linux.C 2003/10/16 02:41:21 1.5 +++ gvpe/src/device-linux.C 2005/04/26 00:55:56 1.16 @@ -1,8 +1,10 @@ /* device-linux.C -- Interaction with Linux tun/tap device - Copyright (C) 2003 Marc Lehmann + Copyright (C) 2003-2005 Marc Lehmann - This program is free software; you can redistribute it and/or modify + This file is part of GVPE. + + GVPE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -13,8 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + along with gvpe; if not, write to the Free Software + Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" @@ -45,6 +47,7 @@ #include "conf.h" #if TEST_ETHEREMU +# define IF_istun # include "ether_emu.C" #endif @@ -54,6 +57,12 @@ return _("Linux tun/tap device"); } +const char * +tap_device::if_up () +{ + return "/sbin/ifconfig $IFNAME hw ether $MAC mtu $MTU"; +} + tap_device::tap_device () { struct ifreq ifr; @@ -65,7 +74,7 @@ if (fd < 0) { slog (L_ERR, _("could not open device %s: %s"), device, strerror (errno)); - exit (1); + exit (EXIT_FAILURE); } memset (&ifr, 0, sizeof (ifr)); @@ -87,10 +96,20 @@ } else { - slog (L_CRIT, _("unable to configure tun/tap interface: %s"), strerror (errno)); - exit (1); + slog (L_CRIT, _("unable to configure tun/tap interface, exiting: %s"), strerror (errno)); + exit (EXIT_FAILURE); } +#if 0 + does not work + id2mac (THISNODE->id, &ifr.ifr_hwaddr.sa_data); + if (ioctl (fd, SIOCSIFHWADDR, &ifr)) + { + slog (L_ERR, _("cannot set MAC address for device %s, exiting: %s"), ifrname, strerror (errno)); + exit (EXIT_FAILURE); + } +#endif + if (ioctl (fd, TUNSETPERSIST, conf.ifpersist ? 1 : 0)) slog (L_WARN, _("cannot set persistency mode for device %s: %s"), ifrname, strerror (errno));