aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_tunnel_tree.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-13 13:44:18 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-13 13:44:18 +0000
commit2e9731ebda48bf2549aed64ca9cdfea5b298f9d7 (patch)
tree299c800975b74b4036dcda3168c352799e7c89e2 /src/mesh/mesh_tunnel_tree.c
parent8c61ac28c875a62ed8f3a51bfbd7359fdd581d0b (diff)
downloadgnunet-2e9731ebda48bf2549aed64ca9cdfea5b298f9d7.tar.gz
gnunet-2e9731ebda48bf2549aed64ca9cdfea5b298f9d7.zip
Extended testcase, fixed bugs in client -> service data traffic handling
Diffstat (limited to 'src/mesh/mesh_tunnel_tree.c')
-rw-r--r--src/mesh/mesh_tunnel_tree.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c
index 7ad5bfbd7..b2c03247e 100644
--- a/src/mesh/mesh_tunnel_tree.c
+++ b/src/mesh/mesh_tunnel_tree.c
@@ -336,7 +336,7 @@ tree_mark_peers_disconnected (struct MeshTunnelTree *tree,
336 * @param hop If known, ID of the first hop. 336 * @param hop If known, ID of the first hop.
337 * If not known, NULL to find out and pass on children. 337 * If not known, NULL to find out and pass on children.
338 */ 338 */
339static void 339void
340tree_update_first_hops (struct MeshTunnelTree *tree, 340tree_update_first_hops (struct MeshTunnelTree *tree,
341 struct MeshTunnelTreeNode *parent, 341 struct MeshTunnelTreeNode *parent,
342 struct GNUNET_PeerIdentity *hop) 342 struct GNUNET_PeerIdentity *hop)
@@ -486,6 +486,7 @@ tree_get_path_to_peer(struct MeshTunnelTree *t, GNUNET_PEER_Id peer)
486} 486}
487 487
488 488
489
489/** 490/**
490 * Integrate a stand alone path into the tunnel tree. 491 * Integrate a stand alone path into the tunnel tree.
491 * If the peer toward which the new path is already in the tree, the peer 492 * If the peer toward which the new path is already in the tree, the peer
@@ -516,7 +517,6 @@ tree_add_path (struct MeshTunnelTree *t,
516 struct MeshTunnelTreeNode *n; 517 struct MeshTunnelTreeNode *n;
517 struct MeshTunnelTreeNode *c; 518 struct MeshTunnelTreeNode *c;
518 struct GNUNET_PeerIdentity id; 519 struct GNUNET_PeerIdentity id;
519 struct GNUNET_PeerIdentity *hop;
520 GNUNET_PEER_Id myid; 520 GNUNET_PEER_Id myid;
521 int me; 521 int me;
522 unsigned int i; 522 unsigned int i;
@@ -604,20 +604,12 @@ tree_add_path (struct MeshTunnelTree *t,
604 n->status = MESH_PEER_SEARCHING; 604 n->status = MESH_PEER_SEARCHING;
605 605
606 /* Add info about first hop into hashmap. */ 606 /* Add info about first hop into hashmap. */
607 if (me < p->length - 1) 607 if (-1 != me && me < p->length - 1)
608 { 608 {
609 GNUNET_PEER_resolve (p->peers[p->length - 1], &id); 609 GNUNET_PEER_resolve (p->peers[me + 1], &id);
610 hop = GNUNET_CONTAINER_multihashmap_get(t->first_hops, &id.hashPubKey); 610 tree_update_first_hops(t,
611 if (NULL != hop) 611 tree_find_peer(t->root, p->peers[p->length - 1]),
612 { 612 &id);
613 GNUNET_CONTAINER_multihashmap_remove_all(t->first_hops, &id.hashPubKey);
614 GNUNET_free(hop);
615 }
616 hop = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
617 GNUNET_PEER_resolve (p->peers[me + 1], hop);
618 GNUNET_CONTAINER_multihashmap_put (t->first_hops, &id.hashPubKey,
619 hop,
620 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
621 } 613 }
622 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "tree: New node added.\n"); 614 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "tree: New node added.\n");
623 return GNUNET_OK; 615 return GNUNET_OK;