- use small mesh hashes for info api
[oweals/gnunet.git] / src / mesh / gnunet-mesh.c
index 698b1d154c912d0477b97ce8570ba47bba56e507..7677b244f85e853b57e030e608a30a52625a51ce 100644 (file)
@@ -26,6 +26,7 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_mesh_service.h"
+#include "mesh.h"
 
 
 /**
@@ -439,12 +440,13 @@ data_callback (void *cls,
  * @param cls Closure.
  * @param peer Peer, or NULL on "EOF".
  * @param tunnel Do we have a tunnel towards this peer?
+ * @param n_paths Number of known paths towards this peer.
  * @param best_path How long is the best path?
  *                  (0 = unknown, 1 = ourselves, 2 = neighbor)
  */
 static void
 peers_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
-                int tunnel, unsigned int best_path)
+                int tunnel, unsigned int n_paths, unsigned int best_path)
 {
   if (NULL == peer)
   {
@@ -454,8 +456,8 @@ peers_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
     }
     return;
   }
-  FPRINTF (stdout, "%s tunnel: %c, best path %u hops]\n",
-           GNUNET_i2s_full (peer), tunnel ? 'Y' : 'N', best_path);
+  FPRINTF (stdout, "%s tunnel: %c, paths: %u\n",
+           GNUNET_i2s_full (peer), tunnel ? 'Y' : 'N', n_paths);
 }
 
 
@@ -496,24 +498,43 @@ tunnels_callback (void *cls,
  *
  * @param cls Closure.
  * @param peer Peer towards whom the tunnel is directed.
- * @param channels Number of channels.
- * @param connections Number of connections.
+ * @param n_channels Number of channels.
+ * @param n_connections Number of connections.
+ * @param channels Channels.
+ * @param connections Connections.
  * @param estate Encryption status.
  * @param cstate Connectivity status.
  */
 void
 tunnel_callback (void *cls,
                  const struct GNUNET_PeerIdentity *peer,
-                 unsigned int channels,
-                 unsigned int connections,
+                 unsigned int n_channels,
+                 unsigned int n_connections,
+                 uint32_t *channels,
+                 struct GNUNET_MeshHash *connections,
                  unsigned int estate,
                  unsigned int cstate)
 {
-  FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
-  FPRINTF (stdout, "- %u channels\n", channels);
-  FPRINTF (stdout, "- %u connections\n", connections);
-  FPRINTF (stdout, "- enc state: %u\n", estate);
-  FPRINTF (stdout, "- con state: %u\n", cstate);
+  unsigned int i;
+
+  if (NULL != peer)
+  {
+    FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
+    FPRINTF (stdout, "- %u channels\n", n_channels);
+    for (i = 0; i < n_channels; i++)
+      FPRINTF (stdout, "   %u\n", channels[i]);
+    FPRINTF (stdout, "- %u connections\n", n_connections);
+    for (i = 0; i < n_connections; i++)
+      FPRINTF (stdout, "   %s\n", GM_h2s (&connections[i]));
+    FPRINTF (stdout, "- enc state: %u\n", estate);
+    FPRINTF (stdout, "- con state: %u\n", cstate);
+  }
+  if (GNUNET_YES != monitor_connections)
+  {
+    GNUNET_SCHEDULER_shutdown();
+  }
+  return;
+
 }
 
 
@@ -720,9 +741,9 @@ main (int argc, char *const *argv)
 //     {'a', "channel", "TUNNEL_ID:CHANNEL_ID",
 //      gettext_noop ("provide information about a particular channel"),
 //      GNUNET_YES, &GNUNET_GETOPT_set_string, &channel_id},
-//     {'b', "connection", "TUNNEL_ID:CONNECTION_ID",
-//      gettext_noop ("provide information about a particular connection"),
-//      GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
+    {'C', "connection", "CONNECTION_ID",
+     gettext_noop ("provide information about a particular connection"),
+     GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
     {'e', "echo", NULL,
      gettext_noop ("activate echo mode"),
      GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},