/*
This file is part of GNUnet.
- Copyright (C) 2009, 2012 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2012 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
/**
* How many peers do we start?
*/
-uint32_t num_peers;
+static uint32_t num_peers;
/**
* How long do we run the test?
*/
static int ok;
-
/**
* Identifier for the churn task that runs periodically
*/
static struct GNUNET_SCHEDULER_Task *churn_task;
-/**
- * Identifier for the churn task that runs periodically
- */
-static struct GNUNET_SCHEDULER_Task *shutdown_task;
-
-
/**
* Called to initialise the given RPSPeer
*/
* Append arguments to file
*/
static void
-tofile_ (const char *file_name, char *line)
+tofile_ (const char *file_name, const char *line)
{
struct GNUNET_DISK_FileHandle *f;
/* char output_buffer[512]; */
if (size != size2)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unable to write to file! (Size: %u, size2: %u)\n",
+ "Unable to write to file! (Size: %lu, size2: %lu)\n",
size,
size2);
return;
/**
- * Write the ids and their according index in the given array to a file
+ * Write the ids and their according index in the given array to a file
* Unused
*/
/* static void
* Task run on timeout to shut everything down.
*/
static void
-shutdown_op (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_op (void *cls)
{
unsigned int i;
in_shutdown = GNUNET_YES;
if (NULL != churn_task)
+ {
GNUNET_SCHEDULER_cancel (churn_task);
-
+ churn_task = NULL;
+ }
for (i = 0; i < num_peers; i++)
if (NULL != rps_peers[i].op)
GNUNET_TESTBED_operation_done (rps_peers[i].op);
/**
* Seed peers.
*/
- void
-seed_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+seed_peers (void *cls)
{
+ struct RPSPeer *peer = cls;
unsigned int amount;
- struct RPSPeer *peer = (struct RPSPeer *) cls;
unsigned int i;
// TODO if malicious don't seed mal peers
GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids);
}
+
/**
* Seed peers.
*/
- void
-seed_peers_big (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+seed_peers_big (void *cls)
{
- struct RPSPeer *peer = (struct RPSPeer *) cls;
+ struct RPSPeer *peer = cls;
unsigned int seed_msg_size;
uint32_t num_peers_max;
unsigned int amount;
"[%s] got %" PRIu64 " peers:\n",
GNUNET_i2s (rps_peer->peer_id),
n);
-
+
for (i = 0; i < n; i++)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
if (0 == evaluate ())
{
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL);
+ GNUNET_SCHEDULER_shutdown ();
}
}
* Request random peers.
*/
static void
-request_peers (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+request_peers (void *cls)
{
+ struct PendingRequest *pending_req = cls;
struct RPSPeer *rps_peer;
- struct PendingRequest *pending_req = (struct PendingRequest *) cls;
struct PendingReply *pending_rep;
if (GNUNET_YES == in_shutdown)
* Cancel a request.
*/
static void
-cancel_request_cb (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+cancel_request_cb (void *cls)
{
+ struct RPSPeer *rps_peer = cls;
struct PendingReply *pending_rep;
- struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
if (GNUNET_YES == in_shutdown)
return;
}
}
+
static void
-churn (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+churn (void *cls)
{
unsigned int i;
unsigned int j;
if (NULL != churn_task)
GNUNET_SCHEDULER_cancel (churn_task);
- shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
+ GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
}
(3 == mal_type))
target_peer = &rps_peer_ids[num_peers - 2];
if (profiler_eval == cur_test_run.eval_cb)
- eval_peer = &rps_peers[num_peers - 1];
+ eval_peer = &rps_peers[num_peers - 1]; /* FIXME: eval_peer could be a
+ malicious peer if not careful
+ with the malicious portion */
ok = 1;
(void) GNUNET_TESTBED_test_run (cur_test_run.name,