diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-25 13:12:26 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-25 13:12:26 +0000 |
commit | 0d8c699ff369b1953a51efb690ad1e25ffe1e981 (patch) | |
tree | c0149feb30f6ecbbeaadc0527d6cb0f353b2d28c /src | |
parent | f45aa9ad24ef852ffd39490b7ce32c213e698b72 (diff) | |
download | gnunet-0d8c699ff369b1953a51efb690ad1e25ffe1e981.tar.gz gnunet-0d8c699ff369b1953a51efb690ad1e25ffe1e981.zip |
overlay connect using lateral connections
Diffstat (limited to 'src')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 72 |
1 files changed, 55 insertions, 17 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 6edf8d897..db26ea56b 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -350,11 +350,6 @@ struct OverlayConnectContext | |||
350 | struct Peer *peer; | 350 | struct Peer *peer; |
351 | 351 | ||
352 | /** | 352 | /** |
353 | * The other peer | ||
354 | */ | ||
355 | struct Peer *other_peer; | ||
356 | |||
357 | /** | ||
358 | * Transport handle of the first peer to get its HELLO | 353 | * Transport handle of the first peer to get its HELLO |
359 | */ | 354 | */ |
360 | struct GNUNET_TRANSPORT_Handle *p1th; | 355 | struct GNUNET_TRANSPORT_Handle *p1th; |
@@ -390,6 +385,11 @@ struct OverlayConnectContext | |||
390 | struct OperationContext *opc; | 385 | struct OperationContext *opc; |
391 | 386 | ||
392 | /** | 387 | /** |
388 | * Controller of peer 2; NULL if the peer is local | ||
389 | */ | ||
390 | struct GNUNET_TESTBED_Controller *peer2_controller; | ||
391 | |||
392 | /** | ||
393 | * The peer identity of the first peer | 393 | * The peer identity of the first peer |
394 | */ | 394 | */ |
395 | struct GNUNET_PeerIdentity peer_identity; | 395 | struct GNUNET_PeerIdentity peer_identity; |
@@ -415,6 +415,15 @@ struct OverlayConnectContext | |||
415 | */ | 415 | */ |
416 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 416 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
417 | 417 | ||
418 | /** | ||
419 | * The id of peer A | ||
420 | */ | ||
421 | uint32_t peer_id; | ||
422 | |||
423 | /** | ||
424 | * The id of peer B | ||
425 | */ | ||
426 | uint32_t other_peer_id; | ||
418 | }; | 427 | }; |
419 | 428 | ||
420 | 429 | ||
@@ -2097,8 +2106,8 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | |||
2097 | htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); | 2106 | htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); |
2098 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT); | 2107 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT); |
2099 | msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); | 2108 | msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); |
2100 | msg->peer1 = htonl (occ->peer->id); | 2109 | msg->peer1 = htonl (occ->peer_id); |
2101 | msg->peer2 = htonl (occ->other_peer->id); | 2110 | msg->peer2 = htonl (occ->other_peer_id); |
2102 | msg->operation_id = GNUNET_htonll (occ->op_id); | 2111 | msg->operation_id = GNUNET_htonll (occ->op_id); |
2103 | queue_message (occ->client, &msg->header); | 2112 | queue_message (occ->client, &msg->header); |
2104 | GNUNET_SCHEDULER_add_now (&occ_cleanup, occ); | 2113 | GNUNET_SCHEDULER_add_now (&occ_cleanup, occ); |
@@ -2123,7 +2132,7 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2123 | return; | 2132 | return; |
2124 | GNUNET_assert (NULL != occ->hello); | 2133 | GNUNET_assert (NULL != occ->hello); |
2125 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 2134 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); |
2126 | if (GNUNET_YES == occ->other_peer->is_remote) | 2135 | if (NULL != occ->peer2_controller) |
2127 | { | 2136 | { |
2128 | struct GNUNET_TESTBED_RequestConnectMessage *msg; | 2137 | struct GNUNET_TESTBED_RequestConnectMessage *msg; |
2129 | uint16_t msize; | 2138 | uint16_t msize; |
@@ -2136,13 +2145,12 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2136 | msg = GNUNET_malloc (msize); | 2145 | msg = GNUNET_malloc (msize); |
2137 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT); | 2146 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT); |
2138 | msg->header.size = htons (msize); | 2147 | msg->header.size = htons (msize); |
2139 | msg->peer = htonl (occ->other_peer->id); | 2148 | msg->peer = htonl (occ->other_peer_id); |
2140 | msg->operation_id = GNUNET_htonll (occ->op_id); | 2149 | msg->operation_id = GNUNET_htonll (occ->op_id); |
2141 | (void) memcpy (&msg->peer_identity, &occ->peer_identity, | 2150 | (void) memcpy (&msg->peer_identity, &occ->peer_identity, |
2142 | sizeof (struct GNUNET_PeerIdentity)); | 2151 | sizeof (struct GNUNET_PeerIdentity)); |
2143 | memcpy (msg->hello, occ->hello, hello_size); | 2152 | memcpy (msg->hello, occ->hello, hello_size); |
2144 | GNUNET_TESTBED_queue_message_ (occ->other_peer->details.remote.controller, | 2153 | GNUNET_TESTBED_queue_message_ (occ->peer2_controller, &msg->header); |
2145 | &msg->header); | ||
2146 | } | 2154 | } |
2147 | else | 2155 | else |
2148 | { | 2156 | { |
@@ -2209,10 +2217,10 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) | |||
2209 | GNUNET_TRANSPORT_disconnect (occ->p1th); | 2217 | GNUNET_TRANSPORT_disconnect (occ->p1th); |
2210 | occ->p1th = NULL; | 2218 | occ->p1th = NULL; |
2211 | GNUNET_free_non_null (occ->emsg); | 2219 | GNUNET_free_non_null (occ->emsg); |
2212 | if (GNUNET_NO == occ->other_peer->is_remote) | 2220 | if (NULL == occ->peer2_controller) |
2213 | { | 2221 | { |
2214 | occ->p2th = | 2222 | occ->p2th = |
2215 | GNUNET_TRANSPORT_connect (occ->other_peer->details.local.cfg, | 2223 | GNUNET_TRANSPORT_connect (peer_list[occ->other_peer_id]->details.local.cfg, |
2216 | &occ->other_peer_identity, NULL, NULL, NULL, | 2224 | &occ->other_peer_identity, NULL, NULL, NULL, |
2217 | NULL); | 2225 | NULL); |
2218 | if (NULL == occ->p2th) | 2226 | if (NULL == occ->p2th) |
@@ -2367,11 +2375,41 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2367 | occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); | 2375 | occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); |
2368 | GNUNET_SERVER_client_keep (client); | 2376 | GNUNET_SERVER_client_keep (client); |
2369 | occ->client = client; | 2377 | occ->client = client; |
2378 | occ->peer_id = p1; | ||
2379 | occ->other_peer_id = p2; | ||
2370 | occ->peer = peer_list[p1]; | 2380 | occ->peer = peer_list[p1]; |
2371 | occ->other_peer = peer_list[p2]; | ||
2372 | occ->op_id = GNUNET_ntohll (msg->operation_id); | 2381 | occ->op_id = GNUNET_ntohll (msg->operation_id); |
2382 | if ((p2 >= peer_list_size) || (NULL == peer_list[p2])) | ||
2383 | { | ||
2384 | uint32_t peer2_host_id; | ||
2385 | |||
2386 | peer2_host_id = ntohl (msg->peer2_host_id); | ||
2387 | if ((peer2_host_id >= slave_list_size) | ||
2388 | || (NULL ==slave_list[peer2_host_id])) | ||
2389 | { | ||
2390 | GNUNET_break (0); | ||
2391 | GNUNET_SERVER_client_drop (client); | ||
2392 | GNUNET_free (occ); | ||
2393 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
2394 | return; | ||
2395 | } | ||
2396 | occ->peer2_controller = slave_list[peer2_host_id]->controller; | ||
2397 | if (NULL == occ->peer2_controller) | ||
2398 | { | ||
2399 | GNUNET_break (0); | ||
2400 | GNUNET_SERVER_client_drop (client); | ||
2401 | GNUNET_free (occ); | ||
2402 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
2403 | return; | ||
2404 | } | ||
2405 | } | ||
2406 | else | ||
2407 | { | ||
2408 | if (GNUNET_YES == peer_list[occ->other_peer_id]->is_remote) | ||
2409 | occ->peer2_controller = peer_list[occ->other_peer_id]->details.remote.controller; | ||
2410 | } | ||
2373 | /* Get the identity of the second peer */ | 2411 | /* Get the identity of the second peer */ |
2374 | if (GNUNET_YES == occ->other_peer->is_remote) | 2412 | if (NULL != occ->peer2_controller) |
2375 | { | 2413 | { |
2376 | struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg; | 2414 | struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg; |
2377 | 2415 | ||
@@ -2381,7 +2419,7 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2381 | cmsg.peer_id = msg->peer2; | 2419 | cmsg.peer_id = msg->peer2; |
2382 | cmsg.operation_id = msg->operation_id; | 2420 | cmsg.operation_id = msg->operation_id; |
2383 | occ->opc = | 2421 | occ->opc = |
2384 | GNUNET_TESTBED_forward_operation_msg_ (occ->other_peer->details.remote.controller, | 2422 | GNUNET_TESTBED_forward_operation_msg_ (occ->peer2_controller, |
2385 | occ->op_id, &cmsg.header, | 2423 | occ->op_id, &cmsg.header, |
2386 | &overlay_connect_get_config, | 2424 | &overlay_connect_get_config, |
2387 | occ); | 2425 | occ); |
@@ -2394,7 +2432,7 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2394 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2432 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
2395 | return; | 2433 | return; |
2396 | } | 2434 | } |
2397 | GNUNET_TESTING_peer_get_identity (occ->other_peer->details.local.peer, | 2435 | GNUNET_TESTING_peer_get_identity (peer_list[occ->other_peer_id]->details.local.peer, |
2398 | &occ->other_peer_identity); | 2436 | &occ->other_peer_identity); |
2399 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ | 2437 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ |
2400 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); | 2438 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); |