[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34183 - in gnunet/src: include sensor sensordashboard
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34183 - in gnunet/src: include sensor sensordashboard |
Date: |
Wed, 20 Aug 2014 16:05:05 +0200 |
Author: otarabai
Date: 2014-08-20 16:05:05 +0200 (Wed, 20 Aug 2014)
New Revision: 34183
Modified:
gnunet/src/include/gnunet_sensor_util_lib.h
gnunet/src/sensor/gnunet-service-sensor_reporting.c
gnunet/src/sensor/gnunet-service-sensor_update.c
gnunet/src/sensor/sensor.conf.in
gnunet/src/sensor/sensor_util_lib_crypto.c
gnunet/src/sensor/test_pow_sign.c
gnunet/src/sensordashboard/gnunet-service-sensordashboard.c
Log:
sensor: proof-of-work ingerated with anomaly reports
Modified: gnunet/src/include/gnunet_sensor_util_lib.h
===================================================================
--- gnunet/src/include/gnunet_sensor_util_lib.h 2014-08-20 13:40:10 UTC (rev
34182)
+++ gnunet/src/include/gnunet_sensor_util_lib.h 2014-08-20 14:05:05 UTC (rev
34183)
@@ -322,11 +322,6 @@
{
/**
- * Message header
- */
- struct GNUNET_MessageHeader header;
-
- /**
* Hash of sensor name
*/
struct GNUNET_HashCode sensorname_hash;
@@ -495,7 +490,6 @@
* @param block The block received and needs to be verified
* @param matching_bits Number of leading zeros in the hash used to verify pow
* @param public_key Public key of the peer that sent this block
- * @param purpose Expected signing purpose
* @param payload Where to store the pointer to the payload
* @return Size of the payload
*/
@@ -503,8 +497,7 @@
GNUNET_SENSOR_crypto_verify_pow_sign (struct GNUNET_SENSOR_crypto_pow_block *
block, int matching_bits,
struct GNUNET_CRYPTO_EddsaPublicKey *
- public_key, uint32_t purpose,
- void **payload);
+ public_key, void **payload);
#if 0 /* keep Emacsens' auto-indent happy */
Modified: gnunet/src/sensor/gnunet-service-sensor_reporting.c
===================================================================
--- gnunet/src/sensor/gnunet-service-sensor_reporting.c 2014-08-20 13:40:10 UTC
(rev 34182)
+++ gnunet/src/sensor/gnunet-service-sensor_reporting.c 2014-08-20 14:05:05 UTC
(rev 34183)
@@ -34,6 +34,35 @@
#define LOG(kind,...) GNUNET_log_from (kind, "sensor-reporting",__VA_ARGS__)
+/**
+ * When we are still generating a proof-of-work and we need to send an anomaly
+ * report, we queue them until the generation is complete
+ */
+struct AnomalyReportingQueueItem
+{
+
+ /**
+ * DLL
+ */
+ struct AnomalyReportingQueueItem *prev;
+
+ /**
+ * DLL
+ */
+ struct AnomalyReportingQueueItem *next;
+
+ /**
+ * Message queue belonging to the peer that is the destination of the report
+ */
+ struct GNUNET_MQ_Handle *dest_mq;
+
+ /**
+ * Report type
+ */
+ int type;
+
+};
+
struct AnomalyInfo
{
@@ -62,6 +91,26 @@
*/
struct GNUNET_CONTAINER_MultiPeerMap *anomalous_neighbors;
+ /**
+ * Report block with proof-of-work and signature
+ */
+ struct GNUNET_SENSOR_crypto_pow_block *report_block;
+
+ /**
+ * Context of an operation creating pow and signature
+ */
+ struct GNUNET_SENSOR_crypto_pow_context *report_creation_cx;
+
+ /**
+ * Head of the queue of pending report destinations
+ */
+ struct AnomalyReportingQueueItem *reporting_queue_head;
+
+ /**
+ * Head of the queue of pending report destinations
+ */
+ struct AnomalyReportingQueueItem *reporting_queue_tail;
+
};
struct ValueInfo
@@ -214,6 +263,11 @@
static struct GNUNET_PeerIdentity mypeerid;
/**
+ * My private key
+ */
+static struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
+
+/**
* Head of DLL of anomaly info structs
*/
static struct AnomalyInfo *ai_head;
@@ -263,8 +317,13 @@
*/
static int neighborhood;
+/**
+ * Parameter that defines the complexity of the proof-of-work
+ */
+static long long unsigned int pow_matching_bits;
+
/******************************************************************************/
/****************************** CLEANUP
******************************/
/******************************************************************************/
@@ -277,8 +336,31 @@
static void
destroy_anomaly_info (struct AnomalyInfo *ai)
{
+ struct AnomalyReportingQueueItem *ar_item;
+
+ ar_item = ai->reporting_queue_head;
+ while (NULL != ar_item)
+ {
+ GNUNET_CONTAINER_DLL_remove (ai->reporting_queue_head,
+ ai->reporting_queue_tail, ar_item);
+ GNUNET_free (ar_item);
+ ar_item = ai->reporting_queue_head;
+ }
+ if (NULL != ai->report_creation_cx)
+ {
+ GNUNET_SENSOR_crypto_pow_sign_cancel (ai->report_creation_cx);
+ ai->report_creation_cx = NULL;
+ }
+ if (NULL != ai->report_block)
+ {
+ GNUNET_free (ai->report_block);
+ ai->report_block = NULL;
+ }
if (NULL != ai->anomalous_neighbors)
+ {
GNUNET_CONTAINER_multipeermap_destroy (ai->anomalous_neighbors);
+ ai->anomalous_neighbors = NULL;
+ }
GNUNET_free (ai);
}
@@ -488,20 +570,135 @@
/**
- * Create an anomaly report message from a given anomaly info struct inside a
- * MQ envelope.
+ * This function is called only when we have a block ready and want to send it
+ * to the given peer (represented by its message queue)
*
- * @param ai Anomaly info struct to use
+ * @param mq Message queue to put the message in
+ * @param ai Anomaly info to report
* @param type Message type
- * @return Envelope with message
*/
-static struct GNUNET_MQ_Envelope *
-create_anomaly_report_message (struct AnomalyInfo *ai, int type)
+static void
+do_send_anomaly_report (struct GNUNET_MQ_Handle *mq, struct AnomalyInfo *ai,
+ int type)
{
- struct GNUNET_SENSOR_AnomalyReportMessage *arm;
+ struct GNUNET_MessageHeader *msg;
struct GNUNET_MQ_Envelope *ev;
+ size_t block_size;
- ev = GNUNET_MQ_msg (arm, type);
+ GNUNET_assert (NULL != ai->report_block);
+ block_size =
+ sizeof (struct GNUNET_SENSOR_crypto_pow_block) +
+ ai->report_block->msg_size;
+ ev = GNUNET_MQ_msg_header_extra (msg, block_size, type);
+ memcpy (&msg[1], ai->report_block, block_size);
+ GNUNET_MQ_send (mq, ev);
+}
+
+
+/**
+ * Check if we have signed and proof-of-work block ready.
+ * If yes, we send the report directly, if no, we enqueue the reporting until
+ * the block is ready.
+ *
+ * @param mq Message queue to put the message in
+ * @param ai Anomaly info to report
+ * @param p2p Is the report sent to a neighboring peer
+ */
+static void
+send_anomaly_report (struct GNUNET_MQ_Handle *mq, struct AnomalyInfo *ai,
+ int p2p)
+{
+ struct AnomalyReportingQueueItem *ar_item;
+ int type;
+
+ type =
+ (GNUNET_YES ==
+ p2p) ? GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT_P2P :
+ GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT;
+ if (NULL == ai->report_block)
+ {
+ ar_item = GNUNET_new (struct AnomalyReportingQueueItem);
+
+ ar_item->dest_mq = mq;
+ ar_item->type = type;
+ GNUNET_CONTAINER_DLL_insert_tail (ai->reporting_queue_head,
+ ai->reporting_queue_tail, ar_item);
+ }
+ else
+ {
+ do_send_anomaly_report (mq, ai, type);
+ }
+}
+
+
+/**
+ * Callback when the crypto module finished created proof-of-work and signature
+ * for an anomaly report.
+ *
+ * @param cls Closure, a `struct AnomalyInfo *`
+ * @param block The resulting block, NULL on error
+ */
+static void
+report_creation_cb (void *cls, struct GNUNET_SENSOR_crypto_pow_block *block)
+{
+ struct AnomalyInfo *ai = cls;
+ struct AnomalyReportingQueueItem *ar_item;
+
+ ai->report_creation_cx = NULL;
+ if (NULL != ai->report_block)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("Double creation of proof-of-work, this should not happen.\n"));
+ return;
+ }
+ if (NULL == block)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to create pow and signature block.\n"));
+ return;
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Anomaly report POW block ready.\n");
+ ai->report_block = block;
+ ar_item = ai->reporting_queue_head;
+ while (NULL != ar_item)
+ {
+ GNUNET_CONTAINER_DLL_remove (ai->reporting_queue_head,
+ ai->reporting_queue_tail, ar_item);
+ do_send_anomaly_report (ar_item->dest_mq, ai, ar_item->type);
+ GNUNET_free (ar_item);
+ ar_item = ai->reporting_queue_head;
+ }
+}
+
+
+/**
+ * When a change to the anomaly info of a sensor is done, this function should
+ * be called to create the message, its proof-of-work and signuature ready to
+ * be sent to other peers or collection point.
+ *
+ * @param ai Anomaly Info struct
+ */
+static void
+update_anomaly_report_pow_block (struct AnomalyInfo *ai)
+{
+ struct GNUNET_SENSOR_AnomalyReportMessage *arm;
+ struct GNUNET_TIME_Absolute timestamp;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Updating anomaly report POW block due to data change.\n");
+ if (NULL != ai->report_block)
+ {
+ GNUNET_free (ai->report_block);
+ ai->report_block = NULL;
+ }
+ if (NULL != ai->report_creation_cx)
+ {
+ /* If a creation is already running, cancel it because the data changed */
+ GNUNET_SENSOR_crypto_pow_sign_cancel (ai->report_creation_cx);
+ ai->report_creation_cx = NULL;
+ }
+ arm = GNUNET_new (struct GNUNET_SENSOR_AnomalyReportMessage);
+
GNUNET_CRYPTO_hash (ai->sensor->name, strlen (ai->sensor->name) + 1,
&arm->sensorname_hash);
arm->sensorversion_major = htons (ai->sensor->version_major);
@@ -512,7 +709,14 @@
neighborhood) ? 0 : ((float)
GNUNET_CONTAINER_multipeermap_size
(ai->anomalous_neighbors)) / neighborhood;
- return ev;
+ timestamp = GNUNET_TIME_absolute_get ();
+ ai->report_creation_cx =
+ GNUNET_SENSOR_crypto_pow_sign (arm,
+ sizeof (struct
+
GNUNET_SENSOR_AnomalyReportMessage),
+ ×tamp, &mypeerid.public_key,
+ private_key, pow_matching_bits,
+ &report_creation_cb, ai);
}
@@ -542,29 +746,6 @@
}
-/**
- * Send given anomaly info report by putting it in the given message queue.
- *
- * @param mq Message queue to put the message in
- * @param ai Anomaly info to report
- * @param p2p Is the report sent to a neighboring peer
- */
-static void
-send_anomaly_report (struct GNUNET_MQ_Handle *mq, struct AnomalyInfo *ai,
- int p2p)
-{
- struct GNUNET_MQ_Envelope *ev;
- int type;
-
- type =
- (GNUNET_YES ==
- p2p) ? GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT_P2P :
- GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT;
- ev = create_anomaly_report_message (ai, type);
- GNUNET_MQ_send (mq, ev);
-}
-
-
/******************************************************************************/
/*************************** CORE Handlers
***************************/
/******************************************************************************/
@@ -583,6 +764,7 @@
handle_anomaly_report (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message)
{
+ struct GNUNET_SENSOR_crypto_pow_block *report_block;
struct GNUNET_SENSOR_AnomalyReportMessage *arm;
struct GNUNET_SENSOR_SensorInfo *sensor;
struct AnomalyInfo *my_anomaly_info;
@@ -590,7 +772,21 @@
int peer_anomalous;
int peer_in_anomalous_list;
- arm = (struct GNUNET_SENSOR_AnomalyReportMessage *) message;
+ /* Verify proof-of-work, signature and extract report message */
+ report_block = (struct GNUNET_SENSOR_crypto_pow_block *) &message[1];
+ if (sizeof (struct GNUNET_SENSOR_AnomalyReportMessage) !=
+ GNUNET_SENSOR_crypto_verify_pow_sign (report_block, pow_matching_bits,
+ (struct
GNUNET_CRYPTO_EddsaPublicKey
+ *) &other->public_key,
+ (void **) &arm))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Received invalid anomaly report from peer `%s'.\n",
+ GNUNET_i2s (other));
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ /* Now we parse the content of the message */
sensor = GNUNET_CONTAINER_multihashmap_get (sensors, &arm->sensorname_hash);
if (NULL == sensor ||
sensor->version_major != ntohs (arm->sensorversion_major) ||
@@ -627,6 +823,8 @@
GNUNET_CONTAINER_multipeermap_remove_all
(my_anomaly_info->anomalous_neighbors, other);
}
+ /* This is important to create an updated block since the data changed */
+ update_anomaly_report_pow_block (my_anomaly_info);
/* Send anomaly update to collection point only if I have the same anomaly */
if (GNUNET_YES == my_anomaly_info->anomalous &&
NULL != sensor->collection_point &&
@@ -839,6 +1037,8 @@
ai = get_anomaly_info_by_sensor (sensor);
GNUNET_assert (NULL != ai);
ai->anomalous = anomalous;
+ /* This is important to create an updated block since the data changed */
+ update_anomaly_report_pow_block (ai);
/* Report change to all neighbors */
corep = corep_head;
while (NULL != corep)
@@ -928,6 +1128,8 @@
ai->anomalous = GNUNET_NO;
ai->anomalous_neighbors =
GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
+ ai->report_block = NULL;
+ ai->report_creation_cx = NULL;
GNUNET_CONTAINER_DLL_insert (ai_head, ai_tail, ai);
/* Create sensor value info context (if needed to be reported) */
if (NULL == sensor->collection_point || GNUNET_NO == sensor->report_values)
@@ -966,6 +1168,8 @@
{
static struct GNUNET_CORE_MessageHandler core_handlers[] = {
{&handle_anomaly_report, GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT_P2P,
+ sizeof (struct GNUNET_MessageHeader) +
+ sizeof (struct GNUNET_SENSOR_crypto_pow_block) +
sizeof (struct GNUNET_SENSOR_AnomalyReportMessage)},
{NULL, 0, 0}
};
@@ -977,6 +1181,23 @@
GNUNET_assert (NULL != s);
sensors = s;
cfg = c;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "sensor-reporting",
+ "POW_MATCHING_BITS",
+ &pow_matching_bits))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "sensor-reporting",
+ "POW_MATCHING_BITS");
+ SENSOR_reporting_stop ();
+ return GNUNET_SYSERR;
+ }
+ if (pow_matching_bits > sizeof (struct GNUNET_HashCode))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Matching bits value too large (%d > %d).\n",
+ pow_matching_bits, sizeof (struct GNUNET_HashCode));
+ SENSOR_reporting_stop ();
+ return GNUNET_SYSERR;
+ }
/* Connect to PEERSTORE */
peerstore = GNUNET_PEERSTORE_connect (cfg);
if (NULL == peerstore)
@@ -1007,6 +1228,13 @@
SENSOR_reporting_stop ();
return GNUNET_SYSERR;
}
+ private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
+ if (NULL == private_key)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, _("Failed to load my private key.\n"));
+ SENSOR_reporting_stop ();
+ return GNUNET_SYSERR;
+ }
GNUNET_CRYPTO_get_peer_identity (cfg, &mypeerid);
GNUNET_CONTAINER_multihashmap_iterate (sensors, &init_sensor_reporting,
NULL);
neighborhood = 0;
Modified: gnunet/src/sensor/gnunet-service-sensor_update.c
===================================================================
--- gnunet/src/sensor/gnunet-service-sensor_update.c 2014-08-20 13:40:10 UTC
(rev 34182)
+++ gnunet/src/sensor/gnunet-service-sensor_update.c 2014-08-20 14:05:05 UTC
(rev 34183)
@@ -452,8 +452,8 @@
int count = 0;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, "sensor", "UPDATE_POINTS",
- &points_list))
+ GNUNET_CONFIGURATION_get_value_string (cfg, "sensor-update",
+ "UPDATE_POINTS", &points_list))
{
return 0;
}
Modified: gnunet/src/sensor/sensor.conf.in
===================================================================
--- gnunet/src/sensor/sensor.conf.in 2014-08-20 13:40:10 UTC (rev 34182)
+++ gnunet/src/sensor/sensor.conf.in 2014-08-20 14:05:05 UTC (rev 34183)
@@ -15,9 +15,6 @@
# If not set, will load from default location.
#SENSOR_DIR =
-# Space separated list of trusted peers running update points
-UPDATE_POINTS =
-
[sensor-analysis]
MODEL = gaussian
# How many subsequent values required to flip anomaly label. (Default: 1)
@@ -27,3 +24,10 @@
[sensor-model-gaussian]
TRAINING_WINDOW = 1000
CONFIDENCE_INTERVAL = 3
+
+[sensor-reporting]
+POW_MATCHING_BITS = 15
+
+[sensor-update]
+# Space separated list of trusted peers running update points
+UPDATE_POINTS =
Modified: gnunet/src/sensor/sensor_util_lib_crypto.c
===================================================================
--- gnunet/src/sensor/sensor_util_lib_crypto.c 2014-08-20 13:40:10 UTC (rev
34182)
+++ gnunet/src/sensor/sensor_util_lib_crypto.c 2014-08-20 14:05:05 UTC (rev
34183)
@@ -257,7 +257,6 @@
* @param block The block received and needs to be verified
* @param matching_bits Number of leading zeros in the hash used to verify pow
* @param public_key Public key of the peer that sent this block
- * @param purpose Expected signing purpose
* @param payload Where to store the pointer to the payload
* @return Size of the payload
*/
@@ -265,8 +264,7 @@
GNUNET_SENSOR_crypto_verify_pow_sign (struct GNUNET_SENSOR_crypto_pow_block *
block, int matching_bits,
struct GNUNET_CRYPTO_EddsaPublicKey *
- public_key, uint32_t purpose,
- void **payload)
+ public_key, void **payload)
{
/* Check public key */
if (0 !=
@@ -278,8 +276,9 @@
}
/* Check signature */
if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (purpose, &block->purpose, &block->signature,
- public_key))
+ GNUNET_CRYPTO_eddsa_verify
+ (GNUNET_SIGNATURE_PURPOSE_SENSOR_ANOMALY_REPORT, &block->purpose,
+ &block->signature, public_key))
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Invalid signature.\n");
return 0;
Modified: gnunet/src/sensor/test_pow_sign.c
===================================================================
--- gnunet/src/sensor/test_pow_sign.c 2014-08-20 13:40:10 UTC (rev 34182)
+++ gnunet/src/sensor/test_pow_sign.c 2014-08-20 14:05:05 UTC (rev 34183)
@@ -76,12 +76,12 @@
/**
* Private key of sending peer
*/
-struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
+static struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
/**
* Public key of sending peer
*/
-struct GNUNET_CRYPTO_EddsaPublicKey *public_key;
+static struct GNUNET_CRYPTO_EddsaPublicKey *public_key;
/**
@@ -117,17 +117,13 @@
/* Test that the block is valid */
GNUNET_assert (MSG_SIZE ==
GNUNET_SENSOR_crypto_verify_pow_sign (block, MATCHING_BITS,
- public_key,
-
GNUNET_SIGNATURE_PURPOSE_SENSOR_ANOMALY_REPORT,
- &response));
+ public_key, &response));
GNUNET_assert (0 == memcmp (msg, response, MSG_SIZE));
/* Modify the payload and test that verification returns invalid */
block->pow++;
GNUNET_assert (0 ==
GNUNET_SENSOR_crypto_verify_pow_sign (block, MATCHING_BITS,
- public_key,
-
GNUNET_SIGNATURE_PURPOSE_SENSOR_ANOMALY_REPORT,
- &response));
+ public_key, &response));
ok = 0;
GNUNET_SCHEDULER_cancel (shutdown_task);
GNUNET_SCHEDULER_add_now (do_shutdown, NULL);
Modified: gnunet/src/sensordashboard/gnunet-service-sensordashboard.c
===================================================================
--- gnunet/src/sensordashboard/gnunet-service-sensordashboard.c 2014-08-20
13:40:10 UTC (rev 34182)
+++ gnunet/src/sensordashboard/gnunet-service-sensordashboard.c 2014-08-20
14:05:05 UTC (rev 34183)
@@ -175,7 +175,12 @@
*/
static struct ClientPeerContext *cp_tail;
+/**
+ * Parameter that defines the complexity of the proof-of-work
+ */
+static long long unsigned int pow_matching_bits;
+
/**
* Trigger sending next pending message to the given client peer if any.
*
@@ -419,6 +424,7 @@
const struct GNUNET_MessageHeader *message)
{
struct ClientPeerContext *cp = *channel_ctx;
+ struct GNUNET_SENSOR_crypto_pow_block *report_block;
struct GNUNET_SENSOR_AnomalyReportMessage *anomaly_msg;
struct GNUNET_SENSOR_SensorInfo *sensor;
struct GNUNET_SENSOR_DashboardAnomalyEntry *anomaly_entry;
@@ -427,7 +433,18 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received an anomaly report message from peer `%s'.\n",
GNUNET_i2s (&cp->peerid));
- anomaly_msg = (struct GNUNET_SENSOR_AnomalyReportMessage *) message;
+ report_block = (struct GNUNET_SENSOR_crypto_pow_block *) &message[1];
+ if (sizeof (struct GNUNET_SENSOR_AnomalyReportMessage) !=
+ GNUNET_SENSOR_crypto_verify_pow_sign (report_block, pow_matching_bits,
+ &cp->peerid.public_key,
+ (void **) &anomaly_msg))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Received invalid anomaly report from peer `%s'.\n",
+ GNUNET_i2s (&cp->peerid));
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
sensor =
GNUNET_CONTAINER_multihashmap_get (sensors,
&anomaly_msg->sensorname_hash);
@@ -790,6 +807,8 @@
sizeof (struct GNUNET_MessageHeader)},
{&handle_anomaly_report,
GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT,
+ sizeof (struct GNUNET_MessageHeader) +
+ sizeof (struct GNUNET_SENSOR_crypto_pow_block) +
sizeof (struct GNUNET_SENSOR_AnomalyReportMessage)},
{NULL, 0, 0}
};
@@ -805,6 +824,26 @@
sensor_dir = GNUNET_SENSOR_get_default_sensor_dir ();
sensors = GNUNET_SENSOR_load_all_sensors (sensor_dir);
GNUNET_assert (NULL != sensors);
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "sensor-reporting",
+ "POW_MATCHING_BITS",
+ &pow_matching_bits))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "sensor-reporting",
+ "POW_MATCHING_BITS");
+ GNUNET_SCHEDULER_add_now (&cleanup_task, NULL);
+ return;
+ }
+ if (pow_matching_bits > sizeof (struct GNUNET_HashCode))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Matching bits value too large (%d > %d).\n",
pow_matching_bits,
+ sizeof (struct GNUNET_HashCode));
+ GNUNET_SCHEDULER_add_now (&cleanup_task, NULL);
+ return;
+ }
+
cadet =
GNUNET_CADET_connect (cfg, NULL, &cadet_channel_created,
&cadet_channel_destroyed, cadet_handlers,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34183 - in gnunet/src: include sensor sensordashboard,
gnunet <=