diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-07-25 13:11:49 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-07-25 13:11:49 +0000 |
commit | 49f7cc3810db46c500de524e3227d04b47adc8e3 (patch) | |
tree | f17976aab26614c4fd4c32bf02f73c906888e744 /src/mesh | |
parent | 041d28b2992949d0062f2ae84478a3f6c0a46ec3 (diff) | |
download | gnunet-49f7cc3810db46c500de524e3227d04b47adc8e3.tar.gz gnunet-49f7cc3810db46c500de524e3227d04b47adc8e3.zip |
- wip
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh-enc.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index 7e76a5216..10378205b 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c | |||
@@ -1367,12 +1367,11 @@ send_connection_ack (struct MeshTunnel2 *t, struct MeshConnection *connection) | |||
1367 | /** | 1367 | /** |
1368 | * Build an ACK message and queue it to send to the given peer. | 1368 | * Build an ACK message and queue it to send to the given peer. |
1369 | * | 1369 | * |
1370 | * @param t Tunnel on which to send the ACK. | ||
1371 | * @param peer Peer to whom send the ACK. | 1370 | * @param peer Peer to whom send the ACK. |
1372 | * @param ack Value of the ACK. | 1371 | * @param ack Value of the ACK. |
1373 | */ | 1372 | */ |
1374 | static void | 1373 | static void |
1375 | send_ack (struct MeshTunnel *t, GNUNET_PEER_Id peer, uint32_t ack) | 1374 | send_ack (GNUNET_PEER_Id peer, uint32_t ack) |
1376 | { | 1375 | { |
1377 | struct GNUNET_MESH_ACK msg; | 1376 | struct GNUNET_MESH_ACK msg; |
1378 | 1377 | ||
@@ -1380,9 +1379,8 @@ send_ack (struct MeshTunnel *t, GNUNET_PEER_Id peer, uint32_t ack) | |||
1380 | msg.header.size = htons (sizeof (msg)); | 1379 | msg.header.size = htons (sizeof (msg)); |
1381 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_ACK); | 1380 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_ACK); |
1382 | msg.pid = htonl (ack); | 1381 | msg.pid = htonl (ack); |
1383 | msg.tid = htonl (t->id.tid); | ||
1384 | 1382 | ||
1385 | send_prebuilt_message (&msg.header, peer, t); | 1383 | send_prebuilt_message (&msg.header, peer, NULL); |
1386 | } | 1384 | } |
1387 | 1385 | ||
1388 | 1386 | ||
@@ -1677,7 +1675,6 @@ peer_get_path_cost (const struct MeshPeer *peer, | |||
1677 | * Choose the best path towards a peer considering the tunnel properties. | 1675 | * Choose the best path towards a peer considering the tunnel properties. |
1678 | * | 1676 | * |
1679 | * @param peer The destination peer. | 1677 | * @param peer The destination peer. |
1680 | * @param t The tunnel the path is for. | ||
1681 | * | 1678 | * |
1682 | * @return Best current known path towards the peer, if any. | 1679 | * @return Best current known path towards the peer, if any. |
1683 | */ | 1680 | */ |
@@ -1686,19 +1683,24 @@ peer_get_best_path (const struct MeshPeer *peer) | |||
1686 | { | 1683 | { |
1687 | struct MeshPeerPath *best_p; | 1684 | struct MeshPeerPath *best_p; |
1688 | struct MeshPeerPath *p; | 1685 | struct MeshPeerPath *p; |
1686 | struct MeshConnection *c; | ||
1689 | unsigned int best_cost; | 1687 | unsigned int best_cost; |
1690 | unsigned int cost; | 1688 | unsigned int cost; |
1691 | 1689 | ||
1692 | best_p = p = peer->path_head; | 1690 | best_cost = UINT_MAX; |
1693 | best_cost = cost = peer_get_path_cost (peer, p); | 1691 | best_p = NULL; |
1694 | while (NULL != p) | 1692 | for (p = peer->path_head; NULL != p; p = p->next) |
1695 | { | 1693 | { |
1694 | for (c = peer->tunnel->connection_head; NULL != c; c = c->next) | ||
1695 | if (c->path == p) | ||
1696 | break; | ||
1697 | if (NULL != p) | ||
1698 | continue; | ||
1696 | if ((cost = peer_get_path_cost (peer, p)) < best_cost) | 1699 | if ((cost = peer_get_path_cost (peer, p)) < best_cost) |
1697 | { | 1700 | { |
1698 | best_cost = cost; | 1701 | best_cost = cost; |
1699 | best_p = p; | 1702 | best_p = p; |
1700 | } | 1703 | } |
1701 | p = p->next; | ||
1702 | } | 1704 | } |
1703 | return best_p; | 1705 | return best_p; |
1704 | } | 1706 | } |
@@ -1710,19 +1712,23 @@ peer_get_best_path (const struct MeshPeer *peer) | |||
1710 | * If the peer already has some path, send a CREATE CONNECTION towards it. | 1712 | * If the peer already has some path, send a CREATE CONNECTION towards it. |
1711 | * | 1713 | * |
1712 | * @param peer PeerInfo of the peer. | 1714 | * @param peer PeerInfo of the peer. |
1713 | * @param t Tunnel for which to create the path, if possible. | ||
1714 | */ | 1715 | */ |
1715 | static void | 1716 | static void |
1716 | peer_connect (struct MeshPeer *peer, struct MeshTunnel2 *t) | 1717 | peer_connect (struct MeshPeer *peer) |
1717 | { | 1718 | { |
1719 | struct MeshTunnel2 *t; | ||
1718 | struct MeshPeerPath *p; | 1720 | struct MeshPeerPath *p; |
1719 | struct MeshConnection *c; | 1721 | struct MeshConnection *c; |
1720 | 1722 | ||
1723 | t = peer->tunnel; | ||
1721 | if (NULL != peer->path_head) | 1724 | if (NULL != peer->path_head) |
1722 | { | 1725 | { |
1723 | p = peer_get_best_path (peer, t); | 1726 | p = peer_get_best_path (peer); |
1724 | c = tunnel_use_path (t, p); | 1727 | if (NULL != p) |
1725 | send_connection_create (t, c); | 1728 | { |
1729 | c = tunnel_use_path (t, p); | ||
1730 | send_connection_create (t, c); | ||
1731 | } | ||
1726 | } | 1732 | } |
1727 | else if (NULL == peer->dhtget) | 1733 | else if (NULL == peer->dhtget) |
1728 | { | 1734 | { |
@@ -4934,22 +4940,12 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
4934 | put_path, put_path_length); | 4940 | put_path, put_path_length); |
4935 | path_add_to_peers (p, GNUNET_NO); | 4941 | path_add_to_peers (p, GNUNET_NO); |
4936 | path_destroy (p); | 4942 | path_destroy (p); |
4937 | for (i = 0; i < peer->ntunnels; i++) | 4943 | |
4944 | if (peer->tunnel->state == MESH_TUNNEL_SEARCHING) | ||
4938 | { | 4945 | { |
4939 | struct GNUNET_PeerIdentity id; | 4946 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); |
4940 | 4947 | peer_connect (peer); | |
4941 | GNUNET_PEER_resolve (peer->tunnels[i]->id.oid, &id); | ||
4942 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ... tunnel %s:%X (%X / %X)\n", | ||
4943 | GNUNET_i2s (&id), peer->tunnels[i]->id.tid, | ||
4944 | peer->tunnels[i]->local_tid, | ||
4945 | peer->tunnels[i]->local_tid_dest); | ||
4946 | if (peer->tunnels[i]->state == MESH_TUNNEL_SEARCHING) | ||
4947 | { | ||
4948 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); | ||
4949 | peer_connect (peer, peer->tunnels[i]); | ||
4950 | } | ||
4951 | } | 4948 | } |
4952 | |||
4953 | return; | 4949 | return; |
4954 | } | 4950 | } |
4955 | 4951 | ||