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