diff options
Diffstat (limited to 'src/mesh/gnunet-service-mesh_connection.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 0d7dfc5f0..7c3cb08bb 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include "gnunet-service-mesh_connection.h" | 32 | #include "gnunet-service-mesh_connection.h" |
33 | #include "gnunet-service-mesh_peer.h" | 33 | #include "gnunet-service-mesh_peer.h" |
34 | #include "gnunet-service-mesh_tunnel.h" | ||
34 | #include "mesh_protocol_enc.h" | 35 | #include "mesh_protocol_enc.h" |
35 | #include "mesh_path.h" | 36 | #include "mesh_path.h" |
36 | 37 | ||
@@ -314,7 +315,6 @@ GMC_state2s (enum MeshConnectionState s) | |||
314 | } | 315 | } |
315 | 316 | ||
316 | 317 | ||
317 | |||
318 | /** | 318 | /** |
319 | * Initialize a Flow Control structure to the initial state. | 319 | * Initialize a Flow Control structure to the initial state. |
320 | * | 320 | * |
@@ -726,8 +726,6 @@ connection_cancel_queues (struct MeshConnection *c, int fwd) | |||
726 | } | 726 | } |
727 | 727 | ||
728 | 728 | ||
729 | |||
730 | |||
731 | /** | 729 | /** |
732 | * Function called if a connection has been stalled for a while, | 730 | * Function called if a connection has been stalled for a while, |
733 | * possibly due to a missed ACK. Poll the neighbor about its ACK status. | 731 | * possibly due to a missed ACK. Poll the neighbor about its ACK status. |
@@ -951,6 +949,23 @@ register_neighbors (struct MeshConnection *c) | |||
951 | } | 949 | } |
952 | 950 | ||
953 | 951 | ||
952 | /** | ||
953 | * | ||
954 | */ | ||
955 | static void | ||
956 | unregister_neighbors (struct MeshConnection *c) | ||
957 | { | ||
958 | struct MeshPeer *peer; | ||
959 | |||
960 | peer = connection_get_next_hop (c); | ||
961 | GMP_remove_connection (peer, c); | ||
962 | |||
963 | peer = connection_get_prev_hop (c); | ||
964 | GMP_remove_connection (peer, c); | ||
965 | |||
966 | } | ||
967 | |||
968 | |||
954 | /******************************************************************************/ | 969 | /******************************************************************************/ |
955 | /******************************** API ***********************************/ | 970 | /******************************** API ***********************************/ |
956 | /******************************************************************************/ | 971 | /******************************************************************************/ |
@@ -1647,7 +1662,7 @@ GMC_handle_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1647 | return GNUNET_OK; | 1662 | return GNUNET_OK; |
1648 | 1663 | ||
1649 | GNUNET_STATISTICS_update (stats, "# keepalives forwarded", 1, GNUNET_NO); | 1664 | GNUNET_STATISTICS_update (stats, "# keepalives forwarded", 1, GNUNET_NO); |
1650 | send_prebuilt_message_connection (message, c, NULL, fwd); | 1665 | GMC_send_prebuilt_message (message, c, NULL, fwd); |
1651 | 1666 | ||
1652 | return GNUNET_OK; | 1667 | return GNUNET_OK; |
1653 | } | 1668 | } |
@@ -1672,17 +1687,17 @@ send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd) | |||
1672 | if (NULL == c || GMC_is_terminal (c, fwd)) | 1687 | if (NULL == c || GMC_is_terminal (c, fwd)) |
1673 | { | 1688 | { |
1674 | LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from all connections\n"); | 1689 | LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from all connections\n"); |
1675 | buffer = tunnel_get_buffer (NULL == c ? ch->t : c->t, fwd); | 1690 | buffer = GMT_get_buffer (NULL == c ? ch->t : c->t, fwd); |
1676 | } | 1691 | } |
1677 | else | 1692 | else |
1678 | { | 1693 | { |
1679 | LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from one connection\n"); | 1694 | LOG (GNUNET_ERROR_TYPE_DEBUG, " getting from one connection\n"); |
1680 | buffer = connection_get_buffer (c, fwd); | 1695 | buffer = GMC_get_buffer (c, fwd); |
1681 | } | 1696 | } |
1682 | LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer); | 1697 | LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer); |
1683 | 1698 | ||
1684 | if ( (NULL != ch && channel_is_origin (ch, fwd)) || | 1699 | if ( (NULL != ch && GMCH_is_origin (ch, fwd)) || |
1685 | (NULL != c && connection_is_origin (c, fwd)) ) | 1700 | (NULL != c && GMC_is_origin (c, fwd)) ) |
1686 | { | 1701 | { |
1687 | LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n"); | 1702 | LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n"); |
1688 | if (0 < buffer) | 1703 | if (0 < buffer) |
@@ -1763,7 +1778,6 @@ GMC_new (const struct GNUNET_HashCode *cid, | |||
1763 | unsigned int own_pos) | 1778 | unsigned int own_pos) |
1764 | { | 1779 | { |
1765 | struct MeshConnection *c; | 1780 | struct MeshConnection *c; |
1766 | unsigned int own_pos; | ||
1767 | 1781 | ||
1768 | c = GNUNET_new (struct MeshConnection); | 1782 | c = GNUNET_new (struct MeshConnection); |
1769 | c->id = *cid; | 1783 | c->id = *cid; |
@@ -1795,7 +1809,7 @@ GMC_new (const struct GNUNET_HashCode *cid, | |||
1795 | } | 1809 | } |
1796 | 1810 | ||
1797 | 1811 | ||
1798 | static void | 1812 | void |
1799 | GMC_destroy (struct MeshConnection *c) | 1813 | GMC_destroy (struct MeshConnection *c) |
1800 | { | 1814 | { |
1801 | struct MeshPeer *peer; | 1815 | struct MeshPeer *peer; |
@@ -1803,9 +1817,8 @@ GMC_destroy (struct MeshConnection *c) | |||
1803 | if (NULL == c) | 1817 | if (NULL == c) |
1804 | return; | 1818 | return; |
1805 | 1819 | ||
1806 | LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying connection %s[%X]\n", | 1820 | LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying connection %s\n", |
1807 | peer2s (c->t->peer), | 1821 | GNUNET_h2s (&c->id)); |
1808 | c->id); | ||
1809 | 1822 | ||
1810 | /* Cancel all traffic */ | 1823 | /* Cancel all traffic */ |
1811 | connection_cancel_queues (c, GNUNET_YES); | 1824 | connection_cancel_queues (c, GNUNET_YES); |
@@ -1817,17 +1830,12 @@ GMC_destroy (struct MeshConnection *c) | |||
1817 | if (GNUNET_SCHEDULER_NO_TASK != c->bck_maintenance_task) | 1830 | if (GNUNET_SCHEDULER_NO_TASK != c->bck_maintenance_task) |
1818 | GNUNET_SCHEDULER_cancel (c->bck_maintenance_task); | 1831 | GNUNET_SCHEDULER_cancel (c->bck_maintenance_task); |
1819 | 1832 | ||
1820 | /* Deregister from neighbors */ | 1833 | /* Unregister from neighbors */ |
1821 | peer = connection_get_next_hop (c); | 1834 | unregister_neighbors (c); |
1822 | if (NULL != peer && NULL != peer->connections) | ||
1823 | GNUNET_CONTAINER_multihashmap_remove (peer->connections, &c->id, c); | ||
1824 | peer = connection_get_prev_hop (c); | ||
1825 | if (NULL != peer && NULL != peer->connections) | ||
1826 | GNUNET_CONTAINER_multihashmap_remove (peer->connections, &c->id, c); | ||
1827 | 1835 | ||
1828 | /* Delete */ | 1836 | /* Delete */ |
1829 | GNUNET_STATISTICS_update (stats, "# connections", -1, GNUNET_NO); | 1837 | GNUNET_STATISTICS_update (stats, "# connections", -1, GNUNET_NO); |
1830 | GNUNET_CONTAINER_DLL_remove (c->t->connection_head, c->t->connection_tail, c); | 1838 | GMT_remove_connection (c->t, c); |
1831 | GNUNET_free (c); | 1839 | GNUNET_free (c); |
1832 | } | 1840 | } |
1833 | 1841 | ||
@@ -1909,7 +1917,6 @@ GMC_notify_broken (struct MeshConnection *c, | |||
1909 | struct MeshPeer *peer, | 1917 | struct MeshPeer *peer, |
1910 | struct GNUNET_PeerIdentity *my_full_id) | 1918 | struct GNUNET_PeerIdentity *my_full_id) |
1911 | { | 1919 | { |
1912 | struct MeshConnection *c = value; | ||
1913 | struct GNUNET_MESH_ConnectionBroken msg; | 1920 | struct GNUNET_MESH_ConnectionBroken msg; |
1914 | int fwd; | 1921 | int fwd; |
1915 | 1922 | ||
@@ -1920,18 +1927,18 @@ GMC_notify_broken (struct MeshConnection *c, | |||
1920 | { | 1927 | { |
1921 | /* Local shutdown, no one to notify about this. */ | 1928 | /* Local shutdown, no one to notify about this. */ |
1922 | GMC_destroy (c); | 1929 | GMC_destroy (c); |
1923 | return GNUNET_YES; | 1930 | return; |
1924 | } | 1931 | } |
1925 | 1932 | ||
1926 | msg.header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken)); | 1933 | msg.header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken)); |
1927 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN); | 1934 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN); |
1928 | msg.cid = c->id; | 1935 | msg.cid = c->id; |
1929 | msg.peer1 = *my_full_id; | 1936 | msg.peer1 = *my_full_id; |
1930 | msg.peer2 = *GNUNET_PEER_resolve2 (peer->id); | 1937 | msg.peer2 = *GMP_get_id (peer); |
1931 | GMC_send_prebuilt_message (&msg.header, c, NULL, fwd); | 1938 | GMC_send_prebuilt_message (&msg.header, c, NULL, fwd); |
1932 | c->destroy = GNUNET_YES; | 1939 | c->destroy = GNUNET_YES; |
1933 | 1940 | ||
1934 | return GNUNET_YES; | 1941 | return; |
1935 | } | 1942 | } |
1936 | 1943 | ||
1937 | 1944 | ||
@@ -2084,9 +2091,8 @@ GMC_send_destroy (struct MeshConnection *c) | |||
2084 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY);; | 2091 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY);; |
2085 | msg.cid = c->id; | 2092 | msg.cid = c->id; |
2086 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2093 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2087 | " sending connection destroy for connection %s[%X]\n", | 2094 | " sending connection destroy for connection %s\n", |
2088 | peer2s (c->t->peer), | 2095 | GNUNET_h2s (&c->id)); |
2089 | c->id); | ||
2090 | 2096 | ||
2091 | if (GNUNET_NO == GMC_is_terminal (c, GNUNET_YES)) | 2097 | if (GNUNET_NO == GMC_is_terminal (c, GNUNET_YES)) |
2092 | GMC_send_prebuilt_message (&msg.header, c, NULL, GNUNET_YES); | 2098 | GMC_send_prebuilt_message (&msg.header, c, NULL, GNUNET_YES); |