aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/reclaim_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 09:51:33 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 10:01:24 +0200
commit48b97768c64eb4e2695756b44e95eedacdf21c02 (patch)
tree366c65e27fe09d8cffd1cea3b4ae1e736274b7fa /src/reclaim/reclaim_api.c
parenteb2d072aa1096c9d77cbfde239a1004cab642e64 (diff)
downloadgnunet-48b97768c64eb4e2695756b44e95eedacdf21c02.tar.gz
gnunet-48b97768c64eb4e2695756b44e95eedacdf21c02.zip
RECLAIM: remove sqlite plugin; housekeeping
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r--src/reclaim/reclaim_api.c501
1 files changed, 195 insertions, 306 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index dd6a249b5..0edae76c2 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -24,15 +24,17 @@
24 * @author Martin Schanzenbach 24 * @author Martin Schanzenbach
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29
28#include "gnunet_constants.h" 30#include "gnunet_constants.h"
29#include "gnunet_protocols.h"
30#include "gnunet_mq_lib.h" 31#include "gnunet_mq_lib.h"
31#include "gnunet_reclaim_service.h" 32#include "gnunet_protocols.h"
32#include "gnunet_reclaim_attribute_lib.h" 33#include "gnunet_reclaim_attribute_lib.h"
34#include "gnunet_reclaim_service.h"
33#include "reclaim.h" 35#include "reclaim.h"
34 36
35#define LOG(kind,...) GNUNET_log_from (kind, "reclaim-api",__VA_ARGS__) 37#define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)
36 38
37 39
38/** 40/**
@@ -96,9 +98,9 @@ struct GNUNET_RECLAIM_Operation
96 * Closure for @e cont or @e cb. 98 * Closure for @e cont or @e cb.
97 */ 99 */
98 void *cls; 100 void *cls;
99
100}; 101};
101 102
103
102/** 104/**
103 * Handle for a ticket iterator operation 105 * Handle for a ticket iterator operation
104 */ 106 */
@@ -126,7 +128,7 @@ struct GNUNET_RECLAIM_TicketIterator
126 GNUNET_SCHEDULER_TaskCallback finish_cb; 128 GNUNET_SCHEDULER_TaskCallback finish_cb;
127 129
128 /** 130 /**
129 * Closure for @e error_cb. 131 * Closure for @e finish_cb.
130 */ 132 */
131 void *finish_cb_cls; 133 void *finish_cb_cls;
132 134
@@ -160,7 +162,6 @@ struct GNUNET_RECLAIM_TicketIterator
160 * The operation id this zone iteration operation has 162 * The operation id this zone iteration operation has
161 */ 163 */
162 uint32_t r_id; 164 uint32_t r_id;
163
164}; 165};
165 166
166 167
@@ -181,7 +182,7 @@ struct GNUNET_RECLAIM_AttributeIterator
181 struct GNUNET_RECLAIM_AttributeIterator *prev; 182 struct GNUNET_RECLAIM_AttributeIterator *prev;
182 183
183 /** 184 /**
184 * Main handle to access the idp. 185 * Main handle to access the service.
185 */ 186 */
186 struct GNUNET_RECLAIM_Handle *h; 187 struct GNUNET_RECLAIM_Handle *h;
187 188
@@ -191,7 +192,7 @@ struct GNUNET_RECLAIM_AttributeIterator
191 GNUNET_SCHEDULER_TaskCallback finish_cb; 192 GNUNET_SCHEDULER_TaskCallback finish_cb;
192 193
193 /** 194 /**
194 * Closure for @e error_cb. 195 * Closure for @e finish_cb.
195 */ 196 */
196 void *finish_cb_cls; 197 void *finish_cb_cls;
197 198
@@ -230,12 +231,11 @@ struct GNUNET_RECLAIM_AttributeIterator
230 * The operation id this zone iteration operation has 231 * The operation id this zone iteration operation has
231 */ 232 */
232 uint32_t r_id; 233 uint32_t r_id;
233
234}; 234};
235 235
236 236
237/** 237/**
238 * Handle for the service. 238 * Handle to the service.
239 */ 239 */
240struct GNUNET_RECLAIM_Handle 240struct GNUNET_RECLAIM_Handle
241{ 241{
@@ -284,7 +284,6 @@ struct GNUNET_RECLAIM_Handle
284 */ 284 */
285 struct GNUNET_RECLAIM_TicketIterator *ticket_it_tail; 285 struct GNUNET_RECLAIM_TicketIterator *ticket_it_tail;
286 286
287
288 /** 287 /**
289 * Currently pending transmission request, or NULL for none. 288 * Currently pending transmission request, or NULL for none.
290 */ 289 */
@@ -293,7 +292,7 @@ struct GNUNET_RECLAIM_Handle
293 /** 292 /**
294 * Task doing exponential back-off trying to reconnect. 293 * Task doing exponential back-off trying to reconnect.
295 */ 294 */
296 struct GNUNET_SCHEDULER_Task * reconnect_task; 295 struct GNUNET_SCHEDULER_Task *reconnect_task;
297 296
298 /** 297 /**
299 * Time for next connect retry. 298 * Time for next connect retry.
@@ -314,9 +313,9 @@ struct GNUNET_RECLAIM_Handle
314 * Are we polling for incoming messages right now? 313 * Are we polling for incoming messages right now?
315 */ 314 */
316 int in_receive; 315 int in_receive;
317
318}; 316};
319 317
318
320/** 319/**
321 * Try again to connect to the service. 320 * Try again to connect to the service.
322 * 321 *
@@ -325,6 +324,7 @@ struct GNUNET_RECLAIM_Handle
325static void 324static void
326reconnect (struct GNUNET_RECLAIM_Handle *h); 325reconnect (struct GNUNET_RECLAIM_Handle *h);
327 326
327
328/** 328/**
329 * Reconnect 329 * Reconnect
330 * 330 *
@@ -350,14 +350,13 @@ force_reconnect (struct GNUNET_RECLAIM_Handle *handle)
350{ 350{
351 GNUNET_MQ_destroy (handle->mq); 351 GNUNET_MQ_destroy (handle->mq);
352 handle->mq = NULL; 352 handle->mq = NULL;
353 handle->reconnect_backoff 353 handle->reconnect_backoff =
354 = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); 354 GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
355 handle->reconnect_task 355 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (
356 = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, 356 handle->reconnect_backoff, &reconnect_task, handle);
357 &reconnect_task,
358 handle);
359} 357}
360 358
359
361/** 360/**
362 * Free @a it. 361 * Free @a it.
363 * 362 *
@@ -368,22 +367,25 @@ free_it (struct GNUNET_RECLAIM_AttributeIterator *it)
368{ 367{
369 struct GNUNET_RECLAIM_Handle *h = it->h; 368 struct GNUNET_RECLAIM_Handle *h = it->h;
370 369
371 GNUNET_CONTAINER_DLL_remove (h->it_head, 370 GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it);
372 h->it_tail,
373 it);
374 if (NULL != it->env) 371 if (NULL != it->env)
375 GNUNET_MQ_discard (it->env); 372 GNUNET_MQ_discard (it->env);
376 GNUNET_free (it); 373 GNUNET_free (it);
377} 374}
378 375
376/**
377 * Free @a op
378 *
379 * @param op the operation to free
380 */
379static void 381static void
380free_op (struct GNUNET_RECLAIM_Operation* op) 382free_op (struct GNUNET_RECLAIM_Operation *op)
381{ 383{
382 if (NULL == op) 384 if (NULL == op)
383 return; 385 return;
384 if (NULL != op->env) 386 if (NULL != op->env)
385 GNUNET_MQ_discard (op->env); 387 GNUNET_MQ_discard (op->env);
386 GNUNET_free(op); 388 GNUNET_free (op);
387} 389}
388 390
389 391
@@ -396,13 +398,13 @@ free_op (struct GNUNET_RECLAIM_Operation* op)
396 * @param error error code 398 * @param error error code
397 */ 399 */
398static void 400static void
399mq_error_handler (void *cls, 401mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
400 enum GNUNET_MQ_Error error)
401{ 402{
402 struct GNUNET_RECLAIM_Handle *handle = cls; 403 struct GNUNET_RECLAIM_Handle *handle = cls;
403 force_reconnect (handle); 404 force_reconnect (handle);
404} 405}
405 406
407
406/** 408/**
407 * Handle an incoming message of type 409 * Handle an incoming message of type
408 * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE 410 * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
@@ -412,7 +414,7 @@ mq_error_handler (void *cls,
412 */ 414 */
413static void 415static void
414handle_attribute_store_response (void *cls, 416handle_attribute_store_response (void *cls,
415 const struct AttributeStoreResultMessage *msg) 417 const struct AttributeStoreResultMessage *msg)
416{ 418{
417 struct GNUNET_RECLAIM_Handle *h = cls; 419 struct GNUNET_RECLAIM_Handle *h = cls;
418 struct GNUNET_RECLAIM_Operation *op; 420 struct GNUNET_RECLAIM_Operation *op;
@@ -428,23 +430,17 @@ handle_attribute_store_response (void *cls,
428 430
429 res = ntohl (msg->op_result); 431 res = ntohl (msg->op_result);
430 LOG (GNUNET_ERROR_TYPE_DEBUG, 432 LOG (GNUNET_ERROR_TYPE_DEBUG,
431 "Received ATTRIBUTE_STORE_RESPONSE with result %d\n", 433 "Received ATTRIBUTE_STORE_RESPONSE with result %d\n", res);
432 res);
433 434
434 /* TODO: add actual error message to response... */ 435 /* TODO: add actual error message to response... */
435 if (GNUNET_SYSERR == res) 436 if (GNUNET_SYSERR == res)
436 emsg = _("failed to store record\n"); 437 emsg = _ ("failed to store record\n");
437 else 438 else
438 emsg = NULL; 439 emsg = NULL;
439 if (NULL != op->as_cb) 440 if (NULL != op->as_cb)
440 op->as_cb (op->cls, 441 op->as_cb (op->cls, res, emsg);
441 res, 442 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
442 emsg);
443 GNUNET_CONTAINER_DLL_remove (h->op_head,
444 h->op_tail,
445 op);
446 free_op (op); 443 free_op (op);
447
448} 444}
449 445
450 446
@@ -465,8 +461,7 @@ check_consume_ticket_result (void *cls,
465 461
466 msg_len = ntohs (msg->header.size); 462 msg_len = ntohs (msg->header.size);
467 attrs_len = ntohs (msg->attrs_len); 463 attrs_len = ntohs (msg->attrs_len);
468 if (msg_len != sizeof (struct ConsumeTicketResultMessage) + attrs_len) 464 if (msg_len != sizeof (struct ConsumeTicketResultMessage) + attrs_len) {
469 {
470 GNUNET_break (0); 465 GNUNET_break (0);
471 return GNUNET_SYSERR; 466 return GNUNET_SYSERR;
472 } 467 }
@@ -491,8 +486,7 @@ handle_consume_ticket_result (void *cls,
491 uint32_t r_id = ntohl (msg->id); 486 uint32_t r_id = ntohl (msg->id);
492 487
493 attrs_len = ntohs (msg->attrs_len); 488 attrs_len = ntohs (msg->attrs_len);
494 LOG (GNUNET_ERROR_TYPE_DEBUG, 489 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
495 "Processing attribute result.\n");
496 490
497 491
498 for (op = h->op_head; NULL != op; op = op->next) 492 for (op = h->op_head; NULL != op; op = op->next)
@@ -504,33 +498,20 @@ handle_consume_ticket_result (void *cls,
504 { 498 {
505 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 499 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
506 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 500 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
507 attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char*)&msg[1], 501 attrs =
508 attrs_len); 502 GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *)&msg[1], attrs_len);
509 if (NULL != op->ar_cb) 503 if (NULL != op->ar_cb) {
510 { 504 if (NULL == attrs) {
511 if (NULL == attrs) 505 op->ar_cb (op->cls, &msg->identity, NULL);
512 { 506 } else {
513 op->ar_cb (op->cls,
514 &msg->identity,
515 NULL);
516 }
517 else
518 {
519 for (le = attrs->list_head; NULL != le; le = le->next) 507 for (le = attrs->list_head; NULL != le; le = le->next)
520 op->ar_cb (op->cls, 508 op->ar_cb (op->cls, &msg->identity, le->claim);
521 &msg->identity,
522 le->claim);
523 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); 509 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
524 } 510 }
525 } 511 }
526 if (NULL != op) 512 if (NULL != op) {
527 { 513 op->ar_cb (op->cls, NULL, NULL);
528 op->ar_cb (op->cls, 514 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
529 NULL,
530 NULL);
531 GNUNET_CONTAINER_DLL_remove (h->op_head,
532 h->op_tail,
533 op);
534 free_op (op); 515 free_op (op);
535 } 516 }
536 return; 517 return;
@@ -548,16 +529,14 @@ handle_consume_ticket_result (void *cls,
548 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 529 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
549 */ 530 */
550static int 531static int
551check_attribute_result (void *cls, 532check_attribute_result (void *cls, const struct AttributeResultMessage *msg)
552 const struct AttributeResultMessage *msg)
553{ 533{
554 size_t msg_len; 534 size_t msg_len;
555 size_t attr_len; 535 size_t attr_len;
556 536
557 msg_len = ntohs (msg->header.size); 537 msg_len = ntohs (msg->header.size);
558 attr_len = ntohs (msg->attr_len); 538 attr_len = ntohs (msg->attr_len);
559 if (msg_len != sizeof (struct AttributeResultMessage) + attr_len) 539 if (msg_len != sizeof (struct AttributeResultMessage) + attr_len) {
560 {
561 GNUNET_break (0); 540 GNUNET_break (0);
562 return GNUNET_SYSERR; 541 return GNUNET_SYSERR;
563 } 542 }
@@ -573,8 +552,7 @@ check_attribute_result (void *cls,
573 * @param msg the message we received 552 * @param msg the message we received
574 */ 553 */
575static void 554static void
576handle_attribute_result (void *cls, 555handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
577 const struct AttributeResultMessage *msg)
578{ 556{
579 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; 557 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
580 struct GNUNET_RECLAIM_Handle *h = cls; 558 struct GNUNET_RECLAIM_Handle *h = cls;
@@ -584,8 +562,7 @@ handle_attribute_result (void *cls,
584 uint32_t r_id = ntohl (msg->id); 562 uint32_t r_id = ntohl (msg->id);
585 563
586 attr_len = ntohs (msg->attr_len); 564 attr_len = ntohs (msg->attr_len);
587 LOG (GNUNET_ERROR_TYPE_DEBUG, 565 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
588 "Processing attribute result.\n");
589 566
590 567
591 for (it = h->it_head; NULL != it; it = it->next) 568 for (it = h->it_head; NULL != it; it = it->next)
@@ -597,54 +574,36 @@ handle_attribute_result (void *cls,
597 if ((NULL == it) && (NULL == op)) 574 if ((NULL == it) && (NULL == op))
598 return; 575 return;
599 576
600 if ( (0 == (memcmp (&msg->identity, 577 if ((0 ==
601 &identity_dummy, 578 (memcmp (&msg->identity, &identity_dummy, sizeof (identity_dummy))))) {
602 sizeof (identity_dummy)))) ) 579 if ((NULL == it) && (NULL == op)) {
603 {
604 if ((NULL == it) && (NULL == op))
605 {
606 GNUNET_break (0); 580 GNUNET_break (0);
607 force_reconnect (h); 581 force_reconnect (h);
608 return; 582 return;
609 } 583 }
610 if (NULL != it) 584 if (NULL != it) {
611 {
612 if (NULL != it->finish_cb) 585 if (NULL != it->finish_cb)
613 it->finish_cb (it->finish_cb_cls); 586 it->finish_cb (it->finish_cb_cls);
614 free_it (it); 587 free_it (it);
615 } 588 }
616 if (NULL != op) 589 if (NULL != op) {
617 {
618 if (NULL != op->ar_cb) 590 if (NULL != op->ar_cb)
619 op->ar_cb (op->cls, 591 op->ar_cb (op->cls, NULL, NULL);
620 NULL, 592 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
621 NULL);
622 GNUNET_CONTAINER_DLL_remove (h->op_head,
623 h->op_tail,
624 op);
625 free_op (op); 593 free_op (op);
626
627 } 594 }
628 return; 595 return;
629 } 596 }
630 597
631 { 598 {
632 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 599 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
633 attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char*)&msg[1], 600 attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *)&msg[1], attr_len);
634 attr_len); 601 if (NULL != it) {
635 if (NULL != it)
636 {
637 if (NULL != it->proc) 602 if (NULL != it->proc)
638 it->proc (it->proc_cls, 603 it->proc (it->proc_cls, &msg->identity, attr);
639 &msg->identity, 604 } else if (NULL != op) {
640 attr);
641 } else if (NULL != op)
642 {
643 if (NULL != op->ar_cb) 605 if (NULL != op->ar_cb)
644 op->ar_cb (op->cls, 606 op->ar_cb (op->cls, &msg->identity, attr);
645 &msg->identity,
646 attr);
647
648 } 607 }
649 GNUNET_free (attr); 608 GNUNET_free (attr);
650 return; 609 return;
@@ -661,14 +620,12 @@ handle_attribute_result (void *cls,
661 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 620 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
662 */ 621 */
663static int 622static int
664check_ticket_result (void *cls, 623check_ticket_result (void *cls, const struct TicketResultMessage *msg)
665 const struct TicketResultMessage *msg)
666{ 624{
667 size_t msg_len; 625 size_t msg_len;
668 626
669 msg_len = ntohs (msg->header.size); 627 msg_len = ntohs (msg->header.size);
670 if (msg_len < sizeof (struct TicketResultMessage)) 628 if (msg_len < sizeof (struct TicketResultMessage)) {
671 {
672 GNUNET_break (0); 629 GNUNET_break (0);
673 return GNUNET_SYSERR; 630 return GNUNET_SYSERR;
674 } 631 }
@@ -676,7 +633,6 @@ check_ticket_result (void *cls,
676} 633}
677 634
678 635
679
680/** 636/**
681 * Handle an incoming message of type 637 * Handle an incoming message of type
682 * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT 638 * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
@@ -685,8 +641,7 @@ check_ticket_result (void *cls,
685 * @param msg the message we received 641 * @param msg the message we received
686 */ 642 */
687static void 643static void
688handle_ticket_result (void *cls, 644handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
689 const struct TicketResultMessage *msg)
690{ 645{
691 struct GNUNET_RECLAIM_Handle *handle = cls; 646 struct GNUNET_RECLAIM_Handle *handle = cls;
692 struct GNUNET_RECLAIM_Operation *op; 647 struct GNUNET_RECLAIM_Operation *op;
@@ -704,13 +659,9 @@ handle_ticket_result (void *cls,
704 if ((NULL == op) && (NULL == it)) 659 if ((NULL == op) && (NULL == it))
705 return; 660 return;
706 msg_len = ntohs (msg->header.size); 661 msg_len = ntohs (msg->header.size);
707 if (NULL != op) 662 if (NULL != op) {
708 { 663 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
709 GNUNET_CONTAINER_DLL_remove (handle->op_head, 664 if (msg_len == sizeof (struct TicketResultMessage)) {
710 handle->op_tail,
711 op);
712 if (msg_len == sizeof (struct TicketResultMessage))
713 {
714 if (NULL != op->tr_cb) 665 if (NULL != op->tr_cb)
715 op->tr_cb (op->cls, NULL); 666 op->tr_cb (op->cls, NULL);
716 } else { 667 } else {
@@ -721,12 +672,10 @@ handle_ticket_result (void *cls,
721 free_op (op); 672 free_op (op);
722 return; 673 return;
723 } else if (NULL != it) { 674 } else if (NULL != it) {
724 if (msg_len == sizeof (struct TicketResultMessage)) 675 if (msg_len == sizeof (struct TicketResultMessage)) {
725 {
726 if (NULL != it->tr_cb) 676 if (NULL != it->tr_cb)
727 GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head, 677 GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
728 handle->ticket_it_tail, 678 handle->ticket_it_tail, it);
729 it);
730 it->finish_cb (it->finish_cb_cls); 679 it->finish_cb (it->finish_cb_cls);
731 GNUNET_free (it); 680 GNUNET_free (it);
732 } else { 681 } else {
@@ -756,8 +705,7 @@ handle_revoke_ticket_result (void *cls,
756 uint32_t r_id = ntohl (msg->id); 705 uint32_t r_id = ntohl (msg->id);
757 int32_t success; 706 int32_t success;
758 707
759 LOG (GNUNET_ERROR_TYPE_DEBUG, 708 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
760 "Processing revocation result.\n");
761 709
762 710
763 for (op = h->op_head; NULL != op; op = op->next) 711 for (op = h->op_head; NULL != op; op = op->next)
@@ -767,15 +715,10 @@ handle_revoke_ticket_result (void *cls,
767 return; 715 return;
768 success = ntohl (msg->success); 716 success = ntohl (msg->success);
769 { 717 {
770 if (NULL != op->rvk_cb) 718 if (NULL != op->rvk_cb) {
771 { 719 op->rvk_cb (op->cls, success, NULL);
772 op->rvk_cb (op->cls,
773 success,
774 NULL);
775 } 720 }
776 GNUNET_CONTAINER_DLL_remove (h->op_head, 721 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
777 h->op_tail,
778 op);
779 free_op (op); 722 free_op (op);
780 return; 723 return;
781 } 724 }
@@ -783,7 +726,6 @@ handle_revoke_ticket_result (void *cls,
783} 726}
784 727
785 728
786
787/** 729/**
788 * Try again to connect to the service. 730 * Try again to connect to the service.
789 * 731 *
@@ -793,44 +735,34 @@ static void
793reconnect (struct GNUNET_RECLAIM_Handle *h) 735reconnect (struct GNUNET_RECLAIM_Handle *h)
794{ 736{
795 struct GNUNET_MQ_MessageHandler handlers[] = { 737 struct GNUNET_MQ_MessageHandler handlers[] = {
796 GNUNET_MQ_hd_fixed_size (attribute_store_response, 738 GNUNET_MQ_hd_fixed_size (
797 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE, 739 attribute_store_response,
798 struct AttributeStoreResultMessage, 740 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE,
799 h), 741 struct AttributeStoreResultMessage, h),
800 GNUNET_MQ_hd_var_size (attribute_result, 742 GNUNET_MQ_hd_var_size (attribute_result,
801 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, 743 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT,
802 struct AttributeResultMessage, 744 struct AttributeResultMessage, h),
803 h), 745 GNUNET_MQ_hd_var_size (ticket_result,
804 GNUNET_MQ_hd_var_size (ticket_result, 746 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
805 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 747 struct TicketResultMessage, h),
806 struct TicketResultMessage, 748 GNUNET_MQ_hd_var_size (consume_ticket_result,
807 h), 749 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT,
808 GNUNET_MQ_hd_var_size (consume_ticket_result, 750 struct ConsumeTicketResultMessage, h),
809 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, 751 GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
810 struct ConsumeTicketResultMessage, 752 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT,
811 h), 753 struct RevokeTicketResultMessage, h),
812 GNUNET_MQ_hd_fixed_size (revoke_ticket_result, 754 GNUNET_MQ_handler_end ()};
813 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT,
814 struct RevokeTicketResultMessage,
815 h),
816 GNUNET_MQ_handler_end ()
817 };
818 struct GNUNET_RECLAIM_Operation *op; 755 struct GNUNET_RECLAIM_Operation *op;
819 756
820 GNUNET_assert (NULL == h->mq); 757 GNUNET_assert (NULL == h->mq);
821 LOG (GNUNET_ERROR_TYPE_DEBUG, 758 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
822 "Connecting to reclaim service.\n");
823 759
824 h->mq = GNUNET_CLIENT_connect (h->cfg, 760 h->mq =
825 "reclaim", 761 GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
826 handlers,
827 &mq_error_handler,
828 h);
829 if (NULL == h->mq) 762 if (NULL == h->mq)
830 return; 763 return;
831 for (op = h->op_head; NULL != op; op = op->next) 764 for (op = h->op_head; NULL != op; op = op->next)
832 GNUNET_MQ_send_copy (h->mq, 765 GNUNET_MQ_send_copy (h->mq, op->env);
833 op->env);
834} 766}
835 767
836 768
@@ -848,8 +780,7 @@ GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
848 h = GNUNET_new (struct GNUNET_RECLAIM_Handle); 780 h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
849 h->cfg = cfg; 781 h->cfg = cfg;
850 reconnect (h); 782 reconnect (h);
851 if (NULL == h->mq) 783 if (NULL == h->mq) {
852 {
853 GNUNET_free (h); 784 GNUNET_free (h);
854 return NULL; 785 return NULL;
855 } 786 }
@@ -870,9 +801,7 @@ GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op)
870{ 801{
871 struct GNUNET_RECLAIM_Handle *h = op->h; 802 struct GNUNET_RECLAIM_Handle *h = op->h;
872 803
873 GNUNET_CONTAINER_DLL_remove (h->op_head, 804 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
874 h->op_tail,
875 op);
876 free_op (op); 805 free_op (op);
877} 806}
878 807
@@ -886,13 +815,11 @@ void
886GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h) 815GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h)
887{ 816{
888 GNUNET_assert (NULL != h); 817 GNUNET_assert (NULL != h);
889 if (NULL != h->mq) 818 if (NULL != h->mq) {
890 {
891 GNUNET_MQ_destroy (h->mq); 819 GNUNET_MQ_destroy (h->mq);
892 h->mq = NULL; 820 h->mq = NULL;
893 } 821 }
894 if (NULL != h->reconnect_task) 822 if (NULL != h->reconnect_task) {
895 {
896 GNUNET_SCHEDULER_cancel (h->reconnect_task); 823 GNUNET_SCHEDULER_cancel (h->reconnect_task);
897 h->reconnect_task = NULL; 824 h->reconnect_task = NULL;
898 } 825 }
@@ -904,7 +831,7 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h)
904 * Store an attribute. If the attribute is already present, 831 * Store an attribute. If the attribute is already present,
905 * it is replaced with the new attribute. 832 * it is replaced with the new attribute.
906 * 833 *
907 * @param h handle to the reclaim 834 * @param h handle to the re:claimID service
908 * @param pkey private key of the identity 835 * @param pkey private key of the identity
909 * @param attr the attribute value 836 * @param attr the attribute value
910 * @param exp_interval the relative expiration interval for the attribute 837 * @param exp_interval the relative expiration interval for the attribute
@@ -913,12 +840,12 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h)
913 * @return handle to abort the request 840 * @return handle to abort the request
914 */ 841 */
915struct GNUNET_RECLAIM_Operation * 842struct GNUNET_RECLAIM_Operation *
916GNUNET_RECLAIM_attribute_store (struct GNUNET_RECLAIM_Handle *h, 843GNUNET_RECLAIM_attribute_store (
917 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 844 struct GNUNET_RECLAIM_Handle *h,
918 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 845 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
919 const struct GNUNET_TIME_Relative *exp_interval, 846 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
920 GNUNET_RECLAIM_ContinuationWithStatus cont, 847 const struct GNUNET_TIME_Relative *exp_interval,
921 void *cont_cls) 848 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
922{ 849{
923 struct GNUNET_RECLAIM_Operation *op; 850 struct GNUNET_RECLAIM_Operation *op;
924 struct AttributeStoreMessage *sam; 851 struct AttributeStoreMessage *sam;
@@ -929,26 +856,20 @@ GNUNET_RECLAIM_attribute_store (struct GNUNET_RECLAIM_Handle *h,
929 op->as_cb = cont; 856 op->as_cb = cont;
930 op->cls = cont_cls; 857 op->cls = cont_cls;
931 op->r_id = h->r_id_gen++; 858 op->r_id = h->r_id_gen++;
932 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 859 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
933 h->op_tail,
934 op);
935 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); 860 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr);
936 op->env = GNUNET_MQ_msg_extra (sam, 861 op->env = GNUNET_MQ_msg_extra (sam, attr_len,
937 attr_len,
938 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); 862 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE);
939 sam->identity = *pkey; 863 sam->identity = *pkey;
940 sam->id = htonl (op->r_id); 864 sam->id = htonl (op->r_id);
941 sam->exp = GNUNET_htonll (exp_interval->rel_value_us); 865 sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
942 866
943 GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, 867 GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *)&sam[1]);
944 (char*)&sam[1]);
945 868
946 sam->attr_len = htons (attr_len); 869 sam->attr_len = htons (attr_len);
947 if (NULL != h->mq) 870 if (NULL != h->mq)
948 GNUNET_MQ_send_copy (h->mq, 871 GNUNET_MQ_send_copy (h->mq, op->env);
949 op->env);
950 return op; 872 return op;
951
952} 873}
953 874
954 875
@@ -964,28 +885,25 @@ GNUNET_RECLAIM_attribute_store (struct GNUNET_RECLAIM_Handle *h,
964 * On normal completion, @a finish_cb proc will be 885 * On normal completion, @a finish_cb proc will be
965 * invoked. 886 * invoked.
966 * 887 *
967 * @param h handle to the idp 888 * @param h Handle to the re:claimID service
968 * @param identity identity to access 889 * @param identity Identity to iterate over
969 * @param error_cb function to call on error (i.e. disconnect), 890 * @param error_cb Function to call on error (i.e. disconnect),
970 * the handle is afterwards invalid 891 * the handle is afterwards invalid
971 * @param error_cb_cls closure for @a error_cb 892 * @param error_cb_cls Closure for @a error_cb
972 * @param proc function to call on each attribute; it 893 * @param proc Function to call on each attribute
973 * will be called repeatedly with a value (if available) 894 * @param proc_cls Closure for @a proc
974 * @param proc_cls closure for @a proc 895 * @param finish_cb Function to call on completion
975 * @param finish_cb function to call on completion
976 * the handle is afterwards invalid 896 * the handle is afterwards invalid
977 * @param finish_cb_cls closure for @a finish_cb 897 * @param finish_cb_cls Closure for @a finish_cb
978 * @return an iterator handle to use for iteration 898 * @return an iterator Handle to use for iteration
979 */ 899 */
980struct GNUNET_RECLAIM_AttributeIterator * 900struct GNUNET_RECLAIM_AttributeIterator *
981GNUNET_RECLAIM_get_attributes_start (struct GNUNET_RECLAIM_Handle *h, 901GNUNET_RECLAIM_get_attributes_start (
982 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 902 struct GNUNET_RECLAIM_Handle *h,
983 GNUNET_SCHEDULER_TaskCallback error_cb, 903 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
984 void *error_cb_cls, 904 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
985 GNUNET_RECLAIM_AttributeResult proc, 905 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
986 void *proc_cls, 906 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
987 GNUNET_SCHEDULER_TaskCallback finish_cb,
988 void *finish_cb_cls)
989{ 907{
990 struct GNUNET_RECLAIM_AttributeIterator *it; 908 struct GNUNET_RECLAIM_AttributeIterator *it;
991 struct GNUNET_MQ_Envelope *env; 909 struct GNUNET_MQ_Envelope *env;
@@ -1003,9 +921,7 @@ GNUNET_RECLAIM_get_attributes_start (struct GNUNET_RECLAIM_Handle *h,
1003 it->proc_cls = proc_cls; 921 it->proc_cls = proc_cls;
1004 it->r_id = rid; 922 it->r_id = rid;
1005 it->identity = *identity; 923 it->identity = *identity;
1006 GNUNET_CONTAINER_DLL_insert_tail (h->it_head, 924 GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it);
1007 h->it_tail,
1008 it);
1009 env = GNUNET_MQ_msg (msg, 925 env = GNUNET_MQ_msg (msg,
1010 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); 926 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START);
1011 msg->id = htonl (rid); 927 msg->id = htonl (rid);
@@ -1013,8 +929,7 @@ GNUNET_RECLAIM_get_attributes_start (struct GNUNET_RECLAIM_Handle *h,
1013 if (NULL == h->mq) 929 if (NULL == h->mq)
1014 it->env = env; 930 it->env = env;
1015 else 931 else
1016 GNUNET_MQ_send (h->mq, 932 GNUNET_MQ_send (h->mq, env);
1017 env);
1018 return it; 933 return it;
1019} 934}
1020 935
@@ -1032,16 +947,15 @@ GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it)
1032 struct AttributeIterationNextMessage *msg; 947 struct AttributeIterationNextMessage *msg;
1033 struct GNUNET_MQ_Envelope *env; 948 struct GNUNET_MQ_Envelope *env;
1034 949
1035 env = GNUNET_MQ_msg (msg, 950 env =
1036 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); 951 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT);
1037 msg->id = htonl (it->r_id); 952 msg->id = htonl (it->r_id);
1038 GNUNET_MQ_send (h->mq, 953 GNUNET_MQ_send (h->mq, env);
1039 env);
1040} 954}
1041 955
1042 956
1043/** 957/**
1044 * Stops iteration and releases the idp handle for further calls. Must 958 * Stops iteration and releases the handle for further calls. Must
1045 * be called on any iteration that has not yet completed prior to calling 959 * be called on any iteration that has not yet completed prior to calling
1046 * #GNUNET_RECLAIM_disconnect. 960 * #GNUNET_RECLAIM_disconnect.
1047 * 961 *
@@ -1054,38 +968,36 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it)
1054 struct GNUNET_MQ_Envelope *env; 968 struct GNUNET_MQ_Envelope *env;
1055 struct AttributeIterationStopMessage *msg; 969 struct AttributeIterationStopMessage *msg;
1056 970
1057 if (NULL != h->mq) 971 if (NULL != h->mq) {
1058 {
1059 env = GNUNET_MQ_msg (msg, 972 env = GNUNET_MQ_msg (msg,
1060 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP); 973 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP);
1061 msg->id = htonl (it->r_id); 974 msg->id = htonl (it->r_id);
1062 GNUNET_MQ_send (h->mq, 975 GNUNET_MQ_send (h->mq, env);
1063 env);
1064 } 976 }
1065 free_it (it); 977 free_it (it);
1066} 978}
1067 979
1068 980
1069/** TODO 981/**
1070 * Issues a ticket to another identity. The identity may use 982 * Issues a ticket to another relying party. The identity may use
1071 * @GNUNET_RECLAIM_authorization_ticket_consume to consume the ticket 983 * @GNUNET_RECLAIM_ticket_consume to consume the ticket
1072 * and retrieve the attributes specified in the AttributeList. 984 * and retrieve the attributes specified in the attribute list.
1073 * 985 *
1074 * @param h the reclaim to use 986 * @param h the reclaim to use
1075 * @param iss the issuing identity 987 * @param iss the issuing identity (= the user)
1076 * @param rp the subject of the ticket (the relying party) 988 * @param rp the subject of the ticket (= the relying party)
1077 * @param attrs the attributes that the relying party is given access to 989 * @param attrs the attributes that the relying party is given access to
1078 * @param cb the callback 990 * @param cb the callback
1079 * @param cb_cls the callback closure 991 * @param cb_cls the callback closure
1080 * @return handle to abort the operation 992 * @return handle to abort the operation
1081 */ 993 */
1082struct GNUNET_RECLAIM_Operation * 994struct GNUNET_RECLAIM_Operation *
1083GNUNET_RECLAIM_ticket_issue (struct GNUNET_RECLAIM_Handle *h, 995GNUNET_RECLAIM_ticket_issue (
1084 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 996 struct GNUNET_RECLAIM_Handle *h,
1085 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 997 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1086 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 998 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1087 GNUNET_RECLAIM_TicketCallback cb, 999 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1088 void *cb_cls) 1000 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls)
1089{ 1001{
1090 struct GNUNET_RECLAIM_Operation *op; 1002 struct GNUNET_RECLAIM_Operation *op;
1091 struct IssueTicketMessage *tim; 1003 struct IssueTicketMessage *tim;
@@ -1096,44 +1008,41 @@ GNUNET_RECLAIM_ticket_issue (struct GNUNET_RECLAIM_Handle *h,
1096 op->tr_cb = cb; 1008 op->tr_cb = cb;
1097 op->cls = cb_cls; 1009 op->cls = cb_cls;
1098 op->r_id = h->r_id_gen++; 1010 op->r_id = h->r_id_gen++;
1099 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 1011 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1100 h->op_tail,
1101 op);
1102 attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); 1012 attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
1103 op->env = GNUNET_MQ_msg_extra (tim, 1013 op->env = GNUNET_MQ_msg_extra (tim, attr_len,
1104 attr_len,
1105 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); 1014 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET);
1106 tim->identity = *iss; 1015 tim->identity = *iss;
1107 tim->rp = *rp; 1016 tim->rp = *rp;
1108 tim->id = htonl (op->r_id); 1017 tim->id = htonl (op->r_id);
1109 1018
1110 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, 1019 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *)&tim[1]);
1111 (char*)&tim[1]);
1112 1020
1113 tim->attr_len = htons (attr_len); 1021 tim->attr_len = htons (attr_len);
1114 if (NULL != h->mq) 1022 if (NULL != h->mq)
1115 GNUNET_MQ_send_copy (h->mq, 1023 GNUNET_MQ_send_copy (h->mq, op->env);
1116 op->env);
1117 return op; 1024 return op;
1118} 1025}
1119 1026
1027
1120/** 1028/**
1121 * Consumes an issued ticket. The ticket is persisted 1029 * Consumes an issued ticket. The ticket is persisted
1122 * and used to retrieve identity information from the issuer 1030 * and used to retrieve identity information from the issuer
1123 * 1031 *
1124 * @param h the reclaim to use 1032 * @param h the reclaim to use
1125 * @param identity the identity that is the subject of the issued ticket (the relying party) 1033 * @param identity the identity that is the subject of the issued ticket (the
1034 * relying party)
1126 * @param ticket the issued ticket to consume 1035 * @param ticket the issued ticket to consume
1127 * @param cb the callback to call 1036 * @param cb the callback to call
1128 * @param cb_cls the callback closure 1037 * @param cb_cls the callback closure
1129 * @return handle to abort the operation 1038 * @return handle to abort the operation
1130 */ 1039 */
1131struct GNUNET_RECLAIM_Operation * 1040struct GNUNET_RECLAIM_Operation *
1132GNUNET_RECLAIM_ticket_consume (struct GNUNET_RECLAIM_Handle *h, 1041GNUNET_RECLAIM_ticket_consume (
1133 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1042 struct GNUNET_RECLAIM_Handle *h,
1134 const struct GNUNET_RECLAIM_Ticket *ticket, 1043 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1135 GNUNET_RECLAIM_AttributeResult cb, 1044 const struct GNUNET_RECLAIM_Ticket *ticket,
1136 void *cb_cls) 1045 GNUNET_RECLAIM_AttributeResult cb, void *cb_cls)
1137{ 1046{
1138 struct GNUNET_RECLAIM_Operation *op; 1047 struct GNUNET_RECLAIM_Operation *op;
1139 struct ConsumeTicketMessage *ctm; 1048 struct ConsumeTicketMessage *ctm;
@@ -1143,24 +1052,19 @@ GNUNET_RECLAIM_ticket_consume (struct GNUNET_RECLAIM_Handle *h,
1143 op->ar_cb = cb; 1052 op->ar_cb = cb;
1144 op->cls = cb_cls; 1053 op->cls = cb_cls;
1145 op->r_id = h->r_id_gen++; 1054 op->r_id = h->r_id_gen++;
1146 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 1055 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1147 h->op_tail, 1056 op->env =
1148 op); 1057 GNUNET_MQ_msg_extra (ctm, sizeof (const struct GNUNET_RECLAIM_Ticket),
1149 op->env = GNUNET_MQ_msg_extra (ctm, 1058 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
1150 sizeof (const struct GNUNET_RECLAIM_Ticket),
1151 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
1152 ctm->identity = *identity; 1059 ctm->identity = *identity;
1153 ctm->id = htonl (op->r_id); 1060 ctm->id = htonl (op->r_id);
1154 1061
1155 GNUNET_memcpy ((char*)&ctm[1], 1062 GNUNET_memcpy ((char *)&ctm[1], ticket,
1156 ticket,
1157 sizeof (const struct GNUNET_RECLAIM_Ticket)); 1063 sizeof (const struct GNUNET_RECLAIM_Ticket));
1158 1064
1159 if (NULL != h->mq) 1065 if (NULL != h->mq)
1160 GNUNET_MQ_send_copy (h->mq, 1066 GNUNET_MQ_send_copy (h->mq, op->env);
1161 op->env);
1162 return op; 1067 return op;
1163
1164} 1068}
1165 1069
1166 1070
@@ -1182,14 +1086,12 @@ GNUNET_RECLAIM_ticket_consume (struct GNUNET_RECLAIM_Handle *h,
1182 * @return an iterator handle to use for iteration 1086 * @return an iterator handle to use for iteration
1183 */ 1087 */
1184struct GNUNET_RECLAIM_TicketIterator * 1088struct GNUNET_RECLAIM_TicketIterator *
1185GNUNET_RECLAIM_ticket_iteration_start (struct GNUNET_RECLAIM_Handle *h, 1089GNUNET_RECLAIM_ticket_iteration_start (
1186 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1090 struct GNUNET_RECLAIM_Handle *h,
1187 GNUNET_SCHEDULER_TaskCallback error_cb, 1091 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1188 void *error_cb_cls, 1092 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
1189 GNUNET_RECLAIM_TicketCallback proc, 1093 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls,
1190 void *proc_cls, 1094 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
1191 GNUNET_SCHEDULER_TaskCallback finish_cb,
1192 void *finish_cb_cls)
1193{ 1095{
1194 struct GNUNET_RECLAIM_TicketIterator *it; 1096 struct GNUNET_RECLAIM_TicketIterator *it;
1195 struct GNUNET_MQ_Envelope *env; 1097 struct GNUNET_MQ_Envelope *env;
@@ -1206,26 +1108,21 @@ GNUNET_RECLAIM_ticket_iteration_start (struct GNUNET_RECLAIM_Handle *h,
1206 it->tr_cb = proc; 1108 it->tr_cb = proc;
1207 it->cls = proc_cls; 1109 it->cls = proc_cls;
1208 it->r_id = rid; 1110 it->r_id = rid;
1209 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, 1111 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it);
1210 h->ticket_it_tail, 1112 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START);
1211 it);
1212 env = GNUNET_MQ_msg (msg,
1213 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START);
1214 msg->id = htonl (rid); 1113 msg->id = htonl (rid);
1215 msg->identity = *identity; 1114 msg->identity = *identity;
1216 if (NULL == h->mq) 1115 if (NULL == h->mq)
1217 it->env = env; 1116 it->env = env;
1218 else 1117 else
1219 GNUNET_MQ_send (h->mq, 1118 GNUNET_MQ_send (h->mq, env);
1220 env);
1221 return it; 1119 return it;
1222
1223} 1120}
1224 1121
1225 1122
1226/** 1123/**
1227 * Calls the record processor specified in #GNUNET_RECLAIM_ticket_iteration_start 1124 * Calls the ticket processor specified in
1228 * for the next record. 1125 * #GNUNET_RECLAIM_ticket_iteration_start for the next record.
1229 * 1126 *
1230 * @param it the iterator 1127 * @param it the iterator
1231 */ 1128 */
@@ -1236,16 +1133,14 @@ GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it)
1236 struct TicketIterationNextMessage *msg; 1133 struct TicketIterationNextMessage *msg;
1237 struct GNUNET_MQ_Envelope *env; 1134 struct GNUNET_MQ_Envelope *env;
1238 1135
1239 env = GNUNET_MQ_msg (msg, 1136 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT);
1240 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT);
1241 msg->id = htonl (it->r_id); 1137 msg->id = htonl (it->r_id);
1242 GNUNET_MQ_send (h->mq, 1138 GNUNET_MQ_send (h->mq, env);
1243 env);
1244} 1139}
1245 1140
1246 1141
1247/** 1142/**
1248 * Stops iteration and releases the idp handle for further calls. Must 1143 * Stops iteration and releases the handle for further calls. Must
1249 * be called on any iteration that has not yet completed prior to calling 1144 * be called on any iteration that has not yet completed prior to calling
1250 * #GNUNET_RECLAIM_disconnect. 1145 * #GNUNET_RECLAIM_disconnect.
1251 * 1146 *
@@ -1258,22 +1153,23 @@ GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it)
1258 struct GNUNET_MQ_Envelope *env; 1153 struct GNUNET_MQ_Envelope *env;
1259 struct TicketIterationStopMessage *msg; 1154 struct TicketIterationStopMessage *msg;
1260 1155
1261 if (NULL != h->mq) 1156 if (NULL != h->mq) {
1262 { 1157 env =
1263 env = GNUNET_MQ_msg (msg, 1158 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP);
1264 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP);
1265 msg->id = htonl (it->r_id); 1159 msg->id = htonl (it->r_id);
1266 GNUNET_MQ_send (h->mq, 1160 GNUNET_MQ_send (h->mq, env);
1267 env);
1268 } 1161 }
1269 GNUNET_free (it); 1162 GNUNET_free (it);
1270} 1163}
1271 1164
1165
1272/** 1166/**
1273 * Revoked an issued ticket. The relying party will be unable to retrieve 1167 * Revoked an issued ticket. The relying party will be unable to retrieve
1274 * updated attributes. 1168 * attributes. Other issued tickets remain unaffected.
1169 * This includes tickets issued to other relying parties as well as to
1170 * other tickets issued to the audience specified in this ticket.
1275 * 1171 *
1276 * @param h the reclaim to use 1172 * @param h the identity provider to use
1277 * @param identity the issuing identity 1173 * @param identity the issuing identity
1278 * @param ticket the ticket to revoke 1174 * @param ticket the ticket to revoke
1279 * @param cb the callback 1175 * @param cb the callback
@@ -1281,11 +1177,11 @@ GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it)
1281 * @return handle to abort the operation 1177 * @return handle to abort the operation
1282 */ 1178 */
1283struct GNUNET_RECLAIM_Operation * 1179struct GNUNET_RECLAIM_Operation *
1284GNUNET_RECLAIM_ticket_revoke (struct GNUNET_RECLAIM_Handle *h, 1180GNUNET_RECLAIM_ticket_revoke (
1285 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1181 struct GNUNET_RECLAIM_Handle *h,
1286 const struct GNUNET_RECLAIM_Ticket *ticket, 1182 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1287 GNUNET_RECLAIM_ContinuationWithStatus cb, 1183 const struct GNUNET_RECLAIM_Ticket *ticket,
1288 void *cb_cls) 1184 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
1289{ 1185{
1290 struct GNUNET_RECLAIM_Operation *op; 1186 struct GNUNET_RECLAIM_Operation *op;
1291 struct RevokeTicketMessage *msg; 1187 struct RevokeTicketMessage *msg;
@@ -1297,25 +1193,18 @@ GNUNET_RECLAIM_ticket_revoke (struct GNUNET_RECLAIM_Handle *h,
1297 op->rvk_cb = cb; 1193 op->rvk_cb = cb;
1298 op->cls = cb_cls; 1194 op->cls = cb_cls;
1299 op->r_id = rid; 1195 op->r_id = rid;
1300 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 1196 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1301 h->op_tail, 1197 op->env = GNUNET_MQ_msg_extra (msg, sizeof (struct GNUNET_RECLAIM_Ticket),
1302 op); 1198 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET);
1303 op->env = GNUNET_MQ_msg_extra (msg,
1304 sizeof (struct GNUNET_RECLAIM_Ticket),
1305 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET);
1306 msg->id = htonl (rid); 1199 msg->id = htonl (rid);
1307 msg->identity = *identity; 1200 msg->identity = *identity;
1308 GNUNET_memcpy (&msg[1], 1201 GNUNET_memcpy (&msg[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket));
1309 ticket,
1310 sizeof (struct GNUNET_RECLAIM_Ticket));
1311 if (NULL != h->mq) { 1202 if (NULL != h->mq) {
1312 GNUNET_MQ_send (h->mq, 1203 GNUNET_MQ_send (h->mq, op->env);
1313 op->env);
1314 op->env = NULL; 1204 op->env = NULL;
1315 } 1205 }
1316 return op; 1206 return op;
1317} 1207}
1318 1208
1319 1209
1320
1321/* end of reclaim_api.c */ 1210/* end of reclaim_api.c */