diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-14 10:33:35 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-14 10:33:35 +0000 |
commit | d17a20b454e89cddd138b3c3c8f1900fdf8d48c2 (patch) | |
tree | b163c43904540abec912a1a4c7c8df7685eebc1c /src/testbed | |
parent | 09046cacc36b90b238eaffbf41e4078c3171e22d (diff) | |
download | gnunet-d17a20b454e89cddd138b3c3c8f1900fdf8d48c2.tar.gz gnunet-d17a20b454e89cddd138b3c3c8f1900fdf8d48c2.zip |
disambiguating local overlay connect
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index f544e17dc..67ab0688a 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -367,17 +367,17 @@ struct OverlayConnectContext | |||
367 | struct Peer *other_peer; | 367 | struct Peer *other_peer; |
368 | 368 | ||
369 | /** | 369 | /** |
370 | * Transport handle of the first peer to offer second peer's HELLO | 370 | * Transport handle of the first peer to get its HELLO |
371 | */ | 371 | */ |
372 | struct GNUNET_TRANSPORT_Handle *p1th; | 372 | struct GNUNET_TRANSPORT_Handle *p1th; |
373 | 373 | ||
374 | /** | 374 | /** |
375 | * Transport handle of other peer to get its HELLO | 375 | * Transport handle of other peer to offer first peer's HELLO |
376 | */ | 376 | */ |
377 | struct GNUNET_TRANSPORT_Handle *p2th; | 377 | struct GNUNET_TRANSPORT_Handle *p2th; |
378 | 378 | ||
379 | /** | 379 | /** |
380 | * Core handles of the peer which has to connect to other peer | 380 | * Core handles of the first peer; used to notify when second peer connects to it |
381 | */ | 381 | */ |
382 | struct GNUNET_CORE_Handle *ch; | 382 | struct GNUNET_CORE_Handle *ch; |
383 | 383 | ||
@@ -387,7 +387,7 @@ struct OverlayConnectContext | |||
387 | struct GNUNET_MessageHeader *hello; | 387 | struct GNUNET_MessageHeader *hello; |
388 | 388 | ||
389 | /** | 389 | /** |
390 | * Get hello handle for the other peer | 390 | * Get hello handle to acquire HELLO of first peer |
391 | */ | 391 | */ |
392 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | 392 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; |
393 | 393 | ||
@@ -2058,9 +2058,8 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | |||
2058 | occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 2058 | occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
2059 | GNUNET_free_non_null (occ->emsg); | 2059 | GNUNET_free_non_null (occ->emsg); |
2060 | occ->emsg = NULL; | 2060 | occ->emsg = NULL; |
2061 | GNUNET_TRANSPORT_disconnect (occ->p1th); | 2061 | GNUNET_TRANSPORT_disconnect (occ->p2th); |
2062 | occ->p1th = NULL; | 2062 | occ->p2th = NULL; |
2063 | /* Peer 1 has connected connect to peer2 - now send overlay connect success message */ | ||
2064 | LOG_DEBUG ("Peers connected - Sending overlay connect success\n"); | 2063 | LOG_DEBUG ("Peers connected - Sending overlay connect success\n"); |
2065 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); | 2064 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); |
2066 | msg->header.size = | 2065 | msg->header.size = |
@@ -2076,6 +2075,13 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | |||
2076 | } | 2075 | } |
2077 | 2076 | ||
2078 | 2077 | ||
2078 | /** | ||
2079 | * Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to | ||
2080 | * peer 1. | ||
2081 | * | ||
2082 | * @param cls the OverlayConnectContext | ||
2083 | * @param tc the TaskContext from scheduler | ||
2084 | */ | ||
2079 | static void | 2085 | static void |
2080 | send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 2086 | send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
2081 | { | 2087 | { |
@@ -2087,11 +2093,11 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2087 | return; | 2093 | return; |
2088 | GNUNET_assert (NULL != occ->hello); | 2094 | GNUNET_assert (NULL != occ->hello); |
2089 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 2095 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); |
2090 | LOG_DEBUG ("Offering HELLO of %s to %s\n", other_peer_str, | 2096 | LOG_DEBUG ("Offering HELLO of %s to %s\n", |
2091 | GNUNET_i2s (&occ->peer_identity)); | 2097 | GNUNET_i2s (&occ->peer_identity), other_peer_str); |
2092 | GNUNET_free (other_peer_str); | 2098 | GNUNET_free (other_peer_str); |
2093 | GNUNET_TRANSPORT_offer_hello (occ->p1th, occ->hello, NULL, NULL); | 2099 | GNUNET_TRANSPORT_offer_hello (occ->p2th, occ->hello, NULL, NULL); |
2094 | GNUNET_TRANSPORT_try_connect (occ->p1th, &occ->other_peer_identity); | 2100 | GNUNET_TRANSPORT_try_connect (occ->p2th, &occ->peer_identity); |
2095 | occ->send_hello_task = | 2101 | occ->send_hello_task = |
2096 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &send_hello, occ); | 2102 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &send_hello, occ); |
2097 | } | 2103 | } |
@@ -2136,17 +2142,16 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) | |||
2136 | &empty); | 2142 | &empty); |
2137 | if (GNUNET_YES == empty) | 2143 | if (GNUNET_YES == empty) |
2138 | { | 2144 | { |
2139 | LOG_DEBUG ("HELLO of %s is empty\n", | 2145 | LOG_DEBUG ("HELLO of %s is empty\n", GNUNET_i2s (&occ->peer_identity)); |
2140 | GNUNET_i2s (&occ->other_peer_identity)); | ||
2141 | return; | 2146 | return; |
2142 | } | 2147 | } |
2143 | LOG_DEBUG ("Received HELLO of %s\n", GNUNET_i2s (&occ->other_peer_identity)); | 2148 | LOG_DEBUG ("Received HELLO of %s\n", GNUNET_i2s (&occ->peer_identity)); |
2144 | occ->hello = GNUNET_malloc (msize); | 2149 | occ->hello = GNUNET_malloc (msize); |
2145 | memcpy (occ->hello, hello, msize); | 2150 | memcpy (occ->hello, hello, msize); |
2146 | GNUNET_TRANSPORT_get_hello_cancel (occ->ghh); | 2151 | GNUNET_TRANSPORT_get_hello_cancel (occ->ghh); |
2147 | occ->ghh = NULL; | 2152 | occ->ghh = NULL; |
2148 | GNUNET_TRANSPORT_disconnect (occ->p2th); | 2153 | GNUNET_TRANSPORT_disconnect (occ->p1th); |
2149 | occ->p2th = NULL; | 2154 | occ->p1th = NULL; |
2150 | GNUNET_free_non_null (occ->emsg); | 2155 | GNUNET_free_non_null (occ->emsg); |
2151 | occ->emsg = GNUNET_strdup ("Timeout while offering HELLO to other peer"); | 2156 | occ->emsg = GNUNET_strdup ("Timeout while offering HELLO to other peer"); |
2152 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); | 2157 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); |
@@ -2192,10 +2197,9 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, | |||
2192 | occ); | 2197 | occ); |
2193 | return; | 2198 | return; |
2194 | } | 2199 | } |
2195 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", | 2200 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", GNUNET_i2s (&occ->peer_identity)); |
2196 | GNUNET_i2s (&occ->other_peer_identity)); | ||
2197 | occ->emsg = GNUNET_strdup ("Timeout while acquiring HELLO message"); | 2201 | occ->emsg = GNUNET_strdup ("Timeout while acquiring HELLO message"); |
2198 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p2th, &hello_update_cb, occ); | 2202 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ); |
2199 | } | 2203 | } |
2200 | 2204 | ||
2201 | 2205 | ||