diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-11 11:23:26 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-11 11:23:26 +0000 |
commit | f1c214bd601c73062a5086dc85caa162f83119d8 (patch) | |
tree | 818662d48a7aa9be95af1d5085c8bbbf9bdeb1fe /src/mesh | |
parent | 27dc0bfe8529724621ad29c07ca9f17e6be03918 (diff) | |
download | gnunet-f1c214bd601c73062a5086dc85caa162f83119d8.tar.gz gnunet-f1c214bd601c73062a5086dc85caa162f83119d8.zip |
Added mangaement of tunnels and paths by intermadiate nodes
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 1f29e6c78..3806e5f8f 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1409,15 +1409,36 @@ tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | /** | 1411 | /** |
1412 | * Add a path to a tunnel, without evaluating costs. | 1412 | * Add a path to a tunnel which we don't own, just to remember the next hop. |
1413 | * If destination node was already in the tunnel, the first hop information | ||
1414 | * will be replaced with the new path. | ||
1415 | * The local node shouldn't be the first or last node in the path, just an | ||
1416 | * intermediate hop. | ||
1413 | * | 1417 | * |
1414 | * @param t Tunnel we want to add a new peer to | 1418 | * @param t Tunnel we want to add a new peer to |
1415 | * @param p Path to add | 1419 | * @param p Path to add |
1420 | * @param own_pos Position of local node in path. | ||
1416 | * | 1421 | * |
1417 | */ | 1422 | */ |
1418 | static void | 1423 | static void |
1419 | tunnel_add_path (struct MeshTunnel *t, struct MeshPeerPath *p) | 1424 | tunnel_add_path (struct MeshTunnel *t, |
1425 | struct MeshPeerPath *p, | ||
1426 | unsigned int own_pos) | ||
1420 | { | 1427 | { |
1428 | struct GNUNET_PeerIdentity id; | ||
1429 | struct GNUNET_PeerIdentity *hop; | ||
1430 | |||
1431 | GNUNET_assert (own_pos < p->length - 1); | ||
1432 | hop = GNUNET_CONTAINER_multihashmap_get (t->tree->first_hops, &id.hashPubKey); | ||
1433 | if (NULL == hop) | ||
1434 | hop = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)); | ||
1435 | GNUNET_PEER_resolve(p->peers[own_pos + 1], hop); | ||
1436 | GNUNET_PEER_resolve(p->peers[p->length - 1], &id); | ||
1437 | GNUNET_CONTAINER_multihashmap_put( | ||
1438 | t->tree->first_hops, | ||
1439 | &id.hashPubKey, | ||
1440 | hop, | ||
1441 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
1421 | } | 1442 | } |
1422 | 1443 | ||
1423 | 1444 | ||
@@ -1985,7 +2006,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2006 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1986 | "MESH: Retransmitting.\n"); | 2007 | "MESH: Retransmitting.\n"); |
1987 | path_add_to_peer(dest_peer_info, path); | 2008 | path_add_to_peer(dest_peer_info, path); |
1988 | tunnel_add_path (t, path); | 2009 | tunnel_add_path (t, path, own_pos); |
1989 | path = path_duplicate(path2); | 2010 | path = path_duplicate(path2); |
1990 | path_add_to_origin(orig_peer_info, path2); | 2011 | path_add_to_origin(orig_peer_info, path2); |
1991 | send_create_path(dest_peer_info, path, t); | 2012 | send_create_path(dest_peer_info, path, t); |