diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-14 14:05:35 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-14 14:05:35 +0000 |
commit | 77248f3758dcf94058ed54a2fa9c48146608bfc2 (patch) | |
tree | 7f115862f736bbd78be96957249c30bed3ae4605 /src/testbed | |
parent | 5355c95f4bab3cd84d2029dd169d93bbf9ace106 (diff) | |
download | gnunet-77248f3758dcf94058ed54a2fa9c48146608bfc2.tar.gz gnunet-77248f3758dcf94058ed54a2fa9c48146608bfc2.zip |
unstable checkpoint save
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 74 | ||||
-rw-r--r-- | src/testbed/testbed.h | 7 |
2 files changed, 61 insertions, 20 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index fd8600598..02dd24f65 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -316,7 +316,7 @@ struct Peer | |||
316 | } details; | 316 | } details; |
317 | 317 | ||
318 | /** | 318 | /** |
319 | * Is this peer local created? | 319 | * Is this peer locally created? |
320 | */ | 320 | */ |
321 | int is_remote; | 321 | int is_remote; |
322 | 322 | ||
@@ -1950,6 +1950,7 @@ occ_cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1950 | { | 1950 | { |
1951 | struct OverlayConnectContext *occ = cls; | 1951 | struct OverlayConnectContext *occ = cls; |
1952 | 1952 | ||
1953 | LOG_DEBUG ("Cleaning up occ\n"); | ||
1953 | GNUNET_free_non_null (occ->emsg); | 1954 | GNUNET_free_non_null (occ->emsg); |
1954 | GNUNET_free_non_null (occ->hello); | 1955 | GNUNET_free_non_null (occ->hello); |
1955 | if (GNUNET_SCHEDULER_NO_TASK != occ->send_hello_task) | 1956 | if (GNUNET_SCHEDULER_NO_TASK != occ->send_hello_task) |
@@ -2016,8 +2017,8 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | |||
2016 | memcmp (new_peer, &occ->other_peer_identity, | 2017 | memcmp (new_peer, &occ->other_peer_identity, |
2017 | sizeof (struct GNUNET_PeerIdentity))) | 2018 | sizeof (struct GNUNET_PeerIdentity))) |
2018 | { | 2019 | { |
2019 | LOG_DEBUG ("Unexpected peer %4s connected to peer %4s\n", new_peer_str, | 2020 | LOG_DEBUG ("Unexpected peer %4s connected when expecting peer %4s\n", |
2020 | other_peer_str); | 2021 | new_peer_str, other_peer_str); |
2021 | GNUNET_free (new_peer_str); | 2022 | GNUNET_free (new_peer_str); |
2022 | GNUNET_free (other_peer_str); | 2023 | GNUNET_free (other_peer_str); |
2023 | return; | 2024 | return; |
@@ -2036,7 +2037,8 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | |||
2036 | occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 2037 | occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
2037 | GNUNET_free_non_null (occ->emsg); | 2038 | GNUNET_free_non_null (occ->emsg); |
2038 | occ->emsg = NULL; | 2039 | occ->emsg = NULL; |
2039 | GNUNET_TRANSPORT_disconnect (occ->p2th); | 2040 | if (NULL != occ->p2th) |
2041 | GNUNET_TRANSPORT_disconnect (occ->p2th); | ||
2040 | occ->p2th = NULL; | 2042 | occ->p2th = NULL; |
2041 | LOG_DEBUG ("Peers connected - Sending overlay connect success\n"); | 2043 | LOG_DEBUG ("Peers connected - Sending overlay connect success\n"); |
2042 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); | 2044 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); |
@@ -2070,12 +2072,34 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2070 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 2072 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
2071 | return; | 2073 | return; |
2072 | GNUNET_assert (NULL != occ->hello); | 2074 | GNUNET_assert (NULL != occ->hello); |
2073 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 2075 | if (GNUNET_YES == occ->other_peer->is_remote) |
2074 | LOG_DEBUG ("Offering HELLO of %s to %s\n", | 2076 | { |
2075 | GNUNET_i2s (&occ->peer_identity), other_peer_str); | 2077 | struct GNUNET_TESTBED_RequestConnectMessage *msg; |
2076 | GNUNET_free (other_peer_str); | 2078 | uint16_t msize; |
2077 | GNUNET_TRANSPORT_offer_hello (occ->p2th, occ->hello, NULL, NULL); | 2079 | uint16_t hello_size; |
2078 | GNUNET_TRANSPORT_try_connect (occ->p2th, &occ->peer_identity); | 2080 | |
2081 | hello_size = ntohs (occ->hello->size); | ||
2082 | msize = sizeof (struct GNUNET_TESTBED_RequestConnectMessage) + hello_size; | ||
2083 | msg = GNUNET_malloc (msize); | ||
2084 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT); | ||
2085 | msg->header.size = htons (msize); | ||
2086 | msg->peer = htonl (occ->peer->id); | ||
2087 | msg->operation_id = GNUNET_htonll (occ->op_id); | ||
2088 | (void) memcpy (&msg->peer_identity, &occ->peer_identity, | ||
2089 | sizeof (struct GNUNET_PeerIdentity)); | ||
2090 | memcpy (msg->hello, occ->hello, hello_size); | ||
2091 | GNUNET_TESTBED_queue_message_ (occ->other_peer->details.remote.controller, | ||
2092 | &msg->header); | ||
2093 | } | ||
2094 | else | ||
2095 | { | ||
2096 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | ||
2097 | LOG_DEBUG ("Offering HELLO of %s to %s\n", | ||
2098 | GNUNET_i2s (&occ->peer_identity), other_peer_str); | ||
2099 | GNUNET_free (other_peer_str); | ||
2100 | GNUNET_TRANSPORT_offer_hello (occ->p2th, occ->hello, NULL, NULL); | ||
2101 | GNUNET_TRANSPORT_try_connect (occ->p2th, &occ->peer_identity); | ||
2102 | } | ||
2079 | occ->send_hello_task = | 2103 | occ->send_hello_task = |
2080 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &send_hello, occ); | 2104 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &send_hello, occ); |
2081 | } | 2105 | } |
@@ -2131,6 +2155,20 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) | |||
2131 | GNUNET_TRANSPORT_disconnect (occ->p1th); | 2155 | GNUNET_TRANSPORT_disconnect (occ->p1th); |
2132 | occ->p1th = NULL; | 2156 | occ->p1th = NULL; |
2133 | GNUNET_free_non_null (occ->emsg); | 2157 | GNUNET_free_non_null (occ->emsg); |
2158 | if (GNUNET_NO == occ->other_peer->is_remote) | ||
2159 | { | ||
2160 | occ->p2th = | ||
2161 | GNUNET_TRANSPORT_connect (occ->other_peer->details.local.cfg, | ||
2162 | &occ->other_peer_identity, NULL, NULL, NULL, | ||
2163 | NULL); | ||
2164 | if (NULL == occ->p2th) | ||
2165 | { | ||
2166 | occ->emsg = GNUNET_strdup ("Cannot connect to TRANSPORT of peer B"); | ||
2167 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | ||
2168 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | ||
2169 | return; | ||
2170 | } | ||
2171 | } | ||
2134 | occ->emsg = GNUNET_strdup ("Timeout while offering HELLO to other peer"); | 2172 | occ->emsg = GNUNET_strdup ("Timeout while offering HELLO to other peer"); |
2135 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); | 2173 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); |
2136 | } | 2174 | } |
@@ -2164,16 +2202,10 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, | |||
2164 | occ->p1th = | 2202 | occ->p1th = |
2165 | GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg, | 2203 | GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg, |
2166 | &occ->peer_identity, NULL, NULL, NULL, NULL); | 2204 | &occ->peer_identity, NULL, NULL, NULL, NULL); |
2167 | /* Connect to the transport of 2nd peer to offer 1st peer's HELLO */ | 2205 | if (NULL == occ->p1th) |
2168 | GNUNET_TESTING_peer_get_identity (occ->other_peer->details.local.peer, | ||
2169 | &occ->other_peer_identity); | ||
2170 | occ->p2th = | ||
2171 | GNUNET_TRANSPORT_connect (occ->other_peer->details.local.cfg, | ||
2172 | &occ->other_peer_identity, NULL, NULL, NULL, | ||
2173 | NULL); | ||
2174 | if ((NULL == occ->p1th) || (NULL == occ->p2th)) | ||
2175 | { | 2206 | { |
2176 | occ->emsg = GNUNET_strdup ("Cannot connect to TRANSPORTs of peers"); | 2207 | GNUNET_asprintf (&occ->emsg, "Cannot connect to TRANSPORT of peers %4s", |
2208 | GNUNET_i2s (&occ->peer_identity)); | ||
2177 | goto error_return; | 2209 | goto error_return; |
2178 | } | 2210 | } |
2179 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", GNUNET_i2s (&occ->peer_identity)); | 2211 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", GNUNET_i2s (&occ->peer_identity)); |
@@ -2184,6 +2216,7 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, | |||
2184 | error_return: | 2216 | error_return: |
2185 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 2217 | GNUNET_SCHEDULER_cancel (occ->timeout_task); |
2186 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 2218 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); |
2219 | return; | ||
2187 | } | 2220 | } |
2188 | 2221 | ||
2189 | 2222 | ||
@@ -2222,6 +2255,9 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2222 | occ->peer = peer_list[p1]; | 2255 | occ->peer = peer_list[p1]; |
2223 | occ->other_peer = peer_list[p2]; | 2256 | occ->other_peer = peer_list[p2]; |
2224 | occ->op_id = GNUNET_ntohll (msg->operation_id); | 2257 | occ->op_id = GNUNET_ntohll (msg->operation_id); |
2258 | /* Get the identity of the second peer */ | ||
2259 | GNUNET_TESTING_peer_get_identity (occ->other_peer->details.local.peer, | ||
2260 | &occ->other_peer_identity); | ||
2225 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ | 2261 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ |
2226 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); | 2262 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); |
2227 | occ->ch = | 2263 | occ->ch = |
diff --git a/src/testbed/testbed.h b/src/testbed/testbed.h index 04421ccf5..24183e8d8 100644 --- a/src/testbed/testbed.h +++ b/src/testbed/testbed.h | |||
@@ -419,7 +419,12 @@ struct GNUNET_TESTBED_RequestConnectMessage | |||
419 | /** | 419 | /** |
420 | * The Operation ID that is used to identify this operation | 420 | * The Operation ID that is used to identify this operation |
421 | */ | 421 | */ |
422 | uint64_t operation_id GNUNET_PACKED; | 422 | uint64_t operation_id GNUNET_PACKED; |
423 | |||
424 | /** | ||
425 | * Identity of A | ||
426 | */ | ||
427 | struct GNUNET_PeerIdentity peer_identity; | ||
423 | 428 | ||
424 | /** | 429 | /** |
425 | * To be followed by the HELLO message of A | 430 | * To be followed by the HELLO message of A |