- dht debug path
authorBart Polot <bart@net.in.tum.de>
Fri, 21 Mar 2014 18:44:20 +0000 (18:44 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 21 Mar 2014 18:44:20 +0000 (18:44 +0000)
src/mesh/gnunet-service-mesh_dht.c
src/mesh/mesh_path.c
src/mesh/mesh_path.h

index a88700cf171a104b14705d285cf34f01527be68d..279645d66561893da4ba35e84fb70a21655b28e7 100644 (file)
@@ -223,9 +223,13 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
   struct GNUNET_HELLO_Message *hello;
   struct MeshPeerPath *p;
   struct MeshPeer *peer;
+  char *s;
 
   p = path_build_from_dht (get_path, get_path_length,
                            put_path, put_path_length);
+  s = path_2s (p);
+  LOG (GNUNET_ERROR_TYPE_INFO, "Got path from DHT: %s\n", s);
+  GNUNET_free_non_null (s);
   peer = GMP_get_short (p->peers[p->length - 1]);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GMP_2s (peer));
   h->callback (h->cls, p);
index ad1f7f4db33fe77d6e3f33c1c5c7d6d04af839a6..3fad58b68a878730068da5d8a429b448f9d03c1e 100644 (file)
@@ -182,6 +182,24 @@ path_destroy (struct MeshPeerPath *p)
   return GNUNET_OK;
 }
 
+char *
+path_2s (struct MeshPeerPath *p)
+{
+  char *s;
+  char *old;
+  unsigned int i;
+
+  s = old = NULL;
+  for (i = 0; i < p->length; i++)
+  {
+    GNUNET_asprintf (&s, "%s %s",
+                     old, GNUNET_i2s (GNUNET_PEER_resolve2 (p->peers[i])));
+    GNUNET_free_non_null (old);
+    old = s;  old = "";
+  }
+  return s;
+}
+
 void
 path_debug (struct MeshPeerPath *p)
 {
index 1608adaa003951b34ef85cfc4d2847292fb74408..8b8e20a1ebd4a0dbd65cc14bef0e835923d0e0cd 100644 (file)
@@ -150,6 +150,13 @@ path_is_valid (const struct MeshPeerPath *path);
 int
 path_destroy (struct MeshPeerPath *p);
 
+/**
+ * Path -> allocated one line string. Caller must free.
+ *
+ * @param p Path.
+ */
+char *
+path_2s (struct MeshPeerPath *p);
 
 /**
  * Print info about the path for debug.