diff options
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 6d14d51aa..19abda0ea 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -88,6 +88,11 @@ static int monitor_connects; | |||
88 | static int monitor_connections; | 88 | static int monitor_connections; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Option -C. | ||
92 | */ | ||
93 | static int try_connect; | ||
94 | |||
95 | /** | ||
91 | * Option -n. | 96 | * Option -n. |
92 | */ | 97 | */ |
93 | static int numeric; | 98 | static int numeric; |
@@ -449,7 +454,11 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
449 | if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) | 454 | if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) |
450 | return; | 455 | return; |
451 | ret = 0; | 456 | ret = 0; |
452 | if (benchmark_send) | 457 | if (try_connect) |
458 | { | ||
459 | /*FIXME */ | ||
460 | } | ||
461 | else if (benchmark_send) | ||
453 | { | 462 | { |
454 | start_time = GNUNET_TIME_absolute_get (); | 463 | start_time = GNUNET_TIME_absolute_get (); |
455 | if (NULL == th) | 464 | if (NULL == th) |
@@ -648,6 +657,7 @@ testservice_task (void *cls, | |||
648 | { | 657 | { |
649 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 658 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
650 | int counter = 0; | 659 | int counter = 0; |
660 | int try_connect = 0; | ||
651 | 661 | ||
652 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 662 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) |
653 | { | 663 | { |
@@ -655,37 +665,53 @@ testservice_task (void *cls, | |||
655 | return; | 665 | return; |
656 | } | 666 | } |
657 | 667 | ||
668 | if ((NULL != cpid) && (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey))) | ||
669 | { | ||
670 | FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid); | ||
671 | return; | ||
672 | } | ||
673 | |||
658 | counter = benchmark_send + benchmark_receive + iterate_connections + | 674 | counter = benchmark_send + benchmark_receive + iterate_connections + |
659 | monitor_connections + monitor_connects; | 675 | monitor_connections + monitor_connects + try_connect; |
660 | 676 | ||
661 | if (1 < counter) | 677 | if (1 < counter) |
662 | { | 678 | { |
663 | FPRINTF (stderr, _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s\n"), | 679 | FPRINTF (stderr, _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s\n"), |
664 | "benchmark send", "benchmark receive", "information", "monitor", "events"); | 680 | "connect", "benchmark send", "benchmark receive", "information", "monitor", "events"); |
665 | return; | 681 | return; |
666 | } | 682 | } |
667 | if (0 == counter) | 683 | if (0 == counter) |
668 | { | 684 | { |
669 | FPRINTF (stderr, _("No operation given. Please choose one operation: %s, %s, %s, %s, %s\n"), | 685 | FPRINTF (stderr, _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s\n"), |
670 | "benchmark send", "benchmark receive", "information", "monitor", "events"); | 686 | "connect", "benchmark send", "benchmark receive", "information", "monitor", "events"); |
671 | return; | 687 | return; |
672 | } | 688 | } |
673 | 689 | ||
674 | 690 | ||
675 | if (benchmark_send) /* Benchmark sending */ | 691 | if (try_connect) |
676 | { | 692 | { |
677 | if (NULL == cpid) | 693 | if (NULL == cpid) |
678 | { | 694 | { |
679 | FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"), | 695 | FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"), |
680 | "-s", "-C"); | 696 | "-C", "-p"); |
681 | return; | 697 | return; |
682 | } | 698 | } |
683 | ret = 1; | 699 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, |
684 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey)) | 700 | ¬ify_receive, |
701 | ¬ify_connect, | ||
702 | ¬ify_disconnect); | ||
703 | GNUNET_TRANSPORT_try_connect (handle, &pid); | ||
704 | |||
705 | } | ||
706 | else if (benchmark_send) /* Benchmark sending */ | ||
707 | { | ||
708 | if (NULL == cpid) | ||
685 | { | 709 | { |
686 | FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid); | 710 | FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"), |
711 | "-s", "-p"); | ||
687 | return; | 712 | return; |
688 | } | 713 | } |
714 | ret = 1; | ||
689 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, | 715 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, |
690 | ¬ify_receive, | 716 | ¬ify_receive, |
691 | ¬ify_connect, | 717 | ¬ify_connect, |
@@ -740,7 +766,7 @@ testservice_task (void *cls, | |||
740 | } | 766 | } |
741 | else | 767 | else |
742 | { | 768 | { |
743 | GNUNET_break (0) | 769 | GNUNET_break (0); |
744 | return; | 770 | return; |
745 | } | 771 | } |
746 | 772 | ||
@@ -782,9 +808,9 @@ main (int argc, char *const *argv) | |||
782 | {'b', "benchmark", NULL, | 808 | {'b', "benchmark", NULL, |
783 | gettext_noop ("measure how fast we are receiving data (until CTRL-C)"), | 809 | gettext_noop ("measure how fast we are receiving data (until CTRL-C)"), |
784 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive}, | 810 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive}, |
785 | {'C', "connect", "PEER", | 811 | {'C', "connect", NULL, |
786 | gettext_noop ("try to connect to the given peer"), | 812 | gettext_noop ("connect to a peer"), |
787 | 1, &GNUNET_GETOPT_set_string, &cpid}, | 813 | 0, &GNUNET_GETOPT_set_one, &try_connect}, |
788 | {'i', "information", NULL, | 814 | {'i', "information", NULL, |
789 | gettext_noop ("provide information about all current connections (once)"), | 815 | gettext_noop ("provide information about all current connections (once)"), |
790 | 0, &GNUNET_GETOPT_set_one, &iterate_connections}, | 816 | 0, &GNUNET_GETOPT_set_one, &iterate_connections}, |
@@ -797,6 +823,9 @@ main (int argc, char *const *argv) | |||
797 | {'n', "numeric", NULL, | 823 | {'n', "numeric", NULL, |
798 | gettext_noop ("do not resolve hostnames"), | 824 | gettext_noop ("do not resolve hostnames"), |
799 | 0, &GNUNET_GETOPT_set_one, &numeric}, | 825 | 0, &GNUNET_GETOPT_set_one, &numeric}, |
826 | {'p', "peer", "PEER", | ||
827 | gettext_noop ("peer identity"), | ||
828 | 1, &GNUNET_GETOPT_set_string, &cpid}, | ||
800 | {'s', "send", NULL, | 829 | {'s', "send", NULL, |
801 | gettext_noop | 830 | gettext_noop |
802 | ("send data for benchmarking to the other peer (until CTRL-C)"), | 831 | ("send data for benchmarking to the other peer (until CTRL-C)"), |