-indentation
[oweals/gnunet.git] / src / nat / gnunet-helper-nat-server-windows.c
index d970ffd70c873133eddcc001f8af741d9460ea01..18040428f7383bf758c0bde94861222ea853515d 100644 (file)
@@ -187,6 +187,11 @@ struct udp_header
   uint16_t crc;
 };
 
+/**
+ * Will this binary be run in permissions testing mode?
+ */
+static boolean privilege_testing = FALSE;
+
 /**
  * Socket we use to receive "fake" ICMP replies.
  */
@@ -526,9 +531,18 @@ main (int argc, char *const *argv)
   fd_set rs;
   struct timeval tv;
   WSADATA wsaData;
-  unsigned int alt;
+  unsigned int alt = 0;
+
+  if ( (argc > 1) && (0 != strcmp (argv[1], "-d")))
+  {
+    privilege_testing = TRUE;
+    fprintf (stderr,
+            "%s",
+            "DEBUG: Running binary in privilege testing mode.");
+    argv++;
+    argc--;
+  }
 
-  alt = 0;
   if (2 != argc)
   {
     fprintf (stderr,
@@ -566,7 +580,8 @@ main (int argc, char *const *argv)
     closesocket (rawsock);
     return 3;
   }
-  while (1)
+
+  while ( ! privilege_testing)
   {
     FD_ZERO (&rs);
     FD_SET (icmpsock, &rs);
@@ -591,6 +606,8 @@ main (int argc, char *const *argv)
   closesocket (rawsock);
   closesocket (udpsock);
   WSACleanup ();
+  if (privilege_testing)
+    return 0;
   return 4;
 }