aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-helper-vpn-windows.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpn/gnunet-helper-vpn-windows.c')
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c
index 04a8e7d58..5166a055c 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -17,7 +17,6 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 */ 19 */
20
21/** 20/**
22 * @file vpn/gnunet-helper-vpn-windows.c 21 * @file vpn/gnunet-helper-vpn-windows.c
23 * @brief the helper for the VPN service in win32 builds. 22 * @brief the helper for the VPN service in win32 builds.
@@ -63,6 +62,10 @@
63#define LOG_DEBUG(msg) do {} while (0) 62#define LOG_DEBUG(msg) do {} while (0)
64#endif 63#endif
65 64
65/**
66 * Will this binary be run in dryrun-mode?
67 */
68static BOOL dryrun = FALSE;
66 69
67/** 70/**
68 * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) 71 * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -1408,9 +1411,12 @@ run (HANDLE tap_handle)
1408 goto teardown; 1411 goto teardown;
1409 } 1412 }
1410#endif 1413#endif
1414
1415 if (dryrun)
1416 goto teardown;
1411 1417
1412 fprintf (stderr, "DEBUG: mainloop has begun\n"); 1418 fprintf (stderr, "DEBUG: mainloop has begun\n");
1413 1419
1414 while (std_out.path_open || tap_write.path_open) 1420 while (std_out.path_open || tap_write.path_open)
1415 { 1421 {
1416 /* perform READ from stdin if possible */ 1422 /* perform READ from stdin if possible */
@@ -1430,10 +1436,8 @@ run (HANDLE tap_handle)
1430 break; 1436 break;
1431 } 1437 }
1432 1438
1433teardown:
1434
1435 fprintf (stderr, "DEBUG: teardown initiated\n"); 1439 fprintf (stderr, "DEBUG: teardown initiated\n");
1436 1440teardown:
1437 CancelIo (tap_handle); 1441 CancelIo (tap_handle);
1438 CancelIo (std_in.handle); 1442 CancelIo (std_in.handle);
1439 CancelIo (std_out.handle); 1443 CancelIo (std_out.handle);
@@ -1449,11 +1453,12 @@ teardown_final:
1449 * 1453 *
1450 * @param argc must be 6 1454 * @param argc must be 6
1451 * @param argv 0: binary name (gnunet-helper-vpn) 1455 * @param argv 0: binary name (gnunet-helper-vpn)
1452 * 1: tunnel interface prefix (gnunet-vpn) 1456 * [1: dryrun/testrun (does not execute mainloop)]
1453 * 2: IPv6 address (::1), "-" to disable 1457 * 2: tunnel interface prefix (gnunet-vpn)
1454 * 3: IPv6 netmask length in bits (64), ignored if #2 is "-" 1458 * 3: IPv6 address (::1), "-" to disable
1455 * 4: IPv4 address (1.2.3.4), "-" to disable 1459 * 4: IPv6 netmask length in bits (64), ignored if #2 is "-"
1456 * 5: IPv4 netmask (255.255.0.0), ignored if #4 is "-" 1460 * 5: IPv4 address (1.2.3.4), "-" to disable
1461 * 6: IPv4 netmask (255.255.0.0), ignored if #4 is "-"
1457 */ 1462 */
1458int 1463int
1459main (int argc, char **argv) 1464main (int argc, char **argv)
@@ -1463,10 +1468,17 @@ main (int argc, char **argv)
1463 int global_ret = 0; 1468 int global_ret = 0;
1464 BOOL have_ip4 = FALSE; 1469 BOOL have_ip4 = FALSE;
1465 BOOL have_ip6 = FALSE; 1470 BOOL have_ip6 = FALSE;
1466 1471
1472 if (argc > 1 && 0 != strcmp (argv[1], "-d")){
1473 dryrun = TRUE;
1474 fprintf (stderr, "DEBUG: Running binary in dryrun mode.", argv[0]);
1475 argv++;
1476 argc--;
1477 }
1478
1467 if (6 != argc) 1479 if (6 != argc)
1468 { 1480 {
1469 fprintf (stderr, "FATAL: must supply 5 arguments\nUsage:\ngnunet-helper-vpn <if name prefix> <address6 or \"-\"> <netbits6> <address4 or \"-\"> <netmask4>\n", argv[0]); 1481 fprintf (stderr, "FATAL: must supply 5 arguments\nUsage:\ngnunet-helper-vpn [-d] <if name prefix> <address6 or \"-\"> <netbits6> <address4 or \"-\"> <netmask4>\n", argv[0]);
1470 return 1; 1482 return 1;
1471 } 1483 }
1472 1484
@@ -1527,7 +1539,6 @@ main (int argc, char **argv)
1527 } 1539 }
1528 1540
1529 run (handle); 1541 run (handle);
1530 global_ret = 0;
1531cleanup: 1542cleanup:
1532 1543
1533 if (have_ip4) 1544 if (have_ip4)