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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_sensor_service.h
23 * @brief API to the sensor service
24 * @author Omar Tarabai
26 #ifndef GNUNET_SENSOR_SERVICE_H
27 #define GNUNET_SENSOR_SERVICE_H
30 #include "gnunet_util_lib.h"
35 #if 0 /* keep Emacsens' auto-indent happy */
42 * Handle to the sensor service.
44 struct GNUNET_SENSOR_Handle;
47 * Context for an iteration request.
49 struct GNUNET_SENSOR_IterateContext;
52 * Context of a force anomaly request
54 struct GNUNET_SENSOR_ForceAnomalyContext;
57 * Structure containing brief info about sensor
59 struct SensorInfoShort
68 * First part of version number
70 uint16_t version_major;
73 * Second part of version number
75 uint16_t version_minor;
85 * Sensor iterate request callback.
88 * @param sensor Brief sensor information
89 * @param error message
91 typedef void (*GNUNET_SENSOR_SensorIterateCB) (void *cls,
92 const struct SensorInfoShort *
93 sensor, const char *err_msg);
97 * Continuation called with a status result.
100 * @param emsg error message, NULL on success
102 typedef void (*GNUNET_SENSOR_Continuation) (void *cls, const char *emsg);
106 * Disconnect from the sensor service
108 * @param h handle to disconnect
111 GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h);
115 * Connect to the sensor service.
117 * @return NULL on error
119 struct GNUNET_SENSOR_Handle *
120 GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
124 * Cancel an iteration request.
125 * This should be called before the iterate callback is called with a NULL value.
127 * @param ic context of the iterator to cancel
130 GNUNET_SENSOR_iterate_cancel (struct GNUNET_SENSOR_IterateContext
135 * Get one or all sensors loaded by the sensor service.
136 * The callback will be called with each sensor received and once with a NULL
137 * value to signal end of iteration.
139 * @param h Handle to SENSOR service
140 * @param timeout how long to wait until timing out
141 * @param sensorname Name of the required sensor, NULL to get all
142 * @param callback the function to call for each sensor
143 * @param callback_cls closure for callback
144 * @return iterator context
146 struct GNUNET_SENSOR_IterateContext *
147 GNUNET_SENSOR_iterate (struct GNUNET_SENSOR_Handle *h,
148 struct GNUNET_TIME_Relative timeout,
149 const char *sensor_name,
150 GNUNET_SENSOR_SensorIterateCB callback,
155 * Cancel a force anomaly request.
157 * @param fa Force anomaly context returned by GNUNET_SENSOR_force_anomaly()
160 GNUNET_SENSOR_force_anomaly_cancel (struct GNUNET_SENSOR_ForceAnomalyContext
165 * Force an anomaly status change on a given sensor. If the sensor reporting
166 * module is running, this will trigger the usual reporting logic, therefore,
167 * please only use this in a test environment.
169 * Also, if the sensor analysis module is running, it might conflict and cause
170 * undefined behaviour if it detects a real anomaly.
172 * @param h Service handle
173 * @param sensor_name Sensor name to set the anomaly status
174 * @param anomalous The desired status: #GNUNET_YES / #GNUNET_NO
175 * @param cont Continuation function to be called after the request is sent
176 * @param cont_cls Closure for cont
178 struct GNUNET_SENSOR_ForceAnomalyContext *
179 GNUNET_SENSOR_force_anomaly (struct GNUNET_SENSOR_Handle *h, char *sensor_name,
180 int anomalous, GNUNET_SENSOR_Continuation cont,
183 #if 0 /* keep Emacsens' auto-indent happy */