aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-24 13:07:29 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-24 13:07:29 +0000
commitd157355d7e3913dda394e7dcccae03b0e7c129b7 (patch)
tree42fc39fbaa2a9607398bb50ea4be206cbd602e00 /src/vpn
parent77da27b63ae4c24ff737fd2212f765a1b9b06de0 (diff)
downloadgnunet-d157355d7e3913dda394e7dcccae03b0e7c129b7.tar.gz
gnunet-d157355d7e3913dda394e7dcccae03b0e7c129b7.zip
helper now always uses BOOL(winbool) instead of boolean to stay
consistent attept_write now properly resets the read facility to IOSTATE_RESUME, in case read was stalled because write was busy
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c
index 3a9702096..f9a2f0f9a 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -400,7 +400,7 @@ remove_address4 (const char *address)
400 * 400 *
401 * @return: TRUE if setup was successful, else FALSE 401 * @return: TRUE if setup was successful, else FALSE
402 */ 402 */
403static boolean 403static BOOL
404setup_interface () 404setup_interface ()
405{ 405{
406 /* 406 /*
@@ -500,7 +500,7 @@ setup_interface ()
500 * 500 *
501 * @return: TRUE if destruction was successful, else FALSE 501 * @return: TRUE if destruction was successful, else FALSE
502 */ 502 */
503static boolean 503static BOOL
504remove_interface () 504remove_interface ()
505{ 505{
506 SP_REMOVEDEVICE_PARAMS remove; 506 SP_REMOVEDEVICE_PARAMS remove;
@@ -541,7 +541,7 @@ remove_interface ()
541 * 541 *
542 * @return: TRUE if we were able to lookup the interface's name, else FALSE 542 * @return: TRUE if we were able to lookup the interface's name, else FALSE
543 */ 543 */
544static boolean 544static BOOL
545resolve_interface_name () 545resolve_interface_name ()
546{ 546{
547 SP_DEVINFO_LIST_DETAIL_DATA device_details; 547 SP_DEVINFO_LIST_DETAIL_DATA device_details;
@@ -551,7 +551,7 @@ resolve_interface_name ()
551 DWORD len; 551 DWORD len;
552 int i = 0; 552 int i = 0;
553 int retrys; 553 int retrys;
554 boolean retval = FALSE; 554 BOOL retval = FALSE;
555 char adapter[] = INTERFACE_REGISTRY_LOCATION; 555 char adapter[] = INTERFACE_REGISTRY_LOCATION;
556 556
557 /* We can obtain the PNP instance ID from our setupapi handle */ 557 /* We can obtain the PNP instance ID from our setupapi handle */
@@ -683,7 +683,7 @@ cleanup:
683 * @param handle the handle to our tap device 683 * @param handle the handle to our tap device
684 * @return TRUE if the version is sufficient, else FALSE 684 * @return TRUE if the version is sufficient, else FALSE
685 */ 685 */
686static boolean 686static BOOL
687check_tapw32_version (HANDLE handle) 687check_tapw32_version (HANDLE handle)
688{ 688{
689 ULONG version[3]; 689 ULONG version[3];
@@ -774,7 +774,7 @@ init_tun ()
774 * @param handle the handle to our TAP device 774 * @param handle the handle to our TAP device
775 * @return True if the operation succeeded, else false 775 * @return True if the operation succeeded, else false
776 */ 776 */
777static boolean 777static BOOL
778tun_up (HANDLE handle) 778tun_up (HANDLE handle)
779{ 779{
780 ULONG status = TRUE; 780 ULONG status = TRUE;
@@ -820,18 +820,18 @@ tun_up (HANDLE handle)
820 * @param output_facility output pipe or file to hand over data to. 820 * @param output_facility output pipe or file to hand over data to.
821 * @return false if an event reset was impossible (OS error), else true 821 * @return false if an event reset was impossible (OS error), else true
822 */ 822 */
823static boolean 823static BOOL
824attempt_read_tap (struct io_facility * input_facility, 824attempt_read_tap (struct io_facility * input_facility,
825 struct io_facility * output_facility) 825 struct io_facility * output_facility)
826{ 826{
827 struct GNUNET_MessageHeader * hdr; 827 struct GNUNET_MessageHeader * hdr;
828 unsigned short size; 828 unsigned short size;
829 BOOL status;
829 830
830 switch (input_facility->facility_state) 831 switch (input_facility->facility_state)
831 { 832 {
832 case IOSTATE_READY: 833 case IOSTATE_READY:
833 { 834 {
834 BOOL status; // BOOL is winbool, NOT boolean!
835 if (!ResetEvent (input_facility->overlapped.hEvent)) 835 if (!ResetEvent (input_facility->overlapped.hEvent))
836 { 836 {
837 return FALSE; 837 return FALSE;
@@ -898,8 +898,6 @@ attempt_read_tap (struct io_facility * input_facility,
898 // We are queued and should check if the read has finished 898 // We are queued and should check if the read has finished
899 case IOSTATE_QUEUED: 899 case IOSTATE_QUEUED:
900 { 900 {
901 BOOL status; // BOOL is winbool, NOT boolean!
902
903 // there was an operation going on already, check if that has completed now. 901 // there was an operation going on already, check if that has completed now.
904 status = GetOverlappedResult (input_facility->handle, 902 status = GetOverlappedResult (input_facility->handle,
905 &input_facility->overlapped, 903 &input_facility->overlapped,
@@ -950,7 +948,6 @@ attempt_read_tap (struct io_facility * input_facility,
950 } 948 }
951 return TRUE; 949 return TRUE;
952 case IOSTATE_RESUME: 950 case IOSTATE_RESUME:
953 {
954 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; 951 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer;
955 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); 952 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader);
956 953
@@ -964,7 +961,6 @@ attempt_read_tap (struct io_facility * input_facility,
964 output_facility->facility_state = IOSTATE_READY; 961 output_facility->facility_state = IOSTATE_READY;
965 input_facility->facility_state = IOSTATE_READY; 962 input_facility->facility_state = IOSTATE_READY;
966 return TRUE; 963 return TRUE;
967 }
968 default: 964 default:
969 return TRUE; 965 return TRUE;
970 } 966 }
@@ -996,15 +992,15 @@ attempt_read_tap (struct io_facility * input_facility,
996 * @param output_facility output pipe or file to hand over data to. 992 * @param output_facility output pipe or file to hand over data to.
997 * @return false if an event reset was impossible (OS error), else true 993 * @return false if an event reset was impossible (OS error), else true
998 */ 994 */
999static boolean 995static BOOL
1000attempt_read_stdin (struct io_facility * input_facility, 996attempt_read_stdin (struct io_facility * input_facility,
1001 struct io_facility * output_facility) 997 struct io_facility * output_facility)
1002{ 998{
999 BOOL status;
1003 switch (input_facility->facility_state) 1000 switch (input_facility->facility_state)
1004 { 1001 {
1005 case IOSTATE_READY: 1002 case IOSTATE_READY:
1006 { 1003 {
1007 BOOL status; // BOOL is winbool, NOT boolean!
1008 if (!ResetEvent (input_facility->overlapped.hEvent)) 1004 if (!ResetEvent (input_facility->overlapped.hEvent))
1009 return FALSE; 1005 return FALSE;
1010 input_facility->buffer_size = 0; 1006 input_facility->buffer_size = 0;
@@ -1083,8 +1079,6 @@ attempt_read_stdin (struct io_facility * input_facility,
1083 // We are queued and should check if the read has finished 1079 // We are queued and should check if the read has finished
1084 case IOSTATE_QUEUED: 1080 case IOSTATE_QUEUED:
1085 { 1081 {
1086 BOOL status; // BOOL is winbool, NOT boolean!
1087
1088 // there was an operation going on already, check if that has completed now. 1082 // there was an operation going on already, check if that has completed now.
1089 status = GetOverlappedResult (input_facility->handle, 1083 status = GetOverlappedResult (input_facility->handle,
1090 &input_facility->overlapped, 1084 &input_facility->overlapped,
@@ -1164,11 +1158,11 @@ attempt_read_stdin (struct io_facility * input_facility,
1164 * @param input_facility input named pipe or file to work with. 1158 * @param input_facility input named pipe or file to work with.
1165 * @return false if an event reset was impossible (OS error), else true 1159 * @return false if an event reset was impossible (OS error), else true
1166 */ 1160 */
1167static boolean 1161static BOOL
1168attempt_write (struct io_facility * output_facility, 1162attempt_write (struct io_facility * output_facility,
1169 struct io_facility * input_facility) 1163 struct io_facility * input_facility)
1170{ 1164{
1171 BOOL status; // BOOL is winbool, NOT boolean! 1165 BOOL status;
1172 1166
1173 switch (output_facility->facility_state) 1167 switch (output_facility->facility_state)
1174 { 1168 {
@@ -1200,7 +1194,7 @@ attempt_write (struct io_facility * output_facility,
1200 1194
1201 /* we successfully wrote something and now need to reset our reader */ 1195 /* we successfully wrote something and now need to reset our reader */
1202 if (IOSTATE_WAITING == input_facility->facility_state) 1196 if (IOSTATE_WAITING == input_facility->facility_state)
1203 input_facility->facility_state = IOSTATE_READY; 1197 input_facility->facility_state = IOSTATE_RESUME;
1204 else if (IOSTATE_FAILED == input_facility->facility_state) 1198 else if (IOSTATE_FAILED == input_facility->facility_state)
1205 output_facility->path_open = FALSE; 1199 output_facility->path_open = FALSE;
1206 } 1200 }
@@ -1238,7 +1232,7 @@ attempt_write (struct io_facility * output_facility,
1238 1232
1239 /* we successfully wrote something and now need to reset our reader */ 1233 /* we successfully wrote something and now need to reset our reader */
1240 if (IOSTATE_WAITING == input_facility->facility_state) 1234 if (IOSTATE_WAITING == input_facility->facility_state)
1241 input_facility->facility_state = IOSTATE_READY; 1235 input_facility->facility_state = IOSTATE_RESUME;
1242 else if (IOSTATE_FAILED == input_facility->facility_state) 1236 else if (IOSTATE_FAILED == input_facility->facility_state)
1243 output_facility->path_open = FALSE; 1237 output_facility->path_open = FALSE;
1244 } 1238 }
@@ -1266,7 +1260,7 @@ attempt_write (struct io_facility * output_facility,
1266 * @param signaled if the hEvent created should default to signaled or not 1260 * @param signaled if the hEvent created should default to signaled or not
1267 * @return true on success, else false 1261 * @return true on success, else false
1268 */ 1262 */
1269static boolean 1263static BOOL
1270initialize_io_facility (struct io_facility * elem, 1264initialize_io_facility (struct io_facility * elem,
1271 int initial_state, 1265 int initial_state,
1272 BOOL signaled) 1266 BOOL signaled)
@@ -1406,8 +1400,8 @@ main (int argc, char **argv)
1406 char hwid[LINE_LEN]; 1400 char hwid[LINE_LEN];
1407 HANDLE handle; 1401 HANDLE handle;
1408 int global_ret = 0; 1402 int global_ret = 0;
1409 boolean have_ip4 = FALSE; 1403 BOOL have_ip4 = FALSE;
1410 boolean have_ip6 = FALSE; 1404 BOOL have_ip6 = FALSE;
1411 1405
1412 if (6 != argc) 1406 if (6 != argc)
1413 { 1407 {