aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-02-01 20:23:00 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-02-01 20:23:00 +0000
commit3da727fad649c8c477fa6a2f02e6230780abe94f (patch)
treee300a0db7b8c3c947d2f151fb8709df18f3bbde5 /src
parenta7384ba9634781fa115a93645d255e525614a86e (diff)
downloadgnunet-3da727fad649c8c477fa6a2f02e6230780abe94f.tar.gz
gnunet-3da727fad649c8c477fa6a2f02e6230780abe94f.zip
- doc & indent
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed.c3
-rw-r--r--src/testbed/gnunet-service-testbed.h17
-rw-r--r--src/testbed/gnunet-service-testbed_cache.c118
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c132
-rw-r--r--src/testbed/testbed_api_testbed.c8
5 files changed, 131 insertions, 147 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 8fc512c13..f1dc3fab9 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -2190,8 +2190,7 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server,
2190 } 2190 }
2191 GNUNET_assert (GNUNET_OK == 2191 GNUNET_assert (GNUNET_OK ==
2192 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED", 2192 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
2193 "CACHE_SIZE", 2193 "CACHE_SIZE", &num));
2194 &num));
2195 GST_cache_init ((unsigned int) num); 2194 GST_cache_init ((unsigned int) num);
2196 GNUNET_assert (GNUNET_OK == 2195 GNUNET_assert (GNUNET_OK ==
2197 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED", 2196 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
diff --git a/src/testbed/gnunet-service-testbed.h b/src/testbed/gnunet-service-testbed.h
index 7314122d3..ebf3c66f9 100644
--- a/src/testbed/gnunet-service-testbed.h
+++ b/src/testbed/gnunet-service-testbed.h
@@ -817,10 +817,10 @@ GST_cache_add_hello (const unsigned int peer_id,
817 * cases, its value being NULL means that CORE connection has failed. 817 * cases, its value being NULL means that CORE connection has failed.
818 */ 818 */
819typedef void (*GST_cache_handle_ready_cb) (void *cls, 819typedef void (*GST_cache_handle_ready_cb) (void *cls,
820 struct GNUNET_CORE_Handle *ch, 820 struct GNUNET_CORE_Handle * ch,
821 struct GNUNET_TRANSPORT_Handle *th, 821 struct GNUNET_TRANSPORT_Handle * th,
822 const struct 822 const struct GNUNET_PeerIdentity *
823 GNUNET_PeerIdentity *peer_id); 823 peer_id);
824 824
825 825
826/** 826/**
@@ -836,7 +836,8 @@ typedef void (*GST_cache_handle_ready_cb) (void *cls,
836 * valid until GST_cache_get_handle_done() is called. 836 * valid until GST_cache_get_handle_done() is called.
837 */ 837 */
838typedef void (*GST_cache_peer_connect_notify) (void *cls, 838typedef void (*GST_cache_peer_connect_notify) (void *cls,
839 const struct GNUNET_PeerIdentity *target); 839 const struct GNUNET_PeerIdentity
840 * target);
840 841
841 842
842/** 843/**
@@ -862,8 +863,7 @@ typedef void (*GST_cache_peer_connect_notify) (void *cls,
862struct GSTCacheGetHandle * 863struct GSTCacheGetHandle *
863GST_cache_get_handle_transport (unsigned int peer_id, 864GST_cache_get_handle_transport (unsigned int peer_id,
864 const struct GNUNET_CONFIGURATION_Handle *cfg, 865 const struct GNUNET_CONFIGURATION_Handle *cfg,
865 GST_cache_handle_ready_cb cb, 866 GST_cache_handle_ready_cb cb, void *cb_cls,
866 void *cb_cls,
867 const struct GNUNET_PeerIdentity *target, 867 const struct GNUNET_PeerIdentity *target,
868 GST_cache_peer_connect_notify connect_notify_cb, 868 GST_cache_peer_connect_notify connect_notify_cb,
869 void *connect_notify_cb_cls); 869 void *connect_notify_cb_cls);
@@ -893,8 +893,7 @@ GST_cache_get_handle_transport (unsigned int peer_id,
893struct GSTCacheGetHandle * 893struct GSTCacheGetHandle *
894GST_cache_get_handle_core (unsigned int peer_id, 894GST_cache_get_handle_core (unsigned int peer_id,
895 const struct GNUNET_CONFIGURATION_Handle *cfg, 895 const struct GNUNET_CONFIGURATION_Handle *cfg,
896 GST_cache_handle_ready_cb cb, 896 GST_cache_handle_ready_cb cb, void *cb_cls,
897 void *cb_cls,
898 const struct GNUNET_PeerIdentity *target, 897 const struct GNUNET_PeerIdentity *target,
899 GST_cache_peer_connect_notify connect_notify_cb, 898 GST_cache_peer_connect_notify connect_notify_cb,
900 void *connect_notify_cb_cls); 899 void *connect_notify_cb_cls);
diff --git a/src/testbed/gnunet-service-testbed_cache.c b/src/testbed/gnunet-service-testbed_cache.c
index 9e65db9e8..46c7d4fce 100644
--- a/src/testbed/gnunet-service-testbed_cache.c
+++ b/src/testbed/gnunet-service-testbed_cache.c
@@ -117,12 +117,12 @@ struct GSTCacheGetHandle
117 * The cache entry object this handle corresponds to 117 * The cache entry object this handle corresponds to
118 */ 118 */
119 struct CacheEntry *entry; 119 struct CacheEntry *entry;
120 120
121 /** 121 /**
122 * The cache callback to call when a handle is available 122 * The cache callback to call when a handle is available
123 */ 123 */
124 GST_cache_handle_ready_cb cb; 124 GST_cache_handle_ready_cb cb;
125 125
126 /** 126 /**
127 * The closure for the above callback 127 * The closure for the above callback
128 */ 128 */
@@ -130,7 +130,7 @@ struct GSTCacheGetHandle
130 130
131 /** 131 /**
132 * The peer connect notify context created for this handle; can be NULL 132 * The peer connect notify context created for this handle; can be NULL
133 */ 133 */
134 struct ConnectNotifyContext *nctxt; 134 struct ConnectNotifyContext *nctxt;
135 135
136 /** 136 /**
@@ -147,7 +147,7 @@ struct GSTCacheGetHandle
147/** 147/**
148 * Cache entry 148 * Cache entry
149 */ 149 */
150struct CacheEntry 150struct CacheEntry
151{ 151{
152 /** 152 /**
153 * DLL next ptr for least recently used cache entries 153 * DLL next ptr for least recently used cache entries
@@ -312,7 +312,7 @@ static void
312close_handles (struct CacheEntry *entry) 312close_handles (struct CacheEntry *entry)
313{ 313{
314 struct ConnectNotifyContext *ctxt; 314 struct ConnectNotifyContext *ctxt;
315 315
316 GNUNET_assert (0 == entry->demand); 316 GNUNET_assert (0 == entry->demand);
317 if (GNUNET_YES == entry->in_lru) 317 if (GNUNET_YES == entry->in_lru)
318 { 318 {
@@ -363,8 +363,7 @@ add_entry (const struct GNUNET_HashCode *key, unsigned int peer_id)
363 entry->peer_id = peer_id; 363 entry->peer_id = peer_id;
364 memcpy (&entry->key, key, sizeof (struct GNUNET_HashCode)); 364 memcpy (&entry->key, key, sizeof (struct GNUNET_HashCode));
365 GNUNET_assert (GNUNET_OK == 365 GNUNET_assert (GNUNET_OK ==
366 GNUNET_CONTAINER_multihashmap_put (cache, &entry->key, 366 GNUNET_CONTAINER_multihashmap_put (cache, &entry->key, entry,
367 entry,
368 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 367 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
369 cache_size++; 368 cache_size++;
370 return entry; 369 return entry;
@@ -388,7 +387,7 @@ search_suitable_cgh (const struct CacheEntry *entry,
388{ 387{
389 const struct GSTCacheGetHandle *cgh; 388 const struct GSTCacheGetHandle *cgh;
390 389
391 for (cgh=head; NULL != cgh; cgh=cgh->next) 390 for (cgh = head; NULL != cgh; cgh = cgh->next)
392 { 391 {
393 if (GNUNET_YES == cgh->notify_called) 392 if (GNUNET_YES == cgh->notify_called)
394 return NULL; 393 return NULL;
@@ -404,7 +403,7 @@ search_suitable_cgh (const struct CacheEntry *entry,
404 break; 403 break;
405 } 404 }
406 break; 405 break;
407 } 406 }
408 return (struct GSTCacheGetHandle *) cgh; 407 return (struct GSTCacheGetHandle *) cgh;
409} 408}
410 409
@@ -422,7 +421,7 @@ call_cgh_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
422 struct CacheEntry *entry = cls; 421 struct CacheEntry *entry = cls;
423 struct GSTCacheGetHandle *cgh; 422 struct GSTCacheGetHandle *cgh;
424 const struct GSTCacheGetHandle *cgh2; 423 const struct GSTCacheGetHandle *cgh2;
425 424
426 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != entry->notify_task); 425 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != entry->notify_task);
427 entry->notify_task = GNUNET_SCHEDULER_NO_TASK; 426 entry->notify_task = GNUNET_SCHEDULER_NO_TASK;
428 cgh = search_suitable_cgh (entry, entry->cgh_qhead); 427 cgh = search_suitable_cgh (entry, entry->cgh_qhead);
@@ -436,13 +435,13 @@ call_cgh_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
436 if (NULL != cgh2) 435 if (NULL != cgh2)
437 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry); 436 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
438 if (NULL != cgh->nctxt) 437 if (NULL != cgh->nctxt)
439 {/* Register the peer connect notify callback */ 438 { /* Register the peer connect notify callback */
440 GNUNET_CONTAINER_DLL_insert_tail (entry->nctxt_qhead, entry->nctxt_qtail, 439 GNUNET_CONTAINER_DLL_insert_tail (entry->nctxt_qhead, entry->nctxt_qtail,
441 cgh->nctxt); 440 cgh->nctxt);
442 } 441 }
443 LOG_DEBUG ("Calling notify for handle type %u\n", cgh->type); 442 LOG_DEBUG ("Calling notify for handle type %u\n", cgh->type);
444 cgh->cb (cgh->cb_cls, entry->core_handle, 443 cgh->cb (cgh->cb_cls, entry->core_handle, entry->transport_handle_,
445 entry->transport_handle_, entry->peer_identity); 444 entry->peer_identity);
446} 445}
447 446
448 447
@@ -455,9 +454,8 @@ call_cgh_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
455 * @param peer the peer that connected 454 * @param peer the peer that connected
456 * @param type the type of the handle this notification corresponds to 455 * @param type the type of the handle this notification corresponds to
457 */ 456 */
458static void 457static void
459peer_connect_notify_cb (void *cls, 458peer_connect_notify_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
460 const struct GNUNET_PeerIdentity *peer,
461 const enum CacheGetType type) 459 const enum CacheGetType type)
462{ 460{
463 struct CacheEntry *entry = cls; 461 struct CacheEntry *entry = cls;
@@ -466,8 +464,8 @@ peer_connect_notify_cb (void *cls,
466 GST_cache_peer_connect_notify cb; 464 GST_cache_peer_connect_notify cb;
467 void *cb_cls; 465 void *cb_cls;
468 466
469 467
470 for (ctxt=entry->nctxt_qhead; NULL != ctxt;) 468 for (ctxt = entry->nctxt_qhead; NULL != ctxt;)
471 { 469 {
472 GNUNET_assert (NULL != ctxt->cgh); 470 GNUNET_assert (NULL != ctxt->cgh);
473 if (type != ctxt->cgh->type) 471 if (type != ctxt->cgh->type)
@@ -487,11 +485,11 @@ peer_connect_notify_cb (void *cls,
487 GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, ctxt); 485 GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, ctxt);
488 GNUNET_free (ctxt); 486 GNUNET_free (ctxt);
489 ctxt = ctxt2; 487 ctxt = ctxt2;
490 cb (cb_cls, peer); 488 cb (cb_cls, peer);
491 } 489 }
492 if (NULL == ctxt) 490 if (NULL == ctxt)
493 return; 491 return;
494 492
495} 493}
496 494
497 495
@@ -504,7 +502,7 @@ peer_connect_notify_cb (void *cls,
504 * @param ats performance data 502 * @param ats performance data
505 * @param ats_count number of entries in ats (excluding 0-termination) 503 * @param ats_count number of entries in ats (excluding 0-termination)
506 */ 504 */
507static void 505static void
508transport_peer_connect_notify_cb (void *cls, 506transport_peer_connect_notify_cb (void *cls,
509 const struct GNUNET_PeerIdentity *peer, 507 const struct GNUNET_PeerIdentity *peer,
510 const struct GNUNET_ATS_Information *ats, 508 const struct GNUNET_ATS_Information *ats,
@@ -527,10 +525,8 @@ opstart_get_handle_transport (void *cls)
527 525
528 GNUNET_assert (NULL != entry); 526 GNUNET_assert (NULL != entry);
529 LOG_DEBUG ("Opening a transport connection to peer %u\n", entry->peer_id); 527 LOG_DEBUG ("Opening a transport connection to peer %u\n", entry->peer_id);
530 entry->transport_handle_ = 528 entry->transport_handle_ =
531 GNUNET_TRANSPORT_connect (entry->cfg, 529 GNUNET_TRANSPORT_connect (entry->cfg, NULL, entry, NULL,
532 NULL, entry,
533 NULL,
534 &transport_peer_connect_notify_cb, NULL); 530 &transport_peer_connect_notify_cb, NULL);
535 if (NULL == entry->transport_handle_) 531 if (NULL == entry->transport_handle_)
536 { 532 {
@@ -556,7 +552,7 @@ static void
556oprelease_get_handle_transport (void *cls) 552oprelease_get_handle_transport (void *cls)
557{ 553{
558 struct CacheEntry *entry = cls; 554 struct CacheEntry *entry = cls;
559 555
560 if (NULL == entry->transport_handle_) 556 if (NULL == entry->transport_handle_)
561 return; 557 return;
562 GNUNET_TRANSPORT_disconnect (entry->transport_handle_); 558 GNUNET_TRANSPORT_disconnect (entry->transport_handle_);
@@ -577,9 +573,8 @@ oprelease_get_handle_transport (void *cls)
577 * @param server handle to the server, NULL if we failed 573 * @param server handle to the server, NULL if we failed
578 * @param my_identity ID of this peer, NULL if we failed 574 * @param my_identity ID of this peer, NULL if we failed
579 */ 575 */
580static void 576static void
581core_startup_cb (void *cls, 577core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server,
582 struct GNUNET_CORE_Handle * server,
583 const struct GNUNET_PeerIdentity *my_identity) 578 const struct GNUNET_PeerIdentity *my_identity)
584{ 579{
585 struct CacheEntry *entry = cls; 580 struct CacheEntry *entry = cls;
@@ -595,7 +590,7 @@ core_startup_cb (void *cls,
595 memcpy (entry->peer_identity, my_identity, 590 memcpy (entry->peer_identity, my_identity,
596 sizeof (struct GNUNET_PeerIdentity)); 591 sizeof (struct GNUNET_PeerIdentity));
597 if (0 == entry->demand) 592 if (0 == entry->demand)
598 return; 593 return;
599 if (GNUNET_SCHEDULER_NO_TASK != entry->notify_task) 594 if (GNUNET_SCHEDULER_NO_TASK != entry->notify_task)
600 return; 595 return;
601 if (NULL != search_suitable_cgh (entry, entry->cgh_qhead)) 596 if (NULL != search_suitable_cgh (entry, entry->cgh_qhead))
@@ -611,12 +606,11 @@ core_startup_cb (void *cls,
611 * @param atsi performance data for the connection 606 * @param atsi performance data for the connection
612 * @param atsi_count number of records in 'atsi' 607 * @param atsi_count number of records in 'atsi'
613 */ 608 */
614static void 609static void
615core_peer_connect_cb (void *cls, 610core_peer_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
616 const struct GNUNET_PeerIdentity * peer, 611 const struct GNUNET_ATS_Information *atsi,
617 const struct GNUNET_ATS_Information * atsi,
618 unsigned int atsi_count) 612 unsigned int atsi_count)
619{ 613{
620 peer_connect_notify_cb (cls, peer, CGT_CORE_HANDLE); 614 peer_connect_notify_cb (cls, peer, CGT_CORE_HANDLE);
621} 615}
622 616
@@ -631,6 +625,7 @@ static void
631opstart_get_handle_core (void *cls) 625opstart_get_handle_core (void *cls)
632{ 626{
633 struct CacheEntry *entry = cls; 627 struct CacheEntry *entry = cls;
628
634 const struct GNUNET_CORE_MessageHandler no_handlers[] = { 629 const struct GNUNET_CORE_MessageHandler no_handlers[] = {
635 {NULL, 0, 0} 630 {NULL, 0, 0}
636 }; 631 };
@@ -638,17 +633,15 @@ opstart_get_handle_core (void *cls)
638 GNUNET_assert (NULL != entry); 633 GNUNET_assert (NULL != entry);
639 LOG_DEBUG ("Opening a CORE connection to peer %u\n", entry->peer_id); 634 LOG_DEBUG ("Opening a CORE connection to peer %u\n", entry->peer_id);
640 /* void?: We also get the handle when the connection to CORE is successful */ 635 /* void?: We also get the handle when the connection to CORE is successful */
641 (void) GNUNET_CORE_connect (entry->cfg, 636 (void) GNUNET_CORE_connect (entry->cfg, entry, /* closure */
642 entry, 637 &core_startup_cb, /* core startup notify */
643 &core_startup_cb, 638 &core_peer_connect_cb, /* peer connect notify */
644 &core_peer_connect_cb, 639 NULL, /* peer disconnect notify */
645 NULL, /* disconnect cb */ 640 NULL, /* inbound notify */
646 NULL, /* inbound notify */ 641 GNUNET_NO, /* inbound header only? */
647 GNUNET_NO, 642 NULL, /* outbound notify */
648 NULL, /* outbound notify */ 643 GNUNET_NO, /* outbound header only? */
649 GNUNET_NO,
650 no_handlers); 644 no_handlers);
651 //GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == entry->notify_task);
652} 645}
653 646
654 647
@@ -662,7 +655,7 @@ static void
662oprelease_get_handle_core (void *cls) 655oprelease_get_handle_core (void *cls)
663{ 656{
664 struct CacheEntry *entry = cls; 657 struct CacheEntry *entry = cls;
665 658
666 if (NULL == entry->core_handle) 659 if (NULL == entry->core_handle)
667 return; 660 return;
668 GNUNET_CORE_disconnect (entry->core_handle); 661 GNUNET_CORE_disconnect (entry->core_handle);
@@ -682,8 +675,7 @@ oprelease_get_handle_core (void *cls)
682 * @param cls the cache entry 675 * @param cls the cache entry
683 */ 676 */
684static struct GSTCacheGetHandle * 677static struct GSTCacheGetHandle *
685cache_get_handle (unsigned int peer_id, 678cache_get_handle (unsigned int peer_id, struct GSTCacheGetHandle *cgh,
686 struct GSTCacheGetHandle *cgh,
687 const struct GNUNET_CONFIGURATION_Handle *cfg, 679 const struct GNUNET_CONFIGURATION_Handle *cfg,
688 const struct GNUNET_PeerIdentity *target, 680 const struct GNUNET_PeerIdentity *target,
689 GST_cache_peer_connect_notify connect_notify_cb, 681 GST_cache_peer_connect_notify connect_notify_cb,
@@ -714,7 +706,8 @@ cache_get_handle (unsigned int peer_id,
714 case CGT_TRANSPORT_HANDLE: 706 case CGT_TRANSPORT_HANDLE:
715 handle = entry->transport_handle_; 707 handle = entry->transport_handle_;
716 if (NULL != handle) 708 if (NULL != handle)
717 LOG_DEBUG ("Found TRANSPORT handle in cache for peer %u\n", entry->peer_id); 709 LOG_DEBUG ("Found TRANSPORT handle in cache for peer %u\n",
710 entry->peer_id);
718 break; 711 break;
719 case CGT_CORE_HANDLE: 712 case CGT_CORE_HANDLE:
720 handle = entry->core_handle; 713 handle = entry->core_handle;
@@ -780,9 +773,7 @@ cache_get_handle (unsigned int peer_id,
780 * GNUNET_NO if not. 773 * GNUNET_NO if not.
781 */ 774 */
782static int 775static int
783cache_clear_iterator (void *cls, 776cache_clear_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
784 const struct GNUNET_HashCode * key,
785 void *value)
786{ 777{
787 struct CacheEntry *entry = value; 778 struct CacheEntry *entry = value;
788 static unsigned int ncleared; 779 static unsigned int ncleared;
@@ -862,12 +853,13 @@ GST_cache_get_handle_done (struct GSTCacheGetHandle *cgh)
862 { 853 {
863 GNUNET_assert (cgh == cgh->nctxt->cgh); 854 GNUNET_assert (cgh == cgh->nctxt->cgh);
864 if (GNUNET_YES == cgh->notify_called) 855 if (GNUNET_YES == cgh->notify_called)
865 GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, cgh->nctxt); 856 GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail,
857 cgh->nctxt);
866 GNUNET_free (cgh->nctxt); 858 GNUNET_free (cgh->nctxt);
867 } 859 }
868 GNUNET_free (cgh); 860 GNUNET_free (cgh);
869 if (0 == entry->demand) 861 if (0 == entry->demand)
870 { 862 {
871 GNUNET_CONTAINER_DLL_insert_tail (lru_cache_head, lru_cache_tail, entry); 863 GNUNET_CONTAINER_DLL_insert_tail (lru_cache_head, lru_cache_tail, entry);
872 lru_cache_size++; 864 lru_cache_size++;
873 entry->in_lru = GNUNET_YES; 865 entry->in_lru = GNUNET_YES;
@@ -907,8 +899,7 @@ GST_cache_get_handle_done (struct GSTCacheGetHandle *cgh)
907struct GSTCacheGetHandle * 899struct GSTCacheGetHandle *
908GST_cache_get_handle_transport (unsigned int peer_id, 900GST_cache_get_handle_transport (unsigned int peer_id,
909 const struct GNUNET_CONFIGURATION_Handle *cfg, 901 const struct GNUNET_CONFIGURATION_Handle *cfg,
910 GST_cache_handle_ready_cb cb, 902 GST_cache_handle_ready_cb cb, void *cb_cls,
911 void *cb_cls,
912 const struct GNUNET_PeerIdentity *target, 903 const struct GNUNET_PeerIdentity *target,
913 GST_cache_peer_connect_notify connect_notify_cb, 904 GST_cache_peer_connect_notify connect_notify_cb,
914 void *connect_notify_cb_cls) 905 void *connect_notify_cb_cls)
@@ -919,8 +910,8 @@ GST_cache_get_handle_transport (unsigned int peer_id,
919 cgh->cb = cb; 910 cgh->cb = cb;
920 cgh->cb_cls = cb_cls; 911 cgh->cb_cls = cb_cls;
921 cgh->type = CGT_TRANSPORT_HANDLE; 912 cgh->type = CGT_TRANSPORT_HANDLE;
922 return cache_get_handle (peer_id, cgh, cfg, 913 return cache_get_handle (peer_id, cgh, cfg, target, connect_notify_cb,
923 target, connect_notify_cb, connect_notify_cb_cls); 914 connect_notify_cb_cls);
924} 915}
925 916
926 917
@@ -948,8 +939,7 @@ GST_cache_get_handle_transport (unsigned int peer_id,
948struct GSTCacheGetHandle * 939struct GSTCacheGetHandle *
949GST_cache_get_handle_core (unsigned int peer_id, 940GST_cache_get_handle_core (unsigned int peer_id,
950 const struct GNUNET_CONFIGURATION_Handle *cfg, 941 const struct GNUNET_CONFIGURATION_Handle *cfg,
951 GST_cache_handle_ready_cb cb, 942 GST_cache_handle_ready_cb cb, void *cb_cls,
952 void *cb_cls,
953 const struct GNUNET_PeerIdentity *target, 943 const struct GNUNET_PeerIdentity *target,
954 GST_cache_peer_connect_notify connect_notify_cb, 944 GST_cache_peer_connect_notify connect_notify_cb,
955 void *connect_notify_cb_cls) 945 void *connect_notify_cb_cls)
@@ -960,8 +950,8 @@ GST_cache_get_handle_core (unsigned int peer_id,
960 cgh->cb = cb; 950 cgh->cb = cb;
961 cgh->cb_cls = cb_cls; 951 cgh->cb_cls = cb_cls;
962 cgh->type = CGT_CORE_HANDLE; 952 cgh->type = CGT_CORE_HANDLE;
963 return cache_get_handle (peer_id, cgh, cfg, 953 return cache_get_handle (peer_id, cgh, cfg, target, connect_notify_cb,
964 target, connect_notify_cb, connect_notify_cb_cls); 954 connect_notify_cb_cls);
965} 955}
966 956
967 957
@@ -976,7 +966,7 @@ GST_cache_lookup_hello (const unsigned int peer_id)
976{ 966{
977 struct CacheEntry *entry; 967 struct CacheEntry *entry;
978 struct GNUNET_HashCode key; 968 struct GNUNET_HashCode key;
979 969
980 LOG_DEBUG ("Looking up HELLO for peer %u\n", peer_id); 970 LOG_DEBUG ("Looking up HELLO for peer %u\n", peer_id);
981 GNUNET_CRYPTO_hash (&peer_id, sizeof (peer_id), &key); 971 GNUNET_CRYPTO_hash (&peer_id, sizeof (peer_id), &key);
982 entry = cache_lookup (&key); 972 entry = cache_lookup (&key);
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index 43841b461..9b571e3dd 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -37,7 +37,7 @@
37 37
38 38
39/** 39/**
40 * Context information for transport try connect 40 * Context information for requesting TRANSPORT to connect to a peer
41 */ 41 */
42struct TryConnectContext 42struct TryConnectContext
43{ 43{
@@ -47,7 +47,7 @@ struct TryConnectContext
47 struct GNUNET_PeerIdentity *pid; 47 struct GNUNET_PeerIdentity *pid;
48 48
49 /** 49 /**
50 * The transport handle 50 * The transport handle obtained from cache. Do NOT close/disconnect.
51 */ 51 */
52 struct GNUNET_TRANSPORT_Handle *th_; 52 struct GNUNET_TRANSPORT_Handle *th_;
53 53
@@ -80,32 +80,34 @@ struct TryConnectContext
80 80
81 81
82/** 82/**
83 * Context information for connecting 2 peers in overlay 83 * Context information for connecting 2 peers in overlay.
84 */ 84 */
85struct OverlayConnectContext 85struct OverlayConnectContext
86{ 86{
87 /** 87 /**
88 * The next pointer for maintaining a DLL 88 * The next pointer for maintaining a DLL of all OverlayConnectContexts
89 */ 89 */
90 struct OverlayConnectContext *next; 90 struct OverlayConnectContext *next;
91 91
92 /** 92 /**
93 * The prev pointer for maintaining a DLL 93 * The prev pointer for maintaining a DLL of all OverlayConnectContexts
94 */ 94 */
95 struct OverlayConnectContext *prev; 95 struct OverlayConnectContext *prev;
96 96
97 /** 97 /**
98 * The client which has requested for overlay connection 98 * The client which has requested for overlay connection. This is used to send
99 * either a success of failure message
99 */ 100 */
100 struct GNUNET_SERVER_Client *client; 101 struct GNUNET_SERVER_Client *client;
101 102
102 /** 103 /**
103 * the peer which has to connect to the other peer 104 * the first peer which is to expect an overlay connection from the second peer.
104 */ 105 */
105 struct Peer *peer; 106 struct Peer *peer;
106 107
107 /** 108 /**
108 * Transport handle of the first peer to get its HELLO 109 * Transport handle of the first peer obtained from cache to get its HELLO. Do
110 * NOT close/disconnect.
109 */ 111 */
110 struct GNUNET_TRANSPORT_Handle *p1th_; 112 struct GNUNET_TRANSPORT_Handle *p1th_;
111 113
@@ -115,27 +117,24 @@ struct OverlayConnectContext
115 struct GSTCacheGetHandle *cgh_p1th; 117 struct GSTCacheGetHandle *cgh_p1th;
116 118
117 /** 119 /**
118 * Core handles of the first peer; used to notify when second peer connects to it 120 * The GetCacheHandle for registering callback to notify CORE level peer
119 */ 121 * connects and to get our identity.
120 //struct GNUNET_CORE_Handle *ch_;
121
122 /**
123 * The GetCacheHandle for the p1th transport handle
124 */ 122 */
125 struct GSTCacheGetHandle *cgh_ch; 123 struct GSTCacheGetHandle *cgh_ch;
126 124
127 /** 125 /**
128 * HELLO of the other peer 126 * HELLO of the first peer. This should be sent to the second peer.
129 */ 127 */
130 struct GNUNET_MessageHeader *hello; 128 struct GNUNET_MessageHeader *hello;
131 129
132 /** 130 /**
133 * Get hello handle to acquire HELLO of first peer 131 * Get GetHelloHandle to acquire a HELLO of the first peer
134 */ 132 */
135 struct GNUNET_TRANSPORT_GetHelloHandle *ghh; 133 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
136 134
137 /** 135 /**
138 * The handle for offering HELLO 136 * The handle for offering the HELLO of the first peer to the second
137 * peer. This is only used if the second peer is a local peer.
139 */ 138 */
140 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; 139 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh;
141 140
@@ -145,17 +144,19 @@ struct OverlayConnectContext
145 char *emsg; 144 char *emsg;
146 145
147 /** 146 /**
148 * Operation context for suboperations 147 * Operation context for the suboperation we start to get the identity of the
148 * second peer if it is a remote peer
149 */ 149 */
150 struct OperationContext *opc; 150 struct OperationContext *opc;
151 151
152 /** 152 /**
153 * Controller of peer 2; NULL if the peer is local 153 * Controller of peer 2; NULL if the peer is a local peer
154 */ 154 */
155 struct GNUNET_TESTBED_Controller *peer2_controller; 155 struct GNUNET_TESTBED_Controller *peer2_controller;
156 156
157 /** 157 /**
158 * The transport try connect context 158 * The transport TryConnectContext. This will be NULL if the second peer is a
159 * remote peer
159 */ 160 */
160 struct TryConnectContext tcc; 161 struct TryConnectContext tcc;
161 162
@@ -204,10 +205,11 @@ struct OverlayConnectContext
204 205
205 206
206/** 207/**
207 * Context information for RequestOverlayConnect 208 * Context information for remote overlay connect operations. Remote overlay
208 * operations. RequestOverlayConnect is used when peers A, B reside on different 209 * connections are used when peers A and B reside on different hosts. In these
209 * hosts and the host controller for peer B is asked by the host controller of 210 * operations the host controller for peer B is asked by the host controller of
210 * peer A to make peer B connect to peer A 211 * peer A to make peer B connect to peer A by sending the controller of peer B
212 * the HELLO of peer A.
211 */ 213 */
212struct RemoteOverlayConnectCtx 214struct RemoteOverlayConnectCtx
213{ 215{
@@ -505,8 +507,7 @@ send_overlay_connect_success_msg (struct OverlayConnectContext *occ)
505 * @param new_peer the peer that connected 507 * @param new_peer the peer that connected
506 */ 508 */
507static void 509static void
508overlay_connect_notify (void *cls, 510overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer)
509 const struct GNUNET_PeerIdentity *new_peer)
510{ 511{
511 struct OverlayConnectContext *occ = cls; 512 struct OverlayConnectContext *occ = cls;
512 char *new_peer_str; 513 char *new_peer_str;
@@ -729,8 +730,8 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
729 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 730 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
730 * @param ignore_ peer identity which is ignored in this callback 731 * @param ignore_ peer identity which is ignored in this callback
731 */ 732 */
732static void 733static void
733p2_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, 734p2_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
734 struct GNUNET_TRANSPORT_Handle *th, 735 struct GNUNET_TRANSPORT_Handle *th,
735 const struct GNUNET_PeerIdentity *ignore_) 736 const struct GNUNET_PeerIdentity *ignore_)
736{ 737{
@@ -769,13 +770,12 @@ p2_transport_connect (struct OverlayConnectContext *occ)
769 if (NULL == occ->peer2_controller) 770 if (NULL == occ->peer2_controller)
770 { 771 {
771 GST_peer_list[occ->other_peer_id]->reference_cnt++; 772 GST_peer_list[occ->other_peer_id]->reference_cnt++;
772 occ->tcc.cgh_th = 773 occ->tcc.cgh_th =
773 GST_cache_get_handle_transport (occ->other_peer_id, 774 GST_cache_get_handle_transport (occ->other_peer_id,
774 GST_peer_list[occ->other_peer_id]-> 775 GST_peer_list[occ->other_peer_id]->
775 details.local.cfg, 776 details.local.cfg,
776 &p2_transport_connect_cache_callback, 777 &p2_transport_connect_cache_callback,
777 occ, 778 occ, NULL, NULL, NULL);
778 NULL, NULL, NULL);
779 return; 779 return;
780 } 780 }
781 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while offering HELLO to %s", 781 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while offering HELLO to %s",
@@ -854,8 +854,8 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
854 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 854 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
855 * @param ignore_ peer identity which is ignored in this callback 855 * @param ignore_ peer identity which is ignored in this callback
856 */ 856 */
857static void 857static void
858p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, 858p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
859 struct GNUNET_TRANSPORT_Handle *th, 859 struct GNUNET_TRANSPORT_Handle *th,
860 const struct GNUNET_PeerIdentity *ignore_) 860 const struct GNUNET_PeerIdentity *ignore_)
861{ 861{
@@ -890,8 +890,8 @@ p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
890 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 890 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
891 * @param my_identity the identity of our peer 891 * @param my_identity the identity of our peer
892 */ 892 */
893static void 893static void
894occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch, 894occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
895 struct GNUNET_TRANSPORT_Handle *th, 895 struct GNUNET_TRANSPORT_Handle *th,
896 const struct GNUNET_PeerIdentity *my_identity) 896 const struct GNUNET_PeerIdentity *my_identity)
897{ 897{
@@ -906,12 +906,13 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
906 "0x%llx: Failed to connect to CORE of peer with" 906 "0x%llx: Failed to connect to CORE of peer with"
907 "id: %u", occ->op_id, occ->peer_id); 907 "id: %u", occ->op_id, occ->peer_id);
908 GNUNET_SCHEDULER_cancel (occ->timeout_task); 908 GNUNET_SCHEDULER_cancel (occ->timeout_task);
909 occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 909 occ->timeout_task =
910 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
910 return; 911 return;
911 } 912 }
912 //occ->ch_ = ch; 913 //occ->ch_ = ch;
913 occ->emsg = NULL; 914 occ->emsg = NULL;
914 if (GNUNET_YES == 915 if (GNUNET_YES ==
915 GNUNET_CORE_is_peer_connected_sync (ch, &occ->other_peer_identity)) 916 GNUNET_CORE_is_peer_connected_sync (ch, &occ->other_peer_identity))
916 { 917 {
917 LOG_DEBUG ("0x%llx: Target peer already connected\n", occ->op_id); 918 LOG_DEBUG ("0x%llx: Target peer already connected\n", occ->op_id);
@@ -920,7 +921,7 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
920 send_overlay_connect_success_msg (occ); 921 send_overlay_connect_success_msg (occ);
921 occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ); 922 occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ);
922 return; 923 return;
923 } 924 }
924 memcpy (&occ->peer_identity, my_identity, 925 memcpy (&occ->peer_identity, my_identity,
925 sizeof (struct GNUNET_PeerIdentity)); 926 sizeof (struct GNUNET_PeerIdentity));
926 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id, 927 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id,
@@ -938,11 +939,10 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
938 "0x%llx: Timeout while acquiring TRANSPORT of %s from cache", 939 "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
939 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 940 occ->op_id, GNUNET_i2s (&occ->peer_identity));
940 occ->peer->reference_cnt++; 941 occ->peer->reference_cnt++;
941 occ->cgh_p1th = 942 occ->cgh_p1th =
942 GST_cache_get_handle_transport (occ->peer_id, 943 GST_cache_get_handle_transport (occ->peer_id,
943 occ->peer->details.local.cfg, 944 occ->peer->details.local.cfg,
944 p1_transport_connect_cache_callback, 945 p1_transport_connect_cache_callback, occ,
945 occ,
946 NULL, NULL, NULL); 946 NULL, NULL, NULL);
947 return; 947 return;
948} 948}
@@ -979,13 +979,11 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
979 "0x%llx: Timeout while connecting to CORE of peer with " 979 "0x%llx: Timeout while connecting to CORE of peer with "
980 "id: %u", occ->op_id, occ->peer_id); 980 "id: %u", occ->op_id, occ->peer_id);
981 occ->peer->reference_cnt++; 981 occ->peer->reference_cnt++;
982 occ->cgh_ch = GST_cache_get_handle_core (occ->peer_id, 982 occ->cgh_ch =
983 occ->peer->details.local.cfg, 983 GST_cache_get_handle_core (occ->peer_id, occ->peer->details.local.cfg,
984 occ_cache_get_handle_core_cb, 984 occ_cache_get_handle_core_cb, occ,
985 occ, 985 &occ->other_peer_identity,
986 &occ->other_peer_identity, 986 &overlay_connect_notify, occ);
987 &overlay_connect_notify,
988 occ);
989 return; 987 return;
990} 988}
991 989
@@ -1296,13 +1294,11 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1296 "0x%llx: Timeout while connecting to CORE of peer with " 1294 "0x%llx: Timeout while connecting to CORE of peer with "
1297 "id: %u", occ->op_id, occ->peer_id); 1295 "id: %u", occ->op_id, occ->peer_id);
1298 occ->peer->reference_cnt++; 1296 occ->peer->reference_cnt++;
1299 occ->cgh_ch = GST_cache_get_handle_core (occ->peer_id, 1297 occ->cgh_ch =
1300 occ->peer->details.local.cfg, 1298 GST_cache_get_handle_core (occ->peer_id, occ->peer->details.local.cfg,
1301 occ_cache_get_handle_core_cb, 1299 occ_cache_get_handle_core_cb, occ,
1302 occ, 1300 &occ->other_peer_identity,
1303 &occ->other_peer_identity, 1301 &overlay_connect_notify, occ);
1304 &overlay_connect_notify,
1305 occ);
1306 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1302 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1307} 1303}
1308 1304
@@ -1367,13 +1363,15 @@ timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1367 * @param ats_count number of entries in ats (excluding 0-termination) 1363 * @param ats_count number of entries in ats (excluding 0-termination)
1368 */ 1364 */
1369static void 1365static void
1370cache_transport_peer_connect_notify (void *cls, 1366cache_transport_peer_connect_notify (void *cls,
1371 const struct GNUNET_PeerIdentity *new_peer) 1367 const struct GNUNET_PeerIdentity *new_peer)
1372{ 1368{
1373 struct RemoteOverlayConnectCtx *rocc = cls; 1369 struct RemoteOverlayConnectCtx *rocc = cls;
1374 1370
1375 LOG_DEBUG ("0x%llx: Request Overlay connect notify\n", rocc->op_id); 1371 LOG_DEBUG ("0x%llx: Request Overlay connect notify\n", rocc->op_id);
1376 GNUNET_assert (0 == memcmp (new_peer, &rocc->a_id, sizeof (struct GNUNET_PeerIdentity))); 1372 GNUNET_assert (0 ==
1373 memcmp (new_peer, &rocc->a_id,
1374 sizeof (struct GNUNET_PeerIdentity)));
1377 LOG_DEBUG ("0x%llx: Peer %4s connected\n", rocc->op_id, 1375 LOG_DEBUG ("0x%llx: Peer %4s connected\n", rocc->op_id,
1378 GNUNET_i2s (&rocc->a_id)); 1376 GNUNET_i2s (&rocc->a_id));
1379 cleanup_rocc (rocc); 1377 cleanup_rocc (rocc);
@@ -1459,13 +1457,13 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1459 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 1457 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
1460 * @param ignore_ peer identity which is ignored in this callback 1458 * @param ignore_ peer identity which is ignored in this callback
1461 */ 1459 */
1462static void 1460static void
1463rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch, 1461rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1464 struct GNUNET_TRANSPORT_Handle *th, 1462 struct GNUNET_TRANSPORT_Handle *th,
1465 const struct GNUNET_PeerIdentity *ignore_) 1463 const struct GNUNET_PeerIdentity *ignore_)
1466{ 1464{
1467 struct RemoteOverlayConnectCtx *rocc = cls; 1465 struct RemoteOverlayConnectCtx *rocc = cls;
1468 1466
1469 if (NULL == th) 1467 if (NULL == th)
1470 { 1468 {
1471 rocc->timeout_rocc_task_id = 1469 rocc->timeout_rocc_task_id =
@@ -1474,8 +1472,8 @@ rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1474 } 1472 }
1475 rocc->tcc.th_ = th; 1473 rocc->tcc.th_ = th;
1476 rocc->tcc.pid = &rocc->a_id; 1474 rocc->tcc.pid = &rocc->a_id;
1477 if (GNUNET_YES == GNUNET_TRANSPORT_check_neighbour_connected (rocc->tcc.th_, 1475 if (GNUNET_YES ==
1478 rocc->tcc.pid)) 1476 GNUNET_TRANSPORT_check_neighbour_connected (rocc->tcc.th_, rocc->tcc.pid))
1479 { 1477 {
1480 LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n", 1478 LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n",
1481 rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); 1479 rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id);
@@ -1483,7 +1481,7 @@ rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1483 return; 1481 return;
1484 } 1482 }
1485 rocc->attempt_connect_task_id = 1483 rocc->attempt_connect_task_id =
1486 GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); 1484 GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc);
1487} 1485}
1488 1486
1489 1487
@@ -1559,11 +1557,9 @@ GST_handle_remote_overlay_connect (void *cls,
1559 rocc->peer->reference_cnt++; 1557 rocc->peer->reference_cnt++;
1560 rocc->hello = GNUNET_malloc (hsize); 1558 rocc->hello = GNUNET_malloc (hsize);
1561 memcpy (rocc->hello, msg->hello, hsize); 1559 memcpy (rocc->hello, msg->hello, hsize);
1562 rocc->tcc.cgh_th = 1560 rocc->tcc.cgh_th =
1563 GST_cache_get_handle_transport (peer_id, 1561 GST_cache_get_handle_transport (peer_id, rocc->peer->details.local.cfg,
1564 rocc->peer->details.local.cfg, 1562 &rocc_cache_get_handle_transport_cb, rocc,
1565 &rocc_cache_get_handle_transport_cb,
1566 rocc,
1567 &rocc->a_id, 1563 &rocc->a_id,
1568 &cache_transport_peer_connect_notify, 1564 &cache_transport_peer_connect_notify,
1569 rocc); 1565 rocc);
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index dd6822a41..6581fffe6 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -973,10 +973,10 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host,
973 if (0 < rc->num_hosts) 973 if (0 < rc->num_hosts)
974 { 974 {
975 old_hosts = rc->hosts; 975 old_hosts = rc->hosts;
976 rc->hosts = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) 976 rc->hosts =
977 * rc->num_hosts); 977 GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * rc->num_hosts);
978 memcpy (rc->hosts, &old_hosts[1], (sizeof (struct GNUNET_TESTBED_Host *) 978 memcpy (rc->hosts, &old_hosts[1],
979 * rc->num_hosts)); 979 (sizeof (struct GNUNET_TESTBED_Host *) * rc->num_hosts));
980 GNUNET_free (old_hosts); 980 GNUNET_free (old_hosts);
981 } 981 }
982 else 982 else