aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-10-12 12:13:01 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-10-12 12:13:01 +0000
commit1483c57ba143a46802d2e478ea02caa9f4e92a04 (patch)
tree3d7e0ceb0411363f34239884a8d705d85384878b
parentc49ecc2c61d5c159b7fc33f63f61b389a9660569 (diff)
downloadgnunet-1483c57ba143a46802d2e478ea02caa9f4e92a04.tar.gz
gnunet-1483c57ba143a46802d2e478ea02caa9f4e92a04.zip
send self config during overlay connect
-rw-r--r--src/testbed/gnunet-service-testbed.c34
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c8
2 files changed, 29 insertions, 13 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 8ca7275c3..44eb19e23 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -639,11 +639,17 @@ static struct Context *master_context;
639 */ 639 */
640static char *hostname; 640static char *hostname;
641 641
642
642/***********/ 643/***********/
643/* Handles */ 644/* Handles */
644/***********/ 645/***********/
645 646
646/** 647/**
648 * Our configuration
649 */
650static struct GNUNET_CONFIGURATION_Handle *our_config;
651
652/**
647 * Current Transmit Handle; NULL if no notify transmit exists currently 653 * Current Transmit Handle; NULL if no notify transmit exists currently
648 */ 654 */
649static struct GNUNET_SERVER_TransmitHandle *transmit_handle; 655static struct GNUNET_SERVER_TransmitHandle *transmit_handle;
@@ -1436,7 +1442,9 @@ handle_init (void *cls, struct GNUNET_SERVER_Client *client,
1436 master_context->system = 1442 master_context->system =
1437 GNUNET_TESTING_system_create ("testbed", master_context->master_ip, hostname); 1443 GNUNET_TESTING_system_create ("testbed", master_context->master_ip, hostname);
1438 host = 1444 host =
1439 GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL, 1445 GNUNET_TESTBED_host_create_with_id (master_context->host_id,
1446 master_context->master_ip,
1447 NULL,
1440 0); 1448 0);
1441 host_list_add (host); 1449 host_list_add (host);
1442 GNUNET_SERVER_client_keep (client); 1450 GNUNET_SERVER_client_keep (client);
@@ -2613,21 +2621,25 @@ static void
2613focc_reg_completion_cc (void *cls, const char *emsg) 2621focc_reg_completion_cc (void *cls, const char *emsg)
2614{ 2622{
2615 struct ForwardedOverlayConnectContext *focc = cls; 2623 struct ForwardedOverlayConnectContext *focc = cls;
2616 2624 struct GNUNET_CONFIGURATION_Handle *cfg;
2625
2617 GNUNET_assert (FOCC_REGISTER == focc->state); 2626 GNUNET_assert (FOCC_REGISTER == focc->state);
2618 focc->rhandle = NULL; 2627 focc->rhandle = NULL;
2619 GNUNET_assert (NULL == focc->sub_op); 2628 GNUNET_assert (NULL == focc->sub_op);
2620 LOG_DEBUG ("Registering peer2's host successful\n"); 2629 LOG_DEBUG ("Registering peer2's host successful\n");
2621 if ((focc->peer2_host_id < slave_list_size) /* Check if we have the needed config */ 2630 if ((NULL == focc->gateway2)
2622 && (NULL != slave_list[focc->peer2_host_id])) 2631 || ((focc->peer2_host_id < slave_list_size) /* Check if we have the needed config */
2632 && (NULL != slave_list[focc->peer2_host_id])))
2623 { 2633 {
2624 focc->state = FOCC_LINK; 2634 focc->state = FOCC_LINK;
2635 cfg = (NULL == focc->gateway2) ?
2636 our_config : slave_list[focc->peer2_host_id]->cfg;
2625 focc->sub_op = 2637 focc->sub_op =
2626 GNUNET_TESTBED_controller_link_ (focc, 2638 GNUNET_TESTBED_controller_link_ (focc,
2627 focc->gateway, 2639 focc->gateway,
2628 focc->peer2_host_id, 2640 focc->peer2_host_id,
2629 peer_list[focc->peer1]->details.remote.remote_host_id, 2641 peer_list[focc->peer1]->details.remote.remote_host_id,
2630 slave_list[focc->peer2_host_id]->cfg, 2642 cfg,
2631 GNUNET_NO); 2643 GNUNET_NO);
2632 return; 2644 return;
2633 } 2645 }
@@ -2708,7 +2720,6 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
2708 uint32_t p2; 2720 uint32_t p2;
2709 uint32_t peer2_host_id; 2721 uint32_t peer2_host_id;
2710 2722
2711
2712 msg = (const struct GNUNET_TESTBED_OverlayConnectMessage *) message; 2723 msg = (const struct GNUNET_TESTBED_OverlayConnectMessage *) message;
2713 p1 = ntohl (msg->peer1); 2724 p1 = ntohl (msg->peer1);
2714 p2 = ntohl (msg->peer2); 2725 p2 = ntohl (msg->peer2);
@@ -2731,12 +2742,14 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
2731 route_to_peer2_host = NULL; 2742 route_to_peer2_host = NULL;
2732 route_to_peer1_host = NULL; 2743 route_to_peer1_host = NULL;
2733 route_to_peer2_host = find_dest_route (peer2_host_id); 2744 route_to_peer2_host = find_dest_route (peer2_host_id);
2734 if (NULL != route_to_peer2_host) 2745 if ((NULL != route_to_peer2_host)
2746 || (peer2_host_id == master_context->host_id))
2735 { 2747 {
2736 route_to_peer1_host = 2748 route_to_peer1_host =
2737 find_dest_route (peer_list[p1]->details.remote.remote_host_id); 2749 find_dest_route (peer_list[p1]->details.remote.remote_host_id);
2738 GNUNET_assert (NULL != route_to_peer1_host); 2750 GNUNET_assert (NULL != route_to_peer1_host);
2739 if (route_to_peer2_host->dest != route_to_peer1_host->dest) 2751 if ((peer2_host_id == master_context->host_id)
2752 || (route_to_peer2_host->dest != route_to_peer1_host->dest))
2740 { 2753 {
2741 struct ForwardedOverlayConnectContext *focc; 2754 struct ForwardedOverlayConnectContext *focc;
2742 uint16_t msize; 2755 uint16_t msize;
@@ -2744,7 +2757,8 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
2744 msize = sizeof (struct GNUNET_TESTBED_OverlayConnectMessage); 2757 msize = sizeof (struct GNUNET_TESTBED_OverlayConnectMessage);
2745 focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext)); 2758 focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext));
2746 focc->gateway = peer->details.remote.controller; 2759 focc->gateway = peer->details.remote.controller;
2747 focc->gateway2 = slave_list[route_to_peer2_host->dest]->controller; 2760 focc->gateway2 = (NULL == route_to_peer2_host) ? NULL :
2761 slave_list[route_to_peer2_host->dest]->controller;
2748 focc->peer1 = p1; 2762 focc->peer1 = p1;
2749 focc->peer2 = p2; 2763 focc->peer2 = p2;
2750 focc->peer2_host_id = peer2_host_id; 2764 focc->peer2_host_id = peer2_host_id;
@@ -3179,6 +3193,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3179 master_context = NULL; 3193 master_context = NULL;
3180 } 3194 }
3181 GNUNET_free_non_null (hostname); 3195 GNUNET_free_non_null (hostname);
3196 GNUNET_CONFIGURATION_destroy (our_config);
3182} 3197}
3183 3198
3184 3199
@@ -3245,6 +3260,7 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server,
3245 3260
3246 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string 3261 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string
3247 (cfg, "testbed", "HOSTNAME", &hostname)); 3262 (cfg, "testbed", "HOSTNAME", &hostname));
3263 our_config = GNUNET_CONFIGURATION_dup (cfg);
3248 GNUNET_SERVER_add_handlers (server, message_handlers); 3264 GNUNET_SERVER_add_handlers (server, message_handlers);
3249 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); 3265 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL);
3250 ss_map = GNUNET_CONTAINER_multihashmap_create (5, GNUNET_NO); 3266 ss_map = GNUNET_CONTAINER_multihashmap_create (5, GNUNET_NO);
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index 4e5f9660e..b79271489 100644
--- a/src/testbed/test_testbed_api_3peers_3controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -530,8 +530,8 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
530 peer3.operation = NULL; 530 peer3.operation = NULL;
531 result = PEER3_STARTED; 531 result = PEER3_STARTED;
532 common_operation = 532 common_operation =
533 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer, 533 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer,
534 peer2.peer); 534 peer1.peer);
535 break; 535 break;
536 default: 536 default:
537 GNUNET_assert (0); 537 GNUNET_assert (0);
@@ -574,8 +574,8 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
574 { 574 {
575 case PEER3_STARTED: 575 case PEER3_STARTED:
576 GNUNET_assert (NULL != common_operation); 576 GNUNET_assert (NULL != common_operation);
577 GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && 577 GNUNET_assert ((event->details.peer_connect.peer1 == peer2.peer) &&
578 (event->details.peer_connect.peer2 == peer2.peer)); 578 (event->details.peer_connect.peer2 == peer1.peer));
579 break; 579 break;
580 case PEERS_2_3_CONNECTED: 580 case PEERS_2_3_CONNECTED:
581 GNUNET_assert (NULL != common_operation); 581 GNUNET_assert (NULL != common_operation);