diff options
-rw-r--r-- | src/include/gnunet_client_manager_lib.h | 77 | ||||
-rw-r--r-- | src/util/client_manager.c | 79 |
2 files changed, 102 insertions, 54 deletions
diff --git a/src/include/gnunet_client_manager_lib.h b/src/include/gnunet_client_manager_lib.h index 07d9d2807..63a745514 100644 --- a/src/include/gnunet_client_manager_lib.h +++ b/src/include/gnunet_client_manager_lib.h | |||
@@ -99,11 +99,12 @@ struct GNUNET_CLIENT_MANAGER_MessageHandler | |||
99 | /** | 99 | /** |
100 | * Connect to a service. | 100 | * Connect to a service. |
101 | * | 101 | * |
102 | * @param cfg Configuration to use. | 102 | * @param cfg |
103 | * @param service_name Service name to connect to. | 103 | * Configuration to use. |
104 | * @param connect_msg FIXME | 104 | * @param service_name |
105 | * @param connection_lost_cb x | 105 | * Service name to connect to. |
106 | * @param cls | 106 | * @param handlers |
107 | * Message handlers. | ||
107 | * | 108 | * |
108 | * @return Client manager connection handle. | 109 | * @return Client manager connection handle. |
109 | */ | 110 | */ |
@@ -117,22 +118,27 @@ GNUNET_CLIENT_MANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
117 | /** | 118 | /** |
118 | * Disconnect from the service. | 119 | * Disconnect from the service. |
119 | * | 120 | * |
120 | * @param mgr Client manager connection. | 121 | * @param mgr |
121 | * @param transmit_queue Transmit pending messages in queue before disconnecting. | 122 | * Client manager connection. |
122 | * @param disconnect_cb Function called after disconnected from the service. | 123 | * @param transmit_queue |
123 | * @param disconnect_cls Closure for @a disconnect_cb. | 124 | * Transmit pending messages in queue before disconnecting. |
125 | * @param disconnect_cb | ||
126 | * Function called after disconnected from the service. | ||
127 | * @param cls | ||
128 | * Closure for @a disconnect_cb. | ||
124 | */ | 129 | */ |
125 | void | 130 | void |
126 | GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 131 | GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
127 | int transmit_queue, | 132 | int transmit_queue, |
128 | GNUNET_ContinuationCallback disconnect_cb, | 133 | GNUNET_ContinuationCallback disconnect_cb, |
129 | void *disconnect_cls); | 134 | void *cls); |
130 | 135 | ||
131 | 136 | ||
132 | /** | 137 | /** |
133 | * Reschedule connect to the service using exponential back-off. | 138 | * Reschedule connect to the service using exponential back-off. |
134 | * | 139 | * |
135 | * @param mgr Client manager connection. | 140 | * @param mgr |
141 | * Client manager connection. | ||
136 | */ | 142 | */ |
137 | void | 143 | void |
138 | GNUNET_CLIENT_MANAGER_reconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr); | 144 | GNUNET_CLIENT_MANAGER_reconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr); |
@@ -141,8 +147,11 @@ GNUNET_CLIENT_MANAGER_reconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr); | |||
141 | /** | 147 | /** |
142 | * Add a message to the end of the transmission queue. | 148 | * Add a message to the end of the transmission queue. |
143 | * | 149 | * |
144 | * @param mgr Client manager connection. | 150 | * @param mgr |
145 | * @param msg Message to transmit. It is free()'d after transmission. | 151 | * Client manager connection. |
152 | * @param msg | ||
153 | * Message to transmit, should be allocated with GNUNET_malloc() or | ||
154 | * GNUNET_new(), as it is freed with GNUNET_free() after transmission. | ||
146 | */ | 155 | */ |
147 | void | 156 | void |
148 | GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 157 | GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
@@ -152,8 +161,11 @@ GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
152 | /** | 161 | /** |
153 | * Add a message to the beginning of the transmission queue. | 162 | * Add a message to the beginning of the transmission queue. |
154 | * | 163 | * |
155 | * @param mgr Client manager connection. | 164 | * @param mgr |
156 | * @param msg Message to transmit. It is free()'d after transmission. | 165 | * Client manager connection. |
166 | * @param msg | ||
167 | * Message to transmit, should be allocated with GNUNET_malloc() or | ||
168 | * GNUNET_new(), as it is freed with GNUNET_free() after transmission. | ||
157 | */ | 169 | */ |
158 | void | 170 | void |
159 | GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 171 | GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
@@ -163,7 +175,8 @@ GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr | |||
163 | /** | 175 | /** |
164 | * Drop all queued messages. | 176 | * Drop all queued messages. |
165 | * | 177 | * |
166 | * @param mgr Client manager connection. | 178 | * @param mgr |
179 | * Client manager connection. | ||
167 | */ | 180 | */ |
168 | void | 181 | void |
169 | GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr); | 182 | GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr); |
@@ -172,7 +185,8 @@ GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr); | |||
172 | /** | 185 | /** |
173 | * Obtain client connection handle. | 186 | * Obtain client connection handle. |
174 | * | 187 | * |
175 | * @param mgr Client manager connection handle. | 188 | * @param mgr |
189 | * Client manager connection. | ||
176 | * | 190 | * |
177 | * @return Client connection handle. | 191 | * @return Client connection handle. |
178 | */ | 192 | */ |
@@ -184,9 +198,10 @@ GNUNET_CLIENT_MANAGER_get_client (struct GNUNET_CLIENT_MANAGER_Connection *mgr); | |||
184 | * Return user context associated with the given client manager. | 198 | * Return user context associated with the given client manager. |
185 | * Note: you should probably use the macro (call without the underscore). | 199 | * Note: you should probably use the macro (call without the underscore). |
186 | * | 200 | * |
187 | * @param mgr Client manager connection. | 201 | * @param mgr |
188 | * @param size Number of bytes in user context struct (for verification only). | 202 | * Client manager connection. |
189 | * @return User context. | 203 | * @param size |
204 | * Number of bytes in user context struct (for verification only). | ||
190 | */ | 205 | */ |
191 | void * | 206 | void * |
192 | GNUNET_CLIENT_MANAGER_get_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 207 | GNUNET_CLIENT_MANAGER_get_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
@@ -197,9 +212,10 @@ GNUNET_CLIENT_MANAGER_get_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection | |||
197 | * Set user context to be associated with the given client manager. | 212 | * Set user context to be associated with the given client manager. |
198 | * Note: you should probably use the macro (call without the underscore). | 213 | * Note: you should probably use the macro (call without the underscore). |
199 | * | 214 | * |
200 | * @param mgr Client manager connection. | 215 | * @param mgr |
201 | * @param ctx User context. | 216 | * Client manager connection. |
202 | * @param size Number of bytes in user context struct (for verification only). | 217 | * @param size |
218 | * Number of bytes in user context struct (for verification only). | ||
203 | */ | 219 | */ |
204 | void | 220 | void |
205 | GNUNET_CLIENT_MANAGER_set_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 221 | GNUNET_CLIENT_MANAGER_set_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
@@ -210,9 +226,12 @@ GNUNET_CLIENT_MANAGER_set_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection | |||
210 | /** | 226 | /** |
211 | * Return user context associated with the given client manager. | 227 | * Return user context associated with the given client manager. |
212 | * | 228 | * |
213 | * @param mgr Client manager connection. | 229 | * @param mgr |
214 | * @param type Expected return type (i.e. 'struct Foo') | 230 | * Client manager connection. |
215 | * @return Pointer to user context of type 'type *'. | 231 | * @param ctx |
232 | * User context. | ||
233 | * @param size | ||
234 | * Number of bytes in user context struct (for verification only). | ||
216 | */ | 235 | */ |
217 | #define GNUNET_CLIENT_MANAGER_get_user_context(mgr, type) \ | 236 | #define GNUNET_CLIENT_MANAGER_get_user_context(mgr, type) \ |
218 | (type *) GNUNET_CLIENT_MANAGER_get_user_context_ (mgr, sizeof (type)) | 237 | (type *) GNUNET_CLIENT_MANAGER_get_user_context_ (mgr, sizeof (type)) |
@@ -221,8 +240,10 @@ GNUNET_CLIENT_MANAGER_set_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection | |||
221 | /** | 240 | /** |
222 | * Set user context to be associated with the given client manager. | 241 | * Set user context to be associated with the given client manager. |
223 | * | 242 | * |
224 | * @param mgr Client manager connection. | 243 | * @param mgr |
225 | * @param ctx Pointer to user context. | 244 | * Client manager connection. |
245 | * @param ctx | ||
246 | * Pointer to user context. | ||
226 | */ | 247 | */ |
227 | #define GNUNET_CLIENT_MANAGER_set_user_context(mgr, ctx) \ | 248 | #define GNUNET_CLIENT_MANAGER_set_user_context(mgr, ctx) \ |
228 | GNUNET_CLIENT_MANAGER_set_user_context_ (mgr, ctx, sizeof (*ctx)) | 249 | GNUNET_CLIENT_MANAGER_set_user_context_ (mgr, ctx, sizeof (*ctx)) |
diff --git a/src/util/client_manager.c b/src/util/client_manager.c index 6ab2c7c6d..f27c5e392 100644 --- a/src/util/client_manager.c +++ b/src/util/client_manager.c | |||
@@ -207,9 +207,12 @@ schedule_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
207 | /** | 207 | /** |
208 | * Transmit next message to service. | 208 | * Transmit next message to service. |
209 | * | 209 | * |
210 | * @param cls The struct GNUNET_PSYC_Channel. | 210 | * @param cls |
211 | * @param size Number of bytes available in @a buf. | 211 | * struct GNUNET_CLIENT_MANAGER_Connection |
212 | * @param buf Where to copy the message. | 212 | * @param size |
213 | * Number of bytes available in @a buf. | ||
214 | * @param buf | ||
215 | * Where to copy the message. | ||
213 | * | 216 | * |
214 | * @return Number of bytes copied to @a buf. | 217 | * @return Number of bytes copied to @a buf. |
215 | */ | 218 | */ |
@@ -292,8 +295,10 @@ transmit_next (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | |||
292 | /** | 295 | /** |
293 | * Try again to connect to the service. | 296 | * Try again to connect to the service. |
294 | * | 297 | * |
295 | * @param cls Channel handle. | 298 | * @param cls |
296 | * @param tc Scheduler context. | 299 | * Channel handle. |
300 | * @param tc | ||
301 | * Scheduler context. | ||
297 | */ | 302 | */ |
298 | static void | 303 | static void |
299 | schedule_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 304 | schedule_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -314,9 +319,12 @@ schedule_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
314 | /** | 319 | /** |
315 | * Connect to service. | 320 | * Connect to service. |
316 | * | 321 | * |
317 | * @param cfg Configuration to use. | 322 | * @param cfg |
318 | * @param service_name Service name to connect to. | 323 | * Configuration to use. |
319 | * @param handlers Message handlers. | 324 | * @param service_name |
325 | * Service name to connect to. | ||
326 | * @param handlers | ||
327 | * Message handlers. | ||
320 | * | 328 | * |
321 | * @return Client manager connection handle. | 329 | * @return Client manager connection handle. |
322 | */ | 330 | */ |
@@ -340,20 +348,24 @@ GNUNET_CLIENT_MANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
340 | /** | 348 | /** |
341 | * Disconnect from the service. | 349 | * Disconnect from the service. |
342 | * | 350 | * |
343 | * @param mgr Client manager connection. | 351 | * @param mgr |
344 | * @param transmit_queue Transmit pending messages in queue before disconnecting. | 352 | * Client manager connection. |
345 | * @param disconnect_cb Function called after disconnected from the service. | 353 | * @param transmit_queue |
346 | * @param disconnect_cls Closure for @a disconnect_cb. | 354 | * Transmit pending messages in queue before disconnecting. |
355 | * @param disconnect_cb | ||
356 | * Function called after disconnected from the service. | ||
357 | * @param cls | ||
358 | * Closure for @a disconnect_cb. | ||
347 | */ | 359 | */ |
348 | void | 360 | void |
349 | GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 361 | GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
350 | int transmit_queue, | 362 | int transmit_queue, |
351 | GNUNET_ContinuationCallback disconnect_cb, | 363 | GNUNET_ContinuationCallback disconnect_cb, |
352 | void *disconnect_cls) | 364 | void *cls) |
353 | { | 365 | { |
354 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting (%d)\n", transmit_queue); | 366 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting (%d)\n", transmit_queue); |
355 | mgr->disconnect_cb = disconnect_cb; | 367 | mgr->disconnect_cb = disconnect_cb; |
356 | mgr->disconnect_cls = disconnect_cls; | 368 | mgr->disconnect_cls = cls; |
357 | if (NULL != mgr->tmit_head) | 369 | if (NULL != mgr->tmit_head) |
358 | { | 370 | { |
359 | if (GNUNET_YES == transmit_queue) | 371 | if (GNUNET_YES == transmit_queue) |
@@ -395,7 +407,8 @@ GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
395 | /** | 407 | /** |
396 | * Reschedule connect to the service using exponential back-off. | 408 | * Reschedule connect to the service using exponential back-off. |
397 | * | 409 | * |
398 | * @param mgr Client manager connection. | 410 | * @param mgr |
411 | * Client manager connection. | ||
399 | */ | 412 | */ |
400 | void | 413 | void |
401 | GNUNET_CLIENT_MANAGER_reconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | 414 | GNUNET_CLIENT_MANAGER_reconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr) |
@@ -426,8 +439,11 @@ GNUNET_CLIENT_MANAGER_reconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | |||
426 | /** | 439 | /** |
427 | * Add a message to the end of the transmission queue. | 440 | * Add a message to the end of the transmission queue. |
428 | * | 441 | * |
429 | * @param mgr Client manager connection. | 442 | * @param mgr |
430 | * @param msg Message to transmit. It is free()'d after transmission. | 443 | * Client manager connection. |
444 | * @param msg | ||
445 | * Message to transmit, should be allocated with GNUNET_malloc() or | ||
446 | * GNUNET_new(), as it is freed with GNUNET_free() after transmission. | ||
431 | */ | 447 | */ |
432 | void | 448 | void |
433 | GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 449 | GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
@@ -443,8 +459,11 @@ GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
443 | /** | 459 | /** |
444 | * Add a message to the beginning of the transmission queue. | 460 | * Add a message to the beginning of the transmission queue. |
445 | * | 461 | * |
446 | * @param mgr Client manager connection. | 462 | * @param mgr |
447 | * @param msg Message to transmit. It is free()'d after transmission. | 463 | * Client manager connection. |
464 | * @param msg | ||
465 | * Message to transmit, should be allocated with GNUNET_malloc() or | ||
466 | * GNUNET_new(), as it is freed with GNUNET_free() after transmission. | ||
448 | */ | 467 | */ |
449 | void | 468 | void |
450 | GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 469 | GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
@@ -460,7 +479,8 @@ GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr | |||
460 | /** | 479 | /** |
461 | * Drop all queued messages. | 480 | * Drop all queued messages. |
462 | * | 481 | * |
463 | * @param mgr Client manager connection. | 482 | * @param mgr |
483 | * Client manager connection. | ||
464 | */ | 484 | */ |
465 | void | 485 | void |
466 | GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | 486 | GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr) |
@@ -479,7 +499,8 @@ GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | |||
479 | /** | 499 | /** |
480 | * Obtain client connection handle. | 500 | * Obtain client connection handle. |
481 | * | 501 | * |
482 | * @param mgr Client manager connection handle. | 502 | * @param mgr |
503 | * Client manager connection. | ||
483 | * | 504 | * |
484 | * @return Client connection handle. | 505 | * @return Client connection handle. |
485 | */ | 506 | */ |
@@ -494,8 +515,11 @@ GNUNET_CLIENT_MANAGER_get_client (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | |||
494 | * Return user context associated with the given client. | 515 | * Return user context associated with the given client. |
495 | * Note: you should probably use the macro (call without the underscore). | 516 | * Note: you should probably use the macro (call without the underscore). |
496 | * | 517 | * |
497 | * @param mgr Client manager connection. | 518 | * @param mgr |
498 | * @param size Number of bytes in user context struct (for verification only). | 519 | * Client manager connection. |
520 | * @param size | ||
521 | * Number of bytes in user context struct (for verification only). | ||
522 | * | ||
499 | * @return User context. | 523 | * @return User context. |
500 | */ | 524 | */ |
501 | void * | 525 | void * |
@@ -514,9 +538,12 @@ GNUNET_CLIENT_MANAGER_get_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection | |||
514 | * Set user context to be associated with the given client. | 538 | * Set user context to be associated with the given client. |
515 | * Note: you should probably use the macro (call without the underscore). | 539 | * Note: you should probably use the macro (call without the underscore). |
516 | * | 540 | * |
517 | * @param mgr Client manager connection. | 541 | * @param mgr |
518 | * @param ctx User context. | 542 | * Client manager connection. |
519 | * @param size Number of bytes in user context struct (for verification only). | 543 | * @param ctx |
544 | * User context. | ||
545 | * @param size | ||
546 | * Number of bytes in user context struct (for verification only). | ||
520 | */ | 547 | */ |
521 | void | 548 | void |
522 | GNUNET_CLIENT_MANAGER_set_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 549 | GNUNET_CLIENT_MANAGER_set_user_context_ (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |