2 This file is part of GNUnet
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Omar Tarabai
23 * API to the sensor service
25 * @defgroup sensor Sensor service
30 #ifndef GNUNET_SENSOR_SERVICE_H
31 #define GNUNET_SENSOR_SERVICE_H
33 #include "gnunet_common.h"
34 #include "gnunet_util_lib.h"
39 #if 0 /* keep Emacsens' auto-indent happy */
46 * Handle to the sensor service.
48 struct GNUNET_SENSOR_Handle;
51 * Context for an iteration request.
53 struct GNUNET_SENSOR_IterateContext;
56 * Context of a force anomaly request
58 struct GNUNET_SENSOR_ForceAnomalyContext;
61 * Structure containing brief info about sensor
63 struct SensorInfoShort
72 * First part of version number
74 uint16_t version_major;
77 * Second part of version number
79 uint16_t version_minor;
89 * Sensor iterate request callback.
92 * @param sensor Brief sensor information
93 * @param error message
95 typedef void (*GNUNET_SENSOR_SensorIterateCB) (void *cls,
96 const struct SensorInfoShort *
97 sensor, const char *err_msg);
101 * Continuation called with a status result.
104 * @param emsg error message, NULL on success
106 typedef void (*GNUNET_SENSOR_Continuation) (void *cls, const char *emsg);
110 * Disconnect from the sensor service
112 * @param h handle to disconnect
115 GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h);
119 * Connect to the sensor service.
121 * @return NULL on error
123 struct GNUNET_SENSOR_Handle *
124 GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
128 * Cancel an iteration request.
129 * This should be called before the iterate callback is called with a NULL value.
131 * @param ic context of the iterator to cancel
134 GNUNET_SENSOR_iterate_cancel (struct GNUNET_SENSOR_IterateContext
139 * Get one or all sensors loaded by the sensor service.
140 * The callback will be called with each sensor received and once with a NULL
141 * value to signal end of iteration.
143 * @param h Handle to SENSOR service
144 * @param timeout how long to wait until timing out
145 * @param sensorname Name of the required sensor, NULL to get all
146 * @param callback the function to call for each sensor
147 * @param callback_cls closure for callback
148 * @return iterator context
150 struct GNUNET_SENSOR_IterateContext *
151 GNUNET_SENSOR_iterate (struct GNUNET_SENSOR_Handle *h,
152 struct GNUNET_TIME_Relative timeout,
153 const char *sensor_name,
154 GNUNET_SENSOR_SensorIterateCB callback,
159 * Cancel a force anomaly request.
161 * @param fa Force anomaly context returned by GNUNET_SENSOR_force_anomaly()
164 GNUNET_SENSOR_force_anomaly_cancel (struct GNUNET_SENSOR_ForceAnomalyContext
169 * Force an anomaly status change on a given sensor. If the sensor reporting
170 * module is running, this will trigger the usual reporting logic, therefore,
171 * please only use this in a test environment.
173 * Also, if the sensor analysis module is running, it might conflict and cause
174 * undefined behaviour if it detects a real anomaly.
176 * @param h Service handle
177 * @param sensor_name Sensor name to set the anomaly status
178 * @param anomalous The desired status: #GNUNET_YES / #GNUNET_NO
179 * @param cont Continuation function to be called after the request is sent
180 * @param cont_cls Closure for cont
182 struct GNUNET_SENSOR_ForceAnomalyContext *
183 GNUNET_SENSOR_force_anomaly (struct GNUNET_SENSOR_Handle *h, char *sensor_name,
184 int anomalous, GNUNET_SENSOR_Continuation cont,
188 #if 0 /* keep Emacsens' auto-indent happy */
197 /** @} */ /* end of group */