diff options
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 1266 |
1 files changed, 633 insertions, 633 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index ebc3f402d..6cc342d06 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011-2014, 2016, 2017 GNUnet e.V. | 3 | Copyright (C) 2011-2014, 2016, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
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 | */ |
@@ -34,19 +34,18 @@ | |||
34 | * Timeout for a name resolution | 34 | * Timeout for a name resolution |
35 | */ | 35 | */ |
36 | #define RESOLUTION_TIMEOUT \ | 36 | #define RESOLUTION_TIMEOUT \ |
37 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 37 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Timeout for an operation | 40 | * Timeout for an operation |
41 | */ | 41 | */ |
42 | #define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 42 | #define OP_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) |
43 | 43 | ||
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Context to store name resolutions for valiation | 46 | * Context to store name resolutions for valiation |
47 | */ | 47 | */ |
48 | struct ValidationResolutionContext | 48 | struct ValidationResolutionContext { |
49 | { | ||
50 | /** | 49 | /** |
51 | * Next in DLL | 50 | * Next in DLL |
52 | */ | 51 | */ |
@@ -96,8 +95,7 @@ struct ValidationResolutionContext | |||
96 | /** | 95 | /** |
97 | * Struct to store information about peers in monitor mode | 96 | * Struct to store information about peers in monitor mode |
98 | */ | 97 | */ |
99 | struct MonitoredPeer | 98 | struct MonitoredPeer { |
100 | { | ||
101 | /** | 99 | /** |
102 | * State of the peer | 100 | * State of the peer |
103 | */ | 101 | */ |
@@ -117,8 +115,7 @@ struct MonitoredPeer | |||
117 | /** | 115 | /** |
118 | * Context to store name resolutions for valiation | 116 | * Context to store name resolutions for valiation |
119 | */ | 117 | */ |
120 | struct PeerResolutionContext | 118 | struct PeerResolutionContext { |
121 | { | ||
122 | /** | 119 | /** |
123 | * Next in DLL | 120 | * Next in DLL |
124 | */ | 121 | */ |
@@ -332,15 +329,15 @@ static struct PeerResolutionContext *rc_tail; | |||
332 | * @return #GNUNET_OK (continue to iterate) | 329 | * @return #GNUNET_OK (continue to iterate) |
333 | */ | 330 | */ |
334 | static int | 331 | static int |
335 | destroy_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | 332 | destroy_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
336 | { | 333 | { |
337 | struct MonitoredPeer *m = value; | 334 | struct MonitoredPeer *m = value; |
338 | 335 | ||
339 | GNUNET_assert ( | 336 | GNUNET_assert( |
340 | GNUNET_OK == | 337 | GNUNET_OK == |
341 | GNUNET_CONTAINER_multipeermap_remove (monitored_peers, key, value)); | 338 | GNUNET_CONTAINER_multipeermap_remove(monitored_peers, key, value)); |
342 | GNUNET_free_non_null (m->address); | 339 | GNUNET_free_non_null(m->address); |
343 | GNUNET_free (value); | 340 | GNUNET_free(value); |
344 | return GNUNET_OK; | 341 | return GNUNET_OK; |
345 | } | 342 | } |
346 | 343 | ||
@@ -352,7 +349,7 @@ destroy_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | |||
352 | * @param cls NULL | 349 | * @param cls NULL |
353 | */ | 350 | */ |
354 | static void | 351 | static void |
355 | shutdown_task (void *cls) | 352 | shutdown_task(void *cls) |
356 | { | 353 | { |
357 | struct GNUNET_TIME_Relative duration; | 354 | struct GNUNET_TIME_Relative duration; |
358 | struct ValidationResolutionContext *cur; | 355 | struct ValidationResolutionContext *cur; |
@@ -360,82 +357,82 @@ shutdown_task (void *cls) | |||
360 | struct PeerResolutionContext *rc; | 357 | struct PeerResolutionContext *rc; |
361 | 358 | ||
362 | if (NULL != op_timeout) | 359 | if (NULL != op_timeout) |
363 | { | 360 | { |
364 | GNUNET_SCHEDULER_cancel (op_timeout); | 361 | GNUNET_SCHEDULER_cancel(op_timeout); |
365 | op_timeout = NULL; | 362 | op_timeout = NULL; |
366 | } | 363 | } |
367 | if (NULL != pic) | 364 | if (NULL != pic) |
368 | { | 365 | { |
369 | GNUNET_TRANSPORT_monitor_peers_cancel (pic); | 366 | GNUNET_TRANSPORT_monitor_peers_cancel(pic); |
370 | pic = NULL; | 367 | pic = NULL; |
371 | } | 368 | } |
372 | if (NULL != pm) | 369 | if (NULL != pm) |
373 | { | 370 | { |
374 | GNUNET_TRANSPORT_monitor_plugins_cancel (pm); | 371 | GNUNET_TRANSPORT_monitor_plugins_cancel(pm); |
375 | pm = NULL; | 372 | pm = NULL; |
376 | } | 373 | } |
377 | 374 | ||
378 | next = vc_head; | 375 | next = vc_head; |
379 | for (cur = next; NULL != cur; cur = next) | 376 | for (cur = next; NULL != cur; cur = next) |
380 | { | 377 | { |
381 | next = cur->next; | 378 | next = cur->next; |
382 | 379 | ||
383 | GNUNET_TRANSPORT_address_to_string_cancel (cur->asc); | 380 | GNUNET_TRANSPORT_address_to_string_cancel(cur->asc); |
384 | GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, cur); | 381 | GNUNET_CONTAINER_DLL_remove(vc_head, vc_tail, cur); |
385 | GNUNET_free (cur->transport); | 382 | GNUNET_free(cur->transport); |
386 | GNUNET_HELLO_address_free (cur->addrcp); | 383 | GNUNET_HELLO_address_free(cur->addrcp); |
387 | GNUNET_free (cur); | 384 | GNUNET_free(cur); |
388 | } | 385 | } |
389 | while (NULL != (rc = rc_head)) | 386 | while (NULL != (rc = rc_head)) |
390 | { | 387 | { |
391 | GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc); | 388 | GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, rc); |
392 | GNUNET_TRANSPORT_address_to_string_cancel (rc->asc); | 389 | GNUNET_TRANSPORT_address_to_string_cancel(rc->asc); |
393 | GNUNET_free (rc->transport); | 390 | GNUNET_free(rc->transport); |
394 | GNUNET_free (rc->addrcp); | 391 | GNUNET_free(rc->addrcp); |
395 | GNUNET_free (rc); | 392 | GNUNET_free(rc); |
396 | } | 393 | } |
397 | if (NULL != handle) | 394 | if (NULL != handle) |
398 | { | 395 | { |
399 | GNUNET_TRANSPORT_core_disconnect (handle); | 396 | GNUNET_TRANSPORT_core_disconnect(handle); |
400 | handle = NULL; | 397 | handle = NULL; |
401 | } | 398 | } |
402 | if (benchmark_send) | 399 | if (benchmark_send) |
403 | { | 400 | { |
404 | duration = GNUNET_TIME_absolute_get_duration (start_time); | 401 | duration = GNUNET_TIME_absolute_get_duration(start_time); |
405 | fprintf (stdout, | 402 | fprintf(stdout, |
406 | _ ("Transmitted %llu bytes/s (%llu bytes in %s)\n"), | 403 | _("Transmitted %llu bytes/s (%llu bytes in %s)\n"), |
407 | 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us), | 404 | 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us), |
408 | traffic_sent, | 405 | traffic_sent, |
409 | GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); | 406 | GNUNET_STRINGS_relative_time_to_string(duration, GNUNET_YES)); |
410 | } | 407 | } |
411 | if (benchmark_receive) | 408 | if (benchmark_receive) |
412 | { | 409 | { |
413 | duration = GNUNET_TIME_absolute_get_duration (start_time); | 410 | duration = GNUNET_TIME_absolute_get_duration(start_time); |
414 | fprintf (stdout, | 411 | fprintf(stdout, |
415 | _ ("Received %llu bytes/s (%llu bytes in %s)\n"), | 412 | _("Received %llu bytes/s (%llu bytes in %s)\n"), |
416 | 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us), | 413 | 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us), |
417 | traffic_received, | 414 | traffic_received, |
418 | GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); | 415 | GNUNET_STRINGS_relative_time_to_string(duration, GNUNET_YES)); |
419 | } | 416 | } |
420 | 417 | ||
421 | if (NULL != monitored_peers) | 418 | if (NULL != monitored_peers) |
422 | { | 419 | { |
423 | GNUNET_CONTAINER_multipeermap_iterate (monitored_peers, &destroy_it, NULL); | 420 | GNUNET_CONTAINER_multipeermap_iterate(monitored_peers, &destroy_it, NULL); |
424 | GNUNET_CONTAINER_multipeermap_destroy (monitored_peers); | 421 | GNUNET_CONTAINER_multipeermap_destroy(monitored_peers); |
425 | monitored_peers = NULL; | 422 | monitored_peers = NULL; |
426 | } | 423 | } |
427 | if (NULL != monitored_plugins) | 424 | if (NULL != monitored_plugins) |
428 | { | 425 | { |
429 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (monitored_plugins)); | 426 | GNUNET_break(0 == GNUNET_CONTAINER_multipeermap_size(monitored_plugins)); |
430 | GNUNET_CONTAINER_multipeermap_destroy (monitored_plugins); | 427 | GNUNET_CONTAINER_multipeermap_destroy(monitored_plugins); |
431 | monitored_plugins = NULL; | 428 | monitored_plugins = NULL; |
432 | } | 429 | } |
433 | if (NULL != blacklist) | 430 | if (NULL != blacklist) |
434 | { | 431 | { |
435 | GNUNET_TRANSPORT_blacklist_cancel (blacklist); | 432 | GNUNET_TRANSPORT_blacklist_cancel(blacklist); |
436 | blacklist = NULL; | 433 | blacklist = NULL; |
437 | ret = 0; | 434 | ret = 0; |
438 | } | 435 | } |
439 | } | 436 | } |
440 | 437 | ||
441 | 438 | ||
@@ -443,42 +440,42 @@ shutdown_task (void *cls) | |||
443 | * We are done, shut down. | 440 | * We are done, shut down. |
444 | */ | 441 | */ |
445 | static void | 442 | static void |
446 | operation_timeout (void *cls) | 443 | operation_timeout(void *cls) |
447 | { | 444 | { |
448 | struct PeerResolutionContext *cur; | 445 | struct PeerResolutionContext *cur; |
449 | struct PeerResolutionContext *next; | 446 | struct PeerResolutionContext *next; |
450 | 447 | ||
451 | op_timeout = NULL; | 448 | op_timeout = NULL; |
452 | if ((benchmark_send) || (benchmark_receive)) | 449 | if ((benchmark_send) || (benchmark_receive)) |
453 | { | 450 | { |
454 | fprintf (stdout, _ ("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid)); | 451 | fprintf(stdout, _("Failed to connect to `%s'\n"), GNUNET_i2s_full(&pid)); |
455 | GNUNET_SCHEDULER_shutdown (); | 452 | GNUNET_SCHEDULER_shutdown(); |
456 | ret = 1; | 453 | ret = 1; |
457 | return; | 454 | return; |
458 | } | 455 | } |
459 | if (iterate_connections) | 456 | if (iterate_connections) |
460 | { | ||
461 | next = rc_head; | ||
462 | while (NULL != (cur = next)) | ||
463 | { | 457 | { |
464 | next = cur->next; | 458 | next = rc_head; |
465 | fprintf (stdout, | 459 | while (NULL != (cur = next)) |
466 | _ ("Failed to resolve address for peer `%s'\n"), | 460 | { |
467 | GNUNET_i2s (&cur->addrcp->peer)); | 461 | next = cur->next; |
468 | 462 | fprintf(stdout, | |
469 | GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, cur); | 463 | _("Failed to resolve address for peer `%s'\n"), |
470 | GNUNET_TRANSPORT_address_to_string_cancel (cur->asc); | 464 | GNUNET_i2s(&cur->addrcp->peer)); |
471 | GNUNET_free (cur->transport); | 465 | |
472 | GNUNET_free (cur->addrcp); | 466 | GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur); |
473 | GNUNET_free (cur); | 467 | GNUNET_TRANSPORT_address_to_string_cancel(cur->asc); |
468 | GNUNET_free(cur->transport); | ||
469 | GNUNET_free(cur->addrcp); | ||
470 | GNUNET_free(cur); | ||
471 | } | ||
472 | fprintf(stdout, | ||
473 | "%s", | ||
474 | _("Failed to list connections, timeout occurred\n")); | ||
475 | GNUNET_SCHEDULER_shutdown(); | ||
476 | ret = 1; | ||
477 | return; | ||
474 | } | 478 | } |
475 | fprintf (stdout, | ||
476 | "%s", | ||
477 | _ ("Failed to list connections, timeout occurred\n")); | ||
478 | GNUNET_SCHEDULER_shutdown (); | ||
479 | ret = 1; | ||
480 | return; | ||
481 | } | ||
482 | } | 479 | } |
483 | 480 | ||
484 | 481 | ||
@@ -489,21 +486,21 @@ operation_timeout (void *cls) | |||
489 | * @param cls closure with the message queue | 486 | * @param cls closure with the message queue |
490 | */ | 487 | */ |
491 | static void | 488 | static void |
492 | do_send (void *cls) | 489 | do_send(void *cls) |
493 | { | 490 | { |
494 | struct GNUNET_MQ_Handle *mq = cls; | 491 | struct GNUNET_MQ_Handle *mq = cls; |
495 | struct GNUNET_MessageHeader *m; | 492 | struct GNUNET_MessageHeader *m; |
496 | struct GNUNET_MQ_Envelope *env; | 493 | struct GNUNET_MQ_Envelope *env; |
497 | 494 | ||
498 | env = GNUNET_MQ_msg_extra (m, BLOCKSIZE * 1024, GNUNET_MESSAGE_TYPE_DUMMY); | 495 | env = GNUNET_MQ_msg_extra(m, BLOCKSIZE * 1024, GNUNET_MESSAGE_TYPE_DUMMY); |
499 | memset (&m[1], 52, BLOCKSIZE * 1024 - sizeof (struct GNUNET_MessageHeader)); | 496 | memset(&m[1], 52, BLOCKSIZE * 1024 - sizeof(struct GNUNET_MessageHeader)); |
500 | traffic_sent += BLOCKSIZE * 1024; | 497 | traffic_sent += BLOCKSIZE * 1024; |
501 | GNUNET_MQ_notify_sent (env, &do_send, mq); | 498 | GNUNET_MQ_notify_sent(env, &do_send, mq); |
502 | if (verbosity > 0) | 499 | if (verbosity > 0) |
503 | fprintf (stdout, | 500 | fprintf(stdout, |
504 | _ ("Transmitting %u bytes\n"), | 501 | _("Transmitting %u bytes\n"), |
505 | (unsigned int) BLOCKSIZE * 1024); | 502 | (unsigned int)BLOCKSIZE * 1024); |
506 | GNUNET_MQ_send (mq, env); | 503 | GNUNET_MQ_send(mq, env); |
507 | } | 504 | } |
508 | 505 | ||
509 | 506 | ||
@@ -516,29 +513,29 @@ do_send (void *cls) | |||
516 | * @param mq message queue for sending to @a peer | 513 | * @param mq message queue for sending to @a peer |
517 | */ | 514 | */ |
518 | static void * | 515 | static void * |
519 | notify_connect (void *cls, | 516 | notify_connect(void *cls, |
520 | const struct GNUNET_PeerIdentity *peer, | 517 | const struct GNUNET_PeerIdentity *peer, |
521 | struct GNUNET_MQ_Handle *mq) | 518 | struct GNUNET_MQ_Handle *mq) |
522 | { | 519 | { |
523 | if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) | 520 | if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity))) |
524 | return NULL; | 521 | return NULL; |
525 | ret = 0; | 522 | ret = 0; |
526 | if (! benchmark_send) | 523 | if (!benchmark_send) |
527 | return NULL; | 524 | return NULL; |
528 | if (NULL != op_timeout) | 525 | if (NULL != op_timeout) |
529 | { | 526 | { |
530 | GNUNET_SCHEDULER_cancel (op_timeout); | 527 | GNUNET_SCHEDULER_cancel(op_timeout); |
531 | op_timeout = NULL; | 528 | op_timeout = NULL; |
532 | } | 529 | } |
533 | if (verbosity > 0) | 530 | if (verbosity > 0) |
534 | fprintf ( | 531 | fprintf( |
535 | stdout, | 532 | stdout, |
536 | _ ( | 533 | _( |
537 | "Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"), | 534 | "Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"), |
538 | GNUNET_i2s (peer), | 535 | GNUNET_i2s(peer), |
539 | BLOCKSIZE); | 536 | BLOCKSIZE); |
540 | start_time = GNUNET_TIME_absolute_get (); | 537 | start_time = GNUNET_TIME_absolute_get(); |
541 | do_send (mq); | 538 | do_send(mq); |
542 | return mq; | 539 | return mq; |
543 | } | 540 | } |
544 | 541 | ||
@@ -552,19 +549,19 @@ notify_connect (void *cls, | |||
552 | * @param internal_cls what we returned from #notify_connect() | 549 | * @param internal_cls what we returned from #notify_connect() |
553 | */ | 550 | */ |
554 | static void | 551 | static void |
555 | notify_disconnect (void *cls, | 552 | notify_disconnect(void *cls, |
556 | const struct GNUNET_PeerIdentity *peer, | 553 | const struct GNUNET_PeerIdentity *peer, |
557 | void *internal_cls) | 554 | void *internal_cls) |
558 | { | 555 | { |
559 | if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) | 556 | if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity))) |
560 | return; | 557 | return; |
561 | if (NULL == internal_cls) | 558 | if (NULL == internal_cls) |
562 | return; /* not about target peer */ | 559 | return; /* not about target peer */ |
563 | if (! benchmark_send) | 560 | if (!benchmark_send) |
564 | return; /* not transmitting */ | 561 | return; /* not transmitting */ |
565 | fprintf (stdout, | 562 | fprintf(stdout, |
566 | _ ("Disconnected from peer `%s' while benchmarking\n"), | 563 | _("Disconnected from peer `%s' while benchmarking\n"), |
567 | GNUNET_i2s (&pid)); | 564 | GNUNET_i2s(&pid)); |
568 | } | 565 | } |
569 | 566 | ||
570 | 567 | ||
@@ -578,20 +575,20 @@ notify_disconnect (void *cls, | |||
578 | * @return NULL | 575 | * @return NULL |
579 | */ | 576 | */ |
580 | static void * | 577 | static void * |
581 | monitor_notify_connect (void *cls, | 578 | monitor_notify_connect(void *cls, |
582 | const struct GNUNET_PeerIdentity *peer, | 579 | const struct GNUNET_PeerIdentity *peer, |
583 | struct GNUNET_MQ_Handle *mq) | 580 | struct GNUNET_MQ_Handle *mq) |
584 | { | 581 | { |
585 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 582 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); |
586 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); | 583 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string(now); |
587 | 584 | ||
588 | monitor_connect_counter++; | 585 | monitor_connect_counter++; |
589 | fprintf (stdout, | 586 | fprintf(stdout, |
590 | _ ("%24s: %-17s %4s (%u connections in total)\n"), | 587 | _("%24s: %-17s %4s (%u connections in total)\n"), |
591 | now_str, | 588 | now_str, |
592 | _ ("Connected to"), | 589 | _("Connected to"), |
593 | GNUNET_i2s (peer), | 590 | GNUNET_i2s(peer), |
594 | monitor_connect_counter); | 591 | monitor_connect_counter); |
595 | return NULL; | 592 | return NULL; |
596 | } | 593 | } |
597 | 594 | ||
@@ -605,22 +602,22 @@ monitor_notify_connect (void *cls, | |||
605 | * @param internal_cls what we returned from #monitor_notify_connect() | 602 | * @param internal_cls what we returned from #monitor_notify_connect() |
606 | */ | 603 | */ |
607 | static void | 604 | static void |
608 | monitor_notify_disconnect (void *cls, | 605 | monitor_notify_disconnect(void *cls, |
609 | const struct GNUNET_PeerIdentity *peer, | 606 | const struct GNUNET_PeerIdentity *peer, |
610 | void *internal_cls) | 607 | void *internal_cls) |
611 | { | 608 | { |
612 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 609 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); |
613 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); | 610 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string(now); |
614 | 611 | ||
615 | GNUNET_assert (monitor_connect_counter > 0); | 612 | GNUNET_assert(monitor_connect_counter > 0); |
616 | monitor_connect_counter--; | 613 | monitor_connect_counter--; |
617 | 614 | ||
618 | fprintf (stdout, | 615 | fprintf(stdout, |
619 | _ ("%24s: %-17s %4s (%u connections in total)\n"), | 616 | _("%24s: %-17s %4s (%u connections in total)\n"), |
620 | now_str, | 617 | now_str, |
621 | _ ("Disconnected from"), | 618 | _("Disconnected from"), |
622 | GNUNET_i2s (peer), | 619 | GNUNET_i2s(peer), |
623 | monitor_connect_counter); | 620 | monitor_connect_counter); |
624 | } | 621 | } |
625 | 622 | ||
626 | 623 | ||
@@ -632,7 +629,7 @@ monitor_notify_disconnect (void *cls, | |||
632 | * @return #GNUNET_OK | 629 | * @return #GNUNET_OK |
633 | */ | 630 | */ |
634 | static int | 631 | static int |
635 | check_dummy (void *cls, const struct GNUNET_MessageHeader *message) | 632 | check_dummy(void *cls, const struct GNUNET_MessageHeader *message) |
636 | { | 633 | { |
637 | return GNUNET_OK; /* all messages are fine */ | 634 | return GNUNET_OK; /* all messages are fine */ |
638 | } | 635 | } |
@@ -645,17 +642,17 @@ check_dummy (void *cls, const struct GNUNET_MessageHeader *message) | |||
645 | * @param message the message | 642 | * @param message the message |
646 | */ | 643 | */ |
647 | static void | 644 | static void |
648 | handle_dummy (void *cls, const struct GNUNET_MessageHeader *message) | 645 | handle_dummy(void *cls, const struct GNUNET_MessageHeader *message) |
649 | { | 646 | { |
650 | if (! benchmark_receive) | 647 | if (!benchmark_receive) |
651 | return; | 648 | return; |
652 | if (verbosity > 0) | 649 | if (verbosity > 0) |
653 | fprintf (stdout, | 650 | fprintf(stdout, |
654 | _ ("Received %u bytes\n"), | 651 | _("Received %u bytes\n"), |
655 | (unsigned int) ntohs (message->size)); | 652 | (unsigned int)ntohs(message->size)); |
656 | if (0 == traffic_received) | 653 | if (0 == traffic_received) |
657 | start_time = GNUNET_TIME_absolute_get (); | 654 | start_time = GNUNET_TIME_absolute_get(); |
658 | traffic_received += ntohs (message->size); | 655 | traffic_received += ntohs(message->size); |
659 | } | 656 | } |
660 | 657 | ||
661 | 658 | ||
@@ -669,41 +666,40 @@ handle_dummy (void *cls, const struct GNUNET_MessageHeader *message) | |||
669 | * @param state_timeout when will the peer's state expire | 666 | * @param state_timeout when will the peer's state expire |
670 | */ | 667 | */ |
671 | static void | 668 | static void |
672 | resolve_peer_address (const struct GNUNET_HELLO_Address *address, | 669 | resolve_peer_address(const struct GNUNET_HELLO_Address *address, |
673 | int numeric, | 670 | int numeric, |
674 | enum GNUNET_TRANSPORT_PeerState state, | 671 | enum GNUNET_TRANSPORT_PeerState state, |
675 | struct GNUNET_TIME_Absolute state_timeout); | 672 | struct GNUNET_TIME_Absolute state_timeout); |
676 | 673 | ||
677 | 674 | ||
678 | static void | 675 | static void |
679 | print_info (const struct GNUNET_PeerIdentity *id, | 676 | print_info(const struct GNUNET_PeerIdentity *id, |
680 | const char *transport, | 677 | const char *transport, |
681 | const char *addr, | 678 | const char *addr, |
682 | enum GNUNET_TRANSPORT_PeerState state, | 679 | enum GNUNET_TRANSPORT_PeerState state, |
683 | struct GNUNET_TIME_Absolute state_timeout) | 680 | struct GNUNET_TIME_Absolute state_timeout) |
684 | { | 681 | { |
685 | |||
686 | if (((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) || | 682 | if (((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) || |
687 | (GNUNET_YES == monitor_connections)) | 683 | (GNUNET_YES == monitor_connections)) |
688 | { | 684 | { |
689 | fprintf (stdout, | 685 | fprintf(stdout, |
690 | _ ("Peer `%s': %s %s in state `%s' until %s\n"), | 686 | _("Peer `%s': %s %s in state `%s' until %s\n"), |
691 | GNUNET_i2s (id), | 687 | GNUNET_i2s(id), |
692 | (NULL == transport) ? "<none>" : transport, | 688 | (NULL == transport) ? "<none>" : transport, |
693 | (NULL == transport) ? "<none>" : addr, | 689 | (NULL == transport) ? "<none>" : addr, |
694 | GNUNET_TRANSPORT_ps2s (state), | 690 | GNUNET_TRANSPORT_ps2s(state), |
695 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | 691 | GNUNET_STRINGS_absolute_time_to_string(state_timeout)); |
696 | } | 692 | } |
697 | else if ((GNUNET_YES == iterate_connections) && | 693 | else if ((GNUNET_YES == iterate_connections) && |
698 | (GNUNET_TRANSPORT_is_connected (state))) | 694 | (GNUNET_TRANSPORT_is_connected(state))) |
699 | { | 695 | { |
700 | /* Only connected peers, skip state */ | 696 | /* Only connected peers, skip state */ |
701 | fprintf (stdout, | 697 | fprintf(stdout, |
702 | _ ("Peer `%s': %s %s\n"), | 698 | _("Peer `%s': %s %s\n"), |
703 | GNUNET_i2s (id), | 699 | GNUNET_i2s(id), |
704 | transport, | 700 | transport, |
705 | addr); | 701 | addr); |
706 | } | 702 | } |
707 | } | 703 | } |
708 | 704 | ||
709 | 705 | ||
@@ -724,82 +720,82 @@ print_info (const struct GNUNET_PeerIdentity *id, | |||
724 | * if #GNUNET_SYSERR: communication error (IPC error) | 720 | * if #GNUNET_SYSERR: communication error (IPC error) |
725 | */ | 721 | */ |
726 | static void | 722 | static void |
727 | process_peer_string (void *cls, const char *address, int res) | 723 | process_peer_string(void *cls, const char *address, int res) |
728 | { | 724 | { |
729 | struct PeerResolutionContext *rc = cls; | 725 | struct PeerResolutionContext *rc = cls; |
730 | 726 | ||
731 | if (NULL != address) | 727 | if (NULL != address) |
732 | { | ||
733 | if (GNUNET_SYSERR == res) | ||
734 | { | 728 | { |
735 | fprintf ( | 729 | if (GNUNET_SYSERR == res) |
736 | stderr, | 730 | { |
737 | "Failed to convert address for peer `%s' plugin `%s' length %u to string \n", | 731 | fprintf( |
738 | GNUNET_i2s (&rc->addrcp->peer), | 732 | stderr, |
739 | rc->addrcp->transport_name, | 733 | "Failed to convert address for peer `%s' plugin `%s' length %u to string \n", |
740 | (unsigned int) rc->addrcp->address_length); | 734 | GNUNET_i2s(&rc->addrcp->peer), |
741 | print_info (&rc->addrcp->peer, | 735 | rc->addrcp->transport_name, |
742 | rc->transport, | 736 | (unsigned int)rc->addrcp->address_length); |
743 | NULL, | 737 | print_info(&rc->addrcp->peer, |
744 | rc->state, | 738 | rc->transport, |
745 | rc->state_timeout); | 739 | NULL, |
746 | rc->printed = GNUNET_YES; | 740 | rc->state, |
741 | rc->state_timeout); | ||
742 | rc->printed = GNUNET_YES; | ||
743 | return; | ||
744 | } | ||
745 | if (GNUNET_OK == res) | ||
746 | { | ||
747 | print_info(&rc->addrcp->peer, | ||
748 | rc->transport, | ||
749 | address, | ||
750 | rc->state, | ||
751 | rc->state_timeout); | ||
752 | rc->printed = GNUNET_YES; | ||
753 | return; /* Wait for done call */ | ||
754 | } | ||
755 | /* GNUNET_NO == res: ignore, was simply not supported */ | ||
747 | return; | 756 | return; |
748 | } | 757 | } |
749 | if (GNUNET_OK == res) | ||
750 | { | ||
751 | print_info (&rc->addrcp->peer, | ||
752 | rc->transport, | ||
753 | address, | ||
754 | rc->state, | ||
755 | rc->state_timeout); | ||
756 | rc->printed = GNUNET_YES; | ||
757 | return; /* Wait for done call */ | ||
758 | } | ||
759 | /* GNUNET_NO == res: ignore, was simply not supported */ | ||
760 | return; | ||
761 | } | ||
762 | /* NULL == address, last call, we are done */ | 758 | /* NULL == address, last call, we are done */ |
763 | 759 | ||
764 | rc->asc = NULL; | 760 | rc->asc = NULL; |
765 | GNUNET_assert (address_resolutions > 0); | 761 | GNUNET_assert(address_resolutions > 0); |
766 | address_resolutions--; | 762 | address_resolutions--; |
767 | if (GNUNET_NO == rc->printed) | 763 | if (GNUNET_NO == rc->printed) |
768 | { | ||
769 | if (numeric == GNUNET_NO) | ||
770 | { | ||
771 | /* Failed to resolve address, try numeric lookup | ||
772 | (note: this should not be needed, as transport | ||
773 | should fallback to numeric conversion if DNS takes | ||
774 | too long) */ | ||
775 | resolve_peer_address (rc->addrcp, | ||
776 | GNUNET_YES, | ||
777 | rc->state, | ||
778 | rc->state_timeout); | ||
779 | } | ||
780 | else | ||
781 | { | 764 | { |
782 | print_info (&rc->addrcp->peer, | 765 | if (numeric == GNUNET_NO) |
783 | rc->transport, | 766 | { |
784 | NULL, | 767 | /* Failed to resolve address, try numeric lookup |
785 | rc->state, | 768 | (note: this should not be needed, as transport |
786 | rc->state_timeout); | 769 | should fallback to numeric conversion if DNS takes |
770 | too long) */ | ||
771 | resolve_peer_address(rc->addrcp, | ||
772 | GNUNET_YES, | ||
773 | rc->state, | ||
774 | rc->state_timeout); | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | print_info(&rc->addrcp->peer, | ||
779 | rc->transport, | ||
780 | NULL, | ||
781 | rc->state, | ||
782 | rc->state_timeout); | ||
783 | } | ||
787 | } | 784 | } |
788 | } | 785 | GNUNET_free(rc->transport); |
789 | GNUNET_free (rc->transport); | 786 | GNUNET_free(rc->addrcp); |
790 | GNUNET_free (rc->addrcp); | 787 | GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, rc); |
791 | GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc); | 788 | GNUNET_free(rc); |
792 | GNUNET_free (rc); | ||
793 | if ((0 == address_resolutions) && (iterate_connections)) | 789 | if ((0 == address_resolutions) && (iterate_connections)) |
794 | { | ||
795 | if (NULL != op_timeout) | ||
796 | { | 790 | { |
797 | GNUNET_SCHEDULER_cancel (op_timeout); | 791 | if (NULL != op_timeout) |
798 | op_timeout = NULL; | 792 | { |
793 | GNUNET_SCHEDULER_cancel(op_timeout); | ||
794 | op_timeout = NULL; | ||
795 | } | ||
796 | ret = 0; | ||
797 | GNUNET_SCHEDULER_shutdown(); | ||
799 | } | 798 | } |
800 | ret = 0; | ||
801 | GNUNET_SCHEDULER_shutdown (); | ||
802 | } | ||
803 | } | 799 | } |
804 | 800 | ||
805 | 801 | ||
@@ -814,28 +810,28 @@ process_peer_string (void *cls, const char *address, int res) | |||
814 | * @param state_timeout when will the peer's state expire | 810 | * @param state_timeout when will the peer's state expire |
815 | */ | 811 | */ |
816 | static void | 812 | static void |
817 | resolve_peer_address (const struct GNUNET_HELLO_Address *address, | 813 | resolve_peer_address(const struct GNUNET_HELLO_Address *address, |
818 | int numeric, | 814 | int numeric, |
819 | enum GNUNET_TRANSPORT_PeerState state, | 815 | enum GNUNET_TRANSPORT_PeerState state, |
820 | struct GNUNET_TIME_Absolute state_timeout) | 816 | struct GNUNET_TIME_Absolute state_timeout) |
821 | { | 817 | { |
822 | struct PeerResolutionContext *rc; | 818 | struct PeerResolutionContext *rc; |
823 | 819 | ||
824 | rc = GNUNET_new (struct PeerResolutionContext); | 820 | rc = GNUNET_new(struct PeerResolutionContext); |
825 | GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc); | 821 | GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc); |
826 | address_resolutions++; | 822 | address_resolutions++; |
827 | rc->transport = GNUNET_strdup (address->transport_name); | 823 | rc->transport = GNUNET_strdup(address->transport_name); |
828 | rc->addrcp = GNUNET_HELLO_address_copy (address); | 824 | rc->addrcp = GNUNET_HELLO_address_copy(address); |
829 | rc->printed = GNUNET_NO; | 825 | rc->printed = GNUNET_NO; |
830 | rc->state = state; | 826 | rc->state = state; |
831 | rc->state_timeout = state_timeout; | 827 | rc->state_timeout = state_timeout; |
832 | /* Resolve address to string */ | 828 | /* Resolve address to string */ |
833 | rc->asc = GNUNET_TRANSPORT_address_to_string (cfg, | 829 | rc->asc = GNUNET_TRANSPORT_address_to_string(cfg, |
834 | address, | 830 | address, |
835 | numeric, | 831 | numeric, |
836 | RESOLUTION_TIMEOUT, | 832 | RESOLUTION_TIMEOUT, |
837 | &process_peer_string, | 833 | &process_peer_string, |
838 | rc); | 834 | rc); |
839 | } | 835 | } |
840 | 836 | ||
841 | 837 | ||
@@ -850,46 +846,44 @@ resolve_peer_address (const struct GNUNET_HELLO_Address *address, | |||
850 | * @param state_timeout time out for the current state | 846 | * @param state_timeout time out for the current state |
851 | */ | 847 | */ |
852 | static void | 848 | static void |
853 | process_peer_iteration_cb (void *cls, | 849 | process_peer_iteration_cb(void *cls, |
854 | const struct GNUNET_PeerIdentity *peer, | 850 | const struct GNUNET_PeerIdentity *peer, |
855 | const struct GNUNET_HELLO_Address *address, | 851 | const struct GNUNET_HELLO_Address *address, |
856 | enum GNUNET_TRANSPORT_PeerState state, | 852 | enum GNUNET_TRANSPORT_PeerState state, |
857 | struct GNUNET_TIME_Absolute state_timeout) | 853 | struct GNUNET_TIME_Absolute state_timeout) |
858 | { | 854 | { |
859 | if (NULL == peer) | 855 | if (NULL == peer) |
860 | { | 856 | { |
861 | /* done */ | 857 | /* done */ |
862 | pic = NULL; | 858 | pic = NULL; |
863 | return; | 859 | return; |
864 | } | 860 | } |
865 | 861 | ||
866 | if ((GNUNET_NO == iterate_all) && | 862 | if ((GNUNET_NO == iterate_all) && |
867 | (GNUNET_NO == GNUNET_TRANSPORT_is_connected (state))) | 863 | (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state))) |
868 | return; /* Display only connected peers */ | 864 | return; /* Display only connected peers */ |
869 | 865 | ||
870 | if (NULL != op_timeout) | 866 | if (NULL != op_timeout) |
871 | GNUNET_SCHEDULER_cancel (op_timeout); | 867 | GNUNET_SCHEDULER_cancel(op_timeout); |
872 | op_timeout = | 868 | op_timeout = |
873 | GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, NULL); | 869 | GNUNET_SCHEDULER_add_delayed(OP_TIMEOUT, &operation_timeout, NULL); |
874 | 870 | ||
875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 871 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
876 | "Received address for peer `%s': %s\n", | 872 | "Received address for peer `%s': %s\n", |
877 | GNUNET_i2s (peer), | 873 | GNUNET_i2s(peer), |
878 | address ? address->transport_name : ""); | 874 | address ? address->transport_name : ""); |
879 | 875 | ||
880 | if (NULL != address) | 876 | if (NULL != address) |
881 | resolve_peer_address (address, numeric, state, state_timeout); | 877 | resolve_peer_address(address, numeric, state, state_timeout); |
882 | else | 878 | else |
883 | print_info (peer, NULL, NULL, state, state_timeout); | 879 | print_info(peer, NULL, NULL, state, state_timeout); |
884 | } | 880 | } |
885 | 881 | ||
886 | 882 | ||
887 | /** | 883 | /** |
888 | * Context for address resolution by #plugin_monitoring_cb(). | 884 | * Context for address resolution by #plugin_monitoring_cb(). |
889 | */ | 885 | */ |
890 | struct PluginMonitorAddress | 886 | struct PluginMonitorAddress { |
891 | { | ||
892 | |||
893 | /** | 887 | /** |
894 | * Ongoing resolution request. | 888 | * Ongoing resolution request. |
895 | */ | 889 | */ |
@@ -915,52 +909,57 @@ struct PluginMonitorAddress | |||
915 | * @param info the monitoring information | 909 | * @param info the monitoring information |
916 | */ | 910 | */ |
917 | static void | 911 | static void |
918 | print_plugin_event_info (struct PluginMonitorAddress *addr, | 912 | print_plugin_event_info(struct PluginMonitorAddress *addr, |
919 | const struct GNUNET_TRANSPORT_SessionInfo *info) | 913 | const struct GNUNET_TRANSPORT_SessionInfo *info) |
920 | { | 914 | { |
921 | const char *state; | 915 | const char *state; |
922 | 916 | ||
923 | switch (info->state) | 917 | switch (info->state) |
924 | { | 918 | { |
925 | case GNUNET_TRANSPORT_SS_INIT: | 919 | case GNUNET_TRANSPORT_SS_INIT: |
926 | state = "INIT"; | 920 | state = "INIT"; |
927 | break; | 921 | break; |
928 | case GNUNET_TRANSPORT_SS_HANDSHAKE: | 922 | |
929 | state = "HANDSHAKE"; | 923 | case GNUNET_TRANSPORT_SS_HANDSHAKE: |
930 | break; | 924 | state = "HANDSHAKE"; |
931 | case GNUNET_TRANSPORT_SS_UP: | 925 | break; |
932 | state = "UP"; | 926 | |
933 | break; | 927 | case GNUNET_TRANSPORT_SS_UP: |
934 | case GNUNET_TRANSPORT_SS_UPDATE: | 928 | state = "UP"; |
935 | state = "UPDATE"; | 929 | break; |
936 | break; | 930 | |
937 | case GNUNET_TRANSPORT_SS_DONE: | 931 | case GNUNET_TRANSPORT_SS_UPDATE: |
938 | state = "DONE"; | 932 | state = "UPDATE"; |
939 | break; | 933 | break; |
940 | default: | 934 | |
941 | state = "UNKNOWN"; | 935 | case GNUNET_TRANSPORT_SS_DONE: |
942 | break; | 936 | state = "DONE"; |
943 | } | 937 | break; |
944 | fprintf (stdout, | 938 | |
945 | "%s: state %s timeout in %s @ %s%s\n", | 939 | default: |
946 | GNUNET_i2s (&info->address->peer), | 940 | state = "UNKNOWN"; |
947 | state, | 941 | break; |
948 | GNUNET_STRINGS_relative_time_to_string ( | 942 | } |
949 | GNUNET_TIME_absolute_get_remaining (info->session_timeout), | 943 | fprintf(stdout, |
950 | GNUNET_YES), | 944 | "%s: state %s timeout in %s @ %s%s\n", |
951 | addr->str, | 945 | GNUNET_i2s(&info->address->peer), |
952 | (info->is_inbound == GNUNET_YES) ? " (INBOUND)" : ""); | 946 | state, |
953 | fprintf (stdout, | 947 | GNUNET_STRINGS_relative_time_to_string( |
954 | "%s: queue has %3u messages and %6u bytes\n", | 948 | GNUNET_TIME_absolute_get_remaining(info->session_timeout), |
955 | GNUNET_i2s (&info->address->peer), | 949 | GNUNET_YES), |
956 | info->num_msg_pending, | 950 | addr->str, |
957 | info->num_bytes_pending); | 951 | (info->is_inbound == GNUNET_YES) ? " (INBOUND)" : ""); |
952 | fprintf(stdout, | ||
953 | "%s: queue has %3u messages and %6u bytes\n", | ||
954 | GNUNET_i2s(&info->address->peer), | ||
955 | info->num_msg_pending, | ||
956 | info->num_bytes_pending); | ||
958 | if (0 != | 957 | if (0 != |
959 | GNUNET_TIME_absolute_get_remaining (info->receive_delay).rel_value_us) | 958 | GNUNET_TIME_absolute_get_remaining(info->receive_delay).rel_value_us) |
960 | fprintf (stdout, | 959 | fprintf(stdout, |
961 | "%s: receiving blocked until %s\n", | 960 | "%s: receiving blocked until %s\n", |
962 | GNUNET_i2s (&info->address->peer), | 961 | GNUNET_i2s(&info->address->peer), |
963 | GNUNET_STRINGS_absolute_time_to_string (info->receive_delay)); | 962 | GNUNET_STRINGS_absolute_time_to_string(info->receive_delay)); |
964 | } | 963 | } |
965 | 964 | ||
966 | 965 | ||
@@ -981,19 +980,19 @@ print_plugin_event_info (struct PluginMonitorAddress *addr, | |||
981 | * if #GNUNET_SYSERR: communication error (IPC error) | 980 | * if #GNUNET_SYSERR: communication error (IPC error) |
982 | */ | 981 | */ |
983 | static void | 982 | static void |
984 | address_cb (void *cls, const char *address, int res) | 983 | address_cb(void *cls, const char *address, int res) |
985 | { | 984 | { |
986 | struct PluginMonitorAddress *addr = cls; | 985 | struct PluginMonitorAddress *addr = cls; |
987 | 986 | ||
988 | if (NULL == address) | 987 | if (NULL == address) |
989 | { | 988 | { |
990 | addr->asc = NULL; | 989 | addr->asc = NULL; |
991 | return; | 990 | return; |
992 | } | 991 | } |
993 | if (NULL != addr->str) | 992 | if (NULL != addr->str) |
994 | return; | 993 | return; |
995 | addr->str = GNUNET_strdup (address); | 994 | addr->str = GNUNET_strdup(address); |
996 | print_plugin_event_info (addr, &addr->si); | 995 | print_plugin_event_info(addr, &addr->si); |
997 | } | 996 | } |
998 | 997 | ||
999 | 998 | ||
@@ -1015,10 +1014,10 @@ address_cb (void *cls, const char *address, int res) | |||
1015 | * was being cancelled while sessions were active | 1014 | * was being cancelled while sessions were active |
1016 | */ | 1015 | */ |
1017 | static void | 1016 | static void |
1018 | plugin_monitoring_cb (void *cls, | 1017 | plugin_monitoring_cb(void *cls, |
1019 | struct GNUNET_TRANSPORT_PluginSession *session, | 1018 | struct GNUNET_TRANSPORT_PluginSession *session, |
1020 | void **session_ctx, | 1019 | void **session_ctx, |
1021 | const struct GNUNET_TRANSPORT_SessionInfo *info) | 1020 | const struct GNUNET_TRANSPORT_SessionInfo *info) |
1022 | { | 1021 | { |
1023 | struct PluginMonitorAddress *addr; | 1022 | struct PluginMonitorAddress *addr; |
1024 | 1023 | ||
@@ -1026,50 +1025,50 @@ plugin_monitoring_cb (void *cls, | |||
1026 | return; /* in sync with transport service */ | 1025 | return; /* in sync with transport service */ |
1027 | addr = *session_ctx; | 1026 | addr = *session_ctx; |
1028 | if (NULL == info) | 1027 | if (NULL == info) |
1029 | { | ||
1030 | if (NULL != addr) | ||
1031 | { | 1028 | { |
1032 | if (NULL != addr->asc) | 1029 | if (NULL != addr) |
1033 | { | 1030 | { |
1034 | GNUNET_TRANSPORT_address_to_string_cancel (addr->asc); | 1031 | if (NULL != addr->asc) |
1035 | addr->asc = NULL; | 1032 | { |
1036 | } | 1033 | GNUNET_TRANSPORT_address_to_string_cancel(addr->asc); |
1037 | GNUNET_free_non_null (addr->str); | 1034 | addr->asc = NULL; |
1038 | GNUNET_free (addr); | 1035 | } |
1039 | *session_ctx = NULL; | 1036 | GNUNET_free_non_null(addr->str); |
1037 | GNUNET_free(addr); | ||
1038 | *session_ctx = NULL; | ||
1039 | } | ||
1040 | return; /* shutdown */ | ||
1040 | } | 1041 | } |
1041 | return; /* shutdown */ | ||
1042 | } | ||
1043 | if (0 != | 1042 | if (0 != |
1044 | memcmp (&info->address->peer, &pid, sizeof (struct GNUNET_PeerIdentity))) | 1043 | memcmp(&info->address->peer, &pid, sizeof(struct GNUNET_PeerIdentity))) |
1045 | return; /* filtered */ | 1044 | return; /* filtered */ |
1046 | if (NULL == addr) | 1045 | if (NULL == addr) |
1047 | { | 1046 | { |
1048 | addr = GNUNET_new (struct PluginMonitorAddress); | 1047 | addr = GNUNET_new(struct PluginMonitorAddress); |
1049 | addr->asc = | 1048 | addr->asc = |
1050 | GNUNET_TRANSPORT_address_to_string (cfg, | 1049 | GNUNET_TRANSPORT_address_to_string(cfg, |
1051 | info->address, | 1050 | info->address, |
1052 | numeric, | 1051 | numeric, |
1053 | GNUNET_TIME_UNIT_FOREVER_REL, | 1052 | GNUNET_TIME_UNIT_FOREVER_REL, |
1054 | &address_cb, | 1053 | &address_cb, |
1055 | addr); | 1054 | addr); |
1056 | *session_ctx = addr; | 1055 | *session_ctx = addr; |
1057 | } | 1056 | } |
1058 | if (NULL == addr->str) | 1057 | if (NULL == addr->str) |
1059 | addr->si = *info; | 1058 | addr->si = *info; |
1060 | else | 1059 | else |
1061 | print_plugin_event_info (addr, info); | 1060 | print_plugin_event_info(addr, info); |
1062 | if (GNUNET_TRANSPORT_SS_DONE == info->state) | 1061 | if (GNUNET_TRANSPORT_SS_DONE == info->state) |
1063 | { | ||
1064 | if (NULL != addr->asc) | ||
1065 | { | 1062 | { |
1066 | GNUNET_TRANSPORT_address_to_string_cancel (addr->asc); | 1063 | if (NULL != addr->asc) |
1067 | addr->asc = NULL; | 1064 | { |
1065 | GNUNET_TRANSPORT_address_to_string_cancel(addr->asc); | ||
1066 | addr->asc = NULL; | ||
1067 | } | ||
1068 | GNUNET_free_non_null(addr->str); | ||
1069 | GNUNET_free(addr); | ||
1070 | *session_ctx = NULL; | ||
1068 | } | 1071 | } |
1069 | GNUNET_free_non_null (addr->str); | ||
1070 | GNUNET_free (addr); | ||
1071 | *session_ctx = NULL; | ||
1072 | } | ||
1073 | } | 1072 | } |
1074 | 1073 | ||
1075 | 1074 | ||
@@ -1084,64 +1083,64 @@ plugin_monitoring_cb (void *cls, | |||
1084 | * @param state_timeout time out for the current state | 1083 | * @param state_timeout time out for the current state |
1085 | */ | 1084 | */ |
1086 | static void | 1085 | static void |
1087 | process_peer_monitoring_cb (void *cls, | 1086 | process_peer_monitoring_cb(void *cls, |
1088 | const struct GNUNET_PeerIdentity *peer, | 1087 | const struct GNUNET_PeerIdentity *peer, |
1089 | const struct GNUNET_HELLO_Address *address, | 1088 | const struct GNUNET_HELLO_Address *address, |
1090 | enum GNUNET_TRANSPORT_PeerState state, | 1089 | enum GNUNET_TRANSPORT_PeerState state, |
1091 | struct GNUNET_TIME_Absolute state_timeout) | 1090 | struct GNUNET_TIME_Absolute state_timeout) |
1092 | { | 1091 | { |
1093 | struct MonitoredPeer *m; | 1092 | struct MonitoredPeer *m; |
1094 | 1093 | ||
1095 | if (NULL == peer) | 1094 | if (NULL == peer) |
1096 | { | 1095 | { |
1097 | fprintf (stdout, | 1096 | fprintf(stdout, |
1098 | "%s", | 1097 | "%s", |
1099 | _ ( | 1098 | _( |
1100 | "Monitor disconnected from transport service. Reconnecting.\n")); | 1099 | "Monitor disconnected from transport service. Reconnecting.\n")); |
1101 | return; | 1100 | return; |
1102 | } | 1101 | } |
1103 | 1102 | ||
1104 | if (NULL != op_timeout) | 1103 | if (NULL != op_timeout) |
1105 | GNUNET_SCHEDULER_cancel (op_timeout); | 1104 | GNUNET_SCHEDULER_cancel(op_timeout); |
1106 | op_timeout = | 1105 | op_timeout = |
1107 | GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, NULL); | 1106 | GNUNET_SCHEDULER_add_delayed(OP_TIMEOUT, &operation_timeout, NULL); |
1108 | 1107 | ||
1109 | if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer))) | 1108 | if (NULL == (m = GNUNET_CONTAINER_multipeermap_get(monitored_peers, peer))) |
1110 | { | 1109 | { |
1111 | m = GNUNET_new (struct MonitoredPeer); | 1110 | m = GNUNET_new(struct MonitoredPeer); |
1112 | GNUNET_CONTAINER_multipeermap_put ( | 1111 | GNUNET_CONTAINER_multipeermap_put( |
1113 | monitored_peers, | 1112 | monitored_peers, |
1114 | peer, | 1113 | peer, |
1115 | m, | 1114 | m, |
1116 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1115 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1117 | } | 1116 | } |
1118 | else | 1117 | else |
1119 | { | ||
1120 | if ((m->state == state) && | ||
1121 | (m->state_timeout.abs_value_us == state_timeout.abs_value_us) && | ||
1122 | (NULL == address) && (NULL == m->address)) | ||
1123 | { | 1118 | { |
1124 | return; /* No real change */ | 1119 | if ((m->state == state) && |
1120 | (m->state_timeout.abs_value_us == state_timeout.abs_value_us) && | ||
1121 | (NULL == address) && (NULL == m->address)) | ||
1122 | { | ||
1123 | return; /* No real change */ | ||
1124 | } | ||
1125 | if ((m->state == state) && (NULL != address) && (NULL != m->address) && | ||
1126 | (0 == GNUNET_HELLO_address_cmp(m->address, address))) | ||
1127 | return; /* No real change */ | ||
1125 | } | 1128 | } |
1126 | if ((m->state == state) && (NULL != address) && (NULL != m->address) && | ||
1127 | (0 == GNUNET_HELLO_address_cmp (m->address, address))) | ||
1128 | return; /* No real change */ | ||
1129 | } | ||
1130 | 1129 | ||
1131 | if (NULL != m->address) | 1130 | if (NULL != m->address) |
1132 | { | 1131 | { |
1133 | GNUNET_free (m->address); | 1132 | GNUNET_free(m->address); |
1134 | m->address = NULL; | 1133 | m->address = NULL; |
1135 | } | 1134 | } |
1136 | if (NULL != address) | 1135 | if (NULL != address) |
1137 | m->address = GNUNET_HELLO_address_copy (address); | 1136 | m->address = GNUNET_HELLO_address_copy(address); |
1138 | m->state = state; | 1137 | m->state = state; |
1139 | m->state_timeout = state_timeout; | 1138 | m->state_timeout = state_timeout; |
1140 | 1139 | ||
1141 | if (NULL != address) | 1140 | if (NULL != address) |
1142 | resolve_peer_address (m->address, numeric, m->state, m->state_timeout); | 1141 | resolve_peer_address(m->address, numeric, m->state, m->state_timeout); |
1143 | else | 1142 | else |
1144 | print_info (peer, NULL, NULL, m->state, m->state_timeout); | 1143 | print_info(peer, NULL, NULL, m->state, m->state_timeout); |
1145 | } | 1144 | } |
1146 | 1145 | ||
1147 | 1146 | ||
@@ -1155,9 +1154,9 @@ process_peer_monitoring_cb (void *cls, | |||
1155 | * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not | 1154 | * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not |
1156 | */ | 1155 | */ |
1157 | static int | 1156 | static int |
1158 | blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *cpid) | 1157 | blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *cpid) |
1159 | { | 1158 | { |
1160 | if (0 == memcmp (cpid, &pid, sizeof (struct GNUNET_PeerIdentity))) | 1159 | if (0 == memcmp(cpid, &pid, sizeof(struct GNUNET_PeerIdentity))) |
1161 | return GNUNET_SYSERR; | 1160 | return GNUNET_SYSERR; |
1162 | return GNUNET_OK; | 1161 | return GNUNET_OK; |
1163 | } | 1162 | } |
@@ -1172,258 +1171,259 @@ blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *cpid) | |||
1172 | * @param mycfg configuration | 1171 | * @param mycfg configuration |
1173 | */ | 1172 | */ |
1174 | static void | 1173 | static void |
1175 | run (void *cls, | 1174 | run(void *cls, |
1176 | char *const *args, | 1175 | char *const *args, |
1177 | const char *cfgfile, | 1176 | const char *cfgfile, |
1178 | const struct GNUNET_CONFIGURATION_Handle *mycfg) | 1177 | const struct GNUNET_CONFIGURATION_Handle *mycfg) |
1179 | { | 1178 | { |
1180 | static struct GNUNET_PeerIdentity zero_pid; | 1179 | static struct GNUNET_PeerIdentity zero_pid; |
1181 | int counter = 0; | 1180 | int counter = 0; |
1181 | |||
1182 | ret = 1; | 1182 | ret = 1; |
1183 | 1183 | ||
1184 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; | 1184 | cfg = (struct GNUNET_CONFIGURATION_Handle *)mycfg; |
1185 | 1185 | ||
1186 | counter = benchmark_send + benchmark_receive + iterate_connections + | 1186 | counter = benchmark_send + benchmark_receive + iterate_connections + |
1187 | monitor_connections + monitor_connects + do_disconnect + | 1187 | monitor_connections + monitor_connects + do_disconnect + |
1188 | monitor_plugins; | 1188 | monitor_plugins; |
1189 | 1189 | ||
1190 | if (1 < counter) | 1190 | if (1 < counter) |
1191 | { | ||
1192 | fprintf ( | ||
1193 | stderr, | ||
1194 | _ ( | ||
1195 | "Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"), | ||
1196 | "disconnect", | ||
1197 | "benchmark send", | ||
1198 | "benchmark receive", | ||
1199 | "information", | ||
1200 | "monitor", | ||
1201 | "events", | ||
1202 | "plugins"); | ||
1203 | return; | ||
1204 | } | ||
1205 | if (0 == counter) | ||
1206 | { | ||
1207 | fprintf ( | ||
1208 | stderr, | ||
1209 | _ ( | ||
1210 | "No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"), | ||
1211 | "disconnect", | ||
1212 | "benchmark send", | ||
1213 | "benchmark receive", | ||
1214 | "information", | ||
1215 | "monitor", | ||
1216 | "events", | ||
1217 | "plugins"); | ||
1218 | return; | ||
1219 | } | ||
1220 | |||
1221 | if (do_disconnect) /* -D: Disconnect from peer */ | ||
1222 | { | ||
1223 | if (0 == memcmp (&zero_pid, &pid, sizeof (pid))) | ||
1224 | { | 1191 | { |
1225 | fprintf (stderr, | 1192 | fprintf( |
1226 | _ ("Option `%s' makes no sense without option `%s'.\n"), | 1193 | stderr, |
1227 | "-D", | 1194 | _( |
1228 | "-p"); | 1195 | "Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"), |
1229 | ret = 1; | 1196 | "disconnect", |
1197 | "benchmark send", | ||
1198 | "benchmark receive", | ||
1199 | "information", | ||
1200 | "monitor", | ||
1201 | "events", | ||
1202 | "plugins"); | ||
1230 | return; | 1203 | return; |
1231 | } | 1204 | } |
1232 | blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_cb, NULL); | 1205 | if (0 == counter) |
1233 | if (NULL == blacklist) | ||
1234 | { | 1206 | { |
1235 | fprintf (stderr, | 1207 | fprintf( |
1236 | "%s", | 1208 | stderr, |
1237 | _ ( | 1209 | _( |
1238 | "Failed to connect to transport service for disconnection\n")); | 1210 | "No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"), |
1239 | ret = 1; | 1211 | "disconnect", |
1212 | "benchmark send", | ||
1213 | "benchmark receive", | ||
1214 | "information", | ||
1215 | "monitor", | ||
1216 | "events", | ||
1217 | "plugins"); | ||
1240 | return; | 1218 | return; |
1241 | } | 1219 | } |
1242 | fprintf (stdout, | 1220 | |
1243 | "%s", | 1221 | if (do_disconnect) /* -D: Disconnect from peer */ |
1244 | _ ("Blacklisting request in place, stop with CTRL-C\n")); | ||
1245 | } | ||
1246 | else if (benchmark_send) /* -s: Benchmark sending */ | ||
1247 | { | ||
1248 | if (0 == memcmp (&zero_pid, &pid, sizeof (pid))) | ||
1249 | { | 1222 | { |
1250 | fprintf (stderr, | 1223 | if (0 == memcmp(&zero_pid, &pid, sizeof(pid))) |
1251 | _ ("Option `%s' makes no sense without option `%s'.\n"), | 1224 | { |
1252 | "-s", | 1225 | fprintf(stderr, |
1253 | "-p"); | 1226 | _("Option `%s' makes no sense without option `%s'.\n"), |
1254 | ret = 1; | 1227 | "-D", |
1255 | return; | 1228 | "-p"); |
1229 | ret = 1; | ||
1230 | return; | ||
1231 | } | ||
1232 | blacklist = GNUNET_TRANSPORT_blacklist(cfg, &blacklist_cb, NULL); | ||
1233 | if (NULL == blacklist) | ||
1234 | { | ||
1235 | fprintf(stderr, | ||
1236 | "%s", | ||
1237 | _( | ||
1238 | "Failed to connect to transport service for disconnection\n")); | ||
1239 | ret = 1; | ||
1240 | return; | ||
1241 | } | ||
1242 | fprintf(stdout, | ||
1243 | "%s", | ||
1244 | _("Blacklisting request in place, stop with CTRL-C\n")); | ||
1256 | } | 1245 | } |
1257 | handle = GNUNET_TRANSPORT_core_connect (cfg, | 1246 | else if (benchmark_send) /* -s: Benchmark sending */ |
1258 | NULL, | ||
1259 | NULL, | ||
1260 | NULL, | ||
1261 | ¬ify_connect, | ||
1262 | ¬ify_disconnect, | ||
1263 | NULL); | ||
1264 | if (NULL == handle) | ||
1265 | { | 1247 | { |
1266 | fprintf (stderr, "%s", _ ("Failed to connect to transport service\n")); | 1248 | if (0 == memcmp(&zero_pid, &pid, sizeof(pid))) |
1267 | ret = 1; | 1249 | { |
1268 | return; | 1250 | fprintf(stderr, |
1251 | _("Option `%s' makes no sense without option `%s'.\n"), | ||
1252 | "-s", | ||
1253 | "-p"); | ||
1254 | ret = 1; | ||
1255 | return; | ||
1256 | } | ||
1257 | handle = GNUNET_TRANSPORT_core_connect(cfg, | ||
1258 | NULL, | ||
1259 | NULL, | ||
1260 | NULL, | ||
1261 | ¬ify_connect, | ||
1262 | ¬ify_disconnect, | ||
1263 | NULL); | ||
1264 | if (NULL == handle) | ||
1265 | { | ||
1266 | fprintf(stderr, "%s", _("Failed to connect to transport service\n")); | ||
1267 | ret = 1; | ||
1268 | return; | ||
1269 | } | ||
1270 | start_time = GNUNET_TIME_absolute_get(); | ||
1271 | op_timeout = | ||
1272 | GNUNET_SCHEDULER_add_delayed(OP_TIMEOUT, &operation_timeout, NULL); | ||
1269 | } | 1273 | } |
1270 | start_time = GNUNET_TIME_absolute_get (); | ||
1271 | op_timeout = | ||
1272 | GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, NULL); | ||
1273 | } | ||
1274 | else if (benchmark_receive) /* -b: Benchmark receiving */ | 1274 | else if (benchmark_receive) /* -b: Benchmark receiving */ |
1275 | { | 1275 | { |
1276 | struct GNUNET_MQ_MessageHandler handlers[] = | 1276 | struct GNUNET_MQ_MessageHandler handlers[] = |
1277 | {GNUNET_MQ_hd_var_size (dummy, | 1277 | { GNUNET_MQ_hd_var_size(dummy, |
1278 | GNUNET_MESSAGE_TYPE_DUMMY, | 1278 | GNUNET_MESSAGE_TYPE_DUMMY, |
1279 | struct GNUNET_MessageHeader, | 1279 | struct GNUNET_MessageHeader, |
1280 | NULL), | 1280 | NULL), |
1281 | GNUNET_MQ_handler_end ()}; | 1281 | GNUNET_MQ_handler_end() }; |
1282 | 1282 | ||
1283 | handle = GNUNET_TRANSPORT_core_connect (cfg, | 1283 | handle = GNUNET_TRANSPORT_core_connect(cfg, |
1284 | NULL, | 1284 | NULL, |
1285 | handlers, | 1285 | handlers, |
1286 | NULL, | 1286 | NULL, |
1287 | NULL, | 1287 | NULL, |
1288 | NULL, | 1288 | NULL, |
1289 | NULL); | 1289 | NULL); |
1290 | if (NULL == handle) | 1290 | if (NULL == handle) |
1291 | { | 1291 | { |
1292 | fprintf (stderr, "%s", _ ("Failed to connect to transport service\n")); | 1292 | fprintf(stderr, "%s", _("Failed to connect to transport service\n")); |
1293 | ret = 1; | 1293 | ret = 1; |
1294 | return; | 1294 | return; |
1295 | } | ||
1296 | if (verbosity > 0) | ||
1297 | fprintf(stdout, "%s", _("Starting to receive benchmark data\n")); | ||
1298 | start_time = GNUNET_TIME_absolute_get(); | ||
1295 | } | 1299 | } |
1296 | if (verbosity > 0) | ||
1297 | fprintf (stdout, "%s", _ ("Starting to receive benchmark data\n")); | ||
1298 | start_time = GNUNET_TIME_absolute_get (); | ||
1299 | } | ||
1300 | else if (iterate_connections) /* -i: List information about peers once */ | 1300 | else if (iterate_connections) /* -i: List information about peers once */ |
1301 | { | 1301 | { |
1302 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, | 1302 | pic = GNUNET_TRANSPORT_monitor_peers(cfg, |
1303 | &pid, | 1303 | &pid, |
1304 | GNUNET_YES, | 1304 | GNUNET_YES, |
1305 | &process_peer_iteration_cb, | 1305 | &process_peer_iteration_cb, |
1306 | (void *) cfg); | 1306 | (void *)cfg); |
1307 | op_timeout = | 1307 | op_timeout = |
1308 | GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, NULL); | 1308 | GNUNET_SCHEDULER_add_delayed(OP_TIMEOUT, &operation_timeout, NULL); |
1309 | } | 1309 | } |
1310 | else if (monitor_connections) /* -m: List information about peers continuously | 1310 | else if (monitor_connections) /* -m: List information about peers continuously |
1311 | */ | 1311 | */ |
1312 | { | 1312 | { |
1313 | monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); | 1313 | monitored_peers = GNUNET_CONTAINER_multipeermap_create(10, GNUNET_NO); |
1314 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, | 1314 | pic = GNUNET_TRANSPORT_monitor_peers(cfg, |
1315 | &pid, | 1315 | &pid, |
1316 | GNUNET_NO, | 1316 | GNUNET_NO, |
1317 | &process_peer_monitoring_cb, | 1317 | &process_peer_monitoring_cb, |
1318 | NULL); | 1318 | NULL); |
1319 | } | 1319 | } |
1320 | else if (monitor_plugins) /* -P: List information about plugins continuously | 1320 | else if (monitor_plugins) /* -P: List information about plugins continuously |
1321 | */ | 1321 | */ |
1322 | { | 1322 | { |
1323 | monitored_plugins = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); | 1323 | monitored_plugins = GNUNET_CONTAINER_multipeermap_create(10, GNUNET_NO); |
1324 | pm = GNUNET_TRANSPORT_monitor_plugins (cfg, &plugin_monitoring_cb, NULL); | 1324 | pm = GNUNET_TRANSPORT_monitor_plugins(cfg, &plugin_monitoring_cb, NULL); |
1325 | } | 1325 | } |
1326 | else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */ | 1326 | else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */ |
1327 | { | ||
1328 | monitor_connect_counter = 0; | ||
1329 | handle = GNUNET_TRANSPORT_core_connect (cfg, | ||
1330 | NULL, | ||
1331 | NULL, | ||
1332 | NULL, | ||
1333 | &monitor_notify_connect, | ||
1334 | &monitor_notify_disconnect, | ||
1335 | NULL); | ||
1336 | if (NULL == handle) | ||
1337 | { | 1327 | { |
1338 | fprintf (stderr, "%s", _ ("Failed to connect to transport service\n")); | 1328 | monitor_connect_counter = 0; |
1339 | ret = 1; | 1329 | handle = GNUNET_TRANSPORT_core_connect(cfg, |
1340 | return; | 1330 | NULL, |
1331 | NULL, | ||
1332 | NULL, | ||
1333 | &monitor_notify_connect, | ||
1334 | &monitor_notify_disconnect, | ||
1335 | NULL); | ||
1336 | if (NULL == handle) | ||
1337 | { | ||
1338 | fprintf(stderr, "%s", _("Failed to connect to transport service\n")); | ||
1339 | ret = 1; | ||
1340 | return; | ||
1341 | } | ||
1342 | ret = 0; | ||
1341 | } | 1343 | } |
1342 | ret = 0; | ||
1343 | } | ||
1344 | else | 1344 | else |
1345 | { | 1345 | { |
1346 | GNUNET_break (0); | 1346 | GNUNET_break(0); |
1347 | return; | 1347 | return; |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 1350 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | 1353 | ||
1354 | int | 1354 | int |
1355 | main (int argc, char *const *argv) | 1355 | main(int argc, char *const *argv) |
1356 | { | 1356 | { |
1357 | int res; | 1357 | int res; |
1358 | struct GNUNET_GETOPT_CommandLineOption options[] = | 1358 | struct GNUNET_GETOPT_CommandLineOption options[] = |
1359 | {GNUNET_GETOPT_option_flag ( | 1359 | { GNUNET_GETOPT_option_flag( |
1360 | 'a', | 1360 | 'a', |
1361 | "all", | 1361 | "all", |
1362 | gettext_noop ( | 1362 | gettext_noop( |
1363 | "print information for all peers (instead of only connected peers)"), | 1363 | "print information for all peers (instead of only connected peers)"), |
1364 | &iterate_all), | 1364 | &iterate_all), |
1365 | GNUNET_GETOPT_option_flag ( | 1365 | GNUNET_GETOPT_option_flag( |
1366 | 'b', | 1366 | 'b', |
1367 | "benchmark", | 1367 | "benchmark", |
1368 | gettext_noop ( | 1368 | gettext_noop( |
1369 | "measure how fast we are receiving data from all peers (until CTRL-C)"), | 1369 | "measure how fast we are receiving data from all peers (until CTRL-C)"), |
1370 | &benchmark_receive), | 1370 | &benchmark_receive), |
1371 | GNUNET_GETOPT_option_flag ('D', | 1371 | GNUNET_GETOPT_option_flag('D', |
1372 | "disconnect", | 1372 | "disconnect", |
1373 | gettext_noop ("disconnect from a peer"), | 1373 | gettext_noop("disconnect from a peer"), |
1374 | &do_disconnect), | 1374 | &do_disconnect), |
1375 | GNUNET_GETOPT_option_flag ( | 1375 | GNUNET_GETOPT_option_flag( |
1376 | 'i', | 1376 | 'i', |
1377 | "information", | 1377 | "information", |
1378 | gettext_noop ( | 1378 | gettext_noop( |
1379 | "provide information about all current connections (once)"), | 1379 | "provide information about all current connections (once)"), |
1380 | &iterate_connections), | 1380 | &iterate_connections), |
1381 | GNUNET_GETOPT_option_flag ( | 1381 | GNUNET_GETOPT_option_flag( |
1382 | 'm', | 1382 | 'm', |
1383 | "monitor", | 1383 | "monitor", |
1384 | gettext_noop ( | 1384 | gettext_noop( |
1385 | "provide information about all current connections (continuously)"), | 1385 | "provide information about all current connections (continuously)"), |
1386 | &monitor_connections), | 1386 | &monitor_connections), |
1387 | GNUNET_GETOPT_option_flag ( | 1387 | GNUNET_GETOPT_option_flag( |
1388 | 'e', | 1388 | 'e', |
1389 | "events", | 1389 | "events", |
1390 | gettext_noop ( | 1390 | gettext_noop( |
1391 | "provide information about all connects and disconnect events (continuously)"), | 1391 | "provide information about all connects and disconnect events (continuously)"), |
1392 | &monitor_connects), | 1392 | &monitor_connects), |
1393 | GNUNET_GETOPT_option_flag ('n', | 1393 | GNUNET_GETOPT_option_flag('n', |
1394 | "numeric", | 1394 | "numeric", |
1395 | gettext_noop ("do not resolve hostnames"), | 1395 | gettext_noop("do not resolve hostnames"), |
1396 | &numeric), | 1396 | &numeric), |
1397 | GNUNET_GETOPT_option_base32_auto ('p', | 1397 | GNUNET_GETOPT_option_base32_auto('p', |
1398 | "peer", | 1398 | "peer", |
1399 | "PEER", | 1399 | "PEER", |
1400 | gettext_noop ("peer identity"), | 1400 | gettext_noop("peer identity"), |
1401 | &pid), | 1401 | &pid), |
1402 | GNUNET_GETOPT_option_flag ('P', | 1402 | GNUNET_GETOPT_option_flag('P', |
1403 | "plugins", | 1403 | "plugins", |
1404 | gettext_noop ("monitor plugin sessions"), | 1404 | gettext_noop("monitor plugin sessions"), |
1405 | &monitor_plugins), | 1405 | &monitor_plugins), |
1406 | GNUNET_GETOPT_option_flag ( | 1406 | GNUNET_GETOPT_option_flag( |
1407 | 's', | 1407 | 's', |
1408 | "send", | 1408 | "send", |
1409 | gettext_noop ( | 1409 | gettext_noop( |
1410 | "send data for benchmarking to the other peer (until CTRL-C)"), | 1410 | "send data for benchmarking to the other peer (until CTRL-C)"), |
1411 | &benchmark_send), | 1411 | &benchmark_send), |
1412 | GNUNET_GETOPT_option_verbose (&verbosity), | 1412 | GNUNET_GETOPT_option_verbose(&verbosity), |
1413 | GNUNET_GETOPT_OPTION_END}; | 1413 | GNUNET_GETOPT_OPTION_END }; |
1414 | 1414 | ||
1415 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 1415 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) |
1416 | return 2; | 1416 | return 2; |
1417 | 1417 | ||
1418 | res = | 1418 | res = |
1419 | GNUNET_PROGRAM_run (argc, | 1419 | GNUNET_PROGRAM_run(argc, |
1420 | argv, | 1420 | argv, |
1421 | "gnunet-transport", | 1421 | "gnunet-transport", |
1422 | gettext_noop ("Direct access to transport service."), | 1422 | gettext_noop("Direct access to transport service."), |
1423 | options, | 1423 | options, |
1424 | &run, | 1424 | &run, |
1425 | NULL); | 1425 | NULL); |
1426 | GNUNET_free ((void *) argv); | 1426 | GNUNET_free((void *)argv); |
1427 | if (GNUNET_OK == res) | 1427 | if (GNUNET_OK == res) |
1428 | return ret; | 1428 | return ret; |
1429 | return 1; | 1429 | return 1; |