aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-service-testbed_peers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/gnunet-service-testbed_peers.c')
-rw-r--r--src/testbed/gnunet-service-testbed_peers.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/testbed/gnunet-service-testbed_peers.c b/src/testbed/gnunet-service-testbed_peers.c
index 1792373a3..959229543 100644
--- a/src/testbed/gnunet-service-testbed_peers.c
+++ b/src/testbed/gnunet-service-testbed_peers.c
@@ -22,7 +22,7 @@
22/** 22/**
23 * @file testbed/gnunet-service-testbed_peers.c 23 * @file testbed/gnunet-service-testbed_peers.c
24 * @brief implementation of TESTBED service that deals with peer management 24 * @brief implementation of TESTBED service that deals with peer management
25 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 25 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
26 */ 26 */
27 27
28#include "gnunet-service-testbed.h" 28#include "gnunet-service-testbed.h"
@@ -70,12 +70,12 @@ struct ManageServiceContext
70 * The client which requested to manage the peer's service 70 * The client which requested to manage the peer's service
71 */ 71 */
72 struct GNUNET_SERVER_Client *client; 72 struct GNUNET_SERVER_Client *client;
73 73
74 /** 74 /**
75 * The operation id of the associated request 75 * The operation id of the associated request
76 */ 76 */
77 uint64_t op_id; 77 uint64_t op_id;
78 78
79 /** 79 /**
80 * 1 if the service at the peer has to be started; 0 if it has to be stopped 80 * 1 if the service at the peer has to be started; 0 if it has to be stopped
81 */ 81 */
@@ -85,7 +85,7 @@ struct ManageServiceContext
85 * Is this context expired? Do not work on this context if it is set to 85 * Is this context expired? Do not work on this context if it is set to
86 * GNUNET_YES 86 * GNUNET_YES
87 */ 87 */
88 uint8_t expired; 88 uint8_t expired;
89}; 89};
90 90
91 91
@@ -343,7 +343,7 @@ GST_handle_peer_create (void *cls, struct GNUNET_SERVER_Client *client,
343 return; 343 return;
344 } 344 }
345 if (UINT32_MAX == peer_id) 345 if (UINT32_MAX == peer_id)
346 { 346 {
347 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 347 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
348 "Cannot create peer with given ID"); 348 "Cannot create peer with given ID");
349 GNUNET_SERVER_receive_done (client, GNUNET_OK); 349 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -793,7 +793,7 @@ prc_stop_cb (void *cls, struct GNUNET_TESTING_Peer *p, int success)
793 struct PeerReconfigureContext *prc = cls; 793 struct PeerReconfigureContext *prc = cls;
794 struct Peer *peer; 794 struct Peer *peer;
795 char *emsg; 795 char *emsg;
796 796
797 GNUNET_assert (VALID_PEER_ID (prc->peer_id)); 797 GNUNET_assert (VALID_PEER_ID (prc->peer_id));
798 peer = GST_peer_list [prc->peer_id]; 798 peer = GST_peer_list [prc->peer_id];
799 GNUNET_assert (GNUNET_NO == peer->is_remote); 799 GNUNET_assert (GNUNET_NO == peer->is_remote);
@@ -815,13 +815,13 @@ prc_stop_cb (void *cls, struct GNUNET_TESTING_Peer *p, int success)
815 } 815 }
816 if (GNUNET_OK != start_peer (peer)) 816 if (GNUNET_OK != start_peer (peer))
817 { 817 {
818 818
819 GST_send_operation_fail_msg (prc->client, prc->op_id, 819 GST_send_operation_fail_msg (prc->client, prc->op_id,
820 "Failed to start reconfigured peer"); 820 "Failed to start reconfigured peer");
821 goto cleanup; 821 goto cleanup;
822 } 822 }
823 GST_send_operation_success_msg (prc->client, prc->op_id); 823 GST_send_operation_success_msg (prc->client, prc->op_id);
824 824
825 cleanup: 825 cleanup:
826 cleanup_prc (prc); 826 cleanup_prc (prc);
827 return; 827 return;
@@ -849,7 +849,7 @@ GST_handle_peer_reconfigure (void *cls, struct GNUNET_SERVER_Client *client,
849 uint64_t op_id; 849 uint64_t op_id;
850 uint32_t peer_id; 850 uint32_t peer_id;
851 uint16_t msize; 851 uint16_t msize;
852 852
853 msize = ntohs (message->size); 853 msize = ntohs (message->size);
854 if (msize <= sizeof (struct GNUNET_TESTBED_PeerReconfigureMessage)) 854 if (msize <= sizeof (struct GNUNET_TESTBED_PeerReconfigureMessage))
855 { 855 {
@@ -907,7 +907,7 @@ GST_handle_peer_reconfigure (void *cls, struct GNUNET_SERVER_Client *client,
907 cfg = GNUNET_TESTBED_extract_config_ (message); 907 cfg = GNUNET_TESTBED_extract_config_ (message);
908 if (NULL == cfg) 908 if (NULL == cfg)
909 { 909 {
910 GNUNET_break (0); 910 GNUNET_break (0);
911 GST_send_operation_fail_msg (client, op_id, "Compression error"); 911 GST_send_operation_fail_msg (client, op_id, "Compression error");
912 GNUNET_SERVER_receive_done (client, GNUNET_OK); 912 GNUNET_SERVER_receive_done (client, GNUNET_OK);
913 return; 913 return;
@@ -916,7 +916,7 @@ GST_handle_peer_reconfigure (void *cls, struct GNUNET_SERVER_Client *client,
916 prc->cfg = cfg; 916 prc->cfg = cfg;
917 prc->peer_id = peer_id; 917 prc->peer_id = peer_id;
918 prc->op_id = op_id; 918 prc->op_id = op_id;
919 prc->client = client; 919 prc->client = client;
920 GNUNET_SERVER_client_keep (client); 920 GNUNET_SERVER_client_keep (client);
921 GNUNET_CONTAINER_DLL_insert_tail (prc_head, prc_tail, prc); 921 GNUNET_CONTAINER_DLL_insert_tail (prc_head, prc_tail, prc);
922 GNUNET_TESTING_peer_stop_async (peer->details.local.peer, prc_stop_cb, prc); 922 GNUNET_TESTING_peer_stop_async (peer->details.local.peer, prc_stop_cb, prc);
@@ -1032,8 +1032,8 @@ arm_ret_string (enum GNUNET_ARM_Result result)
1032 * @param result result of the operation 1032 * @param result result of the operation
1033 */ 1033 */
1034static void 1034static void
1035service_manage_result_cb (void *cls, 1035service_manage_result_cb (void *cls,
1036 enum GNUNET_ARM_RequestStatus rs, 1036 enum GNUNET_ARM_RequestStatus rs,
1037 const char *service, enum GNUNET_ARM_Result result) 1037 const char *service, enum GNUNET_ARM_Result result)
1038{ 1038{
1039 struct ManageServiceContext *mctx = cls; 1039 struct ManageServiceContext *mctx = cls;
@@ -1072,7 +1072,7 @@ service_manage_result_cb (void *cls,
1072 goto ret; 1072 goto ret;
1073 } 1073 }
1074 /* service started successfully */ 1074 /* service started successfully */
1075 1075
1076 ret: 1076 ret:
1077 if (NULL != emsg) 1077 if (NULL != emsg)
1078 { 1078 {
@@ -1107,17 +1107,17 @@ GST_handle_manage_peer_service (void *cls, struct GNUNET_SERVER_Client *client,
1107 uint64_t op_id; 1107 uint64_t op_id;
1108 uint32_t peer_id; 1108 uint32_t peer_id;
1109 uint16_t msize; 1109 uint16_t msize;
1110 1110
1111 1111
1112 msize = ntohs (message->size); 1112 msize = ntohs (message->size);
1113 if (msize <= sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage)) 1113 if (msize <= sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage))
1114 { 1114 {
1115 GNUNET_break_op (0); 1115 GNUNET_break_op (0);
1116 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1116 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1117 return; 1117 return;
1118 } 1118 }
1119 msg = (const struct GNUNET_TESTBED_ManagePeerServiceMessage *) message; 1119 msg = (const struct GNUNET_TESTBED_ManagePeerServiceMessage *) message;
1120 service = (const char *) &msg[1]; 1120 service = (const char *) &msg[1];
1121 if ('\0' != service[msize - sizeof 1121 if ('\0' != service[msize - sizeof
1122 (struct GNUNET_TESTBED_ManagePeerServiceMessage) - 1]) 1122 (struct GNUNET_TESTBED_ManagePeerServiceMessage) - 1])
1123 { 1123 {
@@ -1129,7 +1129,7 @@ GST_handle_manage_peer_service (void *cls, struct GNUNET_SERVER_Client *client,
1129 { 1129 {
1130 GNUNET_break_op (0); 1130 GNUNET_break_op (0);
1131 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1131 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1132 return; 1132 return;
1133 } 1133 }
1134 peer_id = ntohl (msg->peer_id); 1134 peer_id = ntohl (msg->peer_id);
1135 op_id = GNUNET_ntohll (msg->operation_id); 1135 op_id = GNUNET_ntohll (msg->operation_id);
@@ -1247,7 +1247,7 @@ GST_destroy_peers ()
1247 { 1247 {
1248 peer = GST_peer_list[id]; 1248 peer = GST_peer_list[id];
1249 if (NULL == peer) 1249 if (NULL == peer)
1250 continue; 1250 continue;
1251 if (GNUNET_NO == peer->is_remote) 1251 if (GNUNET_NO == peer->is_remote)
1252 { 1252 {
1253 if (GNUNET_YES == peer->details.local.is_running) 1253 if (GNUNET_YES == peer->details.local.is_running)
@@ -1288,7 +1288,7 @@ shutdown_peers_timeout_cb (void *cls,
1288 GNUNET_free (hc); 1288 GNUNET_free (hc);
1289 hc = NULL; 1289 hc = NULL;
1290 } 1290 }
1291 GNUNET_TESTBED_forward_operation_msg_cancel_ (fo_ctxt->opc); 1291 GNUNET_TESTBED_forward_operation_msg_cancel_ (fo_ctxt->opc);
1292 GNUNET_SERVER_client_drop (fo_ctxt->client); 1292 GNUNET_SERVER_client_drop (fo_ctxt->client);
1293 GNUNET_CONTAINER_DLL_remove (fopcq_head, fopcq_tail, fo_ctxt); 1293 GNUNET_CONTAINER_DLL_remove (fopcq_head, fopcq_tail, fo_ctxt);
1294 GNUNET_free (fo_ctxt); 1294 GNUNET_free (fo_ctxt);
@@ -1309,14 +1309,14 @@ shutdown_peers_reply_cb (void *cls,
1309{ 1309{
1310 struct ForwardedOperationContext *fo_ctxt = cls; 1310 struct ForwardedOperationContext *fo_ctxt = cls;
1311 struct HandlerContext_ShutdownPeers *hc; 1311 struct HandlerContext_ShutdownPeers *hc;
1312 1312
1313 hc = fo_ctxt->cls; 1313 hc = fo_ctxt->cls;
1314 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != fo_ctxt->timeout_task); 1314 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != fo_ctxt->timeout_task);
1315 GNUNET_SCHEDULER_cancel (fo_ctxt->timeout_task); 1315 GNUNET_SCHEDULER_cancel (fo_ctxt->timeout_task);
1316 fo_ctxt->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1316 fo_ctxt->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1317 GNUNET_assert (0 < hc->nslaves); 1317 GNUNET_assert (0 < hc->nslaves);
1318 hc->nslaves--; 1318 hc->nslaves--;
1319 if (GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS != 1319 if (GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS !=
1320 ntohs (msg->type)) 1320 ntohs (msg->type))
1321 hc->timeout = GNUNET_YES; 1321 hc->timeout = GNUNET_YES;
1322 if (0 == hc->nslaves) 1322 if (0 == hc->nslaves)
@@ -1398,5 +1398,5 @@ GST_handle_shutdown_peers (void *cls, struct GNUNET_SERVER_Client *client,
1398 GST_send_operation_success_msg (client, op_id); 1398 GST_send_operation_success_msg (client, op_id);
1399 GNUNET_free (hc); 1399 GNUNET_free (hc);
1400 } 1400 }
1401 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1401 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1402} 1402}