*/
static unsigned int failed_connections;
-/* Task handle to use to schedule test failure */
+/**
+ * Task handle to use to schedule test failure
+ */
GNUNET_SCHEDULER_TaskIdentifier die_task;
-/* Global return value (0 for success, anything else for failure) */
+/**
+ * Global return value (0 for success, anything else for failure)
+ */
static int ok;
/**
* @param size number of bytes in data
* @param data pointer to the result data
*/
-void
+static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
- const GNUNET_HashCode * key,
+ const struct GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
- GNUNET_HashCode original_key; /* Key data was stored data under */
+ struct GNUNET_HashCode original_key; /* Key data was stored data under */
char original_data[4]; /* Made up data that was stored */
- memset (&original_key, 42, sizeof (GNUNET_HashCode)); /* Set the key to what it was set to previously */
+ memset (&original_key, 42, sizeof (struct GNUNET_HashCode)); /* Set the key to what it was set to previously */
memset (original_data, 43, sizeof (original_data));
#if VERBOSE
unsigned int i;
#endif
- if ((0 != memcmp (&original_key, key, sizeof (GNUNET_HashCode))) ||
+ if ((0 != memcmp (&original_key, key, sizeof (struct GNUNET_HashCode))) ||
(0 != memcmp (original_data, data, sizeof (original_data))))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
#if VERBOSE
if (put_path != NULL)
{
- fprintf (stderr, "PUT Path: ");
- for (i = 0; i<put_path_length; i++)
- fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&put_path[i]));
- fprintf (stderr, "\n");
+ FPRINTF (stderr, "%s", "PUT Path: ");
+ for (i = 0; i < put_path_length; i++)
+ FPRINTF (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&put_path[i]));
+ FPRINTF (stderr, "%s", "\n");
}
if (get_path != NULL)
{
- fprintf (stderr, "GET Path: ");
- for (i = 0; i<get_path_length; i++)
- fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&get_path[i]));
- fprintf (stderr, "\n");
+ FPRINTF (stderr, "%s", "GET Path: ");
+ for (i = 0; i < get_path_length; i++)
+ FPRINTF (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&get_path[i]));
+ FPRINTF (stderr, "%s", "\n");
}
#endif
GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
}
-/**
- * Start the GET request for the same key/data that was inserted.
- */
-static void
-do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_HashCode key; /* Key for data lookup */
-
- memset (&key, 42, sizeof (GNUNET_HashCode)); /* Set the key to the same thing as when data was inserted */
- global_get_handle =
- GNUNET_DHT_get_start (peer2dht, GNUNET_TIME_relative_get_forever (),
- GNUNET_BLOCK_TYPE_TEST, &key,
- 1, GNUNET_DHT_RO_RECORD_ROUTE,
- NULL, 0, &get_result_iterator, NULL);
-}
/**
* Called when the PUT request has been transmitted to the DHT service.
* Schedule the GET request for some time in the future.
*/
static void
-put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+put_finished (void *cls, int success)
{
+ struct GNUNET_HashCode key; /* Key for data lookup */
+
GNUNET_SCHEDULER_cancel (die_task);
die_task =
GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &end_badly,
"waiting for get response (data not found)");
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL);
+ memset (&key, 42, sizeof (struct GNUNET_HashCode)); /* Set the key to the same thing as when data was inserted */
+ global_get_handle =
+ GNUNET_DHT_get_start (peer2dht,
+ GNUNET_BLOCK_TYPE_TEST, &key, 1,
+ GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0,
+ &get_result_iterator, NULL);
}
/**
static void
do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_HashCode key; /* Made up key to store data under */
+ struct GNUNET_HashCode key; /* Made up key to store data under */
char data[4]; /* Made up data to store */
- memset (&key, 42, sizeof (GNUNET_HashCode)); /* Set the key to something simple so we can issue GET request */
+ memset (&key, 42, sizeof (struct GNUNET_HashCode)); /* Set the key to something simple so we can issue GET request */
memset (data, 43, sizeof (data));
/* Insert the data at the first peer */
- GNUNET_DHT_put (peer1dht, &key, 1,
- GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_BLOCK_TYPE_TEST,
- sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS,
- GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL);
+ GNUNET_DHT_put (peer1dht, &key, 1, GNUNET_DHT_RO_RECORD_ROUTE,
+ GNUNET_BLOCK_TYPE_TEST, sizeof (data), data,
+ GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL,
+ &put_finished, NULL);
}
/**
* The emsg variable is NULL on success (peers connected), and non-NULL on
* failure (peers failed to connect).
*/
-void
+static void
topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
const struct GNUNET_PeerIdentity *second, uint32_t distance,
const struct GNUNET_CONFIGURATION_Handle *first_cfg,
/* Get number of peers to start from configuration (should be two) */
if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing_old", "num_peers",
&num_peers))
num_peers = DEFAULT_NUM_PEERS;