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 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.
17 * @author Omar Tarabai
20 * API to the sensor service
22 * @defgroup sensor Sensor service
27 #ifndef GNUNET_SENSOR_SERVICE_H
28 #define GNUNET_SENSOR_SERVICE_H
30 #include "gnunet_common.h"
31 #include "gnunet_util_lib.h"
36 #if 0 /* keep Emacsens' auto-indent happy */
43 * Handle to the sensor service.
45 struct GNUNET_SENSOR_Handle;
48 * Context for an iteration request.
50 struct GNUNET_SENSOR_IterateContext;
53 * Context of a force anomaly request
55 struct GNUNET_SENSOR_ForceAnomalyContext;
58 * Structure containing brief info about sensor
60 struct SensorInfoShort
69 * First part of version number
71 uint16_t version_major;
74 * Second part of version number
76 uint16_t version_minor;
86 * Sensor iterate request callback.
89 * @param sensor Brief sensor information
90 * @param error message
92 typedef void (*GNUNET_SENSOR_SensorIterateCB) (void *cls,
93 const struct SensorInfoShort *
94 sensor, const char *err_msg);
98 * Continuation called with a status result.
101 * @param emsg error message, NULL on success
103 typedef void (*GNUNET_SENSOR_Continuation) (void *cls, const char *emsg);
107 * Disconnect from the sensor service
109 * @param h handle to disconnect
112 GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h);
116 * Connect to the sensor service.
118 * @return NULL on error
120 struct GNUNET_SENSOR_Handle *
121 GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
125 * Cancel an iteration request.
126 * This should be called before the iterate callback is called with a NULL value.
128 * @param ic context of the iterator to cancel
131 GNUNET_SENSOR_iterate_cancel (struct GNUNET_SENSOR_IterateContext
136 * Get one or all sensors loaded by the sensor service.
137 * The callback will be called with each sensor received and once with a NULL
138 * value to signal end of iteration.
140 * @param h Handle to SENSOR service
141 * @param timeout how long to wait until timing out
142 * @param sensorname Name of the required sensor, NULL to get all
143 * @param callback the function to call for each sensor
144 * @param callback_cls closure for callback
145 * @return iterator context
147 struct GNUNET_SENSOR_IterateContext *
148 GNUNET_SENSOR_iterate (struct GNUNET_SENSOR_Handle *h,
149 struct GNUNET_TIME_Relative timeout,
150 const char *sensor_name,
151 GNUNET_SENSOR_SensorIterateCB callback,
156 * Cancel a force anomaly request.
158 * @param fa Force anomaly context returned by GNUNET_SENSOR_force_anomaly()
161 GNUNET_SENSOR_force_anomaly_cancel (struct GNUNET_SENSOR_ForceAnomalyContext
166 * Force an anomaly status change on a given sensor. If the sensor reporting
167 * module is running, this will trigger the usual reporting logic, therefore,
168 * please only use this in a test environment.
170 * Also, if the sensor analysis module is running, it might conflict and cause
171 * undefined behaviour if it detects a real anomaly.
173 * @param h Service handle
174 * @param sensor_name Sensor name to set the anomaly status
175 * @param anomalous The desired status: #GNUNET_YES / #GNUNET_NO
176 * @param cont Continuation function to be called after the request is sent
177 * @param cont_cls Closure for cont
179 struct GNUNET_SENSOR_ForceAnomalyContext *
180 GNUNET_SENSOR_force_anomaly (struct GNUNET_SENSOR_Handle *h, char *sensor_name,
181 int anomalous, GNUNET_SENSOR_Continuation cont,
185 #if 0 /* keep Emacsens' auto-indent happy */
194 /** @} */ /* end of group */