diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-03-21 17:16:54 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-03-21 17:16:54 +0000 |
commit | b1765acecfce6f858cdda9eaba103b14198203b1 (patch) | |
tree | 3bfae6a10ad0752ebf8f567b6d68b33bd6e138fe /src/exit | |
parent | 3f3bc61d2002a4a69e98c60b8218cf05c6248859 (diff) | |
download | gnunet-b1765acecfce6f858cdda9eaba103b14198203b1.tar.gz gnunet-b1765acecfce6f858cdda9eaba103b14198203b1.zip |
* adde ipv6 forwarding functionality for helper-exit-windows
Diffstat (limited to 'src/exit')
-rw-r--r-- | src/exit/gnunet-helper-exit-windows.c | 115 |
1 files changed, 71 insertions, 44 deletions
diff --git a/src/exit/gnunet-helper-exit-windows.c b/src/exit/gnunet-helper-exit-windows.c index aade15790..01ca2f83d 100644 --- a/src/exit/gnunet-helper-exit-windows.c +++ b/src/exit/gnunet-helper-exit-windows.c | |||
@@ -1446,8 +1446,6 @@ teardown_final: | |||
1446 | 1446 | ||
1447 | CloseHandle (tap_handle); | 1447 | CloseHandle (tap_handle); |
1448 | } | 1448 | } |
1449 | |||
1450 | |||
1451 | /** | 1449 | /** |
1452 | * Open VPN tunnel interface. | 1450 | * Open VPN tunnel interface. |
1453 | * | 1451 | * |
@@ -1470,7 +1468,7 @@ main (int argc, char **argv) | |||
1470 | BOOL have_ip4 = FALSE; | 1468 | BOOL have_ip4 = FALSE; |
1471 | BOOL have_ip6 = FALSE; | 1469 | BOOL have_ip6 = FALSE; |
1472 | BOOL have_nat44 = FALSE; | 1470 | BOOL have_nat44 = FALSE; |
1473 | 1471 | ||
1474 | if (6 != argc) | 1472 | if (6 != argc) |
1475 | { | 1473 | { |
1476 | fprintf (stderr, "FATAL: must supply 5 arguments\nUsage:\ngnunet-helper-vpn <if name prefix> <address6 or \"-\"> <netbits6> <address4 or \"-\"> <netmask4>\n", argv[0]); | 1474 | fprintf (stderr, "FATAL: must supply 5 arguments\nUsage:\ngnunet-helper-vpn <if name prefix> <address6 or \"-\"> <netbits6> <address4 or \"-\"> <netmask4>\n", argv[0]); |
@@ -1504,6 +1502,7 @@ main (int argc, char **argv) | |||
1504 | fprintf (stderr, "DEBUG: Setting IPs, if needed\n"); | 1502 | fprintf (stderr, "DEBUG: Setting IPs, if needed\n"); |
1505 | if (0 != strcmp (argv[3], "-")) | 1503 | if (0 != strcmp (argv[3], "-")) |
1506 | { | 1504 | { |
1505 | char command[LINE_LEN]; | ||
1507 | const char *address = argv[3]; | 1506 | const char *address = argv[3]; |
1508 | long prefix_len = atol (argv[4]); | 1507 | long prefix_len = atol (argv[4]); |
1509 | 1508 | ||
@@ -1514,11 +1513,36 @@ main (int argc, char **argv) | |||
1514 | goto cleanup; | 1513 | goto cleanup; |
1515 | } | 1514 | } |
1516 | 1515 | ||
1517 | fprintf (stderr, "DEBUG: Setting IP6 address: %s/%d\n",address,prefix_len); | 1516 | fprintf (stderr, "DEBUG: Setting IP6 address: %s/%d\n", address, prefix_len); |
1518 | if (0 != (global_ret = set_address6 (address, prefix_len))) | 1517 | if (0 != (global_ret = set_address6 (address, prefix_len))) |
1519 | goto cleanup; | 1518 | goto cleanup; |
1520 | 1519 | ||
1521 | have_ip6 = TRUE; | 1520 | have_ip6 = TRUE; |
1521 | |||
1522 | /* install our the windows NAT module*/ | ||
1523 | fprintf (stderr, "DEBUG: Setting IPv6 Forwarding for internal and external interface.\n"); | ||
1524 | /* outside interface (maybe that's already set) */ | ||
1525 | snprintf (command, LINE_LEN, | ||
1526 | "netsh interface ipv6 set interface interface=\"%s\" metric=1 forwarding=enabled store=active", | ||
1527 | argv[2]); | ||
1528 | local_ret = execute_shellcommand (command); | ||
1529 | if (0 != local_ret) | ||
1530 | { | ||
1531 | fprintf (stderr, "FATAL: Could not enable forwarding via netsh: %s\n", strerror (local_ret)); | ||
1532 | goto cleanup; | ||
1533 | } | ||
1534 | /* internal interface */ | ||
1535 | snprintf (command, LINE_LEN, | ||
1536 | "netsh interface ipv6 set interface interface=\"%s\" metric=1 forwarding=enabled advertise=enabled store=active", | ||
1537 | device_visible_name); | ||
1538 | local_ret = execute_shellcommand (command); | ||
1539 | if (0 != local_ret) | ||
1540 | { | ||
1541 | fprintf (stderr, "FATAL: Could not enable forwarding via netsh: %s\n", strerror (local_ret)); | ||
1542 | goto cleanup; | ||
1543 | } | ||
1544 | /* we can keep IPv6 forwarding around, as all interfaces have | ||
1545 | * their forwarding mode reset to false at bootup. */ | ||
1522 | } | 1546 | } |
1523 | 1547 | ||
1524 | if (0 != strcmp (argv[5], "-")) | 1548 | if (0 != strcmp (argv[5], "-")) |
@@ -1526,54 +1550,57 @@ main (int argc, char **argv) | |||
1526 | const char *address = argv[5]; | 1550 | const char *address = argv[5]; |
1527 | const char *mask = argv[6]; | 1551 | const char *mask = argv[6]; |
1528 | 1552 | ||
1529 | fprintf (stderr, "DEBUG: Setting IP4 address: %s/%s\n",address,mask); | 1553 | fprintf (stderr, "DEBUG: Setting IP4 address: %s/%s\n", address, mask); |
1530 | if (0 != (global_ret = set_address4 (address, mask))) | 1554 | if (0 != (global_ret = set_address4 (address, mask))) |
1531 | goto cleanup; | 1555 | goto cleanup; |
1532 | 1556 | ||
1533 | // setup NAPT, if possible | 1557 | // setup NAPT, if possible |
1534 | /* MS has REMOVED the routing/nat capabilities from Vista+, thus | 1558 | /* MS has REMOVED the routing/nat capabilities from Vista+, thus |
1535 | * we can not setup NAT like in XP or on the server. Actually the | 1559 | * we can not setup NAT like in XP or on the server. Actually the |
1536 | * the only feasible solution seems to be to use | 1560 | * the only feasible solution seems to be to use |
1537 | * Internet Connection Sharing, which introduces a horde of problems | 1561 | * Internet Connection Sharing, which introduces a horde of problems |
1538 | * such as sending out rogue-RAs on the external interface in an ipv6 | 1562 | * such as sending out rogue-RAs on the external interface in an ipv6 |
1539 | * network. | 1563 | * network. |
1540 | * Thus, below stuff ONLY works on | 1564 | * Thus, below stuff ONLY works on |
1541 | * WinXP SP3 | 1565 | * WinXP SP3 |
1542 | * Win Server 2003 SP1+ | 1566 | * Win Server 2003 SP1+ |
1543 | * Win Server 2008 | 1567 | * Win Server 2008 |
1544 | * ... | 1568 | * ... |
1545 | * else we need to use WFAS and do things ourselfs | 1569 | */ |
1546 | */ | 1570 | have_ip4 = TRUE; |
1547 | have_ip4 = TRUE; | 1571 | if (0 != strcmp (argv[2], "-")) |
1548 | if (0 != strcmp(argv[2], "-")) { | 1572 | { |
1549 | char command[LINE_LEN]; | 1573 | char command[LINE_LEN]; |
1550 | 1574 | ||
1551 | /* install our the windows NAT module*/ | 1575 | /* install our the windows NAT module*/ |
1552 | fprintf (stderr, "DEBUG: Adding NAPT/Masquerading between external IF %s and mine.\n",argv[2]); | 1576 | fprintf (stderr, "DEBUG: Adding NAPT/Masquerading between external IF %s and mine.\n", argv[2]); |
1553 | local_ret = execute_shellcommand("netsh routing ip nat install"); | 1577 | local_ret = execute_shellcommand ("netsh routing ip nat install"); |
1554 | if (0 != local_ret){ | 1578 | if (0 != local_ret) |
1555 | fprintf(stderr, "FATAL: Could not install NAPT support via Netsh: %s\n", strerror(local_ret)); | 1579 | { |
1556 | goto cleanup; | 1580 | fprintf (stderr, "FATAL: Could not install NAPT support via Netsh: %s\n", strerror (local_ret)); |
1581 | goto cleanup; | ||
1557 | } | 1582 | } |
1558 | /* external IF */ | 1583 | /* external IF */ |
1559 | snprintf(command, LINE_LEN, | 1584 | snprintf (command, LINE_LEN, |
1560 | "netsh routing ip nat add interface \"%s\" full", /*full = NAPT (addr+port)*/ | 1585 | "netsh routing ip nat add interface \"%s\" full", /*full = NAPT (addr+port)*/ |
1561 | argv[2]); | 1586 | argv[2]); |
1562 | local_ret = execute_shellcommand (command); | 1587 | local_ret = execute_shellcommand (command); |
1563 | if (0 != local_ret){ | 1588 | if (0 != local_ret) |
1564 | fprintf(stderr, "FATAL: IPv4-NAPT on external interface failed: %s\n", strerror(local_ret)); | 1589 | { |
1565 | goto cleanup; | 1590 | fprintf (stderr, "FATAL: IPv4-NAPT on external interface failed: %s\n", strerror (local_ret)); |
1591 | goto cleanup; | ||
1566 | } | 1592 | } |
1567 | /* private/internal/virtual IF */ | 1593 | /* private/internal/virtual IF */ |
1568 | snprintf(command, LINE_LEN, | 1594 | snprintf (command, LINE_LEN, |
1569 | "netsh routing ip nat add interface \"%s\" private", | 1595 | "netsh routing ip nat add interface \"%s\" private", |
1570 | device_visible_name); | 1596 | device_visible_name); |
1571 | local_ret = execute_shellcommand(command); | 1597 | local_ret = execute_shellcommand (command); |
1572 | if (0 != local_ret){ | 1598 | if (0 != local_ret) |
1573 | fprintf(stderr, "FATAL: IPv4-NAPT on internal interface failed: %s\n", strerror(local_ret)); | 1599 | { |
1574 | goto cleanup; | 1600 | fprintf (stderr, "FATAL: IPv4-NAPT on internal interface failed: %s\n", strerror (local_ret)); |
1575 | 1601 | goto cleanup; | |
1576 | have_nat44 = TRUE; | 1602 | |
1603 | have_nat44 = TRUE; | ||
1577 | } | 1604 | } |
1578 | } | 1605 | } |
1579 | } | 1606 | } |