diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-10 16:26:15 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-10 16:26:15 +0000 |
commit | 0b3a3d3f528101f53a5e3a1fad81dc9b6f62cd3c (patch) | |
tree | e0db21f05cc684d8b09cf96a939ee65982976ad4 /src/mesh/mesh_tunnel_tree.c | |
parent | c7b454f407512be4f8ae85962e332b3a1d026c09 (diff) | |
download | gnunet-0b3a3d3f528101f53a5e3a1fad81dc9b6f62cd3c.tar.gz gnunet-0b3a3d3f528101f53a5e3a1fad81dc9b6f62cd3c.zip |
Fixed bugs, refactored path tree
Diffstat (limited to 'src/mesh/mesh_tunnel_tree.c')
-rw-r--r-- | src/mesh/mesh_tunnel_tree.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c index da16bc95b..56f592de5 100644 --- a/src/mesh/mesh_tunnel_tree.c +++ b/src/mesh/mesh_tunnel_tree.c | |||
@@ -70,6 +70,24 @@ path_invert (struct MeshPeerPath *path) | |||
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | /** | ||
74 | * Duplicate a path, incrementing short peer's rc. | ||
75 | * | ||
76 | * @param p The path to duplicate. | ||
77 | */ | ||
78 | struct MeshPeerPath * | ||
79 | path_duplicate (struct MeshPeerPath *path) | ||
80 | { | ||
81 | struct MeshPeerPath *aux; | ||
82 | unsigned int i; | ||
83 | |||
84 | aux = path_new(path->length); | ||
85 | memcpy (aux->peers, path->peers, path->length * sizeof(GNUNET_PEER_Id)); | ||
86 | for (i = 0; i < path->length; i++) | ||
87 | GNUNET_PEER_change_rc(path->peers[i], 1); | ||
88 | return aux; | ||
89 | } | ||
90 | |||
73 | 91 | ||
74 | /** | 92 | /** |
75 | * Find the first peer whom to send a packet to go down this path | 93 | * Find the first peer whom to send a packet to go down this path |
@@ -499,7 +517,7 @@ tree_add_path (struct MeshTunnelTree *t, | |||
499 | struct MeshTunnelTreeNode *c; | 517 | struct MeshTunnelTreeNode *c; |
500 | struct GNUNET_PeerIdentity id; | 518 | struct GNUNET_PeerIdentity id; |
501 | struct GNUNET_PeerIdentity *hop; | 519 | struct GNUNET_PeerIdentity *hop; |
502 | GNUNET_PEER_Id myid = t->me->peer; | 520 | GNUNET_PEER_Id myid; |
503 | int me; | 521 | int me; |
504 | unsigned int i; | 522 | unsigned int i; |
505 | 523 | ||
@@ -508,6 +526,9 @@ tree_add_path (struct MeshTunnelTree *t, | |||
508 | p->length, | 526 | p->length, |
509 | p->peers[p->length - 1], | 527 | p->peers[p->length - 1], |
510 | t->me->peer); | 528 | t->me->peer); |
529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %p %p %p\n", t, t->root, t->me); | ||
530 | |||
531 | myid = t->me->peer; | ||
511 | GNUNET_assert(0 != p->length); | 532 | GNUNET_assert(0 != p->length); |
512 | parent = n = t->root; | 533 | parent = n = t->root; |
513 | if (n->peer != p->peers[0]) | 534 | if (n->peer != p->peers[0]) |