aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-service-testbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/gnunet-service-testbed.c')
-rw-r--r--src/testbed/gnunet-service-testbed.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 8976864f8..8e6ab2325 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -1776,6 +1776,8 @@ handle_peer_start (void *cls,
1776{ 1776{
1777 const struct GNUNET_TESTBED_PeerStartMessage *msg; 1777 const struct GNUNET_TESTBED_PeerStartMessage *msg;
1778 struct GNUNET_TESTBED_PeerEventMessage *reply; 1778 struct GNUNET_TESTBED_PeerEventMessage *reply;
1779 struct ForwardedOperationContext *fopc;
1780 struct Peer *peer;
1779 uint32_t peer_id; 1781 uint32_t peer_id;
1780 1782
1781 msg = (const struct GNUNET_TESTBED_PeerStartMessage *) message; 1783 msg = (const struct GNUNET_TESTBED_PeerStartMessage *) message;
@@ -1784,15 +1786,35 @@ handle_peer_start (void *cls,
1784 || (NULL == peer_list[peer_id])) 1786 || (NULL == peer_list[peer_id]))
1785 { 1787 {
1786 GNUNET_break (0); 1788 GNUNET_break (0);
1787 /* FIXME: reply with failure message or forward to slave controller */ 1789 LOG (GNUNET_ERROR_TYPE_ERROR,
1790 "Asked to start a non existent peer with id: %u\n", peer_id);
1791 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1792 return;
1793 }
1794 peer = peer_list[peer_id];
1795 if (GNUNET_YES == peer->is_remote)
1796 {
1797 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
1798 GNUNET_SERVER_client_keep (client);
1799 fopc->client = client;
1800 fopc->operation_id = GNUNET_ntohll (msg->operation_id);
1801 fopc->opc =
1802 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller,
1803 fopc->operation_id,
1804 &msg->header,
1805 &forwarded_operation_reply_relay,
1806 fopc);
1807 fopc->timeout_task =
1808 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
1809 &forwarded_operation_timeout, fopc);
1788 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1810 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1789 return; 1811 return;
1790 } 1812 }
1791 if (GNUNET_OK != 1813 if (GNUNET_OK !=
1792 GNUNET_TESTING_peer_start (peer_list[peer_id]->details.local.peer)) 1814 GNUNET_TESTING_peer_start (peer->details.local.peer))
1793 { 1815 {
1794 /* FIXME: return FAILURE message */ 1816 send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1795 GNUNET_break (0); 1817 "Failed to start");
1796 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1818 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1797 return; 1819 return;
1798 } 1820 }
@@ -1822,6 +1844,8 @@ handle_peer_stop (void *cls,
1822{ 1844{
1823 const struct GNUNET_TESTBED_PeerStopMessage *msg; 1845 const struct GNUNET_TESTBED_PeerStopMessage *msg;
1824 struct GNUNET_TESTBED_PeerEventMessage *reply; 1846 struct GNUNET_TESTBED_PeerEventMessage *reply;
1847 struct ForwardedOperationContext *fopc;
1848 struct Peer *peer;
1825 uint32_t peer_id; 1849 uint32_t peer_id;
1826 1850
1827 msg = (const struct GNUNET_TESTBED_PeerStopMessage *) message; 1851 msg = (const struct GNUNET_TESTBED_PeerStopMessage *) message;
@@ -1832,8 +1856,27 @@ handle_peer_stop (void *cls,
1832 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1856 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1833 return; 1857 return;
1834 } 1858 }
1859 peer = peer_list[peer_id];
1860 if (GNUNET_YES == peer->is_remote)
1861 {
1862 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
1863 GNUNET_SERVER_client_keep (client);
1864 fopc->client = client;
1865 fopc->operation_id = GNUNET_ntohll (msg->operation_id);
1866 fopc->opc =
1867 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller,
1868 fopc->operation_id,
1869 &msg->header,
1870 &forwarded_operation_reply_relay,
1871 fopc);
1872 fopc->timeout_task =
1873 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
1874 &forwarded_operation_timeout, fopc);
1875 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1876 return;
1877 }
1835 if (GNUNET_OK != 1878 if (GNUNET_OK !=
1836 GNUNET_TESTING_peer_stop (peer_list[peer_id]->details.local.peer)) 1879 GNUNET_TESTING_peer_stop (peer->details.local.peer))
1837 { 1880 {
1838 /* FIXME: return FAILURE message */ 1881 /* FIXME: return FAILURE message */
1839 GNUNET_break (0); 1882 GNUNET_break (0);