aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_tunnel.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-09 08:32:49 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-09 08:32:49 +0000
commitdcba7f93f6cbccbd5f103675109fb1ebb88d6b41 (patch)
tree73063d90c330a71b1b36246b289001124348bf16 /src/mesh/gnunet-service-mesh_tunnel.c
parent637359c6d1883cdd3d3132027b4a3418995859c2 (diff)
downloadgnunet-dcba7f93f6cbccbd5f103675109fb1ebb88d6b41.tar.gz
gnunet-dcba7f93f6cbccbd5f103675109fb1ebb88d6b41.zip
- sync
Diffstat (limited to 'src/mesh/gnunet-service-mesh_tunnel.c')
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c76
1 files changed, 45 insertions, 31 deletions
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index 8a240f4a8..e709a0be5 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -289,36 +289,6 @@ tunnel_get_connection (struct MeshTunnel3 *t, int fwd)
289} 289}
290 290
291 291
292/**
293 * Send all cached messages that we can, tunnel is online.
294 *
295 * @param t Tunnel that holds the messages.
296 * @param fwd Is this fwd?
297 */
298static void
299tunnel_send_queued_data (struct MeshTunnel3 *t, int fwd)
300{
301 struct MeshTunnelQueue *tq;
302 struct MeshTunnelQueue *next;
303 unsigned int room;
304
305 LOG (GNUNET_ERROR_TYPE_DEBUG,
306 "tunnel_send_queued_data on tunnel %s\n",
307 GMP_2s (t->peer));
308 room = GMT_get_buffer (t, fwd);
309 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer space: %u\n", room);
310 for (tq = t->tq_head; NULL != tq && room > 0; tq = next)
311 {
312 next = tq->next;
313 room--;
314 GNUNET_CONTAINER_DLL_remove (t->tq_head, t->tq_tail, tq);
315 GMCH_send_prebuilt_message ((struct GNUNET_MessageHeader *) &tq[1],
316 tq->ch, fwd);
317
318 GNUNET_free (tq);
319 }
320}
321
322void 292void
323handle_data (struct MeshTunnel3 *t, 293handle_data (struct MeshTunnel3 *t,
324 const struct GNUNET_MESH_Data *msg, 294 const struct GNUNET_MESH_Data *msg,
@@ -565,7 +535,38 @@ GMT_queue_data (struct MeshTunnel3 *t,
565 GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tq); 535 GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tq);
566 536
567 if (MESH_TUNNEL_READY == t->state) 537 if (MESH_TUNNEL_READY == t->state)
568 tunnel_send_queued_data (t, fwd); 538 GMT_send_queued_data (t, fwd);
539}
540
541
542/**
543 * Send all cached messages that we can, tunnel is online.
544 *
545 * @param t Tunnel that holds the messages.
546 * @param fwd Is this fwd?
547 */
548void
549GMT_send_queued_data (struct MeshTunnel3 *t, int fwd)
550{
551 struct MeshTunnelQueue *tq;
552 struct MeshTunnelQueue *next;
553 unsigned int room;
554
555 LOG (GNUNET_ERROR_TYPE_DEBUG,
556 "GMT_send_queued_data on tunnel %s\n",
557 GMP_2s (t->peer));
558 room = GMT_get_buffer (t, fwd);
559 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer space: %u\n", room);
560 for (tq = t->tq_head; NULL != tq && room > 0; tq = next)
561 {
562 next = tq->next;
563 room--;
564 GNUNET_CONTAINER_DLL_remove (t->tq_head, t->tq_tail, tq);
565 GMCH_send_prebuilt_message ((struct GNUNET_MessageHeader *) &tq[1],
566 tq->ch, fwd);
567
568 GNUNET_free (tq);
569 }
569} 570}
570 571
571 572
@@ -952,6 +953,19 @@ GMT_count_channels (struct MeshTunnel3 *t)
952 953
953 954
954/** 955/**
956 * Get the state of a tunnel.
957 *
958 * @param t Tunnel.
959 *
960 * @return Tunnel's state.
961 */
962enum MeshTunnelState
963GMT_get_state (struct MeshTunnel3 *t)
964{
965 return t->state;
966}
967
968/**
955 * Get the total buffer space for a tunnel. 969 * Get the total buffer space for a tunnel.
956 * 970 *
957 * @param t Tunnel. 971 * @param t Tunnel.