diff options
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r-- | src/reclaim/reclaim_api.c | 576 |
1 files changed, 286 insertions, 290 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index 725b2b876..a8790cd8e 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file reclaim/reclaim_api.c | 22 | * @file reclaim/reclaim_api.c |
@@ -32,15 +32,13 @@ | |||
32 | #include "gnunet_reclaim_service.h" | 32 | #include "gnunet_reclaim_service.h" |
33 | #include "reclaim.h" | 33 | #include "reclaim.h" |
34 | 34 | ||
35 | #define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__) | 35 | #define LOG(kind, ...) GNUNET_log_from(kind, "reclaim-api", __VA_ARGS__) |
36 | 36 | ||
37 | 37 | ||
38 | /** | 38 | /** |
39 | * Handle for an operation with the service. | 39 | * Handle for an operation with the service. |
40 | */ | 40 | */ |
41 | struct GNUNET_RECLAIM_Operation | 41 | struct GNUNET_RECLAIM_Operation { |
42 | { | ||
43 | |||
44 | /** | 42 | /** |
45 | * Main handle. | 43 | * Main handle. |
46 | */ | 44 | */ |
@@ -102,9 +100,7 @@ struct GNUNET_RECLAIM_Operation | |||
102 | /** | 100 | /** |
103 | * Handle for a ticket iterator operation | 101 | * Handle for a ticket iterator operation |
104 | */ | 102 | */ |
105 | struct GNUNET_RECLAIM_TicketIterator | 103 | struct GNUNET_RECLAIM_TicketIterator { |
106 | { | ||
107 | |||
108 | /** | 104 | /** |
109 | * Kept in a DLL. | 105 | * Kept in a DLL. |
110 | */ | 106 | */ |
@@ -166,9 +162,7 @@ struct GNUNET_RECLAIM_TicketIterator | |||
166 | /** | 162 | /** |
167 | * Handle for a attribute iterator operation | 163 | * Handle for a attribute iterator operation |
168 | */ | 164 | */ |
169 | struct GNUNET_RECLAIM_AttributeIterator | 165 | struct GNUNET_RECLAIM_AttributeIterator { |
170 | { | ||
171 | |||
172 | /** | 166 | /** |
173 | * Kept in a DLL. | 167 | * Kept in a DLL. |
174 | */ | 168 | */ |
@@ -235,8 +229,7 @@ struct GNUNET_RECLAIM_AttributeIterator | |||
235 | /** | 229 | /** |
236 | * Handle to the service. | 230 | * Handle to the service. |
237 | */ | 231 | */ |
238 | struct GNUNET_RECLAIM_Handle | 232 | struct GNUNET_RECLAIM_Handle { |
239 | { | ||
240 | /** | 233 | /** |
241 | * Configuration to use. | 234 | * Configuration to use. |
242 | */ | 235 | */ |
@@ -320,7 +313,7 @@ struct GNUNET_RECLAIM_Handle | |||
320 | * @param h handle to the reclaim service. | 313 | * @param h handle to the reclaim service. |
321 | */ | 314 | */ |
322 | static void | 315 | static void |
323 | reconnect (struct GNUNET_RECLAIM_Handle *h); | 316 | reconnect(struct GNUNET_RECLAIM_Handle *h); |
324 | 317 | ||
325 | 318 | ||
326 | /** | 319 | /** |
@@ -329,12 +322,12 @@ reconnect (struct GNUNET_RECLAIM_Handle *h); | |||
329 | * @param cls the handle | 322 | * @param cls the handle |
330 | */ | 323 | */ |
331 | static void | 324 | static void |
332 | reconnect_task (void *cls) | 325 | reconnect_task(void *cls) |
333 | { | 326 | { |
334 | struct GNUNET_RECLAIM_Handle *handle = cls; | 327 | struct GNUNET_RECLAIM_Handle *handle = cls; |
335 | 328 | ||
336 | handle->reconnect_task = NULL; | 329 | handle->reconnect_task = NULL; |
337 | reconnect (handle); | 330 | reconnect(handle); |
338 | } | 331 | } |
339 | 332 | ||
340 | 333 | ||
@@ -344,16 +337,16 @@ reconnect_task (void *cls) | |||
344 | * @param handle our service | 337 | * @param handle our service |
345 | */ | 338 | */ |
346 | static void | 339 | static void |
347 | force_reconnect (struct GNUNET_RECLAIM_Handle *handle) | 340 | force_reconnect(struct GNUNET_RECLAIM_Handle *handle) |
348 | { | 341 | { |
349 | GNUNET_MQ_destroy (handle->mq); | 342 | GNUNET_MQ_destroy(handle->mq); |
350 | handle->mq = NULL; | 343 | handle->mq = NULL; |
351 | handle->reconnect_backoff = | 344 | handle->reconnect_backoff = |
352 | GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); | 345 | GNUNET_TIME_STD_BACKOFF(handle->reconnect_backoff); |
353 | handle->reconnect_task = | 346 | handle->reconnect_task = |
354 | GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, | 347 | GNUNET_SCHEDULER_add_delayed(handle->reconnect_backoff, |
355 | &reconnect_task, | 348 | &reconnect_task, |
356 | handle); | 349 | handle); |
357 | } | 350 | } |
358 | 351 | ||
359 | 352 | ||
@@ -363,14 +356,14 @@ force_reconnect (struct GNUNET_RECLAIM_Handle *handle) | |||
363 | * @param it entry to free | 356 | * @param it entry to free |
364 | */ | 357 | */ |
365 | static void | 358 | static void |
366 | free_it (struct GNUNET_RECLAIM_AttributeIterator *it) | 359 | free_it(struct GNUNET_RECLAIM_AttributeIterator *it) |
367 | { | 360 | { |
368 | struct GNUNET_RECLAIM_Handle *h = it->h; | 361 | struct GNUNET_RECLAIM_Handle *h = it->h; |
369 | 362 | ||
370 | GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it); | 363 | GNUNET_CONTAINER_DLL_remove(h->it_head, h->it_tail, it); |
371 | if (NULL != it->env) | 364 | if (NULL != it->env) |
372 | GNUNET_MQ_discard (it->env); | 365 | GNUNET_MQ_discard(it->env); |
373 | GNUNET_free (it); | 366 | GNUNET_free(it); |
374 | } | 367 | } |
375 | 368 | ||
376 | /** | 369 | /** |
@@ -379,13 +372,13 @@ free_it (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
379 | * @param op the operation to free | 372 | * @param op the operation to free |
380 | */ | 373 | */ |
381 | static void | 374 | static void |
382 | free_op (struct GNUNET_RECLAIM_Operation *op) | 375 | free_op(struct GNUNET_RECLAIM_Operation *op) |
383 | { | 376 | { |
384 | if (NULL == op) | 377 | if (NULL == op) |
385 | return; | 378 | return; |
386 | if (NULL != op->env) | 379 | if (NULL != op->env) |
387 | GNUNET_MQ_discard (op->env); | 380 | GNUNET_MQ_discard(op->env); |
388 | GNUNET_free (op); | 381 | GNUNET_free(op); |
389 | } | 382 | } |
390 | 383 | ||
391 | 384 | ||
@@ -398,10 +391,11 @@ free_op (struct GNUNET_RECLAIM_Operation *op) | |||
398 | * @param error error code | 391 | * @param error error code |
399 | */ | 392 | */ |
400 | static void | 393 | static void |
401 | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | 394 | mq_error_handler(void *cls, enum GNUNET_MQ_Error error) |
402 | { | 395 | { |
403 | struct GNUNET_RECLAIM_Handle *handle = cls; | 396 | struct GNUNET_RECLAIM_Handle *handle = cls; |
404 | force_reconnect (handle); | 397 | |
398 | force_reconnect(handle); | ||
405 | } | 399 | } |
406 | 400 | ||
407 | 401 | ||
@@ -413,11 +407,11 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | |||
413 | * @param msg the message we received | 407 | * @param msg the message we received |
414 | */ | 408 | */ |
415 | static void | 409 | static void |
416 | handle_success_response (void *cls, const struct SuccessResultMessage *msg) | 410 | handle_success_response(void *cls, const struct SuccessResultMessage *msg) |
417 | { | 411 | { |
418 | struct GNUNET_RECLAIM_Handle *h = cls; | 412 | struct GNUNET_RECLAIM_Handle *h = cls; |
419 | struct GNUNET_RECLAIM_Operation *op; | 413 | struct GNUNET_RECLAIM_Operation *op; |
420 | uint32_t r_id = ntohl (msg->id); | 414 | uint32_t r_id = ntohl(msg->id); |
421 | int res; | 415 | int res; |
422 | const char *emsg; | 416 | const char *emsg; |
423 | 417 | ||
@@ -427,20 +421,20 @@ handle_success_response (void *cls, const struct SuccessResultMessage *msg) | |||
427 | if (NULL == op) | 421 | if (NULL == op) |
428 | return; | 422 | return; |
429 | 423 | ||
430 | res = ntohl (msg->op_result); | 424 | res = ntohl(msg->op_result); |
431 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 425 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
432 | "Received SUCCESS_RESPONSE with result %d\n", | 426 | "Received SUCCESS_RESPONSE with result %d\n", |
433 | res); | 427 | res); |
434 | 428 | ||
435 | /* TODO: add actual error message to response... */ | 429 | /* TODO: add actual error message to response... */ |
436 | if (GNUNET_SYSERR == res) | 430 | if (GNUNET_SYSERR == res) |
437 | emsg = _ ("failed to store record\n"); | 431 | emsg = _("failed to store record\n"); |
438 | else | 432 | else |
439 | emsg = NULL; | 433 | emsg = NULL; |
440 | if (NULL != op->as_cb) | 434 | if (NULL != op->as_cb) |
441 | op->as_cb (op->cls, res, emsg); | 435 | op->as_cb(op->cls, res, emsg); |
442 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 436 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
443 | free_op (op); | 437 | free_op(op); |
444 | } | 438 | } |
445 | 439 | ||
446 | 440 | ||
@@ -453,19 +447,19 @@ handle_success_response (void *cls, const struct SuccessResultMessage *msg) | |||
453 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 447 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
454 | */ | 448 | */ |
455 | static int | 449 | static int |
456 | check_consume_ticket_result (void *cls, | 450 | check_consume_ticket_result(void *cls, |
457 | const struct ConsumeTicketResultMessage *msg) | 451 | const struct ConsumeTicketResultMessage *msg) |
458 | { | 452 | { |
459 | size_t msg_len; | 453 | size_t msg_len; |
460 | size_t attrs_len; | 454 | size_t attrs_len; |
461 | 455 | ||
462 | msg_len = ntohs (msg->header.size); | 456 | msg_len = ntohs(msg->header.size); |
463 | attrs_len = ntohs (msg->attrs_len); | 457 | attrs_len = ntohs(msg->attrs_len); |
464 | if (msg_len != sizeof (struct ConsumeTicketResultMessage) + attrs_len) | 458 | if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len) |
465 | { | 459 | { |
466 | GNUNET_break (0); | 460 | GNUNET_break(0); |
467 | return GNUNET_SYSERR; | 461 | return GNUNET_SYSERR; |
468 | } | 462 | } |
469 | return GNUNET_OK; | 463 | return GNUNET_OK; |
470 | } | 464 | } |
471 | 465 | ||
@@ -478,16 +472,16 @@ check_consume_ticket_result (void *cls, | |||
478 | * @param msg the message we received | 472 | * @param msg the message we received |
479 | */ | 473 | */ |
480 | static void | 474 | static void |
481 | handle_consume_ticket_result (void *cls, | 475 | handle_consume_ticket_result(void *cls, |
482 | const struct ConsumeTicketResultMessage *msg) | 476 | const struct ConsumeTicketResultMessage *msg) |
483 | { | 477 | { |
484 | struct GNUNET_RECLAIM_Handle *h = cls; | 478 | struct GNUNET_RECLAIM_Handle *h = cls; |
485 | struct GNUNET_RECLAIM_Operation *op; | 479 | struct GNUNET_RECLAIM_Operation *op; |
486 | size_t attrs_len; | 480 | size_t attrs_len; |
487 | uint32_t r_id = ntohl (msg->id); | 481 | uint32_t r_id = ntohl(msg->id); |
488 | 482 | ||
489 | attrs_len = ntohs (msg->attrs_len); | 483 | attrs_len = ntohs(msg->attrs_len); |
490 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); | 484 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); |
491 | 485 | ||
492 | 486 | ||
493 | for (op = h->op_head; NULL != op; op = op->next) | 487 | for (op = h->op_head; NULL != op; op = op->next) |
@@ -500,28 +494,28 @@ handle_consume_ticket_result (void *cls, | |||
500 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; | 494 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; |
501 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 495 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
502 | attrs = | 496 | attrs = |
503 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len); | 497 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize((char *)&msg[1], attrs_len); |
504 | if (NULL != op->ar_cb) | 498 | if (NULL != op->ar_cb) |
505 | { | ||
506 | if (NULL == attrs) | ||
507 | { | 499 | { |
508 | op->ar_cb (op->cls, &msg->identity, NULL); | 500 | if (NULL == attrs) |
501 | { | ||
502 | op->ar_cb(op->cls, &msg->identity, NULL); | ||
503 | } | ||
504 | else | ||
505 | { | ||
506 | for (le = attrs->list_head; NULL != le; le = le->next) | ||
507 | op->ar_cb(op->cls, &msg->identity, le->claim); | ||
508 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy(attrs); | ||
509 | attrs = NULL; | ||
510 | } | ||
511 | op->ar_cb(op->cls, NULL, NULL); | ||
509 | } | 512 | } |
510 | else | 513 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
511 | { | 514 | free_op(op); |
512 | for (le = attrs->list_head; NULL != le; le = le->next) | 515 | GNUNET_free_non_null(attrs); |
513 | op->ar_cb (op->cls, &msg->identity, le->claim); | ||
514 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); | ||
515 | attrs = NULL; | ||
516 | } | ||
517 | op->ar_cb (op->cls, NULL, NULL); | ||
518 | } | ||
519 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | ||
520 | free_op (op); | ||
521 | GNUNET_free_non_null (attrs); | ||
522 | return; | 516 | return; |
523 | } | 517 | } |
524 | GNUNET_assert (0); | 518 | GNUNET_assert(0); |
525 | } | 519 | } |
526 | 520 | ||
527 | 521 | ||
@@ -534,18 +528,18 @@ handle_consume_ticket_result (void *cls, | |||
534 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 528 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
535 | */ | 529 | */ |
536 | static int | 530 | static int |
537 | check_attribute_result (void *cls, const struct AttributeResultMessage *msg) | 531 | check_attribute_result(void *cls, const struct AttributeResultMessage *msg) |
538 | { | 532 | { |
539 | size_t msg_len; | 533 | size_t msg_len; |
540 | size_t attr_len; | 534 | size_t attr_len; |
541 | 535 | ||
542 | msg_len = ntohs (msg->header.size); | 536 | msg_len = ntohs(msg->header.size); |
543 | attr_len = ntohs (msg->attr_len); | 537 | attr_len = ntohs(msg->attr_len); |
544 | if (msg_len != sizeof (struct AttributeResultMessage) + attr_len) | 538 | if (msg_len != sizeof(struct AttributeResultMessage) + attr_len) |
545 | { | 539 | { |
546 | GNUNET_break (0); | 540 | GNUNET_break(0); |
547 | return GNUNET_SYSERR; | 541 | return GNUNET_SYSERR; |
548 | } | 542 | } |
549 | return GNUNET_OK; | 543 | return GNUNET_OK; |
550 | } | 544 | } |
551 | 545 | ||
@@ -558,17 +552,17 @@ check_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
558 | * @param msg the message we received | 552 | * @param msg the message we received |
559 | */ | 553 | */ |
560 | static void | 554 | static void |
561 | handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | 555 | handle_attribute_result(void *cls, const struct AttributeResultMessage *msg) |
562 | { | 556 | { |
563 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; | 557 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; |
564 | struct GNUNET_RECLAIM_Handle *h = cls; | 558 | struct GNUNET_RECLAIM_Handle *h = cls; |
565 | struct GNUNET_RECLAIM_AttributeIterator *it; | 559 | struct GNUNET_RECLAIM_AttributeIterator *it; |
566 | struct GNUNET_RECLAIM_Operation *op; | 560 | struct GNUNET_RECLAIM_Operation *op; |
567 | size_t attr_len; | 561 | size_t attr_len; |
568 | uint32_t r_id = ntohl (msg->id); | 562 | uint32_t r_id = ntohl(msg->id); |
569 | 563 | ||
570 | attr_len = ntohs (msg->attr_len); | 564 | attr_len = ntohs(msg->attr_len); |
571 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); | 565 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); |
572 | 566 | ||
573 | 567 | ||
574 | for (it = h->it_head; NULL != it; it = it->next) | 568 | for (it = h->it_head; NULL != it; it = it->next) |
@@ -581,47 +575,47 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
581 | return; | 575 | return; |
582 | 576 | ||
583 | if ((0 == | 577 | if ((0 == |
584 | (memcmp (&msg->identity, &identity_dummy, sizeof (identity_dummy))))) | 578 | (memcmp(&msg->identity, &identity_dummy, sizeof(identity_dummy))))) |
585 | { | ||
586 | if ((NULL == it) && (NULL == op)) | ||
587 | { | 579 | { |
588 | GNUNET_break (0); | 580 | if ((NULL == it) && (NULL == op)) |
589 | force_reconnect (h); | 581 | { |
582 | GNUNET_break(0); | ||
583 | force_reconnect(h); | ||
584 | return; | ||
585 | } | ||
586 | if (NULL != it) | ||
587 | { | ||
588 | if (NULL != it->finish_cb) | ||
589 | it->finish_cb(it->finish_cb_cls); | ||
590 | free_it(it); | ||
591 | } | ||
592 | if (NULL != op) | ||
593 | { | ||
594 | if (NULL != op->ar_cb) | ||
595 | op->ar_cb(op->cls, NULL, NULL); | ||
596 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); | ||
597 | free_op(op); | ||
598 | } | ||
590 | return; | 599 | return; |
591 | } | 600 | } |
592 | if (NULL != it) | ||
593 | { | ||
594 | if (NULL != it->finish_cb) | ||
595 | it->finish_cb (it->finish_cb_cls); | ||
596 | free_it (it); | ||
597 | } | ||
598 | if (NULL != op) | ||
599 | { | ||
600 | if (NULL != op->ar_cb) | ||
601 | op->ar_cb (op->cls, NULL, NULL); | ||
602 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | ||
603 | free_op (op); | ||
604 | } | ||
605 | return; | ||
606 | } | ||
607 | 601 | ||
608 | { | 602 | { |
609 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; | 603 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; |
610 | attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len); | 604 | attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&msg[1], attr_len); |
611 | if (NULL != it) | 605 | if (NULL != it) |
612 | { | 606 | { |
613 | if (NULL != it->proc) | 607 | if (NULL != it->proc) |
614 | it->proc (it->proc_cls, &msg->identity, attr); | 608 | it->proc(it->proc_cls, &msg->identity, attr); |
615 | } | 609 | } |
616 | else if (NULL != op) | 610 | else if (NULL != op) |
617 | { | 611 | { |
618 | if (NULL != op->ar_cb) | 612 | if (NULL != op->ar_cb) |
619 | op->ar_cb (op->cls, &msg->identity, attr); | 613 | op->ar_cb(op->cls, &msg->identity, attr); |
620 | } | 614 | } |
621 | GNUNET_free (attr); | 615 | GNUNET_free(attr); |
622 | return; | 616 | return; |
623 | } | 617 | } |
624 | GNUNET_assert (0); | 618 | GNUNET_assert(0); |
625 | } | 619 | } |
626 | 620 | ||
627 | 621 | ||
@@ -633,13 +627,14 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) | |||
633 | * @param msg the message we received | 627 | * @param msg the message we received |
634 | */ | 628 | */ |
635 | static void | 629 | static void |
636 | handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | 630 | handle_ticket_result(void *cls, const struct TicketResultMessage *msg) |
637 | { | 631 | { |
638 | struct GNUNET_RECLAIM_Handle *handle = cls; | 632 | struct GNUNET_RECLAIM_Handle *handle = cls; |
639 | struct GNUNET_RECLAIM_Operation *op; | 633 | struct GNUNET_RECLAIM_Operation *op; |
640 | struct GNUNET_RECLAIM_TicketIterator *it; | 634 | struct GNUNET_RECLAIM_TicketIterator *it; |
641 | uint32_t r_id = ntohl (msg->id); | 635 | uint32_t r_id = ntohl(msg->id); |
642 | static const struct GNUNET_RECLAIM_Ticket ticket; | 636 | static const struct GNUNET_RECLAIM_Ticket ticket; |
637 | |||
643 | for (op = handle->op_head; NULL != op; op = op->next) | 638 | for (op = handle->op_head; NULL != op; op = op->next) |
644 | if (op->r_id == r_id) | 639 | if (op->r_id == r_id) |
645 | break; | 640 | break; |
@@ -649,41 +644,41 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
649 | if ((NULL == op) && (NULL == it)) | 644 | if ((NULL == op) && (NULL == it)) |
650 | return; | 645 | return; |
651 | if (NULL != op) | 646 | if (NULL != op) |
652 | { | ||
653 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); | ||
654 | if (0 == | ||
655 | memcmp (&msg->ticket, &ticket, sizeof (struct GNUNET_RECLAIM_Ticket))) | ||
656 | { | 647 | { |
657 | if (NULL != op->tr_cb) | 648 | GNUNET_CONTAINER_DLL_remove(handle->op_head, handle->op_tail, op); |
658 | op->tr_cb (op->cls, NULL); | 649 | if (0 == |
659 | } | 650 | memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) |
660 | else | 651 | { |
661 | { | 652 | if (NULL != op->tr_cb) |
662 | if (NULL != op->tr_cb) | 653 | op->tr_cb(op->cls, NULL); |
663 | op->tr_cb (op->cls, &msg->ticket); | 654 | } |
655 | else | ||
656 | { | ||
657 | if (NULL != op->tr_cb) | ||
658 | op->tr_cb(op->cls, &msg->ticket); | ||
659 | } | ||
660 | free_op(op); | ||
661 | return; | ||
664 | } | 662 | } |
665 | free_op (op); | ||
666 | return; | ||
667 | } | ||
668 | else if (NULL != it) | 663 | else if (NULL != it) |
669 | { | ||
670 | if (0 == | ||
671 | memcmp (&msg->ticket, &ticket, sizeof (struct GNUNET_RECLAIM_Ticket))) | ||
672 | { | ||
673 | GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head, | ||
674 | handle->ticket_it_tail, | ||
675 | it); | ||
676 | it->finish_cb (it->finish_cb_cls); | ||
677 | GNUNET_free (it); | ||
678 | } | ||
679 | else | ||
680 | { | 664 | { |
681 | if (NULL != it->tr_cb) | 665 | if (0 == |
682 | it->tr_cb (it->cls, &msg->ticket); | 666 | memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) |
667 | { | ||
668 | GNUNET_CONTAINER_DLL_remove(handle->ticket_it_head, | ||
669 | handle->ticket_it_tail, | ||
670 | it); | ||
671 | it->finish_cb(it->finish_cb_cls); | ||
672 | GNUNET_free(it); | ||
673 | } | ||
674 | else | ||
675 | { | ||
676 | if (NULL != it->tr_cb) | ||
677 | it->tr_cb(it->cls, &msg->ticket); | ||
678 | } | ||
679 | return; | ||
683 | } | 680 | } |
684 | return; | 681 | GNUNET_break(0); |
685 | } | ||
686 | GNUNET_break (0); | ||
687 | } | 682 | } |
688 | 683 | ||
689 | 684 | ||
@@ -695,15 +690,15 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
695 | * @param msg the message we received | 690 | * @param msg the message we received |
696 | */ | 691 | */ |
697 | static void | 692 | static void |
698 | handle_revoke_ticket_result (void *cls, | 693 | handle_revoke_ticket_result(void *cls, |
699 | const struct RevokeTicketResultMessage *msg) | 694 | const struct RevokeTicketResultMessage *msg) |
700 | { | 695 | { |
701 | struct GNUNET_RECLAIM_Handle *h = cls; | 696 | struct GNUNET_RECLAIM_Handle *h = cls; |
702 | struct GNUNET_RECLAIM_Operation *op; | 697 | struct GNUNET_RECLAIM_Operation *op; |
703 | uint32_t r_id = ntohl (msg->id); | 698 | uint32_t r_id = ntohl(msg->id); |
704 | int32_t success; | 699 | int32_t success; |
705 | 700 | ||
706 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n"); | 701 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n"); |
707 | 702 | ||
708 | 703 | ||
709 | for (op = h->op_head; NULL != op; op = op->next) | 704 | for (op = h->op_head; NULL != op; op = op->next) |
@@ -711,17 +706,17 @@ handle_revoke_ticket_result (void *cls, | |||
711 | break; | 706 | break; |
712 | if (NULL == op) | 707 | if (NULL == op) |
713 | return; | 708 | return; |
714 | success = ntohl (msg->success); | 709 | success = ntohl(msg->success); |
715 | { | 710 | { |
716 | if (NULL != op->rvk_cb) | 711 | if (NULL != op->rvk_cb) |
717 | { | 712 | { |
718 | op->rvk_cb (op->cls, success, NULL); | 713 | op->rvk_cb(op->cls, success, NULL); |
719 | } | 714 | } |
720 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 715 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
721 | free_op (op); | 716 | free_op(op); |
722 | return; | 717 | return; |
723 | } | 718 | } |
724 | GNUNET_assert (0); | 719 | GNUNET_assert(0); |
725 | } | 720 | } |
726 | 721 | ||
727 | 722 | ||
@@ -731,41 +726,41 @@ handle_revoke_ticket_result (void *cls, | |||
731 | * @param h handle to the reclaim service. | 726 | * @param h handle to the reclaim service. |
732 | */ | 727 | */ |
733 | static void | 728 | static void |
734 | reconnect (struct GNUNET_RECLAIM_Handle *h) | 729 | reconnect(struct GNUNET_RECLAIM_Handle *h) |
735 | { | 730 | { |
736 | struct GNUNET_MQ_MessageHandler handlers[] = | 731 | struct GNUNET_MQ_MessageHandler handlers[] = |
737 | {GNUNET_MQ_hd_fixed_size (success_response, | 732 | { GNUNET_MQ_hd_fixed_size(success_response, |
738 | GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, | 733 | GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, |
739 | struct SuccessResultMessage, | 734 | struct SuccessResultMessage, |
740 | h), | ||
741 | GNUNET_MQ_hd_var_size (attribute_result, | ||
742 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, | ||
743 | struct AttributeResultMessage, | ||
744 | h), | 735 | h), |
745 | GNUNET_MQ_hd_fixed_size (ticket_result, | 736 | GNUNET_MQ_hd_var_size(attribute_result, |
746 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, | 737 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, |
747 | struct TicketResultMessage, | 738 | struct AttributeResultMessage, |
748 | h), | 739 | h), |
749 | GNUNET_MQ_hd_var_size (consume_ticket_result, | 740 | GNUNET_MQ_hd_fixed_size(ticket_result, |
750 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, | 741 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, |
751 | struct ConsumeTicketResultMessage, | 742 | struct TicketResultMessage, |
752 | h), | 743 | h), |
753 | GNUNET_MQ_hd_fixed_size (revoke_ticket_result, | 744 | GNUNET_MQ_hd_var_size(consume_ticket_result, |
754 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, | 745 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, |
755 | struct RevokeTicketResultMessage, | 746 | struct ConsumeTicketResultMessage, |
756 | h), | 747 | h), |
757 | GNUNET_MQ_handler_end ()}; | 748 | GNUNET_MQ_hd_fixed_size(revoke_ticket_result, |
749 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, | ||
750 | struct RevokeTicketResultMessage, | ||
751 | h), | ||
752 | GNUNET_MQ_handler_end() }; | ||
758 | struct GNUNET_RECLAIM_Operation *op; | 753 | struct GNUNET_RECLAIM_Operation *op; |
759 | 754 | ||
760 | GNUNET_assert (NULL == h->mq); | 755 | GNUNET_assert(NULL == h->mq); |
761 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n"); | 756 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n"); |
762 | 757 | ||
763 | h->mq = | 758 | h->mq = |
764 | GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h); | 759 | GNUNET_CLIENT_connect(h->cfg, "reclaim", handlers, &mq_error_handler, h); |
765 | if (NULL == h->mq) | 760 | if (NULL == h->mq) |
766 | return; | 761 | return; |
767 | for (op = h->op_head; NULL != op; op = op->next) | 762 | for (op = h->op_head; NULL != op; op = op->next) |
768 | GNUNET_MQ_send_copy (h->mq, op->env); | 763 | GNUNET_MQ_send_copy(h->mq, op->env); |
769 | } | 764 | } |
770 | 765 | ||
771 | 766 | ||
@@ -776,18 +771,18 @@ reconnect (struct GNUNET_RECLAIM_Handle *h) | |||
776 | * @return handle to use | 771 | * @return handle to use |
777 | */ | 772 | */ |
778 | struct GNUNET_RECLAIM_Handle * | 773 | struct GNUNET_RECLAIM_Handle * |
779 | GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | 774 | GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) |
780 | { | 775 | { |
781 | struct GNUNET_RECLAIM_Handle *h; | 776 | struct GNUNET_RECLAIM_Handle *h; |
782 | 777 | ||
783 | h = GNUNET_new (struct GNUNET_RECLAIM_Handle); | 778 | h = GNUNET_new(struct GNUNET_RECLAIM_Handle); |
784 | h->cfg = cfg; | 779 | h->cfg = cfg; |
785 | reconnect (h); | 780 | reconnect(h); |
786 | if (NULL == h->mq) | 781 | if (NULL == h->mq) |
787 | { | 782 | { |
788 | GNUNET_free (h); | 783 | GNUNET_free(h); |
789 | return NULL; | 784 | return NULL; |
790 | } | 785 | } |
791 | return h; | 786 | return h; |
792 | } | 787 | } |
793 | 788 | ||
@@ -801,12 +796,12 @@ GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
801 | * @param op operation to cancel | 796 | * @param op operation to cancel |
802 | */ | 797 | */ |
803 | void | 798 | void |
804 | GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op) | 799 | GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op) |
805 | { | 800 | { |
806 | struct GNUNET_RECLAIM_Handle *h = op->h; | 801 | struct GNUNET_RECLAIM_Handle *h = op->h; |
807 | 802 | ||
808 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 803 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
809 | free_op (op); | 804 | free_op(op); |
810 | } | 805 | } |
811 | 806 | ||
812 | 807 | ||
@@ -816,21 +811,21 @@ GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op) | |||
816 | * @param h handle to destroy | 811 | * @param h handle to destroy |
817 | */ | 812 | */ |
818 | void | 813 | void |
819 | GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h) | 814 | GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h) |
820 | { | 815 | { |
821 | GNUNET_assert (NULL != h); | 816 | GNUNET_assert(NULL != h); |
822 | if (NULL != h->mq) | 817 | if (NULL != h->mq) |
823 | { | 818 | { |
824 | GNUNET_MQ_destroy (h->mq); | 819 | GNUNET_MQ_destroy(h->mq); |
825 | h->mq = NULL; | 820 | h->mq = NULL; |
826 | } | 821 | } |
827 | if (NULL != h->reconnect_task) | 822 | if (NULL != h->reconnect_task) |
828 | { | 823 | { |
829 | GNUNET_SCHEDULER_cancel (h->reconnect_task); | 824 | GNUNET_SCHEDULER_cancel(h->reconnect_task); |
830 | h->reconnect_task = NULL; | 825 | h->reconnect_task = NULL; |
831 | } | 826 | } |
832 | GNUNET_assert (NULL == h->op_head); | 827 | GNUNET_assert(NULL == h->op_head); |
833 | GNUNET_free (h); | 828 | GNUNET_free(h); |
834 | } | 829 | } |
835 | 830 | ||
836 | /** | 831 | /** |
@@ -846,7 +841,7 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h) | |||
846 | * @return handle to abort the request | 841 | * @return handle to abort the request |
847 | */ | 842 | */ |
848 | struct GNUNET_RECLAIM_Operation * | 843 | struct GNUNET_RECLAIM_Operation * |
849 | GNUNET_RECLAIM_attribute_store ( | 844 | GNUNET_RECLAIM_attribute_store( |
850 | struct GNUNET_RECLAIM_Handle *h, | 845 | struct GNUNET_RECLAIM_Handle *h, |
851 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 846 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
852 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 847 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
@@ -858,25 +853,25 @@ GNUNET_RECLAIM_attribute_store ( | |||
858 | struct AttributeStoreMessage *sam; | 853 | struct AttributeStoreMessage *sam; |
859 | size_t attr_len; | 854 | size_t attr_len; |
860 | 855 | ||
861 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 856 | op = GNUNET_new(struct GNUNET_RECLAIM_Operation); |
862 | op->h = h; | 857 | op->h = h; |
863 | op->as_cb = cont; | 858 | op->as_cb = cont; |
864 | op->cls = cont_cls; | 859 | op->cls = cont_cls; |
865 | op->r_id = h->r_id_gen++; | 860 | op->r_id = h->r_id_gen++; |
866 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 861 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
867 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); | 862 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(attr); |
868 | op->env = GNUNET_MQ_msg_extra (sam, | 863 | op->env = GNUNET_MQ_msg_extra(sam, |
869 | attr_len, | 864 | attr_len, |
870 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); | 865 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); |
871 | sam->identity = *pkey; | 866 | sam->identity = *pkey; |
872 | sam->id = htonl (op->r_id); | 867 | sam->id = htonl(op->r_id); |
873 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | 868 | sam->exp = GNUNET_htonll(exp_interval->rel_value_us); |
874 | 869 | ||
875 | GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]); | 870 | GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&sam[1]); |
876 | 871 | ||
877 | sam->attr_len = htons (attr_len); | 872 | sam->attr_len = htons(attr_len); |
878 | if (NULL != h->mq) | 873 | if (NULL != h->mq) |
879 | GNUNET_MQ_send_copy (h->mq, op->env); | 874 | GNUNET_MQ_send_copy(h->mq, op->env); |
880 | return op; | 875 | return op; |
881 | } | 876 | } |
882 | 877 | ||
@@ -893,7 +888,7 @@ GNUNET_RECLAIM_attribute_store ( | |||
893 | * @return handle Used to to abort the request | 888 | * @return handle Used to to abort the request |
894 | */ | 889 | */ |
895 | struct GNUNET_RECLAIM_Operation * | 890 | struct GNUNET_RECLAIM_Operation * |
896 | GNUNET_RECLAIM_attribute_delete ( | 891 | GNUNET_RECLAIM_attribute_delete( |
897 | struct GNUNET_RECLAIM_Handle *h, | 892 | struct GNUNET_RECLAIM_Handle *h, |
898 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 893 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
899 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 894 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
@@ -904,23 +899,23 @@ GNUNET_RECLAIM_attribute_delete ( | |||
904 | struct AttributeDeleteMessage *dam; | 899 | struct AttributeDeleteMessage *dam; |
905 | size_t attr_len; | 900 | size_t attr_len; |
906 | 901 | ||
907 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 902 | op = GNUNET_new(struct GNUNET_RECLAIM_Operation); |
908 | op->h = h; | 903 | op->h = h; |
909 | op->as_cb = cont; | 904 | op->as_cb = cont; |
910 | op->cls = cont_cls; | 905 | op->cls = cont_cls; |
911 | op->r_id = h->r_id_gen++; | 906 | op->r_id = h->r_id_gen++; |
912 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 907 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
913 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); | 908 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(attr); |
914 | op->env = GNUNET_MQ_msg_extra (dam, | 909 | op->env = GNUNET_MQ_msg_extra(dam, |
915 | attr_len, | 910 | attr_len, |
916 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); | 911 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); |
917 | dam->identity = *pkey; | 912 | dam->identity = *pkey; |
918 | dam->id = htonl (op->r_id); | 913 | dam->id = htonl(op->r_id); |
919 | GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]); | 914 | GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&dam[1]); |
920 | 915 | ||
921 | dam->attr_len = htons (attr_len); | 916 | dam->attr_len = htons(attr_len); |
922 | if (NULL != h->mq) | 917 | if (NULL != h->mq) |
923 | GNUNET_MQ_send_copy (h->mq, op->env); | 918 | GNUNET_MQ_send_copy(h->mq, op->env); |
924 | return op; | 919 | return op; |
925 | } | 920 | } |
926 | 921 | ||
@@ -950,7 +945,7 @@ GNUNET_RECLAIM_attribute_delete ( | |||
950 | * @return an iterator Handle to use for iteration | 945 | * @return an iterator Handle to use for iteration |
951 | */ | 946 | */ |
952 | struct GNUNET_RECLAIM_AttributeIterator * | 947 | struct GNUNET_RECLAIM_AttributeIterator * |
953 | GNUNET_RECLAIM_get_attributes_start ( | 948 | GNUNET_RECLAIM_get_attributes_start( |
954 | struct GNUNET_RECLAIM_Handle *h, | 949 | struct GNUNET_RECLAIM_Handle *h, |
955 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 950 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
956 | GNUNET_SCHEDULER_TaskCallback error_cb, | 951 | GNUNET_SCHEDULER_TaskCallback error_cb, |
@@ -966,7 +961,7 @@ GNUNET_RECLAIM_get_attributes_start ( | |||
966 | uint32_t rid; | 961 | uint32_t rid; |
967 | 962 | ||
968 | rid = h->r_id_gen++; | 963 | rid = h->r_id_gen++; |
969 | it = GNUNET_new (struct GNUNET_RECLAIM_AttributeIterator); | 964 | it = GNUNET_new(struct GNUNET_RECLAIM_AttributeIterator); |
970 | it->h = h; | 965 | it->h = h; |
971 | it->error_cb = error_cb; | 966 | it->error_cb = error_cb; |
972 | it->error_cb_cls = error_cb_cls; | 967 | it->error_cb_cls = error_cb_cls; |
@@ -976,15 +971,15 @@ GNUNET_RECLAIM_get_attributes_start ( | |||
976 | it->proc_cls = proc_cls; | 971 | it->proc_cls = proc_cls; |
977 | it->r_id = rid; | 972 | it->r_id = rid; |
978 | it->identity = *identity; | 973 | it->identity = *identity; |
979 | GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it); | 974 | GNUNET_CONTAINER_DLL_insert_tail(h->it_head, h->it_tail, it); |
980 | env = | 975 | env = |
981 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); | 976 | GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); |
982 | msg->id = htonl (rid); | 977 | msg->id = htonl(rid); |
983 | msg->identity = *identity; | 978 | msg->identity = *identity; |
984 | if (NULL == h->mq) | 979 | if (NULL == h->mq) |
985 | it->env = env; | 980 | it->env = env; |
986 | else | 981 | else |
987 | GNUNET_MQ_send (h->mq, env); | 982 | GNUNET_MQ_send(h->mq, env); |
988 | return it; | 983 | return it; |
989 | } | 984 | } |
990 | 985 | ||
@@ -996,16 +991,16 @@ GNUNET_RECLAIM_get_attributes_start ( | |||
996 | * @param it the iterator | 991 | * @param it the iterator |
997 | */ | 992 | */ |
998 | void | 993 | void |
999 | GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it) | 994 | GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it) |
1000 | { | 995 | { |
1001 | struct GNUNET_RECLAIM_Handle *h = it->h; | 996 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1002 | struct AttributeIterationNextMessage *msg; | 997 | struct AttributeIterationNextMessage *msg; |
1003 | struct GNUNET_MQ_Envelope *env; | 998 | struct GNUNET_MQ_Envelope *env; |
1004 | 999 | ||
1005 | env = | 1000 | env = |
1006 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); | 1001 | GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); |
1007 | msg->id = htonl (it->r_id); | 1002 | msg->id = htonl(it->r_id); |
1008 | GNUNET_MQ_send (h->mq, env); | 1003 | GNUNET_MQ_send(h->mq, env); |
1009 | } | 1004 | } |
1010 | 1005 | ||
1011 | 1006 | ||
@@ -1017,20 +1012,20 @@ GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
1017 | * @param it the iterator | 1012 | * @param it the iterator |
1018 | */ | 1013 | */ |
1019 | void | 1014 | void |
1020 | GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) | 1015 | GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it) |
1021 | { | 1016 | { |
1022 | struct GNUNET_RECLAIM_Handle *h = it->h; | 1017 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1023 | struct GNUNET_MQ_Envelope *env; | 1018 | struct GNUNET_MQ_Envelope *env; |
1024 | struct AttributeIterationStopMessage *msg; | 1019 | struct AttributeIterationStopMessage *msg; |
1025 | 1020 | ||
1026 | if (NULL != h->mq) | 1021 | if (NULL != h->mq) |
1027 | { | 1022 | { |
1028 | env = | 1023 | env = |
1029 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP); | 1024 | GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP); |
1030 | msg->id = htonl (it->r_id); | 1025 | msg->id = htonl(it->r_id); |
1031 | GNUNET_MQ_send (h->mq, env); | 1026 | GNUNET_MQ_send(h->mq, env); |
1032 | } | 1027 | } |
1033 | free_it (it); | 1028 | free_it(it); |
1034 | } | 1029 | } |
1035 | 1030 | ||
1036 | 1031 | ||
@@ -1048,7 +1043,7 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) | |||
1048 | * @return handle to abort the operation | 1043 | * @return handle to abort the operation |
1049 | */ | 1044 | */ |
1050 | struct GNUNET_RECLAIM_Operation * | 1045 | struct GNUNET_RECLAIM_Operation * |
1051 | GNUNET_RECLAIM_ticket_issue ( | 1046 | GNUNET_RECLAIM_ticket_issue( |
1052 | struct GNUNET_RECLAIM_Handle *h, | 1047 | struct GNUNET_RECLAIM_Handle *h, |
1053 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, | 1048 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, |
1054 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, | 1049 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, |
@@ -1059,26 +1054,27 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1059 | struct GNUNET_RECLAIM_Operation *op; | 1054 | struct GNUNET_RECLAIM_Operation *op; |
1060 | struct IssueTicketMessage *tim; | 1055 | struct IssueTicketMessage *tim; |
1061 | size_t attr_len; | 1056 | size_t attr_len; |
1062 | fprintf (stderr, "Issuing ticket\n"); | 1057 | |
1063 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1058 | fprintf(stderr, "Issuing ticket\n"); |
1059 | op = GNUNET_new(struct GNUNET_RECLAIM_Operation); | ||
1064 | op->h = h; | 1060 | op->h = h; |
1065 | op->tr_cb = cb; | 1061 | op->tr_cb = cb; |
1066 | op->cls = cb_cls; | 1062 | op->cls = cb_cls; |
1067 | op->r_id = h->r_id_gen++; | 1063 | op->r_id = h->r_id_gen++; |
1068 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1064 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
1069 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); | 1065 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(attrs); |
1070 | op->env = GNUNET_MQ_msg_extra (tim, | 1066 | op->env = GNUNET_MQ_msg_extra(tim, |
1071 | attr_len, | 1067 | attr_len, |
1072 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); | 1068 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); |
1073 | tim->identity = *iss; | 1069 | tim->identity = *iss; |
1074 | tim->rp = *rp; | 1070 | tim->rp = *rp; |
1075 | tim->id = htonl (op->r_id); | 1071 | tim->id = htonl(op->r_id); |
1076 | 1072 | ||
1077 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]); | 1073 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize(attrs, (char *)&tim[1]); |
1078 | 1074 | ||
1079 | tim->attr_len = htons (attr_len); | 1075 | tim->attr_len = htons(attr_len); |
1080 | if (NULL != h->mq) | 1076 | if (NULL != h->mq) |
1081 | GNUNET_MQ_send_copy (h->mq, op->env); | 1077 | GNUNET_MQ_send_copy(h->mq, op->env); |
1082 | return op; | 1078 | return op; |
1083 | } | 1079 | } |
1084 | 1080 | ||
@@ -1096,7 +1092,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
1096 | * @return handle to abort the operation | 1092 | * @return handle to abort the operation |
1097 | */ | 1093 | */ |
1098 | struct GNUNET_RECLAIM_Operation * | 1094 | struct GNUNET_RECLAIM_Operation * |
1099 | GNUNET_RECLAIM_ticket_consume ( | 1095 | GNUNET_RECLAIM_ticket_consume( |
1100 | struct GNUNET_RECLAIM_Handle *h, | 1096 | struct GNUNET_RECLAIM_Handle *h, |
1101 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1097 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1102 | const struct GNUNET_RECLAIM_Ticket *ticket, | 1098 | const struct GNUNET_RECLAIM_Ticket *ticket, |
@@ -1106,18 +1102,18 @@ GNUNET_RECLAIM_ticket_consume ( | |||
1106 | struct GNUNET_RECLAIM_Operation *op; | 1102 | struct GNUNET_RECLAIM_Operation *op; |
1107 | struct ConsumeTicketMessage *ctm; | 1103 | struct ConsumeTicketMessage *ctm; |
1108 | 1104 | ||
1109 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1105 | op = GNUNET_new(struct GNUNET_RECLAIM_Operation); |
1110 | op->h = h; | 1106 | op->h = h; |
1111 | op->ar_cb = cb; | 1107 | op->ar_cb = cb; |
1112 | op->cls = cb_cls; | 1108 | op->cls = cb_cls; |
1113 | op->r_id = h->r_id_gen++; | 1109 | op->r_id = h->r_id_gen++; |
1114 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1110 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
1115 | op->env = GNUNET_MQ_msg (ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); | 1111 | op->env = GNUNET_MQ_msg(ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); |
1116 | ctm->identity = *identity; | 1112 | ctm->identity = *identity; |
1117 | ctm->id = htonl (op->r_id); | 1113 | ctm->id = htonl(op->r_id); |
1118 | ctm->ticket = *ticket; | 1114 | ctm->ticket = *ticket; |
1119 | if (NULL != h->mq) | 1115 | if (NULL != h->mq) |
1120 | GNUNET_MQ_send_copy (h->mq, op->env); | 1116 | GNUNET_MQ_send_copy(h->mq, op->env); |
1121 | return op; | 1117 | return op; |
1122 | } | 1118 | } |
1123 | 1119 | ||
@@ -1140,7 +1136,7 @@ GNUNET_RECLAIM_ticket_consume ( | |||
1140 | * @return an iterator handle to use for iteration | 1136 | * @return an iterator handle to use for iteration |
1141 | */ | 1137 | */ |
1142 | struct GNUNET_RECLAIM_TicketIterator * | 1138 | struct GNUNET_RECLAIM_TicketIterator * |
1143 | GNUNET_RECLAIM_ticket_iteration_start ( | 1139 | GNUNET_RECLAIM_ticket_iteration_start( |
1144 | struct GNUNET_RECLAIM_Handle *h, | 1140 | struct GNUNET_RECLAIM_Handle *h, |
1145 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1141 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1146 | GNUNET_SCHEDULER_TaskCallback error_cb, | 1142 | GNUNET_SCHEDULER_TaskCallback error_cb, |
@@ -1156,7 +1152,7 @@ GNUNET_RECLAIM_ticket_iteration_start ( | |||
1156 | uint32_t rid; | 1152 | uint32_t rid; |
1157 | 1153 | ||
1158 | rid = h->r_id_gen++; | 1154 | rid = h->r_id_gen++; |
1159 | it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator); | 1155 | it = GNUNET_new(struct GNUNET_RECLAIM_TicketIterator); |
1160 | it->h = h; | 1156 | it->h = h; |
1161 | it->error_cb = error_cb; | 1157 | it->error_cb = error_cb; |
1162 | it->error_cb_cls = error_cb_cls; | 1158 | it->error_cb_cls = error_cb_cls; |
@@ -1165,14 +1161,14 @@ GNUNET_RECLAIM_ticket_iteration_start ( | |||
1165 | it->tr_cb = proc; | 1161 | it->tr_cb = proc; |
1166 | it->cls = proc_cls; | 1162 | it->cls = proc_cls; |
1167 | it->r_id = rid; | 1163 | it->r_id = rid; |
1168 | GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it); | 1164 | GNUNET_CONTAINER_DLL_insert_tail(h->ticket_it_head, h->ticket_it_tail, it); |
1169 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); | 1165 | env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); |
1170 | msg->id = htonl (rid); | 1166 | msg->id = htonl(rid); |
1171 | msg->identity = *identity; | 1167 | msg->identity = *identity; |
1172 | if (NULL == h->mq) | 1168 | if (NULL == h->mq) |
1173 | it->env = env; | 1169 | it->env = env; |
1174 | else | 1170 | else |
1175 | GNUNET_MQ_send (h->mq, env); | 1171 | GNUNET_MQ_send(h->mq, env); |
1176 | return it; | 1172 | return it; |
1177 | } | 1173 | } |
1178 | 1174 | ||
@@ -1184,15 +1180,15 @@ GNUNET_RECLAIM_ticket_iteration_start ( | |||
1184 | * @param it the iterator | 1180 | * @param it the iterator |
1185 | */ | 1181 | */ |
1186 | void | 1182 | void |
1187 | GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it) | 1183 | GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it) |
1188 | { | 1184 | { |
1189 | struct GNUNET_RECLAIM_Handle *h = it->h; | 1185 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1190 | struct TicketIterationNextMessage *msg; | 1186 | struct TicketIterationNextMessage *msg; |
1191 | struct GNUNET_MQ_Envelope *env; | 1187 | struct GNUNET_MQ_Envelope *env; |
1192 | 1188 | ||
1193 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT); | 1189 | env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT); |
1194 | msg->id = htonl (it->r_id); | 1190 | msg->id = htonl(it->r_id); |
1195 | GNUNET_MQ_send (h->mq, env); | 1191 | GNUNET_MQ_send(h->mq, env); |
1196 | } | 1192 | } |
1197 | 1193 | ||
1198 | 1194 | ||
@@ -1204,20 +1200,20 @@ GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it) | |||
1204 | * @param it the iterator | 1200 | * @param it the iterator |
1205 | */ | 1201 | */ |
1206 | void | 1202 | void |
1207 | GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it) | 1203 | GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it) |
1208 | { | 1204 | { |
1209 | struct GNUNET_RECLAIM_Handle *h = it->h; | 1205 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1210 | struct GNUNET_MQ_Envelope *env; | 1206 | struct GNUNET_MQ_Envelope *env; |
1211 | struct TicketIterationStopMessage *msg; | 1207 | struct TicketIterationStopMessage *msg; |
1212 | 1208 | ||
1213 | if (NULL != h->mq) | 1209 | if (NULL != h->mq) |
1214 | { | 1210 | { |
1215 | env = | 1211 | env = |
1216 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); | 1212 | GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); |
1217 | msg->id = htonl (it->r_id); | 1213 | msg->id = htonl(it->r_id); |
1218 | GNUNET_MQ_send (h->mq, env); | 1214 | GNUNET_MQ_send(h->mq, env); |
1219 | } | 1215 | } |
1220 | GNUNET_free (it); | 1216 | GNUNET_free(it); |
1221 | } | 1217 | } |
1222 | 1218 | ||
1223 | 1219 | ||
@@ -1235,7 +1231,7 @@ GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it) | |||
1235 | * @return handle to abort the operation | 1231 | * @return handle to abort the operation |
1236 | */ | 1232 | */ |
1237 | struct GNUNET_RECLAIM_Operation * | 1233 | struct GNUNET_RECLAIM_Operation * |
1238 | GNUNET_RECLAIM_ticket_revoke ( | 1234 | GNUNET_RECLAIM_ticket_revoke( |
1239 | struct GNUNET_RECLAIM_Handle *h, | 1235 | struct GNUNET_RECLAIM_Handle *h, |
1240 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1236 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1241 | const struct GNUNET_RECLAIM_Ticket *ticket, | 1237 | const struct GNUNET_RECLAIM_Ticket *ticket, |
@@ -1247,21 +1243,21 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
1247 | uint32_t rid; | 1243 | uint32_t rid; |
1248 | 1244 | ||
1249 | rid = h->r_id_gen++; | 1245 | rid = h->r_id_gen++; |
1250 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | 1246 | op = GNUNET_new(struct GNUNET_RECLAIM_Operation); |
1251 | op->h = h; | 1247 | op->h = h; |
1252 | op->rvk_cb = cb; | 1248 | op->rvk_cb = cb; |
1253 | op->cls = cb_cls; | 1249 | op->cls = cb_cls; |
1254 | op->r_id = rid; | 1250 | op->r_id = rid; |
1255 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1251 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
1256 | op->env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); | 1252 | op->env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); |
1257 | msg->id = htonl (rid); | 1253 | msg->id = htonl(rid); |
1258 | msg->identity = *identity; | 1254 | msg->identity = *identity; |
1259 | msg->ticket = *ticket; | 1255 | msg->ticket = *ticket; |
1260 | if (NULL != h->mq) | 1256 | if (NULL != h->mq) |
1261 | { | 1257 | { |
1262 | GNUNET_MQ_send (h->mq, op->env); | 1258 | GNUNET_MQ_send(h->mq, op->env); |
1263 | op->env = NULL; | 1259 | op->env = NULL; |
1264 | } | 1260 | } |
1265 | return op; | 1261 | return op; |
1266 | } | 1262 | } |
1267 | 1263 | ||