+
+ GNUNET_assert (OP_PEER_START == opc->type);
+ GNUNET_assert (NULL != (data = opc->data));
+ GNUNET_assert (NULL != (peer = data->peer));
+ GNUNET_assert ((TESTBED_PS_CREATED == peer->state) || (TESTBED_PS_STOPPED ==
+ peer->state));
+ opc->state = OPC_STATE_STARTED;
+ env = GNUNET_MQ_msg (msg,
+ GNUNET_MESSAGE_TYPE_TESTBED_START_PEER);
+ msg->peer_id = htonl (peer->unique_id);
+ msg->operation_id = GNUNET_htonll (opc->id);
+ GNUNET_TESTBED_insert_opc_ (opc->c, opc);
+ GNUNET_MQ_send (peer->controller->mq,
+ env);
+}
+
+
+/**
+ * Callback which will be called when peer start type operation is released
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+oprelease_peer_start (void *cls)
+{
+ struct OperationContext *opc = cls;
+
+ switch (opc->state)
+ {
+ case OPC_STATE_STARTED:
+ GNUNET_TESTBED_remove_opc_ (opc->c, opc);
+
+ /* no break; continue */
+ case OPC_STATE_INIT:
+ GNUNET_free (opc->data);
+ break;
+
+ case OPC_STATE_FINISHED:
+ break;
+ }
+ GNUNET_free (opc);
+}
+
+
+/**
+ * Function called when a peer stop operation is ready
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+opstart_peer_stop (void *cls)
+{
+ struct OperationContext *opc = cls;
+ struct GNUNET_TESTBED_PeerStopMessage *msg;
+ struct PeerEventData *data;
+ struct GNUNET_TESTBED_Peer *peer;
+ struct GNUNET_MQ_Envelope *env;
+
+ GNUNET_assert (NULL != (data = opc->data));
+ GNUNET_assert (NULL != (peer = data->peer));
+ GNUNET_assert (TESTBED_PS_STARTED == peer->state);
+ opc->state = OPC_STATE_STARTED;
+ env = GNUNET_MQ_msg (msg,
+ GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER);
+ msg->peer_id = htonl (peer->unique_id);
+ msg->operation_id = GNUNET_htonll (opc->id);
+ GNUNET_TESTBED_insert_opc_ (opc->c, opc);
+ GNUNET_MQ_send (peer->controller->mq,
+ env);
+}
+
+
+/**
+ * Callback which will be called when peer stop type operation is released
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+oprelease_peer_stop (void *cls)
+{
+ struct OperationContext *opc = cls;
+
+ switch (opc->state)
+ {
+ case OPC_STATE_STARTED:
+ GNUNET_TESTBED_remove_opc_ (opc->c, opc);
+
+ /* no break; continue */
+ case OPC_STATE_INIT:
+ GNUNET_free (opc->data);
+ break;
+
+ case OPC_STATE_FINISHED:
+ break;
+ }
+ GNUNET_free (opc);
+}
+
+
+/**
+ * Generate PeerGetConfigurationMessage
+ *
+ * @param peer_id the id of the peer whose information we have to get
+ * @param operation_id the ip of the operation that should be represented in the
+ * message
+ * @return the PeerGetConfigurationMessage
+ */
+struct GNUNET_TESTBED_PeerGetConfigurationMessage *
+GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id,
+ uint64_t operation_id)
+{
+ struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg;
+
+ msg =
+ GNUNET_malloc (sizeof
+ (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
+ msg->header.size =
+ htons (sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage));
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION);
+ msg->peer_id = htonl (peer_id);
+ msg->operation_id = GNUNET_htonll (operation_id);
+ return msg;
+}
+
+
+/**
+ * Function called when a peer get information operation is ready
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+opstart_peer_getinfo (void *cls)
+{
+ struct OperationContext *opc = cls;
+ struct PeerInfoData *data = opc->data;
+ struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg;
+
+ GNUNET_assert (NULL != data);
+ opc->state = OPC_STATE_STARTED;
+ msg =
+ GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id,
+ opc->id);
+ GNUNET_TESTBED_insert_opc_ (opc->c, opc);
+ GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
+}
+
+
+/**
+ * Callback which will be called when peer stop type operation is released
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+oprelease_peer_getinfo (void *cls)
+{
+ struct OperationContext *opc = cls;
+ struct GNUNET_TESTBED_PeerInformation *data;
+
+ switch (opc->state)
+ {
+ case OPC_STATE_STARTED:
+ GNUNET_TESTBED_remove_opc_ (opc->c, opc);
+
+ /* no break; continue */
+ case OPC_STATE_INIT:
+ GNUNET_free (opc->data);
+ break;
+
+ case OPC_STATE_FINISHED:
+ data = opc->data;
+ GNUNET_assert (NULL != data);
+ switch (data->pit)
+ {
+ case GNUNET_TESTBED_PIT_CONFIGURATION:
+ if (NULL != data->result.cfg)
+ GNUNET_CONFIGURATION_destroy (data->result.cfg);
+ break;
+
+ case GNUNET_TESTBED_PIT_IDENTITY:
+ GNUNET_free (data->result.id);
+ break;
+
+ default:
+ GNUNET_assert (0); /* We should never reach here */
+ }
+ GNUNET_free (data);
+ break;
+ }
+ GNUNET_free (opc);
+}
+
+
+/**
+ * Function called when a overlay connect operation is ready
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+opstart_overlay_connect (void *cls)
+{
+ struct OperationContext *opc = cls;
+ struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_TESTBED_OverlayConnectMessage *msg;
+ struct OverlayConnectData *data;
+
+ opc->state = OPC_STATE_STARTED;
+ data = opc->data;
+ GNUNET_assert (NULL != data);
+ env = GNUNET_MQ_msg (msg,
+ GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT);
+ msg->peer1 = htonl (data->p1->unique_id);
+ msg->peer2 = htonl (data->p2->unique_id);
+ msg->operation_id = GNUNET_htonll (opc->id);
+ msg->peer2_host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->p2->host));
+ GNUNET_TESTBED_insert_opc_ (opc->c,
+ opc);
+ GNUNET_MQ_send (opc->c->mq,
+ env);
+}
+
+
+/**
+ * Callback which will be called when overlay connect operation is released
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+oprelease_overlay_connect (void *cls)
+{
+ struct OperationContext *opc = cls;
+ struct OverlayConnectData *data;
+
+ data = opc->data;
+ switch (opc->state)
+ {
+ case OPC_STATE_INIT:
+ break;
+
+ case OPC_STATE_STARTED:
+ GNUNET_TESTBED_remove_opc_ (opc->c, opc);
+ break;
+
+ case OPC_STATE_FINISHED:
+ break;
+ }
+ GNUNET_free (data);
+ GNUNET_free (opc);
+}
+
+
+/**
+ * Function called when a peer reconfigure operation is ready
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+opstart_peer_reconfigure (void *cls)
+{
+ struct OperationContext *opc = cls;
+ struct PeerReconfigureData *data = opc->data;
+ struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_TESTBED_PeerReconfigureMessage *msg;