aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-07-23 13:04:49 +0000
committerBart Polot <bart@net.in.tum.de>2013-07-23 13:04:49 +0000
commitc25296abc6420f73477918bf5b2505e3c07fc462 (patch)
tree3753f854e94cad1d951ffd539d3ed5a338699eb8 /src/mesh
parent402389b8f1fd8561bfe9ec9b94642441c187d7ce (diff)
downloadgnunet-c25296abc6420f73477918bf5b2505e3c07fc462.tar.gz
gnunet-c25296abc6420f73477918bf5b2505e3c07fc462.zip
- don't use peer_info as a data strcut name
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c203
1 files changed, 100 insertions, 103 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index b3f310d53..d5b344f02 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -95,7 +95,7 @@ if (0 < __count)\
95/******************************************************************************/ 95/******************************************************************************/
96 96
97/** FWD declaration */ 97/** FWD declaration */
98struct MeshPeerInfo; 98struct MeshPeer;
99struct MeshClient; 99struct MeshClient;
100 100
101 101
@@ -117,7 +117,7 @@ struct MeshPeerQueue
117 /** 117 /**
118 * Peer this transmission is directed to. 118 * Peer this transmission is directed to.
119 */ 119 */
120 struct MeshPeerInfo *peer; 120 struct MeshPeer *peer;
121 121
122 /** 122 /**
123 * Tunnel this message belongs to. 123 * Tunnel this message belongs to.
@@ -144,7 +144,7 @@ struct MeshPeerQueue
144/** 144/**
145 * Struct containing all information regarding a given peer 145 * Struct containing all information regarding a given peer
146 */ 146 */
147struct MeshPeerInfo 147struct MeshPeer
148{ 148{
149 /** 149 /**
150 * ID of the peer 150 * ID of the peer
@@ -670,7 +670,7 @@ static unsigned long long n_tunnels;
670static struct GNUNET_CONTAINER_MultiHashMap32 *incoming_tunnels; 670static struct GNUNET_CONTAINER_MultiHashMap32 *incoming_tunnels;
671 671
672/** 672/**
673 * Peers known, indexed by PeerIdentity (MeshPeerInfo). 673 * Peers known, indexed by PeerIdentity (MeshPeer).
674 */ 674 */
675static struct GNUNET_CONTAINER_MultiHashMap *peers; 675static struct GNUNET_CONTAINER_MultiHashMap *peers;
676 676
@@ -777,26 +777,26 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
777 777
778 778
779/** 779/**
780 * Retrieve the MeshPeerInfo stucture associated with the peer, create one 780 * Retrieve the MeshPeer stucture associated with the peer, create one
781 * and insert it in the appropriate structures if the peer is not known yet. 781 * and insert it in the appropriate structures if the peer is not known yet.
782 * 782 *
783 * @param peer Full identity of the peer. 783 * @param peer Full identity of the peer.
784 * 784 *
785 * @return Existing or newly created peer info. 785 * @return Existing or newly created peer info.
786 */ 786 */
787static struct MeshPeerInfo * 787static struct MeshPeer *
788peer_get (const struct GNUNET_PeerIdentity *peer); 788peer_get (const struct GNUNET_PeerIdentity *peer);
789 789
790 790
791/** 791/**
792 * Retrieve the MeshPeerInfo stucture associated with the peer, create one 792 * Retrieve the MeshPeer stucture associated with the peer, create one
793 * and insert it in the appropriate structures if the peer is not known yet. 793 * and insert it in the appropriate structures if the peer is not known yet.
794 * 794 *
795 * @param peer Short identity of the peer. 795 * @param peer Short identity of the peer.
796 * 796 *
797 * @return Existing or newly created peer info. 797 * @return Existing or newly created peer info.
798 */ 798 */
799static struct MeshPeerInfo * 799static struct MeshPeer *
800peer_get_short (const GNUNET_PEER_Id peer); 800peer_get_short (const GNUNET_PEER_Id peer);
801 801
802 802
@@ -937,7 +937,7 @@ tunnel_destroy (struct MeshTunnel *t);
937 */ 937 */
938static void 938static void
939queue_add (void *cls, uint16_t type, size_t size, 939queue_add (void *cls, uint16_t type, size_t size,
940 struct MeshPeerInfo *dst, struct MeshTunnel *t); 940 struct MeshPeer *dst, struct MeshTunnel *t);
941 941
942 942
943/** 943/**
@@ -963,7 +963,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls);
963 * NULL when there are no transmittable messages. 963 * NULL when there are no transmittable messages.
964 */ 964 */
965struct MeshPeerQueue * 965struct MeshPeerQueue *
966queue_get_next (const struct MeshPeerInfo *peer); 966queue_get_next (const struct MeshPeer *peer);
967 967
968 968
969/** 969/**
@@ -1210,7 +1210,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1210 struct MeshTunnel *t) 1210 struct MeshTunnel *t)
1211{ 1211{
1212 struct GNUNET_PeerIdentity id; 1212 struct GNUNET_PeerIdentity id;
1213 struct MeshPeerInfo *neighbor; 1213 struct MeshPeer *neighbor;
1214 struct MeshPeerPath *p; 1214 struct MeshPeerPath *p;
1215 void *data; 1215 void *data;
1216 size_t size; 1216 size_t size;
@@ -1294,7 +1294,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1294static void 1294static void
1295send_path_create (struct MeshTunnel *t) 1295send_path_create (struct MeshTunnel *t)
1296{ 1296{
1297 struct MeshPeerInfo *neighbor; 1297 struct MeshPeer *neighbor;
1298 1298
1299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send create path\n"); 1299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send create path\n");
1300 neighbor = peer_get_short (t->next_hop); 1300 neighbor = peer_get_short (t->next_hop);
@@ -1316,7 +1316,7 @@ send_path_create (struct MeshTunnel *t)
1316static void 1316static void
1317send_path_ack (struct MeshTunnel *t) 1317send_path_ack (struct MeshTunnel *t)
1318{ 1318{
1319 struct MeshPeerInfo *neighbor; 1319 struct MeshPeer *neighbor;
1320 1320
1321 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send path ack\n"); 1321 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send path ack\n");
1322 neighbor = peer_get_short (t->prev_hop); 1322 neighbor = peer_get_short (t->prev_hop);
@@ -1479,62 +1479,59 @@ send_core_path_ack (void *cls, size_t size, void *buf)
1479 * FIXME implement 1479 * FIXME implement
1480 */ 1480 */
1481static int 1481static int
1482peer_info_timeout (void *cls, 1482peer_timeout (void *cls,
1483 const struct GNUNET_HashCode *key, 1483 const struct GNUNET_HashCode *key,
1484 void *value) 1484 void *value)
1485{ 1485{
1486 return GNUNET_YES; 1486 return GNUNET_YES;
1487} 1487}
1488 1488
1489
1489/** 1490/**
1490 * Retrieve the MeshPeerInfo stucture associated with the peer, create one 1491 * Retrieve the MeshPeer stucture associated with the peer, create one
1491 * and insert it in the appropriate structures if the peer is not known yet. 1492 * and insert it in the appropriate structures if the peer is not known yet.
1492 * 1493 *
1493 * @param peer Full identity of the peer. 1494 * @param peer Full identity of the peer.
1494 * 1495 *
1495 * @return Existing or newly created peer info. 1496 * @return Existing or newly created peer info.
1496 */ 1497 */
1497static struct MeshPeerInfo * 1498static struct MeshPeer *
1498peer_get (const struct GNUNET_PeerIdentity *peer) 1499peer_get (const struct GNUNET_PeerIdentity *peer_id)
1499{ 1500{
1500 struct MeshPeerInfo *peer_info; 1501 struct MeshPeer *peer;
1501 1502
1502 peer_info = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); 1503 peer = GNUNET_CONTAINER_multihashmap_get (peers, &peer_id->hashPubKey);
1503 if (NULL == peer_info) 1504 if (NULL == peer)
1504 { 1505 {
1505 peer_info = 1506 peer = (struct MeshPeer *) GNUNET_malloc (sizeof (struct MeshPeer));
1506 (struct MeshPeerInfo *) GNUNET_malloc (sizeof (struct MeshPeerInfo));
1507 if (GNUNET_CONTAINER_multihashmap_size (peers) > max_peers) 1507 if (GNUNET_CONTAINER_multihashmap_size (peers) > max_peers)
1508 { 1508 {
1509 GNUNET_CONTAINER_multihashmap_iterate (peers, 1509 GNUNET_CONTAINER_multihashmap_iterate (peers,
1510 &peer_info_timeout, 1510 &peer_timeout,
1511 NULL); 1511 NULL);
1512 } 1512 }
1513 GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, peer_info, 1513 GNUNET_CONTAINER_multihashmap_put (peers, &peer_id->hashPubKey, peer,
1514 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1514 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1515 peer_info->id = GNUNET_PEER_intern (peer); 1515 peer->id = GNUNET_PEER_intern (peer_id);
1516 } 1516 }
1517 peer_info->last_contact = GNUNET_TIME_absolute_get(); 1517 peer->last_contact = GNUNET_TIME_absolute_get();
1518 1518
1519 return peer_info; 1519 return peer;
1520} 1520}
1521 1521
1522 1522
1523/** 1523/**
1524 * Retrieve the MeshPeerInfo stucture associated with the peer, create one 1524 * Retrieve the MeshPeer stucture associated with the peer, create one
1525 * and insert it in the appropriate structures if the peer is not known yet. 1525 * and insert it in the appropriate structures if the peer is not known yet.
1526 * 1526 *
1527 * @param peer Short identity of the peer. 1527 * @param peer Short identity of the peer.
1528 * 1528 *
1529 * @return Existing or newly created peer info. 1529 * @return Existing or newly created peer info.
1530 */ 1530 */
1531static struct MeshPeerInfo * 1531static struct MeshPeer *
1532peer_get_short (const GNUNET_PEER_Id peer) 1532peer_get_short (const GNUNET_PEER_Id peer)
1533{ 1533{
1534 struct GNUNET_PeerIdentity id; 1534 return peer_get (GNUNET_PEER_resolve2 (peer));
1535
1536 GNUNET_PEER_resolve (peer, &id);
1537 return peer_get (&id);
1538} 1535}
1539 1536
1540 1537
@@ -1547,15 +1544,15 @@ peer_get_short (const GNUNET_PEER_Id peer)
1547 * @return PID to use, either last sent or first_in_queue - 1 1544 * @return PID to use, either last sent or first_in_queue - 1
1548 */ 1545 */
1549static uint32_t 1546static uint32_t
1550peer_get_first_payload_pid (struct MeshPeerInfo *pi, struct MeshTunnel *t) 1547peer_get_first_payload_pid (struct MeshPeer *p, struct MeshTunnel *t)
1551{ 1548{
1552 struct MeshPeerQueue *q; 1549 struct MeshPeerQueue *q;
1553 uint16_t type; 1550 uint16_t type;
1554 1551
1555 type = pi->id == t->next_hop ? GNUNET_MESSAGE_TYPE_MESH_UNICAST : 1552 type = p->id == t->next_hop ? GNUNET_MESSAGE_TYPE_MESH_UNICAST :
1556 GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN; 1553 GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN;
1557 1554
1558 for (q = pi->queue_head; NULL != q; q = q->next) 1555 for (q = p->queue_head; NULL != q; q = q->next)
1559 { 1556 {
1560 if (q->type == type && q->tunnel == t) 1557 if (q->type == type && q->tunnel == t)
1561 { 1558 {
@@ -1570,7 +1567,7 @@ peer_get_first_payload_pid (struct MeshPeerInfo *pi, struct MeshTunnel *t)
1570 { 1567 {
1571 struct MeshFlowControl *fc; 1568 struct MeshFlowControl *fc;
1572 1569
1573 fc = pi->id == t->next_hop ? &t->next_fc : &t->prev_fc; 1570 fc = p->id == t->next_hop ? &t->next_fc : &t->prev_fc;
1574 return fc->last_pid_sent; 1571 return fc->last_pid_sent;
1575 } 1572 }
1576} 1573}
@@ -1585,7 +1582,7 @@ peer_get_first_payload_pid (struct MeshPeerInfo *pi, struct MeshTunnel *t)
1585 * @return Best current known path towards the peer, if any. 1582 * @return Best current known path towards the peer, if any.
1586 */ 1583 */
1587static struct MeshPeerPath * 1584static struct MeshPeerPath *
1588peer_get_best_path (const struct MeshPeerInfo *peer, const struct MeshTunnel *t) 1585peer_get_best_path (const struct MeshPeer *peer, const struct MeshTunnel *t)
1589{ 1586{
1590 struct MeshPeerPath *best_p; 1587 struct MeshPeerPath *best_p;
1591 struct MeshPeerPath *p; 1588 struct MeshPeerPath *p;
@@ -1601,7 +1598,7 @@ peer_get_best_path (const struct MeshPeerInfo *peer, const struct MeshTunnel *t)
1601 best_cost = cost; 1598 best_cost = cost;
1602 best_p = p; 1599 best_p = p;
1603 } 1600 }
1604 p = p->next; 1601 p = p->next;
1605 } 1602 }
1606 return best_p; 1603 return best_p;
1607} 1604}
@@ -1616,7 +1613,7 @@ peer_get_best_path (const struct MeshPeerInfo *peer, const struct MeshTunnel *t)
1616 * @param t Tunnel for which to create the path, if possible. 1613 * @param t Tunnel for which to create the path, if possible.
1617 */ 1614 */
1618static void 1615static void
1619peer_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t) 1616peer_connect (struct MeshPeer *peer, struct MeshTunnel *t)
1620{ 1617{
1621 struct MeshPeerPath *p; 1618 struct MeshPeerPath *p;
1622 1619
@@ -1664,7 +1661,7 @@ peer_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t)
1664static void 1661static void
1665peer_unlock_queue (GNUNET_PEER_Id peer_id) 1662peer_unlock_queue (GNUNET_PEER_Id peer_id)
1666{ 1663{
1667 struct MeshPeerInfo *peer; 1664 struct MeshPeer *peer;
1668 struct MeshPeerQueue *q; 1665 struct MeshPeerQueue *q;
1669 size_t size; 1666 size_t size;
1670 1667
@@ -1698,33 +1695,33 @@ peer_unlock_queue (GNUNET_PEER_Id peer_id)
1698static void 1695static void
1699peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel *t) 1696peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel *t)
1700{ 1697{
1701 struct MeshPeerInfo *peer_info; 1698 struct MeshPeer *peer;
1702 struct MeshPeerQueue *pq; 1699 struct MeshPeerQueue *q;
1703 struct MeshPeerQueue *next; 1700 struct MeshPeerQueue *next;
1704 struct MeshFlowControl *fc; 1701 struct MeshFlowControl *fc;
1705 1702
1706 if (0 == neighbor) 1703 if (0 == neighbor)
1707 return; /* Was local peer, 0'ed in tunnel_destroy_iterator */ 1704 return; /* Was local peer, 0'ed in tunnel_destroy_iterator */
1708 peer_info = peer_get_short (neighbor); 1705 peer = peer_get_short (neighbor);
1709 for (pq = peer_info->queue_head; NULL != pq; pq = next) 1706 for (q = peer->queue_head; NULL != q; q = next)
1710 { 1707 {
1711 next = pq->next; 1708 next = q->next;
1712 if (pq->tunnel == t) 1709 if (q->tunnel == t)
1713 { 1710 {
1714 if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == pq->type || 1711 if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == q->type ||
1715 GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == pq->type) 1712 GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == q->type)
1716 { 1713 {
1717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1718 "peer_cancel_queues %s\n", 1715 "peer_cancel_queues %s\n",
1719 GNUNET_MESH_DEBUG_M2S (pq->type)); 1716 GNUNET_MESH_DEBUG_M2S (q->type));
1720 } 1717 }
1721 queue_destroy (pq, GNUNET_YES); 1718 queue_destroy (q, GNUNET_YES);
1722 } 1719 }
1723 } 1720 }
1724 if (NULL == peer_info->queue_head && NULL != peer_info->core_transmit) 1721 if (NULL == peer->queue_head && NULL != peer->core_transmit)
1725 { 1722 {
1726 GNUNET_CORE_notify_transmit_ready_cancel (peer_info->core_transmit); 1723 GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit);
1727 peer_info->core_transmit = NULL; 1724 peer->core_transmit = NULL;
1728 } 1725 }
1729 fc = neighbor == t->next_hop ? &t->next_fc : &t->prev_fc; 1726 fc = neighbor == t->next_hop ? &t->next_fc : &t->prev_fc;
1730 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task) 1727 if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task)
@@ -1738,44 +1735,44 @@ peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel *t)
1738/** 1735/**
1739 * Destroy the peer_info and free any allocated resources linked to it 1736 * Destroy the peer_info and free any allocated resources linked to it
1740 * 1737 *
1741 * @param pi The peer_info to destroy. 1738 * @param peer The peer_info to destroy.
1742 * 1739 *
1743 * @return GNUNET_OK on success 1740 * @return GNUNET_OK on success
1744 */ 1741 */
1745static int 1742static int
1746peer_info_destroy (struct MeshPeerInfo *pi) 1743peer_destroy (struct MeshPeer *peer)
1747{ 1744{
1748 struct GNUNET_PeerIdentity id; 1745 struct GNUNET_PeerIdentity id;
1749 struct MeshPeerPath *p; 1746 struct MeshPeerPath *p;
1750 struct MeshPeerPath *nextp; 1747 struct MeshPeerPath *nextp;
1751 unsigned int i; 1748 unsigned int i;
1752 1749
1753 GNUNET_PEER_resolve (pi->id, &id); 1750 GNUNET_PEER_resolve (peer->id, &id);
1754 GNUNET_PEER_change_rc (pi->id, -1); 1751 GNUNET_PEER_change_rc (peer->id, -1);
1755 1752
1756 if (GNUNET_YES != 1753 if (GNUNET_YES !=
1757 GNUNET_CONTAINER_multihashmap_remove (peers, &id.hashPubKey, pi)) 1754 GNUNET_CONTAINER_multihashmap_remove (peers, &id.hashPubKey, peer))
1758 { 1755 {
1759 GNUNET_break (0); 1756 GNUNET_break (0);
1760 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1757 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1761 "removing peer %s, not in hashmap\n", GNUNET_i2s (&id)); 1758 "removing peer %s, not in hashmap\n", GNUNET_i2s (&id));
1762 } 1759 }
1763 if (NULL != pi->dhtget) 1760 if (NULL != peer->dhtget)
1764 { 1761 {
1765 GNUNET_DHT_get_stop (pi->dhtget); 1762 GNUNET_DHT_get_stop (peer->dhtget);
1766 } 1763 }
1767 p = pi->path_head; 1764 p = peer->path_head;
1768 while (NULL != p) 1765 while (NULL != p)
1769 { 1766 {
1770 nextp = p->next; 1767 nextp = p->next;
1771 GNUNET_CONTAINER_DLL_remove (pi->path_head, pi->path_tail, p); 1768 GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, p);
1772 path_destroy (p); 1769 path_destroy (p);
1773 p = nextp; 1770 p = nextp;
1774 } 1771 }
1775 for (i = 0; i < pi->ntunnels; i++) 1772 for (i = 0; i < peer->ntunnels; i++)
1776 tunnel_destroy_empty (pi->tunnels[i]); 1773 tunnel_destroy_empty (peer->tunnels[i]);
1777 GNUNET_array_grow (pi->tunnels, pi->ntunnels, 0); 1774 GNUNET_array_grow (peer->tunnels, peer->ntunnels, 0);
1778 GNUNET_free (pi); 1775 GNUNET_free (peer);
1779 return GNUNET_OK; 1776 return GNUNET_OK;
1780} 1777}
1781 1778
@@ -1792,12 +1789,12 @@ peer_info_destroy (struct MeshPeerInfo *pi)
1792 * TODO: optimize (see below) 1789 * TODO: optimize (see below)
1793 */ 1790 */
1794static void 1791static void
1795peer_info_remove_path (struct MeshPeerInfo *peer, GNUNET_PEER_Id p1, 1792peer_remove_path (struct MeshPeer *peer, GNUNET_PEER_Id p1,
1796 GNUNET_PEER_Id p2) 1793 GNUNET_PEER_Id p2)
1797{ 1794{
1798 struct MeshPeerPath *p; 1795 struct MeshPeerPath *p;
1799 struct MeshPeerPath *next; 1796 struct MeshPeerPath *next;
1800 struct MeshPeerInfo *peer_d; 1797 struct MeshPeer *peer_d;
1801 GNUNET_PEER_Id d; 1798 GNUNET_PEER_Id d;
1802 unsigned int destroyed; 1799 unsigned int destroyed;
1803 unsigned int i; 1800 unsigned int i;
@@ -1847,7 +1844,7 @@ peer_info_remove_path (struct MeshPeerInfo *peer, GNUNET_PEER_Id p1,
1847 * @param trusted Do we trust that this path is real? 1844 * @param trusted Do we trust that this path is real?
1848 */ 1845 */
1849void 1846void
1850peer_info_add_path (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path, 1847peer_add_path (struct MeshPeer *peer_info, struct MeshPeerPath *path,
1851 int trusted) 1848 int trusted)
1852{ 1849{
1853 struct MeshPeerPath *aux; 1850 struct MeshPeerPath *aux;
@@ -1940,11 +1937,11 @@ peer_info_add_path (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path,
1940 * @param trusted Do we trust that this path is real? 1937 * @param trusted Do we trust that this path is real?
1941 */ 1938 */
1942static void 1939static void
1943peer_info_add_path_to_origin (struct MeshPeerInfo *peer_info, 1940peer_add_path_to_origin (struct MeshPeer *peer_info,
1944 struct MeshPeerPath *path, int trusted) 1941 struct MeshPeerPath *path, int trusted)
1945{ 1942{
1946 path_invert (path); 1943 path_invert (path);
1947 peer_info_add_path (peer_info, path, trusted); 1944 peer_add_path (peer_info, path, trusted);
1948} 1945}
1949 1946
1950 1947
@@ -1956,7 +1953,7 @@ peer_info_add_path_to_origin (struct MeshPeerInfo *peer_info,
1956 * @param t Tunnel to add. 1953 * @param t Tunnel to add.
1957 */ 1954 */
1958static void 1955static void
1959peer_info_add_tunnel (struct MeshPeerInfo *p, struct MeshTunnel *t) 1956peer_add_tunnel (struct MeshPeer *p, struct MeshTunnel *t)
1960{ 1957{
1961 if (0 != t->dest) 1958 if (0 != t->dest)
1962 { 1959 {
@@ -1977,7 +1974,7 @@ peer_info_add_tunnel (struct MeshPeerInfo *p, struct MeshTunnel *t)
1977 * @param t Tunnel to remove. 1974 * @param t Tunnel to remove.
1978 */ 1975 */
1979static void 1976static void
1980peer_info_remove_tunnel (struct MeshPeerInfo *p, struct MeshTunnel *t) 1977peer_remove_tunnel (struct MeshPeer *p, struct MeshTunnel *t)
1981{ 1978{
1982 unsigned int i; 1979 unsigned int i;
1983 1980
@@ -2163,13 +2160,13 @@ path_add_to_peers (struct MeshPeerPath *p, int confirmed)
2163 for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ; 2160 for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ;
2164 for (i++; i < p->length; i++) 2161 for (i++; i < p->length; i++)
2165 { 2162 {
2166 struct MeshPeerInfo *aux; 2163 struct MeshPeer *aux;
2167 struct MeshPeerPath *copy; 2164 struct MeshPeerPath *copy;
2168 2165
2169 aux = peer_get_short (p->peers[i]); 2166 aux = peer_get_short (p->peers[i]);
2170 copy = path_duplicate (p); 2167 copy = path_duplicate (p);
2171 copy->length = i + 1; 2168 copy->length = i + 1;
2172 peer_info_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed); 2169 peer_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed);
2173 } 2170 }
2174} 2171}
2175 2172
@@ -2850,7 +2847,7 @@ tunnel_retransmit_message (void *cls,
2850 struct MeshReliableMessage *copy; 2847 struct MeshReliableMessage *copy;
2851 struct MeshFlowControl *fc; 2848 struct MeshFlowControl *fc;
2852 struct MeshPeerQueue *q; 2849 struct MeshPeerQueue *q;
2853 struct MeshPeerInfo *pi; 2850 struct MeshPeer *pi;
2854 struct MeshTunnel *t; 2851 struct MeshTunnel *t;
2855 struct GNUNET_MESH_Data *payload; 2852 struct GNUNET_MESH_Data *payload;
2856 GNUNET_PEER_Id hop; 2853 GNUNET_PEER_Id hop;
@@ -3150,7 +3147,7 @@ tunnel_destroy (struct MeshTunnel *t)
3150 t->prev_fc.poll_task = GNUNET_SCHEDULER_NO_TASK; 3147 t->prev_fc.poll_task = GNUNET_SCHEDULER_NO_TASK;
3151 } 3148 }
3152 if (0 != t->dest) { 3149 if (0 != t->dest) {
3153 peer_info_remove_tunnel (peer_get_short (t->dest), t); 3150 peer_remove_tunnel (peer_get_short (t->dest), t);
3154 } 3151 }
3155 3152
3156 if (GNUNET_SCHEDULER_NO_TASK != t->fwd_maintenance_task) 3153 if (GNUNET_SCHEDULER_NO_TASK != t->fwd_maintenance_task)
@@ -3542,7 +3539,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
3542 * NULL when there are no transmittable messages. 3539 * NULL when there are no transmittable messages.
3543 */ 3540 */
3544struct MeshPeerQueue * 3541struct MeshPeerQueue *
3545queue_get_next (const struct MeshPeerInfo *peer) 3542queue_get_next (const struct MeshPeer *peer)
3546{ 3543{
3547 struct MeshPeerQueue *q; 3544 struct MeshPeerQueue *q;
3548 3545
@@ -3597,7 +3594,7 @@ queue_get_next (const struct MeshPeerInfo *peer)
3597static size_t 3594static size_t
3598queue_send (void *cls, size_t size, void *buf) 3595queue_send (void *cls, size_t size, void *buf)
3599{ 3596{
3600 struct MeshPeerInfo *peer = cls; 3597 struct MeshPeer *peer = cls;
3601 struct GNUNET_MessageHeader *msg; 3598 struct GNUNET_MessageHeader *msg;
3602 struct MeshPeerQueue *queue; 3599 struct MeshPeerQueue *queue;
3603 struct MeshTunnel *t; 3600 struct MeshTunnel *t;
@@ -3810,7 +3807,7 @@ queue_send (void *cls, size_t size, void *buf)
3810 */ 3807 */
3811static void 3808static void
3812queue_add (void *cls, uint16_t type, size_t size, 3809queue_add (void *cls, uint16_t type, size_t size,
3813 struct MeshPeerInfo *dst, struct MeshTunnel *t) 3810 struct MeshPeer *dst, struct MeshTunnel *t)
3814{ 3811{
3815 struct MeshPeerQueue *queue; 3812 struct MeshPeerQueue *queue;
3816 struct MeshFlowControl *fc; 3813 struct MeshFlowControl *fc;
@@ -3922,8 +3919,8 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
3922 struct GNUNET_MESH_CreateTunnel *msg; 3919 struct GNUNET_MESH_CreateTunnel *msg;
3923 struct GNUNET_PeerIdentity *pi; 3920 struct GNUNET_PeerIdentity *pi;
3924 struct MeshPeerPath *path; 3921 struct MeshPeerPath *path;
3925 struct MeshPeerInfo *dest_peer_info; 3922 struct MeshPeer *dest_peer_info;
3926 struct MeshPeerInfo *orig_peer_info; 3923 struct MeshPeer *orig_peer_info;
3927 struct MeshTunnel *t; 3924 struct MeshTunnel *t;
3928 3925
3929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3926 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3989,7 +3986,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
3989 { 3986 {
3990 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3991 " Creating PeerInfo for destination.\n"); 3988 " Creating PeerInfo for destination.\n");
3992 dest_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); 3989 dest_peer_info = GNUNET_malloc (sizeof (struct MeshPeer));
3993 dest_peer_info->id = GNUNET_PEER_intern (&pi[size - 1]); 3990 dest_peer_info->id = GNUNET_PEER_intern (&pi[size - 1]);
3994 GNUNET_CONTAINER_multihashmap_put (peers, &pi[size - 1].hashPubKey, 3991 GNUNET_CONTAINER_multihashmap_put (peers, &pi[size - 1].hashPubKey,
3995 dest_peer_info, 3992 dest_peer_info,
@@ -4000,7 +3997,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
4000 { 3997 {
4001 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4002 " Creating PeerInfo for origin.\n"); 3999 " Creating PeerInfo for origin.\n");
4003 orig_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); 4000 orig_peer_info = GNUNET_malloc (sizeof (struct MeshPeer));
4004 orig_peer_info->id = GNUNET_PEER_intern (pi); 4001 orig_peer_info->id = GNUNET_PEER_intern (pi);
4005 GNUNET_CONTAINER_multihashmap_put (peers, &pi->hashPubKey, orig_peer_info, 4002 GNUNET_CONTAINER_multihashmap_put (peers, &pi->hashPubKey, orig_peer_info,
4006 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 4003 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
@@ -4028,7 +4025,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
4028 path_add_to_peers (path, GNUNET_NO); 4025 path_add_to_peers (path, GNUNET_NO);
4029 tunnel_use_path (t, path); 4026 tunnel_use_path (t, path);
4030 4027
4031 peer_info_add_tunnel (dest_peer_info, t); 4028 peer_add_tunnel (dest_peer_info, t);
4032 4029
4033 if (own_pos == size - 1) 4030 if (own_pos == size - 1)
4034 { 4031 {
@@ -4043,7 +4040,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
4043 } 4040 }
4044 4041
4045 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n"); 4042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n");
4046 peer_info_add_path_to_origin (orig_peer_info, path, GNUNET_YES); 4043 peer_add_path_to_origin (orig_peer_info, path, GNUNET_YES);
4047 /* This can be a retransmission due to a lost PATH ACK. 4044 /* This can be a retransmission due to a lost PATH ACK.
4048 * Check if we already have a destination client for the tunnel. */ 4045 * Check if we already have a destination client for the tunnel. */
4049 if (t->client != c) 4046 if (t->client != c)
@@ -4081,8 +4078,8 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
4081 /* It's for somebody else! Retransmit. */ 4078 /* It's for somebody else! Retransmit. */
4082 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Retransmitting.\n"); 4079 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Retransmitting.\n");
4083 path2 = path_duplicate (path); 4080 path2 = path_duplicate (path);
4084 peer_info_add_path (dest_peer_info, path2, GNUNET_NO); 4081 peer_add_path (dest_peer_info, path2, GNUNET_NO);
4085 peer_info_add_path_to_origin (orig_peer_info, path, GNUNET_NO); 4082 peer_add_path_to_origin (orig_peer_info, path, GNUNET_NO);
4086 send_path_create (t); 4083 send_path_create (t);
4087 } 4084 }
4088 return GNUNET_OK; 4085 return GNUNET_OK;
@@ -4105,7 +4102,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
4105 const struct GNUNET_MessageHeader *message) 4102 const struct GNUNET_MessageHeader *message)
4106{ 4103{
4107 struct GNUNET_MESH_PathACK *msg; 4104 struct GNUNET_MESH_PathACK *msg;
4108 struct MeshPeerInfo *peer_info; 4105 struct MeshPeer *peer_info;
4109 struct MeshPeerPath *p; 4106 struct MeshPeerPath *p;
4110 struct MeshTunnel *t; 4107 struct MeshTunnel *t;
4111 4108
@@ -4829,7 +4826,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
4829 unsigned int put_path_length, enum GNUNET_BLOCK_Type type, 4826 unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
4830 size_t size, const void *data) 4827 size_t size, const void *data)
4831{ 4828{
4832 struct MeshPeerInfo *peer = cls; 4829 struct MeshPeer *peer = cls;
4833 struct MeshPeerPath *p; 4830 struct MeshPeerPath *p;
4834 struct GNUNET_PeerIdentity pi; 4831 struct GNUNET_PeerIdentity pi;
4835 int i; 4832 int i;
@@ -5030,7 +5027,7 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client,
5030 const struct GNUNET_MessageHeader *message) 5027 const struct GNUNET_MessageHeader *message)
5031{ 5028{
5032 struct GNUNET_MESH_TunnelMessage *t_msg; 5029 struct GNUNET_MESH_TunnelMessage *t_msg;
5033 struct MeshPeerInfo *peer_info; 5030 struct MeshPeer *peer_info;
5034 struct MeshTunnel *t; 5031 struct MeshTunnel *t;
5035 struct MeshClient *c; 5032 struct MeshClient *c;
5036 MESH_TunnelNumber tid; 5033 MESH_TunnelNumber tid;
@@ -5091,7 +5088,7 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client,
5091 GNUNET_i2s (&my_full_id), t->id.tid, t->port, t->local_tid); 5088 GNUNET_i2s (&my_full_id), t->id.tid, t->port, t->local_tid);
5092 5089
5093 peer_info = peer_get (&t_msg->peer); 5090 peer_info = peer_get (&t_msg->peer);
5094 peer_info_add_tunnel (peer_info, t); 5091 peer_add_tunnel (peer_info, t);
5095 peer_connect (peer_info, t); 5092 peer_connect (peer_info, t);
5096 tunnel_reset_timeout (t, GNUNET_YES); 5093 tunnel_reset_timeout (t, GNUNET_YES);
5097 GNUNET_SERVER_receive_done (client, GNUNET_OK); 5094 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -5156,7 +5153,7 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
5156 } 5153 }
5157 else if (c == t->owner && GNUNET_MESH_LOCAL_TUNNEL_ID_SERV > tid) 5154 else if (c == t->owner && GNUNET_MESH_LOCAL_TUNNEL_ID_SERV > tid)
5158 { 5155 {
5159 peer_info_remove_tunnel (peer_get_short (t->dest), t); 5156 peer_remove_tunnel (peer_get_short (t->dest), t);
5160 t->owner = NULL; 5157 t->owner = NULL;
5161 } 5158 }
5162 else 5159 else
@@ -5532,7 +5529,7 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
5532static void 5529static void
5533core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 5530core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
5534{ 5531{
5535 struct MeshPeerInfo *peer_info; 5532 struct MeshPeer *peer_info;
5536 struct MeshPeerPath *path; 5533 struct MeshPeerPath *path;
5537 5534
5538 DEBUG_CONN ("Peer connected\n"); 5535 DEBUG_CONN ("Peer connected\n");
@@ -5553,7 +5550,7 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
5553 } 5550 }
5554 path->peers[0] = myid; 5551 path->peers[0] = myid;
5555 GNUNET_PEER_change_rc (myid, 1); 5552 GNUNET_PEER_change_rc (myid, 1);
5556 peer_info_add_path (peer_info, path, GNUNET_YES); 5553 peer_add_path (peer_info, path, GNUNET_YES);
5557 return; 5554 return;
5558} 5555}
5559 5556
@@ -5567,7 +5564,7 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
5567static void 5564static void
5568core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 5565core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
5569{ 5566{
5570 struct MeshPeerInfo *pi; 5567 struct MeshPeer *pi;
5571 struct MeshPeerQueue *q; 5568 struct MeshPeerQueue *q;
5572 struct MeshPeerQueue *n; 5569 struct MeshPeerQueue *n;
5573 5570
@@ -5591,7 +5588,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
5591 GNUNET_CORE_notify_transmit_ready_cancel(pi->core_transmit); 5588 GNUNET_CORE_notify_transmit_ready_cancel(pi->core_transmit);
5592 pi->core_transmit = NULL; 5589 pi->core_transmit = NULL;
5593 } 5590 }
5594 peer_info_remove_path (pi, pi->id, myid); 5591 peer_remove_path (pi, pi->id, myid);
5595 if (myid == pi->id) 5592 if (myid == pi->id)
5596 { 5593 {
5597 DEBUG_CONN (" (self)\n"); 5594 DEBUG_CONN (" (self)\n");
@@ -5700,7 +5697,7 @@ shutdown_tunnel (void *cls, const struct GNUNET_HashCode * key, void *value)
5700static int 5697static int
5701shutdown_peer (void *cls, const struct GNUNET_HashCode * key, void *value) 5698shutdown_peer (void *cls, const struct GNUNET_HashCode * key, void *value)
5702{ 5699{
5703 struct MeshPeerInfo *p = value; 5700 struct MeshPeer *p = value;
5704 struct MeshPeerQueue *q; 5701 struct MeshPeerQueue *q;
5705 struct MeshPeerQueue *n; 5702 struct MeshPeerQueue *n;
5706 5703
@@ -5714,7 +5711,7 @@ shutdown_peer (void *cls, const struct GNUNET_HashCode * key, void *value)
5714 } 5711 }
5715 q = n; 5712 q = n;
5716 } 5713 }
5717 peer_info_destroy (p); 5714 peer_destroy (p);
5718 return GNUNET_YES; 5715 return GNUNET_YES;
5719} 5716}
5720 5717