-static void
-start_cb (struct PeerContext *p, void *cls)
-{
- static int started;
- started++;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%s') started\n",
- p->no,
- GNUNET_i2s (&p->id));
- if (started != 2)
- return;
-
- test_connected = GNUNET_NO;
- sender = p2;
- receiver = p1;
-
- char *sender_c = GNUNET_strdup (GNUNET_i2s (&sender->id));
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Test tries to send from %u (%s) -> peer %u (%s)\n",
- sender->no, sender_c,
- receiver->no, GNUNET_i2s (&receiver->id));
- GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
- &testing_connect_cb,
- NULL);
-}
-
-
-static void
-run (void *cls,
- char * const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL );
-
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- ¬ify_receive, ¬ify_connect, ¬ify_disconnect, &start_cb, NULL );
-
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- ¬ify_receive, ¬ify_connect, ¬ify_disconnect, &start_cb, NULL );
-
- if ((p1 == NULL )|| (p2 == NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
- if (die_task != NULL)
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
- return;
- }
-
- /* Start to watch statistics for peer 1 */
- p1_stat = GNUNET_STATISTICS_create ("transport", p1->cfg);
- GNUNET_STATISTICS_watch (p1_stat, "transport",
- "# Attempts to switch addresses",
- stat_start_attempt_cb, p1);
- GNUNET_STATISTICS_watch (p1_stat, "transport",
- "# Successful attempts to switch addresses",
- stat_success_attempt_cb, p1);
- GNUNET_STATISTICS_watch (p1_stat, "transport",
- "# Failed attempts to switch addresses (failed to send CONNECT CONT)",
- stat_fail_attempt_cb, p1);
- GNUNET_STATISTICS_watch (p1_stat, "transport",
- "# Failed attempts to switch addresses (failed to send CONNECT)",
- stat_fail_attempt_cb, p1);
- GNUNET_STATISTICS_watch (p1_stat, "transport",
- "# Failed attempts to switch addresses (no response)",
- stat_fail_attempt_cb, p1);
- GNUNET_STATISTICS_watch (p1_stat, "transport",
- "# transport addresses",
- stat_addresses_available, p1);
-
- /* Start to watch statistics for peer 2 */
- p2_stat = GNUNET_STATISTICS_create ("transport", p2->cfg);
- GNUNET_STATISTICS_watch (p2_stat, "transport",
- "# Attempts to switch addresses",
- stat_start_attempt_cb, p2);
- GNUNET_STATISTICS_watch (p2_stat, "transport",
- "# Successful attempts to switch addresses",
- stat_success_attempt_cb, p2);
- GNUNET_STATISTICS_watch (p2_stat, "transport",
- "# Failed attempts to switch addresses (failed to send CONNECT CONT)",
- stat_fail_attempt_cb, p2);
- GNUNET_STATISTICS_watch (p2_stat, "transport",
- "# Failed attempts to switch addresses (failed to send CONNECT)",
- stat_fail_attempt_cb, p2);
- GNUNET_STATISTICS_watch (p2_stat, "transport",
- "# Failed attempts to switch addresses (no response)",
- stat_fail_attempt_cb, p2);
- GNUNET_STATISTICS_watch (p2_stat, "transport",
- "# transport addresses",
- stat_addresses_available, p2);
-
- if ((p1_stat == NULL )|| (p2_stat == NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not create statistics for peers!\n");
- if (die_task != NULL)
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
- return;
- }
-}
-