aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesh/gnunet-service-mesh_channel.c93
-rw-r--r--src/mesh/gnunet-service-mesh_channel.h32
-rw-r--r--src/mesh/gnunet-service-mesh_connection.c62
-rw-r--r--src/mesh/gnunet-service-mesh_connection.h21
-rw-r--r--src/mesh/gnunet-service-mesh_peer.c15
-rw-r--r--src/mesh/gnunet-service-mesh_peer.h13
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c76
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.h19
8 files changed, 235 insertions, 96 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c
index 6e99d2b30..7802e34a0 100644
--- a/src/mesh/gnunet-service-mesh_channel.c
+++ b/src/mesh/gnunet-service-mesh_channel.c
@@ -404,43 +404,6 @@ channel_add_client (struct MeshChannel *ch, struct MeshClient *c)
404} 404}
405 405
406 406
407
408/**
409 * Is the root client for this channel on this peer?
410 *
411 * @param ch Channel.
412 * @param fwd Is this for fwd traffic?
413 *
414 * @return GNUNET_YES in case it is.
415 */
416static int
417channel_is_origin (struct MeshChannel *ch, int fwd)
418{
419 struct MeshClient *c;
420
421 c = fwd ? ch->root : ch->dest;
422 return NULL != c;
423}
424
425
426/**
427 * Is the destination client for this channel on this peer?
428 *
429 * @param ch Channel.
430 * @param fwd Is this for fwd traffic?
431 *
432 * @return GNUNET_YES in case it is.
433 */
434static int
435channel_is_terminal (struct MeshChannel *ch, int fwd)
436{
437 struct MeshClient *c;
438
439 c = fwd ? ch->dest : ch->root;
440 return NULL != c;
441}
442
443
444/** 407/**
445 * Destroy all reliable messages queued for a channel, 408 * Destroy all reliable messages queued for a channel,
446 * during a channel destruction. 409 * during a channel destruction.
@@ -1113,6 +1076,20 @@ GMCH_get_id (const struct MeshChannel *ch)
1113 1076
1114 1077
1115/** 1078/**
1079 * Get the channel tunnel.
1080 *
1081 * @param ch Channel to get the tunnel from.
1082 *
1083 * @return tunnel of the channel.
1084 */
1085struct MeshTunnel3 *
1086GMCH_get_tunnel (const struct MeshChannel *ch)
1087{
1088 return ch->t;
1089}
1090
1091
1092/**
1116 * Get free buffer space towards the client on a specific channel. 1093 * Get free buffer space towards the client on a specific channel.
1117 * 1094 *
1118 * @param ch Channel. 1095 * @param ch Channel.
@@ -1124,21 +1101,57 @@ unsigned int
1124GMCH_get_buffer (struct MeshChannel *ch, int fwd) 1101GMCH_get_buffer (struct MeshChannel *ch, int fwd)
1125{ 1102{
1126 struct MeshChannelReliability *rel; 1103 struct MeshChannelReliability *rel;
1127 1104
1128 rel = fwd ? ch->dest_rel : ch->root_rel; 1105 rel = fwd ? ch->dest_rel : ch->root_rel;
1129 1106
1130 /* If rel is NULL it means that the end is not yet created, 1107 /* If rel is NULL it means that the end is not yet created,
1131 * most probably is a loopback channel at the point of sending 1108 * most probably is a loopback channel at the point of sending
1132 * the ChannelCreate to itself. 1109 * the ChannelCreate to itself.
1133 */ 1110 */
1134 if (NULL == rel) 1111 if (NULL == rel)
1135 return 64; 1112 return 64;
1136 1113
1137 return (64 - rel->n_recv); 1114 return (64 - rel->n_recv);
1138} 1115}
1139 1116
1140 1117
1141/** 1118/**
1119 * Is the root client for this channel on this peer?
1120 *
1121 * @param ch Channel.
1122 * @param fwd Is this for fwd traffic?
1123 *
1124 * @return GNUNET_YES in case it is.
1125 */
1126int
1127GMCH_is_origin (struct MeshChannel *ch, int fwd)
1128{
1129 struct MeshClient *c;
1130
1131 c = fwd ? ch->root : ch->dest;
1132 return NULL != c;
1133}
1134
1135
1136/**
1137 * Is the destination client for this channel on this peer?
1138 *
1139 * @param ch Channel.
1140 * @param fwd Is this for fwd traffic?
1141 *
1142 * @return GNUNET_YES in case it is.
1143 */
1144int
1145GMCH_is_terminal (struct MeshChannel *ch, int fwd)
1146{
1147 struct MeshClient *c;
1148
1149 c = fwd ? ch->dest : ch->root;
1150 return NULL != c;
1151}
1152
1153
1154/**
1142 * Notify the destination client that a new incoming channel was created. 1155 * Notify the destination client that a new incoming channel was created.
1143 * 1156 *
1144 * @param ch Channel that was created. 1157 * @param ch Channel that was created.
diff --git a/src/mesh/gnunet-service-mesh_channel.h b/src/mesh/gnunet-service-mesh_channel.h
index 8af9937b0..154e92b0d 100644
--- a/src/mesh/gnunet-service-mesh_channel.h
+++ b/src/mesh/gnunet-service-mesh_channel.h
@@ -58,6 +58,16 @@ MESH_ChannelNumber
58GMCH_get_id (const struct MeshChannel *ch); 58GMCH_get_id (const struct MeshChannel *ch);
59 59
60/** 60/**
61 * Get the channel tunnel.
62 *
63 * @param ch Channel to get the tunnel from.
64 *
65 * @return tunnel of the channel.
66 */
67struct MeshTunnel3 *
68GMCH_get_tunnel (const struct MeshChannel *ch);
69
70/**
61 * Get free buffer space towards the client on a specific channel. 71 * Get free buffer space towards the client on a specific channel.
62 * 72 *
63 * @param ch Channel. 73 * @param ch Channel.
@@ -69,6 +79,28 @@ unsigned int
69GMCH_get_buffer (struct MeshChannel *ch, int fwd); 79GMCH_get_buffer (struct MeshChannel *ch, int fwd);
70 80
71/** 81/**
82 * Is the root client for this channel on this peer?
83 *
84 * @param ch Channel.
85 * @param fwd Is this for fwd traffic?
86 *
87 * @return GNUNET_YES in case it is.
88 */
89int
90GMCH_is_origin (struct MeshChannel *ch, int fwd);
91
92/**
93 * Is the destination client for this channel on this peer?
94 *
95 * @param ch Channel.
96 * @param fwd Is this for fwd traffic?
97 *
98 * @return GNUNET_YES in case it is.
99 */
100int
101GMCH_is_terminal (struct MeshChannel *ch, int fwd);
102
103/**
72 * Send an end-to-end ACK message for the most recent in-sequence payload. 104 * Send an end-to-end ACK message for the most recent in-sequence payload.
73 * 105 *
74 * If channel is not reliable, do nothing. 106 * If channel is not reliable, do nothing.
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c
index 7c3cb08bb..edcb79953 100644
--- a/src/mesh/gnunet-service-mesh_connection.c
+++ b/src/mesh/gnunet-service-mesh_connection.c
@@ -32,6 +32,7 @@
32#include "gnunet-service-mesh_connection.h" 32#include "gnunet-service-mesh_connection.h"
33#include "gnunet-service-mesh_peer.h" 33#include "gnunet-service-mesh_peer.h"
34#include "gnunet-service-mesh_tunnel.h" 34#include "gnunet-service-mesh_tunnel.h"
35#include "gnunet-service-mesh_channel.h"
35#include "mesh_protocol_enc.h" 36#include "mesh_protocol_enc.h"
36#include "mesh_path.h" 37#include "mesh_path.h"
37 38
@@ -1048,7 +1049,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1048 LOG (GNUNET_ERROR_TYPE_DEBUG, " ... adding %s\n", 1049 LOG (GNUNET_ERROR_TYPE_DEBUG, " ... adding %s\n",
1049 GNUNET_i2s (&id[i])); 1050 GNUNET_i2s (&id[i]));
1050 path->peers[i] = GNUNET_PEER_intern (&id[i]); 1051 path->peers[i] = GNUNET_PEER_intern (&id[i]);
1051 if (path->peers[i] == myid) 1052 if (path->peers[i] == my_short_id)
1052 own_pos = i; 1053 own_pos = i;
1053 } 1054 }
1054 if (own_pos == 0 && path->peers[own_pos] != myid) 1055 if (own_pos == 0 && path->peers[own_pos] != myid)
@@ -1056,7 +1057,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1056 /* create path: self not found in path through self */ 1057 /* create path: self not found in path through self */
1057 GNUNET_break_op (0); 1058 GNUNET_break_op (0);
1058 path_destroy (path); 1059 path_destroy (path);
1059 connection_destroy (c); 1060 GMC_destroy (c);
1060 return GNUNET_OK; 1061 return GNUNET_OK;
1061 } 1062 }
1062 LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); 1063 LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos);
@@ -1086,9 +1087,9 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1086 orig_peer->tunnel = tunnel_new (); 1087 orig_peer->tunnel = tunnel_new ();
1087 orig_peer->tunnel->peer = orig_peer; 1088 orig_peer->tunnel->peer = orig_peer;
1088 } 1089 }
1089 tunnel_add_connection (orig_peer->tunnel, c); 1090 GMT_add_connection (orig_peer->tunnel, c);
1090 if (MESH_TUNNEL_NEW == c->t->state) 1091 if (MESH_TUNNEL_NEW == GMT_get_state (c->t))
1091 tunnel_change_state (c->t, MESH_TUNNEL_WAITING); 1092 GMT_change_state (c->t, MESH_TUNNEL_WAITING);
1092 1093
1093 send_connection_ack (c, GNUNET_NO); 1094 send_connection_ack (c, GNUNET_NO);
1094 if (MESH_CONNECTION_SENT == c->state) 1095 if (MESH_CONNECTION_SENT == c->state)
@@ -1199,15 +1200,14 @@ GMC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1199 if (GMC_is_terminal (c, GNUNET_YES)) 1200 if (GMC_is_terminal (c, GNUNET_YES))
1200 { 1201 {
1201 LOG (GNUNET_ERROR_TYPE_DEBUG, " Connection ACK for us!\n"); 1202 LOG (GNUNET_ERROR_TYPE_DEBUG, " Connection ACK for us!\n");
1202 if (MESH_TUNNEL_READY != c->t->state) 1203 GMC_change_state (c, MESH_CONNECTION_READY);
1203 tunnel_change_state (c->t, MESH_TUNNEL_READY); 1204 GMT_change_state (c->t, MESH_TUNNEL_READY);
1204 connection_change_state (c, MESH_CONNECTION_READY); 1205 GMT_send_queued_data (c->t, GNUNET_NO);
1205 tunnel_send_queued_data (c->t, GNUNET_NO);
1206 return GNUNET_OK; 1206 return GNUNET_OK;
1207 } 1207 }
1208 1208
1209 LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); 1209 LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n");
1210 send_prebuilt_message_connection (message, c, NULL, fwd); 1210 GMC_send_prebuilt_message (message, c, NULL, fwd);
1211 return GNUNET_OK; 1211 return GNUNET_OK;
1212} 1212}
1213 1213
@@ -1287,16 +1287,16 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
1287 return GNUNET_OK; 1287 return GNUNET_OK;
1288 } 1288 }
1289 id = GNUNET_PEER_search (peer); 1289 id = GNUNET_PEER_search (peer);
1290 if (id == connection_get_prev_hop (c)->id) 1290 if (id == GMP_get_short_id (connection_get_prev_hop (c)))
1291 fwd = GNUNET_YES; 1291 fwd = GNUNET_YES;
1292 else if (id == connection_get_next_hop (c)->id) 1292 else if (id == GMP_get_short_id (connection_get_next_hop (c)))
1293 fwd = GNUNET_NO; 1293 fwd = GNUNET_NO;
1294 else 1294 else
1295 { 1295 {
1296 GNUNET_break_op (0); 1296 GNUNET_break_op (0);
1297 return GNUNET_OK; 1297 return GNUNET_OK;
1298 } 1298 }
1299 send_prebuilt_message_connection (message, c, NULL, fwd); 1299 GMC_send_prebuilt_message (message, c, NULL, fwd);
1300 c->destroy = GNUNET_YES; 1300 c->destroy = GNUNET_YES;
1301 1301
1302 return GNUNET_OK; 1302 return GNUNET_OK;
@@ -1353,7 +1353,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer,
1353 1353
1354 /* Check if origin is as expected */ 1354 /* Check if origin is as expected */
1355 neighbor = connection_get_hop (c, !fwd); 1355 neighbor = connection_get_hop (c, !fwd);
1356 if (peer_get (peer)->id != neighbor->id) 1356 if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor))
1357 { 1357 {
1358 GNUNET_break_op (0); 1358 GNUNET_break_op (0);
1359 return GNUNET_OK; 1359 return GNUNET_OK;
@@ -1502,13 +1502,13 @@ GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
1502 1502
1503 /* Is this a forward or backward ACK? */ 1503 /* Is this a forward or backward ACK? */
1504 id = GNUNET_PEER_search (peer); 1504 id = GNUNET_PEER_search (peer);
1505 if (connection_get_next_hop (c)->id == id) 1505 if (GMP_get_short_id (connection_get_next_hop (c)) == id)
1506 { 1506 {
1507 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n"); 1507 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n");
1508 fc = &c->fwd_fc; 1508 fc = &c->fwd_fc;
1509 fwd = GNUNET_YES; 1509 fwd = GNUNET_YES;
1510 } 1510 }
1511 else if (connection_get_prev_hop (c)->id == id) 1511 else if (GMP_get_short_id (connection_get_prev_hop (c)) == id)
1512 { 1512 {
1513 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n"); 1513 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n");
1514 fc = &c->bck_fc; 1514 fc = &c->bck_fc;
@@ -1585,12 +1585,12 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
1585 * this way of discerining FWD/BCK should not be a problem. 1585 * this way of discerining FWD/BCK should not be a problem.
1586 */ 1586 */
1587 id = GNUNET_PEER_search (peer); 1587 id = GNUNET_PEER_search (peer);
1588 if (connection_get_next_hop (c)->id == id) 1588 if (GMP_get_short_id (connection_get_next_hop (c)) == id)
1589 { 1589 {
1590 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n"); 1590 LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n");
1591 fc = &c->fwd_fc; 1591 fc = &c->fwd_fc;
1592 } 1592 }
1593 else if (connection_get_prev_hop (c)->id == id) 1593 else if (GMP_get_short_id (connection_get_prev_hop (c)) == id)
1594 { 1594 {
1595 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n"); 1595 LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n");
1596 fc = &c->bck_fc; 1596 fc = &c->bck_fc;
@@ -1625,7 +1625,7 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
1625 */ 1625 */
1626int 1626int
1627GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer, 1627GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
1628 const struct GNUNET_MessageHeader *message) 1628 const struct GNUNET_MessageHeader *message)
1629{ 1629{
1630 struct GNUNET_MESH_ConnectionKeepAlive *msg; 1630 struct GNUNET_MESH_ConnectionKeepAlive *msg;
1631 struct MeshConnection *c; 1631 struct MeshConnection *c;
@@ -1649,7 +1649,7 @@ GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
1649 1649
1650 /* Check if origin is as expected */ 1650 /* Check if origin is as expected */
1651 neighbor = connection_get_hop (c, fwd); 1651 neighbor = connection_get_hop (c, fwd);
1652 if (peer_get (peer)->id != neighbor->id) 1652 if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor))
1653 { 1653 {
1654 GNUNET_break_op (0); 1654 GNUNET_break_op (0);
1655 return GNUNET_OK; 1655 return GNUNET_OK;
@@ -1676,8 +1676,8 @@ GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
1676 * @param ch Channel, if any. 1676 * @param ch Channel, if any.
1677 * @param fwd Is this a fwd ACK? (will go dest->root) 1677 * @param fwd Is this a fwd ACK? (will go dest->root)
1678 */ 1678 */
1679static void 1679void
1680send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd) 1680GMC_send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd)
1681{ 1681{
1682 unsigned int buffer; 1682 unsigned int buffer;
1683 1683
@@ -1686,8 +1686,10 @@ send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd)
1686 fwd ? "FWD" : "BCK", c, ch); 1686 fwd ? "FWD" : "BCK", c, ch);
1687 if (NULL == c || GMC_is_terminal (c, fwd)) 1687 if (NULL == c || GMC_is_terminal (c, fwd))
1688 { 1688 {
1689 struct MeshTunnel3 *t;
1689 LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from all connections\n"); 1690 LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from all connections\n");
1690 buffer = GMT_get_buffer (NULL == c ? ch->t : c->t, fwd); 1691 t = (NULL == c) ? GMCH_get_tunnel (ch) : GMC_get_tunnel (c);
1692 buffer = GMT_get_buffer (t, fwd);
1691 } 1693 }
1692 else 1694 else
1693 { 1695 {
@@ -1721,7 +1723,6 @@ send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd)
1721} 1723}
1722 1724
1723 1725
1724
1725/** 1726/**
1726 * Initialize the connections subsystem 1727 * Initialize the connections subsystem
1727 * 1728 *
@@ -1866,6 +1867,19 @@ GMC_get_state (const struct MeshConnection *c)
1866 return c->state; 1867 return c->state;
1867} 1868}
1868 1869
1870/**
1871 * Get the connection tunnel.
1872 *
1873 * @param c Connection to get the tunnel from.
1874 *
1875 * @return tunnel of the connection.
1876 */
1877struct MeshTunnel3 *
1878GMC_get_tunnel (const struct MeshConnection *c)
1879{
1880 return c->t;
1881}
1882
1869 1883
1870/** 1884/**
1871 * Get free buffer space in a connection. 1885 * Get free buffer space in a connection.
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h
index c2d396969..2552623c3 100644
--- a/src/mesh/gnunet-service-mesh_connection.h
+++ b/src/mesh/gnunet-service-mesh_connection.h
@@ -208,6 +208,17 @@ GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
208 const struct GNUNET_MessageHeader *message); 208 const struct GNUNET_MessageHeader *message);
209 209
210/** 210/**
211 * Send an ACK on the appropriate connection/channel, depending on
212 * the direction and the position of the peer.
213 *
214 * @param c Which connection to send the hop-by-hop ACK.
215 * @param ch Channel, if any.
216 * @param fwd Is this a fwd ACK? (will go dest->root)
217 */
218void
219GMC_send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd);
220
221/**
211 * Initialize the connections subsystem 222 * Initialize the connections subsystem
212 * 223 *
213 * @param c Configuration handle. 224 * @param c Configuration handle.
@@ -264,6 +275,16 @@ enum MeshConnectionState
264GMC_get_state (const struct MeshConnection *c); 275GMC_get_state (const struct MeshConnection *c);
265 276
266/** 277/**
278 * Get the connection tunnel.
279 *
280 * @param c Connection to get the tunnel from.
281 *
282 * @return tunnel of the connection.
283 */
284struct MeshTunnel3 *
285GMC_get_tunnel (const struct MeshConnection *c);
286
287/**
267 * Get free buffer space in a connection. 288 * Get free buffer space in a connection.
268 * 289 *
269 * @param c Connection. 290 * @param c Connection.
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c
index 05fb90f39..2c3967d8a 100644
--- a/src/mesh/gnunet-service-mesh_peer.c
+++ b/src/mesh/gnunet-service-mesh_peer.c
@@ -1569,6 +1569,21 @@ GMP_get_id (const struct MeshPeer *peer)
1569 return GNUNET_PEER_resolve2 (peer->id); 1569 return GNUNET_PEER_resolve2 (peer->id);
1570} 1570}
1571 1571
1572
1573/**
1574 * Get the Short ID of a peer.
1575 *
1576 * @param peer Peer to get from.
1577 *
1578 * @return Short ID of peer.
1579 */
1580GNUNET_PEER_Id
1581GMP_get_short_id (const struct MeshPeer *peer)
1582{
1583 return peer->id;
1584}
1585
1586
1572/** 1587/**
1573 * Get the static string for a peer ID. 1588 * Get the static string for a peer ID.
1574 * 1589 *
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h
index b5c165e9a..6ac3e3801 100644
--- a/src/mesh/gnunet-service-mesh_peer.h
+++ b/src/mesh/gnunet-service-mesh_peer.h
@@ -93,7 +93,7 @@ void
93GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel3 *t); 93GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel3 *t);
94 94
95/** 95/**
96 * Chech whether there is a direct (core level) connection to peer. 96 * Check whether there is a direct (core level) connection to peer.
97 * 97 *
98 * @param peer Peer to check. 98 * @param peer Peer to check.
99 * 99 *
@@ -102,6 +102,7 @@ GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel3 *t);
102int 102int
103GMP_is_neighbor (const struct MeshPeer *peer); 103GMP_is_neighbor (const struct MeshPeer *peer);
104 104
105
105/** 106/**
106 * Add a connection to a neighboring peer. 107 * Add a connection to a neighboring peer.
107 * 108 *
@@ -131,6 +132,16 @@ struct GNUNET_PeerIdentity *
131GMP_get_id (const struct MeshPeer *peer); 132GMP_get_id (const struct MeshPeer *peer);
132 133
133/** 134/**
135 * Get the Short ID of a peer.
136 *
137 * @param peer Peer to get from.
138 *
139 * @return Short ID of peer.
140 */
141GNUNET_PEER_Id
142GMP_get_short_id (const struct MeshPeer *peer);
143
144/**
134 * Get the static string for a peer ID. 145 * Get the static string for a peer ID.
135 * 146 *
136 * @param peer Peer. 147 * @param peer Peer.
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.
diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h
index afa0ee169..71fa5780e 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.h
+++ b/src/mesh/gnunet-service-mesh_tunnel.h
@@ -176,6 +176,15 @@ GMT_queue_data (struct MeshTunnel3 *t,
176 int fwd); 176 int fwd);
177 177
178/** 178/**
179 * Send all cached messages that we can, tunnel is online.
180 *
181 * @param t Tunnel that holds the messages.
182 * @param fwd Is this fwd?
183 */
184void
185GMT_send_queued_data (struct MeshTunnel3 *t, int fwd);
186
187/**
179 * Count established (ready) connections of a tunnel. 188 * Count established (ready) connections of a tunnel.
180 * 189 *
181 * @param t Tunnel on which to count. 190 * @param t Tunnel on which to count.
@@ -196,6 +205,16 @@ unsigned int
196GMT_count_channels (struct MeshTunnel3 *t); 205GMT_count_channels (struct MeshTunnel3 *t);
197 206
198/** 207/**
208 * Get the state of a tunnel.
209 *
210 * @param t Tunnel.
211 *
212 * @return Tunnel's state.
213 */
214enum MeshTunnelState
215GMT_get_state (struct MeshTunnel3 *t);
216
217/**
199 * Get the total buffer space for a tunnel. 218 * Get the total buffer space for a tunnel.
200 * 219 *
201 * @param t Tunnel. 220 * @param t Tunnel.