diff options
Diffstat (limited to 'src/sensordashboard/gnunet-service-sensordashboard.c')
-rw-r--r-- | src/sensordashboard/gnunet-service-sensordashboard.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/sensordashboard/gnunet-service-sensordashboard.c b/src/sensordashboard/gnunet-service-sensordashboard.c index 7dc1b33d6..1af3be332 100644 --- a/src/sensordashboard/gnunet-service-sensordashboard.c +++ b/src/sensordashboard/gnunet-service-sensordashboard.c | |||
@@ -421,9 +421,12 @@ handle_anomaly_report (void *cls, struct GNUNET_CADET_Channel *channel, | |||
421 | struct ClientPeerContext *cp = *channel_ctx; | 421 | struct ClientPeerContext *cp = *channel_ctx; |
422 | struct GNUNET_SENSOR_AnomalyReportMessage *anomaly_msg; | 422 | struct GNUNET_SENSOR_AnomalyReportMessage *anomaly_msg; |
423 | struct GNUNET_SENSOR_SensorInfo *sensor; | 423 | struct GNUNET_SENSOR_SensorInfo *sensor; |
424 | uint16_t anomalous; | 424 | struct GNUNET_SENSOR_DashboardAnomalyEntry *anomaly_entry; |
425 | struct GNUNET_TIME_Absolute expiry; | 425 | struct GNUNET_TIME_Absolute expiry; |
426 | 426 | ||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
428 | "Received an anomaly report message from peer `%s'.\n", | ||
429 | GNUNET_i2s (&cp->peerid)); | ||
427 | anomaly_msg = (struct GNUNET_SENSOR_AnomalyReportMessage *) message; | 430 | anomaly_msg = (struct GNUNET_SENSOR_AnomalyReportMessage *) message; |
428 | sensor = | 431 | sensor = |
429 | GNUNET_CONTAINER_multihashmap_get (sensors, | 432 | GNUNET_CONTAINER_multihashmap_get (sensors, |
@@ -433,13 +436,20 @@ handle_anomaly_report (void *cls, struct GNUNET_CADET_Channel *channel, | |||
433 | GNUNET_break_op (0); | 436 | GNUNET_break_op (0); |
434 | return GNUNET_SYSERR; | 437 | return GNUNET_SYSERR; |
435 | } | 438 | } |
436 | anomalous = ntohs (anomaly_msg->anomalous); | 439 | anomaly_entry = GNUNET_new (struct GNUNET_SENSOR_DashboardAnomalyEntry); |
440 | anomaly_entry->anomalous = ntohs (anomaly_msg->anomalous); | ||
441 | anomaly_entry->anomalous_neighbors = anomaly_msg->anomalous_neighbors; | ||
437 | expiry = | 442 | expiry = |
438 | (GNUNET_YES == | 443 | (GNUNET_YES == |
439 | anomalous) ? GNUNET_TIME_UNIT_FOREVER_ABS : GNUNET_TIME_absolute_get (); | 444 | anomaly_entry->anomalous) ? GNUNET_TIME_UNIT_FOREVER_ABS : |
445 | GNUNET_TIME_absolute_get (); | ||
440 | GNUNET_PEERSTORE_store (peerstore, anomalies_subsystem, &cp->peerid, | 446 | GNUNET_PEERSTORE_store (peerstore, anomalies_subsystem, &cp->peerid, |
441 | sensor->name, &anomalous, sizeof (anomalous), expiry, | 447 | sensor->name, anomaly_entry, |
442 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); | 448 | sizeof (struct GNUNET_SENSOR_DashboardAnomalyEntry), |
449 | expiry, GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, | ||
450 | NULL); | ||
451 | GNUNET_free (anomaly_entry); | ||
452 | GNUNET_CADET_receive_done (channel); | ||
443 | return GNUNET_OK; | 453 | return GNUNET_OK; |
444 | } | 454 | } |
445 | 455 | ||