aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2012-12-10 20:42:31 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2012-12-10 20:42:31 +0000
commitccc397b474f93319e1778ecab31cd3ef396b3cf6 (patch)
treeb57f439fc1bc88c49091a4e803375c3ad82a5bfa /src/vpn
parent3ff5c7d922a0b728fb1998e7ba1e3924af722870 (diff)
downloadgnunet-ccc397b474f93319e1778ecab31cd3ef396b3cf6.tar.gz
gnunet-ccc397b474f93319e1778ecab31cd3ef396b3cf6.zip
added functionality to fetch the virtual interface's FriendlyName from
the registry. This information is needed for netsh later on.
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c
index cee450f45..8d9d3e08d 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -75,7 +75,12 @@
75 * hardware ID for our device. 75 * hardware ID for our device.
76 */ 76 */
77static TCHAR secondary_hwid[LINE_LEN / 2]; 77static TCHAR secondary_hwid[LINE_LEN / 2];
78 78
79/*
80 * Device's Friendly Name, used to identify a network device in netsh.
81 * eg: "TAP-Windows Adapter V9 #4"
82 */
83static TCHAR device_friendly_name[LINE_LEN / 2];
79/** 84/**
80 * This is our own local instance of a virtual network interface 85 * This is our own local instance of a virtual network interface
81 * It is (somewhat) equivalent to using tun/tap in unixoid systems 86 * It is (somewhat) equivalent to using tun/tap in unixoid systems
@@ -191,7 +196,6 @@ set_address4 (const char *dev, const char *address, const char *mask)
191 } 196 }
192} 197}
193 198
194
195/** 199/**
196 * Setup a new virtual interface to use for tunneling. 200 * Setup a new virtual interface to use for tunneling.
197 * 201 *
@@ -256,7 +260,7 @@ setup_interface ()
256 return FALSE; 260 return FALSE;
257 261
258 DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA); 262 DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA);
259 if (!SetupDiCreateDeviceInfo (DeviceInfo, 263 if (! SetupDiCreateDeviceInfo (DeviceInfo,
260 class, 264 class,
261 &guid, 265 &guid,
262 NULL, 266 NULL,
@@ -274,12 +278,24 @@ setup_interface ()
274 return FALSE; 278 return FALSE;
275 279
276 /* Install our new class(=device) into the system */ 280 /* Install our new class(=device) into the system */
277 if (SetupDiCallClassInstaller (DIF_REGISTERDEVICE, 281 if (! SetupDiCallClassInstaller (DIF_REGISTERDEVICE,
278 DeviceInfo, 282 DeviceInfo,
279 &DeviceNode)) 283 &DeviceNode))
280 return TRUE; 284 return FALSE;
281 285
282 return FALSE; 286 /* Now, pull the device device's FriendlyName off the registry. */
287 if ( !SetupDiGetDeviceRegistryProperty(DeviceInfo,
288 (PSP_DEVINFO_DATA) & DeviceNode,
289 SPDRP_FRIENDLYNAME,
290 NULL,
291 (LPBYTE)device_friendly_name,
292 LINE_LEN / 2,
293 NULL) || strlen(device_friendly_name) < 1){
294 return FALSE;
295 }
296 device_friendly_name[LINE_LEN / 2 - 1] = _T("\0");
297
298 return TRUE;
283} 299}
284 300
285 301
@@ -341,13 +357,12 @@ init_tun (TCHAR *hwid)
341 return -1; 357 return -1;
342 } 358 }
343 359
344 if (FALSE == setup_interface()){ 360 if (! setup_interface()){
345 errno = ENODEV; 361 errno = ENODEV;
346 return -1; 362 return -1;
347 } 363 }
348 364
349 365
350
351 return fd; 366 return fd;
352} 367}
353 368
@@ -383,7 +398,7 @@ run (int fd_tun)
383 * 398 *
384 * @param argc must be 6 399 * @param argc must be 6
385 * @param argv 0: binary name (gnunet-helper-vpn) 400 * @param argv 0: binary name (gnunet-helper-vpn)
386 * 1: tunnel interface name (gnunet-vpn) (unused, can be used as additional HWID in the future) 401 * 1: tunnel interface name (gnunet-vpn)
387 * 2: IPv6 address (::1), "-" to disable 402 * 2: IPv6 address (::1), "-" to disable
388 * 3: IPv6 netmask length in bits (64), ignored if #2 is "-" 403 * 3: IPv6 netmask length in bits (64), ignored if #2 is "-"
389 * 4: IPv4 address (1.2.3.4), "-" to disable 404 * 4: IPv4 address (1.2.3.4), "-" to disable
@@ -473,6 +488,7 @@ main (int argc, char **argv)
473 //run (fd_tun); 488 //run (fd_tun);
474 global_ret = 0; 489 global_ret = 0;
475cleanup: 490cleanup:
476 //close (fd_tun); 491 remove_interface();
492
477 return global_ret; 493 return global_ret;
478} 494}