diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-10-17 16:33:37 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-10-17 16:33:37 +0000 |
commit | 4ff43da8a5d8b41a6c12a4c761288554e8093c6e (patch) | |
tree | f7a1cab688d3b46b16e316167636c74117d80263 /src/regex | |
parent | 41cbe7c2e8064a07e7e9652452a5bb482929761f (diff) | |
download | gnunet-4ff43da8a5d8b41a6c12a4c761288554e8093c6e.tar.gz gnunet-4ff43da8a5d8b41a6c12a4c761288554e8093c6e.zip |
doxygen, indentation
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 133 |
1 files changed, 88 insertions, 45 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 90facb8bc..2dc369841 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -128,27 +128,55 @@ static struct GNUNET_TESTBED_ControllerProc *master_proc; | |||
128 | */ | 128 | */ |
129 | static struct GNUNET_TESTBED_Controller *master_ctrl; | 129 | static struct GNUNET_TESTBED_Controller *master_ctrl; |
130 | 130 | ||
131 | |||
131 | /** | 132 | /** |
132 | * Slave host IP addresses | 133 | * Slave host registration handles |
133 | */ | 134 | */ |
135 | static struct GNUNET_TESTBED_HostRegistrationHandle *rh; | ||
134 | 136 | ||
135 | static char *slave_ips[NUM_HOSTS] = { "192.168.1.33", "192.168.1.34" }; | ||
136 | 137 | ||
137 | /** | 138 | /** |
138 | * The slave hosts | 139 | * Handle to global configuration |
139 | */ | 140 | */ |
140 | struct GNUNET_TESTBED_Host *slave_hosts[NUM_HOSTS]; | 141 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
141 | 142 | ||
142 | /** | 143 | /** |
143 | * Slave host registration handles | 144 | * Structure for storing host handles |
144 | */ | 145 | */ |
145 | static struct GNUNET_TESTBED_HostRegistrationHandle *rh; | 146 | struct Host |
147 | { | ||
148 | /** | ||
149 | * IP address of this host. | ||
150 | */ | ||
151 | char *ip; | ||
152 | |||
153 | /** | ||
154 | * Host handle. | ||
155 | */ | ||
156 | struct GNUNET_TESTBED_Host *host; | ||
157 | |||
158 | /** | ||
159 | * Registration state of this host. | ||
160 | */ | ||
161 | int host_registered; | ||
162 | |||
163 | /** | ||
164 | * Operation handle. | ||
165 | */ | ||
166 | struct GNUNET_TESTBED_Operation *op; | ||
146 | 167 | ||
168 | /** | ||
169 | * Host state. | ||
170 | */ | ||
171 | enum SetupState state; | ||
172 | }; | ||
147 | 173 | ||
148 | /** | 174 | /** |
149 | * Handle to global configuration | 175 | * List of slaves. |
150 | */ | 176 | */ |
151 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 177 | static struct Host slaves[NUM_HOSTS] = { {"192.168.1.33", NULL, 0, NULL, INIT}, |
178 | {"192.168.1.34", NULL, 0, NULL, INIT} | ||
179 | }; | ||
152 | 180 | ||
153 | /** | 181 | /** |
154 | * Structure for holding peer's handles. | 182 | * Structure for holding peer's handles. |
@@ -242,10 +270,9 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
242 | * (can be NULL -- that's not an error) | 270 | * (can be NULL -- that's not an error) |
243 | */ | 271 | */ |
244 | void * | 272 | void * |
245 | mesh_inbound_tunnel_handler (void *cls, | 273 | mesh_inbound_tunnel_handler (void *cls, struct GNUNET_MESH_Tunnel *tunnel, |
246 | struct GNUNET_MESH_Tunnel * tunnel, | 274 | const struct GNUNET_PeerIdentity *initiator, |
247 | const struct GNUNET_PeerIdentity * initiator, | 275 | const struct GNUNET_ATS_Information *atsi) |
248 | const struct GNUNET_ATS_Information * atsi) | ||
249 | { | 276 | { |
250 | return NULL; | 277 | return NULL; |
251 | } | 278 | } |
@@ -264,8 +291,8 @@ mesh_inbound_tunnel_handler (void *cls, | |||
264 | * with the tunnel is stored | 291 | * with the tunnel is stored |
265 | */ | 292 | */ |
266 | void | 293 | void |
267 | mesh_tunnel_end_handler (void *cls, | 294 | mesh_tunnel_end_handler (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, |
268 | const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel_ctx) | 295 | void *tunnel_ctx) |
269 | { | 296 | { |
270 | 297 | ||
271 | } | 298 | } |
@@ -307,7 +334,7 @@ mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
307 | void * | 334 | void * |
308 | mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | 335 | mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
309 | { | 336 | { |
310 | struct PeerData *peer = (struct PeerData *)cls; | 337 | struct PeerData *peer = (struct PeerData *) cls; |
311 | 338 | ||
312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect adapter\n"); | 339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect adapter\n"); |
313 | 340 | ||
@@ -319,9 +346,9 @@ mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
319 | GNUNET_APPLICATION_TYPE_END | 346 | GNUNET_APPLICATION_TYPE_END |
320 | }; | 347 | }; |
321 | 348 | ||
322 | peer->mesh_handle = GNUNET_MESH_connect (cfg, cls, | 349 | peer->mesh_handle = |
323 | &mesh_inbound_tunnel_handler, | 350 | GNUNET_MESH_connect (cfg, cls, &mesh_inbound_tunnel_handler, |
324 | &mesh_tunnel_end_handler, handlers, apptypes); | 351 | &mesh_tunnel_end_handler, handlers, apptypes); |
325 | 352 | ||
326 | return NULL; | 353 | return NULL; |
327 | } | 354 | } |
@@ -369,7 +396,7 @@ peer_start_cb (void *cls, const char *emsg) | |||
369 | state[cnt] = LINKING_SLAVES; | 396 | state[cnt] = LINKING_SLAVES; |
370 | op[cnt] = | 397 | op[cnt] = |
371 | GNUNET_TESTBED_get_slave_config ((void *) (long) cnt, master_ctrl, | 398 | GNUNET_TESTBED_get_slave_config ((void *) (long) cnt, master_ctrl, |
372 | slave_hosts[cnt + 1]); | 399 | slaves[cnt + 1].host); |
373 | } | 400 | } |
374 | } | 401 | } |
375 | } | 402 | } |
@@ -425,8 +452,9 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
425 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Overlay Connected\n"); | 452 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Overlay Connected\n"); |
426 | for (i = 0; i < TOTAL_PEERS; i++) | 453 | for (i = 0; i < TOTAL_PEERS; i++) |
427 | { | 454 | { |
428 | GNUNET_TESTBED_service_connect (NULL, peers[i].peer, "mesh", &mesh_connect_cb, | 455 | GNUNET_TESTBED_service_connect (NULL, peers[i].peer, "mesh", |
429 | (void *) i, &mesh_ca, &mesh_da, NULL); | 456 | &mesh_connect_cb, (void *) i, &mesh_ca, |
457 | &mesh_da, NULL); | ||
430 | } | 458 | } |
431 | break; | 459 | break; |
432 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | 460 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: |
@@ -441,25 +469,31 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
441 | switch (state[i]) | 469 | switch (state[i]) |
442 | { | 470 | { |
443 | case INIT: | 471 | case INIT: |
472 | { | ||
444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Init: %u\n", i); | 473 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Init: %u\n", i); |
445 | GNUNET_TESTBED_operation_done (event->details. | 474 | GNUNET_TESTBED_operation_done (event->details. |
446 | operation_finished.operation); | 475 | operation_finished.operation); |
447 | op[i] = NULL; | 476 | op[i] = NULL; |
448 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | 477 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); |
449 | break; | 478 | break; |
479 | } | ||
450 | case LINKING: | 480 | case LINKING: |
451 | GNUNET_TESTBED_operation_done (event->details. | 481 | { |
452 | operation_finished.operation); | 482 | GNUNET_assert (NULL != slaves[i].op); |
453 | op[i] = NULL; | 483 | |
484 | GNUNET_TESTBED_operation_done (slaves[i].op); | ||
485 | slaves[i].op = NULL; | ||
486 | |||
454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | 487 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); |
455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linked host %i\n", i); | 488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linked host %i\n", i); |
456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating peer...\n"); | 489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating peer...\n"); |
457 | 490 | ||
458 | state[i] = CREATING_PEER; | 491 | state[i] = CREATING_PEER; |
459 | op[i] = | 492 | op[i] = |
460 | GNUNET_TESTBED_peer_create (master_ctrl, slave_hosts[i], cfg, | 493 | GNUNET_TESTBED_peer_create (master_ctrl, slaves[i].host, cfg, |
461 | peer_create_cb, (void *) i); | 494 | peer_create_cb, (void *) i); |
462 | break; | 495 | break; |
496 | } | ||
463 | case CREATING_PEER: | 497 | case CREATING_PEER: |
464 | { | 498 | { |
465 | GNUNET_TESTBED_operation_done (event->details. | 499 | GNUNET_TESTBED_operation_done (event->details. |
@@ -484,7 +518,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
484 | state[i] = LINKING_SLAVES_SUCCESS; | 518 | state[i] = LINKING_SLAVES_SUCCESS; |
485 | op[i] = | 519 | op[i] = |
486 | GNUNET_TESTBED_controller_link ((void *) (long) i, master_ctrl, | 520 | GNUNET_TESTBED_controller_link ((void *) (long) i, master_ctrl, |
487 | slave_hosts[i + 1], slave_hosts[i], | 521 | slaves[i + 1].host, slaves[i].host, |
488 | slave_cfg, GNUNET_NO); | 522 | slave_cfg, GNUNET_NO); |
489 | GNUNET_CONFIGURATION_destroy (slave_cfg); | 523 | GNUNET_CONFIGURATION_destroy (slave_cfg); |
490 | break; | 524 | break; |
@@ -506,7 +540,8 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
506 | peer_handles[peer_cnt] = peers[peer_cnt].peer; | 540 | peer_handles[peer_cnt] = peers[peer_cnt].peer; |
507 | } | 541 | } |
508 | op[0] = | 542 | op[0] = |
509 | GNUNET_TESTBED_overlay_configure_topology (NULL, TOTAL_PEERS, peer_handles, | 543 | GNUNET_TESTBED_overlay_configure_topology (NULL, TOTAL_PEERS, |
544 | peer_handles, | ||
510 | GNUNET_TESTBED_TOPOLOGY_LINE); | 545 | GNUNET_TESTBED_TOPOLOGY_LINE); |
511 | GNUNET_assert (NULL != op[0]); | 546 | GNUNET_assert (NULL != op[0]); |
512 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peers...\n"); | 547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peers...\n"); |
@@ -542,25 +577,31 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
542 | static void | 577 | static void |
543 | registration_cont (void *cls, const char *emsg) | 578 | registration_cont (void *cls, const char *emsg) |
544 | { | 579 | { |
545 | if (NULL != emsg) | 580 | struct Host *slave = (struct Host *) cls; |
581 | |||
582 | if (NULL != emsg || NULL == slave) | ||
546 | { | 583 | { |
547 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); | 584 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); |
548 | GNUNET_assert (0); | 585 | GNUNET_assert (0); |
549 | } | 586 | } |
587 | |||
550 | state[host_registered] = LINKING; | 588 | state[host_registered] = LINKING; |
589 | slave->state = LINKING; | ||
590 | |||
551 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking host %u\n", host_registered); | 591 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking host %u\n", host_registered); |
552 | op[host_registered] = | 592 | slave->op = |
553 | GNUNET_TESTBED_controller_link ((void *) (long) host_registered, | 593 | GNUNET_TESTBED_controller_link ((void *) (long) host_registered, |
554 | master_ctrl, slave_hosts[host_registered], | 594 | master_ctrl, slave->host, NULL, cfg, |
555 | NULL, cfg, GNUNET_YES); | 595 | GNUNET_YES); |
556 | host_registered++; | 596 | host_registered++; |
557 | if (NUM_HOSTS != host_registered) | 597 | if (NUM_HOSTS != host_registered) |
558 | { | 598 | { |
559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u\n", | 599 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u with ip %s\n", |
560 | host_registered); | 600 | host_registered, slaves[host_registered].ip); |
561 | rh = GNUNET_TESTBED_register_host (master_ctrl, | 601 | rh = GNUNET_TESTBED_register_host (master_ctrl, |
562 | slave_hosts[host_registered], | 602 | slaves[host_registered].host, |
563 | ®istration_cont, NULL); | 603 | ®istration_cont, |
604 | &slaves[host_registered]); | ||
564 | return; | 605 | return; |
565 | } | 606 | } |
566 | } | 607 | } |
@@ -600,15 +641,16 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, | |||
600 | 641 | ||
601 | for (i = 0; i < NUM_HOSTS; i++) | 642 | for (i = 0; i < NUM_HOSTS; i++) |
602 | { | 643 | { |
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating host %u\n", i); | 644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating host %u with ip %s\n", i, |
604 | slave_hosts[i] = GNUNET_TESTBED_host_create (slave_ips[i], NULL, 0); | 645 | slaves[i].ip); |
605 | GNUNET_assert (NULL != slave_hosts[i]); | 646 | slaves[i].host = GNUNET_TESTBED_host_create (slaves[i].ip, NULL, 0); |
647 | GNUNET_assert (NULL != slaves[i].host); | ||
606 | } | 648 | } |
607 | host_registered = 0; | 649 | host_registered = 0; |
608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u\n", | 650 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u with ip %s\n", |
609 | host_registered); | 651 | host_registered, slaves[0].ip); |
610 | rh = GNUNET_TESTBED_register_host (master_ctrl, slave_hosts[0], | 652 | rh = GNUNET_TESTBED_register_host (master_ctrl, slaves[0].host, |
611 | ®istration_cont, NULL); | 653 | ®istration_cont, &slaves[0]); |
612 | GNUNET_assert (NULL != rh); | 654 | GNUNET_assert (NULL != rh); |
613 | } | 655 | } |
614 | 656 | ||
@@ -668,7 +710,7 @@ main (int argc, char **argv) | |||
668 | for (i = 0; i < NUM_HOSTS; i++) | 710 | for (i = 0; i < NUM_HOSTS; i++) |
669 | { | 711 | { |
670 | char *const remote_args[] = { | 712 | char *const remote_args[] = { |
671 | "ssh", "-o", "BatchMode=yes", slave_ips[i], | 713 | "ssh", "-o", "BatchMode=yes", slaves[i].ip, |
672 | "gnunet-helper-testbed --help > /dev/null", NULL | 714 | "gnunet-helper-testbed --help > /dev/null", NULL |
673 | }; | 715 | }; |
674 | struct GNUNET_OS_Process *auxp; | 716 | struct GNUNET_OS_Process *auxp; |
@@ -693,7 +735,7 @@ main (int argc, char **argv) | |||
693 | { | 735 | { |
694 | fprintf (stderr, | 736 | fprintf (stderr, |
695 | "Unable to run the test as this system is not configured " | 737 | "Unable to run the test as this system is not configured " |
696 | "to use password less SSH logins to host %s.\n", slave_ips[i]); | 738 | "to use password less SSH logins to host %s.\n", slaves[i].ip); |
697 | test_hosts = GNUNET_SYSERR; | 739 | test_hosts = GNUNET_SYSERR; |
698 | } | 740 | } |
699 | } | 741 | } |
@@ -708,7 +750,8 @@ main (int argc, char **argv) | |||
708 | 750 | ||
709 | ret = | 751 | ret = |
710 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 752 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
711 | "gnunet-regex-profiler", "nohelp", options, &run, NULL); | 753 | "gnunet-regex-profiler", "nohelp", options, &run, |
754 | NULL); | ||
712 | 755 | ||
713 | fprintf (stderr, "END.\n"); | 756 | fprintf (stderr, "END.\n"); |
714 | 757 | ||