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.8 by pcg, Thu Jan 29 18:55:10 2004 UTC

28// a newer driver is available as part of the openvpn package: 28// a newer driver is available as part of the openvpn package:
29// http://openvpn.sf.net/ 29// http://openvpn.sf.net/
30 30
31#include "config.h" 31#include "config.h"
32 32
33#include <stdio.h> 33#include <cstdio>
34#include <cstring>
35#include <cstdlib>
34#include <errno.h> 36#include <errno.h>
35#include <sys/types.h> 37#include <sys/types.h>
36#include <sys/stat.h> 38#include <sys/stat.h>
37#include <fcntl.h> 39#include <fcntl.h>
38#include <unistd.h> 40#include <unistd.h>
39#include <cstring>
40 41
41#include "conf.h" 42#include "conf.h"
42#include "util.h" 43#include "util.h"
43 44
44#include <io.h> 45#include <io.h>
100 if (GetLastError () == ERROR_IO_PENDING) 101 if (GetLastError () == ERROR_IO_PENDING)
101 GetOverlappedResult (device_handle, &overlapped, &dlen, TRUE); 102 GetOverlappedResult (device_handle, &overlapped, &dlen, TRUE);
102 else 103 else
103 { 104 {
104 slog (L_ERR, "WIN32 TAP: ReadFile returned error: %s", wstrerror (GetLastError ())); 105 slog (L_ERR, "WIN32 TAP: ReadFile returned error: %s", wstrerror (GetLastError ()));
105 exit (1); 106 exit (EXIT_FAILURE);
106 } 107 }
107 } 108 }
108 109
109 if (dlen > 0) 110 if (dlen > 0)
110 { 111 {
140 141
141 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_CONTROL_NET, 0, KEY_READ, &key)) 142 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_CONTROL_NET, 0, KEY_READ, &key))
142 { 143 {
143 slog (L_ERR, _("WIN32 TAP: unable to read registry: %s"), 144 slog (L_ERR, _("WIN32 TAP: unable to read registry: %s"),
144 wstrerror (GetLastError ())); 145 wstrerror (GetLastError ()));
145 exit (1); 146 exit (EXIT_FAILURE);
146 } 147 }
147 148
148 for (i = 0;; i++) 149 for (i = 0;; i++)
149 { 150 {
150 len = sizeof (adapterid); 151 len = sizeof (adapterid);
191 RegCloseKey (key); 192 RegCloseKey (key);
192 193
193 if (!found) 194 if (!found)
194 { 195 {
195 slog (L_ERR, _("WIN32 TAP: no windows tap device found!")); 196 slog (L_ERR, _("WIN32 TAP: no windows tap device found!"));
196 exit (1); 197 exit (EXIT_FAILURE);
197 } 198 }
198 199
199 /* Try to open the corresponding tap device */ 200 /* Try to open the corresponding tap device */
200 201
201 if (device_handle == INVALID_HANDLE_VALUE) 202 if (device_handle == INVALID_HANDLE_VALUE)
209 210
210 if (device_handle == INVALID_HANDLE_VALUE) 211 if (device_handle == INVALID_HANDLE_VALUE)
211 { 212 {
212 slog (L_ERR, _("WIN32 TAP: %s is not a usable windows tap device %s: %s"), 213 slog (L_ERR, _("WIN32 TAP: %s is not a usable windows tap device %s: %s"),
213 adaptername, tapname, wstrerror (GetLastError ())); 214 adaptername, tapname, wstrerror (GetLastError ()));
214 exit (1); 215 exit (EXIT_FAILURE);
215 } 216 }
216 217
217 strcpy (ifrname, (char *)tapname); 218 strcpy (ifrname, (char *)tapname);
218 219
219 /* Get MAC address from tap device */ 220 /* Get MAC address from tap device */
223 &len, 0)) 224 &len, 0))
224 { 225 {
225 slog (L_ERR, 226 slog (L_ERR,
226 _("WIN32 TAP: could not get MAC address from windows tap device %s: %s"), 227 _("WIN32 TAP: could not get MAC address from windows tap device %s: %s"),
227 adaptername, wstrerror (GetLastError ())); 228 adaptername, wstrerror (GetLastError ()));
228 exit (1); 229 exit (EXIT_FAILURE);
229 } 230 }
230 231
231 pipe (iopipe); 232 pipe (iopipe);
232 fd = iopipe[0]; 233 fd = iopipe[0];
233 pipe_handle = (HANDLE) get_osfhandle (iopipe[1]); 234 pipe_handle = (HANDLE) get_osfhandle (iopipe[1]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines