diff options
Diffstat (limited to 'src/testbed/testbed_api.c')
-rw-r--r-- | src/testbed/testbed_api.c | 198 |
1 files changed, 28 insertions, 170 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 7f1e3d8f7..869fa2fad 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -1516,113 +1516,6 @@ GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller | |||
1516 | 1516 | ||
1517 | 1517 | ||
1518 | /** | 1518 | /** |
1519 | * Same as the GNUNET_TESTBED_controller_link_2, but with ids for delegated host | ||
1520 | * and slave host | ||
1521 | * | ||
1522 | * @param op_cls the operation closure for the event which is generated to | ||
1523 | * signal success or failure of this operation | ||
1524 | * @param master handle to the master controller who creates the association | ||
1525 | * @param delegated_host_id id of the host to which requests should be delegated | ||
1526 | * @param slave_host_id id of the host which is used to run the slave controller | ||
1527 | * @param sxcfg serialized and compressed configuration | ||
1528 | * @param sxcfg_size the size sxcfg | ||
1529 | * @param scfg_size the size of uncompressed serialized configuration | ||
1530 | * @param is_subordinate GNUNET_YES if the controller at delegated_host should | ||
1531 | * be started by the slave controller; GNUNET_NO if the slave | ||
1532 | * controller has to connect to the already started delegated | ||
1533 | * controller via TCP/IP | ||
1534 | * @return the operation handle | ||
1535 | */ | ||
1536 | struct GNUNET_TESTBED_Operation * | ||
1537 | GNUNET_TESTBED_controller_link_2_ (void *op_cls, | ||
1538 | struct GNUNET_TESTBED_Controller *master, | ||
1539 | uint32_t delegated_host_id, | ||
1540 | uint32_t slave_host_id, const char *sxcfg, | ||
1541 | size_t sxcfg_size, size_t scfg_size, | ||
1542 | int is_subordinate) | ||
1543 | { | ||
1544 | struct OperationContext *opc; | ||
1545 | struct GNUNET_TESTBED_ControllerLinkRequest *msg; | ||
1546 | struct ControllerLinkData *data; | ||
1547 | uint16_t msg_size; | ||
1548 | |||
1549 | msg_size = sxcfg_size + sizeof (struct GNUNET_TESTBED_ControllerLinkRequest); | ||
1550 | msg = GNUNET_malloc (msg_size); | ||
1551 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS); | ||
1552 | msg->header.size = htons (msg_size); | ||
1553 | msg->delegated_host_id = htonl (delegated_host_id); | ||
1554 | msg->slave_host_id = htonl (slave_host_id); | ||
1555 | msg->config_size = htons ((uint16_t) scfg_size); | ||
1556 | msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; | ||
1557 | memcpy (&msg[1], sxcfg, sxcfg_size); | ||
1558 | data = GNUNET_malloc (sizeof (struct ControllerLinkData)); | ||
1559 | data->msg = msg; | ||
1560 | data->host_id = delegated_host_id; | ||
1561 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | ||
1562 | opc->c = master; | ||
1563 | opc->data = data; | ||
1564 | opc->type = OP_LINK_CONTROLLERS; | ||
1565 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); | ||
1566 | opc->state = OPC_STATE_INIT; | ||
1567 | opc->op_cls = op_cls; | ||
1568 | msg->operation_id = GNUNET_htonll (opc->id); | ||
1569 | opc->op = | ||
1570 | GNUNET_TESTBED_operation_create_ (opc, &opstart_link_controllers, | ||
1571 | &oprelease_link_controllers); | ||
1572 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, | ||
1573 | opc->op); | ||
1574 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
1575 | return opc->op; | ||
1576 | } | ||
1577 | |||
1578 | |||
1579 | /** | ||
1580 | * Same as the GNUNET_TESTBED_controller_link, however expects configuration in | ||
1581 | * serialized and compressed | ||
1582 | * | ||
1583 | * @param op_cls the operation closure for the event which is generated to | ||
1584 | * signal success or failure of this operation | ||
1585 | * @param master handle to the master controller who creates the association | ||
1586 | * @param delegated_host requests to which host should be delegated; cannot be NULL | ||
1587 | * @param slave_host which host is used to run the slave controller; use NULL to | ||
1588 | * make the master controller connect to the delegated host | ||
1589 | * @param sxcfg serialized and compressed configuration | ||
1590 | * @param sxcfg_size the size sxcfg | ||
1591 | * @param scfg_size the size of uncompressed serialized configuration | ||
1592 | * @param is_subordinate GNUNET_YES if the controller at delegated_host should | ||
1593 | * be started by the slave controller; GNUNET_NO if the slave | ||
1594 | * controller has to connect to the already started delegated | ||
1595 | * controller via TCP/IP | ||
1596 | * @return the operation handle | ||
1597 | */ | ||
1598 | struct GNUNET_TESTBED_Operation * | ||
1599 | GNUNET_TESTBED_controller_link_2 (void *op_cls, | ||
1600 | struct GNUNET_TESTBED_Controller *master, | ||
1601 | struct GNUNET_TESTBED_Host *delegated_host, | ||
1602 | struct GNUNET_TESTBED_Host *slave_host, | ||
1603 | const char *sxcfg, size_t sxcfg_size, | ||
1604 | size_t scfg_size, int is_subordinate) | ||
1605 | { | ||
1606 | uint32_t delegated_host_id; | ||
1607 | uint32_t slave_host_id; | ||
1608 | |||
1609 | GNUNET_assert (GNUNET_YES == | ||
1610 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); | ||
1611 | delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host); | ||
1612 | slave_host_id = | ||
1613 | GNUNET_TESTBED_host_get_id_ ((NULL != | ||
1614 | slave_host) ? slave_host : master->host); | ||
1615 | if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) | ||
1616 | GNUNET_assert (GNUNET_YES == | ||
1617 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); | ||
1618 | |||
1619 | return GNUNET_TESTBED_controller_link_2_ (op_cls, master, delegated_host_id, | ||
1620 | slave_host_id, sxcfg, sxcfg_size, | ||
1621 | scfg_size, is_subordinate); | ||
1622 | } | ||
1623 | |||
1624 | |||
1625 | /** | ||
1626 | * Compresses given configuration using zlib compress | 1519 | * Compresses given configuration using zlib compress |
1627 | * | 1520 | * |
1628 | * @param config the serialized configuration | 1521 | * @param config the serialized configuration |
@@ -1671,54 +1564,6 @@ GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1671 | *size = size_; | 1564 | *size = size_; |
1672 | *xsize = xsize_; | 1565 | *xsize = xsize_; |
1673 | return xconfig; | 1566 | return xconfig; |
1674 | } | ||
1675 | |||
1676 | |||
1677 | /** | ||
1678 | * Same as the GNUNET_TESTBED_controller_link, but with ids for delegated host | ||
1679 | * and slave host | ||
1680 | * | ||
1681 | * @param op_cls the operation closure for the event which is generated to | ||
1682 | * signal success or failure of this operation | ||
1683 | * @param master handle to the master controller who creates the association | ||
1684 | * @param delegated_host_id id of the host to which requests should be | ||
1685 | * delegated; cannot be NULL | ||
1686 | * @param slave_host_id id of the host which should connect to controller | ||
1687 | * running on delegated host ; use NULL to make the master controller | ||
1688 | * connect to the delegated host | ||
1689 | * @param slave_cfg configuration to use for the slave controller | ||
1690 | * @param is_subordinate GNUNET_YES if the controller at delegated_host should | ||
1691 | * be started by the slave controller; GNUNET_NO if the slave | ||
1692 | * controller has to connect to the already started delegated | ||
1693 | * controller via TCP/IP | ||
1694 | * @return the operation handle | ||
1695 | */ | ||
1696 | struct GNUNET_TESTBED_Operation * | ||
1697 | GNUNET_TESTBED_controller_link_ (void *op_cls, | ||
1698 | struct GNUNET_TESTBED_Controller *master, | ||
1699 | uint32_t delegated_host_id, | ||
1700 | uint32_t slave_host_id, | ||
1701 | const struct GNUNET_CONFIGURATION_Handle | ||
1702 | *slave_cfg, int is_subordinate) | ||
1703 | { | ||
1704 | struct GNUNET_TESTBED_Operation *op; | ||
1705 | char *config; | ||
1706 | char *cconfig; | ||
1707 | size_t cc_size; | ||
1708 | size_t config_size; | ||
1709 | |||
1710 | config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size); | ||
1711 | cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig); | ||
1712 | GNUNET_free (config); | ||
1713 | /* Configuration doesn't fit in 1 message */ | ||
1714 | GNUNET_assert ((UINT16_MAX - | ||
1715 | sizeof (struct GNUNET_TESTBED_ControllerLinkRequest)) >= | ||
1716 | cc_size); | ||
1717 | op = GNUNET_TESTBED_controller_link_2_ (op_cls, master, delegated_host_id, | ||
1718 | slave_host_id, (const char *) cconfig, | ||
1719 | cc_size, config_size, is_subordinate); | ||
1720 | GNUNET_free (cconfig); | ||
1721 | return op; | ||
1722 | } | 1567 | } |
1723 | 1568 | ||
1724 | 1569 | ||
@@ -1759,8 +1604,12 @@ GNUNET_TESTBED_controller_link (void *op_cls, | |||
1759 | const struct GNUNET_CONFIGURATION_Handle | 1604 | const struct GNUNET_CONFIGURATION_Handle |
1760 | *slave_cfg, int is_subordinate) | 1605 | *slave_cfg, int is_subordinate) |
1761 | { | 1606 | { |
1607 | struct OperationContext *opc; | ||
1608 | struct GNUNET_TESTBED_ControllerLinkRequest *msg; | ||
1609 | struct ControllerLinkData *data; | ||
1762 | uint32_t slave_host_id; | 1610 | uint32_t slave_host_id; |
1763 | uint32_t delegated_host_id; | 1611 | uint32_t delegated_host_id; |
1612 | uint16_t msg_size; | ||
1764 | 1613 | ||
1765 | GNUNET_assert (GNUNET_YES == | 1614 | GNUNET_assert (GNUNET_YES == |
1766 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); | 1615 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); |
@@ -1771,11 +1620,30 @@ GNUNET_TESTBED_controller_link (void *op_cls, | |||
1771 | if ((NULL != slave_host) && (0 != slave_host_id)) | 1620 | if ((NULL != slave_host) && (0 != slave_host_id)) |
1772 | GNUNET_assert (GNUNET_YES == | 1621 | GNUNET_assert (GNUNET_YES == |
1773 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); | 1622 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); |
1774 | return GNUNET_TESTBED_controller_link_ (op_cls, master, delegated_host_id, | 1623 | msg_size = sizeof (struct GNUNET_TESTBED_ControllerLinkRequest); |
1775 | slave_host_id, | 1624 | msg = GNUNET_malloc (msg_size); |
1776 | GNUNET_TESTBED_host_get_cfg_ (delegated_host), | 1625 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS); |
1777 | is_subordinate); | 1626 | msg->header.size = htons (msg_size); |
1778 | 1627 | msg->delegated_host_id = htonl (delegated_host_id); | |
1628 | msg->slave_host_id = htonl (slave_host_id); | ||
1629 | msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;data = GNUNET_malloc (sizeof (struct ControllerLinkData)); | ||
1630 | data->msg = msg; | ||
1631 | data->host_id = delegated_host_id; | ||
1632 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | ||
1633 | opc->c = master; | ||
1634 | opc->data = data; | ||
1635 | opc->type = OP_LINK_CONTROLLERS; | ||
1636 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); | ||
1637 | opc->state = OPC_STATE_INIT; | ||
1638 | opc->op_cls = op_cls; | ||
1639 | msg->operation_id = GNUNET_htonll (opc->id); | ||
1640 | opc->op = | ||
1641 | GNUNET_TESTBED_operation_create_ (opc, &opstart_link_controllers, | ||
1642 | &oprelease_link_controllers); | ||
1643 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, | ||
1644 | opc->op); | ||
1645 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
1646 | return opc->op; | ||
1779 | } | 1647 | } |
1780 | 1648 | ||
1781 | 1649 | ||
@@ -2009,16 +1877,6 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg) | |||
2009 | xdata = (const Bytef *) &imsg[1]; | 1877 | xdata = (const Bytef *) &imsg[1]; |
2010 | } | 1878 | } |
2011 | break; | 1879 | break; |
2012 | case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS: | ||
2013 | { | ||
2014 | const struct GNUNET_TESTBED_ControllerLinkRequest *imsg; | ||
2015 | imsg = (const struct GNUNET_TESTBED_ControllerLinkRequest *) msg; | ||
2016 | data_len = ntohs (imsg->config_size); | ||
2017 | xdata_len = ntohs (imsg->header.size) - sizeof (const struct | ||
2018 | GNUNET_TESTBED_ControllerLinkRequest); | ||
2019 | xdata = (const Bytef *) &imsg[1]; | ||
2020 | } | ||
2021 | break; | ||
2022 | default: | 1880 | default: |
2023 | GNUNET_assert (0); | 1881 | GNUNET_assert (0); |
2024 | } | 1882 | } |