Replace mesh with new version
[oweals/gnunet.git] / src / vpn / gnunet-helper-vpn-windows.c
index 5166a055c78437bf02b5bd5d8de55f62157cb6fb..0d31ee3996cbda41809b902f24de1dedafb22b06 100644 (file)
  */
 
 #include <stdio.h>
+#include <Winsock2.h>
 #include <windows.h>
 #include <setupapi.h>
+#ifndef __MINGW64_VERSION_MAJOR
 #include <ddk/cfgmgr32.h>
 #include <ddk/newdev.h>
-#include <Winsock2.h>
+#else
+#include <cfgmgr32.h>
+#include <newdev.h>
+#endif
 #include <time.h>
 #include "platform.h"
 #include "tap-windows.h"
@@ -63,9 +68,9 @@
 #endif
 
 /**
- * Will this binary be run in dryrun-mode? 
+ * Will this binary be run in permissions testing mode? 
  */
-static BOOL dryrun = FALSE;
+static boolean privilege_testing = FALSE;
 
 /**
  * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -1356,8 +1361,8 @@ run (HANDLE tap_handle)
    * DHCP and such are all features we will never use in gnunet afaik.
    * But for openvpn those are essential.
    */
-  if (! tun_up (tap_handle))
-    return;
+  if ((privilege_testing) || (! tun_up (tap_handle)))
+    goto teardown_final;
 
   /* Initialize our overlapped IO structures*/
   if (! (initialize_io_facility (&tap_read, IOSTATE_READY, FALSE)
@@ -1412,9 +1417,6 @@ run (HANDLE tap_handle)
     }
 #endif
 
-  if (dryrun)
-    goto teardown;
-  
   fprintf (stderr, "DEBUG: mainloop has begun\n");
 
   while (std_out.path_open || tap_write.path_open)
@@ -1441,9 +1443,7 @@ teardown:
   CancelIo (tap_handle);
   CancelIo (std_in.handle);
   CancelIo (std_out.handle);
-
 teardown_final:
-      
   CloseHandle (tap_handle);
 }
 
@@ -1470,8 +1470,8 @@ main (int argc, char **argv)
   BOOL have_ip6 = FALSE;
   
   if (argc > 1 && 0 != strcmp (argv[1], "-d")){
-      dryrun = TRUE;
-      fprintf (stderr, "DEBUG: Running binary in dryrun mode.", argv[0]);
+      privilege_testing = TRUE;
+      fprintf (stderr, "DEBUG: Running binary in privilege testing mode.", argv[0]);
       argv++;
       argc--;
     }