diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-10-17 14:40:40 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-10-17 14:40:40 +0000 |
commit | 862743be25c33512dc519e00471a252880288a85 (patch) | |
tree | 80f5e4f78f3f1c46e73b8a73d6b7aded471d004d /src/regex | |
parent | 2529c7df1df2f22d5c0edae89271be657c6d1620 (diff) | |
download | gnunet-862743be25c33512dc519e00471a252880288a85.tar.gz gnunet-862743be25c33512dc519e00471a252880288a85.zip |
doxygen
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/Makefile.am | 3 | ||||
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 395 |
2 files changed, 194 insertions, 204 deletions
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index 9824db522..a0595fccb 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am | |||
@@ -27,7 +27,8 @@ gnunet_regex_profiler_SOURCES = \ | |||
27 | gnunet_regex_profiler_LDADD = \ | 27 | gnunet_regex_profiler_LDADD = \ |
28 | $(top_builddir)/src/regex/libgnunetregex.la \ | 28 | $(top_builddir)/src/regex/libgnunetregex.la \ |
29 | $(top_builddir)/src/util/libgnunetutil.la \ | 29 | $(top_builddir)/src/util/libgnunetutil.la \ |
30 | $(top_builddir)/src/testbed/libgnunettestbed.la | 30 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
31 | $(top_builddir)/src/mesh/libgnunetmesh.la | ||
31 | gnunet_regex_profiler_DEPENDENCIES = \ | 32 | gnunet_regex_profiler_DEPENDENCIES = \ |
32 | libgnunetregex.la | 33 | libgnunetregex.la |
33 | 34 | ||
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index a76569a47..90facb8bc 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -28,44 +28,27 @@ | |||
28 | #include <string.h> | 28 | #include <string.h> |
29 | 29 | ||
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | #include "gnunet_applications.h" | ||
31 | #include "gnunet_util_lib.h" | 32 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_mesh_service.h" | 33 | #include "gnunet_mesh_service.h" |
33 | #include "gnunet_stream_lib.h" | 34 | #include "gnunet_stream_lib.h" |
34 | #include "gnunet_testbed_service.h" | 35 | #include "gnunet_testbed_service.h" |
35 | 36 | ||
36 | 37 | ||
38 | /** | ||
39 | * Total number of hosts. | ||
40 | */ | ||
37 | #define NUM_HOSTS 2 | 41 | #define NUM_HOSTS 2 |
38 | 42 | ||
39 | #define PEER_PER_HOST 1 | ||
40 | |||
41 | #define TOTAL_PEERS (NUM_HOSTS * PEER_PER_HOST) | ||
42 | |||
43 | /** | 43 | /** |
44 | * Shorthand for Relative time in seconds | 44 | * Number of peers per host. |
45 | */ | 45 | */ |
46 | #define TIME_REL_SECS(sec) \ | 46 | #define PEER_PER_HOST 1 |
47 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) | ||
48 | 47 | ||
49 | /** | 48 | /** |
50 | * Structure for holding peer's sockets and IO Handles | 49 | * Total number of peers. |
51 | */ | 50 | */ |
52 | struct PeerData | 51 | #define TOTAL_PEERS (NUM_HOSTS * PEER_PER_HOST) |
53 | { | ||
54 | /** | ||
55 | * Handle to testbed peer | ||
56 | */ | ||
57 | struct GNUNET_TESTBED_Peer *peer; | ||
58 | |||
59 | /** | ||
60 | * The service connect operation to stream | ||
61 | */ | ||
62 | struct GNUNET_TESTBED_Operation *op; | ||
63 | |||
64 | /** | ||
65 | * Our Peer id | ||
66 | */ | ||
67 | struct GNUNET_PeerIdentity our_id; | ||
68 | }; | ||
69 | 52 | ||
70 | 53 | ||
71 | /** | 54 | /** |
@@ -105,8 +88,14 @@ uint64_t event_mask; | |||
105 | */ | 88 | */ |
106 | static struct GNUNET_TESTBED_Operation *op[NUM_HOSTS]; | 89 | static struct GNUNET_TESTBED_Operation *op[NUM_HOSTS]; |
107 | 90 | ||
91 | /** | ||
92 | * Setup state. | ||
93 | */ | ||
108 | static enum SetupState state[NUM_HOSTS]; | 94 | static enum SetupState state[NUM_HOSTS]; |
109 | 95 | ||
96 | /** | ||
97 | * Abort task. | ||
98 | */ | ||
110 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; | 99 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; |
111 | 100 | ||
112 | /** | 101 | /** |
@@ -155,48 +144,78 @@ struct GNUNET_TESTBED_Host *slave_hosts[NUM_HOSTS]; | |||
155 | */ | 144 | */ |
156 | static struct GNUNET_TESTBED_HostRegistrationHandle *rh; | 145 | static struct GNUNET_TESTBED_HostRegistrationHandle *rh; |
157 | 146 | ||
158 | /** | ||
159 | * The peers | ||
160 | */ | ||
161 | struct GNUNET_TESTBED_Peer *peers[TOTAL_PEERS]; | ||
162 | 147 | ||
163 | /** | 148 | /** |
164 | * Handle to global configuration | 149 | * Handle to global configuration |
165 | */ | 150 | */ |
166 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 151 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
167 | 152 | ||
153 | /** | ||
154 | * Structure for holding peer's handles. | ||
155 | */ | ||
156 | struct PeerData | ||
157 | { | ||
158 | /** | ||
159 | * Handle to testbed peer. | ||
160 | */ | ||
161 | struct GNUNET_TESTBED_Peer *peer; | ||
162 | |||
163 | /** | ||
164 | * Peer's mesh handle. | ||
165 | */ | ||
166 | struct GNUNET_MESH_Handle *mesh_handle; | ||
167 | |||
168 | /** | ||
169 | * The service connect operation to stream | ||
170 | */ | ||
171 | struct GNUNET_TESTBED_Operation *op; | ||
172 | |||
173 | /** | ||
174 | * Peer setup state. | ||
175 | */ | ||
176 | enum SetupState state; | ||
177 | |||
178 | /** | ||
179 | * Our Peer id | ||
180 | */ | ||
181 | struct GNUNET_PeerIdentity our_id; | ||
182 | }; | ||
168 | 183 | ||
169 | /** | 184 | /** |
170 | * Completion callback for shutdown | 185 | * The peers |
171 | * | ||
172 | * @param cls the closure from GNUNET_STREAM_shutdown call | ||
173 | * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR, | ||
174 | * SHUT_RDWR) | ||
175 | */ | 186 | */ |
176 | // static void | 187 | struct PeerData peers[TOTAL_PEERS]; |
177 | // shutdown_completion (void *cls, | ||
178 | // int operation) | ||
179 | // { | ||
180 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n"); | ||
181 | // GNUNET_SCHEDULER_add_now (&do_close, cls); | ||
182 | // } | ||
183 | 188 | ||
184 | 189 | ||
185 | 190 | ||
186 | /** | 191 | /** |
187 | * Shutdown sockets gracefully | 192 | * Close sockets and stop testing deamons nicely |
188 | */ | 193 | */ |
189 | // static void | 194 | void |
190 | // do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 195 | do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
191 | // { | 196 | { |
192 | // result = GNUNET_OK; | 197 | unsigned int i; |
193 | // peer1.shutdown_handle = GNUNET_STREAM_shutdown (peer1.socket, SHUT_RDWR, | 198 | |
194 | // &shutdown_completion, cls); | 199 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) |
195 | // } | 200 | GNUNET_SCHEDULER_cancel (abort_task); |
201 | |||
202 | for (i = 0; i < TOTAL_PEERS; i++) | ||
203 | { | ||
204 | if (NULL != peers[i].mesh_handle) | ||
205 | GNUNET_MESH_disconnect (peers[i].mesh_handle); | ||
206 | if (NULL != peers[i].op) | ||
207 | GNUNET_TESTBED_operation_done (peers[i].op); | ||
208 | } | ||
209 | |||
210 | GNUNET_SCHEDULER_shutdown (); /* For shutting down testbed */ | ||
211 | } | ||
196 | 212 | ||
197 | 213 | ||
198 | /** | 214 | /** |
199 | * Something went wrong and timed out. Kill everything and set error flag | 215 | * Something went wrong and timed out. Kill everything and set error flag. |
216 | * | ||
217 | * @param cls close. | ||
218 | * @param tc task context. | ||
200 | */ | 219 | */ |
201 | static void | 220 | static void |
202 | do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 221 | do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -208,172 +227,113 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
208 | 227 | ||
209 | 228 | ||
210 | /** | 229 | /** |
211 | * Adapter function called to destroy a connection to | 230 | * Method called whenever another peer has added us to a tunnel |
212 | * a service. | 231 | * the other peer initiated. |
232 | * Only called (once) upon reception of data with a message type which was | ||
233 | * subscribed to in GNUNET_MESH_connect. A call to GNUNET_MESH_tunnel_destroy | ||
234 | * causes te tunnel to be ignored and no further notifications are sent about | ||
235 | * the same tunnel. | ||
213 | * | 236 | * |
214 | * @param cls closure | 237 | * @param cls closure |
215 | * @param op_result service handle returned from the connect adapter | 238 | * @param tunnel new handle to the tunnel |
239 | * @param initiator peer that started the tunnel | ||
240 | * @param atsi performance information for the tunnel | ||
241 | * @return initial tunnel context for the tunnel | ||
242 | * (can be NULL -- that's not an error) | ||
216 | */ | 243 | */ |
217 | // static void | 244 | void * |
218 | // stream_da (void *cls, void *op_result) | 245 | mesh_inbound_tunnel_handler (void *cls, |
219 | // { | 246 | struct GNUNET_MESH_Tunnel * tunnel, |
220 | // struct GNUNET_STREAM_ListenSocket *lsocket; | 247 | const struct GNUNET_PeerIdentity * initiator, |
221 | // struct GNUNET_STREAM_Socket *socket; | 248 | const struct GNUNET_ATS_Information * atsi) |
222 | // | 249 | { |
223 | // if (&peer1 == cls) | 250 | return NULL; |
224 | // { | 251 | } |
225 | // lsocket = op_result; | 252 | |
226 | // GNUNET_STREAM_listen_close (lsocket); | 253 | |
227 | // GNUNET_TESTBED_operation_done (peer2.op); | 254 | /** |
228 | // return; | 255 | * Function called whenever an inbound tunnel is destroyed. Should clean up |
229 | // } | 256 | * any associated state. This function is NOT called if the client has |
230 | // if (&peer2 == cls) | 257 | * explicitly asked for the tunnel to be destroyed using |
231 | // { | 258 | * GNUNET_MESH_tunnel_destroy. It must NOT call GNUNET_MESH_tunnel_destroy on |
232 | // socket = op_result; | 259 | * the tunnel. |
233 | // GNUNET_STREAM_close (socket); | ||
234 | // GNUNET_SCHEDULER_shutdown (); /* Exit point of the test */ | ||
235 | // return; | ||
236 | // } | ||
237 | // GNUNET_assert (0); | ||
238 | // } | ||
239 | |||
240 | |||
241 | /** | ||
242 | * Adapter function called to establish a connection to | ||
243 | * a service. | ||
244 | * | ||
245 | * @param cls closure | ||
246 | * @param cfg configuration of the peer to connect to; will be available until | ||
247 | * GNUNET_TESTBED_operation_done() is called on the operation returned | ||
248 | * from GNUNET_TESTBED_service_connect() | ||
249 | * @return service handle to return in 'op_result', NULL on error | ||
250 | */ | ||
251 | // static void * | ||
252 | // stream_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
253 | // { | ||
254 | // struct GNUNET_STREAM_ListenSocket *lsocket; | ||
255 | // | ||
256 | // switch (setup_state) | ||
257 | // { | ||
258 | // case PEER1_STREAM_CONNECT: | ||
259 | // lsocket = GNUNET_STREAM_listen (cfg, 10, &stream_listen_cb, NULL, | ||
260 | // GNUNET_STREAM_OPTION_SIGNAL_LISTEN_SUCCESS, | ||
261 | // &stream_connect, GNUNET_STREAM_OPTION_END); | ||
262 | // return lsocket; | ||
263 | // case PEER2_STREAM_CONNECT: | ||
264 | // peer2.socket = GNUNET_STREAM_open (cfg, &peer1.our_id, 10, &stream_open_cb, | ||
265 | // &peer2, GNUNET_STREAM_OPTION_END); | ||
266 | // return peer2.socket; | ||
267 | // default: | ||
268 | // GNUNET_assert (0); | ||
269 | // } | ||
270 | // } | ||
271 | |||
272 | |||
273 | /** | ||
274 | * Listen success callback; connects a peer to stream as client | ||
275 | */ | ||
276 | // static void | ||
277 | // stream_connect (void) | ||
278 | // { | ||
279 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n"); | ||
280 | // peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream", | ||
281 | // NULL, NULL, | ||
282 | // stream_ca, stream_da, &peer2); | ||
283 | // setup_state = PEER2_STREAM_CONNECT; | ||
284 | // } | ||
285 | |||
286 | |||
287 | /** | ||
288 | * Callback to be called when the requested peer information is available | ||
289 | * | ||
290 | * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information() | ||
291 | * @param op the operation this callback corresponds to | ||
292 | * @param pinfo the result; will be NULL if the operation has failed | ||
293 | * @param emsg error message if the operation has failed; will be NULL if the | ||
294 | * operation is successfull | ||
295 | */ | ||
296 | // static void | ||
297 | // peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_, | ||
298 | // const struct GNUNET_TESTBED_PeerInformation *pinfo, | ||
299 | // const char *emsg) | ||
300 | // { | ||
301 | // GNUNET_assert (NULL == emsg); | ||
302 | // GNUNET_assert (op == op_); | ||
303 | // switch (setup_state) | ||
304 | // { | ||
305 | // case PEER1_GET_IDENTITY: | ||
306 | // memcpy (&peer1.our_id, pinfo->result.id, | ||
307 | // sizeof (struct GNUNET_PeerIdentity)); | ||
308 | // GNUNET_TESTBED_operation_done (op); | ||
309 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s | ||
310 | // (&peer1.our_id)); | ||
311 | // op = GNUNET_TESTBED_peer_get_information (peer2.peer, | ||
312 | // GNUNET_TESTBED_PIT_IDENTITY, | ||
313 | // &peerinfo_cb, NULL); | ||
314 | // setup_state = PEER2_GET_IDENTITY; | ||
315 | // break; | ||
316 | // case PEER2_GET_IDENTITY: | ||
317 | // memcpy (&peer2.our_id, pinfo->result.id, | ||
318 | // sizeof (struct GNUNET_PeerIdentity)); | ||
319 | // GNUNET_TESTBED_operation_done (op); | ||
320 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s | ||
321 | // (&peer2.our_id)); | ||
322 | // peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "stream", | ||
323 | // NULL, NULL, stream_ca, | ||
324 | // stream_da, &peer1); | ||
325 | // setup_state = PEER1_STREAM_CONNECT; | ||
326 | // break; | ||
327 | // default: | ||
328 | // GNUNET_assert (0); | ||
329 | // } | ||
330 | // } | ||
331 | |||
332 | |||
333 | /** | ||
334 | * Signature of a main function for a testcase. | ||
335 | * | 260 | * |
336 | * @param cls closure | 261 | * @param cls closure (set from GNUNET_MESH_connect) |
337 | * @param num_peers number of peers in 'peers' | 262 | * @param tunnel connection to the other end (henceforth invalid) |
338 | * @param peers handle to peers run in the testbed | 263 | * @param tunnel_ctx place where local state associated |
339 | */ | 264 | * with the tunnel is stored |
340 | // static void | 265 | */ |
341 | // test_master (void *cls, unsigned int num_peers, | 266 | void |
342 | // struct GNUNET_TESTBED_Peer **peers) | 267 | mesh_tunnel_end_handler (void *cls, |
343 | // { | 268 | const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel_ctx) |
344 | // GNUNET_assert (NULL != peers); | 269 | { |
345 | // GNUNET_assert (NULL != peers[0]); | 270 | |
346 | // GNUNET_assert (NULL != peers[1]); | 271 | } |
347 | // peer1.peer = peers[0]; | 272 | |
348 | // peer2.peer = peers[1]; | ||
349 | // op = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL, peer2.peer, peer1.peer); | ||
350 | // setup_state = INIT; | ||
351 | // abort_task = | ||
352 | // GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
353 | // (GNUNET_TIME_UNIT_SECONDS, 40), &do_abort, | ||
354 | // NULL); | ||
355 | // } | ||
356 | 273 | ||
274 | /** | ||
275 | * Mesh connect callback. | ||
276 | * | ||
277 | * @param cls internal peer id. | ||
278 | * @param op operation handle. | ||
279 | * @param ca_result connect adapter result. | ||
280 | * @param emsg error message. | ||
281 | */ | ||
357 | void | 282 | void |
358 | mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | 283 | mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, |
359 | void *ca_result, const char *emsg) | 284 | void *ca_result, const char *emsg) |
360 | { | 285 | { |
361 | long i = (long) cls; | 286 | long i = (long) cls; |
362 | 287 | ||
288 | if (NULL != emsg) | ||
289 | { | ||
290 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Mesh connect failed: %s\n", emsg); | ||
291 | GNUNET_assert (0); | ||
292 | } | ||
293 | |||
363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect callback for peer %i\n", | 294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect callback for peer %i\n", |
364 | i); | 295 | i); |
365 | } | 296 | } |
366 | 297 | ||
367 | 298 | ||
299 | /** | ||
300 | * Mesh connect adapter. | ||
301 | * | ||
302 | * @param cls not used. | ||
303 | * @param cfg configuration handle. | ||
304 | * | ||
305 | * @return | ||
306 | */ | ||
368 | void * | 307 | void * |
369 | mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | 308 | mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
370 | { | 309 | { |
310 | struct PeerData *peer = (struct PeerData *)cls; | ||
311 | |||
371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect adapter\n"); | 312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect adapter\n"); |
372 | 313 | ||
314 | static struct GNUNET_MESH_MessageHandler handlers[] = { | ||
315 | {NULL, 0, 0} | ||
316 | }; | ||
317 | |||
318 | static GNUNET_MESH_ApplicationType apptypes[] = { | ||
319 | GNUNET_APPLICATION_TYPE_END | ||
320 | }; | ||
321 | |||
322 | peer->mesh_handle = GNUNET_MESH_connect (cfg, cls, | ||
323 | &mesh_inbound_tunnel_handler, | ||
324 | &mesh_tunnel_end_handler, handlers, apptypes); | ||
325 | |||
373 | return NULL; | 326 | return NULL; |
374 | } | 327 | } |
375 | 328 | ||
376 | 329 | ||
330 | /** | ||
331 | * Adapter function called to destroy a connection to | ||
332 | * the mesh service | ||
333 | * | ||
334 | * @param cls closure | ||
335 | * @param op_result service handle returned from the connect adapter | ||
336 | */ | ||
377 | void | 337 | void |
378 | mesh_da (void *cls, void *op_result) | 338 | mesh_da (void *cls, void *op_result) |
379 | { | 339 | { |
@@ -432,7 +392,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
432 | 392 | ||
433 | // GNUNET_TESTBED_operation_done(op[i]); | 393 | // GNUNET_TESTBED_operation_done(op[i]); |
434 | peer_id = i; // FIXME A * i + B | 394 | peer_id = i; // FIXME A * i + B |
435 | peers[peer_id] = peer; | 395 | peers[peer_id].peer = peer; |
436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer %i created\n", peer_id); | 396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer %i created\n", peer_id); |
437 | op[i] = GNUNET_TESTBED_peer_start (NULL, peer, peer_start_cb, (void *) i); | 397 | op[i] = GNUNET_TESTBED_peer_start (NULL, peer, peer_start_cb, (void *) i); |
438 | } | 398 | } |
@@ -465,7 +425,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
465 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Overlay Connected\n"); | 425 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Overlay Connected\n"); |
466 | for (i = 0; i < TOTAL_PEERS; i++) | 426 | for (i = 0; i < TOTAL_PEERS; i++) |
467 | { | 427 | { |
468 | GNUNET_TESTBED_service_connect (NULL, peers[i], "mesh", &mesh_connect_cb, | 428 | GNUNET_TESTBED_service_connect (NULL, peers[i].peer, "mesh", &mesh_connect_cb, |
469 | (void *) i, &mesh_ca, &mesh_da, NULL); | 429 | (void *) i, &mesh_ca, &mesh_da, NULL); |
470 | } | 430 | } |
471 | break; | 431 | break; |
@@ -501,12 +461,14 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
501 | peer_create_cb, (void *) i); | 461 | peer_create_cb, (void *) i); |
502 | break; | 462 | break; |
503 | case CREATING_PEER: | 463 | case CREATING_PEER: |
464 | { | ||
504 | GNUNET_TESTBED_operation_done (event->details. | 465 | GNUNET_TESTBED_operation_done (event->details. |
505 | operation_finished.operation); | 466 | operation_finished.operation); |
506 | op[i] = NULL; | 467 | op[i] = NULL; |
507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | 468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); |
508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer create\n"); | 469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer create\n"); |
509 | break; | 470 | break; |
471 | } | ||
510 | case LINKING_SLAVES: | 472 | case LINKING_SLAVES: |
511 | { | 473 | { |
512 | struct GNUNET_CONFIGURATION_Handle *slave_cfg; | 474 | struct GNUNET_CONFIGURATION_Handle *slave_cfg; |
@@ -528,25 +490,37 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
528 | break; | 490 | break; |
529 | } | 491 | } |
530 | case LINKING_SLAVES_SUCCESS: | 492 | case LINKING_SLAVES_SUCCESS: |
493 | { | ||
494 | unsigned int peer_cnt; | ||
495 | struct GNUNET_TESTBED_Peer *peer_handles[TOTAL_PEERS]; | ||
496 | |||
531 | GNUNET_TESTBED_operation_done (event->details. | 497 | GNUNET_TESTBED_operation_done (event->details. |
532 | operation_finished.operation); | 498 | operation_finished.operation); |
533 | op[i] = NULL; | 499 | op[i] = NULL; |
534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | 500 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); |
535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking slave %i succeeded\n", i); | 501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking slave %i succeeded\n", i); |
536 | state[0] = CONNECTING_PEERS; | 502 | state[0] = CONNECTING_PEERS; |
503 | |||
504 | for (peer_cnt = 0; peer_cnt < TOTAL_PEERS; peer_cnt++) | ||
505 | { | ||
506 | peer_handles[peer_cnt] = peers[peer_cnt].peer; | ||
507 | } | ||
537 | op[0] = | 508 | op[0] = |
538 | GNUNET_TESTBED_overlay_configure_topology (NULL, TOTAL_PEERS, peers, | 509 | GNUNET_TESTBED_overlay_configure_topology (NULL, TOTAL_PEERS, peer_handles, |
539 | GNUNET_TESTBED_TOPOLOGY_LINE); | 510 | GNUNET_TESTBED_TOPOLOGY_LINE); |
540 | GNUNET_assert (NULL != op[0]); | 511 | GNUNET_assert (NULL != op[0]); |
541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peers...\n"); | 512 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peers...\n"); |
542 | break; | 513 | break; |
514 | } | ||
543 | case CONNECTING_PEERS: | 515 | case CONNECTING_PEERS: |
516 | { | ||
544 | GNUNET_TESTBED_operation_done (event->details. | 517 | GNUNET_TESTBED_operation_done (event->details. |
545 | operation_finished.operation); | 518 | operation_finished.operation); |
546 | op[i] = NULL; | 519 | op[i] = NULL; |
547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | 520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); |
548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | 521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); |
549 | break; | 522 | break; |
523 | } | ||
550 | default: | 524 | default: |
551 | GNUNET_break (0); | 525 | GNUNET_break (0); |
552 | } | 526 | } |
@@ -556,11 +530,14 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
556 | } | 530 | } |
557 | } | 531 | } |
558 | 532 | ||
533 | |||
559 | /** | 534 | /** |
560 | * Callback which will be called to after a host registration succeeded or failed | 535 | * Callback which will be called to after a host registration succeeded or |
536 | * failed. Registration of all slave hosts is continued and linking of the hosts | ||
537 | * is started. | ||
561 | * | 538 | * |
562 | * @param cls the host which has been registered | 539 | * @param cls not used. |
563 | * @param emsg the error message; NULL if host registration is successful | 540 | * @param emsg the error message; NULL if host registration is successful. |
564 | */ | 541 | */ |
565 | static void | 542 | static void |
566 | registration_cont (void *cls, const char *emsg) | 543 | registration_cont (void *cls, const char *emsg) |
@@ -588,11 +565,15 @@ registration_cont (void *cls, const char *emsg) | |||
588 | } | 565 | } |
589 | } | 566 | } |
590 | 567 | ||
568 | |||
591 | /** | 569 | /** |
592 | * Callback to signal successfull startup of the controller process | 570 | * Callback to signal successfull startup of the controller process. If the |
571 | * startup was successfull the master controller and all slave hosts are | ||
572 | * created. Registering the slave hosts is started and continued in | ||
573 | * registration_cont. | ||
593 | * | 574 | * |
594 | * @param cls the closure from GNUNET_TESTBED_controller_start() | 575 | * @param cls not used. |
595 | * @param cfg the configuration with which the controller has been started; | 576 | * @param config the configuration with which the controller has been started; |
596 | * NULL if status is not GNUNET_OK | 577 | * NULL if status is not GNUNET_OK |
597 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, | 578 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, |
598 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 579 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
@@ -635,10 +616,10 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, | |||
635 | /** | 616 | /** |
636 | * Main run function. | 617 | * Main run function. |
637 | * | 618 | * |
638 | * @param cls NULL | 619 | * @param cls not used. |
639 | * @param args arguments passed to GNUNET_PROGRAM_run | 620 | * @param args arguments passed to GNUNET_PROGRAM_run |
640 | * @param cfgfile the path to configuration file | 621 | * @param cfgfile the path to configuration file |
641 | * @param cfg the configuration file handle | 622 | * @param config the configuration file handle |
642 | */ | 623 | */ |
643 | static void | 624 | static void |
644 | run (void *cls, char *const *args, const char *cfgfile, | 625 | run (void *cls, char *const *args, const char *cfgfile, |
@@ -657,8 +638,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
657 | NULL); | 638 | NULL); |
658 | } | 639 | } |
659 | 640 | ||
641 | |||
660 | /** | 642 | /** |
661 | * Main function | 643 | * Main function for profiling the regex/mesh implementation. Checks if all ssh |
644 | * connections to each of the hosts in 'slave_ips' is possible before setting up | ||
645 | * the testbed. | ||
646 | * | ||
647 | * @param argc argument count. | ||
648 | * @param argv argument values. | ||
649 | * | ||
650 | * @return 0 on success. | ||
662 | */ | 651 | */ |
663 | int | 652 | int |
664 | main (int argc, char **argv) | 653 | main (int argc, char **argv) |