[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30028 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30028 - gnunet/src/mesh |
Date: |
Wed, 9 Oct 2013 10:32:50 +0200 |
Author: bartpolot
Date: 2013-10-09 10:32:49 +0200 (Wed, 09 Oct 2013)
New Revision: 30028
Modified:
gnunet/src/mesh/gnunet-service-mesh_channel.c
gnunet/src/mesh/gnunet-service-mesh_channel.h
gnunet/src/mesh/gnunet-service-mesh_connection.c
gnunet/src/mesh/gnunet-service-mesh_connection.h
gnunet/src/mesh/gnunet-service-mesh_peer.c
gnunet/src/mesh/gnunet-service-mesh_peer.h
gnunet/src/mesh/gnunet-service-mesh_tunnel.c
gnunet/src/mesh/gnunet-service-mesh_tunnel.h
Log:
- sync
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-10-09 08:29:10 UTC
(rev 30027)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-10-09 08:32:49 UTC
(rev 30028)
@@ -404,44 +404,7 @@
}
-
/**
- * Is the root client for this channel on this peer?
- *
- * @param ch Channel.
- * @param fwd Is this for fwd traffic?
- *
- * @return GNUNET_YES in case it is.
- */
-static int
-channel_is_origin (struct MeshChannel *ch, int fwd)
-{
- struct MeshClient *c;
-
- c = fwd ? ch->root : ch->dest;
- return NULL != c;
-}
-
-
-/**
- * Is the destination client for this channel on this peer?
- *
- * @param ch Channel.
- * @param fwd Is this for fwd traffic?
- *
- * @return GNUNET_YES in case it is.
- */
-static int
-channel_is_terminal (struct MeshChannel *ch, int fwd)
-{
- struct MeshClient *c;
-
- c = fwd ? ch->dest : ch->root;
- return NULL != c;
-}
-
-
-/**
* Destroy all reliable messages queued for a channel,
* during a channel destruction.
* Frees the reliability structure itself.
@@ -1113,6 +1076,20 @@
/**
+ * Get the channel tunnel.
+ *
+ * @param ch Channel to get the tunnel from.
+ *
+ * @return tunnel of the channel.
+ */
+struct MeshTunnel3 *
+GMCH_get_tunnel (const struct MeshChannel *ch)
+{
+ return ch->t;
+}
+
+
+/**
* Get free buffer space towards the client on a specific channel.
*
* @param ch Channel.
@@ -1124,21 +1101,57 @@
GMCH_get_buffer (struct MeshChannel *ch, int fwd)
{
struct MeshChannelReliability *rel;
-
+
rel = fwd ? ch->dest_rel : ch->root_rel;
-
+
/* If rel is NULL it means that the end is not yet created,
* most probably is a loopback channel at the point of sending
* the ChannelCreate to itself.
*/
if (NULL == rel)
return 64;
-
+
return (64 - rel->n_recv);
}
/**
+ * Is the root client for this channel on this peer?
+ *
+ * @param ch Channel.
+ * @param fwd Is this for fwd traffic?
+ *
+ * @return GNUNET_YES in case it is.
+ */
+int
+GMCH_is_origin (struct MeshChannel *ch, int fwd)
+{
+ struct MeshClient *c;
+
+ c = fwd ? ch->root : ch->dest;
+ return NULL != c;
+}
+
+
+/**
+ * Is the destination client for this channel on this peer?
+ *
+ * @param ch Channel.
+ * @param fwd Is this for fwd traffic?
+ *
+ * @return GNUNET_YES in case it is.
+ */
+int
+GMCH_is_terminal (struct MeshChannel *ch, int fwd)
+{
+ struct MeshClient *c;
+
+ c = fwd ? ch->dest : ch->root;
+ return NULL != c;
+}
+
+
+/**
* Notify the destination client that a new incoming channel was created.
*
* @param ch Channel that was created.
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-10-09 08:29:10 UTC
(rev 30027)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-10-09 08:32:49 UTC
(rev 30028)
@@ -58,6 +58,16 @@
GMCH_get_id (const struct MeshChannel *ch);
/**
+ * Get the channel tunnel.
+ *
+ * @param ch Channel to get the tunnel from.
+ *
+ * @return tunnel of the channel.
+ */
+struct MeshTunnel3 *
+GMCH_get_tunnel (const struct MeshChannel *ch);
+
+/**
* Get free buffer space towards the client on a specific channel.
*
* @param ch Channel.
@@ -69,6 +79,28 @@
GMCH_get_buffer (struct MeshChannel *ch, int fwd);
/**
+ * Is the root client for this channel on this peer?
+ *
+ * @param ch Channel.
+ * @param fwd Is this for fwd traffic?
+ *
+ * @return GNUNET_YES in case it is.
+ */
+int
+GMCH_is_origin (struct MeshChannel *ch, int fwd);
+
+/**
+ * Is the destination client for this channel on this peer?
+ *
+ * @param ch Channel.
+ * @param fwd Is this for fwd traffic?
+ *
+ * @return GNUNET_YES in case it is.
+ */
+int
+GMCH_is_terminal (struct MeshChannel *ch, int fwd);
+
+/**
* Send an end-to-end ACK message for the most recent in-sequence payload.
*
* If channel is not reliable, do nothing.
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-10-09 08:29:10 UTC
(rev 30027)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-10-09 08:32:49 UTC
(rev 30028)
@@ -32,6 +32,7 @@
#include "gnunet-service-mesh_connection.h"
#include "gnunet-service-mesh_peer.h"
#include "gnunet-service-mesh_tunnel.h"
+#include "gnunet-service-mesh_channel.h"
#include "mesh_protocol_enc.h"
#include "mesh_path.h"
@@ -1048,7 +1049,7 @@
LOG (GNUNET_ERROR_TYPE_DEBUG, " ... adding %s\n",
GNUNET_i2s (&id[i]));
path->peers[i] = GNUNET_PEER_intern (&id[i]);
- if (path->peers[i] == myid)
+ if (path->peers[i] == my_short_id)
own_pos = i;
}
if (own_pos == 0 && path->peers[own_pos] != myid)
@@ -1056,7 +1057,7 @@
/* create path: self not found in path through self */
GNUNET_break_op (0);
path_destroy (path);
- connection_destroy (c);
+ GMC_destroy (c);
return GNUNET_OK;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos);
@@ -1086,9 +1087,9 @@
orig_peer->tunnel = tunnel_new ();
orig_peer->tunnel->peer = orig_peer;
}
- tunnel_add_connection (orig_peer->tunnel, c);
- if (MESH_TUNNEL_NEW == c->t->state)
- tunnel_change_state (c->t, MESH_TUNNEL_WAITING);
+ GMT_add_connection (orig_peer->tunnel, c);
+ if (MESH_TUNNEL_NEW == GMT_get_state (c->t))
+ GMT_change_state (c->t, MESH_TUNNEL_WAITING);
send_connection_ack (c, GNUNET_NO);
if (MESH_CONNECTION_SENT == c->state)
@@ -1199,15 +1200,14 @@
if (GMC_is_terminal (c, GNUNET_YES))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " Connection ACK for us!\n");
- if (MESH_TUNNEL_READY != c->t->state)
- tunnel_change_state (c->t, MESH_TUNNEL_READY);
- connection_change_state (c, MESH_CONNECTION_READY);
- tunnel_send_queued_data (c->t, GNUNET_NO);
+ GMC_change_state (c, MESH_CONNECTION_READY);
+ GMT_change_state (c->t, MESH_TUNNEL_READY);
+ GMT_send_queued_data (c->t, GNUNET_NO);
return GNUNET_OK;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n");
- send_prebuilt_message_connection (message, c, NULL, fwd);
+ GMC_send_prebuilt_message (message, c, NULL, fwd);
return GNUNET_OK;
}
@@ -1287,16 +1287,16 @@
return GNUNET_OK;
}
id = GNUNET_PEER_search (peer);
- if (id == connection_get_prev_hop (c)->id)
+ if (id == GMP_get_short_id (connection_get_prev_hop (c)))
fwd = GNUNET_YES;
- else if (id == connection_get_next_hop (c)->id)
+ else if (id == GMP_get_short_id (connection_get_next_hop (c)))
fwd = GNUNET_NO;
else
{
GNUNET_break_op (0);
return GNUNET_OK;
}
- send_prebuilt_message_connection (message, c, NULL, fwd);
+ GMC_send_prebuilt_message (message, c, NULL, fwd);
c->destroy = GNUNET_YES;
return GNUNET_OK;
@@ -1353,7 +1353,7 @@
/* Check if origin is as expected */
neighbor = connection_get_hop (c, !fwd);
- if (peer_get (peer)->id != neighbor->id)
+ if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor))
{
GNUNET_break_op (0);
return GNUNET_OK;
@@ -1502,13 +1502,13 @@
/* Is this a forward or backward ACK? */
id = GNUNET_PEER_search (peer);
- if (connection_get_next_hop (c)->id == id)
+ if (GMP_get_short_id (connection_get_next_hop (c)) == id)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n");
fc = &c->fwd_fc;
fwd = GNUNET_YES;
}
- else if (connection_get_prev_hop (c)->id == id)
+ else if (GMP_get_short_id (connection_get_prev_hop (c)) == id)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n");
fc = &c->bck_fc;
@@ -1585,12 +1585,12 @@
* this way of discerining FWD/BCK should not be a problem.
*/
id = GNUNET_PEER_search (peer);
- if (connection_get_next_hop (c)->id == id)
+ if (GMP_get_short_id (connection_get_next_hop (c)) == id)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n");
fc = &c->fwd_fc;
}
- else if (connection_get_prev_hop (c)->id == id)
+ else if (GMP_get_short_id (connection_get_prev_hop (c)) == id)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n");
fc = &c->bck_fc;
@@ -1625,7 +1625,7 @@
*/
int
GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MESH_ConnectionKeepAlive *msg;
struct MeshConnection *c;
@@ -1649,7 +1649,7 @@
/* Check if origin is as expected */
neighbor = connection_get_hop (c, fwd);
- if (peer_get (peer)->id != neighbor->id)
+ if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor))
{
GNUNET_break_op (0);
return GNUNET_OK;
@@ -1676,8 +1676,8 @@
* @param ch Channel, if any.
* @param fwd Is this a fwd ACK? (will go dest->root)
*/
-static void
-send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd)
+void
+GMC_send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd)
{
unsigned int buffer;
@@ -1686,8 +1686,10 @@
fwd ? "FWD" : "BCK", c, ch);
if (NULL == c || GMC_is_terminal (c, fwd))
{
+ struct MeshTunnel3 *t;
LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from all connections\n");
- buffer = GMT_get_buffer (NULL == c ? ch->t : c->t, fwd);
+ t = (NULL == c) ? GMCH_get_tunnel (ch) : GMC_get_tunnel (c);
+ buffer = GMT_get_buffer (t, fwd);
}
else
{
@@ -1721,7 +1723,6 @@
}
-
/**
* Initialize the connections subsystem
*
@@ -1866,7 +1867,20 @@
return c->state;
}
+/**
+ * Get the connection tunnel.
+ *
+ * @param c Connection to get the tunnel from.
+ *
+ * @return tunnel of the connection.
+ */
+struct MeshTunnel3 *
+GMC_get_tunnel (const struct MeshConnection *c)
+{
+ return c->t;
+}
+
/**
* Get free buffer space in a connection.
*
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.h 2013-10-09 08:29:10 UTC
(rev 30027)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.h 2013-10-09 08:32:49 UTC
(rev 30028)
@@ -208,6 +208,17 @@
const struct GNUNET_MessageHeader *message);
/**
+ * Send an ACK on the appropriate connection/channel, depending on
+ * the direction and the position of the peer.
+ *
+ * @param c Which connection to send the hop-by-hop ACK.
+ * @param ch Channel, if any.
+ * @param fwd Is this a fwd ACK? (will go dest->root)
+ */
+void
+GMC_send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd);
+
+/**
* Initialize the connections subsystem
*
* @param c Configuration handle.
@@ -264,6 +275,16 @@
GMC_get_state (const struct MeshConnection *c);
/**
+ * Get the connection tunnel.
+ *
+ * @param c Connection to get the tunnel from.
+ *
+ * @return tunnel of the connection.
+ */
+struct MeshTunnel3 *
+GMC_get_tunnel (const struct MeshConnection *c);
+
+/**
* Get free buffer space in a connection.
*
* @param c Connection.
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-10-09 08:29:10 UTC (rev
30027)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-10-09 08:32:49 UTC (rev
30028)
@@ -1569,7 +1569,22 @@
return GNUNET_PEER_resolve2 (peer->id);
}
+
/**
+ * Get the Short ID of a peer.
+ *
+ * @param peer Peer to get from.
+ *
+ * @return Short ID of peer.
+ */
+GNUNET_PEER_Id
+GMP_get_short_id (const struct MeshPeer *peer)
+{
+ return peer->id;
+}
+
+
+/**
* Get the static string for a peer ID.
*
* @param peer Peer.
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-10-09 08:29:10 UTC (rev
30027)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-10-09 08:32:49 UTC (rev
30028)
@@ -93,7 +93,7 @@
GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel3 *t);
/**
- * Chech whether there is a direct (core level) connection to peer.
+ * Check whether there is a direct (core level) connection to peer.
*
* @param peer Peer to check.
*
@@ -102,6 +102,7 @@
int
GMP_is_neighbor (const struct MeshPeer *peer);
+
/**
* Add a connection to a neighboring peer.
*
@@ -131,6 +132,16 @@
GMP_get_id (const struct MeshPeer *peer);
/**
+ * Get the Short ID of a peer.
+ *
+ * @param peer Peer to get from.
+ *
+ * @return Short ID of peer.
+ */
+GNUNET_PEER_Id
+GMP_get_short_id (const struct MeshPeer *peer);
+
+/**
* Get the static string for a peer ID.
*
* @param peer Peer.
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-10-09 08:29:10 UTC
(rev 30027)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-10-09 08:32:49 UTC
(rev 30028)
@@ -289,36 +289,6 @@
}
-/**
- * Send all cached messages that we can, tunnel is online.
- *
- * @param t Tunnel that holds the messages.
- * @param fwd Is this fwd?
- */
-static void
-tunnel_send_queued_data (struct MeshTunnel3 *t, int fwd)
-{
- struct MeshTunnelQueue *tq;
- struct MeshTunnelQueue *next;
- unsigned int room;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "tunnel_send_queued_data on tunnel %s\n",
- GMP_2s (t->peer));
- room = GMT_get_buffer (t, fwd);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer space: %u\n", room);
- for (tq = t->tq_head; NULL != tq && room > 0; tq = next)
- {
- next = tq->next;
- room--;
- GNUNET_CONTAINER_DLL_remove (t->tq_head, t->tq_tail, tq);
- GMCH_send_prebuilt_message ((struct GNUNET_MessageHeader *) &tq[1],
- tq->ch, fwd);
-
- GNUNET_free (tq);
- }
-}
-
void
handle_data (struct MeshTunnel3 *t,
const struct GNUNET_MESH_Data *msg,
@@ -565,11 +535,42 @@
GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tq);
if (MESH_TUNNEL_READY == t->state)
- tunnel_send_queued_data (t, fwd);
+ GMT_send_queued_data (t, fwd);
}
/**
+ * Send all cached messages that we can, tunnel is online.
+ *
+ * @param t Tunnel that holds the messages.
+ * @param fwd Is this fwd?
+ */
+void
+GMT_send_queued_data (struct MeshTunnel3 *t, int fwd)
+{
+ struct MeshTunnelQueue *tq;
+ struct MeshTunnelQueue *next;
+ unsigned int room;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "GMT_send_queued_data on tunnel %s\n",
+ GMP_2s (t->peer));
+ room = GMT_get_buffer (t, fwd);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer space: %u\n", room);
+ for (tq = t->tq_head; NULL != tq && room > 0; tq = next)
+ {
+ next = tq->next;
+ room--;
+ GNUNET_CONTAINER_DLL_remove (t->tq_head, t->tq_tail, tq);
+ GMCH_send_prebuilt_message ((struct GNUNET_MessageHeader *) &tq[1],
+ tq->ch, fwd);
+
+ GNUNET_free (tq);
+ }
+}
+
+
+/**
* Initialize the tunnel subsystem.
*
* @param c Configuration handle.
@@ -952,6 +953,19 @@
/**
+ * Get the state of a tunnel.
+ *
+ * @param t Tunnel.
+ *
+ * @return Tunnel's state.
+ */
+enum MeshTunnelState
+GMT_get_state (struct MeshTunnel3 *t)
+{
+ return t->state;
+}
+
+/**
* Get the total buffer space for a tunnel.
*
* @param t Tunnel.
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.h 2013-10-09 08:29:10 UTC
(rev 30027)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.h 2013-10-09 08:32:49 UTC
(rev 30028)
@@ -176,6 +176,15 @@
int fwd);
/**
+ * Send all cached messages that we can, tunnel is online.
+ *
+ * @param t Tunnel that holds the messages.
+ * @param fwd Is this fwd?
+ */
+void
+GMT_send_queued_data (struct MeshTunnel3 *t, int fwd);
+
+/**
* Count established (ready) connections of a tunnel.
*
* @param t Tunnel on which to count.
@@ -196,6 +205,16 @@
GMT_count_channels (struct MeshTunnel3 *t);
/**
+ * Get the state of a tunnel.
+ *
+ * @param t Tunnel.
+ *
+ * @return Tunnel's state.
+ */
+enum MeshTunnelState
+GMT_get_state (struct MeshTunnel3 *t);
+
+/**
* Get the total buffer space for a tunnel.
*
* @param t Tunnel.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30028 - gnunet/src/mesh,
gnunet <=