aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-05-17 09:23:41 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-05-17 09:23:41 +0000
commit6ebfc499830f2d447ef20514c66a1bb9e24f1dad (patch)
treeefab039fde14230dbab2032268774c4c8dd3ceb8 /src/testbed/testbed_api.c
parentc47979fd1c48558a4981ca853348d8b8d4c4197d (diff)
downloadgnunet-6ebfc499830f2d447ef20514c66a1bb9e24f1dad.tar.gz
gnunet-6ebfc499830f2d447ef20514c66a1bb9e24f1dad.zip
- revert 27104
Diffstat (limited to 'src/testbed/testbed_api.c')
-rw-r--r--src/testbed/testbed_api.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 93bdb03e5..e1068a2b6 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -1440,9 +1440,10 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1440 GNUNET_TESTBED_ControllerCallback cc, 1440 GNUNET_TESTBED_ControllerCallback cc,
1441 void *cc_cls) 1441 void *cc_cls)
1442{ 1442{
1443 struct GNUNET_TESTBED_Controller *c; 1443 struct GNUNET_TESTBED_Controller *controller;
1444 struct GNUNET_TESTBED_InitMessage *msg; 1444 struct GNUNET_TESTBED_InitMessage *msg;
1445 const struct GNUNET_CONFIGURATION_Handle *cfg; 1445 const struct GNUNET_CONFIGURATION_Handle *cfg;
1446 const char *controller_hostname;
1446 unsigned long long max_parallel_operations; 1447 unsigned long long max_parallel_operations;
1447 unsigned long long max_parallel_service_connections; 1448 unsigned long long max_parallel_service_connections;
1448 unsigned long long max_parallel_topology_config_operations; 1449 unsigned long long max_parallel_topology_config_operations;
@@ -1472,35 +1473,44 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1472 GNUNET_break (0); 1473 GNUNET_break (0);
1473 return NULL; 1474 return NULL;
1474 } 1475 }
1475 c = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller)); 1476 controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
1476 c->cc = cc; 1477 controller->cc = cc;
1477 c->cc_cls = cc_cls; 1478 controller->cc_cls = cc_cls;
1478 c->event_mask = event_mask; 1479 controller->event_mask = event_mask;
1479 c->cfg = GNUNET_CONFIGURATION_dup (cfg); 1480 controller->cfg = GNUNET_CONFIGURATION_dup (cfg);
1480 c->client = GNUNET_CLIENT_connect ("testbed", c->cfg); 1481 controller->client = GNUNET_CLIENT_connect ("testbed", controller->cfg);
1481 if (NULL == c->client) 1482 if (NULL == controller->client)
1482 { 1483 {
1483 GNUNET_TESTBED_controller_disconnect (c); 1484 GNUNET_TESTBED_controller_disconnect (controller);
1484 return NULL; 1485 return NULL;
1485 } 1486 }
1486 GNUNET_TESTBED_mark_host_registered_at_ (host, c); 1487 GNUNET_TESTBED_mark_host_registered_at_ (host, controller);
1487 c->host = host; 1488 controller->host = host;
1488 c->opq_parallel_operations = 1489 controller->opq_parallel_operations =
1489 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1490 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1490 max_parallel_operations); 1491 max_parallel_operations);
1491 c->opq_parallel_service_connections = 1492 controller->opq_parallel_service_connections =
1492 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1493 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1493 max_parallel_service_connections); 1494 max_parallel_service_connections);
1494 c->opq_parallel_topology_config_operations = 1495 controller->opq_parallel_topology_config_operations =
1495 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1496 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1496 max_parallel_topology_config_operations); 1497 max_parallel_topology_config_operations);
1497 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage)); 1498 controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
1499 if (NULL == controller_hostname)
1500 controller_hostname = "127.0.0.1";
1501 msg =
1502 GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage) +
1503 strlen (controller_hostname) + 1);
1498 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT); 1504 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT);
1499 msg->header.size = htons (sizeof (struct GNUNET_TESTBED_InitMessage)); 1505 msg->header.size =
1506 htons (sizeof (struct GNUNET_TESTBED_InitMessage) +
1507 strlen (controller_hostname) + 1);
1500 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host)); 1508 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1501 msg->event_mask = GNUNET_htonll (c->event_mask); 1509 msg->event_mask = GNUNET_htonll (controller->event_mask);
1502 GNUNET_TESTBED_queue_message_ (c, &msg->header); 1510 strcpy ((char *) &msg[1], controller_hostname);
1503 return c; 1511 GNUNET_TESTBED_queue_message_ (controller,
1512 (struct GNUNET_MessageHeader *) msg);
1513 return controller;
1504} 1514}
1505 1515
1506 1516