2 This file is part of GNUnet.
3 Copyright (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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, 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_HELLO_Address *addrcp;
75 * Time of last validation
77 struct GNUNET_TIME_Absolute last_validation;
80 * Address is valid until
82 struct GNUNET_TIME_Absolute valid_until;
85 * Time of next validation
87 struct GNUNET_TIME_Absolute next_validation;
90 * state of validation process
92 enum GNUNET_TRANSPORT_ValidationState state;
95 * Tranport conversion handle
97 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
105 * was the entry printed
111 * Struct to store information about peers in monitor mode
118 enum GNUNET_TRANSPORT_PeerState state;
123 struct GNUNET_TIME_Absolute state_timeout;
126 * The address to convert
128 struct GNUNET_HELLO_Address *address;
132 * Context to store name resolutions for valiation
134 struct PeerResolutionContext
139 struct PeerResolutionContext *next;
144 struct PeerResolutionContext *prev;
149 struct GNUNET_HELLO_Address *addrcp;
152 * transport conversiion context
154 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
159 enum GNUNET_TRANSPORT_PeerState state;
164 struct GNUNET_TIME_Absolute state_timeout;
172 * was the entry printed
179 * Context for a plugin test.
186 struct TestContext *prev;
191 struct TestContext *next;
194 * Handle to the active NAT test.
196 struct GNUNET_NAT_Test *tst;
199 * Task identifier for the timeout.
201 struct GNUNET_SCHEDULER_Task * tsk;
204 * Name of plugin under test.
211 unsigned long long bnd_port;
216 unsigned long long adv_port;
227 * NAT returned success
229 NAT_TEST_SUCCESS = GNUNET_OK,
232 * NAT returned failure
234 NAT_TEST_FAIL = GNUNET_NO,
237 * NAT returned failure while running test
239 NAT_TEST_INTERNAL_FAIL = GNUNET_SYSERR,
242 * We could not start the test
244 NAT_TEST_FAILED_TO_START = 2,
247 * We had a timeout while running the test
254 * Benchmarking block size in KB
259 * Which peer should we connect to?
264 * Handle to transport service.
266 static struct GNUNET_TRANSPORT_Handle *handle;
269 * Configuration handle
271 static struct GNUNET_CONFIGURATION_Handle *cfg;
276 struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle;
279 * Try disconnect handle
281 struct GNUNET_TRANSPORT_TryDisconnectHandle *td_handle;
286 static int benchmark_send;
291 static int benchmark_receive;
296 static int benchmark_receive;
301 static int iterate_connections;
306 static int iterate_validation;
311 static int iterate_all;
316 static int test_configuration;
321 static int monitor_connects;
326 static int monitor_connections;
331 static int monitor_validation;
336 static int monitor_plugins;
341 static int try_connect;
346 static int try_disconnect;
354 * Global return value (0 success).
359 * Current number of connections in monitor mode
361 static int monitor_connect_counter;
364 * Number of bytes of traffic we received so far.
366 static unsigned long long traffic_received;
369 * Number of bytes of traffic we sent so far.
371 static unsigned long long traffic_sent;
374 * Starting time of transmitting/receiving data.
376 static struct GNUNET_TIME_Absolute start_time;
379 * Handle for current transmission request.
381 static struct GNUNET_TRANSPORT_TransmitHandle *th;
384 * Map storing information about monitored peers
386 static struct GNUNET_CONTAINER_MultiPeerMap *monitored_peers;
389 * Map storing information about monitored plugins's sessions.
391 static struct GNUNET_CONTAINER_MultiPeerMap *monitored_plugins;
394 * Handle if we are monitoring peers at the transport level.
396 static struct GNUNET_TRANSPORT_PeerMonitoringContext *pic;
399 * Handle if we are monitoring transport validation activity.
401 static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic;
404 * Handle if we are monitoring plugin session activity.
406 static struct GNUNET_TRANSPORT_PluginMonitor *pm;
409 * Identity of the peer we transmit to / connect to.
410 * (equivalent to 'cpid' string).
412 static struct GNUNET_PeerIdentity pid;
415 * Task scheduled for cleanup / termination of the process.
417 static struct GNUNET_SCHEDULER_Task * end;
420 * Task for operation timeout
422 static struct GNUNET_SCHEDULER_Task * op_timeout;
425 * Selected level of verbosity.
427 static int verbosity;
430 * Resolver process handle.
432 struct GNUNET_OS_Process *resolver;
435 * Number of address resolutions pending
437 static unsigned int address_resolutions;
440 * Address resolutions pending in progress
442 static unsigned int address_resolution_in_progress;
445 * DLL for NAT Test Contexts: head
447 struct TestContext *head;
450 * DLL for NAT Test Contexts: tail
452 struct TestContext *tail;
455 * DLL: head of validation resolution entries
457 static struct ValidationResolutionContext *vc_head;
460 * DLL: tail of validation resolution entries
462 static struct ValidationResolutionContext *vc_tail;
465 * DLL: head of resolution entries
467 static struct PeerResolutionContext *rc_head;
470 * DLL: head of resolution entries
472 static struct PeerResolutionContext *rc_tail;
476 * Function called to release data stored in the #monitored_peers map.
479 * @param key the peer identity
480 * @param value a `struct MonitoredPeer` to release
481 * @return #GNUNET_OK (continue to iterate)
484 destroy_it (void *cls,
485 const struct GNUNET_PeerIdentity *key,
488 struct MonitoredPeer *m = value;
490 GNUNET_assert (GNUNET_OK ==
491 GNUNET_CONTAINER_multipeermap_remove (monitored_peers,
494 GNUNET_free_non_null (m->address);
501 * Task run in monitor mode when the user presses CTRL-C to abort.
502 * Stops monitoring activity.
505 * @param tc scheduler context
508 shutdown_task (void *cls,
509 const struct GNUNET_SCHEDULER_TaskContext *tc)
511 struct GNUNET_TIME_Relative duration;
512 struct ValidationResolutionContext *cur;
513 struct ValidationResolutionContext *next;
514 struct PeerResolutionContext *rc;
517 if (NULL != op_timeout)
519 GNUNET_SCHEDULER_cancel (op_timeout);
522 if (NULL != tc_handle)
524 GNUNET_TRANSPORT_try_connect_cancel (tc_handle);
529 GNUNET_TRANSPORT_monitor_peers_cancel (pic);
534 GNUNET_TRANSPORT_monitor_validation_entries_cancel (vic);
539 GNUNET_TRANSPORT_monitor_plugins_cancel (pm);
544 for (cur = next; NULL != cur; cur = next)
548 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
549 GNUNET_CONTAINER_DLL_remove (vc_head,
552 GNUNET_free (cur->transport);
553 GNUNET_HELLO_address_free (cur->addrcp);
556 while (NULL != (rc = rc_head))
558 GNUNET_CONTAINER_DLL_remove (rc_head,
561 GNUNET_TRANSPORT_address_to_string_cancel (rc->asc);
562 GNUNET_free (rc->transport);
563 GNUNET_free (rc->addrcp);
568 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
573 GNUNET_TRANSPORT_disconnect (handle);
578 duration = GNUNET_TIME_absolute_get_duration (start_time);
580 _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
581 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
583 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
585 if (benchmark_receive)
587 duration = GNUNET_TIME_absolute_get_duration (start_time);
589 _("Received %llu bytes/s (%llu bytes in %s)\n"),
590 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
592 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
595 if (NULL != monitored_peers)
597 GNUNET_CONTAINER_multipeermap_iterate (monitored_peers, &destroy_it, NULL);
598 GNUNET_CONTAINER_multipeermap_destroy (monitored_peers);
599 monitored_peers = NULL;
601 if (NULL != monitored_plugins)
604 GNUNET_CONTAINER_multipeermap_size (monitored_plugins));
605 GNUNET_CONTAINER_multipeermap_destroy (monitored_plugins);
606 monitored_plugins = NULL;
612 operation_timeout (void *cls,
613 const struct GNUNET_SCHEDULER_TaskContext *tc)
615 struct PeerResolutionContext *cur;
616 struct PeerResolutionContext *next;
618 if ((try_connect) || (benchmark_send) || (benchmark_receive))
621 _("Failed to connect to `%s'\n"),
622 GNUNET_i2s_full (&pid));
624 GNUNET_SCHEDULER_cancel (end);
625 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
629 if (iterate_connections)
632 while (NULL != (cur = next))
636 _("Failed to resolve address for peer `%s'\n"),
637 GNUNET_i2s (&cur->addrcp->peer));
639 GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur);
640 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
641 GNUNET_free(cur->transport);
642 GNUNET_free(cur->addrcp);
648 _("Failed to list connections, timeout occured\n"));
650 GNUNET_SCHEDULER_cancel (end);
651 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
663 * Display the result of the test.
665 * @param tc test context
666 * @param result #GNUNET_YES on success
669 display_test_result (struct TestContext *tc,
670 enum TestResult result)
675 _("Configuration for plugin `%s' did not work!\n"),
678 case NAT_TEST_SUCCESS:
680 _("Configuration for plugin `%s' did work!\n"),
683 case NAT_TEST_INTERNAL_FAIL:
685 _("Internal NAT error while running test for plugin `%s'\n"),
688 case NAT_TEST_FAILED_TO_START:
690 _("Failed to start NAT test for plugin `%s'\n"),
693 case NAT_TEST_TIMEOUT:
695 _("Timeout while waiting for result of NAT test for plugin `%s'\n"),
700 _("Configuration for plugin `%s' did not work!\n"),
706 GNUNET_SCHEDULER_cancel (tc->tsk);
711 GNUNET_NAT_test_stop (tc->tst);
715 GNUNET_CONTAINER_DLL_remove (head, tail, tc);
716 GNUNET_free (tc->name);
719 if ((NULL == head) && (NULL != resolver))
721 GNUNET_break (0 == GNUNET_OS_process_kill (resolver,
723 GNUNET_OS_process_destroy (resolver);
732 * Function called by NAT to report the outcome of the nat-test.
733 * Clean up and update GUI.
735 * @param cls test context
736 * @param result status code
739 result_callback (void *cls,
740 enum GNUNET_NAT_StatusCode result)
742 struct TestContext *tc = cls;
744 display_test_result (tc,
750 * Resolve address we got a validation state for to a string.
752 * @param address the address itself
753 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
754 * @param last_validation when was the address validated last
755 * @param valid_until until when is the address valid
756 * @param next_validation when will we try to revalidate the address next
757 * @param state where are we in the validation state machine
760 resolve_validation_address (const struct GNUNET_HELLO_Address *address,
762 struct GNUNET_TIME_Absolute last_validation,
763 struct GNUNET_TIME_Absolute valid_until,
764 struct GNUNET_TIME_Absolute next_validation,
765 enum GNUNET_TRANSPORT_ValidationState state);
769 * Function to call with a textual representation of an address. This
770 * function will be called several times with different possible
771 * textual representations, and a last time with @a address being NULL
772 * to signal the end of the iteration. Note that @a address NULL
773 * always is the last call, regardless of the value in @a res.
776 * @param address NULL on end of iteration,
777 * otherwise 0-terminated printable UTF-8 string,
778 * in particular an empty string if @a res is #GNUNET_NO
779 * @param res result of the address to string conversion:
780 * if #GNUNET_OK: conversion successful
781 * if #GNUNET_NO: address was invalid (or not supported)
782 * if #GNUNET_SYSERR: communication error (IPC error)
785 process_validation_string (void *cls,
789 struct ValidationResolutionContext *vc = cls;
796 if (GNUNET_SYSERR == res)
799 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
800 GNUNET_i2s (&vc->addrcp->peer),
801 vc->addrcp->transport_name,
802 (unsigned int) vc->addrcp->address_length);
804 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->valid_until.abs_value_us)
805 s_valid = GNUNET_strdup ("never");
807 s_valid = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->valid_until));
809 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->last_validation.abs_value_us)
810 s_last = GNUNET_strdup ("never");
812 s_last = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->last_validation));
814 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->next_validation.abs_value_us)
815 s_next = GNUNET_strdup ("never");
817 s_next = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->next_validation));
820 _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"),
821 GNUNET_i2s (&vc->addrcp->peer),
822 (GNUNET_OK == res) ? address : "<invalid address>",
823 (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "",
824 "Valid until : ", s_valid,
825 "Last validation: ",s_last,
826 "Next validation: ", s_next);
827 GNUNET_free (s_valid);
828 GNUNET_free (s_last);
829 GNUNET_free (s_next);
830 vc->printed = GNUNET_YES;
833 /* last call, we are done */
834 GNUNET_assert (address_resolutions > 0);
835 address_resolutions--;
836 if ( (GNUNET_SYSERR == res) &&
837 (GNUNET_NO == vc->printed))
839 if (numeric == GNUNET_NO)
841 /* Failed to resolve address, try numeric lookup
842 (note: this should be unnecessary, as
843 transport should fallback to numeric lookup
844 internally if DNS takes too long anyway) */
845 resolve_validation_address (vc->addrcp,
855 _("Peer `%s' %s `%s' \n"),
856 GNUNET_i2s (&vc->addrcp->peer),
857 "<unable to resolve address>",
858 GNUNET_TRANSPORT_vs2s (vc->state));
861 GNUNET_free (vc->transport);
862 GNUNET_free (vc->addrcp);
863 GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, vc);
865 if ((0 == address_resolutions) && (iterate_validation))
869 GNUNET_SCHEDULER_cancel (end);
872 if (NULL != op_timeout)
874 GNUNET_SCHEDULER_cancel (op_timeout);
878 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
884 * Resolve address we got a validation state for to a string.
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_HELLO_Address *address,
896 struct GNUNET_TIME_Absolute last_validation,
897 struct GNUNET_TIME_Absolute valid_until,
898 struct GNUNET_TIME_Absolute next_validation,
899 enum GNUNET_TRANSPORT_ValidationState state)
901 struct ValidationResolutionContext *vc;
903 vc = GNUNET_new (struct ValidationResolutionContext);
904 GNUNET_assert(NULL != vc);
905 GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc);
906 address_resolutions++;
908 vc->transport = GNUNET_strdup(address->transport_name);
909 vc->addrcp = GNUNET_HELLO_address_copy (address);
910 vc->printed = GNUNET_NO;
912 vc->last_validation = last_validation;
913 vc->valid_until = valid_until;
914 vc->next_validation = next_validation;
916 /* Resolve address to string */
917 vc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
921 &process_validation_string, vc);
926 * Resolve address we got a validation state for to a string.
929 * @param address the address itself
930 * @param last_validation when was the address validated last
931 * @param valid_until until when is the address valid
932 * @param next_validation when will we try to revalidate the address next
933 * @param state where are we in the validation state machine
936 process_validation_cb (void *cls,
937 const struct GNUNET_HELLO_Address *address,
938 struct GNUNET_TIME_Absolute last_validation,
939 struct GNUNET_TIME_Absolute valid_until,
940 struct GNUNET_TIME_Absolute next_validation,
941 enum GNUNET_TRANSPORT_ValidationState state)
945 if (monitor_validation)
949 _("Monitor disconnected from transport service. Reconnecting.\n"));
954 GNUNET_SCHEDULER_cancel (end);
955 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
958 resolve_validation_address (address,
970 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
971 "Running test for plugin `%s' using bind port %u and advertised port %u \n",
973 (uint16_t) head->bnd_port,
974 (uint16_t) head->adv_port);
976 head->tst = GNUNET_NAT_test_start (cfg,
977 (0 == strcasecmp (head->name, "udp"))
978 ? GNUNET_NO : GNUNET_YES,
979 (uint16_t) head->bnd_port,
980 (uint16_t) head->adv_port,
982 &result_callback, head);
987 * Test our plugin's configuration (NAT traversal, etc.).
989 * @param cfg configuration to test
992 do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
996 unsigned long long bnd_port;
997 unsigned long long adv_port;
998 struct TestContext *tc;
1002 != GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
1005 FPRINTF (stderr, "%s", _
1006 ("No transport plugins configured, peer will never communicate\n"));
1011 for (tok = strtok (plugins, " "); tok != NULL ; tok = strtok (NULL, " "))
1013 char section[12 + strlen (tok)];
1014 GNUNET_snprintf (section, sizeof(section), "transport-%s", tok);
1016 != GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT",
1020 _("No port configured for plugin `%s', cannot test it\n"), tok);
1023 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, section,
1024 "ADVERTISED_PORT", &adv_port))
1025 adv_port = bnd_port;
1027 tc = GNUNET_new (struct TestContext);
1028 tc->name = GNUNET_strdup (tok);
1029 tc->adv_port = adv_port;
1030 tc->bnd_port = bnd_port;
1031 GNUNET_CONTAINER_DLL_insert_tail (head, tail, tc);
1033 GNUNET_free(plugins);
1035 if ((NULL != head) && (NULL == resolver))
1037 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
1038 resolver = GNUNET_OS_start_process (GNUNET_YES,
1039 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1042 "gnunet-service-resolver", NULL);
1043 if (NULL == resolver)
1045 FPRINTF (stderr, _("Failed to start resolver!\n"));
1049 GNUNET_free(binary);
1050 GNUNET_RESOLVER_connect (cfg);
1057 * Function called to notify a client about the socket
1058 * begin ready to queue more data. @a buf will be
1059 * NULL and @a size zero if the socket was closed for
1060 * writing in the meantime.
1062 * @param cls closure
1063 * @param size number of bytes available in @a buf
1064 * @param buf where the callee should write the message
1065 * @return number of bytes written to @a buf
1068 transmit_data (void *cls,
1072 struct GNUNET_MessageHeader *m = buf;
1074 if ((NULL == buf) || (0 == size))
1080 GNUNET_assert(size >= sizeof(struct GNUNET_MessageHeader));
1081 GNUNET_assert(size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
1082 m->size = ntohs (size);
1083 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
1084 memset (&m[1], 52, size - sizeof(struct GNUNET_MessageHeader));
1085 traffic_sent += size;
1086 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid,
1088 GNUNET_TIME_UNIT_FOREVER_REL,
1089 &transmit_data, NULL);
1091 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
1098 * Function called to notify transport users that another
1099 * peer connected to us.
1101 * @param cls closure
1102 * @param peer the peer that connected
1105 notify_connect (void *cls,
1106 const struct GNUNET_PeerIdentity *peer)
1108 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1113 /* all done, terminate instantly */
1114 FPRINTF (stdout, _("Successfully connected to `%s'\n"),
1115 GNUNET_i2s_full (peer));
1118 if (NULL != op_timeout)
1120 GNUNET_SCHEDULER_cancel (op_timeout);
1125 GNUNET_SCHEDULER_cancel (end);
1126 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1131 if (NULL != op_timeout)
1133 GNUNET_SCHEDULER_cancel (op_timeout);
1138 _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
1139 GNUNET_i2s (&pid), BLOCKSIZE);
1140 start_time = GNUNET_TIME_absolute_get ();
1142 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer,
1144 GNUNET_TIME_UNIT_FOREVER_REL,
1155 * Function called to notify transport users that another
1156 * peer disconnected from us.
1158 * @param cls closure
1159 * @param peer the peer that disconnected
1162 notify_disconnect (void *cls,
1163 const struct GNUNET_PeerIdentity *peer)
1165 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
1170 /* all done, terminate instantly */
1171 FPRINTF (stdout, _("Successfully disconnected from `%s'\n"),
1172 GNUNET_i2s_full (peer));
1175 if (NULL != op_timeout)
1177 GNUNET_SCHEDULER_cancel (op_timeout);
1182 GNUNET_SCHEDULER_cancel (end);
1183 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1189 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
1194 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"),
1197 GNUNET_SCHEDULER_cancel (end);
1204 * Function called to notify transport users that another
1205 * peer connected to us.
1207 * @param cls closure
1208 * @param peer the peer that connected
1211 monitor_notify_connect (void *cls,
1212 const struct GNUNET_PeerIdentity *peer)
1214 monitor_connect_counter++;
1215 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1216 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1219 _("%24s: %-17s %4s (%u connections in total)\n"),
1223 monitor_connect_counter);
1228 * Function called to notify transport users that another
1229 * peer disconnected from us.
1231 * @param cls closure
1232 * @param peer the peer that disconnected
1235 monitor_notify_disconnect (void *cls,
1236 const struct GNUNET_PeerIdentity *peer)
1238 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
1239 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
1241 GNUNET_assert(monitor_connect_counter > 0);
1242 monitor_connect_counter--;
1245 _("%24s: %-17s %4s (%u connections in total)\n"),
1247 _("Disconnected from"),
1249 monitor_connect_counter);
1254 * Function called by the transport for each received message.
1256 * @param cls closure
1257 * @param peer (claimed) identity of the other peer
1258 * @param message the message
1261 notify_receive (void *cls,
1262 const struct GNUNET_PeerIdentity *peer,
1263 const struct GNUNET_MessageHeader *message)
1265 if (benchmark_receive)
1267 if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type))
1271 _("Received %u bytes from %s\n"),
1272 (unsigned int) ntohs (message->size),
1275 if (traffic_received == 0)
1276 start_time = GNUNET_TIME_absolute_get ();
1277 traffic_received += ntohs (message->size);
1284 * Convert address to a printable format.
1286 * @param address the address
1287 * @param numeric #GNUNET_YES to convert to numeric format, #GNUNET_NO
1288 * to try to use reverse DNS
1289 * @param state state the peer is in
1290 * @param state_timeout when will the peer's state expire
1293 resolve_peer_address (const struct GNUNET_HELLO_Address *address,
1295 enum GNUNET_TRANSPORT_PeerState state,
1296 struct GNUNET_TIME_Absolute state_timeout);
1300 print_info (const struct GNUNET_PeerIdentity *id,
1301 const char *transport,
1303 enum GNUNET_TRANSPORT_PeerState state,
1304 struct GNUNET_TIME_Absolute state_timeout)
1307 if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
1308 (GNUNET_YES == monitor_connections))
1311 _("Peer `%s': %s %s in state `%s' until %s\n"),
1313 (NULL == transport) ? "<none>" : transport,
1314 (NULL == transport) ? "<none>" : addr,
1315 GNUNET_TRANSPORT_ps2s (state),
1316 GNUNET_STRINGS_absolute_time_to_string (state_timeout));
1318 else if ( (GNUNET_YES == iterate_connections) &&
1319 (GNUNET_TRANSPORT_is_connected(state)))
1321 /* Only connected peers, skip state */
1323 _("Peer `%s': %s %s\n"),
1332 * Function called with a textual representation of an address. This
1333 * function will be called several times with different possible
1334 * textual representations, and a last time with @a address being NULL
1335 * to signal the end of the iteration. Note that @a address NULL
1336 * always is the last call, regardless of the value in @a res.
1338 * @param cls closure
1339 * @param address NULL on end of iteration,
1340 * otherwise 0-terminated printable UTF-8 string,
1341 * in particular an empty string if @a res is #GNUNET_NO
1342 * @param res result of the address to string conversion:
1343 * if #GNUNET_OK: conversion successful
1344 * if #GNUNET_NO: address was invalid (or not supported)
1345 * if #GNUNET_SYSERR: communication error (IPC error)
1348 process_peer_string (void *cls,
1349 const char *address,
1352 struct PeerResolutionContext *rc = cls;
1354 if (NULL != address)
1356 if (GNUNET_SYSERR == res)
1359 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
1360 GNUNET_i2s (&rc->addrcp->peer),
1361 rc->addrcp->transport_name,
1362 (unsigned int) rc->addrcp->address_length);
1363 print_info (&rc->addrcp->peer,
1368 rc->printed = GNUNET_YES;
1371 if (GNUNET_OK == res)
1373 print_info (&rc->addrcp->peer,
1378 rc->printed = GNUNET_YES;
1379 return; /* Wait for done call */
1381 /* GNUNET_NO == res: ignore, was simply not supported */
1384 /* NULL == address, last call, we are done */
1387 GNUNET_assert (address_resolutions > 0);
1388 address_resolutions--;
1389 if (GNUNET_NO == rc->printed)
1391 if (numeric == GNUNET_NO)
1393 /* Failed to resolve address, try numeric lookup
1394 (note: this should not be needed, as transport
1395 should fallback to numeric conversion if DNS takes
1397 resolve_peer_address (rc->addrcp,
1404 print_info (&rc->addrcp->peer,
1411 GNUNET_free (rc->transport);
1412 GNUNET_free (rc->addrcp);
1413 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc);
1415 if ((0 == address_resolutions) && (iterate_connections))
1419 GNUNET_SCHEDULER_cancel (end);
1422 if (NULL != op_timeout)
1424 GNUNET_SCHEDULER_cancel (op_timeout);
1428 end = GNUNET_SCHEDULER_add_now (&shutdown_task,
1435 * Convert address to a printable format and print it
1436 * together with the given state data.
1438 * @param address the address
1439 * @param numeric #GNUNET_YES to convert to numeric format, #GNUNET_NO
1440 * to try to use reverse DNS
1441 * @param state state the peer is in
1442 * @param state_timeout when will the peer's state expire
1445 resolve_peer_address (const struct GNUNET_HELLO_Address *address,
1447 enum GNUNET_TRANSPORT_PeerState state,
1448 struct GNUNET_TIME_Absolute state_timeout)
1450 struct PeerResolutionContext *rc;
1452 rc = GNUNET_new (struct PeerResolutionContext);
1453 GNUNET_CONTAINER_DLL_insert (rc_head,
1456 address_resolutions++;
1457 rc->transport = GNUNET_strdup (address->transport_name);
1458 rc->addrcp = GNUNET_HELLO_address_copy (address);
1459 rc->printed = GNUNET_NO;
1461 rc->state_timeout = state_timeout;
1462 /* Resolve address to string */
1463 rc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1467 &process_peer_string, rc);
1472 * Function called with information about a peers during a one shot iteration
1474 * @param cls closure
1475 * @param peer identity of the peer, NULL for final callback when operation done
1476 * @param address binary address used to communicate with this peer,
1477 * NULL on disconnect or when done
1478 * @param state current state this peer is in
1479 * @param state_timeout time out for the current state
1482 process_peer_iteration_cb (void *cls,
1483 const struct GNUNET_PeerIdentity *peer,
1484 const struct GNUNET_HELLO_Address *address,
1485 enum GNUNET_TRANSPORT_PeerState state,
1486 struct GNUNET_TIME_Absolute state_timeout)
1491 address_resolution_in_progress = GNUNET_NO;
1494 GNUNET_SCHEDULER_cancel (end);
1495 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1499 if ( (GNUNET_NO == iterate_all) &&
1500 (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)))
1501 return; /* Display only connected peers */
1503 if (NULL != op_timeout)
1504 GNUNET_SCHEDULER_cancel (op_timeout);
1505 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1510 "Received address for peer `%s': %s\n",
1512 address->transport_name);
1514 if (NULL != address)
1515 resolve_peer_address (address,
1529 * Context for address resolution by #plugin_monitoring_cb().
1531 struct PluginMonitorAddress
1535 * Ongoing resolution request.
1537 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
1540 * Resolved address as string.
1545 * Last event we got and did not yet print because
1546 * @e str was NULL (address not yet resolved).
1548 struct GNUNET_TRANSPORT_SessionInfo si;
1553 * Print information about a plugin monitoring event.
1555 * @param addr out internal context
1556 * @param info the monitoring information
1559 print_plugin_event_info (struct PluginMonitorAddress *addr,
1560 const struct GNUNET_TRANSPORT_SessionInfo *info)
1564 switch (info->state)
1566 case GNUNET_TRANSPORT_SS_INIT:
1569 case GNUNET_TRANSPORT_SS_HANDSHAKE:
1570 state = "HANDSHAKE";
1572 case GNUNET_TRANSPORT_SS_UP:
1575 case GNUNET_TRANSPORT_SS_UPDATE:
1578 case GNUNET_TRANSPORT_SS_DONE:
1586 "%s: state %s timeout in %s @ %s%s\n",
1587 GNUNET_i2s (&info->address->peer),
1589 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (info->session_timeout),
1592 (info->is_inbound == GNUNET_YES) ? " (INBOUND)" : "");
1594 "%s: queue has %3u messages and %6u bytes\n",
1595 GNUNET_i2s (&info->address->peer),
1596 info->num_msg_pending,
1597 info->num_bytes_pending);
1598 if (0 != GNUNET_TIME_absolute_get_remaining (info->receive_delay).rel_value_us)
1600 "%s: receiving blocked until %s\n",
1601 GNUNET_i2s (&info->address->peer),
1602 GNUNET_STRINGS_absolute_time_to_string (info->receive_delay));
1607 * Function called with a textual representation of an address. This
1608 * function will be called several times with different possible
1609 * textual representations, and a last time with @a address being NULL
1610 * to signal the end of the iteration. Note that @a address NULL
1611 * always is the last call, regardless of the value in @a res.
1613 * @param cls closure
1614 * @param address NULL on end of iteration,
1615 * otherwise 0-terminated printable UTF-8 string,
1616 * in particular an empty string if @a res is #GNUNET_NO
1617 * @param res result of the address to string conversion:
1618 * if #GNUNET_OK: conversion successful
1619 * if #GNUNET_NO: address was invalid (or not supported)
1620 * if #GNUNET_SYSERR: communication error (IPC error)
1623 address_cb (void *cls,
1624 const char *address,
1627 struct PluginMonitorAddress *addr = cls;
1629 if (NULL == address)
1634 if (NULL != addr->str)
1636 addr->str = GNUNET_strdup (address);
1637 print_plugin_event_info (addr,
1643 * Function called by the plugin with information about the
1644 * current sessions managed by the plugin (for monitoring).
1646 * @param cls closure (NULL)
1647 * @param session session handle this information is about,
1648 * NULL to indicate that we are "in sync" (initial
1649 * iteration complete)
1650 * @param session_ctx storage location where the application
1651 * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT,
1652 * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE
1653 * @param info information about the state of the session,
1654 * NULL if @a session is also NULL and we are
1655 * merely signalling that the initial iteration is over;
1656 * NULL with @a session being non-NULL if the monitor
1657 * was being cancelled while sessions were active
1660 plugin_monitoring_cb (void *cls,
1661 struct GNUNET_TRANSPORT_PluginSession *session,
1663 const struct GNUNET_TRANSPORT_SessionInfo *info)
1665 struct PluginMonitorAddress *addr;
1667 if ( (NULL == info) &&
1669 return; /* in sync with transport service */
1670 addr = *session_ctx;
1675 if (NULL != addr->asc)
1677 GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
1680 GNUNET_free_non_null (addr->str);
1682 *session_ctx = NULL;
1684 return; /* shutdown */
1686 if ( (NULL != cpid) &&
1687 (0 != memcmp (&info->address->peer,
1689 sizeof (struct GNUNET_PeerIdentity))) )
1690 return; /* filtered */
1693 addr = GNUNET_new (struct PluginMonitorAddress);
1694 addr->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1697 GNUNET_TIME_UNIT_FOREVER_REL,
1700 *session_ctx = addr;
1702 if (NULL == addr->str)
1705 print_plugin_event_info (addr,
1707 if (GNUNET_TRANSPORT_SS_DONE == info->state)
1709 if (NULL != addr->asc)
1711 GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
1714 GNUNET_free_non_null (addr->str);
1716 *session_ctx = NULL;
1722 * Function called with information about a peers
1724 * @param cls closure, NULL
1725 * @param peer identity of the peer, NULL for final callback when operation done
1726 * @param address binary address used to communicate with this peer,
1727 * NULL on disconnect or when done
1728 * @param state current state this peer is in
1729 * @param state_timeout time out for the current state
1732 process_peer_monitoring_cb (void *cls,
1733 const struct GNUNET_PeerIdentity *peer,
1734 const struct GNUNET_HELLO_Address *address,
1735 enum GNUNET_TRANSPORT_PeerState state,
1736 struct GNUNET_TIME_Absolute state_timeout)
1738 struct MonitoredPeer *m;
1744 _("Monitor disconnected from transport service. Reconnecting.\n"));
1748 if (NULL != op_timeout)
1749 GNUNET_SCHEDULER_cancel (op_timeout);
1750 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
1754 if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers,
1757 m = GNUNET_new (struct MonitoredPeer);
1758 GNUNET_CONTAINER_multipeermap_put (monitored_peers,
1761 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1765 if ( (m->state == state) &&
1766 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
1767 (NULL == address) &&
1768 (NULL == m->address) )
1770 return; /* No real change */
1772 if ( (m->state == state) &&
1773 (NULL != address) &&
1774 (NULL != m->address) &&
1775 (0 == GNUNET_HELLO_address_cmp(m->address, address)) )
1776 return; /* No real change */
1779 if (NULL != m->address)
1781 GNUNET_free (m->address);
1784 if (NULL != address)
1785 m->address = GNUNET_HELLO_address_copy (address);
1787 m->state_timeout = state_timeout;
1789 if (NULL != address)
1790 resolve_peer_address (m->address,
1804 * Function called with our result of trying to connect to a peer
1805 * using the transport service. Will retry 10 times, and if we still
1806 * fail to connect terminate with an error message.
1809 * @param result #GNUNET_OK if we connected to the service
1812 try_connect_cb (void *cls,
1815 static int retries = 0;
1818 if (GNUNET_OK == result)
1823 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
1831 _("Failed to send connect request to transport service\n"));
1833 GNUNET_SCHEDULER_cancel (end);
1835 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1840 * Function called with our result of trying to disconnect a peer
1841 * using the transport service. Will retry 10 times, and if we still
1842 * fail to disconnect, terminate with an error message.
1845 * @param result #GNUNET_OK if we connected to the service
1848 try_disconnect_cb (void *cls,
1851 static int retries = 0;
1854 if (GNUNET_OK == result)
1859 td_handle = GNUNET_TRANSPORT_try_disconnect (handle,
1865 FPRINTF (stderr, "%s",
1866 _("Failed to send disconnect request to transport service\n"));
1868 GNUNET_SCHEDULER_cancel (end);
1870 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1875 * Function called with the result of the check if the 'transport'
1876 * service is running.
1878 * @param cls closure with our configuration
1879 * @param result #GNUNET_YES if transport is running
1882 testservice_task (void *cls,
1888 if (GNUNET_YES != result)
1890 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
1896 != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid),
1899 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
1903 counter = benchmark_send + benchmark_receive + iterate_connections
1904 + monitor_connections + monitor_connects + try_connect + try_disconnect +
1905 + iterate_validation + monitor_validation + monitor_plugins;
1910 _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
1911 "connect", "benchmark send", "benchmark receive", "information",
1912 "monitor", "events", "plugins");
1918 _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
1919 "connect", "benchmark send", "benchmark receive", "information",
1920 "monitor", "events", "plugins");
1924 if (try_connect) /* -C: Connect to peer */
1928 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1933 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1934 ¬ify_connect, ¬ify_disconnect);
1937 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1941 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
1943 if (NULL == tc_handle)
1945 FPRINTF (stderr, "%s",
1946 _("Failed to send request to transport service\n"));
1950 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1954 else if (try_disconnect) /* -D: Disconnect from peer */
1958 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1963 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
1964 ¬ify_connect, ¬ify_disconnect);
1967 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1971 td_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid,
1974 if (NULL == td_handle)
1976 FPRINTF (stderr, "%s",
1977 _("Failed to send request to transport service\n"));
1981 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1985 else if (benchmark_send) /* -s: Benchmark sending */
1989 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
1994 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
1997 ¬ify_disconnect);
2000 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
2004 tc_handle = GNUNET_TRANSPORT_try_connect (handle,
2008 if (NULL == tc_handle)
2010 FPRINTF (stderr, "%s",
2011 _("Failed to send request to transport service\n"));
2015 start_time = GNUNET_TIME_absolute_get ();
2016 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
2020 else if (benchmark_receive) /* -b: Benchmark receiving */
2022 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, NULL,
2026 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
2031 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n"));
2032 start_time = GNUNET_TIME_absolute_get ();
2035 else if (iterate_connections) /* -i: List information about peers once */
2037 address_resolution_in_progress = GNUNET_YES;
2038 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
2039 GNUNET_YES, TIMEOUT, &process_peer_iteration_cb, (void *) cfg);
2040 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
2043 else if (monitor_connections) /* -m: List information about peers continuously */
2045 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10,
2047 address_resolution_in_progress = GNUNET_YES;
2048 pic = GNUNET_TRANSPORT_monitor_peers (cfg,
2049 (NULL == cpid) ? NULL : &pid,
2052 &process_peer_monitoring_cb, NULL);
2054 else if (monitor_plugins) /* -P: List information about plugins continuously */
2056 monitored_plugins = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
2057 pm = GNUNET_TRANSPORT_monitor_plugins (cfg,
2058 &plugin_monitoring_cb,
2061 else if (iterate_validation) /* -d: Print information about validations */
2063 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
2064 (NULL == cpid) ? NULL : &pid,
2065 GNUNET_YES, TIMEOUT,
2066 &process_validation_cb, (void *) cfg);
2068 else if (monitor_validation) /* -f: Print information about validations continuously */
2070 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
2071 (NULL == cpid) ? NULL : &pid,
2073 &process_validation_cb, (void *) cfg);
2075 else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */
2077 monitor_connect_counter = 0;
2078 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL,
2079 &monitor_notify_connect,
2080 &monitor_notify_disconnect);
2085 _("Failed to connect to transport service\n"));
2097 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
2104 * Main function that will be run by the scheduler.
2106 * @param cls closure
2107 * @param args remaining command-line arguments
2108 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
2109 * @param mycfg configuration
2114 const char *cfgfile,
2115 const struct GNUNET_CONFIGURATION_Handle *mycfg)
2117 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
2118 if (test_configuration)
2120 do_test_configuration (cfg);
2123 GNUNET_CLIENT_service_test ("transport", cfg, GNUNET_TIME_UNIT_SECONDS,
2124 &testservice_task, (void *) cfg);
2128 main (int argc, char * const *argv)
2131 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
2133 gettext_noop ("print information for all peers (instead of only connected peers)"),
2134 0, &GNUNET_GETOPT_set_one, &iterate_all },
2135 { 'b', "benchmark", NULL,
2136 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
2137 0, &GNUNET_GETOPT_set_one, &benchmark_receive },
2139 NULL, gettext_noop ("connect to a peer"), 0,
2140 &GNUNET_GETOPT_set_one, &try_connect },
2141 { 'D', "disconnect",
2142 NULL, gettext_noop ("disconnect to a peer"), 0,
2143 &GNUNET_GETOPT_set_one, &try_disconnect },
2144 { 'd', "validation", NULL,
2145 gettext_noop ("print information for all pending validations "),
2146 0, &GNUNET_GETOPT_set_one, &iterate_validation },
2147 { 'f', "monitorvalidation", NULL,
2148 gettext_noop ("print information for all pending validations continuously"),
2149 0, &GNUNET_GETOPT_set_one, &monitor_validation },
2150 { 'i', "information", NULL,
2151 gettext_noop ("provide information about all current connections (once)"),
2152 0, &GNUNET_GETOPT_set_one, &iterate_connections },
2153 { 'm', "monitor", NULL,
2154 gettext_noop ("provide information about all current connections (continuously)"),
2155 0, &GNUNET_GETOPT_set_one, &monitor_connections },
2156 { 'e', "events", NULL,
2157 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
2158 0, &GNUNET_GETOPT_set_one, &monitor_connects },
2160 NULL, gettext_noop ("do not resolve hostnames"), 0,
2161 &GNUNET_GETOPT_set_one, &numeric },
2162 { 'p', "peer", "PEER",
2163 gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
2165 { 'P', "plugins", NULL,
2166 gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one,
2168 { 's', "send", NULL, gettext_noop
2169 ("send data for benchmarking to the other peer (until CTRL-C)"), 0,
2170 &GNUNET_GETOPT_set_one, &benchmark_send },
2171 { 't', "test", NULL,
2172 gettext_noop ("test transport configuration (involves external server)"),
2173 0, &GNUNET_GETOPT_set_one, &test_configuration },
2174 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
2175 GNUNET_GETOPT_OPTION_END
2178 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
2181 res = GNUNET_PROGRAM_run (argc, argv,
2183 gettext_noop ("Direct access to transport service."),
2186 GNUNET_free((void *) argv);
2187 if (GNUNET_OK == res)
2192 /* end of gnunet-transport.c */