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

Comparing gvpe/src/device-cygwin.C (file contents):
Revision 1.7 by pcg, Sat Jan 17 01:18:36 2004 UTC vs.
Revision 1.9 by pcg, Thu Mar 3 16:54:34 2005 UTC

1/* 1/*
2 device-cygwin.C -- Stub for Cygwin environment 2 device-cygwin.C -- Stub for Cygwin environment
3 Copyright (C) 2003-2004 Marc Lehmann <ocg@goof.com> 3 Copyright (C) 2003-2005 Marc Lehmann <ocg@goof.com>
4 Copyright (C) 2002-2003 Ivo Timmermans <ivo@o2w.nl>, 4 Copyright (C) 2002-2003 Ivo Timmermans <ivo@o2w.nl>,
5 2002-2003 Guus Sliepen <guus@sliepen.eu.org> 5 2002-2003 Guus Sliepen <guus@sliepen.eu.org>
6 6
7 This file is part of GVPE.
8
7 This program is free software; you can redistribute it and/or modify 9 GVPE is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 11 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 12 (at your option) any later version.
11 13
12 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 17 GNU General Public License for more details.
16 18
17 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 20 along with gvpe; if not, write to the Free Software
19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20*/ 22*/
21 23
22// unfortunately, there is be no way to set MAC addresses under windows, 24// unfortunately, there is be no way to set MAC addresses under windows,
23// and the default cipedrvr uses a different MAC address than we do, 25// and the default cipedrvr uses a different MAC address than we do,
28// a newer driver is available as part of the openvpn package: 30// a newer driver is available as part of the openvpn package:
29// http://openvpn.sf.net/ 31// http://openvpn.sf.net/
30 32
31#include "config.h" 33#include "config.h"
32 34
33#include <stdio.h> 35#include <cstdio>
36#include <cstring>
37#include <cstdlib>
34#include <errno.h> 38#include <errno.h>
35#include <sys/types.h> 39#include <sys/types.h>
36#include <sys/stat.h> 40#include <sys/stat.h>
37#include <fcntl.h> 41#include <fcntl.h>
38#include <unistd.h> 42#include <unistd.h>
39#include <cstring>
40 43
41#include "conf.h" 44#include "conf.h"
42#include "util.h" 45#include "util.h"
43 46
44#include <io.h> 47#include <io.h>
100 if (GetLastError () == ERROR_IO_PENDING) 103 if (GetLastError () == ERROR_IO_PENDING)
101 GetOverlappedResult (device_handle, &overlapped, &dlen, TRUE); 104 GetOverlappedResult (device_handle, &overlapped, &dlen, TRUE);
102 else 105 else
103 { 106 {
104 slog (L_ERR, "WIN32 TAP: ReadFile returned error: %s", wstrerror (GetLastError ())); 107 slog (L_ERR, "WIN32 TAP: ReadFile returned error: %s", wstrerror (GetLastError ()));
105 exit (1); 108 exit (EXIT_FAILURE);
106 } 109 }
107 } 110 }
108 111
109 if (dlen > 0) 112 if (dlen > 0)
110 { 113 {
140 143
141 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_CONTROL_NET, 0, KEY_READ, &key)) 144 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_CONTROL_NET, 0, KEY_READ, &key))
142 { 145 {
143 slog (L_ERR, _("WIN32 TAP: unable to read registry: %s"), 146 slog (L_ERR, _("WIN32 TAP: unable to read registry: %s"),
144 wstrerror (GetLastError ())); 147 wstrerror (GetLastError ()));
145 exit (1); 148 exit (EXIT_FAILURE);
146 } 149 }
147 150
148 for (i = 0;; i++) 151 for (i = 0;; i++)
149 { 152 {
150 len = sizeof (adapterid); 153 len = sizeof (adapterid);
191 RegCloseKey (key); 194 RegCloseKey (key);
192 195
193 if (!found) 196 if (!found)
194 { 197 {
195 slog (L_ERR, _("WIN32 TAP: no windows tap device found!")); 198 slog (L_ERR, _("WIN32 TAP: no windows tap device found!"));
196 exit (1); 199 exit (EXIT_FAILURE);
197 } 200 }
198 201
199 /* Try to open the corresponding tap device */ 202 /* Try to open the corresponding tap device */
200 203
201 if (device_handle == INVALID_HANDLE_VALUE) 204 if (device_handle == INVALID_HANDLE_VALUE)
209 212
210 if (device_handle == INVALID_HANDLE_VALUE) 213 if (device_handle == INVALID_HANDLE_VALUE)
211 { 214 {
212 slog (L_ERR, _("WIN32 TAP: %s is not a usable windows tap device %s: %s"), 215 slog (L_ERR, _("WIN32 TAP: %s is not a usable windows tap device %s: %s"),
213 adaptername, tapname, wstrerror (GetLastError ())); 216 adaptername, tapname, wstrerror (GetLastError ()));
214 exit (1); 217 exit (EXIT_FAILURE);
215 } 218 }
216 219
217 strcpy (ifrname, (char *)tapname); 220 strcpy (ifrname, (char *)tapname);
218 221
219 /* Get MAC address from tap device */ 222 /* Get MAC address from tap device */
223 &len, 0)) 226 &len, 0))
224 { 227 {
225 slog (L_ERR, 228 slog (L_ERR,
226 _("WIN32 TAP: could not get MAC address from windows tap device %s: %s"), 229 _("WIN32 TAP: could not get MAC address from windows tap device %s: %s"),
227 adaptername, wstrerror (GetLastError ())); 230 adaptername, wstrerror (GetLastError ()));
228 exit (1); 231 exit (EXIT_FAILURE);
229 } 232 }
230 233
231 pipe (iopipe); 234 pipe (iopipe);
232 fd = iopipe[0]; 235 fd = iopipe[0];
233 pipe_handle = (HANDLE) get_osfhandle (iopipe[1]); 236 pipe_handle = (HANDLE) get_osfhandle (iopipe[1]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines