return;
}
- /* Forward the peer to other host */
+ /* FIXME: Forward the peer to other host */
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
if ((peer_list_size <= peer_id) || (NULL == peer_list[peer_id]))
{
GNUNET_break (0);
- /* Reply with failure event message */
+ /* FIXME: Reply with failure event message or forward to slave controller */
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *reply;
uint32_t peer_id;
- GNUNET_assert (ntohs (message->size)
- == sizeof (struct GNUNET_TESTBED_PeerStartMessage));
msg = (const struct GNUNET_TESTBED_PeerStartMessage *) message;
peer_id = ntohl (msg->peer_id);
if ((peer_id >= peer_list_size)
|| (GNUNET_OK != GNUNET_TESTING_peer_start (peer_list[peer_id]->peer)))
{
GNUNET_break (0);
- /* FIXME: reply with failure message */
+ /* FIXME: reply with failure message or forward to slave controller */
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
}
+/**
+ * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages
+ *
+ * @param cls NULL
+ * @param client identification of the client
+ * @param message the actual message
+ */
+static void
+handle_peer_stop (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ const struct GNUNET_TESTBED_PeerStopMessage *msg;
+ struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *reply;
+ uint32_t peer_id;
+
+ msg = (const struct GNUNET_TESTBED_PeerStopMessage *) message;
+ peer_id = ntohl (msg->peer_id);
+ if ((peer_id >= peer_list_size) || (NULL == peer_list[peer_id]))
+ {
+ GNUNET_break (0); /* FIXME: route to slave? */
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+ if (GNUNET_OK != GNUNET_TESTING_peer_stop (peer_list[peer_id]->peer))
+ {
+ /* FIXME: return FAILURE message */
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+ reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage));
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS);
+ reply->header.size = htons (sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage));
+ reply->operation_id = msg->operation_id;
+ reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_STOP);
+ queue_message (client, &reply->header);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
/**
* Iterator over hash map entries.
*
sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)},
{&handle_peer_start, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER,
sizeof (struct GNUNET_TESTBED_PeerStartMessage)},
+ {&handle_peer_stop, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER,
+ sizeof (struct GNUNET_TESTBED_PeerStopMessage)},
{NULL}
};
msg->operation_id = GNUNET_htonll (op->operation_id);
GNUNET_CONTAINER_DLL_insert_tail (peer->controller->op_head,
peer->controller->op_tail, op);
- GNUNET_TESTBED_queue_message_ (peer->controller,
- (struct GNUNET_MessageHeader *) msg);
+ GNUNET_TESTBED_queue_message_ (peer->controller, &msg->header);
return NULL;
}
struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer)
{
- // FIXME: stop locally or delegate...
- GNUNET_break (0);
+ struct GNUNET_TESTBED_Operation *op;
+ struct GNUNET_TESTBED_PeerStopMessage *msg;
+
+ op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation));
+ op->operation_id = peer->controller->operation_counter++;
+ op->type = OP_PEER_STOP;
+ op->data = peer;
+ msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStopMessage));
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER);
+ msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerStopMessage));
+ msg->peer_id = htonl (peer->unique_id);
+ msg->operation_id = GNUNET_htonll (op->operation_id);
+ GNUNET_CONTAINER_DLL_insert_tail (peer->controller->op_head,
+ peer->controller->op_tail, op);
+ GNUNET_TESTBED_queue_message_ (peer->controller, &msg->header);
return NULL;
}