/*
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
}
+/**
+ * Handle a force anomaly request from client.
+ *
+ * @param cls closure
+ * @param client identification of the client
+ * @param message the actual message
+ */
+static void
+handle_anomaly_force (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct ForceAnomalyMessage *anomaly_msg;
+ struct GNUNET_SENSOR_SensorInfo *sensor;
+
+ anomaly_msg = (struct ForceAnomalyMessage *) message;
+ sensor =
+ GNUNET_CONTAINER_multihashmap_get (sensors,
+ &anomaly_msg->sensor_name_hash);
+ if (NULL == sensor)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Force anomaly message received for a sensor we don't have.\n");
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ SENSOR_reporting_anomaly_update (sensor, ntohs (anomaly_msg->anomalous));
+ GNUNET_SERVER_receive_done (client, GNUNET_YES);
+}
+
+
/**
* Creates a structure with basic sensor info to be sent to a client.
*
0},
{&handle_get_all_sensors, NULL, GNUNET_MESSAGE_TYPE_SENSOR_GETALL,
sizeof (struct GNUNET_MessageHeader)},
+ {
+ &handle_anomaly_force, NULL, GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_FORCE,
+ sizeof (struct ForceAnomalyMessage)},
{NULL, NULL, 0, 0}
};
cfg = c;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg, "SENSOR", "SENSOR_DIR",
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "sensor", "SENSOR_DIR",
&sensor_dir))
{
sensor_dir = GNUNET_SENSOR_get_default_sensor_dir ();
start_reporting = GNUNET_YES;
start_update = GNUNET_YES;
if (GNUNET_NO ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, "SENSOR", "START_MONITORING"))
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, "sensor", "START_MONITORING"))
{
start_monitoring = GNUNET_NO;
}
if (GNUNET_NO ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, "SENSOR", "START_REPORTING"))
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, "sensor", "START_REPORTING"))
{
start_reporting = GNUNET_NO;
}
if (GNUNET_NO ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, "SENSOR", "START_ANALYSIS"))
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, "sensor", "START_ANALYSIS"))
{
start_analysis = GNUNET_NO;
}
if (GNUNET_NO ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, "SENSOR", "START_UPDATE"))
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, "sensor", "START_UPDATE"))
{
start_update = GNUNET_NO;
}