- change tunnel API to pass connection and channel payload
authorBart Polot <bart@net.in.tum.de>
Thu, 30 Jan 2014 02:11:17 +0000 (02:11 +0000)
committerBart Polot <bart@net.in.tum.de>
Thu, 30 Jan 2014 02:11:17 +0000 (02:11 +0000)
src/include/gnunet_mesh_service.h
src/mesh/gnunet-mesh.c
src/mesh/mesh_api.c

index d7c74b6f9e4923ff8986b165155b095cc1ad4e61..51e22a9feecc116fbc3fd4908b8fc8b8b68222f3 100644 (file)
@@ -436,15 +436,19 @@ typedef void (*GNUNET_MESH_TunnelsCB) (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 state.
  * @param cstate Connectivity state.
  */
 typedef void (*GNUNET_MESH_TunnelCB) (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_HashCode *connections,
                                       unsigned int estate,
                                       unsigned int cstate);
 
index ab15ffbd40a2ccbab28041380a12a7d29ee77389..97b0e26b470c69120ff031e4d70044d3f9c4bf91 100644 (file)
@@ -496,24 +496,28 @@ 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_HashCode *connections,
                  unsigned int estate,
                  unsigned int cstate)
 {
   if (NULL != peer)
   {
     FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
-    FPRINTF (stdout, "- %u channels\n", channels);
-    FPRINTF (stdout, "- %u connections\n", connections);
+    FPRINTF (stdout, "- %u channels\n", n_channels);
+    FPRINTF (stdout, "- %u connections\n", n_connections);
     FPRINTF (stdout, "- enc state: %u\n", estate);
     FPRINTF (stdout, "- con state: %u\n", cstate);
   }
index 0ff46f01c6be553b397a879d01596fda7b5a11b7..62b792c4b35c3d069d6601314d217de72f67117a 100644 (file)
@@ -1091,6 +1091,8 @@ process_get_tunnel (struct GNUNET_MESH_Handle *h,
   size_t msize;
   unsigned int ch_n;
   unsigned int c_n;
+  struct GNUNET_HashCode *conns;
+  MESH_ChannelNumber *chns;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnel messasge received\n");
   if (NULL == h->tunnel_cb)
@@ -1106,7 +1108,7 @@ process_get_tunnel (struct GNUNET_MESH_Handle *h,
   if (esize > msize)
   {
     GNUNET_break_op (0);
-    h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0);
+    h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, NULL, NULL, 0, 0);
     goto clean_cls;
   }
   ch_n = ntohl (msg->channels);
@@ -1121,13 +1123,15 @@ process_get_tunnel (struct GNUNET_MESH_Handle *h,
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u (%u ch, %u conn)\n",
                 sizeof (struct GNUNET_MESH_LocalInfoTunnel),
                 sizeof (MESH_ChannelNumber), sizeof (struct GNUNET_HashCode));
-    h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0);
+    h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, NULL, NULL, 0, 0);
     goto clean_cls;
   }
 
   /* Call Callback with tunnel info. */
+  conns = (struct GNUNET_HashCode *) &msg[1];
+  chns = (MESH_ChannelNumber *) &conns[c_n];
   h->tunnel_cb (h->tunnel_cls, &msg->destination,
-                ch_n, c_n,
+                ch_n, c_n, chns, conns,
                 ntohs (msg->estate), ntohs (msg->cstate));
 
 clean_cls: