diff options
Diffstat (limited to 'src/pt/test_gns_vpn.c')
-rw-r--r-- | src/pt/test_gns_vpn.c | 902 |
1 files changed, 451 insertions, 451 deletions
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c index 90405fe37..8a6e3e6d4 100644 --- a/src/pt/test_gns_vpn.c +++ b/src/pt/test_gns_vpn.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file test_gns_vpn.c | 22 | * @file test_gns_vpn.c |
@@ -49,7 +49,7 @@ | |||
49 | #define PORT 8080 | 49 | #define PORT 8080 |
50 | #define TEST_DOMAIN "www.gnu" | 50 | #define TEST_DOMAIN "www.gnu" |
51 | 51 | ||
52 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 52 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Return value for #main(). | 55 | * Return value for #main(). |
@@ -96,8 +96,7 @@ static int src_af; | |||
96 | static int use_v6; | 96 | static int use_v6; |
97 | 97 | ||
98 | 98 | ||
99 | struct CBC | 99 | struct CBC { |
100 | { | ||
101 | char buf[1024]; | 100 | char buf[1024]; |
102 | size_t pos; | 101 | size_t pos; |
103 | }; | 102 | }; |
@@ -106,102 +105,102 @@ static struct CBC cbc; | |||
106 | 105 | ||
107 | 106 | ||
108 | static size_t | 107 | static size_t |
109 | copy_buffer (void *ptr, | 108 | copy_buffer(void *ptr, |
110 | size_t size, | 109 | size_t size, |
111 | size_t nmemb, | 110 | size_t nmemb, |
112 | void *ctx) | 111 | void *ctx) |
113 | { | 112 | { |
114 | struct CBC *cbc = ctx; | 113 | struct CBC *cbc = ctx; |
115 | 114 | ||
116 | if (cbc->pos + size * nmemb > sizeof(cbc->buf)) | 115 | if (cbc->pos + size * nmemb > sizeof(cbc->buf)) |
117 | return 0; /* overflow */ | 116 | return 0; /* overflow */ |
118 | GNUNET_memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); | 117 | GNUNET_memcpy(&cbc->buf[cbc->pos], ptr, size * nmemb); |
119 | cbc->pos += size * nmemb; | 118 | cbc->pos += size * nmemb; |
120 | return size * nmemb; | 119 | return size * nmemb; |
121 | } | 120 | } |
122 | 121 | ||
123 | 122 | ||
124 | static int | 123 | static int |
125 | mhd_ahc (void *cls, | 124 | mhd_ahc(void *cls, |
126 | struct MHD_Connection *connection, | 125 | struct MHD_Connection *connection, |
127 | const char *url, | 126 | const char *url, |
128 | const char *method, | 127 | const char *method, |
129 | const char *version, | 128 | const char *version, |
130 | const char *upload_data, size_t *upload_data_size, | 129 | const char *upload_data, size_t *upload_data_size, |
131 | void **unused) | 130 | void **unused) |
132 | { | 131 | { |
133 | static int ptr; | 132 | static int ptr; |
134 | struct MHD_Response *response; | 133 | struct MHD_Response *response; |
135 | int ret; | 134 | int ret; |
136 | 135 | ||
137 | if (0 != strcmp ("GET", method)) | 136 | if (0 != strcmp("GET", method)) |
138 | return MHD_NO; /* unexpected method */ | 137 | return MHD_NO; /* unexpected method */ |
139 | if (&ptr != *unused) | 138 | if (&ptr != *unused) |
140 | { | 139 | { |
141 | *unused = &ptr; | 140 | *unused = &ptr; |
142 | return MHD_YES; | 141 | return MHD_YES; |
143 | } | 142 | } |
144 | *unused = NULL; | 143 | *unused = NULL; |
145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MHD sends respose for request to URL `%s'\n", url); | 144 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MHD sends respose for request to URL `%s'\n", url); |
146 | response = MHD_create_response_from_buffer (strlen (url), | 145 | response = MHD_create_response_from_buffer(strlen(url), |
147 | (void *) url, | 146 | (void *)url, |
148 | MHD_RESPMEM_MUST_COPY); | 147 | MHD_RESPMEM_MUST_COPY); |
149 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 148 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); |
150 | MHD_destroy_response (response); | 149 | MHD_destroy_response(response); |
151 | if (ret == MHD_NO) | 150 | if (ret == MHD_NO) |
152 | abort (); | 151 | abort(); |
153 | return ret; | 152 | return ret; |
154 | } | 153 | } |
155 | 154 | ||
156 | 155 | ||
157 | static void | 156 | static void |
158 | do_shutdown (void *cls) | 157 | do_shutdown(void *cls) |
159 | { | 158 | { |
160 | if (NULL != mhd_task_id) | 159 | if (NULL != mhd_task_id) |
161 | { | 160 | { |
162 | GNUNET_SCHEDULER_cancel (mhd_task_id); | 161 | GNUNET_SCHEDULER_cancel(mhd_task_id); |
163 | mhd_task_id = NULL; | 162 | mhd_task_id = NULL; |
164 | } | 163 | } |
165 | if (NULL != curl_task_id) | 164 | if (NULL != curl_task_id) |
166 | { | 165 | { |
167 | GNUNET_SCHEDULER_cancel (curl_task_id); | 166 | GNUNET_SCHEDULER_cancel(curl_task_id); |
168 | curl_task_id = NULL; | 167 | curl_task_id = NULL; |
169 | } | 168 | } |
170 | if (NULL != timeout_task) | 169 | if (NULL != timeout_task) |
171 | { | 170 | { |
172 | GNUNET_SCHEDULER_cancel (timeout_task); | 171 | GNUNET_SCHEDULER_cancel(timeout_task); |
173 | timeout_task = NULL; | 172 | timeout_task = NULL; |
174 | } | 173 | } |
175 | if (NULL != mhd) | 174 | if (NULL != mhd) |
176 | { | 175 | { |
177 | MHD_stop_daemon (mhd); | 176 | MHD_stop_daemon(mhd); |
178 | mhd = NULL; | 177 | mhd = NULL; |
179 | } | 178 | } |
180 | if (NULL != identity) | 179 | if (NULL != identity) |
181 | { | 180 | { |
182 | GNUNET_IDENTITY_disconnect (identity); | 181 | GNUNET_IDENTITY_disconnect(identity); |
183 | identity = NULL; | 182 | identity = NULL; |
184 | } | 183 | } |
185 | if (NULL != qe) | 184 | if (NULL != qe) |
186 | { | 185 | { |
187 | GNUNET_NAMESTORE_cancel (qe); | 186 | GNUNET_NAMESTORE_cancel(qe); |
188 | qe = NULL; | 187 | qe = NULL; |
189 | } | 188 | } |
190 | if (NULL != namestore) | 189 | if (NULL != namestore) |
191 | { | 190 | { |
192 | GNUNET_NAMESTORE_disconnect (namestore); | 191 | GNUNET_NAMESTORE_disconnect(namestore); |
193 | namestore = NULL; | 192 | namestore = NULL; |
194 | } | 193 | } |
195 | GNUNET_free_non_null (url); | 194 | GNUNET_free_non_null(url); |
196 | url = NULL; | 195 | url = NULL; |
197 | } | 196 | } |
198 | 197 | ||
199 | 198 | ||
200 | static void | 199 | static void |
201 | do_timeout (void *cls) | 200 | do_timeout(void *cls) |
202 | { | 201 | { |
203 | timeout_task = NULL; | 202 | timeout_task = NULL; |
204 | GNUNET_SCHEDULER_shutdown (); | 203 | GNUNET_SCHEDULER_shutdown(); |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
@@ -209,19 +208,19 @@ do_timeout (void *cls) | |||
209 | * Function to run the HTTP client. | 208 | * Function to run the HTTP client. |
210 | */ | 209 | */ |
211 | static void | 210 | static void |
212 | curl_main (void); | 211 | curl_main(void); |
213 | 212 | ||
214 | 213 | ||
215 | static void | 214 | static void |
216 | curl_task (void *cls) | 215 | curl_task(void *cls) |
217 | { | 216 | { |
218 | curl_task_id = NULL; | 217 | curl_task_id = NULL; |
219 | curl_main (); | 218 | curl_main(); |
220 | } | 219 | } |
221 | 220 | ||
222 | 221 | ||
223 | static void | 222 | static void |
224 | curl_main () | 223 | curl_main() |
225 | { | 224 | { |
226 | fd_set rs; | 225 | fd_set rs; |
227 | fd_set ws; | 226 | fd_set ws; |
@@ -235,102 +234,102 @@ curl_main () | |||
235 | struct CURLMsg *msg; | 234 | struct CURLMsg *msg; |
236 | 235 | ||
237 | max = 0; | 236 | max = 0; |
238 | FD_ZERO (&rs); | 237 | FD_ZERO(&rs); |
239 | FD_ZERO (&ws); | 238 | FD_ZERO(&ws); |
240 | FD_ZERO (&es); | 239 | FD_ZERO(&es); |
241 | curl_multi_perform (multi, &running); | 240 | curl_multi_perform(multi, &running); |
242 | if (running == 0) | 241 | if (running == 0) |
243 | { | ||
244 | GNUNET_assert (NULL != (msg = curl_multi_info_read (multi, &running))); | ||
245 | if (msg->msg == CURLMSG_DONE) | ||
246 | { | ||
247 | if (msg->data.result != CURLE_OK) | ||
248 | { | ||
249 | fprintf (stderr, | ||
250 | "%s failed at %s:%d: `%s'\n", | ||
251 | "curl_multi_perform", | ||
252 | __FILE__, | ||
253 | __LINE__, curl_easy_strerror (msg->data.result)); | ||
254 | global_ret = 1; | ||
255 | } | ||
256 | } | ||
257 | curl_multi_remove_handle (multi, curl); | ||
258 | curl_multi_cleanup (multi); | ||
259 | curl_easy_cleanup (curl); | ||
260 | curl = NULL; | ||
261 | multi = NULL; | ||
262 | if (cbc.pos != strlen ("/hello_world")) | ||
263 | { | 242 | { |
264 | GNUNET_break (0); | 243 | GNUNET_assert(NULL != (msg = curl_multi_info_read(multi, &running))); |
265 | global_ret = 2; | 244 | if (msg->msg == CURLMSG_DONE) |
266 | } | 245 | { |
267 | if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) | 246 | if (msg->data.result != CURLE_OK) |
268 | { | 247 | { |
269 | GNUNET_break (0); | 248 | fprintf(stderr, |
270 | global_ret = 3; | 249 | "%s failed at %s:%d: `%s'\n", |
250 | "curl_multi_perform", | ||
251 | __FILE__, | ||
252 | __LINE__, curl_easy_strerror(msg->data.result)); | ||
253 | global_ret = 1; | ||
254 | } | ||
255 | } | ||
256 | curl_multi_remove_handle(multi, curl); | ||
257 | curl_multi_cleanup(multi); | ||
258 | curl_easy_cleanup(curl); | ||
259 | curl = NULL; | ||
260 | multi = NULL; | ||
261 | if (cbc.pos != strlen("/hello_world")) | ||
262 | { | ||
263 | GNUNET_break(0); | ||
264 | global_ret = 2; | ||
265 | } | ||
266 | if (0 != strncmp("/hello_world", cbc.buf, strlen("/hello_world"))) | ||
267 | { | ||
268 | GNUNET_break(0); | ||
269 | global_ret = 3; | ||
270 | } | ||
271 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
272 | "Download complete, shutting down!\n"); | ||
273 | GNUNET_SCHEDULER_shutdown(); | ||
274 | return; | ||
271 | } | 275 | } |
272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 276 | GNUNET_assert(CURLM_OK == curl_multi_fdset(multi, &rs, &ws, &es, &max)); |
273 | "Download complete, shutting down!\n"); | 277 | if ((CURLM_OK != curl_multi_timeout(multi, &timeout)) || |
274 | GNUNET_SCHEDULER_shutdown (); | 278 | (-1 == timeout)) |
275 | return; | ||
276 | } | ||
277 | GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max)); | ||
278 | if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) || | ||
279 | (-1 == timeout) ) | ||
280 | delay = GNUNET_TIME_UNIT_SECONDS; | 279 | delay = GNUNET_TIME_UNIT_SECONDS; |
281 | else | 280 | else |
282 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, (unsigned int) timeout); | 281 | delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, (unsigned int)timeout); |
283 | GNUNET_NETWORK_fdset_copy_native (&nrs, | 282 | GNUNET_NETWORK_fdset_copy_native(&nrs, |
284 | &rs, | 283 | &rs, |
285 | max + 1); | 284 | max + 1); |
286 | GNUNET_NETWORK_fdset_copy_native (&nws, | 285 | GNUNET_NETWORK_fdset_copy_native(&nws, |
287 | &ws, | 286 | &ws, |
288 | max + 1); | 287 | max + 1); |
289 | curl_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 288 | curl_task_id = GNUNET_SCHEDULER_add_select(GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
290 | delay, | 289 | delay, |
291 | &nrs, | 290 | &nrs, |
292 | &nws, | 291 | &nws, |
293 | &curl_task, | 292 | &curl_task, |
294 | NULL); | 293 | NULL); |
295 | } | 294 | } |
296 | 295 | ||
297 | 296 | ||
298 | static void | 297 | static void |
299 | start_curl (void *cls) | 298 | start_curl(void *cls) |
300 | { | 299 | { |
301 | CURLcode ec; | 300 | CURLcode ec; |
302 | 301 | ||
303 | curl_task_id = NULL; | 302 | curl_task_id = NULL; |
304 | GNUNET_asprintf (&url, | 303 | GNUNET_asprintf(&url, |
305 | "http://%s/hello_world", | 304 | "http://%s/hello_world", |
306 | TEST_DOMAIN); | 305 | TEST_DOMAIN); |
307 | curl = curl_easy_init (); | 306 | curl = curl_easy_init(); |
308 | curl_easy_setopt (curl, CURLOPT_URL, url); | 307 | curl_easy_setopt(curl, CURLOPT_URL, url); |
309 | curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ©_buffer); | 308 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ©_buffer); |
310 | curl_easy_setopt (curl, CURLOPT_WRITEDATA, &cbc); | 309 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &cbc); |
311 | curl_easy_setopt (curl, CURLOPT_FAILONERROR, 1); | 310 | curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); |
312 | curl_easy_setopt (curl, CURLOPT_TIMEOUT, 150L); | 311 | curl_easy_setopt(curl, CURLOPT_TIMEOUT, 150L); |
313 | curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 150L); | 312 | curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 150L); |
314 | curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1); | 313 | curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
315 | if (CURLE_OK != | 314 | if (CURLE_OK != |
316 | (ec = curl_easy_setopt (curl, | 315 | (ec = curl_easy_setopt(curl, |
317 | CURLOPT_DNS_SERVERS, | 316 | CURLOPT_DNS_SERVERS, |
318 | "127.0.0.1:53"))) | 317 | "127.0.0.1:53"))) |
319 | { | 318 | { |
320 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 319 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
321 | "curl build without support for CURLOPT_DNS_SERVERS (%s), cannot run test\n", | 320 | "curl build without support for CURLOPT_DNS_SERVERS (%s), cannot run test\n", |
322 | curl_easy_strerror (ec)); | 321 | curl_easy_strerror(ec)); |
323 | global_ret = 77; | 322 | global_ret = 77; |
324 | GNUNET_SCHEDULER_shutdown (); | 323 | GNUNET_SCHEDULER_shutdown(); |
325 | return; | 324 | return; |
326 | } | 325 | } |
327 | multi = curl_multi_init (); | 326 | multi = curl_multi_init(); |
328 | GNUNET_assert (multi != NULL); | 327 | GNUNET_assert(multi != NULL); |
329 | GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl)); | 328 | GNUNET_assert(CURLM_OK == curl_multi_add_handle(multi, curl)); |
330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 329 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
331 | "Beginning HTTP download from `%s'\n", | 330 | "Beginning HTTP download from `%s'\n", |
332 | url); | 331 | url); |
333 | curl_main (); | 332 | curl_main(); |
334 | } | 333 | } |
335 | 334 | ||
336 | 335 | ||
@@ -347,28 +346,28 @@ start_curl (void *cls) | |||
347 | * specified target peer; NULL on error | 346 | * specified target peer; NULL on error |
348 | */ | 347 | */ |
349 | static void | 348 | static void |
350 | commence_testing (void *cls, | 349 | commence_testing(void *cls, |
351 | int32_t success, | 350 | int32_t success, |
352 | const char *emsg) | 351 | const char *emsg) |
353 | { | 352 | { |
354 | qe = NULL; | 353 | qe = NULL; |
355 | if ( (NULL != emsg) && | 354 | if ((NULL != emsg) && |
356 | (GNUNET_YES != success) ) | 355 | (GNUNET_YES != success)) |
357 | { | 356 | { |
358 | fprintf (stderr, | 357 | fprintf(stderr, |
359 | "NS failed to create record %s\n", | 358 | "NS failed to create record %s\n", |
360 | emsg); | 359 | emsg); |
361 | GNUNET_SCHEDULER_shutdown (); | 360 | GNUNET_SCHEDULER_shutdown(); |
362 | return; | 361 | return; |
363 | } | 362 | } |
364 | 363 | ||
365 | /* wait a little bit before downloading, as we just created the record */ | 364 | /* wait a little bit before downloading, as we just created the record */ |
366 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 365 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
367 | "Launching cURL request\n"); | 366 | "Launching cURL request\n"); |
368 | curl_task_id | 367 | curl_task_id |
369 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 368 | = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, |
370 | &start_curl, | 369 | &start_curl, |
371 | NULL); | 370 | NULL); |
372 | } | 371 | } |
373 | 372 | ||
374 | 373 | ||
@@ -376,20 +375,20 @@ commence_testing (void *cls, | |||
376 | * Function to keep the HTTP server running. | 375 | * Function to keep the HTTP server running. |
377 | */ | 376 | */ |
378 | static void | 377 | static void |
379 | mhd_main (void); | 378 | mhd_main(void); |
380 | 379 | ||
381 | 380 | ||
382 | static void | 381 | static void |
383 | mhd_task (void *cls) | 382 | mhd_task(void *cls) |
384 | { | 383 | { |
385 | mhd_task_id = NULL; | 384 | mhd_task_id = NULL; |
386 | MHD_run (mhd); | 385 | MHD_run(mhd); |
387 | mhd_main (); | 386 | mhd_main(); |
388 | } | 387 | } |
389 | 388 | ||
390 | 389 | ||
391 | static void | 390 | static void |
392 | mhd_main () | 391 | mhd_main() |
393 | { | 392 | { |
394 | struct GNUNET_NETWORK_FDSet nrs; | 393 | struct GNUNET_NETWORK_FDSet nrs; |
395 | struct GNUNET_NETWORK_FDSet nws; | 394 | struct GNUNET_NETWORK_FDSet nws; |
@@ -400,30 +399,30 @@ mhd_main () | |||
400 | unsigned MHD_LONG_LONG timeout; | 399 | unsigned MHD_LONG_LONG timeout; |
401 | struct GNUNET_TIME_Relative delay; | 400 | struct GNUNET_TIME_Relative delay; |
402 | 401 | ||
403 | GNUNET_assert (NULL == mhd_task_id); | 402 | GNUNET_assert(NULL == mhd_task_id); |
404 | FD_ZERO (&rs); | 403 | FD_ZERO(&rs); |
405 | FD_ZERO (&ws); | 404 | FD_ZERO(&ws); |
406 | FD_ZERO (&es); | 405 | FD_ZERO(&es); |
407 | max_fd = -1; | 406 | max_fd = -1; |
408 | GNUNET_assert (MHD_YES == | 407 | GNUNET_assert(MHD_YES == |
409 | MHD_get_fdset (mhd, &rs, &ws, &es, &max_fd)); | 408 | MHD_get_fdset(mhd, &rs, &ws, &es, &max_fd)); |
410 | if (MHD_YES == MHD_get_timeout (mhd, &timeout)) | 409 | if (MHD_YES == MHD_get_timeout(mhd, &timeout)) |
411 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 410 | delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, |
412 | (unsigned int) timeout); | 411 | (unsigned int)timeout); |
413 | else | 412 | else |
414 | delay = GNUNET_TIME_UNIT_FOREVER_REL; | 413 | delay = GNUNET_TIME_UNIT_FOREVER_REL; |
415 | GNUNET_NETWORK_fdset_copy_native (&nrs, | 414 | GNUNET_NETWORK_fdset_copy_native(&nrs, |
416 | &rs, | 415 | &rs, |
417 | max_fd + 1); | 416 | max_fd + 1); |
418 | GNUNET_NETWORK_fdset_copy_native (&nws, | 417 | GNUNET_NETWORK_fdset_copy_native(&nws, |
419 | &ws, | 418 | &ws, |
420 | max_fd + 1); | 419 | max_fd + 1); |
421 | mhd_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 420 | mhd_task_id = GNUNET_SCHEDULER_add_select(GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
422 | delay, | 421 | delay, |
423 | &nrs, | 422 | &nrs, |
424 | &nws, | 423 | &nws, |
425 | &mhd_task, | 424 | &mhd_task, |
426 | NULL); | 425 | NULL); |
427 | } | 426 | } |
428 | 427 | ||
429 | 428 | ||
@@ -436,22 +435,22 @@ mhd_main () | |||
436 | * @param flags open flags (O_RDONLY, O_WRONLY) | 435 | * @param flags open flags (O_RDONLY, O_WRONLY) |
437 | */ | 436 | */ |
438 | static void | 437 | static void |
439 | open_dev_null (int target_fd, | 438 | open_dev_null(int target_fd, |
440 | int flags) | 439 | int flags) |
441 | { | 440 | { |
442 | int fd; | 441 | int fd; |
443 | 442 | ||
444 | fd = open ("/dev/null", flags); | 443 | fd = open("/dev/null", flags); |
445 | if (-1 == fd) | 444 | if (-1 == fd) |
446 | abort (); | 445 | abort(); |
447 | if (fd == target_fd) | 446 | if (fd == target_fd) |
448 | return; | 447 | return; |
449 | if (-1 == dup2 (fd, target_fd)) | 448 | if (-1 == dup2(fd, target_fd)) |
450 | { | 449 | { |
451 | (void) close (fd); | 450 | (void)close(fd); |
452 | abort (); | 451 | abort(); |
453 | } | 452 | } |
454 | (void) close (fd); | 453 | (void)close(fd); |
455 | } | 454 | } |
456 | 455 | ||
457 | 456 | ||
@@ -463,55 +462,56 @@ open_dev_null (int target_fd, | |||
463 | * @return 0 on success, 1 on any error | 462 | * @return 0 on success, 1 on any error |
464 | */ | 463 | */ |
465 | static int | 464 | static int |
466 | fork_and_exec (const char *file, | 465 | fork_and_exec(const char *file, |
467 | char *const cmd[]) | 466 | char *const cmd[]) |
468 | { | 467 | { |
469 | int status; | 468 | int status; |
470 | pid_t pid; | 469 | pid_t pid; |
471 | pid_t ret; | 470 | pid_t ret; |
472 | 471 | ||
473 | pid = fork (); | 472 | pid = fork(); |
474 | if (-1 == pid) | 473 | if (-1 == pid) |
475 | { | 474 | { |
476 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | 475 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, |
477 | "fork"); | 476 | "fork"); |
478 | return 1; | 477 | return 1; |
479 | } | 478 | } |
480 | if (0 == pid) | 479 | if (0 == pid) |
481 | { | 480 | { |
482 | /* we are the child process */ | 481 | /* we are the child process */ |
483 | /* close stdin/stdout to not cause interference | 482 | /* close stdin/stdout to not cause interference |
484 | with the helper's main protocol! */ | 483 | with the helper's main protocol! */ |
485 | (void) close (0); | 484 | (void)close(0); |
486 | open_dev_null (0, O_RDONLY); | 485 | open_dev_null(0, O_RDONLY); |
487 | (void) close (1); | 486 | (void)close(1); |
488 | open_dev_null (1, O_WRONLY); | 487 | open_dev_null(1, O_WRONLY); |
489 | (void) execv (file, cmd); | 488 | (void)execv(file, cmd); |
490 | /* can only get here on error */ | 489 | /* can only get here on error */ |
491 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 490 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, |
492 | "exec", | 491 | "exec", |
493 | file); | 492 | file); |
494 | _exit (1); | 493 | _exit(1); |
495 | } | 494 | } |
496 | /* keep running waitpid as long as the only error we get is 'EINTR' */ | 495 | /* keep running waitpid as long as the only error we get is 'EINTR' */ |
497 | while ( (-1 == (ret = waitpid (pid, &status, 0))) && | 496 | while ((-1 == (ret = waitpid(pid, &status, 0))) && |
498 | (errno == EINTR) ); | 497 | (errno == EINTR)) |
498 | ; | ||
499 | if (-1 == ret) | 499 | if (-1 == ret) |
500 | { | 500 | { |
501 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | 501 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, |
502 | "waitpid"); | 502 | "waitpid"); |
503 | return 1; | 503 | return 1; |
504 | } | 504 | } |
505 | if (! (WIFEXITED (status) && | 505 | if (!(WIFEXITED(status) && |
506 | (0 == WEXITSTATUS (status))) ) | 506 | (0 == WEXITSTATUS(status)))) |
507 | { | 507 | { |
508 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 508 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
509 | "Process `%s` returned status code %d/%d.\n", | 509 | "Process `%s` returned status code %d/%d.\n", |
510 | file, | 510 | file, |
511 | WIFEXITED (status), | 511 | WIFEXITED(status), |
512 | WEXITSTATUS (status)); | 512 | WEXITSTATUS(status)); |
513 | return 1; | 513 | return 1; |
514 | } | 514 | } |
515 | /* child process completed and returned success, we're happy */ | 515 | /* child process completed and returned success, we're happy */ |
516 | return 0; | 516 | return 0; |
517 | } | 517 | } |
@@ -553,10 +553,10 @@ fork_and_exec (const char *file, | |||
553 | * must thus no longer be used | 553 | * must thus no longer be used |
554 | */ | 554 | */ |
555 | static void | 555 | static void |
556 | identity_cb (void *cls, | 556 | identity_cb(void *cls, |
557 | struct GNUNET_IDENTITY_Ego *ego, | 557 | struct GNUNET_IDENTITY_Ego *ego, |
558 | void **ctx, | 558 | void **ctx, |
559 | const char *name) | 559 | const char *name) |
560 | { | 560 | { |
561 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key; | 561 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key; |
562 | struct GNUNET_GNSRECORD_Data rd; | 562 | struct GNUNET_GNSRECORD_Data rd; |
@@ -566,59 +566,59 @@ identity_cb (void *cls, | |||
566 | if (NULL == name) | 566 | if (NULL == name) |
567 | return; | 567 | return; |
568 | if (NULL == ego) | 568 | if (NULL == ego) |
569 | { | ||
570 | if (NULL == qe) | ||
571 | { | 569 | { |
572 | fprintf (stderr, | 570 | if (NULL == qe) |
573 | "Failed to find master-zone ego\n"); | 571 | { |
574 | GNUNET_SCHEDULER_shutdown (); | 572 | fprintf(stderr, |
573 | "Failed to find master-zone ego\n"); | ||
574 | GNUNET_SCHEDULER_shutdown(); | ||
575 | return; | ||
576 | } | ||
577 | GNUNET_IDENTITY_disconnect(identity); | ||
578 | identity = NULL; | ||
575 | return; | 579 | return; |
576 | } | 580 | } |
577 | GNUNET_IDENTITY_disconnect (identity); | 581 | GNUNET_assert(NULL != name); |
578 | identity = NULL; | 582 | if (0 != strcmp(name, |
579 | return; | 583 | "master-zone")) |
580 | } | 584 | { |
581 | GNUNET_assert (NULL != name); | 585 | fprintf(stderr, |
582 | if (0 != strcmp (name, | 586 | "Unexpected name %s\n", |
583 | "master-zone")) | 587 | name); |
584 | { | 588 | return; |
585 | fprintf (stderr, | 589 | } |
586 | "Unexpected name %s\n", | 590 | zone_key = GNUNET_IDENTITY_ego_get_private_key(ego); |
587 | name); | ||
588 | return; | ||
589 | } | ||
590 | zone_key = GNUNET_IDENTITY_ego_get_private_key (ego); | ||
591 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 591 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
592 | peername = GNUNET_strdup (GNUNET_i2s_full (&id)); | 592 | peername = GNUNET_strdup(GNUNET_i2s_full(&id)); |
593 | GNUNET_asprintf (&rd_string, | 593 | GNUNET_asprintf(&rd_string, |
594 | "6 %s %s", | 594 | "6 %s %s", |
595 | peername, | 595 | peername, |
596 | "www"); | 596 | "www"); |
597 | GNUNET_free (peername); | 597 | GNUNET_free(peername); |
598 | GNUNET_assert (GNUNET_OK == | 598 | GNUNET_assert(GNUNET_OK == |
599 | GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN, | 599 | GNUNET_GNSRECORD_string_to_value(GNUNET_GNSRECORD_TYPE_VPN, |
600 | rd_string, | 600 | rd_string, |
601 | (void**) &rd.data, | 601 | (void**)&rd.data, |
602 | &rd.data_size)); | 602 | &rd.data_size)); |
603 | rd.record_type = GNUNET_GNSRECORD_TYPE_VPN; | 603 | rd.record_type = GNUNET_GNSRECORD_TYPE_VPN; |
604 | 604 | ||
605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 605 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
606 | "Creating `www` record\n"); | 606 | "Creating `www` record\n"); |
607 | qe = GNUNET_NAMESTORE_records_store (namestore, | 607 | qe = GNUNET_NAMESTORE_records_store(namestore, |
608 | zone_key, | 608 | zone_key, |
609 | "www", | 609 | "www", |
610 | 1, &rd, | 610 | 1, &rd, |
611 | &commence_testing, | 611 | &commence_testing, |
612 | NULL); | 612 | NULL); |
613 | GNUNET_free ((void**)rd.data); | 613 | GNUNET_free((void**)rd.data); |
614 | GNUNET_free (rd_string); | 614 | GNUNET_free(rd_string); |
615 | } | 615 | } |
616 | 616 | ||
617 | 617 | ||
618 | static void | 618 | static void |
619 | run (void *cls, | 619 | run(void *cls, |
620 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 620 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
621 | struct GNUNET_TESTING_Peer *peer) | 621 | struct GNUNET_TESTING_Peer *peer) |
622 | { | 622 | { |
623 | enum MHD_FLAG flags; | 623 | enum MHD_FLAG flags; |
624 | 624 | ||
@@ -628,19 +628,19 @@ run (void *cls, | |||
628 | char *bin_arm; | 628 | char *bin_arm; |
629 | char *config; | 629 | char *config; |
630 | 630 | ||
631 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 631 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
632 | "Test logic starting...\n"); | 632 | "Test logic starting...\n"); |
633 | if (GNUNET_OK != | 633 | if (GNUNET_OK != |
634 | GNUNET_CONFIGURATION_get_value_string (cfg, | 634 | GNUNET_CONFIGURATION_get_value_string(cfg, |
635 | "arm", | 635 | "arm", |
636 | "CONFIG", | 636 | "CONFIG", |
637 | &config)) | 637 | &config)) |
638 | { | 638 | { |
639 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 639 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
640 | "Failed to locate configuration file. Skipping test.\n"); | 640 | "Failed to locate configuration file. Skipping test.\n"); |
641 | GNUNET_SCHEDULER_shutdown (); | 641 | GNUNET_SCHEDULER_shutdown(); |
642 | return; | 642 | return; |
643 | } | 643 | } |
644 | 644 | ||
645 | char *const identity_args[] = | 645 | char *const identity_args[] = |
646 | { | 646 | { |
@@ -680,187 +680,187 @@ run (void *cls, | |||
680 | NULL | 680 | NULL |
681 | }; | 681 | }; |
682 | 682 | ||
683 | GNUNET_TESTING_peer_get_identity (peer, | 683 | GNUNET_TESTING_peer_get_identity(peer, |
684 | &id); | 684 | &id); |
685 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 685 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, |
686 | NULL); | 686 | NULL); |
687 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 687 | timeout_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, |
688 | &do_timeout, | 688 | &do_timeout, |
689 | NULL); | 689 | NULL); |
690 | bin = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); | 690 | bin = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR); |
691 | GNUNET_asprintf (&bin_identity, | 691 | GNUNET_asprintf(&bin_identity, |
692 | "%s/%s", | 692 | "%s/%s", |
693 | bin, | 693 | bin, |
694 | "gnunet-identity"); | 694 | "gnunet-identity"); |
695 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 695 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
696 | "Creating `master-zone` ego\n"); | 696 | "Creating `master-zone` ego\n"); |
697 | if (0 != fork_and_exec (bin_identity, identity_args)) | 697 | if (0 != fork_and_exec(bin_identity, identity_args)) |
698 | { | 698 | { |
699 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 699 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
700 | "Failed to run `gnunet-identity -C`. Skipping test.\n"); | 700 | "Failed to run `gnunet-identity -C`. Skipping test.\n"); |
701 | GNUNET_SCHEDULER_shutdown (); | 701 | GNUNET_SCHEDULER_shutdown(); |
702 | GNUNET_free (bin_identity); | 702 | GNUNET_free(bin_identity); |
703 | GNUNET_free (config); | 703 | GNUNET_free(config); |
704 | GNUNET_free (bin); | 704 | GNUNET_free(bin); |
705 | return; | 705 | return; |
706 | } | 706 | } |
707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 707 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
708 | "Setting `master-zone` ego as default for `gns-master` and `dns2gns`\n"); | 708 | "Setting `master-zone` ego as default for `gns-master` and `dns2gns`\n"); |
709 | if (0 != fork_and_exec (bin_identity, identity2_args)) | 709 | if (0 != fork_and_exec(bin_identity, identity2_args)) |
710 | { | 710 | { |
711 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 711 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
712 | "Failed to run `gnunet-identity -e`. Skipping test.\n"); | 712 | "Failed to run `gnunet-identity -e`. Skipping test.\n"); |
713 | GNUNET_SCHEDULER_shutdown (); | 713 | GNUNET_SCHEDULER_shutdown(); |
714 | GNUNET_free (bin_identity); | 714 | GNUNET_free(bin_identity); |
715 | GNUNET_free (config); | 715 | GNUNET_free(config); |
716 | GNUNET_free (bin); | 716 | GNUNET_free(bin); |
717 | return; | 717 | return; |
718 | } | 718 | } |
719 | if (0 != fork_and_exec (bin_identity, identity3_args)) | 719 | if (0 != fork_and_exec(bin_identity, identity3_args)) |
720 | { | 720 | { |
721 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 721 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
722 | "Failed to run `gnunet-identity -e`. Skipping test.\n"); | 722 | "Failed to run `gnunet-identity -e`. Skipping test.\n"); |
723 | GNUNET_SCHEDULER_shutdown (); | 723 | GNUNET_SCHEDULER_shutdown(); |
724 | GNUNET_free (bin_identity); | 724 | GNUNET_free(bin_identity); |
725 | GNUNET_free (config); | 725 | GNUNET_free(config); |
726 | GNUNET_free (bin); | 726 | GNUNET_free(bin); |
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | GNUNET_free (bin_identity); | 729 | GNUNET_free(bin_identity); |
730 | 730 | ||
731 | /* do lookup just to launch GNS service */ | 731 | /* do lookup just to launch GNS service */ |
732 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 732 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
733 | "Resolving `www.gnu` zone entry to launch GNS (will yield no answer yet)\n"); | 733 | "Resolving `www.gnu` zone entry to launch GNS (will yield no answer yet)\n"); |
734 | GNUNET_asprintf (&bin_gns, | 734 | GNUNET_asprintf(&bin_gns, |
735 | "%s/%s", | 735 | "%s/%s", |
736 | bin, | 736 | bin, |
737 | "gnunet-gns"); | 737 | "gnunet-gns"); |
738 | if (0 != fork_and_exec (bin_gns, | 738 | if (0 != fork_and_exec(bin_gns, |
739 | gns_args)) | 739 | gns_args)) |
740 | { | 740 | { |
741 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 741 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
742 | "Failed to run `gnunet-gns -u. Skipping test.\n"); | 742 | "Failed to run `gnunet-gns -u. Skipping test.\n"); |
743 | GNUNET_SCHEDULER_shutdown (); | 743 | GNUNET_SCHEDULER_shutdown(); |
744 | GNUNET_free (bin_gns); | 744 | GNUNET_free(bin_gns); |
745 | GNUNET_free (config); | 745 | GNUNET_free(config); |
746 | GNUNET_free (bin); | 746 | GNUNET_free(bin); |
747 | return; | 747 | return; |
748 | } | 748 | } |
749 | GNUNET_free (bin_gns); | 749 | GNUNET_free(bin_gns); |
750 | 750 | ||
751 | GNUNET_asprintf (&bin_arm, | 751 | GNUNET_asprintf(&bin_arm, |
752 | "%s/%s", | 752 | "%s/%s", |
753 | bin, | 753 | bin, |
754 | "gnunet-arm"); | 754 | "gnunet-arm"); |
755 | if (0 != fork_and_exec (bin_arm, | 755 | if (0 != fork_and_exec(bin_arm, |
756 | arm_args)) | 756 | arm_args)) |
757 | { | 757 | { |
758 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 758 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
759 | "Failed to run `gnunet-arm -i dns2gns. Skipping test.\n"); | 759 | "Failed to run `gnunet-arm -i dns2gns. Skipping test.\n"); |
760 | GNUNET_SCHEDULER_shutdown (); | 760 | GNUNET_SCHEDULER_shutdown(); |
761 | GNUNET_free (bin_arm); | 761 | GNUNET_free(bin_arm); |
762 | GNUNET_free (config); | 762 | GNUNET_free(config); |
763 | GNUNET_free (bin); | 763 | GNUNET_free(bin); |
764 | return; | 764 | return; |
765 | } | 765 | } |
766 | GNUNET_free (bin_arm); | 766 | GNUNET_free(bin_arm); |
767 | 767 | ||
768 | GNUNET_free (config); | 768 | GNUNET_free(config); |
769 | GNUNET_free (bin); | 769 | GNUNET_free(bin); |
770 | sleep (1); /* give dns2gns chance to really run */ | 770 | sleep(1); /* give dns2gns chance to really run */ |
771 | 771 | ||
772 | namestore = GNUNET_NAMESTORE_connect (cfg); | 772 | namestore = GNUNET_NAMESTORE_connect(cfg); |
773 | GNUNET_assert (NULL != namestore); | 773 | GNUNET_assert(NULL != namestore); |
774 | flags = MHD_USE_DEBUG; | 774 | flags = MHD_USE_DEBUG; |
775 | if (GNUNET_YES == use_v6) | 775 | if (GNUNET_YES == use_v6) |
776 | flags |= MHD_USE_DUAL_STACK; | 776 | flags |= MHD_USE_DUAL_STACK; |
777 | mhd = MHD_start_daemon (flags, | 777 | mhd = MHD_start_daemon(flags, |
778 | PORT, | 778 | PORT, |
779 | NULL, NULL, | 779 | NULL, NULL, |
780 | &mhd_ahc, NULL, | 780 | &mhd_ahc, NULL, |
781 | MHD_OPTION_END); | 781 | MHD_OPTION_END); |
782 | GNUNET_assert (NULL != mhd); | 782 | GNUNET_assert(NULL != mhd); |
783 | mhd_main (); | 783 | mhd_main(); |
784 | 784 | ||
785 | identity = GNUNET_IDENTITY_connect (cfg, | 785 | identity = GNUNET_IDENTITY_connect(cfg, |
786 | &identity_cb, | 786 | &identity_cb, |
787 | NULL); | 787 | NULL); |
788 | } | 788 | } |
789 | 789 | ||
790 | 790 | ||
791 | int | 791 | int |
792 | main (int argc, | 792 | main(int argc, |
793 | char *const *argv) | 793 | char *const *argv) |
794 | { | 794 | { |
795 | char *bin_vpn; | 795 | char *bin_vpn; |
796 | char *bin_exit; | 796 | char *bin_exit; |
797 | 797 | ||
798 | GNUNET_log_setup ("test-gns-vpn", | 798 | GNUNET_log_setup("test-gns-vpn", |
799 | "WARNING", | 799 | "WARNING", |
800 | NULL); | 800 | NULL); |
801 | if (0 != ACCESS ("/dev/net/tun", R_OK)) | 801 | if (0 != ACCESS("/dev/net/tun", R_OK)) |
802 | { | 802 | { |
803 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 803 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, |
804 | "access", | 804 | "access", |
805 | "/dev/net/tun"); | 805 | "/dev/net/tun"); |
806 | fprintf (stderr, | 806 | fprintf(stderr, |
807 | "WARNING: System unable to run test, skipping.\n"); | 807 | "WARNING: System unable to run test, skipping.\n"); |
808 | return 77; | 808 | return 77; |
809 | } | 809 | } |
810 | 810 | ||
811 | bin_vpn = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn"); | 811 | bin_vpn = GNUNET_OS_get_libexec_binary_path("gnunet-helper-vpn"); |
812 | bin_exit = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit"); | 812 | bin_exit = GNUNET_OS_get_libexec_binary_path("gnunet-helper-exit"); |
813 | if ( (0 != geteuid ()) && | 813 | if ((0 != geteuid()) && |
814 | ( (GNUNET_YES != | 814 | ((GNUNET_YES != |
815 | GNUNET_OS_check_helper_binary (bin_vpn, | 815 | GNUNET_OS_check_helper_binary(bin_vpn, |
816 | GNUNET_YES, | 816 | GNUNET_YES, |
817 | "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please! | 817 | "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please! |
818 | (GNUNET_YES != | 818 | (GNUNET_YES != |
819 | GNUNET_OS_check_helper_binary (bin_exit, | 819 | GNUNET_OS_check_helper_binary(bin_exit, |
820 | GNUNET_YES, | 820 | GNUNET_YES, |
821 | "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) ) ) //no nat, ipv4 only | 821 | "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")))) //no nat, ipv4 only |
822 | { | 822 | { |
823 | fprintf (stderr, | 823 | fprintf(stderr, |
824 | "WARNING: gnunet-helper-{exit,vpn} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n"); | 824 | "WARNING: gnunet-helper-{exit,vpn} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n"); |
825 | fprintf (stderr, | 825 | fprintf(stderr, |
826 | "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n"); | 826 | "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n"); |
827 | GNUNET_free (bin_vpn); | 827 | GNUNET_free(bin_vpn); |
828 | GNUNET_free (bin_exit); | 828 | GNUNET_free(bin_exit); |
829 | return 77; | 829 | return 77; |
830 | } | 830 | } |
831 | GNUNET_free (bin_vpn); | 831 | GNUNET_free(bin_vpn); |
832 | GNUNET_free (bin_exit); | 832 | GNUNET_free(bin_exit); |
833 | 833 | ||
834 | dest_ip = "169.254.86.1"; | 834 | dest_ip = "169.254.86.1"; |
835 | dest_af = AF_INET; | 835 | dest_af = AF_INET; |
836 | src_af = AF_INET; | 836 | src_af = AF_INET; |
837 | 837 | ||
838 | if (GNUNET_OK == GNUNET_NETWORK_test_pf (PF_INET6)) | 838 | if (GNUNET_OK == GNUNET_NETWORK_test_pf(PF_INET6)) |
839 | use_v6 = GNUNET_YES; | 839 | use_v6 = GNUNET_YES; |
840 | else | 840 | else |
841 | use_v6 = GNUNET_NO; | 841 | use_v6 = GNUNET_NO; |
842 | 842 | ||
843 | if ( (GNUNET_OK != GNUNET_NETWORK_test_pf (src_af)) || | 843 | if ((GNUNET_OK != GNUNET_NETWORK_test_pf(src_af)) || |
844 | (GNUNET_OK != GNUNET_NETWORK_test_pf (dest_af)) ) | 844 | (GNUNET_OK != GNUNET_NETWORK_test_pf(dest_af))) |
845 | { | 845 | { |
846 | fprintf (stderr, | 846 | fprintf(stderr, |
847 | "Required address families not supported by this system, skipping test.\n"); | 847 | "Required address families not supported by this system, skipping test.\n"); |
848 | return 77; | 848 | return 77; |
849 | } | 849 | } |
850 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) | 850 | if (0 != curl_global_init(CURL_GLOBAL_WIN32)) |
851 | { | 851 | { |
852 | fprintf (stderr, "failed to initialize curl\n"); | 852 | fprintf(stderr, "failed to initialize curl\n"); |
853 | return 2; | 853 | return 2; |
854 | } | 854 | } |
855 | 855 | ||
856 | 856 | ||
857 | if (0 != | 857 | if (0 != |
858 | GNUNET_TESTING_peer_run ("test_gns_vpn", | 858 | GNUNET_TESTING_peer_run("test_gns_vpn", |
859 | "test_gns_vpn.conf", | 859 | "test_gns_vpn.conf", |
860 | &run, | 860 | &run, |
861 | NULL)) | 861 | NULL)) |
862 | return 1; | 862 | return 1; |
863 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-vpn"); | 863 | GNUNET_DISK_directory_remove("/tmp/gnunet-test-vpn"); |
864 | return global_ret; | 864 | return global_ret; |
865 | } | 865 | } |
866 | 866 | ||