diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-27 14:49:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-27 14:49:03 +0000 |
commit | 6b048559eadd3e57fda24a23d3f3b4681d4e1408 (patch) | |
tree | 88c6f0ab9f0dda3d090f95adfd365078e6ed3b1a /src/testbed/gnunet-service-testbed_oc.c | |
parent | 57d4c0d631fc90945e92f264c841068a8be6565f (diff) | |
download | gnunet-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.c | 61 |
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 | */ |
627 | static void | 627 | static void |
628 | overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer) | 628 | overlay_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 | */ |
686 | static void | 687 | static void |
687 | try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 688 | try_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 | */ |
697 | static void | 699 | static void |
698 | try_connect_cb (void *cls, const int result) | 700 | try_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 | */ |
718 | static void | 721 | static void |
719 | try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 722 | try_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 | */ |
744 | static void | 748 | static void |
745 | send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 749 | send_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 | */ |
756 | static void | 761 | static void |
757 | occ_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 762 | occ_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 | */ |
795 | void | 801 | void |
796 | send_hello_thru_rocc (struct OverlayConnectContext *occ) | 802 | send_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 | */ |
882 | static void | 889 | static void |
883 | p2_transport_connect_cache_callback (void *cls, | 890 | p2_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 | */ |
1019 | static void | 1028 | static void |
1020 | p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, | 1029 | p1_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 | */ |
1060 | static void | 1072 | static void |
1061 | occ_cache_get_handle_core_cb (void *cls, | 1073 | occ_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 | */ |
1246 | static struct RegisteredHostContext * | 1259 | static struct RegisteredHostContext * |
1247 | register_host (struct Slave *slave, struct GNUNET_TESTBED_Host *host) | 1260 | register_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 | */ |
1642 | static void | 1659 | static void |
1643 | rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1660 | rocc_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 | */ |
1674 | static void | 1692 | static void |
1675 | attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1693 | attempt_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 | */ |
1705 | static void | 1725 | static void |
1706 | rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch, | 1726 | rocc_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, |