aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-02-05 17:24:23 +0000
committerBart Polot <bart@net.in.tum.de>2014-02-05 17:24:23 +0000
commitd3a8367a07bd4138b5d36533a3b0920387745b10 (patch)
tree46cead49d0e15cf6b53ee7aaabf4294b96b7fd12 /src/mesh
parentf0850a16d69e4cedf3354316b4223057dcf4c213 (diff)
downloadgnunet-d3a8367a07bd4138b5d36533a3b0920387745b10.tar.gz
gnunet-d3a8367a07bd4138b5d36533a3b0920387745b10.zip
Use DHT_HELLO for MESH peer discovery, benefit from wider replication
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/Makefile.am15
-rw-r--r--src/mesh/gnunet-service-mesh_dht.c19
2 files changed, 11 insertions, 23 deletions
diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am
index 35f06f8d2..2775dff6c 100644
--- a/src/mesh/Makefile.am
+++ b/src/mesh/Makefile.am
@@ -29,21 +29,6 @@ bin_PROGRAMS = \
29lib_LTLIBRARIES = \ 29lib_LTLIBRARIES = \
30 libgnunetmesh.la $(EXP_LIB) 30 libgnunetmesh.la $(EXP_LIB)
31 31
32plugin_LTLIBRARIES = \
33 libgnunet_plugin_block_mesh.la
34
35libgnunet_plugin_block_mesh_la_SOURCES = \
36 plugin_block_mesh.c
37libgnunet_plugin_block_mesh_la_LIBADD = \
38 $(top_builddir)/src/block/libgnunetblock.la \
39 $(top_builddir)/src/util/libgnunetutil.la
40libgnunet_plugin_block_mesh_la_LDFLAGS = \
41 $(GN_PLUGIN_LDFLAGS)
42libgnunet_plugin_block_mesh_la_DEPENDENCIES = \
43 $(top_builddir)/src/block/libgnunetblock.la \
44 $(top_builddir)/src/util/libgnunetutil.la
45
46
47libgnunetmesh_la_SOURCES = \ 32libgnunetmesh_la_SOURCES = \
48 mesh_api.c mesh_common.c 33 mesh_api.c mesh_common.c
49libgnunetmesh_la_LIBADD = \ 34libgnunetmesh_la_LIBADD = \
diff --git a/src/mesh/gnunet-service-mesh_dht.c b/src/mesh/gnunet-service-mesh_dht.c
index 0e27eb9fa..9bed8f40a 100644
--- a/src/mesh/gnunet-service-mesh_dht.c
+++ b/src/mesh/gnunet-service-mesh_dht.c
@@ -25,10 +25,10 @@
25#include "gnunet_dht_service.h" 25#include "gnunet_dht_service.h"
26#include "gnunet_statistics_service.h" 26#include "gnunet_statistics_service.h"
27 27
28#include "block_mesh.h"
29#include "mesh_path.h" 28#include "mesh_path.h"
30#include "gnunet-service-mesh_dht.h" 29#include "gnunet-service-mesh_dht.h"
31#include "gnunet-service-mesh_peer.h" 30#include "gnunet-service-mesh_peer.h"
31#include "gnunet-service-mesh_hello.h"
32 32
33#define LOG(level, ...) GNUNET_log_from (level,"mesh-dht",__VA_ARGS__) 33#define LOG(level, ...) GNUNET_log_from (level,"mesh-dht",__VA_ARGS__)
34 34
@@ -240,8 +240,9 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
240static void 240static void
241announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 241announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
242{ 242{
243 struct PBlock block;
244 struct GNUNET_HashCode phash; 243 struct GNUNET_HashCode phash;
244 struct GNUNET_HELLO_Message *hello;
245 size_t size;
245 246
246 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 247 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
247 { 248 {
@@ -253,15 +254,16 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
253 * - Set data expiration in function of X 254 * - Set data expiration in function of X
254 * - Adapt X to churn 255 * - Adapt X to churn
255 */ 256 */
256 block.id = my_full_id; 257 hello = GMH_get_mine ();
258 size = GNUNET_HELLO_size (hello);
257 GNUNET_CRYPTO_hash (&my_full_id, sizeof (struct GNUNET_PeerIdentity), &phash); 259 GNUNET_CRYPTO_hash (&my_full_id, sizeof (struct GNUNET_PeerIdentity), &phash);
258 GNUNET_DHT_put (dht_handle, /* DHT handle */ 260 GNUNET_DHT_put (dht_handle, /* DHT handle */
259 &phash, /* Key to use */ 261 &phash, /* Key to use */
260 dht_replication_level, /* Replication level */ 262 dht_replication_level, /* Replication level */
261 GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */ 263 GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */
262 GNUNET_BLOCK_TYPE_MESH_PEER, /* Block type */ 264 GNUNET_BLOCK_TYPE_DHT_HELLO, /* Block type */
263 sizeof (block), /* Size of the data */ 265 size, /* Size of the data */
264 (const char *) &block, /* Data itself */ 266 (const char *) hello, /* Data itself */
265 GNUNET_TIME_UNIT_FOREVER_ABS, /* Data expiration */ 267 GNUNET_TIME_UNIT_FOREVER_ABS, /* Data expiration */
266 GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ 268 GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */
267 NULL, /* Continuation */ 269 NULL, /* Continuation */
@@ -364,13 +366,14 @@ GMD_search (const struct GNUNET_PeerIdentity *peer_id,
364 366
365 LOG (GNUNET_ERROR_TYPE_DEBUG, 367 LOG (GNUNET_ERROR_TYPE_DEBUG,
366 " Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id)); 368 " Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id));
367 GNUNET_CRYPTO_hash (peer_id, sizeof (struct GNUNET_PeerIdentity), &phash); 369 memset (&phash, 0, sizeof (phash));
370 memcpy (&phash, &my_full_id, sizeof (my_full_id));
368 h = GNUNET_new (struct GMD_search_handle); 371 h = GNUNET_new (struct GMD_search_handle);
369 h->peer_id = GNUNET_PEER_intern (peer_id); 372 h->peer_id = GNUNET_PEER_intern (peer_id);
370 h->callback = callback; 373 h->callback = callback;
371 h->cls = cls; 374 h->cls = cls;
372 h->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ 375 h->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
373 GNUNET_BLOCK_TYPE_MESH_PEER, /* type */ 376 GNUNET_BLOCK_TYPE_DHT_HELLO, /* type */
374 &phash, /* key to search */ 377 &phash, /* key to search */
375 dht_replication_level, /* replication level */ 378 dht_replication_level, /* replication level */
376 GNUNET_DHT_RO_RECORD_ROUTE | 379 GNUNET_DHT_RO_RECORD_ROUTE |