diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-23 14:22:34 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-23 14:22:34 +0000 |
commit | 5742938289524f4c5fba7883742e4dd69cccf11d (patch) | |
tree | e16fea8b9d778f9825f897237b0c1880305776a0 /src/include/gnunet_arm_service.h | |
parent | f3edb5a8d6ba6f43f5df18f2e98bc1dae90c9d7a (diff) | |
download | gnunet-5742938289524f4c5fba7883742e4dd69cccf11d.tar.gz gnunet-5742938289524f4c5fba7883742e4dd69cccf11d.zip |
refactoring ARM api to use new MQ
Diffstat (limited to 'src/include/gnunet_arm_service.h')
-rw-r--r-- | src/include/gnunet_arm_service.h | 109 |
1 files changed, 59 insertions, 50 deletions
diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h index f21524226..7fb14d3ac 100644 --- a/src/include/gnunet_arm_service.h +++ b/src/include/gnunet_arm_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2009 GNUnet e.V. | 3 | Copyright (C) 2009, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -48,7 +48,7 @@ extern "C" | |||
48 | /** | 48 | /** |
49 | * Version of the arm API. | 49 | * Version of the arm API. |
50 | */ | 50 | */ |
51 | #define GNUNET_ARM_VERSION 0x00000002 | 51 | #define GNUNET_ARM_VERSION 0x00000003 |
52 | 52 | ||
53 | 53 | ||
54 | /** | 54 | /** |
@@ -78,12 +78,6 @@ enum GNUNET_ARM_RequestStatus | |||
78 | GNUNET_ARM_REQUEST_BUSY = 3, | 78 | GNUNET_ARM_REQUEST_BUSY = 3, |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * It was discovered that the request would be too long to fit in a message, | ||
82 | * and thus it was not sent. | ||
83 | */ | ||
84 | GNUNET_ARM_REQUEST_TOO_LONG = 4, | ||
85 | |||
86 | /** | ||
87 | * Request time ran out before we had a chance to send it. | 81 | * Request time ran out before we had a chance to send it. |
88 | */ | 82 | */ |
89 | GNUNET_ARM_REQUEST_TIMEOUT = 5 | 83 | GNUNET_ARM_REQUEST_TIMEOUT = 5 |
@@ -180,50 +174,56 @@ enum GNUNET_ARM_Result | |||
180 | */ | 174 | */ |
181 | struct GNUNET_ARM_Handle; | 175 | struct GNUNET_ARM_Handle; |
182 | 176 | ||
177 | /** | ||
178 | * Handle for an ARM operation. | ||
179 | */ | ||
180 | struct GNUNET_ARM_Operation; | ||
181 | |||
183 | 182 | ||
184 | /** | 183 | /** |
185 | * Function called whenever we connect to or disconnect from ARM. | 184 | * Function called whenever we connect to or disconnect from ARM. |
186 | * | 185 | * |
187 | * @param cls closure | 186 | * @param cls closure |
188 | * @param connected GNUNET_YES if connected, GNUNET_NO if disconnected, | 187 | * @param connected #GNUNET_YES if connected, #GNUNET_NO if disconnected, |
189 | * GNUNET_SYSERR if there was an error. | 188 | * #GNUNET_SYSERR if there was an error. |
190 | */ | 189 | */ |
191 | typedef void (*GNUNET_ARM_ConnectionStatusCallback) (void *cls, | 190 | typedef void |
192 | int connected); | 191 | (*GNUNET_ARM_ConnectionStatusCallback) (void *cls, |
192 | int connected); | ||
193 | 193 | ||
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Function called in response to a start/stop request. | 196 | * Function called in response to a start/stop request. |
197 | * Will be called when request was not sent successfully, | 197 | * Will be called when request was not sent successfully, |
198 | * or when a reply comes. If the request was not sent successfully, | 198 | * or when a reply comes. If the request was not sent successfully, |
199 | * 'rs' will indicate that, and 'service' and 'result' will be undefined. | 199 | * @a rs will indicate that, and @a result will be undefined. |
200 | * | 200 | * |
201 | * @param cls closure | 201 | * @param cls closure |
202 | * @param rs status of the request | 202 | * @param rs status of the request |
203 | * @param service service name | ||
204 | * @param result result of the operation | 203 | * @param result result of the operation |
205 | */ | 204 | */ |
206 | typedef void (*GNUNET_ARM_ResultCallback) (void *cls, | 205 | typedef void |
207 | enum GNUNET_ARM_RequestStatus rs, | 206 | (*GNUNET_ARM_ResultCallback) (void *cls, |
208 | const char *service, | 207 | enum GNUNET_ARM_RequestStatus rs, |
209 | enum GNUNET_ARM_Result result); | 208 | enum GNUNET_ARM_Result result); |
210 | 209 | ||
211 | 210 | ||
212 | /** | 211 | /** |
213 | * Callback function invoked when list operation is complete. | 212 | * Callback function invoked when list operation is complete. |
214 | * Will be called when request was not sent successfully, | 213 | * Will be called when request was not sent successfully, |
215 | * or when a reply comes. If the request was not sent successfully, | 214 | * or when a reply comes. If the request was not sent successfully, |
216 | * 'rs' will indicate that, and 'count' and 'list' will be undefined. | 215 | * @a rs will indicate that, and @a count and @a list will be undefined. |
217 | * | 216 | * |
218 | * @param cls closure | 217 | * @param cls closure |
219 | * @param rs status of the request | 218 | * @param rs status of the request |
220 | * @param count number of strings in the list | 219 | * @param count number of strings in the list |
221 | * @param list list of running services | 220 | * @param list list of running services |
222 | */ | 221 | */ |
223 | typedef void (*GNUNET_ARM_ServiceListCallback) (void *cls, | 222 | typedef void |
224 | enum GNUNET_ARM_RequestStatus rs, | 223 | (*GNUNET_ARM_ServiceListCallback) (void *cls, |
225 | unsigned int count, | 224 | enum GNUNET_ARM_RequestStatus rs, |
226 | const char *const*list); | 225 | unsigned int count, |
226 | const char *const*list); | ||
227 | 227 | ||
228 | 228 | ||
229 | /** | 229 | /** |
@@ -234,13 +234,13 @@ typedef void (*GNUNET_ARM_ServiceListCallback) (void *cls, | |||
234 | * the ARM service may internally use a different | 234 | * the ARM service may internally use a different |
235 | * configuration to determine how to start the service). | 235 | * configuration to determine how to start the service). |
236 | * @param conn_status will be called when connecting/disconnecting | 236 | * @param conn_status will be called when connecting/disconnecting |
237 | * @param cls closure for conn_status | 237 | * @param conn_status_cls closure for @a conn_status |
238 | * @return context to use for further ARM operations, NULL on error. | 238 | * @return context to use for further ARM operations, NULL on error. |
239 | */ | 239 | */ |
240 | struct GNUNET_ARM_Handle * | 240 | struct GNUNET_ARM_Handle * |
241 | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 241 | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
242 | GNUNET_ARM_ConnectionStatusCallback conn_status, | 242 | GNUNET_ARM_ConnectionStatusCallback conn_status, |
243 | void *cls); | 243 | void *conn_status_cls); |
244 | 244 | ||
245 | 245 | ||
246 | /** | 246 | /** |
@@ -249,21 +249,31 @@ GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
249 | * @param h the handle that was being used | 249 | * @param h the handle that was being used |
250 | */ | 250 | */ |
251 | void | 251 | void |
252 | GNUNET_ARM_disconnect_and_free (struct GNUNET_ARM_Handle *h); | 252 | GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h); |
253 | |||
254 | |||
255 | /** | ||
256 | * Abort an operation. Only prevents the callback from being | ||
257 | * called, the operation may still complete. | ||
258 | * | ||
259 | * @param op operation to cancel | ||
260 | */ | ||
261 | void | ||
262 | GNUNET_ARM_operation_cancel (struct GNUNET_ARM_Operation *op); | ||
253 | 263 | ||
254 | 264 | ||
255 | /** | 265 | /** |
256 | * Request a list of running services. | 266 | * Request a list of running services. |
257 | * | 267 | * |
258 | * @param h handle to ARM | 268 | * @param h handle to ARM |
259 | * @param timeout how long to wait before failing for good | ||
260 | * @param cont callback to invoke after request is sent or is not sent | 269 | * @param cont callback to invoke after request is sent or is not sent |
261 | * @param cont_cls closure for callback | 270 | * @param cont_cls closure for @a cont |
271 | * @return handle for the operation, NULL on error | ||
262 | */ | 272 | */ |
263 | void | 273 | struct GNUNET_ARM_Operation * |
264 | GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, | 274 | GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, |
265 | struct GNUNET_TIME_Relative timeout, | 275 | GNUNET_ARM_ServiceListCallback cont, |
266 | GNUNET_ARM_ServiceListCallback cont, void *cont_cls); | 276 | void *cont_cls); |
267 | 277 | ||
268 | 278 | ||
269 | /** | 279 | /** |
@@ -271,20 +281,20 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, | |||
271 | * Stopping arm itself will not invalidate its handle, and | 281 | * Stopping arm itself will not invalidate its handle, and |
272 | * ARM API will try to restore connection to the ARM service, | 282 | * ARM API will try to restore connection to the ARM service, |
273 | * even if ARM connection was lost because you asked for ARM to be stopped. | 283 | * even if ARM connection was lost because you asked for ARM to be stopped. |
274 | * Call GNUNET_ARM_disconnect_and_free () to free the handle and prevent | 284 | * Call #GNUNET_ARM_disconnect() to free the handle and prevent |
275 | * further connection attempts. | 285 | * further connection attempts. |
276 | * | 286 | * |
277 | * @param h handle to ARM | 287 | * @param h handle to ARM |
278 | * @param service_name name of the service | 288 | * @param service_name name of the service |
279 | * @param timeout how long to wait before failing for good | ||
280 | * @param cont callback to invoke after request is sent or is not sent | 289 | * @param cont callback to invoke after request is sent or is not sent |
281 | * @param cont_cls closure for callback | 290 | * @param cont_cls closure for @a cont |
291 | * @return handle for the operation, NULL on error | ||
282 | */ | 292 | */ |
283 | void | 293 | struct GNUNET_ARM_Operation * |
284 | GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, | 294 | GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, |
285 | const char *service_name, | 295 | const char *service_name, |
286 | struct GNUNET_TIME_Relative timeout, | 296 | GNUNET_ARM_ResultCallback cont, |
287 | GNUNET_ARM_ResultCallback cont, void *cont_cls); | 297 | void *cont_cls); |
288 | 298 | ||
289 | 299 | ||
290 | /** | 300 | /** |
@@ -293,15 +303,14 @@ GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, | |||
293 | * @param h handle to ARM | 303 | * @param h handle to ARM |
294 | * @param service_name name of the service | 304 | * @param service_name name of the service |
295 | * @param std_inheritance inheritance of std streams | 305 | * @param std_inheritance inheritance of std streams |
296 | * @param timeout how long to wait before failing for good | ||
297 | * @param cont callback to invoke after request is sent or not sent | 306 | * @param cont callback to invoke after request is sent or not sent |
298 | * @param cont_cls closure for callback | 307 | * @param cont_cls closure for @a cont |
308 | * @return handle for the operation, NULL on error | ||
299 | */ | 309 | */ |
300 | void | 310 | struct GNUNET_ARM_Operation * |
301 | GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, | 311 | GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, |
302 | const char *service_name, | 312 | const char *service_name, |
303 | enum GNUNET_OS_InheritStdioFlags std_inheritance, | 313 | enum GNUNET_OS_InheritStdioFlags std_inheritance, |
304 | struct GNUNET_TIME_Relative timeout, | ||
305 | GNUNET_ARM_ResultCallback cont, | 314 | GNUNET_ARM_ResultCallback cont, |
306 | void *cont_cls); | 315 | void *cont_cls); |
307 | 316 | ||
@@ -316,13 +325,13 @@ struct GNUNET_ARM_MonitorHandle; | |||
316 | * Function called in when a status update arrives. | 325 | * Function called in when a status update arrives. |
317 | * | 326 | * |
318 | * @param cls closure | 327 | * @param cls closure |
319 | * @param arm handle to the arm connection | ||
320 | * @param service service name | 328 | * @param service service name |
321 | * @param status status of the service | 329 | * @param status status of the service |
322 | */ | 330 | */ |
323 | typedef void (*GNUNET_ARM_ServiceStatusCallback) (void *cls, | 331 | typedef void |
324 | const char *service, | 332 | (*GNUNET_ARM_ServiceStatusCallback) (void *cls, |
325 | enum GNUNET_ARM_ServiceStatus status); | 333 | const char *service, |
334 | enum GNUNET_ARM_ServiceStatus status); | ||
326 | 335 | ||
327 | 336 | ||
328 | /** | 337 | /** |
@@ -333,13 +342,13 @@ typedef void (*GNUNET_ARM_ServiceStatusCallback) (void *cls, | |||
333 | * the ARM service may internally use a different | 342 | * the ARM service may internally use a different |
334 | * configuration to determine how to start the service). | 343 | * configuration to determine how to start the service). |
335 | * @param cont callback to invoke on status updates | 344 | * @param cont callback to invoke on status updates |
336 | * @param cont_cls closure | 345 | * @param cont_cls closure for @a cont |
337 | * @return context to use for further ARM monitor operations, NULL on error. | 346 | * @return context to use for further ARM monitor operations, NULL on error. |
338 | */ | 347 | */ |
339 | struct GNUNET_ARM_MonitorHandle * | 348 | struct GNUNET_ARM_MonitorHandle * |
340 | GNUNET_ARM_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg, | 349 | GNUNET_ARM_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
341 | GNUNET_ARM_ServiceStatusCallback cont, | 350 | GNUNET_ARM_ServiceStatusCallback cont, |
342 | void *cont_cls); | 351 | void *cont_cls); |
343 | 352 | ||
344 | 353 | ||
345 | /** | 354 | /** |
@@ -348,7 +357,7 @@ GNUNET_ARM_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
348 | * @param h the handle that was being used | 357 | * @param h the handle that was being used |
349 | */ | 358 | */ |
350 | void | 359 | void |
351 | GNUNET_ARM_monitor_disconnect_and_free (struct GNUNET_ARM_MonitorHandle *h); | 360 | GNUNET_ARM_monitor_stop (struct GNUNET_ARM_MonitorHandle *h); |
352 | 361 | ||
353 | #if 0 /* keep Emacsens' auto-indent happy */ | 362 | #if 0 /* keep Emacsens' auto-indent happy */ |
354 | { | 363 | { |