aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/gnunet-service-mesh_connection.c')
-rw-r--r--src/mesh/gnunet-service-mesh_connection.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c
index ef2df2ce3..c31ee2aab 100644
--- a/src/mesh/gnunet-service-mesh_connection.c
+++ b/src/mesh/gnunet-service-mesh_connection.c
@@ -791,6 +791,39 @@ send_broken (struct MeshConnection *c,
791 791
792 792
793/** 793/**
794 * Send a notification that a connection is broken, when a connection
795 * isn't even created.
796 *
797 * @param connection_id Connection ID.
798 * @param id1 Peer that has disconnected.
799 * @param id2 Peer that has disconnected.
800 * @param peer Peer to notify (neighbor who sent the connection).
801 */
802static void
803send_broken2 (struct GNUNET_HashCode *connection_id,
804 const struct GNUNET_PeerIdentity *id1,
805 const struct GNUNET_PeerIdentity *id2,
806 GNUNET_PEER_Id peer_id)
807{
808 struct GNUNET_MESH_ConnectionBroken *msg;
809 struct MeshPeer *neighbor;
810
811 msg = GNUNET_new (struct GNUNET_MESH_ConnectionBroken);
812 msg->header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken));
813 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN);
814 msg->cid = *connection_id;
815 msg->peer1 = *id1;
816 msg->peer2 = *id2;
817 neighbor = GMP_get_short (peer_id);
818 GMP_queue_add (neighbor, msg,
819 GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED,
820 sizeof (struct GNUNET_MESH_ConnectionBroken),
821 NULL, GNUNET_SYSERR, /* connection, fwd */
822 NULL, NULL); /* continuation */
823}
824
825
826/**
794 * Send keepalive packets for a connection. 827 * Send keepalive packets for a connection.
795 * 828 *
796 * @param c Connection to keep alive.. 829 * @param c Connection to keep alive..
@@ -1383,15 +1416,29 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1383 size, &own_pos); 1416 size, &own_pos);
1384 if (NULL == path) 1417 if (NULL == path)
1385 return GNUNET_OK; 1418 return GNUNET_OK;
1419 if (0 == own_pos)
1420 {
1421 GNUNET_break_op (0);
1422 return GNUNET_OK;
1423 }
1386 LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); 1424 LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos);
1387 GMP_add_path_to_all (path, GNUNET_NO);
1388 LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating connection\n"); 1425 LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating connection\n");
1389 c = GMC_new (cid, NULL, path_duplicate (path), own_pos); 1426 c = GMC_new (cid, NULL, path_duplicate (path), own_pos);
1390 if (NULL == c) 1427 if (NULL == c)
1391 { 1428 {
1429 if (path->length - 1 == own_pos)
1430 {
1431 /* If we are destination, why did the creation fail? */
1432 GNUNET_break (0);
1433 return GNUNET_OK;
1434 }
1435 send_broken2 (cid, &my_full_id,
1436 GNUNET_PEER_resolve2 (path->peers[own_pos + 1]),
1437 path->peers[own_pos - 1]);
1392 path_destroy (path); 1438 path_destroy (path);
1393 return GNUNET_OK; 1439 return GNUNET_OK;
1394 } 1440 }
1441 GMP_add_path_to_all (path, GNUNET_NO);
1395 connection_reset_timeout (c, GNUNET_YES); 1442 connection_reset_timeout (c, GNUNET_YES);
1396 } 1443 }
1397 else 1444 else