diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-11 17:22:27 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-11 17:22:27 +0000 |
commit | ac4befb8c44d653f60924a088f5c6ffd671e13f6 (patch) | |
tree | b0447adbee9978ee7f30a5faeb3ac775e9a2f9f4 /src/mesh/gnunet-service-mesh.c | |
parent | 06ca63e03b0d8fd77673b3e759aab65dc5e0f3da (diff) | |
download | gnunet-ac4befb8c44d653f60924a088f5c6ffd671e13f6.tar.gz gnunet-ac4befb8c44d653f60924a088f5c6ffd671e13f6.zip |
Fixes in path creation
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 3806e5f8f..dfec4157f 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1235,12 +1235,14 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *get_path, | |||
1235 | } | 1235 | } |
1236 | } | 1236 | } |
1237 | #if MESH_DEBUG | 1237 | #if MESH_DEBUG |
1238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1238 | if (get_path_length > 0) |
1239 | "MESH: (first of GET: %s)\n", | 1239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1240 | GNUNET_h2s_full(&get_path[0].hashPubKey)); | 1240 | "MESH: (first of GET: %s)\n", |
1241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1241 | GNUNET_h2s_full(&get_path[0].hashPubKey)); |
1242 | "MESH: (first of PUT: %s)\n", | 1242 | if (put_path_length > 0) |
1243 | GNUNET_h2s_full(&put_path[0].hashPubKey)); | 1243 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1244 | "MESH: (first of PUT: %s)\n", | ||
1245 | GNUNET_h2s_full(&put_path[0].hashPubKey)); | ||
1244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1245 | "MESH: In total: %d hops\n", | 1247 | "MESH: In total: %d hops\n", |
1246 | p->length); | 1248 | p->length); |
@@ -1412,8 +1414,6 @@ tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
1412 | * Add a path to a tunnel which we don't own, just to remember the next hop. | 1414 | * 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 | 1415 | * If destination node was already in the tunnel, the first hop information |
1414 | * will be replaced with the new path. | 1416 | * 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. | ||
1417 | * | 1417 | * |
1418 | * @param t Tunnel we want to add a new peer to | 1418 | * @param t Tunnel we want to add a new peer to |
1419 | * @param p Path to add | 1419 | * @param p Path to add |
@@ -1425,20 +1425,8 @@ tunnel_add_path (struct MeshTunnel *t, | |||
1425 | struct MeshPeerPath *p, | 1425 | struct MeshPeerPath *p, |
1426 | unsigned int own_pos) | 1426 | unsigned int own_pos) |
1427 | { | 1427 | { |
1428 | struct GNUNET_PeerIdentity id; | 1428 | GNUNET_assert (0 != own_pos); |
1429 | struct GNUNET_PeerIdentity *hop; | 1429 | tree_add_path(t->tree, p, NULL); |
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); | ||
1442 | } | 1430 | } |
1443 | 1431 | ||
1444 | 1432 | ||
@@ -1963,6 +1951,8 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1963 | /* FIXME error. destroy tunnel? leave for timeout? */ | 1951 | /* FIXME error. destroy tunnel? leave for timeout? */ |
1964 | return 0; | 1952 | return 0; |
1965 | } | 1953 | } |
1954 | tunnel_add_path (t, path, own_pos); | ||
1955 | t->tree->me = tree_find_peer(t->tree->root, myid); | ||
1966 | if (own_pos == size - 1) | 1956 | if (own_pos == size - 1) |
1967 | { | 1957 | { |
1968 | /* It is for us! Send ack. */ | 1958 | /* It is for us! Send ack. */ |
@@ -1972,7 +1962,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1972 | 1962 | ||
1973 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1963 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1974 | "MESH: It's for us!\n"); | 1964 | "MESH: It's for us!\n"); |
1975 | path_add_to_origin (orig_peer_info, path); /* inverts path! */ | 1965 | path_add_to_origin (orig_peer_info, path); |
1976 | info = GNUNET_malloc (sizeof (struct MeshDataDescriptor)); | 1966 | info = GNUNET_malloc (sizeof (struct MeshDataDescriptor)); |
1977 | info->origin = &t->id; | 1967 | info->origin = &t->id; |
1978 | info->peer = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 1968 | info->peer = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
@@ -1986,6 +1976,8 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1986 | } | 1976 | } |
1987 | } | 1977 | } |
1988 | info->handler_n = j; | 1978 | info->handler_n = j; |
1979 | info->peer->types[j] = GNUNET_MESSAGE_TYPE_MESH_PATH_ACK; | ||
1980 | info->peer->infos[j] = info; | ||
1989 | info->peer->core_transmit[j] = | 1981 | info->peer->core_transmit[j] = |
1990 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 100, | 1982 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 100, |
1991 | GNUNET_TIME_UNIT_FOREVER_REL, peer, | 1983 | GNUNET_TIME_UNIT_FOREVER_REL, peer, |
@@ -2001,12 +1993,11 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2001 | { | 1993 | { |
2002 | struct MeshPeerPath *path2; | 1994 | struct MeshPeerPath *path2; |
2003 | 1995 | ||
2004 | path2 = path_duplicate(path); | ||
2005 | /* It's for somebody else! Retransmit. */ | 1996 | /* It's for somebody else! Retransmit. */ |
1997 | path2 = path_duplicate(path); | ||
2006 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1998 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2007 | "MESH: Retransmitting.\n"); | 1999 | "MESH: Retransmitting.\n"); |
2008 | path_add_to_peer(dest_peer_info, path); | 2000 | path_add_to_peer(dest_peer_info, path); |
2009 | tunnel_add_path (t, path, own_pos); | ||
2010 | path = path_duplicate(path2); | 2001 | path = path_duplicate(path2); |
2011 | path_add_to_origin(orig_peer_info, path2); | 2002 | path_add_to_origin(orig_peer_info, path2); |
2012 | send_create_path(dest_peer_info, path, t); | 2003 | send_create_path(dest_peer_info, path, t); |