+ rc->topology = GNUNET_TESTBED_TOPOLOGY_NONE;
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (rc->cfg, TESTBED_CONFIG_SECTION,
+ "OVERLAY_TOPOLOGY", &topology))
+ {
+ if (GNUNET_NO == GNUNET_TESTBED_topology_get_ (&rc->topology, topology))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, TESTBED_CONFIG_SECTION,
+ "OVERLAY_TOPLOGY",
+ _
+ ("Specified topology must be supported by testbed"));
+ }
+ GNUNET_free (topology);
+ }
+ switch (rc->topology)
+ {
+ case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI:
+ case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING:
+ case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD:
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (rc->cfg, TESTBED_CONFIG_SECTION,
+ "OVERLAY_RANDOM_LINKS",
+ &number))
+ {
+ /* OVERLAY option RANDOM & SMALL_WORLD_RING requires OVERLAY_RANDOM_LINKS
+ * option to be set to the number of random links to be established */
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, TESTBED_CONFIG_SECTION,
+ "OVERLAY_RANDOM_LINKS");
+ goto error_cleanup;
+ }
+ if (number > UINT32_MAX)
+ {
+ GNUNET_break (0); /* Too big number */
+ goto error_cleanup;
+ }
+ rc->random_links = (unsigned int) number;
+ break;
+ case GNUNET_TESTBED_TOPOLOGY_FROM_FILE:
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (rc->cfg, TESTBED_CONFIG_SECTION,
+ "OVERLAY_TOPOLOGY_FILE",
+ &rc->topo_file))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, TESTBED_CONFIG_SECTION,
+ "OVERLAY_TOPOLOGY_FILE");
+ goto error_cleanup;
+ }
+ goto warn_ignore;
+ case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (rc->cfg, TESTBED_CONFIG_SECTION,
+ SCALE_FREE_CAP, &number))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, TESTBED_CONFIG_SECTION,
+ SCALE_FREE_CAP);
+ goto error_cleanup;
+ }
+ if (UINT16_MAX < number)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("Maximum number of edges a peer can have in a scale free topology"
+ " cannot be more than %u. Given `%s = %llu'"), UINT16_MAX,
+ SCALE_FREE_CAP, number);
+ goto error_cleanup;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (rc->cfg, TESTBED_CONFIG_SECTION,
+ SCALE_FREE_M, &number))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, TESTBED_CONFIG_SECTION,
+ SCALE_FREE_M);
+ goto error_cleanup;
+ }
+ if (UINT8_MAX < number)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("The number of edges that can established when adding a new node"
+ " to scale free topology cannot be more than %u. Given `%s = %llu'"),
+ UINT8_MAX, SCALE_FREE_M, number);
+ goto error_cleanup;
+ }
+ goto warn_ignore;
+ default:
+ warn_ignore:
+ /* Warn if OVERLAY_RANDOM_LINKS is present that it will be ignored */
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_have_value (rc->cfg, TESTBED_CONFIG_SECTION,
+ "OVERLAY_RANDOM_LINKS"))
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Ignoring value of `OVERLAY_RANDOM_LINKS' in given configuration\n");
+ break;
+ }
+ if (0 != rc->num_hosts)
+ {
+ rc->hclist = GNUNET_malloc (sizeof (struct CompatibilityCheckContext)
+ * rc->num_hosts);
+ for (nhost = 0; nhost < rc->num_hosts; nhost++)
+ {
+ hc = &rc->hclist[nhost];
+ hc->index = nhost;
+ hc->rc = rc;
+ hc->h = GNUNET_TESTBED_is_host_habitable (rc->hosts[nhost], rc->cfg,
+ &host_habitable_cb, hc);
+ if (NULL == hc->h)
+ {
+ GNUNET_break (0);
+ for (nhost = 0; nhost < rc->num_hosts; nhost++)
+ {
+ hc = &rc->hclist[nhost];
+ if (NULL != hc->h)
+ GNUNET_TESTBED_is_host_habitable_cancel (hc->h);
+ }
+ GNUNET_free (rc->hclist);
+ rc->hclist = NULL;
+ goto error_cleanup;
+ }
+ }
+ }
+ else
+ rc->cproc =
+ GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h,
+ &controller_status_cb, rc);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, TESTBED_CONFIG_SECTION,
+ "SETUP_TIMEOUT",
+ &timeout))
+ {
+ timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+ DEFAULT_SETUP_TIMEOUT);
+ }
+ rc->rcop_map = GNUNET_CONTAINER_multihashmap32_create (256);
+ rc->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task, rc);
+ rc->interrupt_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &interrupt,
+ rc);
+ return;
+
+error_cleanup:
+ if (NULL != rc->h)
+ GNUNET_TESTBED_host_destroy (rc->h);
+ if (NULL != rc->hosts)
+ {
+ for (hid = 0; hid < rc->num_hosts; hid++)
+ if (NULL != rc->hosts[hid])
+ GNUNET_TESTBED_host_destroy (rc->hosts[hid]);
+ GNUNET_free (rc->hosts);
+ }
+ if (NULL != rc->cfg)
+ GNUNET_CONFIGURATION_destroy (rc->cfg);
+ GNUNET_free (rc);