aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-31 17:52:40 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-31 17:52:40 +0000
commiteb38b6484f13b1ab98f2fb62665d5eb2cf3c5b8b (patch)
treeceb6e90a06c26fe5ec6261d6081ce54857d75506 /src/mesh
parentcd885f7b532d11a9de8dcbb2ca4fb007e4e53643 (diff)
downloadgnunet-eb38b6484f13b1ab98f2fb62665d5eb2cf3c5b8b.tar.gz
gnunet-eb38b6484f13b1ab98f2fb62665d5eb2cf3c5b8b.zip
Direct paths can only come from CORE, ignore other sources about paths with l <= 2
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 0a481d6e9..6608b49dc 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1513,11 +1513,12 @@ path_remove_from_peer (struct MeshPeerInfo *peer,
1513 * @param peer_info Destination peer to add the path to. 1513 * @param peer_info Destination peer to add the path to.
1514 * @param path New path to add. Last peer must be the peer in arg 1. 1514 * @param path New path to add. Last peer must be the peer in arg 1.
1515 * Path will be either used of freed if already known. 1515 * Path will be either used of freed if already known.
1516 * 1516 * @param trusted Do we trust that this path is real?
1517 * TODO: trim the part from origin to us? Add it as path to origin?
1518 */ 1517 */
1519void 1518void
1520path_add_to_peer (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) 1519path_add_to_peer (struct MeshPeerInfo *peer_info,
1520 struct MeshPeerPath *path,
1521 int trusted)
1521{ 1522{
1522 struct MeshPeerPath *aux; 1523 struct MeshPeerPath *aux;
1523 unsigned int l; 1524 unsigned int l;
@@ -1529,6 +1530,11 @@ path_add_to_peer (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path)
1529 path_destroy (path); 1530 path_destroy (path);
1530 return; 1531 return;
1531 } 1532 }
1533 if (path->length <= 2 && GNUNET_NO == trusted)
1534 {
1535 /* Only allow CORE to tell us about direct paths */
1536 return;
1537 }
1532 for (l = 1; l < path->length; l++) 1538 for (l = 1; l < path->length; l++)
1533 { 1539 {
1534 if (path->peers[l] == myid) 1540 if (path->peers[l] == myid)
@@ -1599,12 +1605,15 @@ path_add_to_peer (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path)
1599 * 1605 *
1600 * @param peer_info Peer to add the path to, being the origin of the path. 1606 * @param peer_info Peer to add the path to, being the origin of the path.
1601 * @param path New path to add after being inversed. 1607 * @param path New path to add after being inversed.
1608 * @param trusted Do we trust that this path is real?
1602 */ 1609 */
1603static void 1610static void
1604path_add_to_origin (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) 1611path_add_to_origin (struct MeshPeerInfo *peer_info,
1612 struct MeshPeerPath *path,
1613 int trusted)
1605{ 1614{
1606 path_invert(path); 1615 path_invert(path);
1607 path_add_to_peer (peer_info, path); 1616 path_add_to_peer (peer_info, path, trusted);
1608} 1617}
1609 1618
1610 1619
@@ -2568,7 +2577,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
2568 2577
2569 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2570 "MESH: It's for us!\n"); 2579 "MESH: It's for us!\n");
2571 path_add_to_origin (orig_peer_info, path); 2580 path_add_to_origin (orig_peer_info, path, GNUNET_NO);
2572 if (NULL == t->peers) 2581 if (NULL == t->peers)
2573 t->peers = GNUNET_CONTAINER_multihashmap_create(4); 2582 t->peers = GNUNET_CONTAINER_multihashmap_create(4);
2574 GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put ( 2583 GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (
@@ -2603,9 +2612,9 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
2603 path2 = path_duplicate(path); 2612 path2 = path_duplicate(path);
2604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2613 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2605 "MESH: Retransmitting.\n"); 2614 "MESH: Retransmitting.\n");
2606 path_add_to_peer(dest_peer_info, path); 2615 path_add_to_peer(dest_peer_info, path, GNUNET_NO);
2607 path = path_duplicate(path2); 2616 path = path_duplicate(path2);
2608 path_add_to_origin(orig_peer_info, path2); 2617 path_add_to_origin(orig_peer_info, path2, GNUNET_NO);
2609 send_create_path(dest_peer_info, path, t); 2618 send_create_path(dest_peer_info, path, t);
2610 } 2619 }
2611 return GNUNET_OK; 2620 return GNUNET_OK;
@@ -3241,7 +3250,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
3241 3250
3242 p = path_build_from_dht (get_path, get_path_length, 3251 p = path_build_from_dht (get_path, get_path_length,
3243 put_path, put_path_length); 3252 put_path, put_path_length);
3244 path_add_to_peer (path_info->peer, p); 3253 path_add_to_peer (path_info->peer, p, GNUNET_NO);
3245 for (i = 0; i < path_info->peer->ntunnels; i++) 3254 for (i = 0; i < path_info->peer->ntunnels; i++)
3246 { 3255 {
3247 tunnel_add_peer (path_info->peer->tunnels[i], path_info->peer); 3256 tunnel_add_peer (path_info->peer->tunnels[i], path_info->peer);
@@ -3295,7 +3304,7 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
3295 3304
3296 p = path_build_from_dht (get_path, get_path_length, 3305 p = path_build_from_dht (get_path, get_path_length,
3297 put_path, put_path_length); 3306 put_path, put_path_length);
3298 path_add_to_peer (peer_info, p); 3307 path_add_to_peer (peer_info, p, GNUNET_NO);
3299 tunnel_add_peer(t, peer_info); 3308 tunnel_add_peer(t, peer_info);
3300 peer_info_connect (peer_info, t); 3309 peer_info_connect (peer_info, t);
3301} 3310}
@@ -4205,7 +4214,7 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
4205 path->peers[1] = peer_info->id; 4214 path->peers[1] = peer_info->id;
4206 GNUNET_PEER_change_rc(myid, 1); 4215 GNUNET_PEER_change_rc(myid, 1);
4207 GNUNET_PEER_change_rc(peer_info->id, 1); 4216 GNUNET_PEER_change_rc(peer_info->id, 1);
4208 path_add_to_peer (peer_info, path); 4217 path_add_to_peer (peer_info, path, GNUNET_YES);
4209 return; 4218 return;
4210} 4219}
4211 4220
@@ -4423,7 +4432,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
4423 peer = peer_info_get(&my_full_id); 4432 peer = peer_info_get(&my_full_id);
4424 p = path_new (1); 4433 p = path_new (1);
4425 p->peers[0] = myid; 4434 p->peers[0] = myid;
4426 path_add_to_peer(peer, p); 4435 path_add_to_peer(peer, p, GNUNET_YES);
4427 4436
4428 /* Scheduled the task to clean up when shutdown is called */ 4437 /* Scheduled the task to clean up when shutdown is called */
4429 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 4438 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,