2 This file is part of GNUnet.
3 (C) 2011 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.
32 #include "gnunet_util_lib.h"
33 #include "gnunet_resolver_service.h"
34 #include "gnunet_protocols.h"
35 #include "gnunet_transport_service.h"
36 #include "gnunet_nat_lib.h"
39 * How long do we wait for the NAT test to report success?
40 * Should match NAT_SERVER_TIMEOUT in 'nat_test.c'.
42 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
43 #define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
44 #define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
47 * Benchmarking block size in KB
52 * Which peer should we connect to?
57 * Handle to transport service.
59 static struct GNUNET_TRANSPORT_Handle *handle;
62 * Configuration handle
64 static struct GNUNET_CONFIGURATION_Handle *cfg;
69 struct GNUNET_TRANSPORT_TryConnectHandle * tc_handle;
74 static int benchmark_send;
79 static int benchmark_receive;
84 static int benchmark_receive;
89 static int iterate_connections;
94 static int iterate_all;
99 static int test_configuration;
104 static int monitor_connects;
109 static int monitor_connections;
114 static int try_connect;
122 * Global return value (0 success).
127 * Current number of connections in monitor mode
129 static int monitor_connect_counter;
132 * Number of bytes of traffic we received so far.
134 static unsigned long long traffic_received;
137 * Number of bytes of traffic we sent so far.
139 static unsigned long long traffic_sent;
142 * Starting time of transmitting/receiving data.
144 static struct GNUNET_TIME_Absolute start_time;
147 * Handle for current transmission request.
149 static struct GNUNET_TRANSPORT_TransmitHandle *th;
154 struct GNUNET_TRANSPORT_PeerMonitoringContext *pic;
157 * Identity of the peer we transmit to / connect to.
158 * (equivalent to 'cpid' string).
160 static struct GNUNET_PeerIdentity pid;
163 * Task scheduled for cleanup / termination of the process.
165 static GNUNET_SCHEDULER_TaskIdentifier end;
168 * Task for operation timeout
170 static GNUNET_SCHEDULER_TaskIdentifier op_timeout;
173 * Selected level of verbosity.
175 static int verbosity;
178 * Resolver process handle.
180 struct GNUNET_OS_Process *resolver;
183 * Number of tasks running that still need the resolver.
185 static unsigned int resolver_users;
188 * Number of address resolutions pending
190 static unsigned int address_resolutions;
193 * Address resolutions pending in progress
195 static unsigned int address_resolution_in_progress;
198 * Context for a plugin test.
204 * Handle to the active NAT test.
206 struct GNUNET_NAT_Test *tst;
209 * Task identifier for the timeout.
211 GNUNET_SCHEDULER_TaskIdentifier tsk;
214 * Name of plugin under test.
221 * Task run in monitor mode when the user presses CTRL-C to abort.
222 * Stops monitoring activity.
224 * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *'
225 * @param tc scheduler context
228 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
230 struct GNUNET_TIME_Relative duration;
231 end = GNUNET_SCHEDULER_NO_TASK;
232 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
234 GNUNET_SCHEDULER_cancel (op_timeout);
235 op_timeout = GNUNET_SCHEDULER_NO_TASK;
237 if (NULL != tc_handle)
239 GNUNET_TRANSPORT_try_connect_cancel (tc_handle);
244 GNUNET_TRANSPORT_monitor_peers_cancel (pic);
249 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
254 GNUNET_TRANSPORT_disconnect (handle);
259 duration = GNUNET_TIME_absolute_get_duration (start_time);
260 FPRINTF (stdout, _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
261 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
263 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
265 if (benchmark_receive)
267 duration = GNUNET_TIME_absolute_get_duration (start_time);
268 FPRINTF (stdout, _("Received %llu bytes/s (%llu bytes in %s)\n"),
269 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
271 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
275 static struct ResolutionContext *rc_head;
276 static struct ResolutionContext *rc_tail;
278 struct ResolutionContext
280 struct ResolutionContext *next;
281 struct ResolutionContext *prev;
282 struct GNUNET_HELLO_Address *addrcp;
283 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
288 operation_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
290 struct ResolutionContext *cur;
291 struct ResolutionContext *next;
292 op_timeout = GNUNET_SCHEDULER_NO_TASK;
293 if ((try_connect) || (benchmark_send) || (benchmark_receive))
295 FPRINTF (stdout, _("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid));
296 if (GNUNET_SCHEDULER_NO_TASK != end)
297 GNUNET_SCHEDULER_cancel (end);
298 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
302 if (iterate_connections)
305 while (NULL != (cur = next))
308 FPRINTF (stdout, _("Failed to resolve address for peer `%s'\n"),
309 GNUNET_i2s (&cur->addrcp->peer));
311 GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur);
312 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
313 GNUNET_free(cur->addrcp);
317 FPRINTF (stdout, "%s", _("Failed to list connections, timeout occured\n") );
318 if (GNUNET_SCHEDULER_NO_TASK != end)
319 GNUNET_SCHEDULER_cancel (end);
320 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
328 * Display the result of the test.
330 * @param tc test context
331 * @param result #GNUNET_YES on success
334 display_test_result (struct TestContext *tc, int result)
336 if (GNUNET_YES != result)
338 FPRINTF (stderr, "Configuration for plugin `%s' did not work!\n", tc->name);
342 FPRINTF (stderr, "Configuration for plugin `%s' is working!\n", tc->name);
344 if (GNUNET_SCHEDULER_NO_TASK != tc->tsk)
346 GNUNET_SCHEDULER_cancel (tc->tsk);
347 tc->tsk = GNUNET_SCHEDULER_NO_TASK;
351 GNUNET_NAT_test_stop (tc->tst);
356 if ((0 == resolver_users) && (NULL != resolver))
358 GNUNET_break(0 == GNUNET_OS_process_kill (resolver, GNUNET_TERM_SIG));
359 GNUNET_OS_process_destroy (resolver);
365 * Function called by NAT on success.
366 * Clean up and update GUI (with success).
368 * @param cls test context
369 * @param success currently always #GNUNET_OK
370 * @param emsg error message, NULL on success
373 result_callback (void *cls, int success, const char *emsg)
375 struct TestContext *tc = cls;
377 display_test_result (tc, success);
381 * Function called if NAT failed to confirm success.
382 * Clean up and update GUI (with failure).
384 * @param cls test context
385 * @param tc scheduler callback
388 fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
390 struct TestContext *tstc = cls;
392 tstc->tsk = GNUNET_SCHEDULER_NO_TASK;
393 display_test_result (tstc, GNUNET_NO);
397 * Test our plugin's configuration (NAT traversal, etc.).
399 * @param cfg configuration to test
402 do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
406 unsigned long long bnd_port;
407 unsigned long long adv_port;
408 struct TestContext *tc;
412 != GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
415 FPRINTF (stderr, "%s", _
416 ("No transport plugins configured, peer will never communicate\n") );
420 for (tok = strtok (plugins, " "); tok != NULL ; tok = strtok (NULL, " "))
422 char section[12 + strlen (tok)];
424 GNUNET_snprintf (section, sizeof(section), "transport-%s", tok);
426 != GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT",
430 _("No port configured for plugin `%s', cannot test it\n"), tok);
434 != GNUNET_CONFIGURATION_get_value_number (cfg, section,
435 "ADVERTISED_PORT", &adv_port))
437 if (NULL == resolver)
439 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
440 resolver = GNUNET_OS_start_process (GNUNET_YES,
441 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary,
442 "gnunet-service-resolver", NULL );
446 GNUNET_RESOLVER_connect (cfg);
447 tc = GNUNET_new (struct TestContext);
448 tc->name = GNUNET_strdup (tok);
449 tc->tst = GNUNET_NAT_test_start (cfg,
450 (0 == strcasecmp (tok, "udp")) ? GNUNET_NO : GNUNET_YES,
451 (uint16_t) bnd_port, (uint16_t) adv_port, &result_callback, tc);
454 display_test_result (tc, GNUNET_SYSERR);
457 tc->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, tc);
459 GNUNET_free(plugins);
463 * Function called to notify a client about the socket
464 * begin ready to queue more data. @a buf will be
465 * NULL and @a size zero if the socket was closed for
466 * writing in the meantime.
469 * @param size number of bytes available in @a buf
470 * @param buf where the callee should write the message
471 * @return number of bytes written to @a buf
474 transmit_data (void *cls, size_t size, void *buf)
476 struct GNUNET_MessageHeader *m = buf;
478 if ((NULL == buf) || (0 == size))
484 GNUNET_assert(size >= sizeof(struct GNUNET_MessageHeader));
485 GNUNET_assert(size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
486 m->size = ntohs (size);
487 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
488 memset (&m[1], 52, size - sizeof(struct GNUNET_MessageHeader));
489 traffic_sent += size;
490 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, BLOCKSIZE * 1024,
491 0, GNUNET_TIME_UNIT_FOREVER_REL, &transmit_data, NULL );
493 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
499 * Function called to notify transport users that another
500 * peer connected to us.
503 * @param peer the peer that connected
506 notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
508 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
513 /* all done, terminate instantly */
514 FPRINTF (stdout, _("Successfully connected to `%s'\n"),
515 GNUNET_i2s_full (peer));
518 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
520 GNUNET_SCHEDULER_cancel (op_timeout);
521 op_timeout = GNUNET_SCHEDULER_NO_TASK;
524 if (GNUNET_SCHEDULER_NO_TASK != end)
525 GNUNET_SCHEDULER_cancel (end);
526 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
531 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
533 GNUNET_SCHEDULER_cancel (op_timeout);
534 op_timeout = GNUNET_SCHEDULER_NO_TASK;
538 _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
539 GNUNET_i2s (&pid), BLOCKSIZE);
540 start_time = GNUNET_TIME_absolute_get ();
542 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer,
543 BLOCKSIZE * 1024, 0, GNUNET_TIME_UNIT_FOREVER_REL, &transmit_data,
552 * Function called to notify transport users that another
553 * peer disconnected from us.
556 * @param peer the peer that disconnected
559 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
561 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
566 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
571 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"),
573 if (GNUNET_SCHEDULER_NO_TASK != end)
574 GNUNET_SCHEDULER_cancel (end);
580 * Function called to notify transport users that another
581 * peer connected to us.
584 * @param peer the peer that connected
587 monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
589 monitor_connect_counter++;
590 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
591 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
593 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), now_str,
594 _("Connected to"), GNUNET_i2s (peer), monitor_connect_counter);
598 * Function called to notify transport users that another
599 * peer disconnected from us.
602 * @param peer the peer that disconnected
605 monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
607 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
608 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
610 GNUNET_assert(monitor_connect_counter > 0);
611 monitor_connect_counter--;
613 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), now_str,
614 _("Disconnected from"), GNUNET_i2s (peer), monitor_connect_counter);
618 * Function called by the transport for each received message.
621 * @param peer (claimed) identity of the other peer
622 * @param message the message
625 notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
626 const struct GNUNET_MessageHeader *message)
628 if (benchmark_receive)
630 if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type))
633 FPRINTF (stdout, _("Received %u bytes from %s\n"),
634 (unsigned int) ntohs (message->size), GNUNET_i2s (peer));
636 if (traffic_received == 0)
637 start_time = GNUNET_TIME_absolute_get ();
638 traffic_received += ntohs (message->size);
644 resolve_address (const struct GNUNET_HELLO_Address *address, int numeric);
647 process_string (void *cls, const char *address)
649 struct ResolutionContext *rc = cls;
650 struct GNUNET_HELLO_Address *addrcp = rc->addrcp;
652 if (address != NULL )
654 FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (&addrcp->peer),
655 addrcp->transport_name, address);
656 rc->printed = GNUNET_YES;
661 GNUNET_assert(address_resolutions > 0);
662 address_resolutions--;
663 if (GNUNET_NO == rc->printed)
665 if (numeric == GNUNET_NO)
667 resolve_address (rc->addrcp, GNUNET_YES); /* Failed to resolve address, try numeric lookup */
670 FPRINTF (stdout, _("Peer `%s': %s <unable to resolve address>\n"),
671 GNUNET_i2s (&addrcp->peer), addrcp->transport_name);
673 GNUNET_free(rc->addrcp);
674 GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, rc);
676 if ((0 == address_resolutions) && (iterate_connections))
678 if (GNUNET_SCHEDULER_NO_TASK != end)
680 GNUNET_SCHEDULER_cancel (end);
681 end = GNUNET_SCHEDULER_NO_TASK;
683 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
685 GNUNET_SCHEDULER_cancel (op_timeout);
686 op_timeout = GNUNET_SCHEDULER_NO_TASK;
689 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
695 resolve_address (const struct GNUNET_HELLO_Address *address, int numeric)
697 struct ResolutionContext *rc;
699 rc = GNUNET_new (struct ResolutionContext);
700 GNUNET_assert(NULL != rc);
701 GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc);
702 address_resolutions++;
704 rc->addrcp = GNUNET_HELLO_address_copy (address);
705 rc->printed = GNUNET_NO;
706 /* Resolve address to string */
707 rc->asc = GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
708 RESOLUTION_TIMEOUT, &process_string, rc);
712 * Function called with information about a peers
715 * @param peer identity of the peer, NULL for final callback when operation done
716 * @param address binary address used to communicate with this peer,
717 * NULL on disconnect or when done
718 * @param state current state this peer is in
719 * @param state_timeout time out for the current state
723 process_peer_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
724 const struct GNUNET_HELLO_Address *address,
725 enum GNUNET_TRANSPORT_PeerState state,
726 struct GNUNET_TIME_Absolute state_timeout)
731 address_resolution_in_progress = GNUNET_NO;
733 if (GNUNET_SCHEDULER_NO_TASK != end)
734 GNUNET_SCHEDULER_cancel (end);
735 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
738 if (address == NULL )
740 FPRINTF (stdout, _("Peer `%s' disconnected\n"), GNUNET_i2s (peer));
744 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
745 GNUNET_SCHEDULER_cancel (op_timeout);
746 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
749 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received address for peer `%s': %s\n",
750 GNUNET_i2s (peer), address->transport_name);
751 resolve_address (address, numeric);
755 try_connect_cb (void *cls, const int result)
757 static int retries = 0;
758 if (GNUNET_OK == result)
765 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
769 FPRINTF (stderr, "%s",
770 _("Failed to send connect request to transport service\n") );
771 if (GNUNET_SCHEDULER_NO_TASK != end)
772 GNUNET_SCHEDULER_cancel (end);
774 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
780 * Function called with the result of the check if the 'transport'
781 * service is running.
783 * @param cls closure with our configuration
784 * @param result #GNUNET_YES if transport is running
787 testservice_task (void *cls, int result)
792 if (GNUNET_YES != result)
794 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
800 != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid),
803 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
807 counter = benchmark_send + benchmark_receive + iterate_connections
808 + monitor_connections + monitor_connects + try_connect;
813 _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s\n"),
814 "connect", "benchmark send", "benchmark receive", "information",
815 "monitor", "events");
821 _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s\n"),
822 "connect", "benchmark send", "benchmark receive", "information",
823 "monitor", "events");
827 if (try_connect) /* -C: Connect to peer */
831 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
836 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
837 ¬ify_connect, ¬ify_disconnect);
840 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") );
844 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
846 if (NULL == tc_handle)
848 FPRINTF (stderr, "%s",
849 _("Failed to send request to transport service\n") );
853 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
857 else if (benchmark_send) /* -s: Benchmark sending */
861 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
866 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
867 ¬ify_connect, ¬ify_disconnect);
870 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") );
874 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
876 if (NULL == tc_handle)
878 FPRINTF (stderr, "%s",
879 _("Failed to send request to transport service\n") );
883 start_time = GNUNET_TIME_absolute_get ();
884 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
887 else if (benchmark_receive) /* -b: Benchmark receiving */
889 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, NULL,
893 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") );
898 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n") );
899 start_time = GNUNET_TIME_absolute_get ();
902 else if (iterate_connections) /* -i: List information about peers once */
904 address_resolution_in_progress = GNUNET_YES;
905 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
906 GNUNET_YES, TIMEOUT, &process_peer_cb, (void *) cfg);
907 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
910 else if (monitor_connections) /* -m: List information about peers continuously */
912 address_resolution_in_progress = GNUNET_YES;
913 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
914 GNUNET_NO, TIMEOUT, &process_peer_cb, (void *) cfg);
916 else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */
918 monitor_connect_counter = 0;
919 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL,
920 &monitor_notify_connect, &monitor_notify_disconnect);
923 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") );
935 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
936 &shutdown_task, NULL );
941 * Main function that will be run by the scheduler.
944 * @param args remaining command-line arguments
945 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
946 * @param mycfg configuration
949 run (void *cls, char * const *args, const char *cfgfile,
950 const struct GNUNET_CONFIGURATION_Handle *mycfg)
952 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
953 if (test_configuration)
955 do_test_configuration (cfg);
958 GNUNET_CLIENT_service_test ("transport", cfg, GNUNET_TIME_UNIT_SECONDS,
959 &testservice_task, (void *) cfg);
963 main (int argc, char * const *argv)
966 static const struct GNUNET_GETOPT_CommandLineOption options[] =
969 gettext_noop ("print information for all peers (instead of only connected peers )"),
970 0, &GNUNET_GETOPT_set_one, &iterate_all },
971 { 'b', "benchmark", NULL,
972 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
973 0, &GNUNET_GETOPT_set_one, &benchmark_receive }, { 'C', "connect",
974 NULL, gettext_noop ("connect to a peer"), 0,
975 &GNUNET_GETOPT_set_one, &try_connect },
976 { 'i', "information", NULL,
977 gettext_noop ("provide information about all current connections (once)"),
978 0, &GNUNET_GETOPT_set_one, &iterate_connections },
979 { 'm', "monitor", NULL,
980 gettext_noop ("provide information about all current connections (continuously)"),
981 0, &GNUNET_GETOPT_set_one, &monitor_connections },
982 { 'e', "events", NULL,
983 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
984 0, &GNUNET_GETOPT_set_one, &monitor_connects }, { 'n', "numeric",
985 NULL, gettext_noop ("do not resolve hostnames"), 0,
986 &GNUNET_GETOPT_set_one, &numeric }, { 'p', "peer", "PEER",
987 gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
988 &cpid }, { 's', "send", NULL, gettext_noop
989 ("send data for benchmarking to the other peer (until CTRL-C)"), 0,
990 &GNUNET_GETOPT_set_one, &benchmark_send },
992 gettext_noop ("test transport configuration (involves external server)"),
993 0, &GNUNET_GETOPT_set_one, &test_configuration },
994 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
995 GNUNET_GETOPT_OPTION_END };
997 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1000 res = GNUNET_PROGRAM_run (argc, argv, "gnunet-transport", gettext_noop
1001 ("Direct access to transport service."), options, &run, NULL );
1002 GNUNET_free((void * ) argv);
1003 if (GNUNET_OK == res)
1008 /* end of gnunet-transport.c */