aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-01-24 10:11:13 +0000
committerChristian Grothoff <christian@grothoff.org>2013-01-24 10:11:13 +0000
commiteb7e0beb4eeb7897e25b1afbd9575e9111199e43 (patch)
treeb826c958c22461cd612aea083bde2b691f30e539 /src/vpn
parent8b2c52fda1687c5a61f5eb0fd98536c03f53c8ee (diff)
downloadgnunet-eb7e0beb4eeb7897e25b1afbd9575e9111199e43.tar.gz
gnunet-eb7e0beb4eeb7897e25b1afbd9575e9111199e43.zip
-tiny fixmes
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c64
1 files changed, 41 insertions, 23 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c
index 520ed774a..07285722e 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -132,15 +132,46 @@ static SP_DEVINFO_DATA DeviceNode;
132 */ 132 */
133static char device_guid[256]; 133static char device_guid[256];
134 134
135
136/**
137 * Possible states of an IO facility.
138 */
139enum IO_State
140{
141
142 /**
143 * overlapped I/O is ready for work
144 */
145 IOSTATE_READY = 0,
146
147 /**
148 * overlapped I/O has been queued
149 */
150 IOSTATE_QUEUED,
151
152 /**
153 * overlapped I/O has finished, but is waiting for it's write-partner
154 */
155 IOSTATE_WAITING,
156
157 /**
158 * Operlapped IO states for facility objects
159 * overlapped I/O has failed, stop processing
160 */
161 IOSTATE_FAILED
162
163};
164
165
135/** 166/**
136 * A IO Object + read/writebuffer + buffer-size for windows asynchronous IO handling 167 * A IO Object + read/writebuffer + buffer-size for windows asynchronous IO handling
137 */ 168 */
138struct io_facility 169struct io_facility
139{ 170{
140 /** 171 /**
141 * The mode the state machine associated with this object is in. IOSTATE_* 172 * The mode the state machine associated with this object is in.
142 */ 173 */
143 int facility_state; 174 enum IO_State facility_state;
144 175
145 /** 176 /**
146 * If the path is open or blocked in general (used for quickly checking) 177 * If the path is open or blocked in general (used for quickly checking)
@@ -173,23 +204,6 @@ struct io_facility
173 DWORD buffer_size_written; 204 DWORD buffer_size_written;
174}; 205};
175 206
176/**
177 * Operlapped IO states for facility objects
178 * overlapped I/O has failed, stop processing
179 */
180#define IOSTATE_FAILED -1
181/**
182 * overlapped I/O is ready for work
183 */
184#define IOSTATE_READY 0
185/**
186 * overlapped I/O has been queued
187 */
188#define IOSTATE_QUEUED 1
189/**
190 * overlapped I/O has finished, but is waiting for it's write-partner
191 */
192#define IOSTATE_WAITING 3
193 207
194/** 208/**
195 * ReOpenFile is only available as of XP SP2 and 2003 SP1 209 * ReOpenFile is only available as of XP SP2 and 2003 SP1
@@ -210,8 +224,8 @@ execute_shellcommand (const char *command)
210{ 224{
211 FILE *pipe; 225 FILE *pipe;
212 226
213 if (NULL == command || 227 if ( (NULL == command) ||
214 NULL == (pipe = _popen (command, "rt"))) 228 (NULL == (pipe = _popen (command, "rt"))) )
215 return EINVAL; 229 return EINVAL;
216 230
217#ifdef TESTING 231#ifdef TESTING
@@ -659,6 +673,9 @@ cleanup:
659} 673}
660 674
661 675
676/**
677 * FIXME.
678 */
662static boolean 679static boolean
663check_tapw32_version (HANDLE handle) 680check_tapw32_version (HANDLE handle)
664{ 681{
@@ -699,7 +716,7 @@ init_tun ()
699 char device_path[256]; 716 char device_path[256];
700 HANDLE handle; 717 HANDLE handle;
701 718
702 if (!setup_interface ()) 719 if (! setup_interface ())
703 { 720 {
704 errno = ENODEV; 721 errno = ENODEV;
705 return INVALID_HANDLE_VALUE; 722 return INVALID_HANDLE_VALUE;
@@ -927,6 +944,7 @@ attempt_read_tap (struct io_facility * input_facility,
927 } 944 }
928} 945}
929 946
947
930/** 948/**
931 * Attempts to read off an input facility (tap or named pipe) in overlapped mode. 949 * Attempts to read off an input facility (tap or named pipe) in overlapped mode.
932 * 950 *
@@ -1118,6 +1136,7 @@ static boolean
1118attempt_write (struct io_facility * output_facility, 1136attempt_write (struct io_facility * output_facility,
1119 struct io_facility * input_facility) 1137 struct io_facility * input_facility)
1120{ 1138{
1139 // FIXME: use switch...
1121 if (IOSTATE_READY == output_facility->facility_state 1140 if (IOSTATE_READY == output_facility->facility_state
1122 && output_facility->buffer_size > 0) 1141 && output_facility->buffer_size > 0)
1123 { 1142 {
@@ -1224,7 +1243,6 @@ initialize_io_facility (struct io_facility * elem,
1224 int initial_state, 1243 int initial_state,
1225 BOOL signaled) 1244 BOOL signaled)
1226{ 1245{
1227
1228 elem->path_open = TRUE; 1246 elem->path_open = TRUE;
1229 elem->handle = INVALID_HANDLE_VALUE; 1247 elem->handle = INVALID_HANDLE_VALUE;
1230 elem->facility_state = initial_state; 1248 elem->facility_state = initial_state;