aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-01-30 02:11:17 +0000
committerBart Polot <bart@net.in.tum.de>2014-01-30 02:11:17 +0000
commit32dafdb8cc0be8a06853a5e212cea9d6de961b58 (patch)
tree81f956a931c8360217e0577d16818d7094d105a4 /src
parente43078b68951ad8a3daa3a193473e9c321549e1d (diff)
downloadgnunet-32dafdb8cc0be8a06853a5e212cea9d6de961b58.tar.gz
gnunet-32dafdb8cc0be8a06853a5e212cea9d6de961b58.zip
- change tunnel API to pass connection and channel payload
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_mesh_service.h12
-rw-r--r--src/mesh/gnunet-mesh.c16
-rw-r--r--src/mesh/mesh_api.c10
3 files changed, 25 insertions, 13 deletions
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,
436 * 436 *
437 * @param cls Closure. 437 * @param cls Closure.
438 * @param peer Peer towards whom the tunnel is directed. 438 * @param peer Peer towards whom the tunnel is directed.
439 * @param channels Number of channels. 439 * @param n_channels Number of channels.
440 * @param connections Number of connections. 440 * @param n_connections Number of connections.
441 * @param channels Channels.
442 * @param connections Connections.
441 * @param estate Encryption state. 443 * @param estate Encryption state.
442 * @param cstate Connectivity state. 444 * @param cstate Connectivity state.
443 */ 445 */
444typedef void (*GNUNET_MESH_TunnelCB) (void *cls, 446typedef void (*GNUNET_MESH_TunnelCB) (void *cls,
445 const struct GNUNET_PeerIdentity *peer, 447 const struct GNUNET_PeerIdentity *peer,
446 unsigned int channels, 448 unsigned int n_channels,
447 unsigned int connections, 449 unsigned int n_connections,
450 uint32_t *channels,
451 struct GNUNET_HashCode *connections,
448 unsigned int estate, 452 unsigned int estate,
449 unsigned int cstate); 453 unsigned int cstate);
450 454
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,
496 * 496 *
497 * @param cls Closure. 497 * @param cls Closure.
498 * @param peer Peer towards whom the tunnel is directed. 498 * @param peer Peer towards whom the tunnel is directed.
499 * @param channels Number of channels. 499 * @param n_channels Number of channels.
500 * @param connections Number of connections. 500 * @param n_connections Number of connections.
501 * @param channels Channels.
502 * @param connections Connections.
501 * @param estate Encryption status. 503 * @param estate Encryption status.
502 * @param cstate Connectivity status. 504 * @param cstate Connectivity status.
503 */ 505 */
504void 506void
505tunnel_callback (void *cls, 507tunnel_callback (void *cls,
506 const struct GNUNET_PeerIdentity *peer, 508 const struct GNUNET_PeerIdentity *peer,
507 unsigned int channels, 509 unsigned int n_channels,
508 unsigned int connections, 510 unsigned int n_connections,
511 uint32_t *channels,
512 struct GNUNET_HashCode *connections,
509 unsigned int estate, 513 unsigned int estate,
510 unsigned int cstate) 514 unsigned int cstate)
511{ 515{
512 if (NULL != peer) 516 if (NULL != peer)
513 { 517 {
514 FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer)); 518 FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
515 FPRINTF (stdout, "- %u channels\n", channels); 519 FPRINTF (stdout, "- %u channels\n", n_channels);
516 FPRINTF (stdout, "- %u connections\n", connections); 520 FPRINTF (stdout, "- %u connections\n", n_connections);
517 FPRINTF (stdout, "- enc state: %u\n", estate); 521 FPRINTF (stdout, "- enc state: %u\n", estate);
518 FPRINTF (stdout, "- con state: %u\n", cstate); 522 FPRINTF (stdout, "- con state: %u\n", cstate);
519 } 523 }
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,
1091 size_t msize; 1091 size_t msize;
1092 unsigned int ch_n; 1092 unsigned int ch_n;
1093 unsigned int c_n; 1093 unsigned int c_n;
1094 struct GNUNET_HashCode *conns;
1095 MESH_ChannelNumber *chns;
1094 1096
1095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnel messasge received\n"); 1097 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnel messasge received\n");
1096 if (NULL == h->tunnel_cb) 1098 if (NULL == h->tunnel_cb)
@@ -1106,7 +1108,7 @@ process_get_tunnel (struct GNUNET_MESH_Handle *h,
1106 if (esize > msize) 1108 if (esize > msize)
1107 { 1109 {
1108 GNUNET_break_op (0); 1110 GNUNET_break_op (0);
1109 h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0); 1111 h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, NULL, NULL, 0, 0);
1110 goto clean_cls; 1112 goto clean_cls;
1111 } 1113 }
1112 ch_n = ntohl (msg->channels); 1114 ch_n = ntohl (msg->channels);
@@ -1121,13 +1123,15 @@ process_get_tunnel (struct GNUNET_MESH_Handle *h,
1121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u (%u ch, %u conn)\n", 1123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u (%u ch, %u conn)\n",
1122 sizeof (struct GNUNET_MESH_LocalInfoTunnel), 1124 sizeof (struct GNUNET_MESH_LocalInfoTunnel),
1123 sizeof (MESH_ChannelNumber), sizeof (struct GNUNET_HashCode)); 1125 sizeof (MESH_ChannelNumber), sizeof (struct GNUNET_HashCode));
1124 h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0); 1126 h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, NULL, NULL, 0, 0);
1125 goto clean_cls; 1127 goto clean_cls;
1126 } 1128 }
1127 1129
1128 /* Call Callback with tunnel info. */ 1130 /* Call Callback with tunnel info. */
1131 conns = (struct GNUNET_HashCode *) &msg[1];
1132 chns = (MESH_ChannelNumber *) &conns[c_n];
1129 h->tunnel_cb (h->tunnel_cls, &msg->destination, 1133 h->tunnel_cb (h->tunnel_cls, &msg->destination,
1130 ch_n, c_n, 1134 ch_n, c_n, chns, conns,
1131 ntohs (msg->estate), ntohs (msg->cstate)); 1135 ntohs (msg->estate), ntohs (msg->cstate));
1132 1136
1133clean_cls: 1137clean_cls: