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 sensor/sensor_util_lib.c
23 * @brief senor utilities
24 * @author Omar Tarabai
27 #ifndef GNUNET_SENSOR_UTIL_LIB_H
28 #define GNUNET_SENSOR_UTIL_LIB_H
33 #if 0 /* keep Emacsens' auto-indent happy */
39 * Structure containing sensor definition
41 struct GNUNET_SENSOR_SensorInfo
45 * The configuration handle
46 * carrying sensor information
48 struct GNUNET_CONFIGURATION_Handle *cfg;
56 * Path to definition file
61 * First part of version number
63 uint16_t version_major;
66 * Second part of version number
68 uint16_t version_minor;
76 * Sensor currently enabled
81 * Category under which the sensor falls (e.g. tcp, datastore)
86 * When does the sensor become active
88 struct GNUNET_TIME_Absolute *start_time;
91 * When does the sensor expire
93 struct GNUNET_TIME_Absolute *end_time;
96 * Time interval to collect sensor information (e.g. every 1 min)
98 struct GNUNET_TIME_Relative interval;
101 * Lifetime of an information sample after which it is deleted from storage
102 * If not supplied, will default to the interval value
104 struct GNUNET_TIME_Relative lifetime;
107 * A set of required peer capabilities for the sensor to collect meaningful information (e.g. ipv6)
112 * Either "gnunet-statistics" or external "process"
117 * Name of the GNUnet service that is the source for the gnunet-statistics entry
119 char *gnunet_stat_service;
122 * Name of the gnunet-statistics entry
124 char *gnunet_stat_name;
127 * Handle to statistics get request (OR GNUNET_SCHEDULER_NO_TASK)
129 struct GNUNET_STATISTICS_GetHandle *gnunet_stat_get_handle;
132 * Name of the external process to be executed
137 * Arguments to be passed to the external process
142 * Handle to the external process
144 struct GNUNET_OS_CommandHandle *ext_cmd;
147 * Did we already receive a value
148 * from the currently running external
149 * proccess ? #GNUNET_YES / #GNUNET_NO
151 int ext_cmd_value_received;
154 * The output datatype to be expected
156 char *expected_datatype;
159 * Peer-identity of peer running collection point
161 struct GNUNET_PeerIdentity *collection_point;
164 * Do we report received sensor values to collection point?
165 * #GNUNET_YES / #GNUNET_NO
170 * Time interval to send sensor values to collection point (e.g. every 30 mins)
172 struct GNUNET_TIME_Relative value_reporting_interval;
175 * Do we report anomalies to collection point?
176 * #GNUNET_YES / #GNUNET_NO
178 int report_anomalies;
181 * Execution task (OR GNUNET_SCHEDULER_NO_TASK)
183 GNUNET_SCHEDULER_TaskIdentifier execution_task;
186 * Is the sensor being executed
192 GNUNET_NETWORK_STRUCT_BEGIN
194 * Used to communicate sensor readings to
195 * collection points (SENSORDASHBAORD service)
197 struct GNUNET_SENSOR_ReadingMessage
201 * GNUNET general message header
203 struct GNUNET_MessageHeader header;
206 * Size of the sensor name value, allocated
207 * at position 0 after this struct
209 uint16_t sensorname_size;
212 * First part of sensor version number
214 uint16_t sensorversion_major;
217 * Second part of sensor version number
219 uint16_t sensorversion_minor;
222 * Timestamp of recorded reading
227 * Size of reading value, allocation
228 * at poistion 1 after this struct
235 * Used to communicate brief information about a sensor.
237 struct GNUNET_SENSOR_SensorBriefMessage
241 * GNUNET general message header.
243 struct GNUNET_MessageHeader header;
246 * Size of sensor name string, allocated at position 0 after this struct.
251 * First part of sensor version number
253 uint16_t version_major;
256 * Second part of sensor version number
258 uint16_t version_minor;
263 * Used to communicate full information about a sensor.
265 struct GNUNET_SENSOR_SensorFullMessage
269 * GNUNET general message header.
271 struct GNUNET_MessageHeader header;
274 * Size of sensor name.
275 * Name allocated at position 0 after this struct.
277 uint16_t sensorname_size;
280 * Size of the sensor definition file carrying full sensor information.
281 * The file content allocated at position 1 after this struct.
283 uint16_t sensorfile_size;
286 * Name of the file (usually script) associated with this sensor.
287 * At the moment we only support having one file per sensor.
288 * The file name is allocated at position 2 after this struct.
290 uint16_t scriptname_size;
293 * Size of the file (usually script) associated with this sensor.
294 * The file content is allocated at position 3 after this struct.
296 uint16_t scriptfile_size;
301 * Message carrying an anomaly status change report
303 struct AnomalyReportMessage
309 struct GNUNET_MessageHeader header;
312 * Hash of sensor name
314 struct GNUNET_HashCode sensorname_hash;
317 * First part of sensor version number
319 uint16_t sensorversion_major;
322 * Second part of sensor version name
324 uint16_t sensorversion_minor;
332 * Percentage of neighbors reported the same anomaly
334 float anomalous_neighbors;
338 GNUNET_NETWORK_STRUCT_END
341 * Given two version numbers as major and minor, compare them.
343 * @param v1_major First part of first version number
344 * @param v1_minor Second part of first version number
345 * @param v2_major First part of second version number
346 * @param v2_minor Second part of second version number
349 GNUNET_SENSOR_version_compare (uint16_t v1_major, uint16_t v1_minor,
350 uint16_t v2_major, uint16_t v2_minor);
354 * Reads sensor definitions from local data files
356 * @return a multihashmap of loaded sensors
358 struct GNUNET_CONTAINER_MultiHashMap *
359 GNUNET_SENSOR_load_all_sensors ();
363 * Get path to the directory containing the sensor definition files
365 * @return sensor files directory string
368 GNUNET_SENSOR_get_sensor_dir ();
372 * Destroys a group of sensors in a hashmap and the hashmap itself
374 * @param sensors hashmap containing the sensors
377 GNUNET_SENSOR_destroy_sensors (struct GNUNET_CONTAINER_MultiHashMap *sensors);
379 #if 0 /* keep Emacsens' auto-indent happy */
386 /* ifndef GNUNET_SENSOR_UTIL_LIB_H */
388 /* end of gnunet_sensor_util_lib.h */