aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api.c')
-rw-r--r--src/testbed/testbed_api.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 01df06729..80f940467 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -1436,10 +1436,9 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1436 GNUNET_TESTBED_ControllerCallback cc, 1436 GNUNET_TESTBED_ControllerCallback cc,
1437 void *cc_cls) 1437 void *cc_cls)
1438{ 1438{
1439 struct GNUNET_TESTBED_Controller *controller; 1439 struct GNUNET_TESTBED_Controller *c;
1440 struct GNUNET_TESTBED_InitMessage *msg; 1440 struct GNUNET_TESTBED_InitMessage *msg;
1441 const struct GNUNET_CONFIGURATION_Handle *cfg; 1441 const struct GNUNET_CONFIGURATION_Handle *cfg;
1442 const char *controller_hostname;
1443 unsigned long long max_parallel_operations; 1442 unsigned long long max_parallel_operations;
1444 unsigned long long max_parallel_service_connections; 1443 unsigned long long max_parallel_service_connections;
1445 unsigned long long max_parallel_topology_config_operations; 1444 unsigned long long max_parallel_topology_config_operations;
@@ -1469,44 +1468,35 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1469 GNUNET_break (0); 1468 GNUNET_break (0);
1470 return NULL; 1469 return NULL;
1471 } 1470 }
1472 controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller)); 1471 c = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
1473 controller->cc = cc; 1472 c->cc = cc;
1474 controller->cc_cls = cc_cls; 1473 c->cc_cls = cc_cls;
1475 controller->event_mask = event_mask; 1474 c->event_mask = event_mask;
1476 controller->cfg = GNUNET_CONFIGURATION_dup (cfg); 1475 c->cfg = GNUNET_CONFIGURATION_dup (cfg);
1477 controller->client = GNUNET_CLIENT_connect ("testbed", controller->cfg); 1476 c->client = GNUNET_CLIENT_connect ("testbed", c->cfg);
1478 if (NULL == controller->client) 1477 if (NULL == c->client)
1479 { 1478 {
1480 GNUNET_TESTBED_controller_disconnect (controller); 1479 GNUNET_TESTBED_controller_disconnect (c);
1481 return NULL; 1480 return NULL;
1482 } 1481 }
1483 GNUNET_TESTBED_mark_host_registered_at_ (host, controller); 1482 GNUNET_TESTBED_mark_host_registered_at_ (host, c);
1484 controller->host = host; 1483 c->host = host;
1485 controller->opq_parallel_operations = 1484 c->opq_parallel_operations =
1486 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1485 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1487 max_parallel_operations); 1486 max_parallel_operations);
1488 controller->opq_parallel_service_connections = 1487 c->opq_parallel_service_connections =
1489 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1488 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1490 max_parallel_service_connections); 1489 max_parallel_service_connections);
1491 controller->opq_parallel_topology_config_operations = 1490 c->opq_parallel_topology_config_operations =
1492 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1491 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1493 max_parallel_topology_config_operations); 1492 max_parallel_topology_config_operations);
1494 controller_hostname = GNUNET_TESTBED_host_get_hostname (host); 1493 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage));
1495 if (NULL == controller_hostname)
1496 controller_hostname = "127.0.0.1";
1497 msg =
1498 GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage) +
1499 strlen (controller_hostname) + 1);
1500 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT); 1494 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT);
1501 msg->header.size = 1495 msg->header.size = htons (sizeof (struct GNUNET_TESTBED_InitMessage));
1502 htons (sizeof (struct GNUNET_TESTBED_InitMessage) +
1503 strlen (controller_hostname) + 1);
1504 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host)); 1496 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1505 msg->event_mask = GNUNET_htonll (controller->event_mask); 1497 msg->event_mask = GNUNET_htonll (c->event_mask);
1506 strcpy ((char *) &msg[1], controller_hostname); 1498 GNUNET_TESTBED_queue_message_ (c, &msg->header);
1507 GNUNET_TESTBED_queue_message_ (controller, 1499 return c;
1508 (struct GNUNET_MessageHeader *) msg);
1509 return controller;
1510} 1500}
1511 1501
1512 1502