+act_malicious_cont (void *cls, int success)
+{
+ struct MaliciousContext *mc = cls;
+ struct Context *ctx = mc->ctx;
+
+ GNUNET_TESTBED_operation_done (ctx->op);
+ ctx->op = NULL;
+ return;
+}
+
+
+/**
+ * Call malicious API for all the malicious peers.
+ * @param cls the malicious context.
+ * @param op the operation that has been finished
+ * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
+ * @param emsg error message in case the operation has failed; will be NULL if
+ * operation has executed successfully.
+ */
+static void
+dht_set_malicious(void *cls,
+ struct GNUNET_TESTBED_Operation *op,
+ void *ca_result,
+ const char *emsg)
+{
+ struct MaliciousContext *mc = cls;
+ struct Context *ctx = mc->ctx;
+
+ GNUNET_assert (NULL != ctx);
+ GNUNET_assert (NULL != ctx->op);
+ GNUNET_assert (ctx->op == op);
+ mc->dht = (struct GNUNET_DHT_Handle *) ca_result;
+ if (NULL != emsg)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to DHT service failed: %s\n", emsg);
+ GNUNET_TESTBED_operation_done (ctx->op); /* Calls dht_disconnect_malicious() */
+ ctx->op = NULL;
+ return;
+ }
+ mc->dht_malicious = GNUNET_DHT_act_malicious(mc->dht, 1, act_malicious_cont, mc);
+}
+
+
+/**
+ * Adapter function called to destroy a connection to
+ * a service.
+ *
+ * @param cls the active context
+ * @param op_result service handle returned from the connect adapter
+ */
+static void
+dht_disconnect_malicious (void *cls, void *op_result)
+{
+ struct MaliciousContext *mc = cls;
+ count_malicious++;
+ GNUNET_assert (NULL != mc->dht);
+ GNUNET_assert (mc->dht == op_result);
+ GNUNET_DHT_disconnect (mc->dht);
+ mc->dht = NULL;
+ mc->ctx->op = NULL;
+ n_dht--;
+
+ if (0 != n_dht)
+ return;
+
+ if(n_malicious == count_malicious)
+ {
+ DEBUG("\n Call start_profiling()");
+ start_profiling();
+ }
+}
+
+
+/**
+ * Set the malicious variable in peer malicious context.
+ */
+static void
+set_malicious()