aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-09-26 19:23:55 +0000
committerBart Polot <bart@net.in.tum.de>2011-09-26 19:23:55 +0000
commit461cc5743782469d2ecf8b130c2f359ea741cc13 (patch)
treedd1527e17644f9140b20f5de9ef9f62174f35f3e /src/mesh
parent174554b2727e3057c1a8150974162ff8d9b8a993 (diff)
downloadgnunet-461cc5743782469d2ecf8b130c2f359ea741cc13.tar.gz
gnunet-461cc5743782469d2ecf8b130c2f359ea741cc13.zip
Adapted service API handling to new tree API
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 9fc388517..615da463e 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1105,14 +1105,25 @@ notify_peer_disconnected (const struct MeshTunnelTreeNode *n)
1105void 1105void
1106tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer) 1106tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer)
1107{ 1107{
1108// struct MeshTunnelTreeNode *n;
1108 struct MeshPeerPath *p; 1109 struct MeshPeerPath *p;
1109 struct MeshPeerPath *best_p; 1110 struct MeshPeerPath *best_p;
1110 unsigned int best_cost; 1111 unsigned int best_cost;
1111 unsigned int cost; 1112 unsigned int cost;
1112 1113
1114 if (NULL != tree_find_peer(t->tree->root, peer->id))
1115 {
1116 /* Already have it, nothing to do. */
1117 return;
1118 }
1119
1120 t->peers_total++;
1113 GNUNET_array_append (peer->tunnels, peer->ntunnels, t); 1121 GNUNET_array_append (peer->tunnels, peer->ntunnels, t);
1114 if (NULL == (p = peer->path_head)) 1122 if (NULL == (p = peer->path_head))
1123 {
1124 GNUNET_break (0);
1115 return; 1125 return;
1126 }
1116 1127
1117 best_p = p; 1128 best_p = p;
1118 best_cost = UINT_MAX; 1129 best_cost = UINT_MAX;
@@ -2599,8 +2610,6 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
2599 * @param cls closure 2610 * @param cls closure
2600 * @param client identification of the client 2611 * @param client identification of the client
2601 * @param message the actual message (PeerControl) 2612 * @param message the actual message (PeerControl)
2602 *
2603 * FIXME path
2604 */ 2613 */
2605static void 2614static void
2606handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client, 2615handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client,
@@ -2648,21 +2657,33 @@ handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client,
2648 return; 2657 return;
2649 } 2658 }
2650 2659
2651 t->peers_total++;
2652 peer_info = peer_info_get (&peer_msg->peer); 2660 peer_info = peer_info_get (&peer_msg->peer);
2653 2661
2654 /* Start DHT search if needed FIXME: if not already connected */ 2662 /* Start DHT search if needed, otherwise just add peer to tunnel. */
2655 if (NULL == peer_info->dhtget) 2663 if (NULL == peer_info->dhtget && NULL == peer_info->path_head)
2656 { 2664 {
2657 peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_BLOCK_TYPE_TEST, &peer_msg->peer.hashPubKey, 4, /* replication level */ 2665 struct MeshPathInfo *path_info;
2658 GNUNET_DHT_RO_RECORD_ROUTE, NULL, /* bloom filter */
2659 0, /* mutator */
2660 NULL, /* xquery */
2661 0, /* xquery bits */
2662 dht_get_id_handler,
2663 (void *) peer_info);
2664 }
2665 2666
2667 path_info = GNUNET_malloc(sizeof(struct MeshPathInfo));
2668 path_info->peer = peer_info;
2669 path_info->t = t;
2670 peer_info->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */
2671 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
2672 GNUNET_BLOCK_TYPE_TEST, /* type */
2673 &peer_msg->peer.hashPubKey, /*key to search */
2674 4, /* replication level */
2675 GNUNET_DHT_RO_RECORD_ROUTE,
2676 NULL, /* bloom filter */
2677 0, /* mutator */
2678 NULL, /* xquery */
2679 0, /* xquery bits */
2680 dht_get_id_handler,
2681 (void *) path_info);
2682 }
2683 if (NULL != peer_info->path_head)
2684 {
2685 tunnel_add_peer(t, peer_info);
2686 }
2666 GNUNET_SERVER_receive_done (client, GNUNET_OK); 2687 GNUNET_SERVER_receive_done (client, GNUNET_OK);
2667 return; 2688 return;
2668} 2689}