diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-15 18:50:31 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-15 18:50:31 +0000 |
commit | 9555e79edd6a50c572dd3c8cd227937010c4830e (patch) | |
tree | d07cee7c4e23049056c93e6b2cb433ff7a199e88 /src/vpn | |
parent | 687c0c114b4bc5238334f0ab632d8cbb81b4db94 (diff) | |
download | gnunet-9555e79edd6a50c572dd3c8cd227937010c4830e.tar.gz gnunet-9555e79edd6a50c572dd3c8cd227937010c4830e.zip |
a bit of bugfixing
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/gnunet-helper-vpn-windows.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c index 50137322d..4cc2794c2 100644 --- a/src/vpn/gnunet-helper-vpn-windows.c +++ b/src/vpn/gnunet-helper-vpn-windows.c | |||
@@ -35,9 +35,10 @@ | |||
35 | #include <windows.h> | 35 | #include <windows.h> |
36 | #include <setupapi.h> | 36 | #include <setupapi.h> |
37 | #include <ddk/cfgmgr32.h> | 37 | #include <ddk/cfgmgr32.h> |
38 | #include <Winsock2.h> | ||
38 | #include "platform.h" | 39 | #include "platform.h" |
39 | #include "tap-windows.h" | 40 | #include "tap-windows.h" |
40 | #include <Winsock2.h> | 41 | |
41 | 42 | ||
42 | /** | 43 | /** |
43 | * Need 'struct GNUNET_MessageHeader'. | 44 | * Need 'struct GNUNET_MessageHeader'. |
@@ -64,7 +65,7 @@ | |||
64 | * Name or Path+Name of our driver in Unicode. | 65 | * Name or Path+Name of our driver in Unicode. |
65 | * The .sys and .cat files HAVE to be in the same location as this file! | 66 | * The .sys and .cat files HAVE to be in the same location as this file! |
66 | */ | 67 | */ |
67 | #define INF_FILE "tapw32.inf" | 68 | #define INF_FILE "OemWin2k.inf" |
68 | 69 | ||
69 | /** | 70 | /** |
70 | * Hardware ID used in the inf-file. | 71 | * Hardware ID used in the inf-file. |
@@ -346,6 +347,7 @@ setup_interface () | |||
346 | * these details over time. | 347 | * these details over time. |
347 | */ | 348 | */ |
348 | char inf_file_path[MAX_PATH]; | 349 | char inf_file_path[MAX_PATH]; |
350 | char * temp_inf_filename; | ||
349 | char hwidlist[LINE_LEN + 4]; | 351 | char hwidlist[LINE_LEN + 4]; |
350 | char class_name[128]; | 352 | char class_name[128]; |
351 | GUID class_guid; | 353 | GUID class_guid; |
@@ -367,7 +369,7 @@ setup_interface () | |||
367 | */ | 369 | */ |
368 | str_lenth = strlen (hwidlist) + 1; | 370 | str_lenth = strlen (hwidlist) + 1; |
369 | strncpy (&hwidlist[str_lenth], secondary_hwid, LINE_LEN - str_lenth); | 371 | strncpy (&hwidlist[str_lenth], secondary_hwid, LINE_LEN - str_lenth); |
370 | 372 | ||
371 | /** | 373 | /** |
372 | * Locate the inf-file, we need to store it somewhere where the system can | 374 | * Locate the inf-file, we need to store it somewhere where the system can |
373 | * find it. A good choice would be CWD/PDW or %WINDIR$\system32\ | 375 | * find it. A good choice would be CWD/PDW or %WINDIR$\system32\ |
@@ -375,8 +377,8 @@ setup_interface () | |||
375 | * TODO: How about win64 in the future? | 377 | * TODO: How about win64 in the future? |
376 | * We need to use a different driver for amd64/i386 ! | 378 | * We need to use a different driver for amd64/i386 ! |
377 | */ | 379 | */ |
378 | GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, NULL); | 380 | GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename); |
379 | 381 | ||
380 | /** | 382 | /** |
381 | * Bootstrap our device info using the drivers inf-file | 383 | * Bootstrap our device info using the drivers inf-file |
382 | */ | 384 | */ |
@@ -385,7 +387,7 @@ setup_interface () | |||
385 | class_name, sizeof (class_name) / sizeof (char), | 387 | class_name, sizeof (class_name) / sizeof (char), |
386 | NULL)) | 388 | NULL)) |
387 | return FALSE; | 389 | return FALSE; |
388 | 390 | ||
389 | /** | 391 | /** |
390 | * Collect all the other needed information... | 392 | * Collect all the other needed information... |
391 | * let the system fill our this form | 393 | * let the system fill our this form |
@@ -393,7 +395,7 @@ setup_interface () | |||
393 | DeviceInfo = SetupDiCreateDeviceInfoList (&class_guid, NULL); | 395 | DeviceInfo = SetupDiCreateDeviceInfoList (&class_guid, NULL); |
394 | if (DeviceInfo == INVALID_HANDLE_VALUE) | 396 | if (DeviceInfo == INVALID_HANDLE_VALUE) |
395 | return FALSE; | 397 | return FALSE; |
396 | 398 | ||
397 | DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA); | 399 | DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA); |
398 | if (!SetupDiCreateDeviceInfoA (DeviceInfo, | 400 | if (!SetupDiCreateDeviceInfoA (DeviceInfo, |
399 | class_name, | 401 | class_name, |
@@ -403,7 +405,7 @@ setup_interface () | |||
403 | DICD_GENERATE_ID, | 405 | DICD_GENERATE_ID, |
404 | &DeviceNode)) | 406 | &DeviceNode)) |
405 | return FALSE; | 407 | return FALSE; |
406 | 408 | ||
407 | /* Deploy all the information collected into the registry */ | 409 | /* Deploy all the information collected into the registry */ |
408 | if (!SetupDiSetDeviceRegistryPropertyA (DeviceInfo, | 410 | if (!SetupDiSetDeviceRegistryPropertyA (DeviceInfo, |
409 | &DeviceNode, | 411 | &DeviceNode, |
@@ -411,13 +413,13 @@ setup_interface () | |||
411 | (LPBYTE) hwidlist, | 413 | (LPBYTE) hwidlist, |
412 | (strlen (hwidlist) + 2) * sizeof (char))) | 414 | (strlen (hwidlist) + 2) * sizeof (char))) |
413 | return FALSE; | 415 | return FALSE; |
414 | 416 | ||
415 | /* Install our new class(=device) into the system */ | 417 | /* Install our new class(=device) into the system */ |
416 | if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE, | 418 | if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE, |
417 | DeviceInfo, | 419 | DeviceInfo, |
418 | &DeviceNode)) | 420 | &DeviceNode)) |
419 | return FALSE; | 421 | return FALSE; |
420 | 422 | ||
421 | return TRUE; | 423 | return TRUE; |
422 | } | 424 | } |
423 | 425 | ||
@@ -488,7 +490,7 @@ resolve_interface_name () | |||
488 | 0, //must be 0 | 490 | 0, //must be 0 |
489 | NULL)) //hMachine, we are local | 491 | NULL)) //hMachine, we are local |
490 | return FALSE; | 492 | return FALSE; |
491 | 493 | ||
492 | /* Now we can use this ID to locate the correct networks interface in registry */ | 494 | /* Now we can use this ID to locate the correct networks interface in registry */ |
493 | if (ERROR_SUCCESS != RegOpenKeyExA ( | 495 | if (ERROR_SUCCESS != RegOpenKeyExA ( |
494 | HKEY_LOCAL_MACHINE, | 496 | HKEY_LOCAL_MACHINE, |
@@ -510,7 +512,7 @@ resolve_interface_name () | |||
510 | char pnpinstanceid_value[256]; | 512 | char pnpinstanceid_value[256]; |
511 | char adaptername_name[] = "Name"; | 513 | char adaptername_name[] = "Name"; |
512 | DWORD data_type; | 514 | DWORD data_type; |
513 | 515 | ||
514 | len = sizeof (adapter_key_handle); | 516 | len = sizeof (adapter_key_handle); |
515 | /* optain a subkey of {4D36E972-E325-11CE-BFC1-08002BE10318} */ | 517 | /* optain a subkey of {4D36E972-E325-11CE-BFC1-08002BE10318} */ |
516 | status = RegEnumKeyExA ( | 518 | status = RegEnumKeyExA ( |
@@ -1112,7 +1114,7 @@ main (int argc, char **argv) | |||
1112 | snprintf (secondary_hwid, LINE_LEN / 2, "%s-%d", | 1114 | snprintf (secondary_hwid, LINE_LEN / 2, "%s-%d", |
1113 | hwid, | 1115 | hwid, |
1114 | _getpid ()); | 1116 | _getpid ()); |
1115 | 1117 | ||
1116 | if (INVALID_HANDLE_VALUE == (handle = init_tun ())) | 1118 | if (INVALID_HANDLE_VALUE == (handle = init_tun ())) |
1117 | { | 1119 | { |
1118 | fprintf (stderr, "Fatal: could not initialize virtual-interface %s with IPv6 %s/%s and IPv4 %s/%s\n", | 1120 | fprintf (stderr, "Fatal: could not initialize virtual-interface %s with IPv6 %s/%s and IPv4 %s/%s\n", |
@@ -1147,7 +1149,7 @@ main (int argc, char **argv) | |||
1147 | set_address4 (address, mask); | 1149 | set_address4 (address, mask); |
1148 | } | 1150 | } |
1149 | 1151 | ||
1150 | run (handle); | 1152 | //run (handle); |
1151 | global_ret = 0; | 1153 | global_ret = 0; |
1152 | cleanup: | 1154 | cleanup: |
1153 | remove_interface (); | 1155 | remove_interface (); |