- d = GNUNET_TESTING_daemon_get (pg, i);
- hs[i] = GNUNET_DHT_connect (d->cfg, 32);
- mhs[i] = GNUNET_DHT_monitor_start(hs[i],
- GNUNET_BLOCK_TYPE_ANY,
- NULL,
- &monitor_get_cb,
- &monitor_res_cb,
- &monitor_put_cb,
- (void *)(long)i);
- }
-
- if ((NULL == o) || (NULL == d_far))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "test: Error getting daemons from pg\n");
- GNUNET_SCHEDULER_cancel (disconnect_task);
- disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
- return;
- }
- monitor_counter = 0;
- put_task = GNUNET_SCHEDULER_add_now (&put_id, NULL);
- test_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 2), &do_test,
- NULL);
- disconnect_task =
- GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &disconnect_peers, NULL);
-
-}
-
-
-/**
- * Function that will be called whenever two daemons are connected by
- * the testing library.
- *
- * @param cls closure
- * @param first peer id for first daemon
- * @param second peer id for the second daemon
- * @param distance distance between the connected peers
- * @param first_cfg config for the first daemon
- * @param second_cfg config for the second daemon
- * @param first_daemon handle for the first daemon
- * @param second_daemon handle for the second daemon
- * @param emsg error message (NULL on success)
- */
-static void
-connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
- const struct GNUNET_PeerIdentity *second, uint32_t distance,
- const struct GNUNET_CONFIGURATION_Handle *first_cfg,
- const struct GNUNET_CONFIGURATION_Handle *second_cfg,
- struct GNUNET_TESTING_Daemon *first_daemon,
- struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg)
-{
-
- if (emsg == NULL)
- {
- total_connections++;
- GNUNET_PEER_intern (first);
- GNUNET_PEER_intern (second);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: Problem with new connection (%s)\n", emsg);
- }
-
-}
-
-
-/**
- * run: load configuration options and schedule test to run (start peergroup)
- * @param cls closure
- * @param args argv
- * @param cfgfile configuration file name (can be NULL)
- * @param cfg configuration handle
- */
-static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- char *temp_str;
- struct GNUNET_TESTING_Host *hosts;
- char *data_filename;
-
- ok = 1;
- testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
-
- GNUNET_log_setup ("test_dht_monitor",
- "WARNING",
- NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Starting daemons.\n");
- GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing_old",
- "use_progressbars", "YES");
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing_old",
- "num_peers", &num_peers))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Option TESTING:NUM_PEERS is required!\n");
- return;
- }
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, "testing_old",
- "topology_output_file",
- &topology_file))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Option test_dht_monitor:topology_output_file is required!\n");
- return;
- }
-
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (testing_cfg, "test_dht_topo",
- "data_output_file",
- &data_filename))
- {
- data_file =
- GNUNET_DISK_file_open (data_filename,
- GNUNET_DISK_OPEN_READWRITE |
- GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (data_file == NULL)