* FIXME: Do churn!
*/
#include "platform.h"
+#ifndef HAVE_MALICIOUS
+#error foo
+#endif
#include "gnunet_testing_lib.h"
#include "gnunet_core_service.h"
#include "gnunet_dht_service.h"
/*
* Default frequency for sending malicious get messages
*/
-#define DEFAULT_MALICIOUS_GET_FREQUENCY 1000 /* Number of milliseconds */
+#define DEFAULT_MALICIOUS_GET_FREQUENCY GNUNET_TIME_UNIT_SECONDS
/*
* Default frequency for sending malicious put messages
*/
-#define DEFAULT_MALICIOUS_PUT_FREQUENCY 1000 /* Default is in milliseconds */
+#define DEFAULT_MALICIOUS_PUT_FREQUENCY GNUNET_TIME_UNIT_SECONDS
/* Structs */
static unsigned long long malicious_droppers;
-static unsigned long long malicious_get_frequency;
+static struct GNUNET_TIME_Relative malicious_get_frequency;
-static unsigned long long malicious_put_frequency;
+static struct GNUNET_TIME_Relative malicious_put_frequency;
static unsigned long long settle_time;
if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task);
if (test_get->get_handle != NULL)
- GNUNET_DHT_get_stop(test_get->get_handle, NULL, NULL);
+ GNUNET_DHT_get_stop(test_get->get_handle);
if (test_get->dht_handle != NULL)
GNUNET_DHT_disconnect(test_get->dht_handle);
test_get = test_get->next;
if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task);
if (test_get->get_handle != NULL)
- GNUNET_DHT_get_stop(test_get->get_handle, NULL, NULL);
+ GNUNET_DHT_get_stop(test_get->get_handle);
if (test_get->dht_handle != NULL)
GNUNET_DHT_disconnect(test_get->dht_handle);
test_get = test_get->next;
if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
gets_failed++;
GNUNET_assert(test_get->get_handle != NULL);
- GNUNET_DHT_get_stop(test_get->get_handle, &get_stop_finished, test_get);
+ GNUNET_DHT_get_stop(test_get->get_handle);
test_get->get_handle = NULL;
test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get);
}
/**
* @param cls closure
* @param exp when will this value expire
* @param key key of the result
+ * @param get_path NULL-terminated array of pointers
+ * to the peers on reverse GET path (or NULL if not recorded)
+ * @param put_path NULL-terminated array of pointers
+ * to the peers on the PUT path (or NULL if not recorded)
* @param type type of the result
* @param size number of bytes in data
* @param data pointer to the result data
void get_result_iterator (void *cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- uint32_t type,
+ const struct GNUNET_PeerIdentity * const *get_path,
+ const struct GNUNET_PeerIdentity * const *put_path,
+ enum GNUNET_BLOCK_Type type,
uint32_t size,
const void *data)
{
GNUNET_SCHEDULER_add_continuation(sched, &get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE);
}
-/**
- * Continuation telling us GET request was sent.
- */
-static void
-get_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
-{
- // Is there something to be done here?
- if (tc->reason != GNUNET_SCHEDULER_REASON_PREREQ_DONE)
- return;
-}
+
/**
* Set up some data, and call API PUT function
/* Insert the data at the first peer */
test_get->get_handle = GNUNET_DHT_get_start(test_get->dht_handle,
get_delay,
- 1,
+ 1 /* FIXME: use real type */,
&known_keys[test_get->uid],
+ GNUNET_DHT_RO_NONE,
+ NULL, 0,
+ NULL, 0,
&get_result_iterator,
- test_get,
- &get_continuation,
test_get);
+
#if VERBOSE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n",
test_get->uid,
outstanding_puts++;
GNUNET_DHT_put(test_put->dht_handle,
&known_keys[test_put->uid],
- 1,
+ GNUNET_DHT_RO_NONE,
+ 1 /* FIXME: use real type */,
sizeof(data), data,
- GNUNET_TIME_absolute_get_forever(),
+ GNUNET_TIME_UNIT_FOREVER_ABS,
put_delay,
&put_finished, test_put);
test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put);
set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
{
struct MaliciousContext *ctx = cls;
- int ret;
if (outstanding_malicious > DEFAULT_MAX_OUTSTANDING_GETS)
{
ctx->daemon->shortname, ctx->malicious_type);
#endif
- ret = GNUNET_YES;
switch (ctx->malicious_type)
{
case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET:
- ret = GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency, &malicious_done_task, ctx);
+ GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency);
+ GNUNET_SCHEDULER_add_now (sched,
+ &malicious_done_task, ctx);
break;
case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT:
- ret = GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency, &malicious_done_task, ctx);
+ GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency);
+ GNUNET_SCHEDULER_add_now (sched,
+ &malicious_done_task, ctx);
break;
case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP:
- ret = GNUNET_DHT_set_malicious_dropper(ctx->dht_handle, &malicious_done_task, ctx);
+ GNUNET_DHT_set_malicious_dropper(ctx->dht_handle);
+ GNUNET_SCHEDULER_add_now (sched, &malicious_done_task, ctx);
break;
default:
break;
}
- if (ret == GNUNET_NO)
- {
- GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx);
- }
- else
- ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &malicious_disconnect_task, ctx);
+ ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &malicious_disconnect_task, ctx);
}
/**
replicate_same = GNUNET_YES;
}
- if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING",
- "MALICIOUS_GET_FREQUENCY",
- &malicious_get_frequency))
+ if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING",
+ "MALICIOUS_GET_FREQUENCY",
+ &malicious_get_frequency))
malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY;
- if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING",
- "MALICIOUS_PUT_FREQUENCY",
- &malicious_put_frequency))
+ if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING",
+ "MALICIOUS_PUT_FREQUENCY",
+ &malicious_put_frequency))
malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY;
trial_info.malicious_getters = malicious_getters;
trial_info.malicious_putters = malicious_putters;
trial_info.malicious_droppers = malicious_droppers;
- trial_info.malicious_get_frequency = malicious_get_frequency;
- trial_info.malicious_put_frequency = malicious_put_frequency;
+ trial_info.malicious_get_frequency = malicious_get_frequency.value;
+ trial_info.malicious_put_frequency = malicious_put_frequency.value;
trial_info.stop_closest = stop_closest;
trial_info.stop_found = stop_found;
trial_info.strict_kademlia = strict_kademlia;