diff options
Diffstat (limited to 'src/include/gnunet_sensor_service.h')
-rw-r--r-- | src/include/gnunet_sensor_service.h | 199 |
1 files changed, 0 insertions, 199 deletions
diff --git a/src/include/gnunet_sensor_service.h b/src/include/gnunet_sensor_service.h deleted file mode 100644 index 391db58bf..000000000 --- a/src/include/gnunet_sensor_service.h +++ /dev/null | |||
@@ -1,199 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Omar Tarabai | ||
23 | * | ||
24 | * @file | ||
25 | * API to the sensor service | ||
26 | * | ||
27 | * @defgroup sensor Sensor service | ||
28 | * | ||
29 | * @{ | ||
30 | */ | ||
31 | |||
32 | #ifndef GNUNET_SENSOR_SERVICE_H | ||
33 | #define GNUNET_SENSOR_SERVICE_H | ||
34 | |||
35 | #include "gnunet_common.h" | ||
36 | #include "gnunet_util_lib.h" | ||
37 | |||
38 | #ifdef __cplusplus | ||
39 | extern "C" | ||
40 | { | ||
41 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
42 | } | ||
43 | #endif | ||
44 | #endif | ||
45 | |||
46 | |||
47 | /** | ||
48 | * Handle to the sensor service. | ||
49 | */ | ||
50 | struct GNUNET_SENSOR_Handle; | ||
51 | |||
52 | /** | ||
53 | * Context for an iteration request. | ||
54 | */ | ||
55 | struct GNUNET_SENSOR_IterateContext; | ||
56 | |||
57 | /** | ||
58 | * Context of a force anomaly request | ||
59 | */ | ||
60 | struct GNUNET_SENSOR_ForceAnomalyContext; | ||
61 | |||
62 | /** | ||
63 | * Structure containing brief info about sensor | ||
64 | */ | ||
65 | struct SensorInfoShort | ||
66 | { | ||
67 | |||
68 | /* | ||
69 | * Sensor name | ||
70 | */ | ||
71 | char *name; | ||
72 | |||
73 | /* | ||
74 | * First part of version number | ||
75 | */ | ||
76 | uint16_t version_major; | ||
77 | |||
78 | /* | ||
79 | * Second part of version number | ||
80 | */ | ||
81 | uint16_t version_minor; | ||
82 | |||
83 | /* | ||
84 | * Sensor description | ||
85 | */ | ||
86 | char *description; | ||
87 | |||
88 | }; | ||
89 | |||
90 | /** | ||
91 | * Sensor iterate request callback. | ||
92 | * | ||
93 | * @param cls closure | ||
94 | * @param sensor Brief sensor information | ||
95 | * @param error message | ||
96 | */ | ||
97 | typedef void (*GNUNET_SENSOR_SensorIterateCB) (void *cls, | ||
98 | const struct SensorInfoShort * | ||
99 | sensor, const char *err_msg); | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Continuation called with a status result. | ||
104 | * | ||
105 | * @param cls closure | ||
106 | * @param emsg error message, NULL on success | ||
107 | */ | ||
108 | typedef void (*GNUNET_SENSOR_Continuation) (void *cls, const char *emsg); | ||
109 | |||
110 | |||
111 | /** | ||
112 | * Disconnect from the sensor service | ||
113 | * | ||
114 | * @param h handle to disconnect | ||
115 | */ | ||
116 | void | ||
117 | GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h); | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Connect to the sensor service. | ||
122 | * | ||
123 | * @return NULL on error | ||
124 | */ | ||
125 | struct GNUNET_SENSOR_Handle * | ||
126 | GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Cancel an iteration request. | ||
131 | * This should be called before the iterate callback is called with a NULL value. | ||
132 | * | ||
133 | * @param ic context of the iterator to cancel | ||
134 | */ | ||
135 | void | ||
136 | GNUNET_SENSOR_iterate_cancel (struct GNUNET_SENSOR_IterateContext | ||
137 | *ic); | ||
138 | |||
139 | |||
140 | /** | ||
141 | * Get one or all sensors loaded by the sensor service. | ||
142 | * The callback will be called with each sensor received and once with a NULL | ||
143 | * value to signal end of iteration. | ||
144 | * | ||
145 | * @param h Handle to SENSOR service | ||
146 | * @param timeout how long to wait until timing out | ||
147 | * @param sensorname Name of the required sensor, NULL to get all | ||
148 | * @param callback the function to call for each sensor | ||
149 | * @param callback_cls closure for callback | ||
150 | * @return iterator context | ||
151 | */ | ||
152 | struct GNUNET_SENSOR_IterateContext * | ||
153 | GNUNET_SENSOR_iterate (struct GNUNET_SENSOR_Handle *h, | ||
154 | struct GNUNET_TIME_Relative timeout, | ||
155 | const char *sensor_name, | ||
156 | GNUNET_SENSOR_SensorIterateCB callback, | ||
157 | void *callback_cls); | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Cancel a force anomaly request. | ||
162 | * | ||
163 | * @param fa Force anomaly context returned by GNUNET_SENSOR_force_anomaly() | ||
164 | */ | ||
165 | void | ||
166 | GNUNET_SENSOR_force_anomaly_cancel (struct GNUNET_SENSOR_ForceAnomalyContext | ||
167 | *fa); | ||
168 | |||
169 | |||
170 | /** | ||
171 | * Force an anomaly status change on a given sensor. If the sensor reporting | ||
172 | * module is running, this will trigger the usual reporting logic, therefore, | ||
173 | * please only use this in a test environment. | ||
174 | * | ||
175 | * Also, if the sensor analysis module is running, it might conflict and cause | ||
176 | * undefined behaviour if it detects a real anomaly. | ||
177 | * | ||
178 | * @param h Service handle | ||
179 | * @param sensor_name Sensor name to set the anomaly status | ||
180 | * @param anomalous The desired status: #GNUNET_YES / #GNUNET_NO | ||
181 | * @param cont Continuation function to be called after the request is sent | ||
182 | * @param cont_cls Closure for cont | ||
183 | */ | ||
184 | struct GNUNET_SENSOR_ForceAnomalyContext * | ||
185 | GNUNET_SENSOR_force_anomaly (struct GNUNET_SENSOR_Handle *h, char *sensor_name, | ||
186 | int anomalous, GNUNET_SENSOR_Continuation cont, | ||
187 | void *cont_cls); | ||
188 | |||
189 | |||
190 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
191 | { | ||
192 | #endif | ||
193 | #ifdef __cplusplus | ||
194 | } | ||
195 | #endif | ||
196 | |||
197 | #endif | ||
198 | |||
199 | /** @} */ /* end of group */ | ||