aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_topology.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-11-20 13:08:05 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-11-20 13:08:05 +0000
commitd5764ce0391a8089341a57e9c8cba41b15cc6c7b (patch)
tree2607abc16e83a28589785724dd297ab7ead2035e /src/testbed/testbed_api_topology.c
parentb0ca95f6c05e8486e252b4d8bdd6ae16b6d2560a (diff)
downloadgnunet-d5764ce0391a8089341a57e9c8cba41b15cc6c7b.tar.gz
gnunet-d5764ce0391a8089341a57e9c8cba41b15cc6c7b.zip
- topology name handling
Diffstat (limited to 'src/testbed/testbed_api_topology.c')
-rw-r--r--src/testbed/testbed_api_topology.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c
index 2c1e7b1bc..a49cabd46 100644
--- a/src/testbed/testbed_api_topology.c
+++ b/src/testbed/testbed_api_topology.c
@@ -111,6 +111,81 @@ struct TopologyContext
111 111
112 112
113/** 113/**
114 * A array of names representing topologies. Should be in sync with enum
115 * GNUNET_TESTBED_TopologyOption
116 */
117const char * topology_strings[] = {
118
119 /**
120 * A clique (everyone connected to everyone else). No options. If there are N
121 * peers this topology results in (N * (N -1)) connections.
122 */
123 "CLIQUE",
124
125 /**
126 * Small-world network (2d torus plus random links). Followed
127 * by the number of random links to add (unsigned int).
128 */
129 "SMALL_WORLD",
130
131 /**
132 * Small-world network (ring plus random links). Followed
133 * by the number of random links to add (unsigned int).
134 */
135 "SMALL_WORLD_RING",
136
137 /**
138 * Ring topology. No options.
139 */
140 "RING",
141
142 /**
143 * 2-d torus. No options.
144 */
145 "2D_TORUS",
146
147 /**
148 * Random graph. Followed by the number of random links to be established
149 * (unsigned int)
150 */
151 "RANDOM", // GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI
152
153 /**
154 * Certain percentage of peers are unable to communicate directly
155 * replicating NAT conditions. Followed by the fraction of
156 * NAT'ed peers (float).
157 */
158 "INTERNAT",
159
160 /**
161 * Scale free topology. FIXME: options?
162 */
163 "SCALE_FREE",
164
165 /**
166 * Straight line topology. No options.
167 */
168 "LINE",
169
170 /**
171 * Read a topology from a given file. Followed by the name of the file (const char *).
172 */
173 "FROM_FILE",
174
175 /**
176 * All peers are disconnected. No options.
177 */
178 "NONE",
179
180 /**
181 * End of strings
182 */
183 NULL
184
185 };
186
187
188/**
114 * Callback to be called when an overlay_link operation complete 189 * Callback to be called when an overlay_link operation complete
115 * 190 *
116 * @param cls element of the link_op array which points to the corresponding operation 191 * @param cls element of the link_op array which points to the corresponding operation
@@ -681,4 +756,48 @@ GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int num_peers,
681 return op; 756 return op;
682} 757}
683 758
759
760/**
761 * Get a topology from a string input.
762 *
763 * @param topology where to write the retrieved topology
764 * @param topology_string The string to attempt to
765 * get a configuration value from
766 * @return GNUNET_YES if topology string matched a
767 * known topology, GNUNET_NO if not
768 */
769int
770GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology,
771 const char *topology_string)
772{
773 unsigned int cnt;
774
775 for (cnt = 0; NULL != topology_strings[cnt]; cnt++)
776 {
777 if (0 == strcasecmp (topology_string, topology_strings[cnt]))
778 {
779 if (NULL != topology)
780 *topology = cnt;
781 return GNUNET_YES;
782 }
783 }
784 return GNUNET_NO;
785}
786
787
788/**
789 * Returns the string corresponding to the given topology
790 *
791 * @param topology the topology
792 * @return the string (freshly allocated) of given topology; NULL if topology cannot be
793 * expressed as a string
794 */
795char *
796GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology)
797{
798 if (GNUNET_TESTBED_TOPOLOGY_OPTION_END <= topology)
799 return NULL;
800 return GNUNET_strdup (topology_strings[topology]);
801}
802
684/* end of testbed_api_topology.c */ 803/* end of testbed_api_topology.c */