diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-12-06 10:10:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-12-06 10:10:08 +0000 |
commit | 270c5403fa5e6b2edf26211b5ecbdfb9e5d454f2 (patch) | |
tree | ff1d780b7e9b2df15b474e1c9bdc9acfcc782601 /src/vpn | |
parent | c3bf7a364a9dac82d17631f2f2fd71353df5bb2e (diff) | |
download | gnunet-270c5403fa5e6b2edf26211b5ecbdfb9e5d454f2.tar.gz gnunet-270c5403fa5e6b2edf26211b5ecbdfb9e5d454f2.zip |
-feedback on style
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/gnunet-helper-vpn-windows.c | 79 |
1 files changed, 47 insertions, 32 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c index 93bf290c8..74e06430a 100644 --- a/src/vpn/gnunet-helper-vpn-windows.c +++ b/src/vpn/gnunet-helper-vpn-windows.c | |||
@@ -73,10 +73,23 @@ | |||
73 | * | 73 | * |
74 | * If we crash this device might stay around. | 74 | * If we crash this device might stay around. |
75 | */ | 75 | */ |
76 | HDEVINFO DeviceInfo = INVALID_HANDLE_VALUE; | 76 | static HDEVINFO DeviceInfo = INVALID_HANDLE_VALUE; |
77 | SP_DEVINFO_DATA DeviceNode; | 77 | |
78 | TCHAR class[128]; | 78 | /** |
79 | GUID guid; | 79 | * FIXME |
80 | */ | ||
81 | static SP_DEVINFO_DATA DeviceNode; | ||
82 | |||
83 | /** | ||
84 | * FIXME | ||
85 | */ | ||
86 | static TCHAR class[128]; | ||
87 | |||
88 | /** | ||
89 | * FIXME | ||
90 | */ | ||
91 | static GUID guid; | ||
92 | |||
80 | 93 | ||
81 | /** | 94 | /** |
82 | * Creates a tun-interface called dev; | 95 | * Creates a tun-interface called dev; |
@@ -101,6 +114,7 @@ init_tun (char *dev) | |||
101 | return fd; | 114 | return fd; |
102 | } | 115 | } |
103 | 116 | ||
117 | |||
104 | /** | 118 | /** |
105 | * @brief Sets the IPv6-Address given in address on the interface dev | 119 | * @brief Sets the IPv6-Address given in address on the interface dev |
106 | * | 120 | * |
@@ -111,7 +125,7 @@ init_tun (char *dev) | |||
111 | static void | 125 | static void |
112 | set_address6 (const char *dev, const char *address, unsigned long prefix_len) | 126 | set_address6 (const char *dev, const char *address, unsigned long prefix_len) |
113 | { | 127 | { |
114 | int fd = 0; | 128 | int fd = -1; |
115 | 129 | ||
116 | /* | 130 | /* |
117 | * parse the new address | 131 | * parse the new address |
@@ -152,7 +166,7 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len) | |||
152 | static void | 166 | static void |
153 | set_address4 (const char *dev, const char *address, const char *mask) | 167 | set_address4 (const char *dev, const char *address, const char *mask) |
154 | { | 168 | { |
155 | int fd = 0; | 169 | int fd = -1; |
156 | 170 | ||
157 | /* | 171 | /* |
158 | * Parse the address | 172 | * Parse the address |
@@ -190,6 +204,10 @@ set_address4 (const char *dev, const char *address, const char *mask) | |||
190 | } | 204 | } |
191 | } | 205 | } |
192 | 206 | ||
207 | |||
208 | /** | ||
209 | * FIXME. | ||
210 | */ | ||
193 | static boolean | 211 | static boolean |
194 | setup_interface () | 212 | setup_interface () |
195 | { | 213 | { |
@@ -199,11 +217,12 @@ setup_interface () | |||
199 | * We do not directly input all the props here, because openvpn will update | 217 | * We do not directly input all the props here, because openvpn will update |
200 | * these details over time. | 218 | * these details over time. |
201 | */ | 219 | */ |
202 | TCHAR InfFile[] = "tapw32.inf"; | 220 | TCHAR InfFile[] = _T("tapw32.inf"); // FIXME: inline or #define, no 'variable' |
203 | TCHAR hwid[] = "TAP0901"; | 221 | TCHAR hwid[] = _T("TAP0901"); |
204 | TCHAR * InfFilePath; | 222 | TCHAR InfFilePath[MAX_PATH]; |
205 | TCHAR * hwIdList; | 223 | TCHAR hwIdList[LINE_LEN + 4]; |
206 | 224 | ||
225 | #if DEAD | ||
207 | /** | 226 | /** |
208 | * Locate the inf-file, we need to store it somewhere where the system can | 227 | * Locate the inf-file, we need to store it somewhere where the system can |
209 | * find it. A good choice would be CWD/PDW or %WINDIR$\system32\ | 228 | * find it. A good choice would be CWD/PDW or %WINDIR$\system32\ |
@@ -211,13 +230,12 @@ setup_interface () | |||
211 | * TODO: Finde a more sane way to do this! | 230 | * TODO: Finde a more sane way to do this! |
212 | */ | 231 | */ |
213 | 232 | ||
214 | InfFilePath = calloc (MAX_PATH, sizeof (TCHAR)); | 233 | if (NULL == (InfFilePath = calloc (MAX_PATH, sizeof (TCHAR)))) |
215 | if (InfFilePath == NULL) | ||
216 | { | ||
217 | return FALSE; | 234 | return FALSE; |
218 | } | 235 | #endif |
219 | GetFullPathName (InfFile, MAX_PATH, InfFilePath, NULL); | 236 | GetFullPathName (InfFile, MAX_PATH, InfFilePath, NULL); |
220 | 237 | ||
238 | #if DEAD | ||
221 | /** | 239 | /** |
222 | * Set the device's hardware ID and add it to a list. | 240 | * Set the device's hardware ID and add it to a list. |
223 | * This information will later on identify this device in registry. | 241 | * This information will later on identify this device in registry. |
@@ -230,6 +248,7 @@ setup_interface () | |||
230 | { | 248 | { |
231 | goto cleanup1; | 249 | goto cleanup1; |
232 | } | 250 | } |
251 | #endif | ||
233 | strncpy (hwIdList, hwid, LINE_LEN); | 252 | strncpy (hwIdList, hwid, LINE_LEN); |
234 | 253 | ||
235 | /** | 254 | /** |
@@ -295,6 +314,7 @@ cleanup1: | |||
295 | 314 | ||
296 | } | 315 | } |
297 | 316 | ||
317 | |||
298 | static boolean | 318 | static boolean |
299 | remove_interface () | 319 | remove_interface () |
300 | { | 320 | { |
@@ -304,25 +324,19 @@ remove_interface () | |||
304 | remove.HwProfile = 0; | 324 | remove.HwProfile = 0; |
305 | remove.Scope = DI_REMOVEDEVICE_GLOBAL; | 325 | remove.Scope = DI_REMOVEDEVICE_GLOBAL; |
306 | remove.ClassInstallHeader.InstallFunction = DIF_REMOVE; | 326 | remove.ClassInstallHeader.InstallFunction = DIF_REMOVE; |
307 | 327 | if (! SetupDiSetClassInstallParams (DeviceInfo, | |
308 | 328 | (PSP_DEVINFO_DATA) &DeviceNode, | |
309 | if (SetupDiSetClassInstallParams (DeviceInfo, | 329 | &remove.ClassInstallHeader, |
310 | (PSP_DEVINFO_DATA) &DeviceNode, | 330 | sizeof (remove))) |
311 | &remove.ClassInstallHeader, | 331 | return FALSE; |
312 | sizeof (remove))) | 332 | if (! SetupDiCallClassInstaller (DIF_REMOVE, |
313 | { | 333 | DeviceInfo, |
314 | if (SetupDiCallClassInstaller (DIF_REMOVE, | 334 | (PSP_DEVINFO_DATA) &DeviceNode)) |
315 | DeviceInfo, | 335 | return FALSE; |
316 | (PSP_DEVINFO_DATA) &DeviceNode)) | 336 | return TRUE; |
317 | { | ||
318 | return TRUE; | ||
319 | } | ||
320 | } | ||
321 | |||
322 | return FALSE; | ||
323 | |||
324 | } | 337 | } |
325 | 338 | ||
339 | |||
326 | /** | 340 | /** |
327 | * Start forwarding to and from the tunnel. | 341 | * Start forwarding to and from the tunnel. |
328 | * | 342 | * |
@@ -346,8 +360,10 @@ run (int fd_tun) | |||
346 | size_t bufin_rpos = 0; | 360 | size_t bufin_rpos = 0; |
347 | unsigned char *bufin_read = NULL; | 361 | unsigned char *bufin_read = NULL; |
348 | /* Hello, I am a stub function! I did my job, yay me! */ | 362 | /* Hello, I am a stub function! I did my job, yay me! */ |
363 | |||
349 | } | 364 | } |
350 | 365 | ||
366 | |||
351 | /** | 367 | /** |
352 | * Open VPN tunnel interface. | 368 | * Open VPN tunnel interface. |
353 | * | 369 | * |
@@ -359,7 +375,6 @@ run (int fd_tun) | |||
359 | * 4: IPv4 address (1.2.3.4), "-" to disable | 375 | * 4: IPv4 address (1.2.3.4), "-" to disable |
360 | * 5: IPv4 netmask (255.255.0.0), ignored if #4 is "-" | 376 | * 5: IPv4 netmask (255.255.0.0), ignored if #4 is "-" |
361 | */ | 377 | */ |
362 | |||
363 | int | 378 | int |
364 | main (int argc, char **argv) | 379 | main (int argc, char **argv) |
365 | { | 380 | { |