struct DHTRouteSource *pos;
struct PeerInfo *peer_info;
const struct GNUNET_MessageHeader *hello_msg;
+#if DEBUG_DHT > 1
unsigned int i;
- char *path_offset;
+#endif
increment_stats (STAT_RESULTS);
/**
increment_stats (STAT_RESULTS_TO_CLIENT);
if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_DHT_GET_RESULT)
increment_stats (STAT_GET_REPLY);
-
+#if DEBUG_DHT > 1
for (i = 0; i < msg_ctx->path_history_len; i++)
{
+ char *path_offset;
+
path_offset = &msg_ctx->path_history[i * sizeof(struct GNUNET_PeerIdentity)];
-#if DEBUG_DHT > 1
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "(before client) Key %s Found peer %d:%s\n", GNUNET_h2s(&msg_ctx->key), i, GNUNET_i2s((struct GNUNET_PeerIdentity *)path_offset));
-#endif
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "(before client) Key %s Found peer %d:%s\n",
+ GNUNET_h2s(&msg_ctx->key), i,
+ GNUNET_i2s((struct GNUNET_PeerIdentity *)path_offset));
}
+#endif
send_reply_to_client (pos->client, msg, msg_ctx);
}
else /* Send to peer */
unsigned int i;
unsigned int count;
unsigned int offset;
- unsigned int my_matching_bits;
int closest_bucket;
struct PeerInfo *pos;
struct PeerInfo *sorted_closest[bucket_size];
unsigned int largest_distance;
struct PeerInfo *chosen;
- my_matching_bits =
- GNUNET_CRYPTO_hash_matching_bits (target, &my_identity.hashPubKey);
-
total_distance = 0;
/** If we are doing kademlia routing, or converge is binary (saves some cycles) */
if ((strict_kademlia == GNUNET_YES) ||
* @param message HELLO message of peer
*/
static void
-process_hello (void *cls, const struct GNUNET_MessageHeader *message)
+process_hello (void *cls,
+ const struct GNUNET_MessageHeader *message)
{
struct GNUNET_TESTING_Daemon *daemon = cls;
+#if WAIT_FOR_HELLO
GNUNET_TESTING_NotifyDaemonRunning cb;
+#endif
int msize;
if (daemon == NULL)
return;
GNUNET_assert (daemon->phase == SP_GET_HELLO || daemon->phase == SP_START_DONE);
-
+#if WAIT_FOR_HELLO
cb = daemon->cb;
+#endif
daemon->cb = NULL;
if (daemon->task != GNUNET_SCHEDULER_NO_TASK) /* Assertion here instead? */
GNUNET_SCHEDULER_cancel(daemon->task);
#if WAIT_FOR_HELLO
if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */
- cb (daemon->cb_cls, &daemon->id, daemon->cfg, daemon, NULL);
+ cb (daemon->cb_cls,
+ &daemon->id,
+ daemon->cfg,
+ daemon, NULL);
#endif
}
copy_allowed(struct GNUNET_TESTING_PeerGroup *pg,
GNUNET_TESTING_ConnectionProcessor proc)
{
- struct UnblacklistContext un_ctx;
unsigned int count;
unsigned int total;
struct PeerConnection *iter;
+#if !OLD
+ struct UnblacklistContext un_ctx;
un_ctx.pg = pg;
+#endif
total = 0;
for (count = 0; count < pg->total - 1; count++)
{
- un_ctx.first_uid = count;
#if OLD
iter = pg->peers[count].allowed_peers_head;
while (iter != NULL)
iter = iter->next;
}
#else
- total += GNUNET_CONTAINER_multihashmap_iterate(pg->peers[count].allowed_peers, &unblacklist_iterator, &un_ctx);
+ un_ctx.first_uid = count;
+ total += GNUNET_CONTAINER_multihashmap_iterate(pg->peers[count].allowed_peers,
+ &unblacklist_iterator,
+ &un_ctx);
#endif
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unblacklisted %u peers\n", total);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Unblacklisted %u peers\n",
+ total);
return total;
}
GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list)
{
unsigned int count;
- int connect_attempts;
+ unsigned int connect_attempts;
connect_attempts = 0;
-
/* Connect each peer to the next highest numbered peer */
for (count = 0; count < pg->total - 1; count++)
{
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting peer %d to peer %d\n", count, count + 1);
+ "Connecting peer %d to peer %d\n",
+ count, count + 1);
#endif
connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
}
int connect_attempts;
unsigned int first_peer_index;
unsigned int second_peer_index;
- connect_attempts = 0;
struct stat frstat;
int count;
char *data;
char *buf;
unsigned int total_peers;
-
enum States curr_state;
+ connect_attempts = 0;
if (GNUNET_OK != GNUNET_DISK_file_test (filename))
GNUNET_DISK_fn_write (filename, NULL, 0, GNUNET_DISK_PERM_USER_READ);
choose_random_connections(struct GNUNET_TESTING_PeerGroup *pg,
double percentage)
{
- struct RandomContext random_ctx;
uint32_t pg_iter;
#if OLD
- struct PeerConnection *temp_peers;
struct PeerConnection *conn_iter;
double random_number;
+#else
+ struct RandomContext random_ctx;
#endif
for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
{
- random_ctx.first_uid = pg_iter;
- random_ctx.first = &pg->peers[pg_iter];
- random_ctx.percentage = percentage;
- random_ctx.pg = pg;
#if OLD
- temp_peers = NULL;
conn_iter = pg->peers[pg_iter].connect_peers_head;
while (conn_iter != NULL)
{
conn_iter = conn_iter->next;
}
#else
- pg->peers[pg_iter].connect_peers_working_set =
- GNUNET_CONTAINER_multihashmap_create (pg->total);
+ random_ctx.first_uid = pg_iter;
+ random_ctx.first = &pg->peers[pg_iter];
+ random_ctx.percentage = percentage;
+ random_ctx.pg = pg;
+ pg->peers[pg_iter].connect_peers_working_set
+ = GNUNET_CONTAINER_multihashmap_create (pg->total);
GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers,
- &random_connect_iterator,
- &random_ctx);
+ &random_connect_iterator,
+ &random_ctx);
/* Now remove the old connections */
GNUNET_CONTAINER_multihashmap_destroy (pg->
- peers[pg_iter].connect_peers);
+ peers[pg_iter].connect_peers);
/* And replace with the random set */
- pg->peers[pg_iter].connect_peers =
- pg->peers[pg_iter].connect_peers_working_set;
+ pg->peers[pg_iter].connect_peers
+ = pg->peers[pg_iter].connect_peers_working_set;
#endif
}