const struct GNUNET_GNSRECORD_Data *rd,
unsigned int rd_count)
{
- size_t payload_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
+ size_t payload_len = GNUNET_GNSRECORD_records_get_size (rd_count,
+ rd);
char payload[sizeof (uint32_t) + payload_len];
struct GNUNET_GNSRECORD_Block *block;
struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
struct GNUNET_GNSRECORD_Data rdc[rd_count];
uint32_t rd_count_nbo;
- unsigned int i;
struct GNUNET_TIME_Absolute now;
if (payload_len > GNUNET_GNSRECORD_MAX_BLOCK_SIZE)
return NULL;
/* convert relative to absolute times */
now = GNUNET_TIME_absolute_get ();
- for (i=0;i<rd_count;i++)
+ for (unsigned int i=0;i<rd_count;i++)
{
rdc[i] = rd[i];
if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
}
/* serialize */
rd_count_nbo = htonl (rd_count);
- GNUNET_memcpy (payload, &rd_count_nbo, sizeof (uint32_t));
+ GNUNET_memcpy (payload,
+ &rd_count_nbo,
+ sizeof (uint32_t));
GNUNET_assert (payload_len ==
- GNUNET_GNSRECORD_records_serialize (rd_count, rdc,
- payload_len, &payload[sizeof (uint32_t)]));
+ GNUNET_GNSRECORD_records_serialize (rd_count,
+ rdc,
+ payload_len,
+ &payload[sizeof (uint32_t)]));
block = GNUNET_malloc (sizeof (struct GNUNET_GNSRECORD_Block) +
- sizeof (uint32_t) + payload_len);
- block->purpose.size = htonl (sizeof (uint32_t) + payload_len +
+ sizeof (uint32_t) +
+ payload_len);
+ block->purpose.size = htonl (sizeof (uint32_t) +
+ payload_len +
sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
sizeof (struct GNUNET_TIME_AbsoluteNBO));
block->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
label,
"gns");
GNUNET_CRYPTO_ecdsa_key_get_public (dkey,
- &block->derived_key);
+ &block->derived_key);
GNUNET_CRYPTO_ecdsa_key_get_public (key,
- &pkey);
- derive_block_aes_key (&iv, &skey, label, &pkey);
+ &pkey);
+ derive_block_aes_key (&iv,
+ &skey,
+ label,
+ &pkey);
GNUNET_break (payload_len + sizeof (uint32_t) ==
- GNUNET_CRYPTO_symmetric_encrypt (payload, payload_len + sizeof (uint32_t),
- &skey, &iv,
+ GNUNET_CRYPTO_symmetric_encrypt (payload,
+ payload_len + sizeof (uint32_t),
+ &skey,
+ &iv,
&block[1]));
if (GNUNET_OK !=
GNUNET_CRYPTO_ecdsa_sign (dkey,
- &block->purpose,
- &block->signature))
+ &block->purpose,
+ &block->signature))
{
GNUNET_break (0);
GNUNET_free (dkey);
GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block)
{
return GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN,
- &block->purpose,
- &block->signature,
- &block->derived_key);
+ &block->purpose,
+ &block->signature,
+ &block->derived_key);
}
}
{
struct GNUNET_GNSRECORD_Data rd[rd_count];
- unsigned int i;
unsigned int j;
- unsigned int k;
struct GNUNET_TIME_Absolute now;
if (GNUNET_OK !=
/* hide expired records */
now = GNUNET_TIME_absolute_get ();
j = 0;
- for (i=0;i<rd_count;i++)
+ for (unsigned int i=0;i<rd_count;i++)
{
if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
{
{
int include_record = GNUNET_YES;
/* Shadow record, figure out if we have a not expired active record */
- for (k=0;k<rd_count;k++)
+ for (unsigned int k=0;k<rd_count;k++)
{
if (k == i)
continue;
}
rd_count = j;
if (NULL != proc)
- proc (proc_cls, rd_count, (0 != rd_count) ? rd : NULL);
+ proc (proc_cls,
+ rd_count,
+ (0 != rd_count) ? rd : NULL);
}
}
return GNUNET_OK;
{
struct GNUNET_CRYPTO_EcdsaPublicKey pd;
- GNUNET_CRYPTO_ecdsa_public_key_derive (pub, label, "gns", &pd);
- GNUNET_CRYPTO_hash (&pd, sizeof (pd), query);
+ GNUNET_CRYPTO_ecdsa_public_key_derive (pub,
+ label,
+ "gns",
+ &pd);
+ GNUNET_CRYPTO_hash (&pd,
+ sizeof (pd),
+ query);
}
* @param rd_count number of entries in @a rd array
* @param rd array of records with data to store
*/
-typedef void (*GNUNET_GNSRECORD_RecordCallback) (void *cls,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd);
+typedef void
+(*GNUNET_GNSRECORD_RecordCallback) (void *cls,
+ unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd);
#include "gnunet_namecache_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_namestore_plugin.h"
+#include "gnunet_statistics_service.h"
#include "gnunet_signatures.h"
#include "namestore.h"
*/
static const struct GNUNET_CONFIGURATION_Handle *GSN_cfg;
+/**
+ * Handle to the statistics service
+ */
+static struct GNUNET_STATISTICS_Handle *statistics;
+
/**
* Namecache handle.
*/
GNUNET_notification_context_destroy (monitor_nc);
monitor_nc = NULL;
}
+ if (NULL != statistics)
+ {
+ GNUNET_STATISTICS_destroy (statistics,
+ GNUNET_NO);
+ statistics = NULL;
+ }
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending RECORD_RESULT message with %u records\n",
res_count);
+ GNUNET_STATISTICS_update (statistics,
+ "Record sets sent to clients",
+ 1,
+ GNUNET_NO);
GNUNET_MQ_send (nc->mq,
env);
if (rd != res)
name,
res_count,
GNUNET_GNSRECORD_z2s (&pkey));
+ GNUNET_STATISTICS_update (statistics,
+ "Namecache updates pushed",
+ 1,
+ GNUNET_NO);
cop = GNUNET_new (struct CacheOperation);
cop->nc = nc;
cop->rid = rid;
unsigned int rdc_res;
(void) private_key;
- if (0 == strcmp (label, rlc->label))
+ if (0 == strcmp (label,
+ rlc->label))
{
rlc->found = GNUNET_YES;
if (0 != rd_count)
struct ZoneIterationProcResult *proc = cls;
int do_refresh_block;
- if ((NULL == zone_key) && (NULL == name))
+ if ( (NULL == zone_key) &&
+ (NULL == name) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Iteration done\n");
{
if (GNUNET_SYSERR ==
(ret = GSN_database->iterate_records (GSN_database->cls,
- (0 == memcmp (&zi->zone, &zero, sizeof (zero)))
+ (0 == memcmp (&zi->zone,
+ &zero,
+ sizeof (zero)))
? NULL
: &zi->zone,
zi->offset,
- &zone_iterate_proc, &proc)))
+ &zone_iterate_proc,
+ &proc)))
{
GNUNET_break (0);
break;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received ZONE_ITERATION_NEXT message\n");
+ GNUNET_STATISTICS_update (statistics,
+ "Iteration NEXT messages received",
+ 1,
+ GNUNET_NO);
rid = ntohl (zis_msg->gns_header.r_id);
for (zi = nc->op_head; NULL != zi; zi = zi->next)
if (zi->request_id == rid)
monitor_sync (zm);
return;
}
+ GNUNET_STATISTICS_update (statistics,
+ "Monitor notifications sent",
+ 1,
+ GNUNET_NO);
send_lookup_response (zm->nc,
0,
zone_key,
GSN_database = GNUNET_PLUGIN_load (db_lib_name,
(void *) GSN_cfg);
GNUNET_free (database);
+ statistics = GNUNET_STATISTICS_create ("namestore",
+ cfg);
GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
NULL);
if (NULL == GSN_database)
{
struct GNUNET_TIME_Absolute now;
unsigned int rd_public_count;
- unsigned int i;
rd_public_count = 0;
now = GNUNET_TIME_absolute_get ();
- for (i=0;i<rd_count;i++)
+ for (unsigned int i=0;i<rd_count;i++)
if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
{
rd_public[rd_public_count] = rd[i];
GNUNET_GNSRECORD_query_from_private_key (key,
label,
&query);
+ GNUNET_STATISTICS_update (statistics,
+ "DHT put operations initiated",
+ 1,
+ GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n",
rd_public_count,
/**
* We encountered an error in our zone iteration.
+ *
+ * @param cls NULL
*/
static void
zone_iteration_error (void *cls)
{
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got disconnected from namestore database, retrying.\n");
namestore_iter = NULL;
/**
* Zone iteration is completed.
+ *
+ * @param cls NULL
*/
static void
zone_iteration_finished (void *cls)
{
+ (void) cls;
/* we're done with one iteration, calculate when to do the next one */
namestore_iter = NULL;
last_num_public_records = num_public_records;
struct GNUNET_GNSRECORD_Data rd_public[rd_count];
unsigned int rd_public_count;
+ (void) cls;
rd_public_count = convert_records_for_export (rd,
rd_count,
rd_public);
-
if (0 == rd_public_count)
{
GNUNET_assert (NULL == zone_publish_task);
publish_zone_dht_start (void *cls)
{
zone_publish_task = NULL;
-
+ GNUNET_STATISTICS_update (statistics,
+ "Full zone iterations launched",
+ 1,
+ GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting DHT zone update!\n");
/* start counting again */
unsigned int rd_public_count;
struct MonitorActivity *ma;
+ GNUNET_STATISTICS_update (statistics,
+ "Namestore monitor events received",
+ 1,
+ GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received %u records for label `%s' via namestore monitor\n",
rd_count,
static void
monitor_sync_event (void *cls)
{
+ (void) cls;
if ( (NULL == zone_publish_task) &&
(NULL == namestore_iter) )
- zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
- NULL);
+ zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
+ NULL);
}
/**
- * The zone monitor is now in SYNC with the current state of the
- * name store. Start to perform periodic iterations.
+ * The zone monitor encountered an IPC error trying to to get in
+ * sync. Restart from the beginning.
*
* @param cls NULL
*/
static void
handle_monitor_error (void *cls)
{
+ (void) cls;
+ GNUNET_STATISTICS_update (statistics,
+ "Namestore monitor errors encountered",
+ 1,
+ GNUNET_NO);
if (NULL != zone_publish_task)
{
GNUNET_SCHEDULER_cancel (zone_publish_task);
{
unsigned long long max_parallel_bg_queries = 128;
+ (void) cls;
min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL;
namestore_handle = GNUNET_NAMESTORE_connect (c);
if (NULL == namestore_handle)
max_parallel_bg_queries);
}
if (0 == max_parallel_bg_queries)
- max_parallel_bg_queries = 1;
+ max_parallel_bg_queries = 1;
dht_handle = GNUNET_DHT_connect (c,
(unsigned int) max_parallel_bg_queries);
if (NULL == dht_handle)
/* Schedule periodic put for our records. */
first_zone_iteration = GNUNET_YES;\
- statistics = GNUNET_STATISTICS_create ("zonemaster", c);
+ statistics = GNUNET_STATISTICS_create ("zonemaster",
+ c);
zmon = GNUNET_NAMESTORE_zone_monitor_start (c,
NULL,
GNUNET_NO,