diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-25 15:28:08 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-25 15:28:08 +0000 |
commit | 30c5c323f28ade8a1e7c6c593778793e44accb3a (patch) | |
tree | 845955ec895d221338b44f0cadce7932932e78cc /src/testbed/gnunet-service-testbed_oc.c | |
parent | 43d558efd13a3245e65efd0acdc9c4ba59cd2bee (diff) | |
download | gnunet-30c5c323f28ade8a1e7c6c593778793e44accb3a.tar.gz gnunet-30c5c323f28ade8a1e7c6c593778793e44accb3a.zip |
- indent
Diffstat (limited to 'src/testbed/gnunet-service-testbed_oc.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_oc.c | 358 |
1 files changed, 180 insertions, 178 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index f5811194b..000e670b6 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -80,7 +80,7 @@ struct OverlayConnectContext | |||
80 | * The prev pointer for maintaining a DLL | 80 | * The prev pointer for maintaining a DLL |
81 | */ | 81 | */ |
82 | struct OverlayConnectContext *prev; | 82 | struct OverlayConnectContext *prev; |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * The client which has requested for overlay connection | 85 | * The client which has requested for overlay connection |
86 | */ | 86 | */ |
@@ -202,7 +202,7 @@ struct RequestOverlayConnectContext | |||
202 | * The peer handle of peer B | 202 | * The peer handle of peer B |
203 | */ | 203 | */ |
204 | struct Peer *peer; | 204 | struct Peer *peer; |
205 | 205 | ||
206 | /** | 206 | /** |
207 | * Peer A's HELLO | 207 | * Peer A's HELLO |
208 | */ | 208 | */ |
@@ -227,12 +227,12 @@ struct RequestOverlayConnectContext | |||
227 | * Task for offering HELLO of A to B and doing try_connect | 227 | * Task for offering HELLO of A to B and doing try_connect |
228 | */ | 228 | */ |
229 | GNUNET_SCHEDULER_TaskIdentifier attempt_connect_task_id; | 229 | GNUNET_SCHEDULER_TaskIdentifier attempt_connect_task_id; |
230 | 230 | ||
231 | /** | 231 | /** |
232 | * Task to timeout RequestOverlayConnect | 232 | * Task to timeout RequestOverlayConnect |
233 | */ | 233 | */ |
234 | GNUNET_SCHEDULER_TaskIdentifier timeout_rocc_task_id; | 234 | GNUNET_SCHEDULER_TaskIdentifier timeout_rocc_task_id; |
235 | 235 | ||
236 | /** | 236 | /** |
237 | * The id of the operation responsible for creating this context | 237 | * The id of the operation responsible for creating this context |
238 | */ | 238 | */ |
@@ -289,13 +289,13 @@ forwarded_overlay_connect_timeout (void *cls, | |||
289 | struct ForwardedOperationContext *fopc = cls; | 289 | struct ForwardedOperationContext *fopc = cls; |
290 | struct RegisteredHostContext *rhc; | 290 | struct RegisteredHostContext *rhc; |
291 | struct ForwardedOverlayConnectContext *focc; | 291 | struct ForwardedOverlayConnectContext *focc; |
292 | 292 | ||
293 | rhc = fopc->cls; | 293 | rhc = fopc->cls; |
294 | focc = rhc->focc_dll_head; | 294 | focc = rhc->focc_dll_head; |
295 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc); | 295 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc); |
296 | GST_cleanup_focc (focc); | 296 | GST_cleanup_focc (focc); |
297 | LOG_DEBUG ("Overlay linking between peers %u and %u failed\n", | 297 | LOG_DEBUG ("Overlay linking between peers %u and %u failed\n", focc->peer1, |
298 | focc->peer1, focc->peer2); | 298 | focc->peer2); |
299 | GST_forwarded_operation_timeout (cls, tc); | 299 | GST_forwarded_operation_timeout (cls, tc); |
300 | if (NULL != rhc->focc_dll_head) | 300 | if (NULL != rhc->focc_dll_head) |
301 | GST_process_next_focc (rhc); | 301 | GST_process_next_focc (rhc); |
@@ -317,7 +317,7 @@ forwarded_overlay_connect_listener (void *cls, | |||
317 | struct ForwardedOperationContext *fopc = cls; | 317 | struct ForwardedOperationContext *fopc = cls; |
318 | struct RegisteredHostContext *rhc; | 318 | struct RegisteredHostContext *rhc; |
319 | struct ForwardedOverlayConnectContext *focc; | 319 | struct ForwardedOverlayConnectContext *focc; |
320 | 320 | ||
321 | rhc = fopc->cls; | 321 | rhc = fopc->cls; |
322 | GST_forwarded_operation_reply_relay (cls, msg); | 322 | GST_forwarded_operation_reply_relay (cls, msg); |
323 | focc = rhc->focc_dll_head; | 323 | focc = rhc->focc_dll_head; |
@@ -344,7 +344,7 @@ GST_process_next_focc (struct RegisteredHostContext *rhc) | |||
344 | GNUNET_assert (RHC_OL_CONNECT == rhc->state); | 344 | GNUNET_assert (RHC_OL_CONNECT == rhc->state); |
345 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 345 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); |
346 | GNUNET_SERVER_client_keep (rhc->client); | 346 | GNUNET_SERVER_client_keep (rhc->client); |
347 | fopc->client = rhc->client; | 347 | fopc->client = rhc->client; |
348 | fopc->operation_id = focc->operation_id; | 348 | fopc->operation_id = focc->operation_id; |
349 | fopc->cls = rhc; | 349 | fopc->cls = rhc; |
350 | fopc->type = OP_OVERLAY_CONNECT; | 350 | fopc->type = OP_OVERLAY_CONNECT; |
@@ -405,13 +405,13 @@ cleanup_occ (struct OverlayConnectContext *occ) | |||
405 | GNUNET_TRANSPORT_disconnect (occ->tcc.th); | 405 | GNUNET_TRANSPORT_disconnect (occ->tcc.th); |
406 | GST_peer_list[occ->other_peer_id]->reference_cnt--; | 406 | GST_peer_list[occ->other_peer_id]->reference_cnt--; |
407 | } | 407 | } |
408 | if ((GNUNET_YES == occ->peer->destroy_flag) | 408 | if ((GNUNET_YES == occ->peer->destroy_flag) && |
409 | && (0 == occ->peer->reference_cnt)) | 409 | (0 == occ->peer->reference_cnt)) |
410 | GST_destroy_peer (occ->peer); | 410 | GST_destroy_peer (occ->peer); |
411 | if ((NULL == occ->peer2_controller) | 411 | if ((NULL == occ->peer2_controller) && |
412 | && (GNUNET_YES == GST_peer_list[occ->other_peer_id]->destroy_flag) | 412 | (GNUNET_YES == GST_peer_list[occ->other_peer_id]->destroy_flag) && |
413 | && (0 == GST_peer_list[occ->other_peer_id]->reference_cnt)) | 413 | (0 == GST_peer_list[occ->other_peer_id]->reference_cnt)) |
414 | GST_destroy_peer (GST_peer_list[occ->other_peer_id]); | 414 | GST_destroy_peer (GST_peer_list[occ->other_peer_id]); |
415 | GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ); | 415 | GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ); |
416 | GNUNET_free (occ); | 416 | GNUNET_free (occ); |
417 | } | 417 | } |
@@ -427,7 +427,7 @@ static void | |||
427 | do_cleanup_occ (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 427 | do_cleanup_occ (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
428 | { | 428 | { |
429 | struct OverlayConnectContext *occ = cls; | 429 | struct OverlayConnectContext *occ = cls; |
430 | 430 | ||
431 | occ->cleanup_task = GNUNET_SCHEDULER_NO_TASK; | 431 | occ->cleanup_task = GNUNET_SCHEDULER_NO_TASK; |
432 | cleanup_occ (occ); | 432 | cleanup_occ (occ); |
433 | } | 433 | } |
@@ -447,8 +447,8 @@ timeout_overlay_connect (void *cls, | |||
447 | 447 | ||
448 | occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 448 | occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
449 | LOG (GNUNET_ERROR_TYPE_WARNING, | 449 | LOG (GNUNET_ERROR_TYPE_WARNING, |
450 | "0x%llx: Timeout while connecting peers %u and %u\n", | 450 | "0x%llx: Timeout while connecting peers %u and %u\n", occ->op_id, |
451 | occ->op_id, occ->peer_id, occ->other_peer_id); | 451 | occ->peer_id, occ->other_peer_id); |
452 | GST_send_operation_fail_msg (occ->client, occ->op_id, occ->emsg); | 452 | GST_send_operation_fail_msg (occ->client, occ->op_id, occ->emsg); |
453 | cleanup_occ (occ); | 453 | cleanup_occ (occ); |
454 | } | 454 | } |
@@ -485,7 +485,7 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | |||
485 | sizeof (struct GNUNET_PeerIdentity))) | 485 | sizeof (struct GNUNET_PeerIdentity))) |
486 | { | 486 | { |
487 | /* LOG_DEBUG ("Unexpected peer %4s connected when expecting peer %4s\n", */ | 487 | /* LOG_DEBUG ("Unexpected peer %4s connected when expecting peer %4s\n", */ |
488 | /* new_peer_str, other_peer_str); */ | 488 | /* new_peer_str, other_peer_str); */ |
489 | GNUNET_free (new_peer_str); | 489 | GNUNET_free (new_peer_str); |
490 | GNUNET_free (other_peer_str); | 490 | GNUNET_free (other_peer_str); |
491 | return; | 491 | return; |
@@ -542,17 +542,18 @@ try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
542 | * @param result GNUNET_OK if message was transmitted to transport service | 542 | * @param result GNUNET_OK if message was transmitted to transport service |
543 | * GNUNET_SYSERR if message was not transmitted to transport service | 543 | * GNUNET_SYSERR if message was not transmitted to transport service |
544 | */ | 544 | */ |
545 | static void | 545 | static void |
546 | try_connect_cb (void *cls, const int result) | 546 | try_connect_cb (void *cls, const int result) |
547 | { | 547 | { |
548 | struct TryConnectContext *tcc = cls; | 548 | struct TryConnectContext *tcc = cls; |
549 | 549 | ||
550 | tcc->tch = NULL; | 550 | tcc->tch = NULL; |
551 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tcc->task); | 551 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tcc->task); |
552 | tcc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 552 | tcc->task = |
553 | (GNUNET_TIME_UNIT_MILLISECONDS, | 553 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
554 | 500 + pow(2, ++tcc->retries)), | 554 | (GNUNET_TIME_UNIT_MILLISECONDS, |
555 | &try_connect_task, tcc); | 555 | 500 + pow (2, ++tcc->retries)), |
556 | &try_connect_task, tcc); | ||
556 | } | 557 | } |
557 | 558 | ||
558 | 559 | ||
@@ -569,13 +570,14 @@ try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
569 | 570 | ||
570 | tcc->task = GNUNET_SCHEDULER_NO_TASK; | 571 | tcc->task = GNUNET_SCHEDULER_NO_TASK; |
571 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 572 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) |
572 | return; | 573 | return; |
573 | GNUNET_assert (NULL == tcc->tch); | 574 | GNUNET_assert (NULL == tcc->tch); |
574 | GNUNET_assert (NULL != tcc->pid); | 575 | GNUNET_assert (NULL != tcc->pid); |
575 | GNUNET_assert (NULL != tcc->th); | 576 | GNUNET_assert (NULL != tcc->th); |
576 | LOG_DEBUG ("0x%llx: Trail %u to connect to peer %s\n", tcc->op_id, tcc->retries, | 577 | LOG_DEBUG ("0x%llx: Trail %u to connect to peer %s\n", tcc->op_id, |
577 | GNUNET_i2s(tcc->pid)); | 578 | tcc->retries, GNUNET_i2s (tcc->pid)); |
578 | tcc->tch = GNUNET_TRANSPORT_try_connect (tcc->th, tcc->pid, &try_connect_cb, tcc); | 579 | tcc->tch = |
580 | GNUNET_TRANSPORT_try_connect (tcc->th, tcc->pid, &try_connect_cb, tcc); | ||
579 | } | 581 | } |
580 | 582 | ||
581 | 583 | ||
@@ -617,9 +619,8 @@ occ_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
617 | if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) | 619 | if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) |
618 | return; | 620 | return; |
619 | GNUNET_free_non_null (occ->emsg); | 621 | GNUNET_free_non_null (occ->emsg); |
620 | GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while try connect", | 622 | GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while try connect", occ->op_id); |
621 | occ->op_id); | 623 | occ->tcc.pid = &occ->peer_identity; |
622 | occ->tcc.pid = &occ->peer_identity; | ||
623 | occ->tcc.op_id = occ->op_id; | 624 | occ->tcc.op_id = occ->op_id; |
624 | occ->tcc.task = GNUNET_SCHEDULER_add_now (&try_connect_task, &occ->tcc); | 625 | occ->tcc.task = GNUNET_SCHEDULER_add_now (&try_connect_task, &occ->tcc); |
625 | } | 626 | } |
@@ -650,11 +651,9 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
650 | uint16_t hello_size; | 651 | uint16_t hello_size; |
651 | 652 | ||
652 | LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote " | 653 | LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote " |
653 | "Overlay Request\n", | 654 | "Overlay Request\n", occ->op_id, |
654 | occ->op_id, | 655 | GNUNET_i2s (&occ->peer_identity), ntohs (occ->hello->size), |
655 | GNUNET_i2s (&occ->peer_identity), | 656 | other_peer_str); |
656 | ntohs (occ->hello->size), | ||
657 | other_peer_str); | ||
658 | hello_size = ntohs (occ->hello->size); | 657 | hello_size = ntohs (occ->hello->size); |
659 | msize = sizeof (struct GNUNET_TESTBED_RequestConnectMessage) + hello_size; | 658 | msize = sizeof (struct GNUNET_TESTBED_RequestConnectMessage) + hello_size; |
660 | msg = GNUNET_malloc (msize); | 659 | msg = GNUNET_malloc (msize); |
@@ -663,31 +662,30 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
663 | msg->peer = htonl (occ->other_peer_id); | 662 | msg->peer = htonl (occ->other_peer_id); |
664 | msg->operation_id = GNUNET_htonll (occ->op_id); | 663 | msg->operation_id = GNUNET_htonll (occ->op_id); |
665 | (void) memcpy (&msg->peer_identity, &occ->peer_identity, | 664 | (void) memcpy (&msg->peer_identity, &occ->peer_identity, |
666 | sizeof (struct GNUNET_PeerIdentity)); | 665 | sizeof (struct GNUNET_PeerIdentity)); |
667 | memcpy (msg->hello, occ->hello, hello_size); | 666 | memcpy (msg->hello, occ->hello, hello_size); |
668 | GNUNET_TESTBED_queue_message_ (occ->peer2_controller, &msg->header); | 667 | GNUNET_TESTBED_queue_message_ (occ->peer2_controller, &msg->header); |
669 | } | 668 | } |
670 | else | 669 | else |
671 | { | 670 | { |
672 | LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n", | 671 | LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n", occ->op_id, |
673 | occ->op_id, | 672 | GNUNET_i2s (&occ->peer_identity), other_peer_str); |
674 | GNUNET_i2s (&occ->peer_identity), other_peer_str); | 673 | occ->ohh = |
675 | occ->ohh = GNUNET_TRANSPORT_offer_hello (occ->tcc.th, | 674 | GNUNET_TRANSPORT_offer_hello (occ->tcc.th, occ->hello, |
676 | occ->hello, | 675 | occ_hello_sent_cb, occ); |
677 | occ_hello_sent_cb, | ||
678 | occ); | ||
679 | if (NULL == occ->ohh) | 676 | if (NULL == occ->ohh) |
680 | { | 677 | { |
681 | GNUNET_break (0); | 678 | GNUNET_break (0); |
682 | occ->send_hello_task = | 679 | occ->send_hello_task = |
683 | GNUNET_SCHEDULER_add_delayed | 680 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
684 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 681 | (GNUNET_TIME_UNIT_MILLISECONDS, |
685 | 100 + GNUNET_CRYPTO_random_u32 | 682 | 100 + |
686 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), | 683 | GNUNET_CRYPTO_random_u32 |
687 | &send_hello, occ); | 684 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), |
685 | &send_hello, occ); | ||
688 | } | 686 | } |
689 | } | 687 | } |
690 | GNUNET_free (other_peer_str); | 688 | GNUNET_free (other_peer_str); |
691 | } | 689 | } |
692 | 690 | ||
693 | 691 | ||
@@ -708,15 +706,16 @@ p2_transport_connect (struct OverlayConnectContext *occ) | |||
708 | { | 706 | { |
709 | GST_peer_list[occ->other_peer_id]->reference_cnt++; | 707 | GST_peer_list[occ->other_peer_id]->reference_cnt++; |
710 | occ->tcc.th = | 708 | occ->tcc.th = |
711 | GNUNET_TRANSPORT_connect (GST_peer_list[occ->other_peer_id]->details.local.cfg, | 709 | GNUNET_TRANSPORT_connect (GST_peer_list[occ->other_peer_id]-> |
712 | &occ->other_peer_identity, NULL, NULL, NULL, | 710 | details.local.cfg, &occ->other_peer_identity, |
713 | NULL); | 711 | NULL, NULL, NULL, NULL); |
714 | if (NULL == occ->tcc.th) | 712 | if (NULL == occ->tcc.th) |
715 | { | 713 | { |
716 | GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s", | 714 | GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s", |
717 | occ->op_id, GNUNET_i2s (&occ->other_peer_identity)); | 715 | occ->op_id, GNUNET_i2s (&occ->other_peer_identity)); |
718 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 716 | GNUNET_SCHEDULER_cancel (occ->timeout_task); |
719 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 717 | occ->timeout_task = |
718 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | ||
720 | return; | 719 | return; |
721 | } | 720 | } |
722 | } | 721 | } |
@@ -767,12 +766,12 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) | |||
767 | &empty); | 766 | &empty); |
768 | if (GNUNET_YES == empty) | 767 | if (GNUNET_YES == empty) |
769 | { | 768 | { |
770 | LOG_DEBUG ("0x%llx: HELLO of %s is empty\n", | 769 | LOG_DEBUG ("0x%llx: HELLO of %s is empty\n", occ->op_id, |
771 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); | 770 | GNUNET_i2s (&occ->peer_identity)); |
772 | return; | 771 | return; |
773 | } | 772 | } |
774 | LOG_DEBUG ("0x%llx: Received HELLO of %s\n", | 773 | LOG_DEBUG ("0x%llx: Received HELLO of %s\n", occ->op_id, |
775 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); | 774 | GNUNET_i2s (&occ->peer_identity)); |
776 | occ->hello = GNUNET_malloc (msize); | 775 | occ->hello = GNUNET_malloc (msize); |
777 | GST_hello_cache_add (&occ->peer_identity, hello); | 776 | GST_hello_cache_add (&occ->peer_identity, hello); |
778 | memcpy (occ->hello, hello, msize); | 777 | memcpy (occ->hello, hello, msize); |
@@ -816,13 +815,13 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, | |||
816 | occ->emsg = NULL; | 815 | occ->emsg = NULL; |
817 | memcpy (&occ->peer_identity, my_identity, | 816 | memcpy (&occ->peer_identity, my_identity, |
818 | sizeof (struct GNUNET_PeerIdentity)); | 817 | sizeof (struct GNUNET_PeerIdentity)); |
819 | LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", | 818 | LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id, |
820 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); | 819 | GNUNET_i2s (&occ->peer_identity)); |
821 | /* Lookup for HELLO in hello cache */ | 820 | /* Lookup for HELLO in hello cache */ |
822 | if (NULL != (hello = GST_hello_cache_lookup (&occ->peer_identity))) | 821 | if (NULL != (hello = GST_hello_cache_lookup (&occ->peer_identity))) |
823 | { | 822 | { |
824 | LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", | 823 | LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", occ->op_id, |
825 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); | 824 | GNUNET_i2s (&occ->peer_identity)); |
826 | occ->hello = GNUNET_copy_message (hello); | 825 | occ->hello = GNUNET_copy_message (hello); |
827 | p2_transport_connect (occ); | 826 | p2_transport_connect (occ); |
828 | return; | 827 | return; |
@@ -837,14 +836,14 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, | |||
837 | "0x%llx: Cannot connect to TRANSPORT of peer %4s", | 836 | "0x%llx: Cannot connect to TRANSPORT of peer %4s", |
838 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); | 837 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); |
839 | goto error_return; | 838 | goto error_return; |
840 | } | 839 | } |
841 | GNUNET_asprintf (&occ->emsg, | 840 | GNUNET_asprintf (&occ->emsg, |
842 | "0x%llx: Timeout while acquiring HELLO of peer %4s", | 841 | "0x%llx: Timeout while acquiring HELLO of peer %4s", |
843 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); | 842 | occ->op_id, GNUNET_i2s (&occ->peer_identity)); |
844 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ); | 843 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ); |
845 | return; | 844 | return; |
846 | 845 | ||
847 | error_return: | 846 | error_return: |
848 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 847 | GNUNET_SCHEDULER_cancel (occ->timeout_task); |
849 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 848 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); |
850 | return; | 849 | return; |
@@ -864,6 +863,7 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg) | |||
864 | { | 863 | { |
865 | struct OverlayConnectContext *occ = cls; | 864 | struct OverlayConnectContext *occ = cls; |
866 | const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg; | 865 | const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg; |
866 | |||
867 | const struct GNUNET_CORE_MessageHandler no_handlers[] = { | 867 | const struct GNUNET_CORE_MessageHandler no_handlers[] = { |
868 | {NULL, 0, 0} | 868 | {NULL, 0, 0} |
869 | }; | 869 | }; |
@@ -871,10 +871,10 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg) | |||
871 | occ->opc = NULL; | 871 | occ->opc = NULL; |
872 | if (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG != ntohs (msg->type)) | 872 | if (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG != ntohs (msg->type)) |
873 | goto error_return; | 873 | goto error_return; |
874 | cmsg = (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) | 874 | cmsg = |
875 | msg; | 875 | (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg; |
876 | memcpy (&occ->other_peer_identity, &cmsg->peer_identity, | 876 | memcpy (&occ->other_peer_identity, &cmsg->peer_identity, |
877 | sizeof (struct GNUNET_PeerIdentity)); | 877 | sizeof (struct GNUNET_PeerIdentity)); |
878 | GNUNET_free_non_null (occ->emsg); | 878 | GNUNET_free_non_null (occ->emsg); |
879 | GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while connecting to CORE", | 879 | GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while connecting to CORE", |
880 | occ->op_id); | 880 | occ->op_id); |
@@ -887,10 +887,9 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg) | |||
887 | goto error_return; | 887 | goto error_return; |
888 | return; | 888 | return; |
889 | 889 | ||
890 | error_return: | 890 | error_return: |
891 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 891 | GNUNET_SCHEDULER_cancel (occ->timeout_task); |
892 | occ->timeout_task = | 892 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); |
893 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | ||
894 | } | 893 | } |
895 | 894 | ||
896 | 895 | ||
@@ -900,7 +899,7 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg) | |||
900 | * @param cls the RegisteredHostContext | 899 | * @param cls the RegisteredHostContext |
901 | * @param emsg the error message; NULL if host registration is successful | 900 | * @param emsg the error message; NULL if host registration is successful |
902 | */ | 901 | */ |
903 | static void | 902 | static void |
904 | registeredhost_registration_completion (void *cls, const char *emsg) | 903 | registeredhost_registration_completion (void *cls, const char *emsg) |
905 | { | 904 | { |
906 | struct RegisteredHostContext *rhc = cls; | 905 | struct RegisteredHostContext *rhc = cls; |
@@ -912,25 +911,23 @@ registeredhost_registration_completion (void *cls, const char *emsg) | |||
912 | peer2_host_id = GNUNET_TESTBED_host_get_id_ (rhc->reg_host); | 911 | peer2_host_id = GNUNET_TESTBED_host_get_id_ (rhc->reg_host); |
913 | GNUNET_assert (RHC_INIT == rhc->state); | 912 | GNUNET_assert (RHC_INIT == rhc->state); |
914 | GNUNET_assert (NULL == rhc->sub_op); | 913 | GNUNET_assert (NULL == rhc->sub_op); |
915 | if ((NULL == rhc->gateway2) | 914 | if ((NULL == rhc->gateway2) || ((peer2_host_id < GST_slave_list_size) /* Check if we have the needed config */ |
916 | || ((peer2_host_id < GST_slave_list_size) /* Check if we have the needed config */ | 915 | && (NULL != GST_slave_list[peer2_host_id]))) |
917 | && (NULL != GST_slave_list[peer2_host_id]))) | ||
918 | { | 916 | { |
919 | rhc->state = RHC_LINK; | 917 | rhc->state = RHC_LINK; |
920 | cfg = (NULL == rhc->gateway2) ? our_config : GST_slave_list[peer2_host_id]->cfg; | 918 | cfg = |
919 | (NULL == | ||
920 | rhc->gateway2) ? our_config : GST_slave_list[peer2_host_id]->cfg; | ||
921 | rhc->sub_op = | 921 | rhc->sub_op = |
922 | GNUNET_TESTBED_controller_link (rhc, | 922 | GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller, |
923 | rhc->gateway->controller, | 923 | rhc->reg_host, rhc->host, cfg, |
924 | rhc->reg_host, | ||
925 | rhc->host, | ||
926 | cfg, | ||
927 | GNUNET_NO); | 924 | GNUNET_NO); |
928 | return; | 925 | return; |
929 | } | 926 | } |
930 | rhc->state = RHC_GET_CFG; | 927 | rhc->state = RHC_GET_CFG; |
931 | rhc->sub_op = GNUNET_TESTBED_get_slave_config (rhc, | 928 | rhc->sub_op = |
932 | rhc->gateway2->controller, | 929 | GNUNET_TESTBED_get_slave_config (rhc, rhc->gateway2->controller, |
933 | rhc->reg_host); | 930 | rhc->reg_host); |
934 | } | 931 | } |
935 | 932 | ||
936 | 933 | ||
@@ -944,9 +941,8 @@ registeredhost_registration_completion (void *cls, const char *emsg) | |||
944 | * iterate, | 941 | * iterate, |
945 | * GNUNET_NO if not. | 942 | * GNUNET_NO if not. |
946 | */ | 943 | */ |
947 | static int | 944 | static int |
948 | reghost_match_iterator (void *cls, | 945 | reghost_match_iterator (void *cls, const struct GNUNET_HashCode *key, |
949 | const struct GNUNET_HashCode * key, | ||
950 | void *value) | 946 | void *value) |
951 | { | 947 | { |
952 | struct RegisteredHostContext **rh = cls; | 948 | struct RegisteredHostContext **rh = cls; |
@@ -992,9 +988,10 @@ hash_hosts (struct GNUNET_TESTBED_Host *reg_host, | |||
992 | */ | 988 | */ |
993 | void | 989 | void |
994 | GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | 990 | GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, |
995 | const struct GNUNET_MessageHeader *message) | 991 | const struct GNUNET_MessageHeader *message) |
996 | { | 992 | { |
997 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg; | 993 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg; |
994 | |||
998 | const struct GNUNET_CORE_MessageHandler no_handlers[] = { | 995 | const struct GNUNET_CORE_MessageHandler no_handlers[] = { |
999 | {NULL, 0, 0} | 996 | {NULL, 0, 0} |
1000 | }; | 997 | }; |
@@ -1003,11 +1000,11 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1003 | struct GNUNET_TESTBED_Controller *peer2_controller; | 1000 | struct GNUNET_TESTBED_Controller *peer2_controller; |
1004 | uint64_t operation_id; | 1001 | uint64_t operation_id; |
1005 | uint32_t p1; | 1002 | uint32_t p1; |
1006 | uint32_t p2; | 1003 | uint32_t p2; |
1007 | uint32_t peer2_host_id; | 1004 | uint32_t peer2_host_id; |
1008 | 1005 | ||
1009 | if (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage) | 1006 | if (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage) != |
1010 | != ntohs (message->size)) | 1007 | ntohs (message->size)) |
1011 | { | 1008 | { |
1012 | GNUNET_break (0); | 1009 | GNUNET_break (0); |
1013 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1010 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -1024,9 +1021,10 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1024 | } | 1021 | } |
1025 | peer = GST_peer_list[p1]; | 1022 | peer = GST_peer_list[p1]; |
1026 | peer2_host_id = ntohl (msg->peer2_host_id); | 1023 | peer2_host_id = ntohl (msg->peer2_host_id); |
1027 | operation_id = GNUNET_ntohll (msg->operation_id); | 1024 | operation_id = GNUNET_ntohll (msg->operation_id); |
1028 | LOG_DEBUG ("Received overlay connect for peers %u and %u with op id: 0x%llx\n", | 1025 | LOG_DEBUG |
1029 | p1, p2, operation_id); | 1026 | ("Received overlay connect for peers %u and %u with op id: 0x%llx\n", p1, |
1027 | p2, operation_id); | ||
1030 | if (GNUNET_YES == peer->is_remote) | 1028 | if (GNUNET_YES == peer->is_remote) |
1031 | { | 1029 | { |
1032 | struct ForwardedOperationContext *fopc; | 1030 | struct ForwardedOperationContext *fopc; |
@@ -1037,20 +1035,20 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1037 | route_to_peer2_host = NULL; | 1035 | route_to_peer2_host = NULL; |
1038 | route_to_peer1_host = NULL; | 1036 | route_to_peer1_host = NULL; |
1039 | route_to_peer2_host = GST_find_dest_route (peer2_host_id); | 1037 | route_to_peer2_host = GST_find_dest_route (peer2_host_id); |
1040 | if ((NULL != route_to_peer2_host) | 1038 | if ((NULL != route_to_peer2_host) || |
1041 | || (peer2_host_id == GST_context->host_id)) | 1039 | (peer2_host_id == GST_context->host_id)) |
1042 | { | 1040 | { |
1043 | /* Peer 2 either below us OR with us */ | 1041 | /* Peer 2 either below us OR with us */ |
1044 | route_to_peer1_host = | 1042 | route_to_peer1_host = |
1045 | GST_find_dest_route | 1043 | GST_find_dest_route (GST_peer_list[p1]->details. |
1046 | (GST_peer_list[p1]->details.remote.remote_host_id); | 1044 | remote.remote_host_id); |
1047 | /* Because we get this message only if we know where peer 1 is */ | 1045 | /* Because we get this message only if we know where peer 1 is */ |
1048 | GNUNET_assert (NULL != route_to_peer1_host); | 1046 | GNUNET_assert (NULL != route_to_peer1_host); |
1049 | if ((peer2_host_id == GST_context->host_id) | 1047 | if ((peer2_host_id == GST_context->host_id) || |
1050 | || (route_to_peer2_host->dest != route_to_peer1_host->dest)) | 1048 | (route_to_peer2_host->dest != route_to_peer1_host->dest)) |
1051 | { | 1049 | { |
1052 | /* Peer2 is either with us OR peer1 and peer2 can be reached through | 1050 | /* Peer2 is either with us OR peer1 and peer2 can be reached through |
1053 | different gateways */ | 1051 | * different gateways */ |
1054 | struct GNUNET_HashCode hash; | 1052 | struct GNUNET_HashCode hash; |
1055 | struct RegisteredHostContext *rhc; | 1053 | struct RegisteredHostContext *rhc; |
1056 | int skip_focc; | 1054 | int skip_focc; |
@@ -1064,36 +1062,42 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1064 | GNUNET_assert (NULL != rhc->reg_host); | 1062 | GNUNET_assert (NULL != rhc->reg_host); |
1065 | GNUNET_assert (NULL != rhc->host); | 1063 | GNUNET_assert (NULL != rhc->host); |
1066 | rhc->gateway = peer->details.remote.slave; | 1064 | rhc->gateway = peer->details.remote.slave; |
1067 | rhc->gateway2 = (NULL == route_to_peer2_host) ? NULL : | 1065 | rhc->gateway2 = |
1066 | (NULL == | ||
1067 | route_to_peer2_host) ? NULL : | ||
1068 | GST_slave_list[route_to_peer2_host->dest]; | 1068 | GST_slave_list[route_to_peer2_host->dest]; |
1069 | rhc->state = RHC_INIT; | 1069 | rhc->state = RHC_INIT; |
1070 | GNUNET_SERVER_client_keep (client); | 1070 | GNUNET_SERVER_client_keep (client); |
1071 | rhc->client = client; | 1071 | rhc->client = client; |
1072 | hash = hash_hosts (rhc->reg_host, rhc->host); | 1072 | hash = hash_hosts (rhc->reg_host, rhc->host); |
1073 | skip_focc = GNUNET_NO; | 1073 | skip_focc = GNUNET_NO; |
1074 | if ((GNUNET_NO == | 1074 | if ((GNUNET_NO == |
1075 | GNUNET_CONTAINER_multihashmap_contains | 1075 | GNUNET_CONTAINER_multihashmap_contains (peer->details. |
1076 | (peer->details.remote.slave->reghost_map, &hash)) | 1076 | remote.slave->reghost_map, |
1077 | || (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple | 1077 | &hash)) || |
1078 | (peer->details.remote.slave->reghost_map, &hash, | 1078 | (GNUNET_SYSERR != |
1079 | reghost_match_iterator, &rhc))) | 1079 | GNUNET_CONTAINER_multihashmap_get_multiple (peer->details.remote. |
1080 | slave->reghost_map, | ||
1081 | &hash, | ||
1082 | reghost_match_iterator, | ||
1083 | &rhc))) | ||
1080 | { | 1084 | { |
1081 | /* create and add a new registerd host context */ | 1085 | /* create and add a new registerd host context */ |
1082 | /* add the focc to its queue */ | 1086 | /* add the focc to its queue */ |
1083 | GNUNET_CONTAINER_multihashmap_put | 1087 | GNUNET_CONTAINER_multihashmap_put (peer->details.remote. |
1084 | (peer->details.remote.slave->reghost_map, | 1088 | slave->reghost_map, &hash, rhc, |
1085 | &hash, rhc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1089 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1086 | GNUNET_assert (NULL != GST_host_list[peer2_host_id]); | 1090 | GNUNET_assert (NULL != GST_host_list[peer2_host_id]); |
1087 | GST_queue_host_registration (peer->details.remote.slave, | 1091 | GST_queue_host_registration (peer->details.remote.slave, |
1088 | registeredhost_registration_completion, | 1092 | registeredhost_registration_completion, |
1089 | rhc, | 1093 | rhc, GST_host_list[peer2_host_id]); |
1090 | GST_host_list[peer2_host_id]); | ||
1091 | } | 1094 | } |
1092 | else { | 1095 | else |
1096 | { | ||
1093 | /* rhc is now set to the existing one from the hash map by | 1097 | /* rhc is now set to the existing one from the hash map by |
1094 | reghost_match_iterator() */ | 1098 | * reghost_match_iterator() */ |
1095 | /* if queue is empty then ignore creating focc and proceed with | 1099 | /* if queue is empty then ignore creating focc and proceed with |
1096 | normal forwarding */ | 1100 | * normal forwarding */ |
1097 | if (RHC_OL_CONNECT == rhc->state) | 1101 | if (RHC_OL_CONNECT == rhc->state) |
1098 | skip_focc = GNUNET_YES; | 1102 | skip_focc = GNUNET_YES; |
1099 | } | 1103 | } |
@@ -1108,8 +1112,7 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1108 | focc->orig_msg = GNUNET_copy_message (message); | 1112 | focc->orig_msg = GNUNET_copy_message (message); |
1109 | focc->operation_id = operation_id; | 1113 | focc->operation_id = operation_id; |
1110 | GNUNET_CONTAINER_DLL_insert_tail (rhc->focc_dll_head, | 1114 | GNUNET_CONTAINER_DLL_insert_tail (rhc->focc_dll_head, |
1111 | rhc->focc_dll_tail, | 1115 | rhc->focc_dll_tail, focc); |
1112 | focc); | ||
1113 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1116 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1114 | return; | 1117 | return; |
1115 | } | 1118 | } |
@@ -1120,14 +1123,15 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1120 | fopc->client = client; | 1123 | fopc->client = client; |
1121 | fopc->operation_id = operation_id; | 1124 | fopc->operation_id = operation_id; |
1122 | fopc->type = OP_OVERLAY_CONNECT; | 1125 | fopc->type = OP_OVERLAY_CONNECT; |
1123 | fopc->opc = | 1126 | fopc->opc = |
1124 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller, | 1127 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote. |
1125 | operation_id, message, | 1128 | slave->controller, operation_id, |
1126 | &GST_forwarded_operation_reply_relay, | 1129 | message, |
1127 | fopc); | 1130 | &GST_forwarded_operation_reply_relay, |
1131 | fopc); | ||
1128 | fopc->timeout_task = | 1132 | fopc->timeout_task = |
1129 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout, | 1133 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout, |
1130 | fopc); | 1134 | fopc); |
1131 | GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc); | 1135 | GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc); |
1132 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1136 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1133 | return; | 1137 | return; |
@@ -1135,20 +1139,20 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1135 | 1139 | ||
1136 | peer2_controller = NULL; | 1140 | peer2_controller = NULL; |
1137 | if ((p2 >= GST_peer_list_size) || (NULL == GST_peer_list[p2])) | 1141 | if ((p2 >= GST_peer_list_size) || (NULL == GST_peer_list[p2])) |
1138 | { | 1142 | { |
1139 | if ((peer2_host_id >= GST_slave_list_size) | 1143 | if ((peer2_host_id >= GST_slave_list_size) || |
1140 | || (NULL ==GST_slave_list[peer2_host_id])) | 1144 | (NULL == GST_slave_list[peer2_host_id])) |
1141 | { | 1145 | { |
1142 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1146 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1143 | "0x%llx: Configuration of peer2's controller missing for connecting peers" | 1147 | "0x%llx: Configuration of peer2's controller missing for connecting peers" |
1144 | "%u and %u\n", operation_id, p1, p2); | 1148 | "%u and %u\n", operation_id, p1, p2); |
1145 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1149 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1146 | return; | 1150 | return; |
1147 | } | 1151 | } |
1148 | peer2_controller = GST_slave_list[peer2_host_id]->controller; | 1152 | peer2_controller = GST_slave_list[peer2_host_id]->controller; |
1149 | if (NULL == peer2_controller) | 1153 | if (NULL == peer2_controller) |
1150 | { | 1154 | { |
1151 | GNUNET_break (0); /* What's going on? */ | 1155 | GNUNET_break (0); /* What's going on? */ |
1152 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1156 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1153 | return; | 1157 | return; |
1154 | } | 1158 | } |
@@ -1172,27 +1176,27 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1172 | { | 1176 | { |
1173 | struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg; | 1177 | struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg; |
1174 | 1178 | ||
1175 | cmsg.header.size = | 1179 | cmsg.header.size = |
1176 | htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); | 1180 | htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); |
1177 | cmsg.header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG); | 1181 | cmsg.header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG); |
1178 | cmsg.peer_id = msg->peer2; | 1182 | cmsg.peer_id = msg->peer2; |
1179 | cmsg.operation_id = msg->operation_id; | 1183 | cmsg.operation_id = msg->operation_id; |
1180 | occ->opc = | 1184 | occ->opc = |
1181 | GNUNET_TESTBED_forward_operation_msg_ (occ->peer2_controller, | 1185 | GNUNET_TESTBED_forward_operation_msg_ (occ->peer2_controller, |
1182 | occ->op_id, &cmsg.header, | 1186 | occ->op_id, &cmsg.header, |
1183 | &overlay_connect_get_config, | 1187 | &overlay_connect_get_config, |
1184 | occ); | 1188 | occ); |
1185 | GNUNET_asprintf (&occ->emsg, | 1189 | GNUNET_asprintf (&occ->emsg, |
1186 | "0x%llx: Timeout while getting peer identity of peer " | 1190 | "0x%llx: Timeout while getting peer identity of peer " |
1187 | "with id: %u", occ->op_id, occ->other_peer_id); | 1191 | "with id: %u", occ->op_id, occ->other_peer_id); |
1188 | occ->timeout_task = | 1192 | occ->timeout_task = |
1189 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 1193 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_overlay_connect, occ); |
1190 | &timeout_overlay_connect, occ); | ||
1191 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1194 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1192 | return; | 1195 | return; |
1193 | } | 1196 | } |
1194 | GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]->details.local.peer, | 1197 | GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]-> |
1195 | &occ->other_peer_identity); | 1198 | details.local.peer, |
1199 | &occ->other_peer_identity); | ||
1196 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ | 1200 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ |
1197 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); | 1201 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); |
1198 | GNUNET_asprintf (&occ->emsg, | 1202 | GNUNET_asprintf (&occ->emsg, |
@@ -1204,12 +1208,11 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1204 | &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL, | 1208 | &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL, |
1205 | GNUNET_NO, no_handlers); | 1209 | GNUNET_NO, no_handlers); |
1206 | if (NULL == occ->ch) | 1210 | if (NULL == occ->ch) |
1207 | occ->timeout_task = | 1211 | occ->timeout_task = |
1208 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 1212 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); |
1209 | else | 1213 | else |
1210 | occ->timeout_task = | 1214 | occ->timeout_task = |
1211 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 1215 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_overlay_connect, occ); |
1212 | &timeout_overlay_connect, occ); | ||
1213 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1216 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1214 | } | 1217 | } |
1215 | 1218 | ||
@@ -1236,8 +1239,8 @@ cleanup_rocc (struct RequestOverlayConnectContext *rocc) | |||
1236 | GNUNET_SCHEDULER_cancel (rocc->tcc.task); | 1239 | GNUNET_SCHEDULER_cancel (rocc->tcc.task); |
1237 | GNUNET_TRANSPORT_disconnect (rocc->tcc.th); | 1240 | GNUNET_TRANSPORT_disconnect (rocc->tcc.th); |
1238 | rocc->peer->reference_cnt--; | 1241 | rocc->peer->reference_cnt--; |
1239 | if ((GNUNET_YES == rocc->peer->destroy_flag) | 1242 | if ((GNUNET_YES == rocc->peer->destroy_flag) && |
1240 | && (0 == rocc->peer->reference_cnt)) | 1243 | (0 == rocc->peer->reference_cnt)) |
1241 | GST_destroy_peer (rocc->peer); | 1244 | GST_destroy_peer (rocc->peer); |
1242 | GNUNET_free_non_null (rocc->hello); | 1245 | GNUNET_free_non_null (rocc->hello); |
1243 | GNUNET_CONTAINER_DLL_remove (roccq_head, roccq_tail, rocc); | 1246 | GNUNET_CONTAINER_DLL_remove (roccq_head, roccq_tail, rocc); |
@@ -1255,7 +1258,7 @@ static void | |||
1255 | timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1258 | timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1256 | { | 1259 | { |
1257 | struct RequestOverlayConnectContext *rocc = cls; | 1260 | struct RequestOverlayConnectContext *rocc = cls; |
1258 | 1261 | ||
1259 | GNUNET_assert (rocc->timeout_rocc_task_id != GNUNET_SCHEDULER_NO_TASK); | 1262 | GNUNET_assert (rocc->timeout_rocc_task_id != GNUNET_SCHEDULER_NO_TASK); |
1260 | rocc->timeout_rocc_task_id = GNUNET_SCHEDULER_NO_TASK; | 1263 | rocc->timeout_rocc_task_id = GNUNET_SCHEDULER_NO_TASK; |
1261 | LOG_DEBUG ("0x%llx: rocc timed out\n", rocc->op_id); | 1264 | LOG_DEBUG ("0x%llx: rocc timed out\n", rocc->op_id); |
@@ -1272,9 +1275,9 @@ timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1272 | * @param ats performance data | 1275 | * @param ats performance data |
1273 | * @param ats_count number of entries in ats (excluding 0-termination) | 1276 | * @param ats_count number of entries in ats (excluding 0-termination) |
1274 | */ | 1277 | */ |
1275 | static void | 1278 | static void |
1276 | transport_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | 1279 | transport_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, |
1277 | const struct GNUNET_ATS_Information * ats, | 1280 | const struct GNUNET_ATS_Information *ats, |
1278 | uint32_t ats_count) | 1281 | uint32_t ats_count) |
1279 | { | 1282 | { |
1280 | struct RequestOverlayConnectContext *rocc = cls; | 1283 | struct RequestOverlayConnectContext *rocc = cls; |
@@ -1311,7 +1314,7 @@ static void | |||
1311 | rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1314 | rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1312 | { | 1315 | { |
1313 | struct RequestOverlayConnectContext *rocc = cls; | 1316 | struct RequestOverlayConnectContext *rocc = cls; |
1314 | 1317 | ||
1315 | rocc->ohh = NULL; | 1318 | rocc->ohh = NULL; |
1316 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rocc->attempt_connect_task_id); | 1319 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rocc->attempt_connect_task_id); |
1317 | LOG_DEBUG ("0x%llx: HELLO of peer %4s sent to local peer with id: %u\n", | 1320 | LOG_DEBUG ("0x%llx: HELLO of peer %4s sent to local peer with id: %u\n", |
@@ -1320,8 +1323,7 @@ rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1320 | { | 1323 | { |
1321 | GNUNET_break (0); | 1324 | GNUNET_break (0); |
1322 | rocc->attempt_connect_task_id = | 1325 | rocc->attempt_connect_task_id = |
1323 | GNUNET_SCHEDULER_add_now (&attempt_connect_task, | 1326 | GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); |
1324 | rocc); | ||
1325 | return; | 1327 | return; |
1326 | } | 1328 | } |
1327 | if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) | 1329 | if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) |
@@ -1346,15 +1348,17 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1346 | rocc->attempt_connect_task_id = GNUNET_SCHEDULER_NO_TASK; | 1348 | rocc->attempt_connect_task_id = GNUNET_SCHEDULER_NO_TASK; |
1347 | LOG_DEBUG ("0x%llx: Offering HELLO of peer %4s to local peer with id: %u\n", | 1349 | LOG_DEBUG ("0x%llx: Offering HELLO of peer %4s to local peer with id: %u\n", |
1348 | rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); | 1350 | rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); |
1349 | rocc->ohh = GNUNET_TRANSPORT_offer_hello (rocc->tcc.th, rocc->hello, | 1351 | rocc->ohh = |
1350 | rocc_hello_sent_cb, rocc); | 1352 | GNUNET_TRANSPORT_offer_hello (rocc->tcc.th, rocc->hello, |
1353 | rocc_hello_sent_cb, rocc); | ||
1351 | if (NULL == rocc->ohh) | 1354 | if (NULL == rocc->ohh) |
1352 | rocc->attempt_connect_task_id = | 1355 | rocc->attempt_connect_task_id = |
1353 | GNUNET_SCHEDULER_add_delayed | 1356 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1354 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 1357 | (GNUNET_TIME_UNIT_MILLISECONDS, |
1355 | 100 + GNUNET_CRYPTO_random_u32 | 1358 | 100 + |
1356 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), | 1359 | GNUNET_CRYPTO_random_u32 |
1357 | &attempt_connect_task, rocc); | 1360 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), |
1361 | &attempt_connect_task, rocc); | ||
1358 | } | 1362 | } |
1359 | 1363 | ||
1360 | 1364 | ||
@@ -1367,9 +1371,8 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1367 | */ | 1371 | */ |
1368 | void | 1372 | void |
1369 | GST_handle_overlay_request_connect (void *cls, | 1373 | GST_handle_overlay_request_connect (void *cls, |
1370 | struct GNUNET_SERVER_Client *client, | 1374 | struct GNUNET_SERVER_Client *client, |
1371 | const struct GNUNET_MessageHeader | 1375 | const struct GNUNET_MessageHeader *message) |
1372 | *message) | ||
1373 | { | 1376 | { |
1374 | const struct GNUNET_TESTBED_RequestConnectMessage *msg; | 1377 | const struct GNUNET_TESTBED_RequestConnectMessage *msg; |
1375 | struct RequestOverlayConnectContext *rocc; | 1378 | struct RequestOverlayConnectContext *rocc; |
@@ -1377,16 +1380,16 @@ GST_handle_overlay_request_connect (void *cls, | |||
1377 | uint32_t peer_id; | 1380 | uint32_t peer_id; |
1378 | uint16_t msize; | 1381 | uint16_t msize; |
1379 | uint16_t hsize; | 1382 | uint16_t hsize; |
1380 | 1383 | ||
1381 | msize = ntohs (message->size); | 1384 | msize = ntohs (message->size); |
1382 | if (sizeof (struct GNUNET_TESTBED_RequestConnectMessage) >= msize) | 1385 | if (sizeof (struct GNUNET_TESTBED_RequestConnectMessage) >= msize) |
1383 | { | 1386 | { |
1384 | GNUNET_break (0); | 1387 | GNUNET_break (0); |
1385 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1388 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1386 | return; | 1389 | return; |
1387 | } | 1390 | } |
1388 | msg = (const struct GNUNET_TESTBED_RequestConnectMessage *) message; | 1391 | msg = (const struct GNUNET_TESTBED_RequestConnectMessage *) message; |
1389 | if ((NULL == msg->hello) || | 1392 | if ((NULL == msg->hello) || |
1390 | (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))) | 1393 | (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))) |
1391 | { | 1394 | { |
1392 | GNUNET_break (0); | 1395 | GNUNET_break (0); |
@@ -1401,7 +1404,8 @@ GST_handle_overlay_request_connect (void *cls, | |||
1401 | return; | 1404 | return; |
1402 | } | 1405 | } |
1403 | peer_id = ntohl (msg->peer); | 1406 | peer_id = ntohl (msg->peer); |
1404 | if ((peer_id >= GST_peer_list_size) || (NULL == (peer = GST_peer_list[peer_id]))) | 1407 | if ((peer_id >= GST_peer_list_size) || |
1408 | (NULL == (peer = GST_peer_list[peer_id]))) | ||
1405 | { | 1409 | { |
1406 | GNUNET_break_op (0); | 1410 | GNUNET_break_op (0); |
1407 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1411 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -1410,7 +1414,7 @@ GST_handle_overlay_request_connect (void *cls, | |||
1410 | if (GNUNET_YES == peer->is_remote) | 1414 | if (GNUNET_YES == peer->is_remote) |
1411 | { | 1415 | { |
1412 | struct GNUNET_MessageHeader *msg2; | 1416 | struct GNUNET_MessageHeader *msg2; |
1413 | 1417 | ||
1414 | msg2 = GNUNET_copy_message (message); | 1418 | msg2 = GNUNET_copy_message (message); |
1415 | GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller, | 1419 | GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller, |
1416 | msg2); | 1420 | msg2); |
@@ -1424,15 +1428,13 @@ GST_handle_overlay_request_connect (void *cls, | |||
1424 | sizeof (struct GNUNET_PeerIdentity)); | 1428 | sizeof (struct GNUNET_PeerIdentity)); |
1425 | LOG_DEBUG ("Received request for overlay connection with op_id: 0x%llx " | 1429 | LOG_DEBUG ("Received request for overlay connection with op_id: 0x%llx " |
1426 | "from local peer %u to peer %4s with hello size: %u\n", | 1430 | "from local peer %u to peer %4s with hello size: %u\n", |
1427 | rocc->op_id, | 1431 | rocc->op_id, peer_id, GNUNET_i2s (&rocc->a_id), hsize); |
1428 | peer_id, | ||
1429 | GNUNET_i2s (&rocc->a_id), | ||
1430 | hsize); | ||
1431 | rocc->peer = peer; | 1432 | rocc->peer = peer; |
1432 | rocc->peer->reference_cnt++; | 1433 | rocc->peer->reference_cnt++; |
1433 | rocc->tcc.op_id = rocc->op_id; | 1434 | rocc->tcc.op_id = rocc->op_id; |
1434 | rocc->tcc.th = GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, NULL, rocc, | 1435 | rocc->tcc.th = |
1435 | NULL, &transport_connect_notify, NULL); | 1436 | GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, NULL, rocc, NULL, |
1437 | &transport_connect_notify, NULL); | ||
1436 | if (NULL == rocc->tcc.th) | 1438 | if (NULL == rocc->tcc.th) |
1437 | { | 1439 | { |
1438 | GNUNET_break (0); | 1440 | GNUNET_break (0); |