gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9245 - in GNUnet/src: applications/dv/module include


From: gnunet
Subject: [GNUnet-SVN] r9245 - in GNUnet/src: applications/dv/module include
Date: Thu, 22 Oct 2009 19:01:27 -0600

Author: nevans
Date: 2009-10-22 19:01:27 -0600 (Thu, 22 Oct 2009)
New Revision: 9245

Modified:
   GNUnet/src/applications/dv/module/dv.c
   GNUnet/src/include/gnunet_dv_service.h
Log:
allows checking for peer in dv table

Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c      2009-10-23 00:59:56 UTC (rev 
9244)
+++ GNUnet/src/applications/dv/module/dv.c      2009-10-23 01:01:27 UTC (rev 
9245)
@@ -33,9 +33,10 @@
 #include "gnunet_stats_service.h"
 #include "dv.h"
 
-#define DEBUG_DV_MAINTAIN GNUNET_NO
-#define DEBUG_DV GNUNET_YES
+#define DEBUG_DV_MAINTAIN GNUNET_YES
+#define DEBUG_DV GNUNET_NO
 #define DEBUG_DV_FORWARD GNUNET_NO
+#define DEBUG_PEERS GNUNET_NO
 /* How long to allow a message to be delayed */
 #define DV_DELAY (5000 * GNUNET_CRON_MILLISECONDS)
 #define DV_PRIORITY 0
@@ -97,6 +98,18 @@
 static struct GNUNET_ThreadHandle *sendingThread;
 static GNUNET_CoreAPIForPlugins *coreAPI;
 
+#if DEBUG_PEERS
+static int printPeer (const GNUNET_HashCode * key,
+    void *value, void *cls)
+{
+       GNUNET_EncName enc;
+  GNUNET_hash_to_enc (key, &enc);
+  GNUNET_GE_LOG (coreAPI->ectx,
+                                                                
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                                                                
GNUNET_GE_BULK, "\tPeer: %s", (char *)&enc);
+}
+#endif
+
 /*
  * Update the statistics about dv routing
  */
@@ -111,6 +124,17 @@
 
   stats->change (stat_dv_total_peers, delta);
 
+#if DEBUG_PEERS
+  current_stat = stats->get (stat_dv_total_peers);
+
+  GNUNET_GE_LOG (coreAPI->ectx,
+                                                                
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                                                                GNUNET_GE_BULK,
+                                                                "%s: Known 
Peers\n", &shortID);
+  GNUNET_multi_hash_map_iterate (ctx->extended_neighbors,
+       &printPeer, NULL);
+
+#endif
   return GNUNET_OK;
 }
 
@@ -207,6 +231,19 @@
 }
 
 /**
+ * Checks whether the given peer is known to us.
+ *
+ * Returns GNUNET_YES if known
+ * GNUNET_NO if not
+ */
+int
+GNUNET_DV_have_peer (GNUNET_PeerIdentity *peer)
+{
+       return GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
+      &peer->hashPubKey);
+}
+
+/**
  * Calls a given method for each dv connected host.
  *
  * @param method method to call for each connected peer
@@ -536,6 +573,13 @@
 
 #endif
   ret = GNUNET_OK;
+  GNUNET_GE_LOG (coreAPI->ectx,
+                                                                
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                                                                GNUNET_GE_BULK,
+                                                                "%s: Received 
data message:\nOriginal Sender ID:\n%d\nDestination ID:%d, type: %d\n",
+                                                                &shortID, 
ntohl (incoming->sender),
+                                                                ntohl 
(incoming->recipient), ntohs(packed_message->type));
+
   if ((ntohs (incoming->header.size) < sizeof (p2p_dv_MESSAGE_Data))
       || (ntohs (incoming->header.size) !=
           (sizeof (p2p_dv_MESSAGE_Data) + ntohs (packed_message->size))))
@@ -1272,6 +1316,7 @@
   api.dv_connections_iterate = &GNUNET_DV_connection_iterate_peers;
   api.p2p_connection_status_check =
     &GNUNET_DV_connection_get_bandwidth_assigned_to_peer;
+  api.have_peer = &GNUNET_DV_have_peer;
 
   stats = capi->service_request ("stats");
   if (stats != NULL)

Modified: GNUnet/src/include/gnunet_dv_service.h
===================================================================
--- GNUnet/src/include/gnunet_dv_service.h      2009-10-23 00:59:56 UTC (rev 
9244)
+++ GNUnet/src/include/gnunet_dv_service.h      2009-10-23 01:01:27 UTC (rev 
9245)
@@ -64,6 +64,14 @@
                                       unsigned int *bpm,
                                       GNUNET_CronTime * last_seen);
 
+  /**
+   * Checks whether the given peer is known to us.
+   *
+   * Returns GNUNET_YES if known
+   * GNUNET_NO if not
+   */
+  int (*have_peer) (const GNUNET_PeerIdentity * peer);
+
 } GNUNET_DV_ServiceAPI;
 
 #endif /* end of gnunet_dv_service.h */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]