From: Bart Polot Date: Fri, 21 Mar 2014 18:44:20 +0000 (+0000) Subject: - dht debug path X-Git-Tag: initial-import-from-subversion-38251~4469 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5fc0aee1f2830a56b6da3bd957d55e3757064840;p=oweals%2Fgnunet.git - dht debug path --- diff --git a/src/mesh/gnunet-service-mesh_dht.c b/src/mesh/gnunet-service-mesh_dht.c index a88700cf1..279645d66 100644 --- a/src/mesh/gnunet-service-mesh_dht.c +++ b/src/mesh/gnunet-service-mesh_dht.c @@ -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); diff --git a/src/mesh/mesh_path.c b/src/mesh/mesh_path.c index ad1f7f4db..3fad58b68 100644 --- a/src/mesh/mesh_path.c +++ b/src/mesh/mesh_path.c @@ -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) { diff --git a/src/mesh/mesh_path.h b/src/mesh/mesh_path.h index 1608adaa0..8b8e20a1e 100644 --- a/src/mesh/mesh_path.h +++ b/src/mesh/mesh_path.h @@ -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.