aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-service-testbed_oc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-27 14:49:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-10-27 14:49:03 +0000
commit6b048559eadd3e57fda24a23d3f3b4681d4e1408 (patch)
tree88c6f0ab9f0dda3d090f95adfd365078e6ed3b1a /src/testbed/gnunet-service-testbed_oc.c
parent57d4c0d631fc90945e92f264c841068a8be6565f (diff)
downloadgnunet-6b048559eadd3e57fda24a23d3f3b4681d4e1408.tar.gz
gnunet-6b048559eadd3e57fda24a23d3f3b4681d4e1408.zip
prepare testbed for #3675 by having an option to establish connections to ATS
Diffstat (limited to 'src/testbed/gnunet-service-testbed_oc.c')
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c61
1 files changed, 42 insertions, 19 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index bb3a04e93..ca7f5dd14 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -625,7 +625,8 @@ send_overlay_connect_success_msg (struct OverlayConnectContext *occ)
625 * @param new_peer the peer that connected 625 * @param new_peer the peer that connected
626 */ 626 */
627static void 627static void
628overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer) 628overlay_connect_notify (void *cls,
629 const struct GNUNET_PeerIdentity *new_peer)
629{ 630{
630 struct OverlayConnectContext *occ = cls; 631 struct OverlayConnectContext *occ = cls;
631 struct LocalPeer2Context *lp2c; 632 struct LocalPeer2Context *lp2c;
@@ -684,18 +685,20 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer)
684 * @param tc the scheduler task context 685 * @param tc the scheduler task context
685 */ 686 */
686static void 687static void
687try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 688try_connect_task (void *cls,
689 const struct GNUNET_SCHEDULER_TaskContext *tc);
688 690
689 691
690/** 692/**
691 * Callback to be called with result of the try connect request. 693 * Callback to be called with result of the try connect request.
692 * 694 *
693 * @param cls the overlay connect context 695 * @param cls the overlay connect context
694 * @param result GNUNET_OK if message was transmitted to transport service 696 * @param result #GNUNET_OK if message was transmitted to transport service
695 * GNUNET_SYSERR if message was not transmitted to transport service 697 * #GNUNET_SYSERR if message was not transmitted to transport service
696 */ 698 */
697static void 699static void
698try_connect_cb (void *cls, const int result) 700try_connect_cb (void *cls,
701 const int result)
699{ 702{
700 struct TryConnectContext *tcc = cls; 703 struct TryConnectContext *tcc = cls;
701 704
@@ -716,7 +719,8 @@ try_connect_cb (void *cls, const int result)
716 * @param tc the scheduler task context 719 * @param tc the scheduler task context
717 */ 720 */
718static void 721static void
719try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 722try_connect_task (void *cls,
723 const struct GNUNET_SCHEDULER_TaskContext *tc)
720{ 724{
721 struct TryConnectContext *tcc = cls; 725 struct TryConnectContext *tcc = cls;
722 726
@@ -742,7 +746,8 @@ try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
742 * @param tc the TaskContext from scheduler 746 * @param tc the TaskContext from scheduler
743 */ 747 */
744static void 748static void
745send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 749send_hello (void *cls,
750 const struct GNUNET_SCHEDULER_TaskContext *tc);
746 751
747 752
748/** 753/**
@@ -750,11 +755,12 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
750 * 755 *
751 * @param cls the overlay connect context 756 * @param cls the overlay connect context
752 * @param tc the scheduler task context; if tc->reason = 757 * @param tc the scheduler task context; if tc->reason =
753 * GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if 758 * #GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if
754 * GNUNET_SCHEDULER_REASON_READ_READY is succeeded 759 * #GNUNET_SCHEDULER_REASON_READ_READY is succeeded
755 */ 760 */
756static void 761static void
757occ_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 762occ_hello_sent_cb (void *cls,
763 const struct GNUNET_SCHEDULER_TaskContext *tc)
758{ 764{
759 struct OverlayConnectContext *occ = cls; 765 struct OverlayConnectContext *occ = cls;
760 struct LocalPeer2Context *lp2c; 766 struct LocalPeer2Context *lp2c;
@@ -790,7 +796,7 @@ occ_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
790 * request. 796 * request.
791 * 797 *
792 * @param occ the overlay connect context. Its type must be either 798 * @param occ the overlay connect context. Its type must be either
793 * OCC_TYPE_REMOTE_SLAVE or OCC_TYPE_REMOTE_LATERAL 799 * #OCC_TYPE_REMOTE_SLAVE or #OCC_TYPE_REMOTE_LATERAL
794 */ 800 */
795void 801void
796send_hello_thru_rocc (struct OverlayConnectContext *occ) 802send_hello_thru_rocc (struct OverlayConnectContext *occ)
@@ -877,12 +883,14 @@ send_hello (void *cls,
877 * @param cls the closure passed to GST_cache_get_handle_transport() 883 * @param cls the closure passed to GST_cache_get_handle_transport()
878 * @param ch the handle to CORE. Can be NULL if it is not requested 884 * @param ch the handle to CORE. Can be NULL if it is not requested
879 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 885 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
886 * @param ac the handle to ATS. Can be NULL if it is not requested
880 * @param ignore_ peer identity which is ignored in this callback 887 * @param ignore_ peer identity which is ignored in this callback
881 */ 888 */
882static void 889static void
883p2_transport_connect_cache_callback (void *cls, 890p2_transport_connect_cache_callback (void *cls,
884 struct GNUNET_CORE_Handle *ch, 891 struct GNUNET_CORE_Handle *ch,
885 struct GNUNET_TRANSPORT_Handle *th, 892 struct GNUNET_TRANSPORT_Handle *th,
893 struct GNUNET_ATS_ConnectivityHandle *ac,
886 const struct GNUNET_PeerIdentity *ignore_) 894 const struct GNUNET_PeerIdentity *ignore_)
887{ 895{
888 struct OverlayConnectContext *occ = cls; 896 struct OverlayConnectContext *occ = cls;
@@ -1014,11 +1022,14 @@ hello_update_cb (void *cls,
1014 * @param cls the closure passed to GST_cache_get_handle_transport() 1022 * @param cls the closure passed to GST_cache_get_handle_transport()
1015 * @param ch the handle to CORE. Can be NULL if it is not requested 1023 * @param ch the handle to CORE. Can be NULL if it is not requested
1016 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 1024 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
1025 * @param ac the handle to ATS. Can be NULL if it is not requested
1017 * @param ignore_ peer identity which is ignored in this callback 1026 * @param ignore_ peer identity which is ignored in this callback
1018 */ 1027 */
1019static void 1028static void
1020p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, 1029p1_transport_connect_cache_callback (void *cls,
1030 struct GNUNET_CORE_Handle *ch,
1021 struct GNUNET_TRANSPORT_Handle *th, 1031 struct GNUNET_TRANSPORT_Handle *th,
1032 struct GNUNET_ATS_ConnectivityHandle *ac,
1022 const struct GNUNET_PeerIdentity *ignore_) 1033 const struct GNUNET_PeerIdentity *ignore_)
1023{ 1034{
1024 struct OverlayConnectContext *occ = cls; 1035 struct OverlayConnectContext *occ = cls;
@@ -1055,12 +1066,14 @@ p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
1055 * @param cls the closure passed to GST_cache_get_handle_transport() 1066 * @param cls the closure passed to GST_cache_get_handle_transport()
1056 * @param ch the handle to CORE. Can be NULL if it is not requested 1067 * @param ch the handle to CORE. Can be NULL if it is not requested
1057 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 1068 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
1069 * @param ac the handle to ATS. Can be NULL if it is not requested
1058 * @param my_identity the identity of our peer 1070 * @param my_identity the identity of our peer
1059 */ 1071 */
1060static void 1072static void
1061occ_cache_get_handle_core_cb (void *cls, 1073occ_cache_get_handle_core_cb (void *cls,
1062 struct GNUNET_CORE_Handle *ch, 1074 struct GNUNET_CORE_Handle *ch,
1063 struct GNUNET_TRANSPORT_Handle *th, 1075 struct GNUNET_TRANSPORT_Handle *th,
1076 struct GNUNET_ATS_ConnectivityHandle *ac,
1064 const struct GNUNET_PeerIdentity *my_identity) 1077 const struct GNUNET_PeerIdentity *my_identity)
1065{ 1078{
1066 struct OverlayConnectContext *occ = cls; 1079 struct OverlayConnectContext *occ = cls;
@@ -1244,7 +1257,8 @@ hash_hosts (struct GNUNET_TESTBED_Host *reg_host,
1244 * already registered, NULL is returned. 1257 * already registered, NULL is returned.
1245 */ 1258 */
1246static struct RegisteredHostContext * 1259static struct RegisteredHostContext *
1247register_host (struct Slave *slave, struct GNUNET_TESTBED_Host *host) 1260register_host (struct Slave *slave,
1261 struct GNUNET_TESTBED_Host *host)
1248{ 1262{
1249 struct GNUNET_HashCode hash; 1263 struct GNUNET_HashCode hash;
1250 struct RegisteredHostContext *rhc; 1264 struct RegisteredHostContext *rhc;
@@ -1357,9 +1371,12 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg,
1357 &GST_forwarded_operation_reply_relay, 1371 &GST_forwarded_operation_reply_relay,
1358 fopc); 1372 fopc);
1359 fopc->timeout_task = 1373 fopc->timeout_task =
1360 GNUNET_SCHEDULER_add_delayed (GST_timeout, &GST_forwarded_operation_timeout, 1374 GNUNET_SCHEDULER_add_delayed (GST_timeout,
1375 &GST_forwarded_operation_timeout,
1376 fopc);
1377 GNUNET_CONTAINER_DLL_insert_tail (fopcq_head,
1378 fopcq_tail,
1361 fopc); 1379 fopc);
1362 GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
1363} 1380}
1364 1381
1365 1382
@@ -1640,7 +1657,8 @@ attempt_connect_task (void *cls,
1640 * #GNUNET_SCHEDULER_REASON_READ_READY is succeeded 1657 * #GNUNET_SCHEDULER_REASON_READ_READY is succeeded
1641 */ 1658 */
1642static void 1659static void
1643rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1660rocc_hello_sent_cb (void *cls,
1661 const struct GNUNET_SCHEDULER_TaskContext *tc)
1644{ 1662{
1645 struct RemoteOverlayConnectCtx *rocc = cls; 1663 struct RemoteOverlayConnectCtx *rocc = cls;
1646 1664
@@ -1672,7 +1690,8 @@ rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1672 * @param tc the TaskContext from scheduler 1690 * @param tc the TaskContext from scheduler
1673 */ 1691 */
1674static void 1692static void
1675attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1693attempt_connect_task (void *cls,
1694 const struct GNUNET_SCHEDULER_TaskContext *tc)
1676{ 1695{
1677 struct RemoteOverlayConnectCtx *rocc = cls; 1696 struct RemoteOverlayConnectCtx *rocc = cls;
1678 1697
@@ -1700,11 +1719,14 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1700 * @param cls the closure passed to GST_cache_get_handle_transport() 1719 * @param cls the closure passed to GST_cache_get_handle_transport()
1701 * @param ch the handle to CORE. Can be NULL if it is not requested 1720 * @param ch the handle to CORE. Can be NULL if it is not requested
1702 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 1721 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
1722 * @param ac the handle to ATS. Can be NULL if it is not requested
1703 * @param ignore_ peer identity which is ignored in this callback 1723 * @param ignore_ peer identity which is ignored in this callback
1704 */ 1724 */
1705static void 1725static void
1706rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch, 1726rocc_cache_get_handle_transport_cb (void *cls,
1727 struct GNUNET_CORE_Handle *ch,
1707 struct GNUNET_TRANSPORT_Handle *th, 1728 struct GNUNET_TRANSPORT_Handle *th,
1729 struct GNUNET_ATS_ConnectivityHandle *ac,
1708 const struct GNUNET_PeerIdentity *ignore_) 1730 const struct GNUNET_PeerIdentity *ignore_)
1709{ 1731{
1710 struct RemoteOverlayConnectCtx *rocc = cls; 1732 struct RemoteOverlayConnectCtx *rocc = cls;
@@ -1718,7 +1740,8 @@ rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1718 rocc->tcc.th_ = th; 1740 rocc->tcc.th_ = th;
1719 rocc->tcc.pid = &rocc->a_id; 1741 rocc->tcc.pid = &rocc->a_id;
1720 if (GNUNET_YES == 1742 if (GNUNET_YES ==
1721 GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_, rocc->tcc.pid)) 1743 GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_,
1744 rocc->tcc.pid))
1722 { 1745 {
1723 LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n", 1746 LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n",
1724 rocc->op_id, 1747 rocc->op_id,