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 struct GNUNET_SCHEDULER_Task * 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;
289 * Try disconnect handle
291 struct GNUNET_TRANSPORT_TryDisconnectHandle *td_handle;
296 static int benchmark_send;
301 static int benchmark_receive;
306 static int benchmark_receive;
311 static int iterate_connections;
316 static int iterate_validation;
321 static int iterate_all;
326 static int test_configuration;
331 static int monitor_connects;
336 static int monitor_connections;
341 static int monitor_validation;
346 static int monitor_plugins;
351 static int try_connect;
356 static int try_disconnect;
364 * Global return value (0 success).
369 * Current number of connections in monitor mode
371 static int monitor_connect_counter;
374 * Number of bytes of traffic we received so far.
376 static unsigned long long traffic_received;
379 * Number of bytes of traffic we sent so far.
381 static unsigned long long traffic_sent;
384 * Starting time of transmitting/receiving data.
386 static struct GNUNET_TIME_Absolute start_time;
389 * Handle for current transmission request.
391 static struct GNUNET_TRANSPORT_TransmitHandle *th;
394 * Map storing information about monitored peers
396 static struct GNUNET_CONTAINER_MultiPeerMap *monitored_peers;
399 * Map storing information about monitored plugins's sessions.
401 static struct GNUNET_CONTAINER_MultiPeerMap *monitored_plugins;
404 * Handle if we are monitoring peers at the transport level.
406 static struct GNUNET_TRANSPORT_PeerMonitoringContext *pic;
409 * Handle if we are monitoring transport validation activity.
411 static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic;
414 * Handle if we are monitoring plugin session activity.
416 static struct GNUNET_TRANSPORT_PluginMonitor *pm;
419 * Identity of the peer we transmit to / connect to.
420 * (equivalent to 'cpid' string).
422 static struct GNUNET_PeerIdentity pid;
425 * Task scheduled for cleanup / termination of the process.
427 static struct GNUNET_SCHEDULER_Task * end;
430 * Task for operation timeout
432 static struct GNUNET_SCHEDULER_Task * op_timeout;
435 * Selected level of verbosity.
437 static int verbosity;
440 * Resolver process handle.
442 struct GNUNET_OS_Process *resolver;
445 * Number of address resolutions pending
447 static unsigned int address_resolutions;
450 * Address resolutions pending in progress
452 static unsigned int address_resolution_in_progress;
455 * DLL for NAT Test Contexts: head
457 struct TestContext *head;
460 * DLL for NAT Test Contexts: tail
462 struct TestContext *tail;
465 * DLL: head of validation resolution entries
467 static struct ValidationResolutionContext *vc_head;
470 * DLL: tail of validation resolution entries
472 static struct ValidationResolutionContext *vc_tail;
475 * DLL: head of resolution entries
477 static struct PeerResolutionContext *rc_head;
480 * DLL: head of resolution entries
482 static struct PeerResolutionContext *rc_tail;
486 * Function called to release data stored in the #monitored_peers map.
489 * @param key the peer identity
490 * @param value a `struct MonitoredPeer` to release
491 * @return #GNUNET_OK (continue to iterate)
494 destroy_it (void *cls,
495 const struct GNUNET_PeerIdentity *key,
498 struct MonitoredPeer *m = value;
500 GNUNET_assert (GNUNET_OK ==
501 GNUNET_CONTAINER_multipeermap_remove (monitored_peers,
504 GNUNET_free_non_null (m->address);
511 * Task run in monitor mode when the user presses CTRL-C to abort.
512 * Stops monitoring activity.
515 * @param tc scheduler context
518 shutdown_task (void *cls,
519 const struct GNUNET_SCHEDULER_TaskContext *tc)
521 struct GNUNET_TIME_Relative duration;
522 struct ValidationResolutionContext *cur;
523 struct ValidationResolutionContext *next;
526 if (NULL != op_timeout)
528 GNUNET_SCHEDULER_cancel (op_timeout);
531 if (NULL != tc_handle)
533 GNUNET_TRANSPORT_try_connect_cancel (tc_handle);
538 GNUNET_TRANSPORT_monitor_peers_cancel (pic);
543 GNUNET_TRANSPORT_monitor_validation_entries_cancel (vic);
548 GNUNET_TRANSPORT_monitor_plugins_cancel (pm);
553 for (cur = next; NULL != cur; cur = next)
557 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
558 GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, cur);
559 GNUNET_free (cur->transport);
560 GNUNET_HELLO_address_free (cur->addrcp);
566 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
571 GNUNET_TRANSPORT_disconnect (handle);
576 duration = GNUNET_TIME_absolute_get_duration (start_time);
578 _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
579 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
581 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
583 if (benchmark_receive)
585 duration = GNUNET_TIME_absolute_get_duration (start_time);
587 _("Received %llu bytes/s (%llu bytes in %s)\n"),
588 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
590 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
593 if (NULL != monitored_peers)
595 GNUNET_CONTAINER_multipeermap_iterate (monitored_peers, &destroy_it, NULL);
596 GNUNET_CONTAINER_multipeermap_destroy (monitored_peers);
597 monitored_peers = NULL;
599 if (NULL != monitored_plugins)
602 GNUNET_CONTAINER_multipeermap_size (monitored_plugins));
603 GNUNET_CONTAINER_multipeermap_destroy (monitored_plugins);
604 monitored_plugins = NULL;
610 operation_timeout (void *cls,
611 const struct GNUNET_SCHEDULER_TaskContext *tc)
613 struct PeerResolutionContext *cur;
614 struct PeerResolutionContext *next;
616 if ((try_connect) || (benchmark_send) || (benchmark_receive))
619 _("Failed to connect to `%s'\n"),
620 GNUNET_i2s_full (&pid));
622 GNUNET_SCHEDULER_cancel (end);
623 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
627 if (iterate_connections)
630 while (NULL != (cur = next))
634 _("Failed to resolve address for peer `%s'\n"),
635 GNUNET_i2s (&cur->addrcp->peer));
637 GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur);
638 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
639 GNUNET_free(cur->transport);
640 GNUNET_free(cur->addrcp);
646 _("Failed to list connections, timeout occured\n"));
648 GNUNET_SCHEDULER_cancel (end);
649 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
661 * Display the result of the test.
663 * @param tc test context
664 * @param result #GNUNET_YES on success
667 display_test_result (struct TestContext *tc,
668 enum TestResult result)
673 _("Configuration for plugin `%s' did not work!\n"),
676 case NAT_TEST_SUCCESS:
678 _("Configuration for plugin `%s' did work!\n"),
681 case NAT_TEST_INTERNAL_FAIL:
683 _("Internal NAT error while running test for plugin `%s'\n"),
686 case NAT_TEST_FAILED_TO_START:
688 _("Failed to start NAT test for plugin `%s'\n"),
691 case NAT_TEST_TIMEOUT:
693 _("Timeout while waiting for result of NAT test for plugin `%s'\n"),
698 _("Configuration for plugin `%s' did not work!\n"),
704 GNUNET_SCHEDULER_cancel (tc->tsk);
709 GNUNET_NAT_test_stop (tc->tst);
713 GNUNET_CONTAINER_DLL_remove (head, tail, tc);
714 GNUNET_free (tc->name);
717 if ((NULL == head) && (NULL != resolver))
719 GNUNET_break (0 == GNUNET_OS_process_kill (resolver,
721 GNUNET_OS_process_destroy (resolver);
729 * Function called by NAT to report the outcome of the nat-test.
730 * Clean up and update GUI.
732 * @param cls test context
733 * @param result status code
736 result_callback (void *cls,
737 enum GNUNET_NAT_StatusCode result)
739 struct TestContext *tc = cls;
741 display_test_result (tc, result);
746 * Resolve address we got a validation state for to a string.
748 * @param id peer identity the address is for
749 * @param address the address itself
750 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
751 * @param last_validation when was the address validated last
752 * @param valid_until until when is the address valid
753 * @param next_validation when will we try to revalidate the address next
754 * @param state where are we in the validation state machine
757 resolve_validation_address (const struct GNUNET_PeerIdentity *id,
758 const struct GNUNET_HELLO_Address *address,
760 struct GNUNET_TIME_Absolute last_validation,
761 struct GNUNET_TIME_Absolute valid_until,
762 struct GNUNET_TIME_Absolute next_validation,
763 enum GNUNET_TRANSPORT_ValidationState state);
767 * Function to call with a textual representation of an address. This
768 * function will be called several times with different possible
769 * textual representations, and a last time with @a address being NULL
770 * to signal the end of the iteration. Note that @a address NULL
771 * always is the last call, regardless of the value in @a res.
774 * @param address NULL on end of iteration,
775 * otherwise 0-terminated printable UTF-8 string,
776 * in particular an empty string if @a res is #GNUNET_NO
777 * @param res result of the address to string conversion:
778 * if #GNUNET_OK: conversion successful
779 * if #GNUNET_NO: address was invalid (or not supported)
780 * if #GNUNET_SYSERR: communication error (IPC error)
783 process_validation_string (void *cls,
787 struct ValidationResolutionContext *vc = cls;
794 if (GNUNET_SYSERR == res)
797 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
798 GNUNET_i2s (&vc->id),
799 vc->addrcp->transport_name,
800 (unsigned int) vc->addrcp->address_length);
802 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->valid_until.abs_value_us)
803 s_valid = GNUNET_strdup ("never");
805 s_valid = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->valid_until));
807 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->last_validation.abs_value_us)
808 s_last = GNUNET_strdup ("never");
810 s_last = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->last_validation));
812 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->next_validation.abs_value_us)
813 s_next = GNUNET_strdup ("never");
815 s_next = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->next_validation));
818 _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"),
819 GNUNET_i2s (&vc->id),
820 (GNUNET_OK == res) ? address : "<invalid address>",
821 (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "",
822 "Valid until : ", s_valid,
823 "Last validation: ",s_last,
824 "Next validation: ", s_next);
825 GNUNET_free (s_valid);
826 GNUNET_free (s_last);
827 GNUNET_free (s_next);
828 vc->printed = GNUNET_YES;
831 /* last call, we are done */
832 GNUNET_assert (address_resolutions > 0);
833 address_resolutions--;
834 if ( (GNUNET_SYSERR == res) &&
835 (GNUNET_NO == vc->printed))
837 if (numeric == GNUNET_NO)
839 /* Failed to resolve address, try numeric lookup
840 (note: this should be unnecessary, as
841 transport should fallback to numeric lookup
842 internally if DNS takes too long anyway) */
843 resolve_validation_address (&vc->id,
854 _("Peer `%s' %s `%s' \n"),
855 GNUNET_i2s (&vc->id),
856 "<unable to resolve address>",
857 GNUNET_TRANSPORT_vs2s (vc->state));
860 GNUNET_free (vc->transport);
861 GNUNET_free (vc->addrcp);
862 GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, vc);
864 if ((0 == address_resolutions) && (iterate_validation))
868 GNUNET_SCHEDULER_cancel (end);
871 if (NULL != op_timeout)
873 GNUNET_SCHEDULER_cancel (op_timeout);
877 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
883 * Resolve address we got a validation state for to a string.
885 * @param id peer identity the address is for
886 * @param address the address itself
887 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
888 * @param last_validation when was the address validated last
889 * @param valid_until until when is the address valid
890 * @param next_validation when will we try to revalidate the address next
891 * @param state where are we in the validation state machine
894 resolve_validation_address (const struct GNUNET_PeerIdentity *id,
895 const struct GNUNET_HELLO_Address *address,
897 struct GNUNET_TIME_Absolute last_validation,
898 struct GNUNET_TIME_Absolute valid_until,
899 struct GNUNET_TIME_Absolute next_validation,
900 enum GNUNET_TRANSPORT_ValidationState state)
902 struct ValidationResolutionContext *vc;
904 vc = GNUNET_new (struct ValidationResolutionContext);
905 GNUNET_assert(NULL != vc);
906 GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc);
907 address_resolutions++;
910 vc->transport = GNUNET_strdup(address->transport_name);
911 vc->addrcp = GNUNET_HELLO_address_copy (address);
912 vc->printed = GNUNET_NO;
914 vc->last_validation = last_validation;
915 vc->valid_until = valid_until;
916 vc->next_validation = next_validation;
918 /* Resolve address to string */
919 vc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
923 &process_validation_string, vc);
928 * Resolve address we got a validation state for to a string.
931 * @param peer peer identity the address is for
932 * @param address the address itself
933 * @param last_validation when was the address validated last
934 * @param valid_until until when is the address valid
935 * @param next_validation when will we try to revalidate the address next
936 * @param state where are we in the validation state machine
939 process_validation_cb (void *cls,
940 const struct GNUNET_PeerIdentity *peer,
941 const struct GNUNET_HELLO_Address *address,
942 struct GNUNET_TIME_Absolute last_validation,
943 struct GNUNET_TIME_Absolute valid_until,
944 struct GNUNET_TIME_Absolute next_validation,
945 enum GNUNET_TRANSPORT_ValidationState state)
947 if ((NULL == peer) && (NULL == address))
949 if (monitor_validation)
953 _("Monitor disconnected from transport service. Reconnecting.\n"));
960 GNUNET_SCHEDULER_cancel (end);
961 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
964 if ((NULL == peer) || (NULL == address))
966 /* invalid response */
969 GNUNET_SCHEDULER_cancel (end);
970 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
973 resolve_validation_address (peer,
986 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
987 "Running test for plugin `%s' using bind port %u and advertised port %u \n",
989 (uint16_t) head->bnd_port,
990 (uint16_t) head->adv_port);
992 head->tst = GNUNET_NAT_test_start (cfg,
993 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES,
994 (uint16_t) head->bnd_port,
995 (uint16_t) head->adv_port,
997 &result_callback, head);
1002 * Test our plugin's configuration (NAT traversal, etc.).
1004 * @param cfg configuration to test
1007 do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
1011 unsigned long long bnd_port;
1012 unsigned long long adv_port;
1013 struct TestContext *tc;
1017 != GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
1020 FPRINTF (stderr, "%s", _
1021 ("No transport plugins configured, peer will never communicate\n"));
1026 for (tok = strtok (plugins, " "); tok != NULL ; tok = strtok (NULL, " "))
1028 char section[12 + strlen (tok)];
1029 GNUNET_snprintf (section, sizeof(section), "transport-%s", tok);
1031 != GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT",
1035 _("No port configured for plugin `%s', cannot test it\n"), tok);
1038 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, section,
1039 "ADVERTISED_PORT", &adv_port))
1040 adv_port = bnd_port;
1042 tc = GNUNET_new (struct TestContext);
1043 tc->name = GNUNET_strdup (tok);
1044 tc->adv_port = adv_port;
1045 tc->bnd_port = bnd_port;
1046 GNUNET_CONTAINER_DLL_insert_tail (head, tail, tc);
1048 GNUNET_free(plugins);
1050 if ((NULL != head) && (NULL == resolver))
1052 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
1053 resolver = GNUNET_OS_start_process (GNUNET_YES,
1054 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1057 "gnunet-service-resolver", NULL);
1058 if (NULL == resolver)
1060 FPRINTF (stderr, _("Failed to start resolver!\n"));
1064 GNUNET_free(binary);
1065 GNUNET_RESOLVER_connect (cfg);
1072 * Function called to notify a client about the socket
1073 * begin ready to queue more data. @a buf will be
1074 * NULL and @a size zero if the socket was closed for
1075 * writing in the meantime.
1077 * @param cls closure
1078 * @param size number of bytes available in @a buf
1079 * @param buf where the callee should write the message
1080 * @return number of bytes written to @a buf
1083 transmit_data (void *cls,
1087 struct GNUNET_MessageHeader *m = buf;
1089 if ((NULL == buf) || (0 == size))
1095 GNUNET_assert(size >= sizeof(struct GNUNET_MessageHeader));
1096 GNUNET_assert(size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
1097 m->size = ntohs (size);
1098 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
1099 memset (&m[1], 52, size - sizeof(struct GNUNET_MessageHeader));
1100 traffic_sent += size;
1101 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid,
1103 GNUNET_TIME_UNIT_FOREVER_REL,
1104 &transmit_data, NULL);
1106 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
1113 * Function called to notify transport users that another
1114 * peer connected to us.
1116 * @param cls closure
1117 * @param peer the peer that connected
1120 notify_connect (void *cls,
1121 const struct GNUNET_PeerIdentity *peer)
1123 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1128 /* all done, terminate instantly */
1129 FPRINTF (stdout, _("Successfully connected to `%s'\n"),
1130 GNUNET_i2s_full (peer));
1133 if (NULL != op_timeout)
1135 GNUNET_SCHEDULER_cancel (op_timeout);
1140 GNUNET_SCHEDULER_cancel (end);
1141 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1146 if (NULL != op_timeout)
1148 GNUNET_SCHEDULER_cancel (op_timeout);
1153 _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
1154 GNUNET_i2s (&pid), BLOCKSIZE);
1155 start_time = GNUNET_TIME_absolute_get ();
1157 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer,
1159 GNUNET_TIME_UNIT_FOREVER_REL,
1170 * Function called to notify transport users that another
1171 * peer disconnected from us.
1173 * @param cls closure
1174 * @param peer the peer that disconnected
1177 notify_disconnect (void *cls,
1178 const struct GNUNET_PeerIdentity *peer)
1180 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1185 /* all done, terminate instantly */
1186 FPRINTF (stdout, _("Successfully disconnected from `%s'\n"),
1187 GNUNET_i2s_full (peer));
1190 if (NULL != op_timeout)
1192 GNUNET_SCHEDULER_cancel (op_timeout);
1197 GNUNET_SCHEDULER_cancel (end);
1198 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1204 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
1209 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"),
1212 GNUNET_SCHEDULER_cancel (end);
1219 * Function called to notify transport users that another
1220 * peer connected to us.
1222 * @param cls closure
1223 * @param peer the peer that connected
1226 monitor_notify_connect (void *cls,
1227 const struct GNUNET_PeerIdentity *peer)
1229 monitor_connect_counter++;
1230 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1231 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1234 _("%24s: %-17s %4s (%u connections in total)\n"),
1238 monitor_connect_counter);
1243 * Function called to notify transport users that another
1244 * peer disconnected from us.
1246 * @param cls closure
1247 * @param peer the peer that disconnected
1250 monitor_notify_disconnect (void *cls,
1251 const struct GNUNET_PeerIdentity *peer)
1253 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1254 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1256 GNUNET_assert(monitor_connect_counter > 0);
1257 monitor_connect_counter--;
1260 _("%24s: %-17s %4s (%u connections in total)\n"),
1262 _("Disconnected from"),
1264 monitor_connect_counter);
1269 * Function called by the transport for each received message.
1271 * @param cls closure
1272 * @param peer (claimed) identity of the other peer
1273 * @param message the message
1276 notify_receive (void *cls,
1277 const struct GNUNET_PeerIdentity *peer,
1278 const struct GNUNET_MessageHeader *message)
1280 if (benchmark_receive)
1282 if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type))
1286 _("Received %u bytes from %s\n"),
1287 (unsigned int) ntohs (message->size),
1290 if (traffic_received == 0)
1291 start_time = GNUNET_TIME_absolute_get ();
1292 traffic_received += ntohs (message->size);
1299 resolve_peer_address (const struct GNUNET_PeerIdentity *id,
1300 const struct GNUNET_HELLO_Address *address,
1302 enum GNUNET_TRANSPORT_PeerState state,
1303 struct GNUNET_TIME_Absolute state_timeout);
1307 print_info (const struct GNUNET_PeerIdentity *id,
1308 const char *transport,
1310 enum GNUNET_TRANSPORT_PeerState state,
1311 struct GNUNET_TIME_Absolute state_timeout)
1314 if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
1315 (GNUNET_YES == monitor_connections))
1318 _("Peer `%s': %s %s in state `%s' until %s\n"),
1320 (NULL == transport) ? "<none>" : transport,
1321 (NULL == transport) ? "<none>" : addr,
1322 GNUNET_TRANSPORT_ps2s (state),
1323 GNUNET_STRINGS_absolute_time_to_string (state_timeout));
1325 else if ( (GNUNET_YES == iterate_connections) &&
1326 (GNUNET_TRANSPORT_is_connected(state)))
1328 /* Only connected peers, skip state */
1330 _("Peer `%s': %s %s\n"),
1339 * Function called with a textual representation of an address. This
1340 * function will be called several times with different possible
1341 * textual representations, and a last time with @a address being NULL
1342 * to signal the end of the iteration. Note that @a address NULL
1343 * always is the last call, regardless of the value in @a res.
1345 * @param cls closure
1346 * @param address NULL on end of iteration,
1347 * otherwise 0-terminated printable UTF-8 string,
1348 * in particular an empty string if @a res is #GNUNET_NO
1349 * @param res result of the address to string conversion:
1350 * if #GNUNET_OK: conversion successful
1351 * if #GNUNET_NO: address was invalid (or not supported)
1352 * if #GNUNET_SYSERR: communication error (IPC error)
1355 process_peer_string (void *cls,
1356 const char *address,
1359 struct PeerResolutionContext *rc = cls;
1361 if (NULL != address)
1363 if (GNUNET_SYSERR == res)
1366 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
1367 GNUNET_i2s (&rc->id),
1368 rc->addrcp->transport_name,
1369 (unsigned int) rc->addrcp->address_length);
1370 print_info (&rc->id,
1375 rc->printed = GNUNET_YES;
1378 if (GNUNET_OK == res)
1380 print_info (&rc->id,
1385 rc->printed = GNUNET_YES;
1386 return; /* Wait for done call */
1388 /* GNUNET_NO == res: ignore, was simply not supported */
1391 /* NULL == address, last call, we are done */
1393 GNUNET_assert (address_resolutions > 0);
1394 address_resolutions--;
1395 if (GNUNET_NO == rc->printed)
1397 if (numeric == GNUNET_NO)
1399 /* Failed to resolve address, try numeric lookup
1400 (note: this should not be needed, as transport
1401 should fallback to numeric conversion if DNS takes
1403 resolve_peer_address (&rc->id,
1411 print_info (&rc->id,
1418 GNUNET_free (rc->transport);
1419 GNUNET_free (rc->addrcp);
1420 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc);
1422 if ((0 == address_resolutions) && (iterate_connections))
1426 GNUNET_SCHEDULER_cancel (end);
1429 if (NULL != op_timeout)
1431 GNUNET_SCHEDULER_cancel (op_timeout);
1435 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1441 resolve_peer_address (const struct GNUNET_PeerIdentity *id,
1442 const struct GNUNET_HELLO_Address *address,
1444 enum GNUNET_TRANSPORT_PeerState state,
1445 struct GNUNET_TIME_Absolute state_timeout)
1447 struct PeerResolutionContext *rc;
1449 rc = GNUNET_new (struct PeerResolutionContext);
1450 GNUNET_assert(NULL != rc);
1451 GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc);
1452 address_resolutions++;
1455 rc->transport = GNUNET_strdup(address->transport_name);
1456 rc->addrcp = GNUNET_HELLO_address_copy (address);
1457 rc->printed = GNUNET_NO;
1459 rc->state_timeout = state_timeout;
1460 /* Resolve address to string */
1461 rc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1465 &process_peer_string, rc);
1470 * Function called with information about a peers during a one shot iteration
1472 * @param cls closure
1473 * @param peer identity of the peer, NULL for final callback when operation done
1474 * @param address binary address used to communicate with this peer,
1475 * NULL on disconnect or when done
1476 * @param state current state this peer is in
1477 * @param state_timeout time out for the current state
1480 process_peer_iteration_cb (void *cls,
1481 const struct GNUNET_PeerIdentity *peer,
1482 const struct GNUNET_HELLO_Address *address,
1483 enum GNUNET_TRANSPORT_PeerState state,
1484 struct GNUNET_TIME_Absolute state_timeout)
1489 address_resolution_in_progress = GNUNET_NO;
1492 GNUNET_SCHEDULER_cancel (end);
1493 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1497 if ( (GNUNET_NO == iterate_all) &&
1498 (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)))
1499 return; /* Display only connected peers */
1501 if (NULL != op_timeout)
1502 GNUNET_SCHEDULER_cancel (op_timeout);
1503 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1508 "Received address for peer `%s': %s\n",
1510 address->transport_name);
1512 if (NULL != address)
1513 resolve_peer_address (peer, address, numeric, state, state_timeout);
1515 print_info (peer, NULL, NULL, state, state_timeout);
1520 * Context for address resolution by #plugin_monitoring_cb().
1522 struct PluginMonitorAddress
1526 * Ongoing resolution request.
1528 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
1531 * Resolved address as string.
1538 * Function called with a textual representation of an address. This
1539 * function will be called several times with different possible
1540 * textual representations, and a last time with @a address being NULL
1541 * to signal the end of the iteration. Note that @a address NULL
1542 * always is the last call, regardless of the value in @a res.
1544 * @param cls closure
1545 * @param address NULL on end of iteration,
1546 * otherwise 0-terminated printable UTF-8 string,
1547 * in particular an empty string if @a res is #GNUNET_NO
1548 * @param res result of the address to string conversion:
1549 * if #GNUNET_OK: conversion successful
1550 * if #GNUNET_NO: address was invalid (or not supported)
1551 * if #GNUNET_SYSERR: communication error (IPC error)
1554 address_cb (void *cls,
1555 const char *address,
1558 struct PluginMonitorAddress *addr = cls;
1560 if (NULL == address)
1565 if (NULL != addr->str)
1567 addr->str = GNUNET_strdup (address);
1572 * Function called by the plugin with information about the
1573 * current sessions managed by the plugin (for monitoring).
1575 * @param cls closure (NULL)
1576 * @param session session handle this information is about,
1577 * NULL to indicate that we are "in sync" (initial
1578 * iteration complete)
1579 * @param session_ctx storage location where the application
1580 * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT,
1581 * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE
1582 * @param info information about the state of the session,
1583 * NULL if @a session is also NULL and we are
1584 * merely signalling that the initial iteration is over;
1585 * NULL with @a session being non-NULL if the monitor
1586 * was being cancelled while sessions were active
1589 plugin_monitoring_cb (void *cls,
1590 struct GNUNET_TRANSPORT_PluginSession *session,
1592 const struct GNUNET_TRANSPORT_SessionInfo *info)
1595 struct PluginMonitorAddress *addr;
1597 if ( (NULL == info) &&
1599 return; /* in sync with transport service */
1600 addr = *session_ctx;
1605 if (NULL != addr->asc)
1607 GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
1610 GNUNET_free_non_null (addr->str);
1612 *session_ctx = NULL;
1614 return; /* shutdown */
1616 if ( (NULL != cpid) &&
1617 (0 != memcmp (&info->address->peer,
1619 sizeof (struct GNUNET_PeerIdentity))) )
1620 return; /* filtered */
1623 addr = GNUNET_new (struct PluginMonitorAddress);
1624 addr->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1627 GNUNET_TIME_UNIT_FOREVER_REL,
1630 *session_ctx = addr;
1632 switch (info->state)
1634 case GNUNET_TRANSPORT_SS_INIT:
1637 case GNUNET_TRANSPORT_SS_HANDSHAKE:
1638 state = "HANDSHAKE";
1640 case GNUNET_TRANSPORT_SS_UP:
1643 case GNUNET_TRANSPORT_SS_UPDATE:
1646 case GNUNET_TRANSPORT_SS_DONE:
1654 "%s: %s %s (# %u/%u b) blocked until %s timeout in %s [%s]\n",
1655 GNUNET_i2s (&info->address->peer),
1657 (info->is_inbound == GNUNET_YES) ? "<-" : ((info->is_inbound == GNUNET_NO) ? "->" : "<>"),
1658 info->num_msg_pending,
1659 info->num_bytes_pending,
1660 GNUNET_STRINGS_absolute_time_to_string (info->receive_delay),
1661 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (info->session_timeout),
1664 if (GNUNET_TRANSPORT_SS_DONE == info->state)
1666 if (NULL != addr->asc)
1668 GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
1671 GNUNET_free_non_null (addr->str);
1673 *session_ctx = NULL;
1679 * Function called with information about a peers
1681 * @param cls closure
1682 * @param peer identity of the peer, NULL for final callback when operation done
1683 * @param address binary address used to communicate with this peer,
1684 * NULL on disconnect or when done
1685 * @param state current state this peer is in
1686 * @param state_timeout time out for the current state
1690 process_peer_monitoring_cb (void *cls,
1691 const struct GNUNET_PeerIdentity *peer,
1692 const struct GNUNET_HELLO_Address *address,
1693 enum GNUNET_TRANSPORT_PeerState state,
1694 struct GNUNET_TIME_Absolute state_timeout)
1696 struct MonitoredPeer *m;
1702 _("Monitor disconnected from transport service. Reconnecting.\n"));
1706 if (NULL != op_timeout)
1707 GNUNET_SCHEDULER_cancel (op_timeout);
1708 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1712 if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer)))
1714 m = GNUNET_new (struct MonitoredPeer);
1715 GNUNET_CONTAINER_multipeermap_put (monitored_peers, peer,
1716 m, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1720 if ( (m->state == state) &&
1721 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
1722 ((NULL == address) && (NULL == m->address)))
1724 return; /* No real change */
1726 if ( (m->state == state) && ((NULL != address) && (NULL != m->address)) &&
1727 (0 == GNUNET_HELLO_address_cmp(m->address, address)))
1728 return; /* No real change */
1731 if (NULL != m->address)
1733 GNUNET_free (m->address);
1736 if (NULL != address)
1737 m->address = GNUNET_HELLO_address_copy (address);
1739 m->state_timeout = state_timeout;
1741 if (NULL != address)
1742 resolve_peer_address (peer,
1757 * Function called with our result of trying to connect to a peer
1758 * using the transport service. Will retry 10 times, and if we still
1759 * fail to connect terminate with an error message.
1762 * @param result #GNUNET_OK if we connected to the service
1765 try_connect_cb (void *cls,
1768 static int retries = 0;
1771 if (GNUNET_OK == result)
1776 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
1784 _("Failed to send connect request to transport service\n"));
1786 GNUNET_SCHEDULER_cancel (end);
1788 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1793 * Function called with our result of trying to disconnect a peer
1794 * using the transport service. Will retry 10 times, and if we still
1795 * fail to disconnect, terminate with an error message.
1798 * @param result #GNUNET_OK if we connected to the service
1801 try_disconnect_cb (void *cls,
1804 static int retries = 0;
1807 if (GNUNET_OK == result)
1812 td_handle = GNUNET_TRANSPORT_try_disconnect (handle,
1818 FPRINTF (stderr, "%s",
1819 _("Failed to send disconnect request to transport service\n"));
1821 GNUNET_SCHEDULER_cancel (end);
1823 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1828 * Function called with the result of the check if the 'transport'
1829 * service is running.
1831 * @param cls closure with our configuration
1832 * @param result #GNUNET_YES if transport is running
1835 testservice_task (void *cls,
1841 if (GNUNET_YES != result)
1843 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
1849 != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid),
1852 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
1856 counter = benchmark_send + benchmark_receive + iterate_connections
1857 + monitor_connections + monitor_connects + try_connect + try_disconnect +
1858 + iterate_validation + monitor_validation + monitor_plugins;
1863 _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
1864 "connect", "benchmark send", "benchmark receive", "information",
1865 "monitor", "events", "plugins");
1871 _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
1872 "connect", "benchmark send", "benchmark receive", "information",
1873 "monitor", "events", "plugins");
1877 if (try_connect) /* -C: Connect to peer */
1881 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1886 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1887 ¬ify_connect, ¬ify_disconnect);
1890 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1894 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
1896 if (NULL == tc_handle)
1898 FPRINTF (stderr, "%s",
1899 _("Failed to send request to transport service\n"));
1903 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1907 else if (try_disconnect) /* -D: Disconnect from peer */
1911 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1916 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1917 ¬ify_connect, ¬ify_disconnect);
1920 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1924 td_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid,
1927 if (NULL == td_handle)
1929 FPRINTF (stderr, "%s",
1930 _("Failed to send request to transport service\n"));
1934 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1938 else if (benchmark_send) /* -s: Benchmark sending */
1942 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1947 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
1950 ¬ify_disconnect);
1953 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1957 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
1961 if (NULL == tc_handle)
1963 FPRINTF (stderr, "%s",
1964 _("Failed to send request to transport service\n"));
1968 start_time = GNUNET_TIME_absolute_get ();
1969 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1973 else if (benchmark_receive) /* -b: Benchmark receiving */
1975 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, NULL,
1979 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1984 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n"));
1985 start_time = GNUNET_TIME_absolute_get ();
1988 else if (iterate_connections) /* -i: List information about peers once */
1990 address_resolution_in_progress = GNUNET_YES;
1991 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
1992 GNUNET_YES, TIMEOUT, &process_peer_iteration_cb, (void *) cfg);
1993 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1996 else if (monitor_connections) /* -m: List information about peers continuously */
1998 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1999 address_resolution_in_progress = GNUNET_YES;
2000 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
2002 &process_peer_monitoring_cb, (void *) cfg);
2004 else if (monitor_plugins) /* -P: List information about plugins continuously */
2006 monitored_plugins = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
2007 pm = GNUNET_TRANSPORT_monitor_plugins (cfg,
2008 &plugin_monitoring_cb,
2011 else if (iterate_validation) /* -d: Print information about validations */
2013 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
2014 (NULL == cpid) ? NULL : &pid,
2015 GNUNET_YES, TIMEOUT,
2016 &process_validation_cb, (void *) cfg);
2018 else if (monitor_validation) /* -f: Print information about validations continuously */
2020 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
2021 (NULL == cpid) ? NULL : &pid,
2023 &process_validation_cb, (void *) cfg);
2025 else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */
2027 monitor_connect_counter = 0;
2028 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL,
2029 &monitor_notify_connect,
2030 &monitor_notify_disconnect);
2035 _("Failed to connect to transport service\n"));
2047 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
2054 * Main function that will be run by the scheduler.
2056 * @param cls closure
2057 * @param args remaining command-line arguments
2058 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
2059 * @param mycfg configuration
2064 const char *cfgfile,
2065 const struct GNUNET_CONFIGURATION_Handle *mycfg)
2067 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
2068 if (test_configuration)
2070 do_test_configuration (cfg);
2073 GNUNET_CLIENT_service_test ("transport", cfg, GNUNET_TIME_UNIT_SECONDS,
2074 &testservice_task, (void *) cfg);
2078 main (int argc, char * const *argv)
2081 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
2083 gettext_noop ("print information for all peers (instead of only connected peers)"),
2084 0, &GNUNET_GETOPT_set_one, &iterate_all },
2085 { 'b', "benchmark", NULL,
2086 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
2087 0, &GNUNET_GETOPT_set_one, &benchmark_receive },
2089 NULL, gettext_noop ("connect to a peer"), 0,
2090 &GNUNET_GETOPT_set_one, &try_connect },
2091 { 'D', "disconnect",
2092 NULL, gettext_noop ("disconnect to a peer"), 0,
2093 &GNUNET_GETOPT_set_one, &try_disconnect },
2094 { 'd', "validation", NULL,
2095 gettext_noop ("print information for all pending validations "),
2096 0, &GNUNET_GETOPT_set_one, &iterate_validation },
2097 { 'f', "monitorvalidation", NULL,
2098 gettext_noop ("print information for all pending validations continuously"),
2099 0, &GNUNET_GETOPT_set_one, &monitor_validation },
2100 { 'i', "information", NULL,
2101 gettext_noop ("provide information about all current connections (once)"),
2102 0, &GNUNET_GETOPT_set_one, &iterate_connections },
2103 { 'm', "monitor", NULL,
2104 gettext_noop ("provide information about all current connections (continuously)"),
2105 0, &GNUNET_GETOPT_set_one, &monitor_connections },
2106 { 'e', "events", NULL,
2107 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
2108 0, &GNUNET_GETOPT_set_one, &monitor_connects },
2110 NULL, gettext_noop ("do not resolve hostnames"), 0,
2111 &GNUNET_GETOPT_set_one, &numeric },
2112 { 'p', "peer", "PEER",
2113 gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
2115 { 'P', "plugins", NULL,
2116 gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one,
2118 { 's', "send", NULL, gettext_noop
2119 ("send data for benchmarking to the other peer (until CTRL-C)"), 0,
2120 &GNUNET_GETOPT_set_one, &benchmark_send },
2121 { 't', "test", NULL,
2122 gettext_noop ("test transport configuration (involves external server)"),
2123 0, &GNUNET_GETOPT_set_one, &test_configuration },
2124 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
2125 GNUNET_GETOPT_OPTION_END
2128 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
2131 res = GNUNET_PROGRAM_run (argc, argv,
2133 gettext_noop ("Direct access to transport service."),
2136 GNUNET_free((void *) argv);
2137 if (GNUNET_OK == res)
2142 /* end of gnunet-transport.c */