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"),
700 if (GNUNET_YES != result)
703 _("Configuration for plugin `%s' did not work!\n"),
709 _("Configuration for plugin `%s' is working!\n"),
714 GNUNET_SCHEDULER_cancel (tc->tsk);
719 GNUNET_NAT_test_stop (tc->tst);
723 GNUNET_CONTAINER_DLL_remove (head, tail, tc);
724 GNUNET_free (tc->name);
727 if ((NULL == head) && (NULL != resolver))
729 GNUNET_break (0 == GNUNET_OS_process_kill (resolver,
731 GNUNET_OS_process_destroy (resolver);
739 * Function called by NAT to report the outcome of the nat-test.
740 * Clean up and update GUI.
742 * @param cls test context
743 * @param result status code
746 result_callback (void *cls,
747 enum GNUNET_NAT_StatusCode result)
749 struct TestContext *tc = cls;
751 display_test_result (tc, result);
756 * Resolve address we got a validation state for to a string.
758 * @param id peer identity the address is for
759 * @param address the address itself
760 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
761 * @param last_validation when was the address validated last
762 * @param valid_until until when is the address valid
763 * @param next_validation when will we try to revalidate the address next
764 * @param state where are we in the validation state machine
767 resolve_validation_address (const struct GNUNET_PeerIdentity *id,
768 const struct GNUNET_HELLO_Address *address,
770 struct GNUNET_TIME_Absolute last_validation,
771 struct GNUNET_TIME_Absolute valid_until,
772 struct GNUNET_TIME_Absolute next_validation,
773 enum GNUNET_TRANSPORT_ValidationState state);
777 * Function to call with a textual representation of an address. This
778 * function will be called several times with different possible
779 * textual representations, and a last time with @a address being NULL
780 * to signal the end of the iteration. Note that @a address NULL
781 * always is the last call, regardless of the value in @a res.
784 * @param address NULL on end of iteration,
785 * otherwise 0-terminated printable UTF-8 string,
786 * in particular an empty string if @a res is #GNUNET_NO
787 * @param res result of the address to string conversion:
788 * if #GNUNET_OK: conversion successful
789 * if #GNUNET_NO: address was invalid (or not supported)
790 * if #GNUNET_SYSERR: communication error (IPC error)
793 process_validation_string (void *cls,
797 struct ValidationResolutionContext *vc = cls;
804 if (GNUNET_SYSERR == res)
807 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
808 GNUNET_i2s (&vc->id),
809 vc->addrcp->transport_name,
810 (unsigned int) vc->addrcp->address_length);
812 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->valid_until.abs_value_us)
813 s_valid = GNUNET_strdup ("never");
815 s_valid = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->valid_until));
817 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->last_validation.abs_value_us)
818 s_last = GNUNET_strdup ("never");
820 s_last = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->last_validation));
822 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->next_validation.abs_value_us)
823 s_next = GNUNET_strdup ("never");
825 s_next = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->next_validation));
828 _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"),
829 GNUNET_i2s (&vc->id),
830 (GNUNET_OK == res) ? address : "<invalid address>",
831 (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "",
832 "Valid until : ", s_valid,
833 "Last validation: ",s_last,
834 "Next validation: ", s_next);
835 GNUNET_free (s_valid);
836 GNUNET_free (s_last);
837 GNUNET_free (s_next);
838 vc->printed = GNUNET_YES;
841 /* last call, we are done */
842 GNUNET_assert (address_resolutions > 0);
843 address_resolutions--;
844 if ( (GNUNET_SYSERR == res) &&
845 (GNUNET_NO == vc->printed))
847 if (numeric == GNUNET_NO)
849 /* Failed to resolve address, try numeric lookup
850 (note: this should be unnecessary, as
851 transport should fallback to numeric lookup
852 internally if DNS takes too long anyway) */
853 resolve_validation_address (&vc->id,
864 _("Peer `%s' %s `%s' \n"),
865 GNUNET_i2s (&vc->id),
866 "<unable to resolve address>",
867 GNUNET_TRANSPORT_vs2s (vc->state));
870 GNUNET_free (vc->transport);
871 GNUNET_free (vc->addrcp);
872 GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, vc);
874 if ((0 == address_resolutions) && (iterate_validation))
878 GNUNET_SCHEDULER_cancel (end);
881 if (NULL != op_timeout)
883 GNUNET_SCHEDULER_cancel (op_timeout);
887 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
893 * Resolve address we got a validation state for to a string.
895 * @param id peer identity the address is for
896 * @param address the address itself
897 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
898 * @param last_validation when was the address validated last
899 * @param valid_until until when is the address valid
900 * @param next_validation when will we try to revalidate the address next
901 * @param state where are we in the validation state machine
904 resolve_validation_address (const struct GNUNET_PeerIdentity *id,
905 const struct GNUNET_HELLO_Address *address,
907 struct GNUNET_TIME_Absolute last_validation,
908 struct GNUNET_TIME_Absolute valid_until,
909 struct GNUNET_TIME_Absolute next_validation,
910 enum GNUNET_TRANSPORT_ValidationState state)
912 struct ValidationResolutionContext *vc;
914 vc = GNUNET_new (struct ValidationResolutionContext);
915 GNUNET_assert(NULL != vc);
916 GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc);
917 address_resolutions++;
920 vc->transport = GNUNET_strdup(address->transport_name);
921 vc->addrcp = GNUNET_HELLO_address_copy (address);
922 vc->printed = GNUNET_NO;
924 vc->last_validation = last_validation;
925 vc->valid_until = valid_until;
926 vc->next_validation = next_validation;
928 /* Resolve address to string */
929 vc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
933 &process_validation_string, vc);
938 * Resolve address we got a validation state for to a string.
941 * @param peer peer identity the address is for
942 * @param address the address itself
943 * @param last_validation when was the address validated last
944 * @param valid_until until when is the address valid
945 * @param next_validation when will we try to revalidate the address next
946 * @param state where are we in the validation state machine
949 process_validation_cb (void *cls,
950 const struct GNUNET_PeerIdentity *peer,
951 const struct GNUNET_HELLO_Address *address,
952 struct GNUNET_TIME_Absolute last_validation,
953 struct GNUNET_TIME_Absolute valid_until,
954 struct GNUNET_TIME_Absolute next_validation,
955 enum GNUNET_TRANSPORT_ValidationState state)
957 if ((NULL == peer) && (NULL == address))
959 if (monitor_validation)
963 _("Monitor disconnected from transport service. Reconnecting.\n"));
970 GNUNET_SCHEDULER_cancel (end);
971 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
974 if ((NULL == peer) || (NULL == address))
976 /* invalid response */
979 GNUNET_SCHEDULER_cancel (end);
980 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
983 resolve_validation_address (peer,
996 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
997 "Running test for plugin `%s' using bind port %u and advertised port %u \n",
999 (uint16_t) head->bnd_port,
1000 (uint16_t) head->adv_port);
1002 head->tst = GNUNET_NAT_test_start (cfg,
1003 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES,
1004 (uint16_t) head->bnd_port,
1005 (uint16_t) head->adv_port,
1007 &result_callback, head);
1012 * Test our plugin's configuration (NAT traversal, etc.).
1014 * @param cfg configuration to test
1017 do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
1021 unsigned long long bnd_port;
1022 unsigned long long adv_port;
1023 struct TestContext *tc;
1027 != GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
1030 FPRINTF (stderr, "%s", _
1031 ("No transport plugins configured, peer will never communicate\n"));
1036 for (tok = strtok (plugins, " "); tok != NULL ; tok = strtok (NULL, " "))
1038 char section[12 + strlen (tok)];
1039 GNUNET_snprintf (section, sizeof(section), "transport-%s", tok);
1041 != GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT",
1045 _("No port configured for plugin `%s', cannot test it\n"), tok);
1048 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, section,
1049 "ADVERTISED_PORT", &adv_port))
1050 adv_port = bnd_port;
1052 tc = GNUNET_new (struct TestContext);
1053 tc->name = GNUNET_strdup (tok);
1054 tc->adv_port = adv_port;
1055 tc->bnd_port = bnd_port;
1056 GNUNET_CONTAINER_DLL_insert_tail (head, tail, tc);
1058 GNUNET_free(plugins);
1060 if ((NULL != head) && (NULL == resolver))
1062 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
1063 resolver = GNUNET_OS_start_process (GNUNET_YES,
1064 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1067 "gnunet-service-resolver", NULL);
1068 if (NULL == resolver)
1070 FPRINTF (stderr, _("Failed to start resolver!\n"));
1074 GNUNET_free(binary);
1075 GNUNET_RESOLVER_connect (cfg);
1082 * Function called to notify a client about the socket
1083 * begin ready to queue more data. @a buf will be
1084 * NULL and @a size zero if the socket was closed for
1085 * writing in the meantime.
1087 * @param cls closure
1088 * @param size number of bytes available in @a buf
1089 * @param buf where the callee should write the message
1090 * @return number of bytes written to @a buf
1093 transmit_data (void *cls,
1097 struct GNUNET_MessageHeader *m = buf;
1099 if ((NULL == buf) || (0 == size))
1105 GNUNET_assert(size >= sizeof(struct GNUNET_MessageHeader));
1106 GNUNET_assert(size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
1107 m->size = ntohs (size);
1108 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
1109 memset (&m[1], 52, size - sizeof(struct GNUNET_MessageHeader));
1110 traffic_sent += size;
1111 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid,
1113 GNUNET_TIME_UNIT_FOREVER_REL,
1114 &transmit_data, NULL);
1116 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
1123 * Function called to notify transport users that another
1124 * peer connected to us.
1126 * @param cls closure
1127 * @param peer the peer that connected
1130 notify_connect (void *cls,
1131 const struct GNUNET_PeerIdentity *peer)
1133 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1138 /* all done, terminate instantly */
1139 FPRINTF (stdout, _("Successfully connected to `%s'\n"),
1140 GNUNET_i2s_full (peer));
1143 if (NULL != op_timeout)
1145 GNUNET_SCHEDULER_cancel (op_timeout);
1150 GNUNET_SCHEDULER_cancel (end);
1151 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1156 if (NULL != op_timeout)
1158 GNUNET_SCHEDULER_cancel (op_timeout);
1163 _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
1164 GNUNET_i2s (&pid), BLOCKSIZE);
1165 start_time = GNUNET_TIME_absolute_get ();
1167 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer,
1169 GNUNET_TIME_UNIT_FOREVER_REL,
1180 * Function called to notify transport users that another
1181 * peer disconnected from us.
1183 * @param cls closure
1184 * @param peer the peer that disconnected
1187 notify_disconnect (void *cls,
1188 const struct GNUNET_PeerIdentity *peer)
1190 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1195 /* all done, terminate instantly */
1196 FPRINTF (stdout, _("Successfully disconnected from `%s'\n"),
1197 GNUNET_i2s_full (peer));
1200 if (NULL != op_timeout)
1202 GNUNET_SCHEDULER_cancel (op_timeout);
1207 GNUNET_SCHEDULER_cancel (end);
1208 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1214 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
1219 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"),
1222 GNUNET_SCHEDULER_cancel (end);
1229 * Function called to notify transport users that another
1230 * peer connected to us.
1232 * @param cls closure
1233 * @param peer the peer that connected
1236 monitor_notify_connect (void *cls,
1237 const struct GNUNET_PeerIdentity *peer)
1239 monitor_connect_counter++;
1240 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1241 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1244 _("%24s: %-17s %4s (%u connections in total)\n"),
1248 monitor_connect_counter);
1253 * Function called to notify transport users that another
1254 * peer disconnected from us.
1256 * @param cls closure
1257 * @param peer the peer that disconnected
1260 monitor_notify_disconnect (void *cls,
1261 const struct GNUNET_PeerIdentity *peer)
1263 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1264 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1266 GNUNET_assert(monitor_connect_counter > 0);
1267 monitor_connect_counter--;
1270 _("%24s: %-17s %4s (%u connections in total)\n"),
1272 _("Disconnected from"),
1274 monitor_connect_counter);
1279 * Function called by the transport for each received message.
1281 * @param cls closure
1282 * @param peer (claimed) identity of the other peer
1283 * @param message the message
1286 notify_receive (void *cls,
1287 const struct GNUNET_PeerIdentity *peer,
1288 const struct GNUNET_MessageHeader *message)
1290 if (benchmark_receive)
1292 if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type))
1296 _("Received %u bytes from %s\n"),
1297 (unsigned int) ntohs (message->size),
1300 if (traffic_received == 0)
1301 start_time = GNUNET_TIME_absolute_get ();
1302 traffic_received += ntohs (message->size);
1309 resolve_peer_address (const struct GNUNET_PeerIdentity *id,
1310 const struct GNUNET_HELLO_Address *address,
1312 enum GNUNET_TRANSPORT_PeerState state,
1313 struct GNUNET_TIME_Absolute state_timeout);
1317 print_info (const struct GNUNET_PeerIdentity *id,
1318 const char *transport,
1320 enum GNUNET_TRANSPORT_PeerState state,
1321 struct GNUNET_TIME_Absolute state_timeout)
1324 if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
1325 (GNUNET_YES == monitor_connections))
1328 _("Peer `%s': %s %s in state `%s' until %s\n"),
1330 (NULL == transport) ? "<none>" : transport,
1331 (NULL == transport) ? "<none>" : addr,
1332 GNUNET_TRANSPORT_ps2s (state),
1333 GNUNET_STRINGS_absolute_time_to_string (state_timeout));
1335 else if ( (GNUNET_YES == iterate_connections) &&
1336 (GNUNET_TRANSPORT_is_connected(state)))
1338 /* Only connected peers, skip state */
1340 _("Peer `%s': %s %s\n"),
1349 * Function called with a textual representation of an address. This
1350 * function will be called several times with different possible
1351 * textual representations, and a last time with @a address being NULL
1352 * to signal the end of the iteration. Note that @a address NULL
1353 * always is the last call, regardless of the value in @a res.
1355 * @param cls closure
1356 * @param address NULL on end of iteration,
1357 * otherwise 0-terminated printable UTF-8 string,
1358 * in particular an empty string if @a res is #GNUNET_NO
1359 * @param res result of the address to string conversion:
1360 * if #GNUNET_OK: conversion successful
1361 * if #GNUNET_NO: address was invalid (or not supported)
1362 * if #GNUNET_SYSERR: communication error (IPC error)
1365 process_peer_string (void *cls,
1366 const char *address,
1369 struct PeerResolutionContext *rc = cls;
1371 if (NULL != address)
1373 if (GNUNET_SYSERR == res)
1376 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
1377 GNUNET_i2s (&rc->id),
1378 rc->addrcp->transport_name,
1379 (unsigned int) rc->addrcp->address_length);
1380 print_info (&rc->id,
1385 rc->printed = GNUNET_YES;
1388 if (GNUNET_OK == res)
1390 print_info (&rc->id,
1395 rc->printed = GNUNET_YES;
1396 return; /* Wait for done call */
1398 /* GNUNET_NO == res: ignore, was simply not supported */
1401 /* NULL == address, last call, we are done */
1403 GNUNET_assert (address_resolutions > 0);
1404 address_resolutions--;
1405 if (GNUNET_NO == rc->printed)
1407 if (numeric == GNUNET_NO)
1409 /* Failed to resolve address, try numeric lookup
1410 (note: this should not be needed, as transport
1411 should fallback to numeric conversion if DNS takes
1413 resolve_peer_address (&rc->id,
1421 print_info (&rc->id,
1428 GNUNET_free (rc->transport);
1429 GNUNET_free (rc->addrcp);
1430 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc);
1432 if ((0 == address_resolutions) && (iterate_connections))
1436 GNUNET_SCHEDULER_cancel (end);
1439 if (NULL != op_timeout)
1441 GNUNET_SCHEDULER_cancel (op_timeout);
1445 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1451 resolve_peer_address (const struct GNUNET_PeerIdentity *id,
1452 const struct GNUNET_HELLO_Address *address,
1454 enum GNUNET_TRANSPORT_PeerState state,
1455 struct GNUNET_TIME_Absolute state_timeout)
1457 struct PeerResolutionContext *rc;
1459 rc = GNUNET_new (struct PeerResolutionContext);
1460 GNUNET_assert(NULL != rc);
1461 GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc);
1462 address_resolutions++;
1465 rc->transport = GNUNET_strdup(address->transport_name);
1466 rc->addrcp = GNUNET_HELLO_address_copy (address);
1467 rc->printed = GNUNET_NO;
1469 rc->state_timeout = state_timeout;
1470 /* Resolve address to string */
1471 rc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1475 &process_peer_string, rc);
1480 * Function called with information about a peers during a one shot iteration
1482 * @param cls closure
1483 * @param peer identity of the peer, NULL for final callback when operation done
1484 * @param address binary address used to communicate with this peer,
1485 * NULL on disconnect or when done
1486 * @param state current state this peer is in
1487 * @param state_timeout time out for the current state
1490 process_peer_iteration_cb (void *cls,
1491 const struct GNUNET_PeerIdentity *peer,
1492 const struct GNUNET_HELLO_Address *address,
1493 enum GNUNET_TRANSPORT_PeerState state,
1494 struct GNUNET_TIME_Absolute state_timeout)
1499 address_resolution_in_progress = GNUNET_NO;
1502 GNUNET_SCHEDULER_cancel (end);
1503 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1507 if ( (GNUNET_NO == iterate_all) &&
1508 (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)))
1509 return; /* Display only connected peers */
1511 if (NULL != op_timeout)
1512 GNUNET_SCHEDULER_cancel (op_timeout);
1513 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1518 "Received address for peer `%s': %s\n",
1520 address->transport_name);
1522 if (NULL != address)
1523 resolve_peer_address (peer, address, numeric, state, state_timeout);
1525 print_info (peer, NULL, NULL, state, state_timeout);
1530 * Context for address resolution by #plugin_monitoring_cb().
1532 struct PluginMonitorAddress
1536 * Ongoing resolution request.
1538 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
1541 * Resolved address as string.
1548 * Function called with a textual representation of an address. This
1549 * function will be called several times with different possible
1550 * textual representations, and a last time with @a address being NULL
1551 * to signal the end of the iteration. Note that @a address NULL
1552 * always is the last call, regardless of the value in @a res.
1554 * @param cls closure
1555 * @param address NULL on end of iteration,
1556 * otherwise 0-terminated printable UTF-8 string,
1557 * in particular an empty string if @a res is #GNUNET_NO
1558 * @param res result of the address to string conversion:
1559 * if #GNUNET_OK: conversion successful
1560 * if #GNUNET_NO: address was invalid (or not supported)
1561 * if #GNUNET_SYSERR: communication error (IPC error)
1564 address_cb (void *cls,
1565 const char *address,
1568 struct PluginMonitorAddress *addr = cls;
1570 if (NULL == address)
1575 if (NULL != addr->str)
1577 addr->str = GNUNET_strdup (address);
1582 * Function called by the plugin with information about the
1583 * current sessions managed by the plugin (for monitoring).
1585 * @param cls closure (NULL)
1586 * @param session session handle this information is about,
1587 * NULL to indicate that we are "in sync" (initial
1588 * iteration complete)
1589 * @param session_ctx storage location where the application
1590 * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT,
1591 * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE
1592 * @param info information about the state of the session,
1593 * NULL if @a session is also NULL and we are
1594 * merely signalling that the initial iteration is over;
1595 * NULL with @a session being non-NULL if the monitor
1596 * was being cancelled while sessions were active
1599 plugin_monitoring_cb (void *cls,
1600 struct GNUNET_TRANSPORT_PluginSession *session,
1602 const struct GNUNET_TRANSPORT_SessionInfo *info)
1605 struct PluginMonitorAddress *addr;
1607 if ( (NULL == info) &&
1609 return; /* in sync with transport service */
1610 addr = *session_ctx;
1615 if (NULL != addr->asc)
1617 GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
1620 GNUNET_free_non_null (addr->str);
1622 *session_ctx = NULL;
1624 return; /* shutdown */
1626 if ( (NULL != cpid) &&
1627 (0 != memcmp (&info->address->peer,
1629 sizeof (struct GNUNET_PeerIdentity))) )
1630 return; /* filtered */
1633 addr = GNUNET_new (struct PluginMonitorAddress);
1634 addr->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1637 GNUNET_TIME_UNIT_FOREVER_REL,
1640 *session_ctx = addr;
1642 switch (info->state)
1644 case GNUNET_TRANSPORT_SS_INIT:
1647 case GNUNET_TRANSPORT_SS_HANDSHAKE:
1648 state = "HANDSHAKE";
1650 case GNUNET_TRANSPORT_SS_UP:
1653 case GNUNET_TRANSPORT_SS_UPDATE:
1656 case GNUNET_TRANSPORT_SS_DONE:
1664 "%s: %s %s (# %u/%u b) blocked until %s timeout in %s [%s]\n",
1665 GNUNET_i2s (&info->address->peer),
1667 (info->is_inbound == GNUNET_YES) ? "<-" : ((info->is_inbound == GNUNET_NO) ? "->" : "<>"),
1668 info->num_msg_pending,
1669 info->num_bytes_pending,
1670 GNUNET_STRINGS_absolute_time_to_string (info->receive_delay),
1671 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (info->session_timeout),
1674 if (GNUNET_TRANSPORT_SS_DONE == info->state)
1676 if (NULL != addr->asc)
1678 GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
1681 GNUNET_free_non_null (addr->str);
1683 *session_ctx = NULL;
1689 * Function called with information about a peers
1691 * @param cls closure
1692 * @param peer identity of the peer, NULL for final callback when operation done
1693 * @param address binary address used to communicate with this peer,
1694 * NULL on disconnect or when done
1695 * @param state current state this peer is in
1696 * @param state_timeout time out for the current state
1700 process_peer_monitoring_cb (void *cls,
1701 const struct GNUNET_PeerIdentity *peer,
1702 const struct GNUNET_HELLO_Address *address,
1703 enum GNUNET_TRANSPORT_PeerState state,
1704 struct GNUNET_TIME_Absolute state_timeout)
1706 struct MonitoredPeer *m;
1712 _("Monitor disconnected from transport service. Reconnecting.\n"));
1716 if (NULL != op_timeout)
1717 GNUNET_SCHEDULER_cancel (op_timeout);
1718 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1722 if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer)))
1724 m = GNUNET_new (struct MonitoredPeer);
1725 GNUNET_CONTAINER_multipeermap_put (monitored_peers, peer,
1726 m, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1730 if ( (m->state == state) &&
1731 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
1732 ((NULL == address) && (NULL == m->address)))
1734 return; /* No real change */
1736 if ( (m->state == state) && ((NULL != address) && (NULL != m->address)) &&
1737 (0 == GNUNET_HELLO_address_cmp(m->address, address)))
1738 return; /* No real change */
1741 if (NULL != m->address)
1743 GNUNET_free (m->address);
1746 if (NULL != address)
1747 m->address = GNUNET_HELLO_address_copy (address);
1749 m->state_timeout = state_timeout;
1751 if (NULL != address)
1752 resolve_peer_address (peer,
1767 * Function called with our result of trying to connect to a peer
1768 * using the transport service. Will retry 10 times, and if we still
1769 * fail to connect terminate with an error message.
1772 * @param result #GNUNET_OK if we connected to the service
1775 try_connect_cb (void *cls,
1778 static int retries = 0;
1781 if (GNUNET_OK == result)
1786 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
1794 _("Failed to send connect request to transport service\n"));
1796 GNUNET_SCHEDULER_cancel (end);
1798 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1803 * Function called with our result of trying to disconnect a peer
1804 * using the transport service. Will retry 10 times, and if we still
1805 * fail to disconnect, terminate with an error message.
1808 * @param result #GNUNET_OK if we connected to the service
1811 try_disconnect_cb (void *cls,
1814 static int retries = 0;
1817 if (GNUNET_OK == result)
1822 td_handle = GNUNET_TRANSPORT_try_disconnect (handle,
1828 FPRINTF (stderr, "%s",
1829 _("Failed to send disconnect request to transport service\n"));
1831 GNUNET_SCHEDULER_cancel (end);
1833 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1838 * Function called with the result of the check if the 'transport'
1839 * service is running.
1841 * @param cls closure with our configuration
1842 * @param result #GNUNET_YES if transport is running
1845 testservice_task (void *cls,
1851 if (GNUNET_YES != result)
1853 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
1859 != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid),
1862 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
1866 counter = benchmark_send + benchmark_receive + iterate_connections
1867 + monitor_connections + monitor_connects + try_connect + try_disconnect +
1868 + iterate_validation + monitor_validation + monitor_plugins;
1873 _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
1874 "connect", "benchmark send", "benchmark receive", "information",
1875 "monitor", "events", "plugins");
1881 _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
1882 "connect", "benchmark send", "benchmark receive", "information",
1883 "monitor", "events", "plugins");
1887 if (try_connect) /* -C: Connect to peer */
1891 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1896 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1897 ¬ify_connect, ¬ify_disconnect);
1900 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1904 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
1906 if (NULL == tc_handle)
1908 FPRINTF (stderr, "%s",
1909 _("Failed to send request to transport service\n"));
1913 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1917 else if (try_disconnect) /* -D: Disconnect from peer */
1921 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1926 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1927 ¬ify_connect, ¬ify_disconnect);
1930 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1934 td_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid,
1937 if (NULL == td_handle)
1939 FPRINTF (stderr, "%s",
1940 _("Failed to send request to transport service\n"));
1944 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1948 else if (benchmark_send) /* -s: Benchmark sending */
1952 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1957 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
1960 ¬ify_disconnect);
1963 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1967 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
1971 if (NULL == tc_handle)
1973 FPRINTF (stderr, "%s",
1974 _("Failed to send request to transport service\n"));
1978 start_time = GNUNET_TIME_absolute_get ();
1979 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1983 else if (benchmark_receive) /* -b: Benchmark receiving */
1985 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, NULL,
1989 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1994 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n"));
1995 start_time = GNUNET_TIME_absolute_get ();
1998 else if (iterate_connections) /* -i: List information about peers once */
2000 address_resolution_in_progress = GNUNET_YES;
2001 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
2002 GNUNET_YES, TIMEOUT, &process_peer_iteration_cb, (void *) cfg);
2003 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
2006 else if (monitor_connections) /* -m: List information about peers continuously */
2008 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
2009 address_resolution_in_progress = GNUNET_YES;
2010 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
2012 &process_peer_monitoring_cb, (void *) cfg);
2014 else if (monitor_plugins) /* -P: List information about plugins continuously */
2016 monitored_plugins = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
2017 pm = GNUNET_TRANSPORT_monitor_plugins (cfg,
2018 &plugin_monitoring_cb,
2021 else if (iterate_validation) /* -d: Print information about validations */
2023 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
2024 (NULL == cpid) ? NULL : &pid,
2025 GNUNET_YES, TIMEOUT,
2026 &process_validation_cb, (void *) cfg);
2028 else if (monitor_validation) /* -f: Print information about validations continuously */
2030 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
2031 (NULL == cpid) ? NULL : &pid,
2033 &process_validation_cb, (void *) cfg);
2035 else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */
2037 monitor_connect_counter = 0;
2038 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL,
2039 &monitor_notify_connect,
2040 &monitor_notify_disconnect);
2045 _("Failed to connect to transport service\n"));
2057 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
2064 * Main function that will be run by the scheduler.
2066 * @param cls closure
2067 * @param args remaining command-line arguments
2068 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
2069 * @param mycfg configuration
2074 const char *cfgfile,
2075 const struct GNUNET_CONFIGURATION_Handle *mycfg)
2077 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
2078 if (test_configuration)
2080 do_test_configuration (cfg);
2083 GNUNET_CLIENT_service_test ("transport", cfg, GNUNET_TIME_UNIT_SECONDS,
2084 &testservice_task, (void *) cfg);
2088 main (int argc, char * const *argv)
2091 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
2093 gettext_noop ("print information for all peers (instead of only connected peers)"),
2094 0, &GNUNET_GETOPT_set_one, &iterate_all },
2095 { 'b', "benchmark", NULL,
2096 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
2097 0, &GNUNET_GETOPT_set_one, &benchmark_receive },
2099 NULL, gettext_noop ("connect to a peer"), 0,
2100 &GNUNET_GETOPT_set_one, &try_connect },
2101 { 'D', "disconnect",
2102 NULL, gettext_noop ("disconnect to a peer"), 0,
2103 &GNUNET_GETOPT_set_one, &try_disconnect },
2104 { 'd', "validation", NULL,
2105 gettext_noop ("print information for all pending validations "),
2106 0, &GNUNET_GETOPT_set_one, &iterate_validation },
2107 { 'f', "monitorvalidation", NULL,
2108 gettext_noop ("print information for all pending validations continuously"),
2109 0, &GNUNET_GETOPT_set_one, &monitor_validation },
2110 { 'i', "information", NULL,
2111 gettext_noop ("provide information about all current connections (once)"),
2112 0, &GNUNET_GETOPT_set_one, &iterate_connections },
2113 { 'm', "monitor", NULL,
2114 gettext_noop ("provide information about all current connections (continuously)"),
2115 0, &GNUNET_GETOPT_set_one, &monitor_connections },
2116 { 'e', "events", NULL,
2117 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
2118 0, &GNUNET_GETOPT_set_one, &monitor_connects },
2120 NULL, gettext_noop ("do not resolve hostnames"), 0,
2121 &GNUNET_GETOPT_set_one, &numeric },
2122 { 'p', "peer", "PEER",
2123 gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
2125 { 'P', "plugins", NULL,
2126 gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one,
2128 { 's', "send", NULL, gettext_noop
2129 ("send data for benchmarking to the other peer (until CTRL-C)"), 0,
2130 &GNUNET_GETOPT_set_one, &benchmark_send },
2131 { 't', "test", NULL,
2132 gettext_noop ("test transport configuration (involves external server)"),
2133 0, &GNUNET_GETOPT_set_one, &test_configuration },
2134 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
2135 GNUNET_GETOPT_OPTION_END
2138 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
2141 res = GNUNET_PROGRAM_run (argc, argv,
2143 gettext_noop ("Direct access to transport service."),
2146 GNUNET_free((void *) argv);
2147 if (GNUNET_OK == res)
2152 /* end of gnunet-transport.c */