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 * Structure containing sensor definition
53 * The configuration handle
54 * carrying sensor information
56 struct GNUNET_CONFIGURATION_Handle *cfg;
64 * Path to definition file
69 * First part of version number
71 uint16_t version_major;
74 * Second part of version number
76 uint16_t version_minor;
84 * Sensor currently enabled
89 * Category under which the sensor falls (e.g. tcp, datastore)
94 * When does the sensor become active
96 struct GNUNET_TIME_Absolute *start_time;
99 * When does the sensor expire
101 struct GNUNET_TIME_Absolute *end_time;
104 * Time interval to collect sensor information (e.g. every 1 min)
106 struct GNUNET_TIME_Relative interval;
109 * Lifetime of an information sample after which it is deleted from storage
110 * If not supplied, will default to the interval value
112 struct GNUNET_TIME_Relative lifetime;
115 * A set of required peer capabilities for the sensor to collect meaningful information (e.g. ipv6)
120 * Either "gnunet-statistics" or external "process"
125 * Name of the GNUnet service that is the source for the gnunet-statistics entry
127 char *gnunet_stat_service;
130 * Name of the gnunet-statistics entry
132 char *gnunet_stat_name;
135 * Handle to statistics get request (OR GNUNET_SCHEDULER_NO_TASK)
137 struct GNUNET_STATISTICS_GetHandle *gnunet_stat_get_handle;
140 * Name of the external process to be executed
145 * Arguments to be passed to the external process
150 * Handle to the external process
152 struct GNUNET_OS_CommandHandle *ext_cmd;
155 * Did we already receive a value
156 * from the currently running external
157 * proccess ? #GNUNET_YES / #GNUNET_NO
159 int ext_cmd_value_received;
162 * The output datatype to be expected
164 char *expected_datatype;
167 * Peer-identity of peer running collection point
169 struct GNUNET_PeerIdentity *collection_point;
172 * Time interval to send sensor information to collection point (e.g. every 30 mins)
174 struct GNUNET_TIME_Relative collection_interval;
177 * Flag specifying if value is to be communicated to the p2p network
182 * Time interval to communicate value to the p2p network
184 struct GNUNET_TIME_Relative p2p_interval;
187 * Execution task (OR GNUNET_SCHEDULER_NO_TASK)
189 GNUNET_SCHEDULER_TaskIdentifier execution_task;
192 * Is the sensor being executed
199 * Structure containing brief info about sensor
201 struct SensorInfoShort
210 * First part of version number
212 uint16_t version_major;
215 * Second part of version number
217 uint16_t version_minor;
227 * Type of an iterator over sensor definitions.
230 * @param hello hello message for the peer (can be NULL)
231 * @param error message
233 typedef void (*GNUNET_SENSOR_SensorIteratorCB) (void *cls,
234 const struct SensorInfoShort *sensor,
235 const char *err_msg);
238 * Continuation called with a status result.
241 * @param emsg error message, NULL on success
243 typedef void (*GNUNET_SENSOR_Continuation)(void *cls,
247 * Connect to the sensor service.
249 * @return NULL on error
251 struct GNUNET_SENSOR_Handle *
252 GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
255 * Disconnect from the sensor service
257 * @param h handle to disconnect
260 GNUNET_SENSOR_disconnect(struct GNUNET_SENSOR_Handle *h);
263 * Client asking to iterate all available sensors
265 * @param h Handle to SENSOR service
266 * @param timeout how long to wait until timing out
267 * @param sensorname information on one sensor only, can be NULL to get all
268 * @param sensorname_len length of the sensorname parameter
269 * @param callback the method to call for each sensor
270 * @param callback_cls closure for callback
271 * @return iterator context
273 struct GNUNET_SENSOR_SensorIteratorContext *
274 GNUNET_SENSOR_iterate_sensors (struct GNUNET_SENSOR_Handle *h,
275 struct GNUNET_TIME_Relative timeout,
276 const char* sensorname, size_t sensorname_len,
277 GNUNET_SENSOR_SensorIteratorCB callback, void *callback_cls);
279 #if 0 /* keep Emacsens' auto-indent happy */