aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r--src/mesh/gnunet-service-mesh.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 391045a10..61ff4d745 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -54,6 +54,15 @@
54#include "mesh_protocol.h" 54#include "mesh_protocol.h"
55#include "gnunet_dht_service.h" 55#include "gnunet_dht_service.h"
56 56
57#define MESH_DEBUG 0
58
59#if MESH_DEBUG
60static void
61mesh_debug (const char *s)
62{
63 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s", s);
64}
65#endif
57 66
58#define CORE_QUEUE_SIZE 10 67#define CORE_QUEUE_SIZE 10
59#define LOCAL_QUEUE_SIZE 100 68#define LOCAL_QUEUE_SIZE 100
@@ -1098,7 +1107,7 @@ handle_mesh_path_create (void *cls,
1098 struct MeshPeerInfo *orig_peer_info; 1107 struct MeshPeerInfo *orig_peer_info;
1099 struct MeshTunnel *t; 1108 struct MeshTunnel *t;
1100 1109
1101 1110 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received a MESH path create msg\n");
1102 size = ntohs(message->size); 1111 size = ntohs(message->size);
1103 if (size < sizeof(struct GNUNET_MESH_ManipulatePath)) { 1112 if (size < sizeof(struct GNUNET_MESH_ManipulatePath)) {
1104 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1113 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
@@ -1125,11 +1134,10 @@ handle_mesh_path_create (void *cls,
1125 t = retrieve_tunnel(pi, tid); 1134 t = retrieve_tunnel(pi, tid);
1126 1135
1127 if (NULL == t) { 1136 if (NULL == t) {
1137 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Creating tunnel\n");
1128 t = GNUNET_malloc(sizeof(struct MeshTunnel)); 1138 t = GNUNET_malloc(sizeof(struct MeshTunnel));
1129 t->id.oid = GNUNET_PEER_intern(pi); 1139 t->id.oid = GNUNET_PEER_intern(pi);
1130 t->id.tid = tid; 1140 t->id.tid = tid;
1131 t->local_tid = 0;
1132 t->client = NULL;
1133 t->peers = GNUNET_CONTAINER_multihashmap_create(32); 1141 t->peers = GNUNET_CONTAINER_multihashmap_create(32);
1134 1142
1135 GNUNET_CRYPTO_hash(&t->id, sizeof(struct MESH_TunnelID), &hash); 1143 GNUNET_CRYPTO_hash(&t->id, sizeof(struct MESH_TunnelID), &hash);
@@ -1139,8 +1147,7 @@ handle_mesh_path_create (void *cls,
1139 t, 1147 t,
1140 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) 1148 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1141 { 1149 {
1142 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1150 GNUNET_break(0);
1143 "create path: could not store tunnel in hashmap\n");
1144 return GNUNET_OK; 1151 return GNUNET_OK;
1145 } 1152 }
1146 1153
@@ -2324,6 +2331,27 @@ core_init (void *cls,
2324 "Core init\n"); 2331 "Core init\n");
2325 core_handle = server; 2332 core_handle = server;
2326 myid = GNUNET_PEER_intern(identity); 2333 myid = GNUNET_PEER_intern(identity);
2334 /* TODO
2335 * - Repeat every X seconds to avoid churn induced failures,
2336 * increase replication and diversify routes.
2337 * - Set data expiration in function of X
2338 * - Adapt X to churn
2339 */
2340 GNUNET_DHT_put(dht_handle, /* DHT handle */
2341 &identity->hashPubKey, /* Key to use */
2342 10U, /* Replication level */
2343 GNUNET_DHT_RO_RECORD_ROUTE, /* DHT options */
2344 GNUNET_BLOCK_TYPE_ANY, /* Block type */
2345 0, /* Size of the data */
2346 NULL, /* Data itself */
2347 GNUNET_TIME_absolute_get_forever(), /* Data expiration */
2348 GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */
2349#if MESH_DEBUG
2350
2351#else
2352 NULL, /* Continuation */
2353 NULL); /* Continuation closure */
2354#endif
2327 return; 2355 return;
2328} 2356}
2329 2357
@@ -2460,8 +2488,14 @@ run (void *cls,
2460 } 2488 }
2461 dht_handle = GNUNET_DHT_connect(c, 64); 2489 dht_handle = GNUNET_DHT_connect(c, 64);
2462 if (dht_handle == NULL) { 2490 if (dht_handle == NULL) {
2491 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2492 "Error connecting to DHT.\
2493 Running without DHT has a severe\
2494 impact in MESH capabilities.\n\
2495 Plase check your configuretion and enable DHT.\n");
2463 GNUNET_break(0); 2496 GNUNET_break(0);
2464 } 2497 }
2498
2465 next_tid = 0; 2499 next_tid = 0;
2466 2500
2467 tunnels = GNUNET_CONTAINER_multihashmap_create(32); 2501 tunnels = GNUNET_CONTAINER_multihashmap_create(32);
@@ -2476,7 +2510,7 @@ run (void *cls,
2476 &shutdown_task, NULL); 2510 &shutdown_task, NULL);
2477 2511
2478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2512 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2479 "end if run()\n"); 2513 "end of run()\n");
2480} 2514}
2481 2515
2482/** 2516/**