-fix ftbfs
[oweals/gnunet.git] / src / sensor / gnunet-service-sensor_analysis.c
index 63249a4e2ad5ed3adc21c7be38c2242fee6c4c76..6412031cb06db043a49802872a5b84cf0e5452b2 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C)
+     Copyright (C)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -86,6 +86,11 @@ struct SensorModel
  */
 static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
+/**
+ * Hashmap of loaded sensors
+ */
+static struct GNUNET_CONTAINER_MultiHashMap *sensors;
+
 /*
  * Model library name
  */
@@ -114,13 +119,13 @@ static struct SensorModel *models_tail;
 /**
  * My peer id
  */
-struct GNUNET_PeerIdentity peerid;
+static struct GNUNET_PeerIdentity peerid;
 
 /**
  * How many subsequent values required to flip anomaly label.
  * E.g. After 3 subsequent anomaly reports, status change to anomalous.
  */
-unsigned long long confirmation_count;
+static unsigned long long confirmation_count;
 
 /**
  * Destroy a created model
@@ -184,7 +189,9 @@ SENSOR_analysis_stop ()
  * @return #GNUNET_YES
  */
 static int
-sensor_watcher (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+sensor_watcher (void *cls,
+                const struct GNUNET_PEERSTORE_Record *record,
+                const char *emsg)
 {
   struct SensorModel *model = cls;
   double *val;
@@ -208,7 +215,8 @@ sensor_watcher (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
     {
       model->anomalous = GNUNET_YES;
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           "Anomaly state started for sensor `%s'.\n", model->sensor->name);
+           "Anomaly state started for sensor `%s', value: %f.\n",
+           model->sensor->name, val);
       SENSOR_reporting_anomaly_update (model->sensor, model->anomalous);
     }
   }
@@ -220,8 +228,9 @@ sensor_watcher (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
         model->negative_count >= confirmation_count)
     {
       model->anomalous = GNUNET_NO;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Anomaly state stopped for sensor `%s'.\n",
-           model->sensor->name);
+      LOG (GNUNET_ERROR_TYPE_INFO,
+          "Anomaly state stopped for sensor `%s', value: %f.\n",
+           model->sensor->name, val);
       SENSOR_reporting_anomaly_update (model->sensor, model->anomalous);
     }
   }
@@ -271,12 +280,13 @@ init_sensor_model (void *cls, const struct GNUNET_HashCode *key, void *value)
  */
 int
 SENSOR_analysis_start (const struct GNUNET_CONFIGURATION_Handle *c,
-                       struct GNUNET_CONTAINER_MultiHashMap *sensors)
+                       struct GNUNET_CONTAINER_MultiHashMap *s)
 {
   char *model_name;
 
-  GNUNET_assert (NULL != sensors);
+  GNUNET_assert (NULL != s);
   cfg = c;
+  sensors = s;
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "sensor-analysis", "MODEL",
                                              &model_name))