… | |
… | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
16 | |
16 | |
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
18 | along with gvpe; if not, write to the Free Software |
18 | along with gvpe; if not, write to the Free Software |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | */ |
20 | */ |
21 | |
21 | |
22 | #include "config.h" |
22 | #include "config.h" |
23 | |
23 | |
24 | #include <cstdio> |
24 | #include <cstdio> |
… | |
… | |
55 | tap_device::info () |
55 | tap_device::info () |
56 | { |
56 | { |
57 | return _("Linux tun/tap device"); |
57 | return _("Linux tun/tap device"); |
58 | } |
58 | } |
59 | |
59 | |
|
|
60 | const char * |
|
|
61 | tap_device::if_up () |
|
|
62 | { |
|
|
63 | return "/sbin/ifconfig $IFNAME hw ether $MAC mtu $MTU"; |
|
|
64 | } |
|
|
65 | |
60 | tap_device::tap_device () |
66 | tap_device::tap_device () |
61 | { |
67 | { |
62 | struct ifreq ifr; |
68 | struct ifreq ifr; |
63 | |
69 | |
64 | device = DEFAULT_DEVICE; |
70 | device = DEFAULT_DEVICE; |
… | |
… | |
88 | strncpy (ifrname, ifr.ifr_name, IFNAMSIZ); |
94 | strncpy (ifrname, ifr.ifr_name, IFNAMSIZ); |
89 | ifrname [IFNAMSIZ] = 0; |
95 | ifrname [IFNAMSIZ] = 0; |
90 | } |
96 | } |
91 | else |
97 | else |
92 | { |
98 | { |
93 | 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)); |
94 | exit (EXIT_FAILURE); |
100 | exit (EXIT_FAILURE); |
95 | } |
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 |
96 | |
112 | |
97 | if (ioctl (fd, TUNSETPERSIST, conf.ifpersist ? 1 : 0)) |
113 | if (ioctl (fd, TUNSETPERSIST, conf.ifpersist ? 1 : 0)) |
98 | 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)); |
99 | |
115 | |
100 | slog (L_DEBUG, _("%s is a %s"), device, info ()); |
116 | slog (L_DEBUG, _("%s is a %s"), device, info ()); |