From: Bart Polot Date: Thu, 30 Jan 2014 02:11:17 +0000 (+0000) Subject: - change tunnel API to pass connection and channel payload X-Git-Tag: initial-import-from-subversion-38251~4898 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=32dafdb8cc0be8a06853a5e212cea9d6de961b58;p=oweals%2Fgnunet.git - change tunnel API to pass connection and channel payload --- diff --git a/src/include/gnunet_mesh_service.h b/src/include/gnunet_mesh_service.h index d7c74b6f9..51e22a9fe 100644 --- a/src/include/gnunet_mesh_service.h +++ b/src/include/gnunet_mesh_service.h @@ -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); diff --git a/src/mesh/gnunet-mesh.c b/src/mesh/gnunet-mesh.c index ab15ffbd4..97b0e26b4 100644 --- a/src/mesh/gnunet-mesh.c +++ b/src/mesh/gnunet-mesh.c @@ -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); } diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 0ff46f01c..62b792c4b 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -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: