aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet_connection.c')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c65
1 files changed, 2 insertions, 63 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index a7a3b9121..147bf1e8e 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -1517,67 +1517,6 @@ add_to_peer (struct CadetConnection *c, struct CadetPeer *peer)
1517 1517
1518 1518
1519/** 1519/**
1520 * Builds a path from a PeerIdentity array.
1521 *
1522 * @param peers PeerIdentity array.
1523 * @param size Size of the @c peers array.
1524 * @param own_pos Output parameter: own position in the path.
1525 *
1526 * @return Fixed and shortened path.
1527 */
1528static struct CadetPeerPath *
1529build_path_from_peer_ids (struct GNUNET_PeerIdentity *peers,
1530 unsigned int size,
1531 unsigned int *own_pos)
1532{
1533 struct CadetPeerPath *path;
1534 GNUNET_PEER_Id shortid;
1535 unsigned int i;
1536 unsigned int j;
1537 unsigned int offset;
1538
1539 /* Create path */
1540 LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating path...\n");
1541 path = path_new (size);
1542 *own_pos = 0;
1543 offset = 0;
1544 for (i = 0; i < size; i++)
1545 {
1546 LOG (GNUNET_ERROR_TYPE_DEBUG, " - %u: taking %s\n",
1547 i, GNUNET_i2s (&peers[i]));
1548 shortid = GNUNET_PEER_intern (&peers[i]);
1549
1550 /* Check for loops / duplicates */
1551 for (j = 0; j < i - offset; j++)
1552 {
1553 if (path->peers[j] == shortid)
1554 {
1555 LOG (GNUNET_ERROR_TYPE_DEBUG, " already exists at pos %u\n", j);
1556 offset = i - j;
1557 LOG (GNUNET_ERROR_TYPE_DEBUG, " offset now %u\n", offset);
1558 GNUNET_PEER_change_rc (shortid, -1);
1559 }
1560 }
1561 LOG (GNUNET_ERROR_TYPE_DEBUG, " storing at %u\n", i - offset);
1562 path->peers[i - offset] = shortid;
1563 if (path->peers[i - offset] == myid)
1564 *own_pos = i - offset;
1565 }
1566 path->length -= offset;
1567
1568 if (path->peers[*own_pos] != myid)
1569 {
1570 /* create path: self not found in path through self */
1571 GNUNET_break_op (0);
1572 path_destroy (path);
1573 return NULL;
1574 }
1575
1576 return path;
1577}
1578
1579
1580/**
1581 * Log receipt of message on stderr (INFO level). 1520 * Log receipt of message on stderr (INFO level).
1582 * 1521 *
1583 * @param message Message received. 1522 * @param message Message received.
@@ -1656,8 +1595,8 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1656 c = connection_get (cid); 1595 c = connection_get (cid);
1657 if (NULL == c) 1596 if (NULL == c)
1658 { 1597 {
1659 path = build_path_from_peer_ids ((struct GNUNET_PeerIdentity *) &msg[1], 1598 path = path_build_from_peer_ids ((struct GNUNET_PeerIdentity *) &msg[1],
1660 size, &own_pos); 1599 size, myid, &own_pos);
1661 if (NULL == path) 1600 if (NULL == path)
1662 return GNUNET_OK; 1601 return GNUNET_OK;
1663 1602