From 8fff1a5af6382f5dfbbb6cafc71907bb08fc96db Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Wed, 20 Jun 2012 16:57:11 +0000 Subject: [PATCH] - complete block plugin, use block by put id --- src/mesh/gnunet-service-mesh_new.c | 12 ++++++++---- src/mesh/plugin_block_mesh.c | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mesh/gnunet-service-mesh_new.c b/src/mesh/gnunet-service-mesh_new.c index b6ff241d7..ef3f73f98 100644 --- a/src/mesh/gnunet-service-mesh_new.c +++ b/src/mesh/gnunet-service-mesh_new.c @@ -677,8 +677,8 @@ announce_application (void *cls, const struct GNUNET_HashCode * key, void *value GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE, - sizeof (struct PBlock), - &block, + sizeof (block), + (const char *) &block, GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), APP_ANNOUNCE_TIME), APP_ANNOUNCE_TIME, NULL, NULL); @@ -723,6 +723,8 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + struct PBlock block; + if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) { announce_id_task = GNUNET_SCHEDULER_NO_TASK; @@ -734,13 +736,15 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ DEBUG_DHT ("DHT_put for ID %s started.\n", GNUNET_i2s (&my_full_id)); + block.id = my_full_id; + block.type = htonl (0); GNUNET_DHT_put (dht_handle, /* DHT handle */ &my_full_id.hashPubKey, /* Key to use */ 10, /* Replication level */ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */ GNUNET_BLOCK_TYPE_MESH_PEER, /* Block type */ - sizeof (my_full_id), /* Size of the data */ - (char *) &my_full_id, /* Data itself */ + sizeof (block), /* Size of the data */ + (const char *) &block, /* Data itself */ GNUNET_TIME_UNIT_FOREVER_ABS, /* Data expiration */ GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ NULL, /* Continuation */ diff --git a/src/mesh/plugin_block_mesh.c b/src/mesh/plugin_block_mesh.c index 8b601652f..7c5b9fbeb 100644 --- a/src/mesh/plugin_block_mesh.c +++ b/src/mesh/plugin_block_mesh.c @@ -127,16 +127,18 @@ block_plugin_mesh_get_key (void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_HashCode * key) { const struct PBlock *pb; + pb = block; switch (type) { case GNUNET_BLOCK_TYPE_MESH_PEER: if (sizeof (struct PBlock) != block_size) return GNUNET_SYSERR; - pb = block; *key = pb->id.hashPubKey; return GNUNET_OK; - // FIXME: other types... + case GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE: + GNUNET_CRYPTO_hash (&pb->type, sizeof(GNUNET_MESH_ApplicationType), key); + return GNUNET_OK; default: return GNUNET_SYSERR; } -- 2.25.1