ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/device-linux.C
(Generate patch)

Comparing gvpe/src/device-linux.C (file contents):
Revision 1.10 by pcg, Fri Mar 18 01:53:05 2005 UTC vs.
Revision 1.15 by pcg, Fri Apr 8 16:48:16 2005 UTC

40#else 40#else
41#include <linux/if_tun.h> 41#include <linux/if_tun.h>
42#endif 42#endif
43#define DEFAULT_DEVICE "/dev/net/tun" 43#define DEFAULT_DEVICE "/dev/net/tun"
44 44
45#include "gettext.h"
46
45#include "conf.h" 47#include "conf.h"
46 48
47#if TEST_ETHEREMU 49#if TEST_ETHEREMU
48# define IF_istun 50# define IF_istun
49# include "ether_emu.C" 51# include "ether_emu.C"
51 53
52const char * 54const char *
53tap_device::info () 55tap_device::info ()
54{ 56{
55 return _("Linux tun/tap device"); 57 return _("Linux tun/tap device");
58}
59
60const char *
61tap_device::if_up ()
62{
63 return "/sbin/ifconfig $IFNAME hw ether $MAC mtu $MTU";
56} 64}
57 65
58tap_device::tap_device () 66tap_device::tap_device ()
59{ 67{
60 struct ifreq ifr; 68 struct ifreq ifr;
86 strncpy (ifrname, ifr.ifr_name, IFNAMSIZ); 94 strncpy (ifrname, ifr.ifr_name, IFNAMSIZ);
87 ifrname [IFNAMSIZ] = 0; 95 ifrname [IFNAMSIZ] = 0;
88 } 96 }
89 else 97 else
90 { 98 {
91 slog (L_CRIT, _("unable to configure tun/tap interface: %s"), strerror (errno)); 99 slog (L_CRIT, _("unable to configure tun/tap interface, exiting: %s"), strerror (errno));
92 exit (EXIT_FAILURE); 100 exit (EXIT_FAILURE);
93 } 101 }
102
103#if 0
104 does not work
105 id2mac (THISNODE->id, &ifr.ifr_hwaddr.sa_data);
106 if (ioctl (fd, SIOCSIFHWADDR, &ifr))
107 {
108 slog (L_ERR, _("cannot set MAC address for device %s, exiting: %s"), ifrname, strerror (errno));
109 exit (EXIT_FAILURE);
110 }
111#endif
94 112
95 if (ioctl (fd, TUNSETPERSIST, conf.ifpersist ? 1 : 0)) 113 if (ioctl (fd, TUNSETPERSIST, conf.ifpersist ? 1 : 0))
96 slog (L_WARN, _("cannot set persistency mode for device %s: %s"), ifrname, strerror (errno)); 114 slog (L_WARN, _("cannot set persistency mode for device %s: %s"), ifrname, strerror (errno));
97 115
98 slog (L_DEBUG, _("%s is a %s"), device, info ()); 116 slog (L_DEBUG, _("%s is a %s"), device, info ());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines