aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-31 14:15:10 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-31 14:15:10 +0000
commit61a895198882629e1bf1632a640eb876202067a0 (patch)
treeaaf8b8ce749e3e51da43c9da2c96ce1bc33bcd89 /src/exit
parent328b1ac9a1b40d6963e454183af2bf2e5019d286 (diff)
downloadgnunet-61a895198882629e1bf1632a640eb876202067a0.tar.gz
gnunet-61a895198882629e1bf1632a640eb876202067a0.zip
re-enumated argv to conform with helper-exit syntax
added stub for ipv4 nat. Note that there is a problem ahead!
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/gnunet-helper-exit-windows.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/src/exit/gnunet-helper-exit-windows.c b/src/exit/gnunet-helper-exit-windows.c
index 0da3c9b69..c4519fb1c 100644
--- a/src/exit/gnunet-helper-exit-windows.c
+++ b/src/exit/gnunet-helper-exit-windows.c
@@ -17,7 +17,18 @@
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 20/**
21 * @file exit/gnunet-helper-exit-windows.c
22 * @brief the helper for the EXIT service in win32 builds.
23 * Opens a virtual network-interface, sends data received on the if to stdout,
24 * sends data received on stdin to the interface
25 * @author Christian M. Fuchs
26 *
27 * The following list of people have reviewed this code and considered
28 * it safe since the last modification (if you reviewed it, please
29 * have your name added to the list):
30 *
31 */
21#include <stdio.h> 32#include <stdio.h>
22#include <windows.h> 33#include <windows.h>
23#include <setupapi.h> 34#include <setupapi.h>
@@ -1441,12 +1452,13 @@ teardown_final:
1441 * Open VPN tunnel interface. 1452 * Open VPN tunnel interface.
1442 * 1453 *
1443 * @param argc must be 6 1454 * @param argc must be 6
1444 * @param argv 0: binary name (gnunet-helper-vpn) 1455 * @param argv 0: binary name ("gnunet-helper-exit")
1445 * 1: tunnel interface prefix (gnunet-vpn) 1456 * 1: tunnel interface name ("gnunet-exit")
1446 * 2: IPv6 address (::1), "-" to disable 1457 * 2: IPv4 "physical" interface name ("eth0"), or "%" to not do IPv4 NAT
1447 * 3: IPv6 netmask length in bits (64), ignored if #2 is "-" 1458 * 3: IPv6 address ("::1"), or "-" to skip IPv6
1448 * 4: IPv4 address (1.2.3.4), "-" to disable 1459 * 4: IPv6 netmask length in bits ("64") [ignored if #4 is "-"]
1449 * 5: IPv4 netmask (255.255.0.0), ignored if #4 is "-" 1460 * 5: IPv4 address ("1.2.3.4"), or "-" to skip IPv4
1461 * 6: IPv4 netmask ("255.255.0.0") [ignored if #4 is "-"]
1450 */ 1462 */
1451int 1463int
1452main (int argc, char **argv) 1464main (int argc, char **argv)
@@ -1479,19 +1491,19 @@ main (int argc, char **argv)
1479 { 1491 {
1480 fprintf (stderr, "FATAL: could not initialize virtual-interface %s with IPv6 %s/%s and IPv4 %s/%s\n", 1492 fprintf (stderr, "FATAL: could not initialize virtual-interface %s with IPv6 %s/%s and IPv4 %s/%s\n",
1481 hwid, 1493 hwid,
1482 argv[2],
1483 argv[3], 1494 argv[3],
1484 argv[4], 1495 argv[4],
1485 argv[5]); 1496 argv[5],
1497 argv[6]);
1486 global_ret = -1; 1498 global_ret = -1;
1487 goto cleanup; 1499 goto cleanup;
1488 } 1500 }
1489 1501
1490 fprintf (stderr, "DEBUG: Setting IPs, if needed\n"); 1502 fprintf (stderr, "DEBUG: Setting IPs, if needed\n");
1491 if (0 != strcmp (argv[2], "-")) 1503 if (0 != strcmp (argv[3], "-"))
1492 { 1504 {
1493 const char *address = argv[2]; 1505 const char *address = argv[3];
1494 long prefix_len = atol (argv[3]); 1506 long prefix_len = atol (argv[4]);
1495 1507
1496 if ((prefix_len < 1) || (prefix_len > 127)) 1508 if ((prefix_len < 1) || (prefix_len > 127))
1497 { 1509 {
@@ -1507,15 +1519,27 @@ main (int argc, char **argv)
1507 have_ip6 = TRUE; 1519 have_ip6 = TRUE;
1508 } 1520 }
1509 1521
1510 if (0 != strcmp (argv[4], "-")) 1522 if (0 != strcmp (argv[5], "-"))
1511 { 1523 {
1512 const char *address = argv[4]; 1524 const char *address = argv[5];
1513 const char *mask = argv[5]; 1525 const char *mask = argv[6];
1514 1526
1515 fprintf (stderr, "DEBUG: Setting IP4 address: %s/%s\n",address,mask); 1527 fprintf (stderr, "DEBUG: Setting IP4 address: %s/%s\n",address,mask);
1516 if (0 != (global_ret = set_address4 (address, mask))) 1528 if (0 != (global_ret = set_address4 (address, mask)))
1517 goto cleanup; 1529 goto cleanup;
1518 1530
1531 // setup NAT, if possible
1532 if (0 != strcmp (argv[2], "%"))
1533 {
1534 /* TODO: " Windows Firewall with Advanced Security" (lol)
1535 *
1536 * MS has REMOVED the routing/nat capabilities since Vista, thus
1537 * we can not setup NAT like in XP. Our best bet is
1538 * to determine if we are running on XP, if we do, use netsh routing
1539 * else we need to use WFAS and do things ourselfs
1540 */
1541 }
1542
1519 have_ip4 = TRUE; 1543 have_ip4 = TRUE;
1520 } 1544 }
1521 1545
@@ -1525,13 +1549,13 @@ cleanup:
1525 1549
1526 if (have_ip4) 1550 if (have_ip4)
1527 { 1551 {
1528 const char *address = argv[4]; 1552 const char *address = argv[5];
1529 fprintf (stderr, "DEBUG: Removing IP4 address\n"); 1553 fprintf (stderr, "DEBUG: Removing IP4 address\n");
1530 remove_address4 (address); 1554 remove_address4 (address);
1531 } 1555 }
1532 if (have_ip6) 1556 if (have_ip6)
1533 { 1557 {
1534 const char *address = argv[2]; 1558 const char *address = argv[3];
1535 fprintf (stderr, "DEBUG: Removing IP6 address\n"); 1559 fprintf (stderr, "DEBUG: Removing IP6 address\n");
1536 remove_address6 (address); 1560 remove_address6 (address);
1537 } 1561 }