aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-04 15:03:44 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-04 15:03:44 +0000
commit25ce95a7d4aa7f83346424c990c0f6316417e83d (patch)
tree35404193d7aadd74c7bd071ad88b058b1221445b /src/mesh/gnunet-service-mesh.c
parentdae44779ebc12613acf1ca50db8d3dee05a5cd54 (diff)
downloadgnunet-25ce95a7d4aa7f83346424c990c0f6316417e83d.tar.gz
gnunet-25ce95a7d4aa7f83346424c990c0f6316417e83d.zip
Enabled DHT use again
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r--src/mesh/gnunet-service-mesh.c210
1 files changed, 103 insertions, 107 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 1d8d2786e..5347a1b98 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -361,7 +361,7 @@ struct MeshClient
361/************************ DEBUG FUNCTIONS ****************************/ 361/************************ DEBUG FUNCTIONS ****************************/
362/******************************************************************************/ 362/******************************************************************************/
363 363
364#if LATER /* FIXME DHT */ 364
365/** 365/**
366 * GNUNET_SCHEDULER_Task for printing a message after some operation is done 366 * GNUNET_SCHEDULER_Task for printing a message after some operation is done
367 * @param cls string to print 367 * @param cls string to print
@@ -378,7 +378,6 @@ mesh_debug (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
378 } 378 }
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", s); 379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", s);
380} 380}
381#endif
382 381
383 382
384/******************************************************************************/ 383/******************************************************************************/
@@ -409,7 +408,7 @@ static struct GNUNET_CORE_Handle *core_handle;
409/** 408/**
410 * Handle to use DHT 409 * Handle to use DHT
411 */ 410 */
412//static struct GNUNET_DHT_Handle *dht_handle; FIXME DHT 411static struct GNUNET_DHT_Handle *dht_handle;
413 412
414/** 413/**
415 * Handle to server 414 * Handle to server
@@ -501,8 +500,8 @@ static int
501announce_application (void *cls, const GNUNET_HashCode * key, void *value) 500announce_application (void *cls, const GNUNET_HashCode * key, void *value)
502{ 501{
503 /* FIXME are hashes in multihash map equal on all aquitectures? */ 502 /* FIXME are hashes in multihash map equal on all aquitectures? */
504 /* FIXME DHT */ 503
505/* GNUNET_DHT_put (dht_handle, key, 10U, GNUNET_DHT_RO_RECORD_ROUTE, 504 GNUNET_DHT_put (dht_handle, key, 10U, GNUNET_DHT_RO_RECORD_ROUTE,
506 GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity), 505 GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity),
507 (const char *) &my_full_id, 506 (const char *) &my_full_id,
508#if MESH_DEBUG 507#if MESH_DEBUG
@@ -512,7 +511,7 @@ announce_application (void *cls, const GNUNET_HashCode * key, void *value)
512 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), 511 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
513 APP_ANNOUNCE_TIME), 512 APP_ANNOUNCE_TIME),
514 APP_ANNOUNCE_TIME, NULL, NULL); 513 APP_ANNOUNCE_TIME, NULL, NULL);
515#endif*/ 514#endif
516 return GNUNET_OK; 515 return GNUNET_OK;
517} 516}
518 517
@@ -560,28 +559,28 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
560 * - Set data expiration in function of X 559 * - Set data expiration in function of X
561 * - Adapt X to churn 560 * - Adapt X to churn
562 */ 561 */
563// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: DHT_put for ID %s started.\n", 562 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: DHT_put for ID %s started.\n",
564// GNUNET_h2s_full (&my_full_id.hashPubKey)); 563 GNUNET_h2s_full (&my_full_id.hashPubKey));
565// GNUNET_DHT_put (dht_handle, /* DHT handle */ FIXME DHT 564 GNUNET_DHT_put (dht_handle, /* DHT handle */
566// &my_full_id.hashPubKey, /* Key to use */ 565 &my_full_id.hashPubKey, /* Key to use */
567// 10U, /* Replication level */ 566 10U, /* Replication level */
568// GNUNET_DHT_RO_RECORD_ROUTE, /* DHT options */ 567 GNUNET_DHT_RO_RECORD_ROUTE, /* DHT options */
569// GNUNET_BLOCK_TYPE_TEST, /* Block type */ 568 GNUNET_BLOCK_TYPE_TEST, /* Block type */
570// sizeof(my_full_id), /* Size of the data */ 569 sizeof(my_full_id), /* Size of the data */
571// (char *)&my_full_id, /* Data itself */ 570 (char *)&my_full_id, /* Data itself */
572// GNUNET_TIME_absolute_get_forever (), /* Data expiration */ 571 GNUNET_TIME_absolute_get_forever (), /* Data expiration */
573// GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ 572 GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */
574// #if MESH_DEBUG 573#if MESH_DEBUG
575// &mesh_debug, "DHT_put for id completed"); 574 &mesh_debug, "DHT_put for id completed");
576// #else 575#else
577// NULL, /* Continuation */ 576 NULL, /* Continuation */
578// NULL); /* Continuation closure */ 577 NULL); /* Continuation closure */
579// #endif 578#endif
580 announce_id_task = 579 announce_id_task =
581 GNUNET_SCHEDULER_add_delayed (ID_ANNOUNCE_TIME, &announce_id, cls); 580 GNUNET_SCHEDULER_add_delayed (ID_ANNOUNCE_TIME, &announce_id, cls);
582} 581}
583 582
584#if LATER /* FIXME DHT */ 583
585/** 584/**
586 * Function to process paths received for a new peer addition. The recorded 585 * Function to process paths received for a new peer addition. The recorded
587 * paths form the initial tunnel, which can be optimized later. 586 * paths form the initial tunnel, which can be optimized later.
@@ -602,7 +601,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
602 const struct GNUNET_PeerIdentity *put_path, 601 const struct GNUNET_PeerIdentity *put_path,
603 unsigned int put_path_length, 602 unsigned int put_path_length,
604 enum GNUNET_BLOCK_Type type, size_t size, const void *data); 603 enum GNUNET_BLOCK_Type type, size_t size, const void *data);
605#endif 604
606 605
607/******************************************************************************/ 606/******************************************************************************/
608/****************** GENERAL HELPER FUNCTIONS ************************/ 607/****************** GENERAL HELPER FUNCTIONS ************************/
@@ -756,24 +755,24 @@ path_remove_from_peer (struct MeshPeerInfo *peer,
756 } 755 }
757 else 756 else
758 { 757 {
759// struct MeshPathInfo *path_info; 758 struct MeshPathInfo *path_info;
760 759
761 if (NULL != peer_d->dhtget) 760 if (NULL != peer_d->dhtget)
762 return; 761 return;
763// path_info = GNUNET_malloc(sizeof(struct MeshPathInfo)); FIXME DHT 762 path_info = GNUNET_malloc(sizeof(struct MeshPathInfo));
764// path_info->path = p; 763 path_info->path = p;
765// path_info->peer = peer_d; 764 path_info->peer = peer_d;
766// path_info->t = peer->tunnels[i]; 765 path_info->t = peer->tunnels[i];
767// peer_d->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */ 766 peer_d->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */
768// GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ 767 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
769// GNUNET_BLOCK_TYPE_TEST, /* type */ 768 GNUNET_BLOCK_TYPE_TEST, /* type */
770// &id.hashPubKey, /*key to search */ 769 &id.hashPubKey, /*key to search */
771// 4, /* replication level */ 770 4, /* replication level */
772// GNUNET_DHT_RO_RECORD_ROUTE, 771 GNUNET_DHT_RO_RECORD_ROUTE,
773// NULL, /* xquery */ 772 NULL, /* xquery */
774// 0, /* xquery bits */ 773 0, /* xquery bits */
775// &dht_get_id_handler, 774 &dht_get_id_handler,
776// (void *) path_info); 775 (void *) path_info);
777 } 776 }
778 } 777 }
779} 778}
@@ -844,7 +843,6 @@ path_add_to_origin (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path)
844} 843}
845 844
846 845
847#if LATER /* FIXME DHT */
848/** 846/**
849 * Build a PeerPath from the paths returned from the DHT, reversing the paths 847 * Build a PeerPath from the paths returned from the DHT, reversing the paths
850 * to obtain a local peer -> destination path and interning the peer ids. 848 * to obtain a local peer -> destination path and interning the peer ids.
@@ -911,7 +909,6 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *get_path,
911#endif 909#endif
912 return p; 910 return p;
913} 911}
914#endif
915 912
916 913
917/** 914/**
@@ -2116,7 +2113,7 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2116 return; 2113 return;
2117} 2114}
2118 2115
2119#if LATER /* FIXME DHT */ 2116
2120/** 2117/**
2121 * Function to process paths received for a new peer addition. The recorded 2118 * Function to process paths received for a new peer addition. The recorded
2122 * paths form the initial tunnel, which can be optimized later. 2119 * paths form the initial tunnel, which can be optimized later.
@@ -2157,16 +2154,16 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2157 { 2154 {
2158 // Find ourselves some alternate initial path to the destination: retry 2155 // Find ourselves some alternate initial path to the destination: retry
2159 GNUNET_DHT_get_stop (path_info->peer->dhtget); 2156 GNUNET_DHT_get_stop (path_info->peer->dhtget);
2160// path_info->peer->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ FIXME DHT 2157 path_info->peer->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
2161// GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ 2158 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
2162// GNUNET_BLOCK_TYPE_TEST, /* type */ 2159 GNUNET_BLOCK_TYPE_TEST, /* type */
2163// &pi.hashPubKey, /*key to search */ 2160 &pi.hashPubKey, /*key to search */
2164// 4, /* replication level */ 2161 4, /* replication level */
2165// GNUNET_DHT_RO_RECORD_ROUTE, 2162 GNUNET_DHT_RO_RECORD_ROUTE,
2166// NULL, /* xquery */ 2163 NULL, /* xquery */
2167// 0, /* xquery bits */ 2164 0, /* xquery bits */
2168// &dht_get_id_handler, 2165 &dht_get_id_handler,
2169// (void *) path_info); 2166 (void *) path_info);
2170 return; 2167 return;
2171 } 2168 }
2172 } 2169 }
@@ -2258,27 +2255,27 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2258 if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head && 2255 if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head &&
2259 NULL == peer_info->dhtget) 2256 NULL == peer_info->dhtget)
2260 { 2257 {
2261// path_info = GNUNET_malloc (sizeof (struct MeshPathInfo)); FIXME DHT 2258 path_info = GNUNET_malloc (sizeof (struct MeshPathInfo));
2262// path_info->peer = peer_info; 2259 path_info->peer = peer_info;
2263// path_info->t = t; 2260 path_info->t = t;
2264// /* we don't have a route to the peer, let's try a direct lookup */ 2261 /* we don't have a route to the peer, let's try a direct lookup */
2265// peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, 2262 peer_info->dhtget = GNUNET_DHT_get_start (dht_handle,
2266// /* handle */ 2263 /* handle */
2267// GNUNET_TIME_UNIT_FOREVER_REL, 2264 GNUNET_TIME_UNIT_FOREVER_REL,
2268// /* timeout */ 2265 /* timeout */
2269// GNUNET_BLOCK_TYPE_TEST, 2266 GNUNET_BLOCK_TYPE_TEST,
2270// /* block type */ 2267 /* block type */
2271// &pi->hashPubKey, 2268 &pi->hashPubKey,
2272// /* key to look up */ 2269 /* key to look up */
2273// 10U, 2270 10U,
2274// /* replication level */ 2271 /* replication level */
2275// GNUNET_DHT_RO_RECORD_ROUTE, 2272 GNUNET_DHT_RO_RECORD_ROUTE,
2276// /* option to dht: record route */ 2273 /* option to dht: record route */
2277// NULL, /* xquery */ 2274 NULL, /* xquery */
2278// 0, /* xquery bits */ 2275 0, /* xquery bits */
2279// dht_get_id_handler, 2276 dht_get_id_handler,
2280// /* callback */ 2277 /* callback */
2281// path_info); /* closure */ 2278 path_info); /* closure */
2282 return; 2279 return;
2283 } 2280 }
2284 2281
@@ -2329,7 +2326,6 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2329 send_client_peer_connected(t, myid); 2326 send_client_peer_connected(t, myid);
2330} 2327}
2331 2328
2332#endif
2333 2329
2334/******************************************************************************/ 2330/******************************************************************************/
2335/********************* MESH LOCAL HANDLES **************************/ 2331/********************* MESH LOCAL HANDLES **************************/
@@ -2704,19 +2700,19 @@ handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client,
2704 /* Start DHT search if needed, otherwise just add peer to tunnel. */ 2700 /* Start DHT search if needed, otherwise just add peer to tunnel. */
2705 if (NULL == peer_info->dhtget && NULL == peer_info->path_head) 2701 if (NULL == peer_info->dhtget && NULL == peer_info->path_head)
2706 { 2702 {
2707// path_info = GNUNET_malloc(sizeof(struct MeshPathInfo)); 2703 path_info = GNUNET_malloc(sizeof(struct MeshPathInfo));
2708// path_info->peer = peer_info; 2704 path_info->peer = peer_info;
2709// path_info->t = t; 2705 path_info->t = t;
2710// peer_info->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */ FIXME DHT 2706 peer_info->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */
2711// GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ 2707 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
2712// GNUNET_BLOCK_TYPE_TEST, /* type */ 2708 GNUNET_BLOCK_TYPE_TEST, /* type */
2713// &peer_msg->peer.hashPubKey, /*key to search */ 2709 &peer_msg->peer.hashPubKey, /*key to search */
2714// 4, /* replication level */ 2710 4, /* replication level */
2715// GNUNET_DHT_RO_RECORD_ROUTE, 2711 GNUNET_DHT_RO_RECORD_ROUTE,
2716// NULL, /* xquery */ 2712 NULL, /* xquery */
2717// 0, /* xquery bits */ 2713 0, /* xquery bits */
2718// &dht_get_id_handler, 2714 &dht_get_id_handler,
2719// (void *) path_info); 2715 (void *) path_info);
2720 } 2716 }
2721 else if (NULL != peer_info->path_head) 2717 else if (NULL != peer_info->path_head)
2722 { 2718 {
@@ -2900,11 +2896,11 @@ handle_local_connect_by_type (void *cls, struct GNUNET_SERVER_Client *client,
2900 } 2896 }
2901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: looking in DHT for %s\n", 2897 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: looking in DHT for %s\n",
2902 GNUNET_h2s_full (&hash)); 2898 GNUNET_h2s_full (&hash));
2903// c->dht_get_type = FIXME DHT 2899 c->dht_get_type =
2904// GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, 2900 GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL,
2905// GNUNET_BLOCK_TYPE_TEST, &hash, 10U, 2901 GNUNET_BLOCK_TYPE_TEST, &hash, 10U,
2906// GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0, 2902 GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0,
2907// &dht_get_type_handler, t); 2903 &dht_get_type_handler, t);
2908 2904
2909 GNUNET_SERVER_receive_done (client, GNUNET_OK); 2905 GNUNET_SERVER_receive_done (client, GNUNET_OK);
2910 return; 2906 return;
@@ -3220,7 +3216,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
3220static void 3216static void
3221shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 3217shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3222{ 3218{
3223// struct MeshClient *c; 3219 struct MeshClient *c;
3224 3220
3225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: shutting down\n"); 3221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: shutting down\n");
3226 if (core_handle != NULL) 3222 if (core_handle != NULL)
@@ -3228,14 +3224,14 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3228 GNUNET_CORE_disconnect (core_handle); 3224 GNUNET_CORE_disconnect (core_handle);
3229 core_handle = NULL; 3225 core_handle = NULL;
3230 } 3226 }
3231// if (dht_handle != NULL) FIXME DHT 3227 if (dht_handle != NULL)
3232// { 3228 {
3233// for (c = clients; NULL != c; c = c->next) 3229 for (c = clients; NULL != c; c = c->next)
3234// if (NULL != c->dht_get_type) 3230 if (NULL != c->dht_get_type)
3235// GNUNET_DHT_get_stop (c->dht_get_type); 3231 GNUNET_DHT_get_stop (c->dht_get_type);
3236// GNUNET_DHT_disconnect (dht_handle); 3232 GNUNET_DHT_disconnect (dht_handle);
3237// dht_handle = NULL; 3233 dht_handle = NULL;
3238// } 3234 }
3239 if (nc != NULL) 3235 if (nc != NULL)
3240 { 3236 {
3241 GNUNET_SERVER_notification_context_destroy (nc); 3237 GNUNET_SERVER_notification_context_destroy (nc);
@@ -3309,11 +3305,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
3309 &my_full_id.hashPubKey); 3305 &my_full_id.hashPubKey);
3310 myid = GNUNET_PEER_intern (&my_full_id); 3306 myid = GNUNET_PEER_intern (&my_full_id);
3311 3307
3312// dht_handle = GNUNET_DHT_connect (c, 64); FIXME DHT 3308 dht_handle = GNUNET_DHT_connect (c, 64);
3313// if (dht_handle == NULL) 3309 if (dht_handle == NULL)
3314// { 3310 {
3315// GNUNET_break (0); 3311 GNUNET_break (0);
3316// } 3312 }
3317 3313
3318 next_tid = 0; 3314 next_tid = 0;
3319 next_local_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; 3315 next_local_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;