aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-27 16:04:58 +0000
committerChristian Grothoff <christian@grothoff.org>2015-10-27 16:04:58 +0000
commit2aee8da94c5aee59e4ffe2ce4ac9f0c984c4d570 (patch)
tree4ab489ffbe1820a1e871a169fd12c1da784b860d /src
parent94ac243261c531a8f9214645b387fe9e0bb33760 (diff)
downloadgnunet-2aee8da94c5aee59e4ffe2ce4ac9f0c984c4d570.tar.gz
gnunet-2aee8da94c5aee59e4ffe2ce4ac9f0c984c4d570.zip
stop using deprecated TRANSPORT_try_connect() API, use modern ATS connectivity suggestions instead
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed_connectionpool.c24
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c339
2 files changed, 201 insertions, 162 deletions
diff --git a/src/testbed/gnunet-service-testbed_connectionpool.c b/src/testbed/gnunet-service-testbed_connectionpool.c
index 4ca13ed42..3e21f9632 100644
--- a/src/testbed/gnunet-service-testbed_connectionpool.c
+++ b/src/testbed/gnunet-service-testbed_connectionpool.c
@@ -975,15 +975,19 @@ GST_connection_pool_get_handle_done (struct GST_ConnectionPool_GetHandle *gh)
975{ 975{
976 struct PooledConnection *entry; 976 struct PooledConnection *entry;
977 977
978 if (NULL == gh)
979 return;
978 entry = gh->entry; 980 entry = gh->entry;
979 LOG_DEBUG ("Cleaning up get handle %p for service %u, peer %u\n", 981 LOG_DEBUG ("Cleaning up get handle %p for service %u, peer %u\n",
980 gh, 982 gh,
981 gh->service, entry->index); 983 gh->service, entry->index);
982 if (!gh->connection_ready_called) 984 if (! gh->connection_ready_called)
983 { 985 {
984 GNUNET_CONTAINER_DLL_remove (entry->head_waiting, entry->tail_waiting, gh); 986 GNUNET_CONTAINER_DLL_remove (entry->head_waiting,
985 if ( (NULL == search_waiting (entry, entry->head_waiting)) 987 entry->tail_waiting,
986 && (NULL != entry->notify_task) ) 988 gh);
989 if ( (NULL == search_waiting (entry, entry->head_waiting)) &&
990 (NULL != entry->notify_task) )
987 { 991 {
988 GNUNET_SCHEDULER_cancel (entry->notify_task); 992 GNUNET_SCHEDULER_cancel (entry->notify_task);
989 entry->notify_task = NULL; 993 entry->notify_task = NULL;
@@ -991,14 +995,18 @@ GST_connection_pool_get_handle_done (struct GST_ConnectionPool_GetHandle *gh)
991 } 995 }
992 if (gh->notify_waiting) 996 if (gh->notify_waiting)
993 { 997 {
994 GNUNET_CONTAINER_DLL_remove (entry->head_notify, entry->tail_notify, gh); 998 GNUNET_CONTAINER_DLL_remove (entry->head_notify,
999 entry->tail_notify,
1000 gh);
995 gh->notify_waiting = 0; 1001 gh->notify_waiting = 0;
996 } 1002 }
997 GNUNET_free (gh); 1003 GNUNET_free (gh);
998 gh = NULL; 1004 gh = NULL;
999 GNUNET_assert (!entry->in_lru); 1005 GNUNET_assert (! entry->in_lru);
1000 if (!entry->in_pool) 1006 if (! entry->in_pool)
1001 GNUNET_CONTAINER_DLL_remove (head_not_pooled, tail_not_pooled, entry); 1007 GNUNET_CONTAINER_DLL_remove (head_not_pooled,
1008 tail_not_pooled,
1009 entry);
1002 if (NULL != map) 1010 if (NULL != map)
1003 { 1011 {
1004 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap32_contains (map, 1012 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap32_contains (map,
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index ca7f5dd14..ff5331fe4 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2008--2013 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2008--2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -38,14 +38,10 @@
38 38
39 39
40/** 40/**
41 * Context information for requesting TRANSPORT to connect to a peer 41 * Context information for requesting ATS to connect to a peer
42 */ 42 */
43struct TryConnectContext 43struct ConnectivitySuggestContext
44{ 44{
45 /**
46 * The identity of the peer to which the transport has to attempt a connection
47 */
48 struct GNUNET_PeerIdentity *pid;
49 45
50 /** 46 /**
51 * The transport handle obtained from cache. Do NOT close/disconnect. 47 * The transport handle obtained from cache. Do NOT close/disconnect.
@@ -53,29 +49,20 @@ struct TryConnectContext
53 struct GNUNET_TRANSPORT_Handle *th_; 49 struct GNUNET_TRANSPORT_Handle *th_;
54 50
55 /** 51 /**
56 * The GetCacheHandle for the p1th transport handle 52 * The GetCacheHandle for the peer2's transport handle
57 */ 53 * (used to offer the HELLO to the peer).
58 struct GST_ConnectionPool_GetHandle *cgh_th;
59
60 /**
61 * the try connect handle
62 */ 54 */
63 struct GNUNET_TRANSPORT_TryConnectHandle *tch; 55 struct GST_ConnectionPool_GetHandle *cgh_p2_th;
64 56
65 /** 57 /**
66 * The task handle 58 * The GetCacheHandle for the peer2's ATS handle.
67 */ 59 */
68 struct GNUNET_SCHEDULER_Task *task; 60 struct GST_ConnectionPool_GetHandle *cgh_p2_ats;
69 61
70 /** 62 /**
71 * The id of the operation which is resposible for this context 63 * The ATS handle for the connectivity suggestion.
72 */ 64 */
73 uint64_t op_id; 65 struct GNUNET_ATS_ConnectivitySuggestHandle *csh;
74
75 /**
76 * The number of times we attempted to connect
77 */
78 unsigned int retries;
79 66
80}; 67};
81 68
@@ -118,9 +105,9 @@ struct LocalPeer2Context
118 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; 105 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh;
119 106
120 /** 107 /**
121 * The transport TryConnectContext 108 * The transport ConnectivitySuggestContext
122 */ 109 */
123 struct TryConnectContext tcc; 110 struct ConnectivitySuggestContext tcc;
124}; 111};
125 112
126 113
@@ -151,7 +138,7 @@ struct RemotePeer2Context
151 138
152 /** 139 /**
153 * The neighbour handle. Only used if the type of overlay connection is 140 * The neighbour handle. Only used if the type of overlay connection is
154 * OCC_TYPE_REMOTE_LATERAL. 141 * #OCC_TYPE_REMOTE_LATERAL.
155 */ 142 */
156 struct Neighbour *p2n; 143 struct Neighbour *p2n;
157}; 144};
@@ -311,7 +298,7 @@ struct RemoteOverlayConnectCtx
311 /** 298 /**
312 * The transport try connect context 299 * The transport try connect context
313 */ 300 */
314 struct TryConnectContext tcc; 301 struct ConnectivitySuggestContext tcc;
315 302
316 /** 303 /**
317 * The peer identity of peer A 304 * The peer identity of peer A
@@ -474,12 +461,10 @@ cleanup_occ_lp2c (struct LocalPeer2Context *lp2c)
474{ 461{
475 if (NULL != lp2c->ohh) 462 if (NULL != lp2c->ohh)
476 GNUNET_TRANSPORT_offer_hello_cancel (lp2c->ohh); 463 GNUNET_TRANSPORT_offer_hello_cancel (lp2c->ohh);
477 if (NULL != lp2c->tcc.cgh_th) 464 GST_connection_pool_get_handle_done (lp2c->tcc.cgh_p2_th);
478 GST_connection_pool_get_handle_done (lp2c->tcc.cgh_th); 465 GST_connection_pool_get_handle_done (lp2c->tcc.cgh_p2_ats);
479 if (NULL != lp2c->tcc.tch) 466 if (NULL != lp2c->tcc.csh)
480 GNUNET_TRANSPORT_try_connect_cancel (lp2c->tcc.tch); 467 GNUNET_ATS_connectivity_suggest_cancel (lp2c->tcc.csh);
481 if (NULL != lp2c->tcc.task)
482 GNUNET_SCHEDULER_cancel (lp2c->tcc.task);
483} 468}
484 469
485 470
@@ -498,7 +483,6 @@ cleanup_occ_rp2c (struct RemotePeer2Context *rp2c)
498 GST_neighbour_get_connection_cancel (rp2c->ncn); 483 GST_neighbour_get_connection_cancel (rp2c->ncn);
499 if ( (NULL != rp2c->p2c) && (NULL != rp2c->p2n) ) 484 if ( (NULL != rp2c->p2c) && (NULL != rp2c->p2n) )
500 GST_neighbour_release_connection (rp2c->p2n); 485 GST_neighbour_release_connection (rp2c->p2n);
501
502} 486}
503 487
504/** 488/**
@@ -533,8 +517,7 @@ cleanup_occ (struct OverlayConnectContext *occ)
533 GST_connection_pool_get_handle_done (occ->cgh_ch); 517 GST_connection_pool_get_handle_done (occ->cgh_ch);
534 if (NULL != occ->ghh) 518 if (NULL != occ->ghh)
535 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh); 519 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
536 if (NULL != occ->cgh_p1th) 520 GST_connection_pool_get_handle_done (occ->cgh_p1th);
537 GST_connection_pool_get_handle_done (occ->cgh_p1th);
538 GNUNET_assert (NULL != GST_peer_list); 521 GNUNET_assert (NULL != GST_peer_list);
539 GNUNET_assert (occ->peer->reference_cnt > 0); 522 GNUNET_assert (occ->peer->reference_cnt > 0);
540 occ->peer->reference_cnt--; 523 occ->peer->reference_cnt--;
@@ -555,7 +538,9 @@ cleanup_occ (struct OverlayConnectContext *occ)
555 cleanup_occ_rp2c (&occ->p2ctx.remote); 538 cleanup_occ_rp2c (&occ->p2ctx.remote);
556 break; 539 break;
557 } 540 }
558 GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ); 541 GNUNET_CONTAINER_DLL_remove (occq_head,
542 occq_tail,
543 occ);
559 GNUNET_free (occ); 544 GNUNET_free (occ);
560} 545}
561 546
@@ -567,7 +552,8 @@ cleanup_occ (struct OverlayConnectContext *occ)
567 * @param tc the task context 552 * @param tc the task context
568 */ 553 */
569static void 554static void
570do_cleanup_occ (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 555do_cleanup_occ (void *cls,
556 const struct GNUNET_SCHEDULER_TaskContext *tc)
571{ 557{
572 struct OverlayConnectContext *occ = cls; 558 struct OverlayConnectContext *occ = cls;
573 559
@@ -629,7 +615,6 @@ overlay_connect_notify (void *cls,
629 const struct GNUNET_PeerIdentity *new_peer) 615 const struct GNUNET_PeerIdentity *new_peer)
630{ 616{
631 struct OverlayConnectContext *occ = cls; 617 struct OverlayConnectContext *occ = cls;
632 struct LocalPeer2Context *lp2c;
633 char *new_peer_str; 618 char *new_peer_str;
634 char *other_peer_str; 619 char *other_peer_str;
635 620
@@ -641,18 +626,22 @@ overlay_connect_notify (void *cls,
641 new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer)); 626 new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer));
642 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); 627 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
643 if (0 != 628 if (0 !=
644 memcmp (new_peer, &occ->other_peer_identity, 629 memcmp (new_peer,
630 &occ->other_peer_identity,
645 sizeof (struct GNUNET_PeerIdentity))) 631 sizeof (struct GNUNET_PeerIdentity)))
646 { 632 {
647 LOG_DEBUG ("Unexpected peer %4s connected when expecting peer %4s\n", 633 LOG_DEBUG ("Unexpected peer %s connected when expecting peer %s\n",
648 new_peer_str, other_peer_str); 634 new_peer_str,
635 other_peer_str);
649 GNUNET_free (new_peer_str); 636 GNUNET_free (new_peer_str);
650 GNUNET_free (other_peer_str); 637 GNUNET_free (other_peer_str);
651 return; 638 return;
652 } 639 }
653 GNUNET_free (new_peer_str); 640 GNUNET_free (new_peer_str);
654 LOG_DEBUG ("0x%llx: Peer %4s connected to peer %4s\n", occ->op_id, 641 LOG_DEBUG ("0x%llx: Peer %s connected to peer %s\n",
655 other_peer_str, GNUNET_i2s (&occ->peer_identity)); 642 occ->op_id,
643 other_peer_str,
644 GNUNET_i2s (&occ->peer_identity));
656 GNUNET_free (other_peer_str); 645 GNUNET_free (other_peer_str);
657 if (NULL != occ->send_hello_task) 646 if (NULL != occ->send_hello_task)
658 { 647 {
@@ -662,15 +651,6 @@ overlay_connect_notify (void *cls,
662 GNUNET_assert (NULL != occ->timeout_task); 651 GNUNET_assert (NULL != occ->timeout_task);
663 GNUNET_SCHEDULER_cancel (occ->timeout_task); 652 GNUNET_SCHEDULER_cancel (occ->timeout_task);
664 occ->timeout_task = NULL; 653 occ->timeout_task = NULL;
665 if (OCC_TYPE_LOCAL == occ->type)
666 {
667 lp2c = &occ->p2ctx.local;
668 if (NULL != lp2c->tcc.task)
669 {
670 GNUNET_SCHEDULER_cancel (lp2c->tcc.task);
671 lp2c->tcc.task = NULL;
672 }
673 }
674 GNUNET_free_non_null (occ->emsg); 654 GNUNET_free_non_null (occ->emsg);
675 occ->emsg = NULL; 655 occ->emsg = NULL;
676 send_overlay_connect_success_msg (occ); 656 send_overlay_connect_success_msg (occ);
@@ -679,62 +659,76 @@ overlay_connect_notify (void *cls,
679 659
680 660
681/** 661/**
682 * Task to ask transport of a peer to connect to another peer 662 * Callback from cache with needed ATS handle set
683 * 663 *
684 * @param cls the TryConnectContext 664 * @param cls a `struct OverlayConnectCtx *`
685 * @param tc the scheduler task context 665 * @param ch the handle to CORE. Can be NULL if it is not requested
666 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
667 * @param ac the handle to ATS. Can be NULL if it is not requested
668 * @param my_identity the identity of our peer
686 */ 669 */
687static void 670static void
688try_connect_task (void *cls, 671occ_cache_get_handle_ats_occ_cb (void *cls,
689 const struct GNUNET_SCHEDULER_TaskContext *tc); 672 struct GNUNET_CORE_Handle *ch,
673 struct GNUNET_TRANSPORT_Handle *th,
674 struct GNUNET_ATS_ConnectivityHandle *ac,
675 const struct GNUNET_PeerIdentity *my_identity)
676{
677 struct OverlayConnectContext *occ = cls;
678 struct LocalPeer2Context *lp2c;
690 679
680 GNUNET_assert (OCC_TYPE_LOCAL == occ->type);
681 GNUNET_assert (NULL != occ->timeout_task);
682 GNUNET_free_non_null (occ->emsg);
683 if (NULL == ac)
684 {
685 GNUNET_asprintf (&occ->emsg,
686 "0x%llx: Failed to connect to ATS of peer with id: %u",
687 occ->op_id,
688 occ->peer->id);
689 GNUNET_SCHEDULER_cancel (occ->timeout_task);
690 occ->timeout_task =
691 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect,
692 occ);
693 return;
694 }
695 occ->emsg = NULL;
691 696
692/** 697 GNUNET_asprintf (&occ->emsg,
693 * Callback to be called with result of the try connect request. 698 "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s",
694 * 699 occ->op_id,
695 * @param cls the overlay connect context 700 GNUNET_i2s (&occ->other_peer_identity));
696 * @param result #GNUNET_OK if message was transmitted to transport service 701
697 * #GNUNET_SYSERR if message was not transmitted to transport service 702 lp2c = &occ->p2ctx.local;
698 */ 703 lp2c->tcc.csh =
699static void 704 GNUNET_ATS_connectivity_suggest (ac,
700try_connect_cb (void *cls, 705 &occ->peer_identity,
701 const int result) 706 1);
702{
703 struct TryConnectContext *tcc = cls;
704
705 tcc->tch = NULL;
706 GNUNET_assert (NULL == tcc->task);
707 tcc->task =
708 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
709 (GNUNET_TIME_UNIT_MILLISECONDS,
710 500 + pow (2, ++tcc->retries)),
711 &try_connect_task, tcc);
712} 707}
713 708
714 709
715/** 710/**
716 * Task to ask transport of a peer to connect to another peer 711 * Callback from cache with needed ATS handle set
717 * 712 *
718 * @param cls the TryConnectContext 713 * @param cls a `struct RemoteOverlayConnectCtx *`
719 * @param tc the scheduler task context 714 * @param ch the handle to CORE. Can be NULL if it is not requested
715 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
716 * @param ac the handle to ATS. Can be NULL if it is not requested
717 * @param my_identity the identity of our peer
720 */ 718 */
721static void 719static void
722try_connect_task (void *cls, 720occ_cache_get_handle_ats_rocc_cb (void *cls,
723 const struct GNUNET_SCHEDULER_TaskContext *tc) 721 struct GNUNET_CORE_Handle *ch,
722 struct GNUNET_TRANSPORT_Handle *th,
723 struct GNUNET_ATS_ConnectivityHandle *ac,
724 const struct GNUNET_PeerIdentity *my_identity)
724{ 725{
725 struct TryConnectContext *tcc = cls; 726 struct RemoteOverlayConnectCtx *rocc = cls;
726 727
727 tcc->task = NULL; 728 rocc->tcc.csh =
728 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 729 GNUNET_ATS_connectivity_suggest (ac,
729 return; 730 &rocc->a_id,
730 GNUNET_assert (NULL == tcc->tch); 731 1);
731 GNUNET_assert (NULL != tcc->pid);
732 GNUNET_assert (NULL != tcc->th_);
733 GNUNET_assert (NULL != tcc->cgh_th);
734 LOG_DEBUG ("0x%llx: Trail %u to connect to peer %4s\n", tcc->op_id,
735 tcc->retries, GNUNET_i2s (tcc->pid));
736 tcc->tch =
737 GNUNET_TRANSPORT_try_connect (tcc->th_, tcc->pid, &try_connect_cb, tcc);
738} 732}
739 733
740 734
@@ -764,10 +758,12 @@ occ_hello_sent_cb (void *cls,
764{ 758{
765 struct OverlayConnectContext *occ = cls; 759 struct OverlayConnectContext *occ = cls;
766 struct LocalPeer2Context *lp2c; 760 struct LocalPeer2Context *lp2c;
761 struct Peer *peer2;
767 762
768 GNUNET_assert (OCC_TYPE_LOCAL == occ->type); 763 GNUNET_assert (OCC_TYPE_LOCAL == occ->type);
769 lp2c = &occ->p2ctx.local; 764 lp2c = &occ->p2ctx.local;
770 lp2c->ohh = NULL; 765 lp2c->ohh = NULL;
766
771 GNUNET_assert (NULL == occ->send_hello_task); 767 GNUNET_assert (NULL == occ->send_hello_task);
772 if (GNUNET_SCHEDULER_REASON_TIMEOUT == tc->reason) 768 if (GNUNET_SCHEDULER_REASON_TIMEOUT == tc->reason)
773 { 769 {
@@ -775,19 +771,25 @@ occ_hello_sent_cb (void *cls,
775 GNUNET_asprintf (&occ->emsg, 771 GNUNET_asprintf (&occ->emsg,
776 "0x%llx: Timeout while offering HELLO to other peer", 772 "0x%llx: Timeout while offering HELLO to other peer",
777 occ->op_id); 773 occ->op_id);
778 occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); 774 occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello,
775 occ);
779 return; 776 return;
780 } 777 }
781 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) 778 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason)
782 return; 779 return;
783 GNUNET_free_non_null (occ->emsg); 780 GNUNET_free_non_null (occ->emsg);
781
784 GNUNET_asprintf (&occ->emsg, 782 GNUNET_asprintf (&occ->emsg,
785 "0x%llx: Timeout during TRANSPORT_try_connect() " 783 "0x%llx: Timeout while acquiring ATS of %s from cache",
786 "at peer %4s", occ->op_id, 784 occ->op_id,
787 GNUNET_i2s(&occ->other_peer_identity)); 785 GNUNET_i2s (&occ->other_peer_identity));
788 lp2c->tcc.pid = &occ->peer_identity; 786 GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
789 lp2c->tcc.op_id = occ->op_id; 787 lp2c->tcc.cgh_p2_ats =
790 lp2c->tcc.task = GNUNET_SCHEDULER_add_now (&try_connect_task, &lp2c->tcc); 788 GST_connection_pool_get_handle (occ->other_peer_id,
789 peer2->details.local.cfg,
790 GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY,
791 &occ_cache_get_handle_ats_occ_cb,
792 occ, NULL, NULL, NULL);
791} 793}
792 794
793 795
@@ -798,7 +800,7 @@ occ_hello_sent_cb (void *cls,
798 * @param occ the overlay connect context. Its type must be either 800 * @param occ the overlay connect context. Its type must be either
799 * #OCC_TYPE_REMOTE_SLAVE or #OCC_TYPE_REMOTE_LATERAL 801 * #OCC_TYPE_REMOTE_SLAVE or #OCC_TYPE_REMOTE_LATERAL
800 */ 802 */
801void 803static void
802send_hello_thru_rocc (struct OverlayConnectContext *occ) 804send_hello_thru_rocc (struct OverlayConnectContext *occ)
803{ 805{
804 struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg; 806 struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg;
@@ -809,24 +811,26 @@ send_hello_thru_rocc (struct OverlayConnectContext *occ)
809 GNUNET_assert (OCC_TYPE_LOCAL != occ->type); 811 GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
810 GNUNET_assert (NULL != occ->hello); 812 GNUNET_assert (NULL != occ->hello);
811 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); 813 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
812 LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote " 814 LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote Overlay Request\n",
813 "Overlay Request\n", occ->op_id, 815 occ->op_id,
814 GNUNET_i2s (&occ->peer_identity), ntohs (occ->hello->size), 816 GNUNET_i2s (&occ->peer_identity),
817 ntohs (occ->hello->size),
815 other_peer_str); 818 other_peer_str);
816 GNUNET_free (other_peer_str); 819 GNUNET_free (other_peer_str);
817 hello_size = ntohs (occ->hello->size); 820 hello_size = ntohs (occ->hello->size);
818 msize = 821 msize = sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hello_size;
819 sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hello_size;
820 msg = GNUNET_malloc (msize); 822 msg = GNUNET_malloc (msize);
821 msg->header.type = 823 msg->header.type =
822 htons (GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT); 824 htons (GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT);
823 msg->header.size = htons (msize); 825 msg->header.size = htons (msize);
824 msg->peer = htonl (occ->other_peer_id); 826 msg->peer = htonl (occ->other_peer_id);
825 msg->operation_id = GNUNET_htonll (occ->op_id); 827 msg->operation_id = GNUNET_htonll (occ->op_id);
826 (void) memcpy (&msg->peer_identity, &occ->peer_identity, 828 msg->peer_identity = occ->peer_identity;
827 sizeof (struct GNUNET_PeerIdentity)); 829 memcpy (msg->hello,
828 memcpy (msg->hello, occ->hello, hello_size); 830 occ->hello,
829 GNUNET_TESTBED_queue_message_ (occ->p2ctx.remote.p2c, &msg->header); 831 hello_size);
832 GNUNET_TESTBED_queue_message_ (occ->p2ctx.remote.p2c,
833 &msg->header);
830} 834}
831 835
832 836
@@ -857,12 +861,16 @@ send_hello (void *cls,
857 } 861 }
858 lp2c = &occ->p2ctx.local; 862 lp2c = &occ->p2ctx.local;
859 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); 863 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
860 LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n", occ->op_id, 864 LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n",
861 GNUNET_i2s (&occ->peer_identity), other_peer_str); 865 occ->op_id,
866 GNUNET_i2s (&occ->peer_identity),
867 other_peer_str);
862 GNUNET_free (other_peer_str); 868 GNUNET_free (other_peer_str);
863 lp2c->ohh = 869 lp2c->ohh =
864 GNUNET_TRANSPORT_offer_hello (lp2c->tcc.th_, occ->hello, 870 GNUNET_TRANSPORT_offer_hello (lp2c->tcc.th_,
865 occ_hello_sent_cb, occ); 871 occ->hello,
872 occ_hello_sent_cb,
873 occ);
866 if (NULL == lp2c->ohh) 874 if (NULL == lp2c->ohh)
867 { 875 {
868 GNUNET_break (0); 876 GNUNET_break (0);
@@ -900,7 +908,8 @@ p2_transport_connect_cache_callback (void *cls,
900 { 908 {
901 GNUNET_asprintf (&occ->emsg, 909 GNUNET_asprintf (&occ->emsg,
902 "0x%llx: Cannot connect to TRANSPORT of %s", 910 "0x%llx: Cannot connect to TRANSPORT of %s",
903 occ->op_id, GNUNET_i2s (&occ->other_peer_identity)); 911 occ->op_id,
912 GNUNET_i2s (&occ->other_peer_identity));
904 GNUNET_SCHEDULER_cancel (occ->timeout_task); 913 GNUNET_SCHEDULER_cancel (occ->timeout_task);
905 occ->timeout_task = 914 occ->timeout_task =
906 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 915 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
@@ -934,7 +943,7 @@ p2_transport_connect (struct OverlayConnectContext *occ)
934 if (OCC_TYPE_LOCAL == occ->type) 943 if (OCC_TYPE_LOCAL == occ->type)
935 { 944 {
936 GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id])); 945 GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
937 occ->p2ctx.local.tcc.cgh_th = 946 occ->p2ctx.local.tcc.cgh_p2_th =
938 GST_connection_pool_get_handle (occ->other_peer_id, 947 GST_connection_pool_get_handle (occ->other_peer_id,
939 peer2->details.local.cfg, 948 peer2->details.local.cfg,
940 GST_CONNECTIONPOOL_SERVICE_TRANSPORT, 949 GST_CONNECTIONPOOL_SERVICE_TRANSPORT,
@@ -956,7 +965,7 @@ p2_transport_connect (struct OverlayConnectContext *occ)
956 * @param cls empty flag to set 965 * @param cls empty flag to set
957 * @param address the HELLO 966 * @param address the HELLO
958 * @param expiration expiration of the HELLO 967 * @param expiration expiration of the HELLO
959 * @return 968 * @return #GNUNET_OK
960 */ 969 */
961static int 970static int
962test_address (void *cls, 971test_address (void *cls,
@@ -1061,7 +1070,7 @@ p1_transport_connect_cache_callback (void *cls,
1061 1070
1062 1071
1063/** 1072/**
1064 * Callback from cache with needed handles set 1073 * Callback from cache with needed CORE handle set
1065 * 1074 *
1066 * @param cls the closure passed to GST_cache_get_handle_transport() 1075 * @param cls the closure passed to GST_cache_get_handle_transport()
1067 * @param ch the handle to CORE. Can be NULL if it is not requested 1076 * @param ch the handle to CORE. Can be NULL if it is not requested
@@ -1095,24 +1104,26 @@ occ_cache_get_handle_core_cb (void *cls,
1095 } 1104 }
1096 occ->emsg = NULL; 1105 occ->emsg = NULL;
1097 if (GNUNET_YES == 1106 if (GNUNET_YES ==
1098 GNUNET_CORE_is_peer_connected_sync (ch, &occ->other_peer_identity)) 1107 GNUNET_CORE_is_peer_connected_sync (ch,
1108 &occ->other_peer_identity))
1099 { 1109 {
1100 LOG_DEBUG ("0x%llx: Target peer already connected\n", occ->op_id); 1110 LOG_DEBUG ("0x%llx: Target peer already connected\n",
1111 occ->op_id);
1101 GNUNET_SCHEDULER_cancel (occ->timeout_task); 1112 GNUNET_SCHEDULER_cancel (occ->timeout_task);
1102 occ->timeout_task = NULL; 1113 occ->timeout_task = NULL;
1103 send_overlay_connect_success_msg (occ); 1114 send_overlay_connect_success_msg (occ);
1104 occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ); 1115 occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ);
1105 return; 1116 return;
1106 } 1117 }
1107 memcpy (&occ->peer_identity, my_identity, 1118 occ->peer_identity = *my_identity;
1108 sizeof (struct GNUNET_PeerIdentity));
1109 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", 1119 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
1110 occ->op_id, 1120 occ->op_id,
1111 GNUNET_i2s (&occ->peer_identity)); 1121 GNUNET_i2s (&occ->peer_identity));
1112 /* Lookup for HELLO in hello cache */ 1122 /* Lookup for HELLO in hello cache */
1113 if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id))) 1123 if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id)))
1114 { 1124 {
1115 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", occ->op_id, 1125 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n",
1126 occ->op_id,
1116 GNUNET_i2s (&occ->peer_identity)); 1127 GNUNET_i2s (&occ->peer_identity));
1117 occ->hello = GNUNET_copy_message (hello); 1128 occ->hello = GNUNET_copy_message (hello);
1118 p2_transport_connect (occ); 1129 p2_transport_connect (occ);
@@ -1120,12 +1131,14 @@ occ_cache_get_handle_core_cb (void *cls,
1120 } 1131 }
1121 GNUNET_asprintf (&occ->emsg, 1132 GNUNET_asprintf (&occ->emsg,
1122 "0x%llx: Timeout while acquiring TRANSPORT of %s from cache", 1133 "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
1123 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 1134 occ->op_id,
1135 GNUNET_i2s (&occ->peer_identity));
1124 occ->cgh_p1th = 1136 occ->cgh_p1th =
1125 GST_connection_pool_get_handle (occ->peer->id, 1137 GST_connection_pool_get_handle (occ->peer->id,
1126 occ->peer->details.local.cfg, 1138 occ->peer->details.local.cfg,
1127 GST_CONNECTIONPOOL_SERVICE_TRANSPORT, 1139 GST_CONNECTIONPOOL_SERVICE_TRANSPORT,
1128 p1_transport_connect_cache_callback, occ, 1140 p1_transport_connect_cache_callback,
1141 occ,
1129 NULL, NULL, NULL); 1142 NULL, NULL, NULL);
1130} 1143}
1131 1144
@@ -1568,25 +1581,27 @@ GST_handle_overlay_connect (void *cls,
1568static void 1581static void
1569cleanup_rocc (struct RemoteOverlayConnectCtx *rocc) 1582cleanup_rocc (struct RemoteOverlayConnectCtx *rocc)
1570{ 1583{
1571 LOG_DEBUG ("0x%llx: Cleaning up rocc\n", rocc->op_id); 1584 LOG_DEBUG ("0x%llx: Cleaning up rocc\n",
1585 rocc->op_id);
1572 if (NULL != rocc->attempt_connect_task_id) 1586 if (NULL != rocc->attempt_connect_task_id)
1573 GNUNET_SCHEDULER_cancel (rocc->attempt_connect_task_id); 1587 GNUNET_SCHEDULER_cancel (rocc->attempt_connect_task_id);
1574 if (NULL != rocc->timeout_rocc_task_id) 1588 if (NULL != rocc->timeout_rocc_task_id)
1575 GNUNET_SCHEDULER_cancel (rocc->timeout_rocc_task_id); 1589 GNUNET_SCHEDULER_cancel (rocc->timeout_rocc_task_id);
1576 if (NULL != rocc->ohh) 1590 if (NULL != rocc->ohh)
1577 GNUNET_TRANSPORT_offer_hello_cancel (rocc->ohh); 1591 GNUNET_TRANSPORT_offer_hello_cancel (rocc->ohh);
1578 if (NULL != rocc->tcc.tch) 1592 if (NULL != rocc->tcc.csh)
1579 GNUNET_TRANSPORT_try_connect_cancel (rocc->tcc.tch); 1593 GNUNET_ATS_connectivity_suggest_cancel (rocc->tcc.csh);
1580 if (NULL != rocc->tcc.task) 1594 GST_connection_pool_get_handle_done (rocc->tcc.cgh_p2_th);
1581 GNUNET_SCHEDULER_cancel (rocc->tcc.task); 1595 GST_connection_pool_get_handle_done (rocc->tcc.cgh_p2_ats);
1582 GST_connection_pool_get_handle_done (rocc->tcc.cgh_th);
1583 GNUNET_assert (rocc->peer->reference_cnt > 0); 1596 GNUNET_assert (rocc->peer->reference_cnt > 0);
1584 rocc->peer->reference_cnt--; 1597 rocc->peer->reference_cnt--;
1585 if ((GNUNET_YES == rocc->peer->destroy_flag) && 1598 if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1586 (0 == rocc->peer->reference_cnt)) 1599 (0 == rocc->peer->reference_cnt))
1587 GST_destroy_peer (rocc->peer); 1600 GST_destroy_peer (rocc->peer);
1588 GNUNET_free_non_null (rocc->hello); 1601 GNUNET_free_non_null (rocc->hello);
1589 GNUNET_CONTAINER_DLL_remove (roccq_head, roccq_tail, rocc); 1602 GNUNET_CONTAINER_DLL_remove (roccq_head,
1603 roccq_tail,
1604 rocc);
1590 GNUNET_free (rocc); 1605 GNUNET_free (rocc);
1591} 1606}
1592 1607
@@ -1629,7 +1644,7 @@ cache_transport_peer_connect_notify (void *cls,
1629 GNUNET_assert (0 == 1644 GNUNET_assert (0 ==
1630 memcmp (new_peer, &rocc->a_id, 1645 memcmp (new_peer, &rocc->a_id,
1631 sizeof (struct GNUNET_PeerIdentity))); 1646 sizeof (struct GNUNET_PeerIdentity)));
1632 LOG_DEBUG ("0x%llx: Peer %4s connected\n", 1647 LOG_DEBUG ("0x%llx: Peer %s connected\n",
1633 rocc->op_id, 1648 rocc->op_id,
1634 GNUNET_i2s (&rocc->a_id)); 1649 GNUNET_i2s (&rocc->a_id));
1635 cleanup_rocc (rocc); 1650 cleanup_rocc (rocc);
@@ -1664,13 +1679,16 @@ rocc_hello_sent_cb (void *cls,
1664 1679
1665 rocc->ohh = NULL; 1680 rocc->ohh = NULL;
1666 GNUNET_assert (NULL == rocc->attempt_connect_task_id); 1681 GNUNET_assert (NULL == rocc->attempt_connect_task_id);
1667 LOG_DEBUG ("0x%llx: HELLO of peer %4s sent to local peer with id: %u\n", 1682 LOG_DEBUG ("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n",
1668 rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); 1683 rocc->op_id,
1684 GNUNET_i2s (&rocc->a_id),
1685 rocc->peer->id);
1669 if (GNUNET_SCHEDULER_REASON_TIMEOUT == tc->reason) 1686 if (GNUNET_SCHEDULER_REASON_TIMEOUT == tc->reason)
1670 { 1687 {
1671 GNUNET_break (0); 1688 GNUNET_break (0);
1672 rocc->attempt_connect_task_id = 1689 rocc->attempt_connect_task_id =
1673 GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); 1690 GNUNET_SCHEDULER_add_now (&attempt_connect_task,
1691 rocc);
1674 return; 1692 return;
1675 } 1693 }
1676 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) 1694 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason)
@@ -1678,7 +1696,14 @@ rocc_hello_sent_cb (void *cls,
1678 GNUNET_break (0); 1696 GNUNET_break (0);
1679 return; 1697 return;
1680 } 1698 }
1681 rocc->tcc.task = GNUNET_SCHEDULER_add_now (&try_connect_task, &rocc->tcc); 1699
1700 rocc->tcc.cgh_p2_ats =
1701 GST_connection_pool_get_handle (rocc->peer->id,
1702 rocc->peer->details.local.cfg,
1703 GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY,
1704 &occ_cache_get_handle_ats_rocc_cb,
1705 rocc, NULL, NULL, NULL);
1706
1682} 1707}
1683 1708
1684 1709
@@ -1697,10 +1722,13 @@ attempt_connect_task (void *cls,
1697 1722
1698 GNUNET_assert (NULL != rocc->attempt_connect_task_id); 1723 GNUNET_assert (NULL != rocc->attempt_connect_task_id);
1699 rocc->attempt_connect_task_id = NULL; 1724 rocc->attempt_connect_task_id = NULL;
1700 LOG_DEBUG ("0x%llx: Offering HELLO of peer %4s to local peer with id: %u\n", 1725 LOG_DEBUG ("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n",
1701 rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); 1726 rocc->op_id,
1727 GNUNET_i2s (&rocc->a_id),
1728 rocc->peer->id);
1702 rocc->ohh = 1729 rocc->ohh =
1703 GNUNET_TRANSPORT_offer_hello (rocc->tcc.th_, rocc->hello, 1730 GNUNET_TRANSPORT_offer_hello (rocc->tcc.th_,
1731 rocc->hello,
1704 rocc_hello_sent_cb, rocc); 1732 rocc_hello_sent_cb, rocc);
1705 if (NULL == rocc->ohh) 1733 if (NULL == rocc->ohh)
1706 rocc->attempt_connect_task_id = 1734 rocc->attempt_connect_task_id =
@@ -1738,12 +1766,11 @@ rocc_cache_get_handle_transport_cb (void *cls,
1738 return; 1766 return;
1739 } 1767 }
1740 rocc->tcc.th_ = th; 1768 rocc->tcc.th_ = th;
1741 rocc->tcc.pid = &rocc->a_id;
1742 if (GNUNET_YES == 1769 if (GNUNET_YES ==
1743 GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_, 1770 GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_,
1744 rocc->tcc.pid)) 1771 &rocc->a_id))
1745 { 1772 {
1746 LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n", 1773 LOG_DEBUG ("0x%llx: Target peer %s already connected to local peer: %u\n",
1747 rocc->op_id, 1774 rocc->op_id,
1748 GNUNET_i2s (&rocc->a_id), 1775 GNUNET_i2s (&rocc->a_id),
1749 rocc->peer->id); 1776 rocc->peer->id);
@@ -1819,12 +1846,16 @@ GST_handle_remote_overlay_connect (void *cls,
1819 } 1846 }
1820 rocc = GNUNET_new (struct RemoteOverlayConnectCtx); 1847 rocc = GNUNET_new (struct RemoteOverlayConnectCtx);
1821 rocc->op_id = GNUNET_ntohll (msg->operation_id); 1848 rocc->op_id = GNUNET_ntohll (msg->operation_id);
1822 GNUNET_CONTAINER_DLL_insert_tail (roccq_head, roccq_tail, rocc); 1849 GNUNET_CONTAINER_DLL_insert_tail (roccq_head,
1823 memcpy (&rocc->a_id, &msg->peer_identity, 1850 roccq_tail,
1824 sizeof (struct GNUNET_PeerIdentity)); 1851 rocc);
1825 GNUNET_TESTING_peer_get_identity (peer->details.local.peer, &pid); 1852 rocc->a_id = msg->peer_identity;
1826 (void) strncpy (pid_str, GNUNET_i2s (&pid), 15); 1853 GNUNET_TESTING_peer_get_identity (peer->details.local.peer,
1827 LOG_DEBUG ("0x%llx: Remote overlay connect %4s to peer %4s with hello size: %u\n", 1854 &pid);
1855 (void) strncpy (pid_str,
1856 GNUNET_i2s (&pid),
1857 15);
1858 LOG_DEBUG ("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1828 rocc->op_id, 1859 rocc->op_id,
1829 pid_str, 1860 pid_str,
1830 GNUNET_i2s (&rocc->a_id), 1861 GNUNET_i2s (&rocc->a_id),
@@ -1833,8 +1864,7 @@ GST_handle_remote_overlay_connect (void *cls,
1833 rocc->peer->reference_cnt++; 1864 rocc->peer->reference_cnt++;
1834 rocc->hello = GNUNET_malloc (hsize); 1865 rocc->hello = GNUNET_malloc (hsize);
1835 memcpy (rocc->hello, msg->hello, hsize); 1866 memcpy (rocc->hello, msg->hello, hsize);
1836 rocc->tcc.op_id = rocc->op_id; 1867 rocc->tcc.cgh_p2_th =
1837 rocc->tcc.cgh_th =
1838 GST_connection_pool_get_handle (peer_id, 1868 GST_connection_pool_get_handle (peer_id,
1839 rocc->peer->details.local.cfg, 1869 rocc->peer->details.local.cfg,
1840 GST_CONNECTIONPOOL_SERVICE_TRANSPORT, 1870 GST_CONNECTIONPOOL_SERVICE_TRANSPORT,
@@ -1847,7 +1877,8 @@ GST_handle_remote_overlay_connect (void *cls,
1847 GNUNET_SCHEDULER_add_delayed (GST_timeout, 1877 GNUNET_SCHEDULER_add_delayed (GST_timeout,
1848 &timeout_rocc_task, 1878 &timeout_rocc_task,
1849 rocc); 1879 rocc);
1850 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1880 GNUNET_SERVER_receive_done (client,
1881 GNUNET_OK);
1851} 1882}
1852 1883
1853 1884