[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28540 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28540 - gnunet/src/mesh |
Date: |
Mon, 12 Aug 2013 17:07:01 +0200 |
Author: bartpolot
Date: 2013-08-12 17:07:01 +0200 (Mon, 12 Aug 2013)
New Revision: 28540
Modified:
gnunet/src/mesh/gnunet-service-mesh-enc.c
Log:
- fixes
Modified: gnunet/src/mesh/gnunet-service-mesh-enc.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-enc.c 2013-08-12 14:50:20 UTC (rev
28539)
+++ gnunet/src/mesh/gnunet-service-mesh-enc.c 2013-08-12 15:07:01 UTC (rev
28540)
@@ -1865,10 +1865,8 @@
}
msg->header.size = htons (sizeof (struct GNUNET_MESH_ConnectionACK));
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK);
- GNUNET_CRYPTO_hash_xor (&GNUNET_PEER_resolve2 (t->peer->id)->hashPubKey,
- &my_full_id.hashPubKey,
- &msg->tid);
msg->cid = htonl (c->id);
+ msg->tid = t->id;
/* TODO add signature */
@@ -2262,7 +2260,26 @@
}
+/**
+ * Is this peer the last one on the connection?
+ *
+ * @param c Connection.
+ * @param fwd Is this about fwd traffic?
+ * Note that the ROOT is the terminal for BCK traffic!
+ *
+ * @return GNUNET_YES if terminal, GNUNET_NO if relay/origin.
+ */
+static int
+connection_is_terminal (struct MeshConnection *c, int fwd)
+{
+ if (fwd && c->own_pos == c->path->length - 1)
+ return GNUNET_YES;
+ if (!fwd && c->own_pos == 0)
+ return GNUNET_YES;
+ return GNUNET_NO;
+}
+
/**
* @brief Re-initiate traffic on this connection if necessary.
*
@@ -3780,6 +3797,8 @@
struct MeshTunnel2 *t;
t = tunnel_get (tid);
+ if (NULL == t)
+ return NULL;
for (c = t->connection_head; NULL != c; c = c->next)
if (c->id == cid)
return c;
@@ -4079,7 +4098,7 @@
peer2s (c->t->peer),
c->id);
- if (NULL != c->t->channel_head) /* If local, leave TODO review */
+ if (connection_is_terminal (c, GNUNET_NO)) /* If local, leave. */
return;
connection_destroy (c);
@@ -4108,7 +4127,7 @@
peer2s (c->t->peer),
c->id);
- if (NULL != c->t->channel_head) /* If local, leave TODO review */
+ if (connection_is_terminal (c, GNUNET_YES)) /* If local, leave. */
return;
connection_destroy (c);
@@ -4140,7 +4159,7 @@
if (GNUNET_SCHEDULER_NO_TASK != *ti)
GNUNET_SCHEDULER_cancel (*ti);
- if (NULL != c->t->channel_head) /* Endpoint */
+ if (connection_is_terminal (c, !fwd)) /* Endpoint */
{
f = fwd ? &connection_fwd_keepalive : &connection_bck_keepalive;
*ti = GNUNET_SCHEDULER_add_delayed (refresh_connection_time, f, c);
@@ -4339,14 +4358,14 @@
break;
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* path create\n");
- if (NULL != c->t->channel_head)
+ if (connection_is_terminal (c, GNUNET_NO))
data_size = send_core_connection_create (queue->cls, size, buf);
else
data_size = send_core_data_raw (queue->cls, size, buf);
break;
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* path ack\n");
- if (NULL != c->t->channel_head)
+ if (connection_is_terminal (c, GNUNET_YES))
data_size = send_core_connection_ack (queue->cls, size, buf);
else
data_size = send_core_data_raw (queue->cls, size, buf);
@@ -4903,7 +4922,7 @@
connection_reset_timeout (c, GNUNET_NO);
/* Message for us? */
- if (NULL != c->t->channel_head)
+ if (connection_is_terminal (c, GNUNET_NO))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n");
if (3 <= tunnel_count_connections(c->t) && NULL != c->t->peer->dhtget)
@@ -5194,7 +5213,7 @@
fc->last_pid_recv = pid;
/* Is this message for us? */
- if (NULL != c->t->channel_head)
+ if (connection_is_terminal (c, fwd))
{
size_t dsize = size - sizeof (struct GNUNET_MESH_Encrypted);
char cbuf[dsize];
@@ -5489,7 +5508,7 @@
connection_change_state (c, MESH_CONNECTION_READY);
connection_reset_timeout (c, fwd);
- if (NULL != c->t->channel_head)
+ if (connection_is_terminal (c, fwd))
return GNUNET_OK;
GNUNET_STATISTICS_update (stats, "# keepalives forwarded", 1, GNUNET_NO);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28540 - gnunet/src/mesh,
gnunet <=