"OVERLAY_TOPOLOGY",
&topology))
{
- if (0 == strcasecmp (topology, "RANDOM"))
+ if (GNUNET_NO == GNUNET_TESTBED_topology_get_ (&rc->topology,
+ topology))
{
- rc->topology = GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI;
- }
- else if (0 == strcasecmp (topology, "SMALL_WORLD_RING"))
- {
- rc->topology = GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING;
- }
- else if (0 == strcasecmp (topology, "SMALL_WORLD"))
- {
- rc->topology = GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD;
- }
- else if (0 == strcasecmp (topology, "CLIQUE"))
- {
- rc->topology = GNUNET_TESTBED_TOPOLOGY_CLIQUE;
- }
- else if (0 == strcasecmp (topology, "LINE"))
- {
- rc->topology = GNUNET_TESTBED_TOPOLOGY_LINE;
- }
- else if (0 == strcasecmp (topology, "RING"))
- {
- rc->topology = GNUNET_TESTBED_TOPOLOGY_RING;
- }
- else if (0 == strcasecmp (topology, "2D_TORUS"))
- {
- rc->topology = GNUNET_TESTBED_TOPOLOGY_2D_TORUS;
- }
- else
LOG (GNUNET_ERROR_TYPE_WARNING,
"Unknown topology %s given in configuration\n", topology);
+ }
GNUNET_free (topology);
}
if ( (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology)
};
+/**
+ * A array of names representing topologies. Should be in sync with enum
+ * GNUNET_TESTBED_TopologyOption
+ */
+const char * topology_strings[] = {
+
+ /**
+ * A clique (everyone connected to everyone else). No options. If there are N
+ * peers this topology results in (N * (N -1)) connections.
+ */
+ "CLIQUE",
+
+ /**
+ * Small-world network (2d torus plus random links). Followed
+ * by the number of random links to add (unsigned int).
+ */
+ "SMALL_WORLD",
+
+ /**
+ * Small-world network (ring plus random links). Followed
+ * by the number of random links to add (unsigned int).
+ */
+ "SMALL_WORLD_RING",
+
+ /**
+ * Ring topology. No options.
+ */
+ "RING",
+
+ /**
+ * 2-d torus. No options.
+ */
+ "2D_TORUS",
+
+ /**
+ * Random graph. Followed by the number of random links to be established
+ * (unsigned int)
+ */
+ "RANDOM", // GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI
+
+ /**
+ * Certain percentage of peers are unable to communicate directly
+ * replicating NAT conditions. Followed by the fraction of
+ * NAT'ed peers (float).
+ */
+ "INTERNAT",
+
+ /**
+ * Scale free topology. FIXME: options?
+ */
+ "SCALE_FREE",
+
+ /**
+ * Straight line topology. No options.
+ */
+ "LINE",
+
+ /**
+ * Read a topology from a given file. Followed by the name of the file (const char *).
+ */
+ "FROM_FILE",
+
+ /**
+ * All peers are disconnected. No options.
+ */
+ "NONE",
+
+ /**
+ * End of strings
+ */
+ NULL
+
+ };
+
+
/**
* Callback to be called when an overlay_link operation complete
*
return op;
}
+
+/**
+ * Get a topology from a string input.
+ *
+ * @param topology where to write the retrieved topology
+ * @param topology_string The string to attempt to
+ * get a configuration value from
+ * @return GNUNET_YES if topology string matched a
+ * known topology, GNUNET_NO if not
+ */
+int
+GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology,
+ const char *topology_string)
+{
+ unsigned int cnt;
+
+ for (cnt = 0; NULL != topology_strings[cnt]; cnt++)
+ {
+ if (0 == strcasecmp (topology_string, topology_strings[cnt]))
+ {
+ if (NULL != topology)
+ *topology = cnt;
+ return GNUNET_YES;
+ }
+ }
+ return GNUNET_NO;
+}
+
+
+/**
+ * Returns the string corresponding to the given topology
+ *
+ * @param topology the topology
+ * @return the string (freshly allocated) of given topology; NULL if topology cannot be
+ * expressed as a string
+ */
+char *
+GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology)
+{
+ if (GNUNET_TESTBED_TOPOLOGY_OPTION_END <= topology)
+ return NULL;
+ return GNUNET_strdup (topology_strings[topology]);
+}
+
/* end of testbed_api_topology.c */
unsigned int *rows,
unsigned int **rows_len);
+
+/**
+ * Get a topology from a string input.
+ *
+ * @param topology where to write the retrieved topology
+ * @param topology_string The string to attempt to
+ * get a configuration value from
+ * @return GNUNET_YES if topology string matched a
+ * known topology, GNUNET_NO if not
+ */
+int
+GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology,
+ const char *topology_string);
+
+
+/**
+ * Returns the string corresponding to the given topology
+ *
+ * @param topology the topology
+ * @return the string (freshly allocated) of given topology; NULL if topology cannot be
+ * expressed as a string
+ */
+char *
+GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology);
+
#endif
/* end of testbed_api_topology.h */