2 This file is part of GNUnet.
3 (C) 2011-2014 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file src/transport/gnunet-transport.c
23 * @brief Tool to help configure, measure and control the transport subsystem.
24 * @author Christian Grothoff
25 * @author Nathan Evans
27 * This utility can be used to test if a transport mechanism for
28 * GNUnet is properly configured.
31 #include "gnunet_util_lib.h"
32 #include "gnunet_resolver_service.h"
33 #include "gnunet_protocols.h"
34 #include "gnunet_transport_service.h"
35 #include "gnunet_nat_lib.h"
38 * How long do we wait for the NAT test to report success?
39 * Should match NAT_SERVER_TIMEOUT in 'nat_test.c'.
41 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
44 * Timeout for a name resolution
46 #define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
49 * Timeout for an operations
51 #define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
55 * Context to store name resolutions for valiation
57 struct ValidationResolutionContext
62 struct ValidationResolutionContext *next;
67 struct ValidationResolutionContext *prev;
72 struct GNUNET_PeerIdentity id;
77 struct GNUNET_HELLO_Address *addrcp;
80 * Time of last validation
82 struct GNUNET_TIME_Absolute last_validation;
85 * Address is valid until
87 struct GNUNET_TIME_Absolute valid_until;
90 * Time of next validation
92 struct GNUNET_TIME_Absolute next_validation;
95 * state of validation process
97 enum GNUNET_TRANSPORT_ValidationState state;
100 * Tranport conversion handle
102 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
110 * was the entry printed
116 * Struct to store information about peers in monitor mode
123 enum GNUNET_TRANSPORT_PeerState state;
128 struct GNUNET_TIME_Absolute state_timeout;
131 * The address to convert
133 struct GNUNET_HELLO_Address *address;
137 * Context to store name resolutions for valiation
139 struct PeerResolutionContext
144 struct PeerResolutionContext *next;
149 struct PeerResolutionContext *prev;
154 struct GNUNET_PeerIdentity id;
159 struct GNUNET_HELLO_Address *addrcp;
162 * transport conversiion context
164 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
169 enum GNUNET_TRANSPORT_PeerState state;
174 struct GNUNET_TIME_Absolute state_timeout;
182 * was the entry printed
189 * Context for a plugin test.
196 struct TestContext *prev;
201 struct TestContext *next;
204 * Handle to the active NAT test.
206 struct GNUNET_NAT_Test *tst;
209 * Task identifier for the timeout.
211 GNUNET_SCHEDULER_TaskIdentifier tsk;
214 * Name of plugin under test.
221 unsigned long long bnd_port;
226 unsigned long long adv_port;
237 * NAT returned success
239 NAT_TEST_SUCCESS = GNUNET_OK,
242 * NAT returned failure
244 NAT_TEST_FAIL = GNUNET_NO,
247 * NAT returned failure while running test
249 NAT_TEST_INTERNAL_FAIL = GNUNET_SYSERR,
252 * We could not start the test
254 NAT_TEST_FAILED_TO_START = 2,
257 * We had a timeout while running the test
264 * Benchmarking block size in KB
269 * Which peer should we connect to?
274 * Handle to transport service.
276 static struct GNUNET_TRANSPORT_Handle *handle;
279 * Configuration handle
281 static struct GNUNET_CONFIGURATION_Handle *cfg;
286 struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle;
291 static int benchmark_send;
296 static int benchmark_receive;
301 static int benchmark_receive;
306 static int iterate_connections;
311 static int iterate_validation;
316 static int iterate_all;
321 static int test_configuration;
326 static int monitor_connects;
331 static int monitor_connections;
336 static int monitor_validation;
341 static int monitor_plugins;
346 static int try_connect;
351 static int try_disconnect;
359 * Global return value (0 success).
364 * Current number of connections in monitor mode
366 static int monitor_connect_counter;
369 * Number of bytes of traffic we received so far.
371 static unsigned long long traffic_received;
374 * Number of bytes of traffic we sent so far.
376 static unsigned long long traffic_sent;
379 * Starting time of transmitting/receiving data.
381 static struct GNUNET_TIME_Absolute start_time;
384 * Handle for current transmission request.
386 static struct GNUNET_TRANSPORT_TransmitHandle *th;
389 * Map storing information about monitored peers
391 static struct GNUNET_CONTAINER_MultiPeerMap *monitored_peers;
394 * Map storing information about monitored plugins's sessions.
396 static struct GNUNET_CONTAINER_MultiPeerMap *monitored_plugins;
399 * Handle if we are monitoring peers at the transport level.
401 static struct GNUNET_TRANSPORT_PeerMonitoringContext *pic;
404 * Handle if we are monitoring transport validation activity.
406 static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic;
409 * Handle if we are monitoring plugin session activity.
411 static struct GNUNET_TRANSPORT_PluginMonitor *pm;
414 * Identity of the peer we transmit to / connect to.
415 * (equivalent to 'cpid' string).
417 static struct GNUNET_PeerIdentity pid;
420 * Task scheduled for cleanup / termination of the process.
422 static GNUNET_SCHEDULER_TaskIdentifier end;
425 * Task for operation timeout
427 static GNUNET_SCHEDULER_TaskIdentifier op_timeout;
430 * Selected level of verbosity.
432 static int verbosity;
435 * Resolver process handle.
437 struct GNUNET_OS_Process *resolver;
440 * Number of address resolutions pending
442 static unsigned int address_resolutions;
445 * Address resolutions pending in progress
447 static unsigned int address_resolution_in_progress;
450 * DLL for NAT Test Contexts: head
452 struct TestContext *head;
455 * DLL for NAT Test Contexts: tail
457 struct TestContext *tail;
460 * DLL: head of validation resolution entries
462 static struct ValidationResolutionContext *vc_head;
465 * DLL: tail of validation resolution entries
467 static struct ValidationResolutionContext *vc_tail;
470 * DLL: head of resolution entries
472 static struct PeerResolutionContext *rc_head;
475 * DLL: head of resolution entries
477 static struct PeerResolutionContext *rc_tail;
481 * Function called to release data stored in the #monitored_peers map.
484 * @param key the peer identity
485 * @param value a `struct MonitoredPeer` to release
486 * @return #GNUNET_OK (continue to iterate)
489 destroy_it (void *cls,
490 const struct GNUNET_PeerIdentity *key,
493 struct MonitoredPeer *m = value;
495 GNUNET_assert (GNUNET_OK ==
496 GNUNET_CONTAINER_multipeermap_remove (monitored_peers,
499 GNUNET_free_non_null (m->address);
506 * Task run in monitor mode when the user presses CTRL-C to abort.
507 * Stops monitoring activity.
510 * @param tc scheduler context
513 shutdown_task (void *cls,
514 const struct GNUNET_SCHEDULER_TaskContext *tc)
516 struct GNUNET_TIME_Relative duration;
517 struct ValidationResolutionContext *cur;
518 struct ValidationResolutionContext *next;
520 end = GNUNET_SCHEDULER_NO_TASK;
521 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
523 GNUNET_SCHEDULER_cancel (op_timeout);
524 op_timeout = GNUNET_SCHEDULER_NO_TASK;
526 if (NULL != tc_handle)
528 GNUNET_TRANSPORT_try_connect_cancel (tc_handle);
533 GNUNET_TRANSPORT_monitor_peers_cancel (pic);
538 GNUNET_TRANSPORT_monitor_validation_entries_cancel (vic);
543 GNUNET_TRANSPORT_monitor_plugins_cancel (pm);
548 for (cur = next; NULL != cur; cur = next)
552 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
553 GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, cur);
554 GNUNET_free (cur->transport);
555 GNUNET_HELLO_address_free (cur->addrcp);
561 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
566 GNUNET_TRANSPORT_disconnect (handle);
571 duration = GNUNET_TIME_absolute_get_duration (start_time);
573 _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
574 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
576 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
578 if (benchmark_receive)
580 duration = GNUNET_TIME_absolute_get_duration (start_time);
582 _("Received %llu bytes/s (%llu bytes in %s)\n"),
583 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
585 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
588 if (NULL != monitored_peers)
590 GNUNET_CONTAINER_multipeermap_iterate (monitored_peers, &destroy_it, NULL);
591 GNUNET_CONTAINER_multipeermap_destroy (monitored_peers);
592 monitored_peers = NULL;
594 if (NULL != monitored_plugins)
597 GNUNET_CONTAINER_multipeermap_size (monitored_plugins));
598 GNUNET_CONTAINER_multipeermap_destroy (monitored_plugins);
599 monitored_plugins = NULL;
605 operation_timeout (void *cls,
606 const struct GNUNET_SCHEDULER_TaskContext *tc)
608 struct PeerResolutionContext *cur;
609 struct PeerResolutionContext *next;
610 op_timeout = GNUNET_SCHEDULER_NO_TASK;
611 if ((try_connect) || (benchmark_send) || (benchmark_receive))
614 _("Failed to connect to `%s'\n"),
615 GNUNET_i2s_full (&pid));
616 if (GNUNET_SCHEDULER_NO_TASK != end)
617 GNUNET_SCHEDULER_cancel (end);
618 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
622 if (iterate_connections)
625 while (NULL != (cur = next))
629 _("Failed to resolve address for peer `%s'\n"),
630 GNUNET_i2s (&cur->addrcp->peer));
632 GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur);
633 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
634 GNUNET_free(cur->transport);
635 GNUNET_free(cur->addrcp);
641 _("Failed to list connections, timeout occured\n"));
642 if (GNUNET_SCHEDULER_NO_TASK != end)
643 GNUNET_SCHEDULER_cancel (end);
644 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
656 * Display the result of the test.
658 * @param tc test context
659 * @param result #GNUNET_YES on success
662 display_test_result (struct TestContext *tc,
663 enum TestResult result)
668 _("Configuration for plugin `%s' did not work!\n"),
671 case NAT_TEST_SUCCESS:
673 _("Configuration for plugin `%s' did work!\n"),
676 case NAT_TEST_INTERNAL_FAIL:
678 _("Internal NAT error while running test for plugin `%s'\n"),
681 case NAT_TEST_FAILED_TO_START:
683 _("Failed to start NAT test for plugin `%s'\n"),
686 case NAT_TEST_TIMEOUT:
688 _("Timeout while waiting for result of NAT test for plugin `%s'\n"),
695 if (GNUNET_YES != result)
698 _("Configuration for plugin `%s' did not work!\n"),
704 _("Configuration for plugin `%s' is working!\n"),
707 if (GNUNET_SCHEDULER_NO_TASK != tc->tsk)
709 GNUNET_SCHEDULER_cancel (tc->tsk);
710 tc->tsk = GNUNET_SCHEDULER_NO_TASK;
714 GNUNET_NAT_test_stop (tc->tst);
718 GNUNET_CONTAINER_DLL_remove (head, tail, tc);
719 GNUNET_free (tc->name);
722 if ((NULL == head) && (NULL != resolver))
724 GNUNET_break (0 == GNUNET_OS_process_kill (resolver,
726 GNUNET_OS_process_destroy (resolver);
734 * Function called by NAT to report the outcome of the nat-test.
735 * Clean up and update GUI.
737 * @param cls test context
738 * @param result status code
741 result_callback (void *cls,
742 enum GNUNET_NAT_StatusCode result)
744 struct TestContext *tc = cls;
746 display_test_result (tc, result);
751 * Resolve address we got a validation state for to a string.
753 * @param id peer identity the address is for
754 * @param address the address itself
755 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
756 * @param last_validation when was the address validated last
757 * @param valid_until until when is the address valid
758 * @param next_validation when will we try to revalidate the address next
759 * @param state where are we in the validation state machine
762 resolve_validation_address (const struct GNUNET_PeerIdentity *id,
763 const struct GNUNET_HELLO_Address *address,
765 struct GNUNET_TIME_Absolute last_validation,
766 struct GNUNET_TIME_Absolute valid_until,
767 struct GNUNET_TIME_Absolute next_validation,
768 enum GNUNET_TRANSPORT_ValidationState state);
772 * Function to call with a textual representation of an address. This
773 * function will be called several times with different possible
774 * textual representations, and a last time with @a address being NULL
775 * to signal the end of the iteration. Note that @a address NULL
776 * always is the last call, regardless of the value in @a res.
779 * @param address NULL on end of iteration,
780 * otherwise 0-terminated printable UTF-8 string,
781 * in particular an empty string if @a res is #GNUNET_NO
782 * @param res result of the address to string conversion:
783 * if #GNUNET_OK: conversion successful
784 * if #GNUNET_NO: address was invalid (or not supported)
785 * if #GNUNET_SYSERR: communication error (IPC error)
788 process_validation_string (void *cls,
792 struct ValidationResolutionContext *vc = cls;
799 if (GNUNET_SYSERR == res)
802 "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n",
803 GNUNET_i2s (&vc->id),
804 vc->addrcp->transport_name,
805 vc->addrcp->address_length);
807 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->valid_until.abs_value_us)
808 s_valid = GNUNET_strdup ("never");
810 s_valid = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->valid_until));
812 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->last_validation.abs_value_us)
813 s_last = GNUNET_strdup ("never");
815 s_last = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->last_validation));
817 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->next_validation.abs_value_us)
818 s_next = GNUNET_strdup ("never");
820 s_next = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->next_validation));
823 _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"),
824 GNUNET_i2s (&vc->id),
825 (GNUNET_OK == res) ? address : "<invalid address>",
826 (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "",
827 "Valid until : ", s_valid,
828 "Last validation: ",s_last,
829 "Next validation: ", s_next);
830 GNUNET_free (s_valid);
831 GNUNET_free (s_last);
832 GNUNET_free (s_next);
833 vc->printed = GNUNET_YES;
836 /* last call, we are done */
837 GNUNET_assert (address_resolutions > 0);
838 address_resolutions--;
839 if ( (GNUNET_SYSERR == res) &&
840 (GNUNET_NO == vc->printed))
842 if (numeric == GNUNET_NO)
844 /* Failed to resolve address, try numeric lookup
845 (note: this should be unnecessary, as
846 transport should fallback to numeric lookup
847 internally if DNS takes too long anyway) */
848 resolve_validation_address (&vc->id,
859 _("Peer `%s' %s `%s' \n"),
860 GNUNET_i2s (&vc->id),
861 "<unable to resolve address>",
862 GNUNET_TRANSPORT_vs2s (vc->state));
865 GNUNET_free (vc->transport);
866 GNUNET_free (vc->addrcp);
867 GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, vc);
869 if ((0 == address_resolutions) && (iterate_validation))
871 if (GNUNET_SCHEDULER_NO_TASK != end)
873 GNUNET_SCHEDULER_cancel (end);
874 end = GNUNET_SCHEDULER_NO_TASK;
876 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
878 GNUNET_SCHEDULER_cancel (op_timeout);
879 op_timeout = GNUNET_SCHEDULER_NO_TASK;
882 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
888 * Resolve address we got a validation state for to a string.
890 * @param id peer identity the address is for
891 * @param address the address itself
892 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
893 * @param last_validation when was the address validated last
894 * @param valid_until until when is the address valid
895 * @param next_validation when will we try to revalidate the address next
896 * @param state where are we in the validation state machine
899 resolve_validation_address (const struct GNUNET_PeerIdentity *id,
900 const struct GNUNET_HELLO_Address *address,
902 struct GNUNET_TIME_Absolute last_validation,
903 struct GNUNET_TIME_Absolute valid_until,
904 struct GNUNET_TIME_Absolute next_validation,
905 enum GNUNET_TRANSPORT_ValidationState state)
907 struct ValidationResolutionContext *vc;
909 vc = GNUNET_new (struct ValidationResolutionContext);
910 GNUNET_assert(NULL != vc);
911 GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc);
912 address_resolutions++;
915 vc->transport = GNUNET_strdup(address->transport_name);
916 vc->addrcp = GNUNET_HELLO_address_copy (address);
917 vc->printed = GNUNET_NO;
919 vc->last_validation = last_validation;
920 vc->valid_until = valid_until;
921 vc->next_validation = next_validation;
923 /* Resolve address to string */
924 vc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
928 &process_validation_string, vc);
933 * Resolve address we got a validation state for to a string.
936 * @param peer peer identity the address is for
937 * @param address the address itself
938 * @param last_validation when was the address validated last
939 * @param valid_until until when is the address valid
940 * @param next_validation when will we try to revalidate the address next
941 * @param state where are we in the validation state machine
944 process_validation_cb (void *cls,
945 const struct GNUNET_PeerIdentity *peer,
946 const struct GNUNET_HELLO_Address *address,
947 struct GNUNET_TIME_Absolute last_validation,
948 struct GNUNET_TIME_Absolute valid_until,
949 struct GNUNET_TIME_Absolute next_validation,
950 enum GNUNET_TRANSPORT_ValidationState state)
952 if ((NULL == peer) && (NULL == address))
954 if (monitor_validation)
958 _("Monitor disconnected from transport service. Reconnecting.\n"));
964 if (GNUNET_SCHEDULER_NO_TASK != end)
965 GNUNET_SCHEDULER_cancel (end);
966 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
969 if ((NULL == peer) || (NULL == address))
971 /* invalid response */
973 if (GNUNET_SCHEDULER_NO_TASK != end)
974 GNUNET_SCHEDULER_cancel (end);
975 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
978 resolve_validation_address (peer,
991 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
992 "Running test for plugin `%s' using bind port %u and advertised port %u \n",
994 (uint16_t) head->bnd_port,
995 (uint16_t) head->adv_port);
997 head->tst = GNUNET_NAT_test_start (cfg,
998 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES,
999 (uint16_t) head->bnd_port,
1000 (uint16_t) head->adv_port,
1002 &result_callback, head);
1007 * Test our plugin's configuration (NAT traversal, etc.).
1009 * @param cfg configuration to test
1012 do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
1016 unsigned long long bnd_port;
1017 unsigned long long adv_port;
1018 struct TestContext *tc;
1022 != GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
1025 FPRINTF (stderr, "%s", _
1026 ("No transport plugins configured, peer will never communicate\n"));
1031 for (tok = strtok (plugins, " "); tok != NULL ; tok = strtok (NULL, " "))
1033 char section[12 + strlen (tok)];
1034 GNUNET_snprintf (section, sizeof(section), "transport-%s", tok);
1036 != GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT",
1040 _("No port configured for plugin `%s', cannot test it\n"), tok);
1043 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, section,
1044 "ADVERTISED_PORT", &adv_port))
1045 adv_port = bnd_port;
1047 tc = GNUNET_new (struct TestContext);
1048 tc->name = GNUNET_strdup (tok);
1049 tc->adv_port = adv_port;
1050 tc->bnd_port = bnd_port;
1051 GNUNET_CONTAINER_DLL_insert_tail (head, tail, tc);
1053 GNUNET_free(plugins);
1055 if ((NULL != head) && (NULL == resolver))
1057 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
1058 resolver = GNUNET_OS_start_process (GNUNET_YES,
1059 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1062 "gnunet-service-resolver", NULL);
1063 if (NULL == resolver)
1065 FPRINTF (stderr, _("Failed to start resolver!\n"));
1069 GNUNET_free(binary);
1070 GNUNET_RESOLVER_connect (cfg);
1077 * Function called to notify a client about the socket
1078 * begin ready to queue more data. @a buf will be
1079 * NULL and @a size zero if the socket was closed for
1080 * writing in the meantime.
1082 * @param cls closure
1083 * @param size number of bytes available in @a buf
1084 * @param buf where the callee should write the message
1085 * @return number of bytes written to @a buf
1088 transmit_data (void *cls,
1092 struct GNUNET_MessageHeader *m = buf;
1094 if ((NULL == buf) || (0 == size))
1100 GNUNET_assert(size >= sizeof(struct GNUNET_MessageHeader));
1101 GNUNET_assert(size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
1102 m->size = ntohs (size);
1103 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
1104 memset (&m[1], 52, size - sizeof(struct GNUNET_MessageHeader));
1105 traffic_sent += size;
1106 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid,
1108 GNUNET_TIME_UNIT_FOREVER_REL,
1109 &transmit_data, NULL);
1111 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
1118 * Function called to notify transport users that another
1119 * peer connected to us.
1121 * @param cls closure
1122 * @param peer the peer that connected
1125 notify_connect (void *cls,
1126 const struct GNUNET_PeerIdentity *peer)
1128 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1133 /* all done, terminate instantly */
1134 FPRINTF (stdout, _("Successfully connected to `%s'\n"),
1135 GNUNET_i2s_full (peer));
1138 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
1140 GNUNET_SCHEDULER_cancel (op_timeout);
1141 op_timeout = GNUNET_SCHEDULER_NO_TASK;
1144 if (GNUNET_SCHEDULER_NO_TASK != end)
1145 GNUNET_SCHEDULER_cancel (end);
1146 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1151 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
1153 GNUNET_SCHEDULER_cancel (op_timeout);
1154 op_timeout = GNUNET_SCHEDULER_NO_TASK;
1158 _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
1159 GNUNET_i2s (&pid), BLOCKSIZE);
1160 start_time = GNUNET_TIME_absolute_get ();
1162 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer,
1164 GNUNET_TIME_UNIT_FOREVER_REL,
1175 * Function called to notify transport users that another
1176 * peer disconnected from us.
1178 * @param cls closure
1179 * @param peer the peer that disconnected
1182 notify_disconnect (void *cls,
1183 const struct GNUNET_PeerIdentity *peer)
1185 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1190 /* all done, terminate instantly */
1191 FPRINTF (stdout, _("Successfully disconnected from `%s'\n"),
1192 GNUNET_i2s_full (peer));
1195 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
1197 GNUNET_SCHEDULER_cancel (op_timeout);
1198 op_timeout = GNUNET_SCHEDULER_NO_TASK;
1201 if (GNUNET_SCHEDULER_NO_TASK != end)
1202 GNUNET_SCHEDULER_cancel (end);
1203 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1209 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
1214 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"),
1216 if (GNUNET_SCHEDULER_NO_TASK != end)
1217 GNUNET_SCHEDULER_cancel (end);
1224 * Function called to notify transport users that another
1225 * peer connected to us.
1227 * @param cls closure
1228 * @param peer the peer that connected
1231 monitor_notify_connect (void *cls,
1232 const struct GNUNET_PeerIdentity *peer)
1234 monitor_connect_counter++;
1235 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1236 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1239 _("%24s: %-17s %4s (%u connections in total)\n"),
1243 monitor_connect_counter);
1248 * Function called to notify transport users that another
1249 * peer disconnected from us.
1251 * @param cls closure
1252 * @param peer the peer that disconnected
1255 monitor_notify_disconnect (void *cls,
1256 const struct GNUNET_PeerIdentity *peer)
1258 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1259 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1261 GNUNET_assert(monitor_connect_counter > 0);
1262 monitor_connect_counter--;
1265 _("%24s: %-17s %4s (%u connections in total)\n"),
1267 _("Disconnected from"),
1269 monitor_connect_counter);
1274 * Function called by the transport for each received message.
1276 * @param cls closure
1277 * @param peer (claimed) identity of the other peer
1278 * @param message the message
1281 notify_receive (void *cls,
1282 const struct GNUNET_PeerIdentity *peer,
1283 const struct GNUNET_MessageHeader *message)
1285 if (benchmark_receive)
1287 if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type))
1291 _("Received %u bytes from %s\n"),
1292 (unsigned int) ntohs (message->size),
1295 if (traffic_received == 0)
1296 start_time = GNUNET_TIME_absolute_get ();
1297 traffic_received += ntohs (message->size);
1304 resolve_peer_address (const struct GNUNET_PeerIdentity *id,
1305 const struct GNUNET_HELLO_Address *address,
1307 enum GNUNET_TRANSPORT_PeerState state,
1308 struct GNUNET_TIME_Absolute state_timeout);
1312 print_info (const struct GNUNET_PeerIdentity *id,
1313 const char *transport,
1315 enum GNUNET_TRANSPORT_PeerState state,
1316 struct GNUNET_TIME_Absolute state_timeout)
1319 if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
1320 (GNUNET_YES == monitor_connections))
1323 _("Peer `%s': %s %s in state `%s' until %s\n"),
1325 (NULL == transport) ? "<none>" : transport,
1326 (NULL == transport) ? "<none>" : addr,
1327 GNUNET_TRANSPORT_ps2s (state),
1328 GNUNET_STRINGS_absolute_time_to_string (state_timeout));
1330 else if ( (GNUNET_YES == iterate_connections) &&
1331 (GNUNET_TRANSPORT_is_connected(state)))
1333 /* Only connected peers, skip state */
1335 _("Peer `%s': %s %s\n"),
1344 * Function called with a textual representation of an address. This
1345 * function will be called several times with different possible
1346 * textual representations, and a last time with @a address being NULL
1347 * to signal the end of the iteration. Note that @a address NULL
1348 * always is the last call, regardless of the value in @a res.
1350 * @param cls closure
1351 * @param address NULL on end of iteration,
1352 * otherwise 0-terminated printable UTF-8 string,
1353 * in particular an empty string if @a res is #GNUNET_NO
1354 * @param res result of the address to string conversion:
1355 * if #GNUNET_OK: conversion successful
1356 * if #GNUNET_NO: address was invalid (or not supported)
1357 * if #GNUNET_SYSERR: communication error (IPC error)
1360 process_peer_string (void *cls,
1361 const char *address,
1364 struct PeerResolutionContext *rc = cls;
1366 if (NULL != address)
1368 if (GNUNET_SYSERR == res)
1371 "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n",
1372 GNUNET_i2s (&rc->id),
1373 rc->addrcp->transport_name,
1374 rc->addrcp->address_length);
1375 print_info (&rc->id,
1380 rc->printed = GNUNET_YES;
1383 if (GNUNET_OK == res)
1385 print_info (&rc->id,
1390 rc->printed = GNUNET_YES;
1391 return; /* Wait for done call */
1393 /* GNUNET_NO == res: ignore, was simply not supported */
1396 /* NULL == address, last call, we are done */
1398 GNUNET_assert (address_resolutions > 0);
1399 address_resolutions--;
1400 if (GNUNET_NO == rc->printed)
1402 if (numeric == GNUNET_NO)
1404 /* Failed to resolve address, try numeric lookup
1405 (note: this should not be needed, as transport
1406 should fallback to numeric conversion if DNS takes
1408 resolve_peer_address (&rc->id,
1416 print_info (&rc->id,
1423 GNUNET_free (rc->transport);
1424 GNUNET_free (rc->addrcp);
1425 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc);
1427 if ((0 == address_resolutions) && (iterate_connections))
1429 if (GNUNET_SCHEDULER_NO_TASK != end)
1431 GNUNET_SCHEDULER_cancel (end);
1432 end = GNUNET_SCHEDULER_NO_TASK;
1434 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
1436 GNUNET_SCHEDULER_cancel (op_timeout);
1437 op_timeout = GNUNET_SCHEDULER_NO_TASK;
1440 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1446 resolve_peer_address (const struct GNUNET_PeerIdentity *id,
1447 const struct GNUNET_HELLO_Address *address,
1449 enum GNUNET_TRANSPORT_PeerState state,
1450 struct GNUNET_TIME_Absolute state_timeout)
1452 struct PeerResolutionContext *rc;
1454 rc = GNUNET_new (struct PeerResolutionContext);
1455 GNUNET_assert(NULL != rc);
1456 GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc);
1457 address_resolutions++;
1460 rc->transport = GNUNET_strdup(address->transport_name);
1461 rc->addrcp = GNUNET_HELLO_address_copy (address);
1462 rc->printed = GNUNET_NO;
1464 rc->state_timeout = state_timeout;
1465 /* Resolve address to string */
1466 rc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1470 &process_peer_string, rc);
1475 * Function called with information about a peers during a one shot iteration
1477 * @param cls closure
1478 * @param peer identity of the peer, NULL for final callback when operation done
1479 * @param address binary address used to communicate with this peer,
1480 * NULL on disconnect or when done
1481 * @param state current state this peer is in
1482 * @param state_timeout time out for the current state
1485 process_peer_iteration_cb (void *cls,
1486 const struct GNUNET_PeerIdentity *peer,
1487 const struct GNUNET_HELLO_Address *address,
1488 enum GNUNET_TRANSPORT_PeerState state,
1489 struct GNUNET_TIME_Absolute state_timeout)
1494 address_resolution_in_progress = GNUNET_NO;
1496 if (GNUNET_SCHEDULER_NO_TASK != end)
1497 GNUNET_SCHEDULER_cancel (end);
1498 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1502 if ( (GNUNET_NO == iterate_all) &&
1503 (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)))
1504 return; /* Display only connected peers */
1506 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
1507 GNUNET_SCHEDULER_cancel (op_timeout);
1508 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1512 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1513 "Received address for peer `%s': %s\n",
1515 address->transport_name);
1517 if (NULL != address)
1518 resolve_peer_address (peer, address, numeric, state, state_timeout);
1520 print_info (peer, NULL, NULL, state, state_timeout);
1525 * Context for address resolution by #plugin_monitoring_cb().
1527 struct PluginMonitorAddress
1531 * Ongoing resolution request.
1533 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
1536 * Resolved address as string.
1543 * Function called with a textual representation of an address. This
1544 * function will be called several times with different possible
1545 * textual representations, and a last time with @a address being NULL
1546 * to signal the end of the iteration. Note that @a address NULL
1547 * always is the last call, regardless of the value in @a res.
1549 * @param cls closure
1550 * @param address NULL on end of iteration,
1551 * otherwise 0-terminated printable UTF-8 string,
1552 * in particular an empty string if @a res is #GNUNET_NO
1553 * @param res result of the address to string conversion:
1554 * if #GNUNET_OK: conversion successful
1555 * if #GNUNET_NO: address was invalid (or not supported)
1556 * if #GNUNET_SYSERR: communication error (IPC error)
1559 address_cb (void *cls,
1560 const char *address,
1563 struct PluginMonitorAddress *addr = cls;
1565 if (NULL == address)
1570 if (NULL != addr->str)
1572 addr->str = GNUNET_strdup (address);
1577 * Function called by the plugin with information about the
1578 * current sessions managed by the plugin (for monitoring).
1580 * @param cls closure (NULL)
1581 * @param session session handle this information is about,
1582 * NULL to indicate that we are "in sync" (initial
1583 * iteration complete)
1584 * @param session_ctx storage location where the application
1585 * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT,
1586 * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE
1587 * @param info information about the state of the session,
1588 * NULL if @a session is also NULL and we are
1589 * merely signalling that the initial iteration is over;
1590 * NULL with @a session being non-NULL if the monitor
1591 * was being cancelled while sessions were active
1594 plugin_monitoring_cb (void *cls,
1595 struct GNUNET_TRANSPORT_PluginSession *session,
1597 const struct GNUNET_TRANSPORT_SessionInfo *info)
1600 struct PluginMonitorAddress *addr;
1602 if ( (NULL == info) &&
1604 return; /* in sync with transport service */
1605 if ( (NULL != cpid) &&
1606 (0 != memcmp (&info->address->peer,
1608 sizeof (struct GNUNET_PeerIdentity))) )
1609 return; /* filtered */
1610 addr = *session_ctx;
1613 addr = GNUNET_new (struct PluginMonitorAddress);
1614 addr->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1617 GNUNET_TIME_UNIT_FOREVER_REL,
1620 *session_ctx = addr;
1622 switch (info->state)
1624 case GNUNET_TRANSPORT_SS_INIT:
1627 case GNUNET_TRANSPORT_SS_HANDSHAKE:
1628 state = "HANDSHAKE";
1630 case GNUNET_TRANSPORT_SS_UP:
1633 case GNUNET_TRANSPORT_SS_UPDATE:
1636 case GNUNET_TRANSPORT_SS_DONE:
1644 "%s: %s %s (# %u/%u b) blocked until %s timeout in %s [%s]\n",
1645 GNUNET_i2s (&info->address->peer),
1647 (info->is_inbound == GNUNET_YES) ? "<-" : ((info->is_inbound == GNUNET_NO) ? "->" : "<>"),
1648 info->num_msg_pending,
1649 info->num_bytes_pending,
1650 GNUNET_STRINGS_absolute_time_to_string (info->receive_delay),
1651 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (info->session_timeout),
1654 if (GNUNET_TRANSPORT_SS_DONE == info->state)
1656 if (NULL != addr->asc)
1658 GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
1661 GNUNET_free_non_null (addr->str);
1663 *session_ctx = NULL;
1669 * Function called with information about a peers
1671 * @param cls closure
1672 * @param peer identity of the peer, NULL for final callback when operation done
1673 * @param address binary address used to communicate with this peer,
1674 * NULL on disconnect or when done
1675 * @param state current state this peer is in
1676 * @param state_timeout time out for the current state
1680 process_peer_monitoring_cb (void *cls,
1681 const struct GNUNET_PeerIdentity *peer,
1682 const struct GNUNET_HELLO_Address *address,
1683 enum GNUNET_TRANSPORT_PeerState state,
1684 struct GNUNET_TIME_Absolute state_timeout)
1686 struct MonitoredPeer *m;
1692 _("Monitor disconnected from transport service. Reconnecting.\n"));
1696 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
1697 GNUNET_SCHEDULER_cancel (op_timeout);
1698 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1702 if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer)))
1704 m = GNUNET_new (struct MonitoredPeer);
1705 GNUNET_CONTAINER_multipeermap_put (monitored_peers, peer,
1706 m, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1710 if ( (m->state == state) &&
1711 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
1712 ((NULL == address) && (NULL == m->address)))
1714 return; /* No real change */
1716 if ( (m->state == state) && ((NULL != address) && (NULL != m->address)) &&
1717 (0 == GNUNET_HELLO_address_cmp(m->address, address)))
1718 return; /* No real change */
1721 if (NULL != m->address)
1723 GNUNET_free (m->address);
1726 if (NULL != address)
1727 m->address = GNUNET_HELLO_address_copy (address);
1729 m->state_timeout = state_timeout;
1731 if (NULL != address)
1732 resolve_peer_address (peer,
1747 * Function called with our result of trying to connect to the
1748 * transport service. Will retry 10 times, and if we still
1749 * fail to connect terminate with an error message.
1752 * @param result #GNUNET_OK if we connected to the service
1755 try_connect_cb (void *cls,
1758 static int retries = 0;
1760 if (GNUNET_OK == result)
1768 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
1777 _("Failed to send connect request to transport service\n"));
1778 if (GNUNET_SCHEDULER_NO_TASK != end)
1779 GNUNET_SCHEDULER_cancel (end);
1781 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1788 try_disconnect_cb (void *cls,
1791 static int retries = 0;
1792 if (GNUNET_OK == result)
1799 tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb,
1803 FPRINTF (stderr, "%s",
1804 _("Failed to send connect request to transport service\n"));
1805 if (GNUNET_SCHEDULER_NO_TASK != end)
1806 GNUNET_SCHEDULER_cancel (end);
1808 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1815 * Function called with the result of the check if the 'transport'
1816 * service is running.
1818 * @param cls closure with our configuration
1819 * @param result #GNUNET_YES if transport is running
1822 testservice_task (void *cls, int result)
1827 if (GNUNET_YES != result)
1829 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
1835 != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid),
1838 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
1842 counter = benchmark_send + benchmark_receive + iterate_connections
1843 + monitor_connections + monitor_connects + try_connect + try_disconnect +
1844 + iterate_validation + monitor_validation + monitor_plugins;
1849 _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
1850 "connect", "benchmark send", "benchmark receive", "information",
1851 "monitor", "events", "plugins");
1857 _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
1858 "connect", "benchmark send", "benchmark receive", "information",
1859 "monitor", "events", "plugins");
1863 if (try_connect) /* -C: Connect to peer */
1867 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1872 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1873 ¬ify_connect, ¬ify_disconnect);
1876 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1880 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
1882 if (NULL == tc_handle)
1884 FPRINTF (stderr, "%s",
1885 _("Failed to send request to transport service\n"));
1889 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1893 else if (try_disconnect) /* -D: Disconnect from peer */
1897 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1902 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1903 ¬ify_connect, ¬ify_disconnect);
1906 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1910 tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb,
1912 if (NULL == tc_handle)
1914 FPRINTF (stderr, "%s",
1915 _("Failed to send request to transport service\n"));
1919 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1923 else if (benchmark_send) /* -s: Benchmark sending */
1927 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1932 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
1935 ¬ify_disconnect);
1938 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1942 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
1946 if (NULL == tc_handle)
1948 FPRINTF (stderr, "%s",
1949 _("Failed to send request to transport service\n"));
1953 start_time = GNUNET_TIME_absolute_get ();
1954 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1958 else if (benchmark_receive) /* -b: Benchmark receiving */
1960 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, NULL,
1964 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1969 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n"));
1970 start_time = GNUNET_TIME_absolute_get ();
1973 else if (iterate_connections) /* -i: List information about peers once */
1975 address_resolution_in_progress = GNUNET_YES;
1976 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
1977 GNUNET_YES, TIMEOUT, &process_peer_iteration_cb, (void *) cfg);
1978 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1981 else if (monitor_connections) /* -m: List information about peers continuously */
1983 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1984 address_resolution_in_progress = GNUNET_YES;
1985 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
1987 &process_peer_monitoring_cb, (void *) cfg);
1989 else if (monitor_plugins) /* -P: List information about plugins continuously */
1991 monitored_plugins = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1992 pm = GNUNET_TRANSPORT_monitor_plugins (cfg,
1993 &plugin_monitoring_cb,
1996 else if (iterate_validation) /* -d: Print information about validations */
1998 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
1999 (NULL == cpid) ? NULL : &pid,
2000 GNUNET_YES, TIMEOUT,
2001 &process_validation_cb, (void *) cfg);
2003 else if (monitor_validation) /* -f: Print information about validations continuously */
2005 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
2006 (NULL == cpid) ? NULL : &pid,
2008 &process_validation_cb, (void *) cfg);
2010 else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */
2012 monitor_connect_counter = 0;
2013 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL,
2014 &monitor_notify_connect,
2015 &monitor_notify_disconnect);
2020 _("Failed to connect to transport service\n"));
2032 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
2039 * Main function that will be run by the scheduler.
2041 * @param cls closure
2042 * @param args remaining command-line arguments
2043 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
2044 * @param mycfg configuration
2049 const char *cfgfile,
2050 const struct GNUNET_CONFIGURATION_Handle *mycfg)
2052 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
2053 if (test_configuration)
2055 do_test_configuration (cfg);
2058 GNUNET_CLIENT_service_test ("transport", cfg, GNUNET_TIME_UNIT_SECONDS,
2059 &testservice_task, (void *) cfg);
2063 main (int argc, char * const *argv)
2066 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
2068 gettext_noop ("print information for all peers (instead of only connected peers)"),
2069 0, &GNUNET_GETOPT_set_one, &iterate_all },
2070 { 'b', "benchmark", NULL,
2071 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
2072 0, &GNUNET_GETOPT_set_one, &benchmark_receive },
2074 NULL, gettext_noop ("connect to a peer"), 0,
2075 &GNUNET_GETOPT_set_one, &try_connect },
2076 { 'D', "disconnect",
2077 NULL, gettext_noop ("disconnect to a peer"), 0,
2078 &GNUNET_GETOPT_set_one, &try_disconnect },
2079 { 'd', "validation", NULL,
2080 gettext_noop ("print information for all pending validations "),
2081 0, &GNUNET_GETOPT_set_one, &iterate_validation },
2082 { 'f', "monitorvalidation", NULL,
2083 gettext_noop ("print information for all pending validations continuously"),
2084 0, &GNUNET_GETOPT_set_one, &monitor_validation },
2085 { 'i', "information", NULL,
2086 gettext_noop ("provide information about all current connections (once)"),
2087 0, &GNUNET_GETOPT_set_one, &iterate_connections },
2088 { 'm', "monitor", NULL,
2089 gettext_noop ("provide information about all current connections (continuously)"),
2090 0, &GNUNET_GETOPT_set_one, &monitor_connections },
2091 { 'e', "events", NULL,
2092 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
2093 0, &GNUNET_GETOPT_set_one, &monitor_connects },
2095 NULL, gettext_noop ("do not resolve hostnames"), 0,
2096 &GNUNET_GETOPT_set_one, &numeric },
2097 { 'p', "peer", "PEER",
2098 gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
2100 { 'P', "plugins", NULL,
2101 gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one,
2103 { 's', "send", NULL, gettext_noop
2104 ("send data for benchmarking to the other peer (until CTRL-C)"), 0,
2105 &GNUNET_GETOPT_set_one, &benchmark_send },
2106 { 't', "test", NULL,
2107 gettext_noop ("test transport configuration (involves external server)"),
2108 0, &GNUNET_GETOPT_set_one, &test_configuration },
2109 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
2110 GNUNET_GETOPT_OPTION_END
2113 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
2116 res = GNUNET_PROGRAM_run (argc, argv,
2118 gettext_noop ("Direct access to transport service."),
2121 GNUNET_free((void *) argv);
2122 if (GNUNET_OK == res)
2127 /* end of gnunet-transport.c */