GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
#include "gnunet_hello_lib.h"
#include "gnunet_peerinfo_service.h"
#include "gnunet_crypto_lib.h"
+#include "gnunet_statistics_service.h"
#include "dv.h"
/**
*/
static struct GNUNET_CONTAINER_Heap *neighbor_max_heap;
+/**
+ * Handle for the statistics service.
+ */
+struct GNUNET_STATISTICS_Handle *stats;
+
/**
* How far out to keep peers we learn about.
*/
received_msg = GNUNET_malloc(size);
received_msg->header.size = htons(size);
received_msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECEIVE);
- received_msg->sender_address_len = htonl(sender_address_len);
received_msg->distance = htonl(cost);
received_msg->msg_len = htonl(message_size);
/* Set the sender in this message to be the original sender! */
memcpy (&toSend[1], message, message_size);
if ((source != NULL) && (source->pkey == NULL)) /* Test our hypothesis about message failures! */
{
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: Sending message, but anticipate recipient will not know sender!!!\n\n\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: Sending message, but anticipate recipient will not know sender!!!\n\n\n", my_short_id);
}
GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
core_pending_tail,
{
#if DEBUG_DV_MESSAGES
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s: unknown sender (%u), Message uid %llu from %s!\n", my_short_id, ntohl(incoming->sender), ntohl(incoming->uid), GNUNET_i2s(&dn->identity));
+ "%s: unknown sender (%u), Message uid %u from %s!\n", my_short_id, ntohl(incoming->sender), ntohl(incoming->uid), GNUNET_i2s(&dn->identity));
pos = dn->referee_head;
while ((NULL != pos) && (pos->referrer_id != sid))
{
}
#endif
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "%s: unknown sender (%u), Message uid %llu from %s!\n", my_short_id, ntohl(incoming->sender), ntohl(incoming->uid), GNUNET_i2s(&dn->identity));
+ "%s: unknown sender (%u), Message uid %u from %s!\n", my_short_id, ntohl(incoming->sender), ntohl(incoming->uid), GNUNET_i2s(&dn->identity));
found_pos = -1;
for (i = 0; i< MAX_OUTSTANDING_MESSAGES; i++)
}
}
}
- if (cost != DIRECT_NEIGHBOR_COST)
+ if ((cost != DIRECT_NEIGHBOR_COST) && (neighbor->pkey != NULL))
{
/* Added neighbor, now send HELLO to transport */
hello_context = GNUNET_malloc(sizeof(struct HelloContext));
if (distant->referrer_id == ntohl(enc_message->peer_id))
{
distant_neighbor_free(distant);
+ distant = referrer->referee_head;
}
- distant = referrer->referee_head;
+ else
+ distant = distant->next;
}
return GNUNET_OK;
* @param cls closure
* @param peer id of the peer, NULL for last call
* @param hello hello message for the peer (can be NULL)
- * @param trust amount of trust we have in the peer
*/
static void
process_peerinfo (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello, uint32_t trust)
+ const struct GNUNET_HELLO_Message *hello)
{
struct PeerIteratorContext *peerinfo_iterator = cls;
struct DirectNeighbor *neighbor = peerinfo_iterator->neighbor;
#endif
peerinfo_iterator->ic = GNUNET_PEERINFO_iterate(peerinfo_handle,
&peerinfo_iterator->neighbor->identity,
- 0,
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3),
&process_peerinfo,
peerinfo_iterator);
}
sent = GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, neighbor->send_context);
-
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_update (stats, "# distant peers gossiped to direct neighbors", sent, GNUNET_NO);
+ }
#if DEBUG_DV_PEER_NUMBERS
neighbor_pid = GNUNET_strdup(GNUNET_i2s(&neighbor->identity));
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped %d extended peers to %s\n", GNUNET_i2s(&my_identity), sent, neighbor_pid);
#endif
sent = GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &add_all_direct_neighbors, neighbor);
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_update (stats, "# direct peers gossiped to direct neighbors", sent, GNUNET_NO);
+ }
#if DEBUG_DV_PEER_NUMBERS
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent);
GNUNET_free(neighbor_pid);
peerinfo_iterator->neighbor = neighbor;
peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle,
peer,
- 0,
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3),
&process_peerinfo,
peerinfo_iterator);
{
about = GNUNET_CONTAINER_multihashmap_get(extended_neighbors, &peer->hashPubKey);
if ((GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey) == NULL) && (about != NULL))
- sent = GNUNET_CONTAINER_multihashmap_iterate(direct_neighbors, &add_distant_all_direct_neighbors, about);
+ {
+ sent = GNUNET_CONTAINER_multihashmap_iterate(direct_neighbors, &add_distant_all_direct_neighbors, about);
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_update (stats, "# direct peers gossiped to new direct neighbors", sent, GNUNET_NO);
+ }
+ }
#if DEBUG_DV
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s: Distance (%d) greater than %d or already know about peer (%s), not re-adding!\n", "dv", distance, DIRECT_NEIGHBOR_COST, GNUNET_i2s(peer));
&core_init,
&handle_core_connect,
&handle_core_disconnect,
+ NULL,
NULL,
GNUNET_NO,
NULL,
if (coreAPI == NULL)
return;
- coreMST = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
- &tokenized_message_handler,
+ coreMST = GNUNET_SERVER_mst_create (&tokenized_message_handler,
NULL);
peerinfo_handle = GNUNET_PEERINFO_connect(sched, cfg);
GNUNET_TIME_UNIT_FOREVER_REL,
&shutdown_task,
NULL);
-#if INSANE_GOSSIP
- GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
- &gossip_all_to_all,
- NULL);
-#endif
}