2 This file is part of GNUnet
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Omar Tarabai
25 * API to the sensor service
27 * @defgroup sensor Sensor service
32 #ifndef GNUNET_SENSOR_SERVICE_H
33 #define GNUNET_SENSOR_SERVICE_H
36 #include "gnunet_util_lib.h"
41 #if 0 /* keep Emacsens' auto-indent happy */
48 * Handle to the sensor service.
50 struct GNUNET_SENSOR_Handle;
53 * Context for an iteration request.
55 struct GNUNET_SENSOR_IterateContext;
58 * Context of a force anomaly request
60 struct GNUNET_SENSOR_ForceAnomalyContext;
63 * Structure containing brief info about sensor
65 struct SensorInfoShort
74 * First part of version number
76 uint16_t version_major;
79 * Second part of version number
81 uint16_t version_minor;
91 * Sensor iterate request callback.
94 * @param sensor Brief sensor information
95 * @param error message
97 typedef void (*GNUNET_SENSOR_SensorIterateCB) (void *cls,
98 const struct SensorInfoShort *
99 sensor, const char *err_msg);
103 * Continuation called with a status result.
106 * @param emsg error message, NULL on success
108 typedef void (*GNUNET_SENSOR_Continuation) (void *cls, const char *emsg);
112 * Disconnect from the sensor service
114 * @param h handle to disconnect
117 GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h);
121 * Connect to the sensor service.
123 * @return NULL on error
125 struct GNUNET_SENSOR_Handle *
126 GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
130 * Cancel an iteration request.
131 * This should be called before the iterate callback is called with a NULL value.
133 * @param ic context of the iterator to cancel
136 GNUNET_SENSOR_iterate_cancel (struct GNUNET_SENSOR_IterateContext
141 * Get one or all sensors loaded by the sensor service.
142 * The callback will be called with each sensor received and once with a NULL
143 * value to signal end of iteration.
145 * @param h Handle to SENSOR service
146 * @param timeout how long to wait until timing out
147 * @param sensorname Name of the required sensor, NULL to get all
148 * @param callback the function to call for each sensor
149 * @param callback_cls closure for callback
150 * @return iterator context
152 struct GNUNET_SENSOR_IterateContext *
153 GNUNET_SENSOR_iterate (struct GNUNET_SENSOR_Handle *h,
154 struct GNUNET_TIME_Relative timeout,
155 const char *sensor_name,
156 GNUNET_SENSOR_SensorIterateCB callback,
161 * Cancel a force anomaly request.
163 * @param fa Force anomaly context returned by GNUNET_SENSOR_force_anomaly()
166 GNUNET_SENSOR_force_anomaly_cancel (struct GNUNET_SENSOR_ForceAnomalyContext
171 * Force an anomaly status change on a given sensor. If the sensor reporting
172 * module is running, this will trigger the usual reporting logic, therefore,
173 * please only use this in a test environment.
175 * Also, if the sensor analysis module is running, it might conflict and cause
176 * undefined behaviour if it detects a real anomaly.
178 * @param h Service handle
179 * @param sensor_name Sensor name to set the anomaly status
180 * @param anomalous The desired status: #GNUNET_YES / #GNUNET_NO
181 * @param cont Continuation function to be called after the request is sent
182 * @param cont_cls Closure for cont
184 struct GNUNET_SENSOR_ForceAnomalyContext *
185 GNUNET_SENSOR_force_anomaly (struct GNUNET_SENSOR_Handle *h, char *sensor_name,
186 int anomalous, GNUNET_SENSOR_Continuation cont,
190 #if 0 /* keep Emacsens' auto-indent happy */
199 /** @} */ /* end of group */