[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28401 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28401 - gnunet/src/mesh |
Date: |
Mon, 5 Aug 2013 15:57:57 +0200 |
Author: bartpolot
Date: 2013-08-05 15:57:57 +0200 (Mon, 05 Aug 2013)
New Revision: 28401
Modified:
gnunet/src/mesh/gnunet-service-mesh-enc.c
Log:
- handle connection keep-alives
Modified: gnunet/src/mesh/gnunet-service-mesh-enc.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-enc.c 2013-08-05 13:49:20 UTC (rev
28400)
+++ gnunet/src/mesh/gnunet-service-mesh-enc.c 2013-08-05 13:57:57 UTC (rev
28401)
@@ -4849,6 +4849,7 @@
GNUNET_NO);
return GNUNET_OK;
}
+
ack = ntohl (msg->ack);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ACK %u\n", ack);
@@ -4964,40 +4965,45 @@
handle_mesh_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct GNUNET_MESH_TunnelKeepAlive *msg;
- struct MeshTunnel *t;
- struct MeshClient *c;
- GNUNET_PEER_Id hop;
+ struct GNUNET_MESH_ConnectionKeepAlive *msg;
+ struct MeshConnection *c;
+ struct MeshPeer *neighbor;
int fwd;
- msg = (struct GNUNET_MESH_TunnelKeepAlive *) message;
+ msg = (struct GNUNET_MESH_ConnectionKeepAlive *) message;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a keepalive packet from %s\n",
GNUNET_i2s (peer));
- t = channel_get (&msg->oid, ntohl (msg->tid));
- if (NULL == t)
+ c = connection_get (&msg->tid, ntohl (msg->cid));
+ if (NULL == c)
{
- /* TODO notify that we dont know that tunnel */
- GNUNET_STATISTICS_update (stats, "# keepalive on unknown tunnel", 1,
+ GNUNET_STATISTICS_update (stats, "# keepalive on unknown connection", 1,
GNUNET_NO);
return GNUNET_OK;
}
fwd = GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE == ntohs (message->type) ?
GNUNET_YES : GNUNET_NO;
- c = fwd ? t->client : t->owner;
- hop = fwd ? t->next_hop : t->prev_hop;
- if (NULL != c)
- tunnel_change_state (t, MESH_TUNNEL_READY);
- tunnel_reset_timeout (t, fwd);
- if (NULL != c || 0 == hop || myid == hop)
+ /* Check if origin is as expected */
+ neighbor = fwd ? connection_get_prev_hop (c) : connection_get_next_hop (c);
+ if (peer_get (peer)->id != neighbor->id)
+ {
+ GNUNET_break_op (0);
return GNUNET_OK;
+ }
+ connection_change_state (c, MESH_CONNECTION_READY);
+ connection_reset_timeout (c, fwd);
+
+ if (NULL != c->t->channel_head)
+ return GNUNET_OK;
+
GNUNET_STATISTICS_update (stats, "# keepalives forwarded", 1, GNUNET_NO);
- send_prebuilt_message (message, hop, t);
+ send_prebuilt_message_connection (message, c, NULL, fwd);
+
return GNUNET_OK;
- }
+}
@@ -5013,16 +5019,16 @@
sizeof (struct GNUNET_MESH_ConnectionBroken)},
{&handle_mesh_connection_destroy,
GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY,
sizeof (struct GNUNET_MESH_ConnectionDestroy)},
- {&handle_mesh_fwd, GNUNET_MESSAGE_TYPE_MESH_FWD, 0},
- {&handle_mesh_bck, GNUNET_MESSAGE_TYPE_MESH_BCK, 0},
{&handle_mesh_keepalive, GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE,
- sizeof (struct GNUNET_MESH_TunnelKeepAlive)},
+ sizeof (struct GNUNET_MESH_ConnectionKeepAlive)},
{&handle_mesh_keepalive, GNUNET_MESSAGE_TYPE_MESH_BCK_KEEPALIVE,
- sizeof (struct GNUNET_MESH_TunnelKeepAlive)},
+ sizeof (struct GNUNET_MESH_ConnectionKeepAlive)},
{&handle_mesh_ack, GNUNET_MESSAGE_TYPE_MESH_ACK,
sizeof (struct GNUNET_MESH_ACK)},
{&handle_mesh_poll, GNUNET_MESSAGE_TYPE_MESH_POLL,
sizeof (struct GNUNET_MESH_Poll)},
+ {&handle_mesh_fwd, GNUNET_MESSAGE_TYPE_MESH_FWD, 0},
+ {&handle_mesh_bck, GNUNET_MESSAGE_TYPE_MESH_BCK, 0},
{NULL, 0, 0}
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28401 - gnunet/src/mesh,
gnunet <=