diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-01 11:49:41 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-01 11:49:41 +0000 |
commit | ed8bae1885d78ce9d91bf742e0a8080a7e922b76 (patch) | |
tree | 0a81b21b0f587794145070cc7a9222832877c6ad /src/vpn | |
parent | d4c657e337060285f560b1a9287dd6a51551d35e (diff) | |
download | gnunet-ed8bae1885d78ce9d91bf742e0a8080a7e922b76.tar.gz gnunet-ed8bae1885d78ce9d91bf742e0a8080a7e922b76.zip |
* re-added mainloop for run
* started work on our select-equivalent for windows.
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/gnunet-helper-vpn-windows.c | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c index 2df5377c6..2214f0695 100644 --- a/src/vpn/gnunet-helper-vpn-windows.c +++ b/src/vpn/gnunet-helper-vpn-windows.c | |||
@@ -90,7 +90,7 @@ | |||
90 | #define TAP_WIN_MIN_MINOR 9 | 90 | #define TAP_WIN_MIN_MINOR 9 |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Time to wait for our virtual device to go up after telling it to do so. | 93 | * Time in seconds to wait for our virtual device to go up after telling it to do so. |
94 | * | 94 | * |
95 | * openvpn doesn't specify a value, 4 seems sane for testing, even for openwrt | 95 | * openvpn doesn't specify a value, 4 seems sane for testing, even for openwrt |
96 | * (in fact, 4 was chosen by a fair dice roll...) | 96 | * (in fact, 4 was chosen by a fair dice roll...) |
@@ -648,6 +648,8 @@ init_tun () | |||
648 | CloseHandle (handle); | 648 | CloseHandle (handle); |
649 | return INVALID_HANDLE_VALUE; | 649 | return INVALID_HANDLE_VALUE; |
650 | } | 650 | } |
651 | |||
652 | /* TODO (opt?): get MTU-Size */ | ||
651 | 653 | ||
652 | return handle; | 654 | return handle; |
653 | } | 655 | } |
@@ -698,23 +700,77 @@ run (HANDLE handle) | |||
698 | //openvpn | 700 | //openvpn |
699 | // Set Device to Subnet-Mode? | 701 | // Set Device to Subnet-Mode? |
700 | // do we really need tun.c:2925 ? | 702 | // do we really need tun.c:2925 ? |
701 | // Why do we also assign IPv4's there??? Foobar?? | 703 | // Why does openvpn assign IPv4's there??? Foobar?? |
702 | 704 | ||
703 | /* tun up: */ | 705 | /* tun up: */ |
706 | /* we do this HERE and not beforehand (in init_tun()), in contrast to openvpn | ||
707 | * to remove the need to flush the arp cache, handle DHCP and wrong IPs. | ||
708 | * | ||
709 | * DHCP and such are all features we will never use in gnunet afaik. | ||
710 | * But for openvpn those are essential. | ||
711 | */ | ||
704 | if (!tun_up (handle)) | 712 | if (!tun_up (handle)) |
705 | goto teardown; | 713 | goto teardown; |
714 | |||
715 | fd_set fds_w; | ||
716 | fd_set fds_r; | ||
717 | |||
718 | /* read refers to reading from fd_tun, writing to stdout */ | ||
719 | int read_open = 1; | ||
706 | 720 | ||
707 | // tun.c:3038 | 721 | /* write refers to reading from stdin, writing to fd_tun */ |
722 | int write_open = 1; | ||
708 | 723 | ||
724 | // Setup should be complete here. | ||
725 | // If something is missing, check init.c:3400+ | ||
726 | |||
709 | // mainloop: | 727 | // mainloop: |
710 | // tunnel_point_to_point | 728 | // tunnel_point_to_point |
711 | //openvpn.c:62 | 729 | // openvpn.c:62 |
730 | |||
731 | while ((1 == read_open) || (1 == write_open)) | ||
732 | { | ||
733 | FD_ZERO (&fds_w); | ||
734 | FD_ZERO (&fds_r); | ||
735 | |||
736 | // openvpn.c:80 ? | ||
737 | |||
738 | /* | ||
739 | * We are supposed to read and the buffer is empty | ||
740 | * -> select on read from tun | ||
741 | */ | ||
742 | if (read_open && (0 == buftun_size)) | ||
743 | // FD_SET (fd_tun, &fds_r); | ||
744 | ; | ||
745 | |||
746 | /* | ||
747 | * We are supposed to read and the buffer is not empty | ||
748 | * -> select on write to stdout | ||
749 | */ | ||
750 | if (read_open && (0 != buftun_size)) | ||
751 | FD_SET (1, &fds_w); | ||
752 | |||
753 | /* | ||
754 | * We are supposed to write and the buffer is empty | ||
755 | * -> select on read from stdin | ||
756 | */ | ||
757 | if (write_open && (NULL == bufin_read)) | ||
758 | FD_SET (0, &fds_r); | ||
759 | |||
760 | /* | ||
761 | * We are supposed to write and the buffer is not empty | ||
762 | * -> select on write to tun | ||
763 | */ | ||
764 | if (write_open && (NULL != bufin_read)) | ||
765 | // FD_SET (fd_tun, &fds_w); | ||
766 | ; | ||
767 | |||
712 | 768 | ||
713 | // init.c:3337 | 769 | // init.c:3337 |
714 | /* setup ansync IO */ | 770 | /* setup ansync IO */ |
715 | //forward.c: 1515 | 771 | //forward.c: 1515 |
716 | 772 | ||
717 | 773 | } | |
718 | teardown: | 774 | teardown: |
719 | ; | 775 | ; |
720 | //init.c:3472 | 776 | //init.c:3472 |