aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-11 17:22:27 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-11 17:22:27 +0000
commitac4befb8c44d653f60924a088f5c6ffd671e13f6 (patch)
treeb0447adbee9978ee7f30a5faeb3ac775e9a2f9f4 /src/mesh
parent06ca63e03b0d8fd77673b3e759aab65dc5e0f3da (diff)
downloadgnunet-ac4befb8c44d653f60924a088f5c6ffd671e13f6.tar.gz
gnunet-ac4befb8c44d653f60924a088f5c6ffd671e13f6.zip
Fixes in path creation
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c41
-rw-r--r--src/mesh/mesh_tunnel_tree.c20
-rw-r--r--src/mesh/test_mesh_small.conf4
3 files changed, 26 insertions, 39 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);
diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c
index cea028670..7ad5bfbd7 100644
--- a/src/mesh/mesh_tunnel_tree.c
+++ b/src/mesh/mesh_tunnel_tree.c
@@ -313,7 +313,7 @@ tree_mark_peers_disconnected (struct MeshTunnelTree *tree,
313 { 313 {
314 tree_mark_peers_disconnected (tree, n, cb); 314 tree_mark_peers_disconnected (tree, n, cb);
315 } 315 }
316 if (MESH_PEER_READY == parent->status) 316 if (MESH_PEER_READY == parent->status && NULL != cb)
317 { 317 {
318 cb (parent); 318 cb (parent);
319 } 319 }
@@ -420,7 +420,7 @@ tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer_id,
420 return n; 420 return n;
421 } 421 }
422 } 422 }
423 n = tree_find_peer (t->me, peer_id); 423 n = tree_find_peer (t->root, peer_id);
424 if (NULL == n) 424 if (NULL == n)
425 return NULL; 425 return NULL;
426 node = n; 426 node = n;
@@ -522,12 +522,14 @@ tree_add_path (struct MeshTunnelTree *t,
522 unsigned int i; 522 unsigned int i;
523 523
524 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 524 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
525 "tree: Adding path [%u] towards peer %u to peer %u.\n", 525 "tree: Adding path [%u] towards peer %u.\n",
526 p->length, 526 p->length,
527 p->peers[p->length - 1], 527 p->peers[p->length - 1]);
528 t->me->peer);
529 528
530 myid = t->me->peer; 529 if (NULL != t->me)
530 myid = t->me->peer;
531 else
532 myid = 0;
531 GNUNET_assert(0 != p->length); 533 GNUNET_assert(0 != p->length);
532 parent = n = t->root; 534 parent = n = t->root;
533 if (n->peer != p->peers[0]) 535 if (n->peer != p->peers[0])
@@ -571,12 +573,6 @@ tree_add_path (struct MeshTunnelTree *t,
571 } 573 }
572 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 574 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
573 "tree: All childen visited.\n"); 575 "tree: All childen visited.\n");
574 if (-1 == me)
575 {
576 /* New path deviates from tree before reaching us. What happened? */
577 GNUNET_break (0);
578 return GNUNET_SYSERR;
579 }
580 /* Add the rest of the path as a branch from parent. */ 576 /* Add the rest of the path as a branch from parent. */
581 while (i < p->length) 577 while (i < p->length)
582 { 578 {
diff --git a/src/mesh/test_mesh_small.conf b/src/mesh/test_mesh_small.conf
index 833fab062..304d5ca10 100644
--- a/src/mesh/test_mesh_small.conf
+++ b/src/mesh/test_mesh_small.conf
@@ -62,8 +62,8 @@ NUM_PEERS = 16
62WEAKRANDOM = YES 62WEAKRANDOM = YES
63TOPOLOGY = 2D_TORUS 63TOPOLOGY = 2D_TORUS
64CONNECT_TOPOLOGY = NONE 64CONNECT_TOPOLOGY = NONE
65TOPOLOGY_FILE = small.dat 65#TOPOLOGY_FILE = small.dat
66#CONNECT_TOPOLOGY = ERDOS_RENYI 66CONNECT_TOPOLOGY = 2D_TORUS
67#CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM 67#CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM
68#CONNECT_TOPOLOGY_OPTION_MODIFIER = 25 68#CONNECT_TOPOLOGY_OPTION_MODIFIER = 25
69#PERCENTAGE = 3 69#PERCENTAGE = 3