aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/gnunet-service-reclaim.c266
1 files changed, 157 insertions, 109 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 0f0de86d3..bb4cd6716 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -531,7 +531,8 @@ do_shutdown (void *cls)
531 531
532 532
533static void 533static void
534send_ticket_result (const struct IdpClient *client, uint32_t r_id, 534send_ticket_result (const struct IdpClient *client,
535 uint32_t r_id,
535 const struct GNUNET_RECLAIM_Ticket *ticket, 536 const struct GNUNET_RECLAIM_Ticket *ticket,
536 uint32_t success) 537 uint32_t success)
537{ 538{
@@ -540,7 +541,8 @@ send_ticket_result (const struct IdpClient *client, uint32_t r_id,
540 struct GNUNET_RECLAIM_Ticket *ticket_buf; 541 struct GNUNET_RECLAIM_Ticket *ticket_buf;
541 542
542 if (NULL != ticket) { 543 if (NULL != ticket) {
543 env = GNUNET_MQ_msg_extra (irm, sizeof (struct GNUNET_RECLAIM_Ticket), 544 env = GNUNET_MQ_msg_extra (irm,
545 sizeof (struct GNUNET_RECLAIM_Ticket),
544 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); 546 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
545 ticket_buf = (struct GNUNET_RECLAIM_Ticket *)&irm[1]; 547 ticket_buf = (struct GNUNET_RECLAIM_Ticket *)&irm[1];
546 *ticket_buf = *ticket; 548 *ticket_buf = *ticket;
@@ -553,21 +555,23 @@ send_ticket_result (const struct IdpClient *client, uint32_t r_id,
553} 555}
554 556
555static void 557static void
556issue_ticket_result_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket, 558issue_ticket_result_cb (void *cls,
557 int32_t success, const char *emsg) 559 struct GNUNET_RECLAIM_Ticket *ticket,
560 int32_t success,
561 const char *emsg)
558{ 562{
559 struct TicketIssueOperation *tio = cls; 563 struct TicketIssueOperation *tio = cls;
560 if (GNUNET_OK != success) { 564 if (GNUNET_OK != success) {
561 send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR); 565 send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR);
562 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head, 566 GNUNET_CONTAINER_DLL_remove (
563 tio->client->issue_op_tail, tio); 567 tio->client->issue_op_head, tio->client->issue_op_tail, tio);
564 GNUNET_free (tio); 568 GNUNET_free (tio);
565 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg); 569 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
566 return; 570 return;
567 } 571 }
568 send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR); 572 send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR);
569 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head, 573 GNUNET_CONTAINER_DLL_remove (
570 tio->client->issue_op_tail, tio); 574 tio->client->issue_op_head, tio->client->issue_op_tail, tio);
571 GNUNET_free (tio); 575 GNUNET_free (tio);
572} 576}
573 577
@@ -598,8 +602,8 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
598 tio->r_id = ntohl (im->id); 602 tio->r_id = ntohl (im->id);
599 tio->client = idp; 603 tio->client = idp;
600 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio); 604 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
601 RECLAIM_TICKETS_issue (&im->identity, attrs, &im->rp, &issue_ticket_result_cb, 605 RECLAIM_TICKETS_issue (
602 tio); 606 &im->identity, attrs, &im->rp, &issue_ticket_result_cb, tio);
603 GNUNET_SERVICE_client_continue (idp->client); 607 GNUNET_SERVICE_client_continue (idp->client);
604 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); 608 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
605} 609}
@@ -620,8 +624,8 @@ revoke_result_cb (void *cls, int32_t success)
620 trm->id = htonl (rop->r_id); 624 trm->id = htonl (rop->r_id);
621 trm->success = htonl (success); 625 trm->success = htonl (success);
622 GNUNET_MQ_send (rop->client->mq, env); 626 GNUNET_MQ_send (rop->client->mq, env);
623 GNUNET_CONTAINER_DLL_remove (rop->client->revoke_op_head, 627 GNUNET_CONTAINER_DLL_remove (
624 rop->client->revoke_op_tail, rop); 628 rop->client->revoke_op_head, rop->client->revoke_op_tail, rop);
625 GNUNET_free (rop); 629 GNUNET_free (rop);
626} 630}
627 631
@@ -651,8 +655,8 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
651 rop->r_id = ntohl (rm->id); 655 rop->r_id = ntohl (rm->id);
652 rop->client = idp; 656 rop->client = idp;
653 GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop); 657 GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
654 rop->rh = 658 rop->rh
655 RECLAIM_TICKETS_revoke (ticket, &rm->identity, &revoke_result_cb, rop); 659 = RECLAIM_TICKETS_revoke (ticket, &rm->identity, &revoke_result_cb, rop);
656 GNUNET_SERVICE_client_continue (idp->client); 660 GNUNET_SERVICE_client_continue (idp->client);
657} 661}
658 662
@@ -673,7 +677,8 @@ static void
673consume_result_cb (void *cls, 677consume_result_cb (void *cls,
674 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 678 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
675 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 679 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
676 int32_t success, const char *emsg) 680 int32_t success,
681 const char *emsg)
677{ 682{
678 struct ConsumeTicketOperation *cop = cls; 683 struct ConsumeTicketOperation *cop = cls;
679 struct ConsumeTicketResultMessage *crm; 684 struct ConsumeTicketResultMessage *crm;
@@ -684,8 +689,8 @@ consume_result_cb (void *cls,
684 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); 689 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
685 } 690 }
686 attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); 691 attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
687 env = GNUNET_MQ_msg_extra (crm, attrs_len, 692 env = GNUNET_MQ_msg_extra (
688 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); 693 crm, attrs_len, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT);
689 crm->id = htonl (cop->r_id); 694 crm->id = htonl (cop->r_id);
690 crm->attrs_len = htons (attrs_len); 695 crm->attrs_len = htons (attrs_len);
691 crm->identity = *identity; 696 crm->identity = *identity;
@@ -693,8 +698,8 @@ consume_result_cb (void *cls,
693 data_tmp = (char *)&crm[1]; 698 data_tmp = (char *)&crm[1];
694 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp); 699 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp);
695 GNUNET_MQ_send (cop->client->mq, env); 700 GNUNET_MQ_send (cop->client->mq, env);
696 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, 701 GNUNET_CONTAINER_DLL_remove (
697 cop->client->consume_op_tail, cop); 702 cop->client->consume_op_head, cop->client->consume_op_tail, cop);
698 GNUNET_free (cop); 703 GNUNET_free (cop);
699} 704}
700 705
@@ -709,8 +714,8 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
709 cop->r_id = ntohl (cm->id); 714 cop->r_id = ntohl (cm->id);
710 cop->client = idp; 715 cop->client = idp;
711 ticket = (struct GNUNET_RECLAIM_Ticket *)&cm[1]; 716 ticket = (struct GNUNET_RECLAIM_Ticket *)&cm[1];
712 cop->ch = 717 cop->ch = RECLAIM_TICKETS_consume (
713 RECLAIM_TICKETS_consume (&cm->identity, ticket, &consume_result_cb, cop); 718 &cm->identity, ticket, &consume_result_cb, cop);
714 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop); 719 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
715 GNUNET_SERVICE_client_continue (idp->client); 720 GNUNET_SERVICE_client_continue (idp->client);
716} 721}
@@ -742,12 +747,12 @@ attr_store_cont (void *cls, int32_t success, const char *emsg)
742 struct SuccessResultMessage *acr_msg; 747 struct SuccessResultMessage *acr_msg;
743 748
744 ash->ns_qe = NULL; 749 ash->ns_qe = NULL;
745 GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, 750 GNUNET_CONTAINER_DLL_remove (
746 ash->client->store_op_tail, ash); 751 ash->client->store_op_head, ash->client->store_op_tail, ash);
747 752
748 if (GNUNET_SYSERR == success) { 753 if (GNUNET_SYSERR == success) {
749 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to store attribute %s\n", 754 GNUNET_log (
750 emsg); 755 GNUNET_ERROR_TYPE_ERROR, "Failed to store attribute %s\n", emsg);
751 cleanup_as_handle (ash); 756 cleanup_as_handle (ash);
752 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 757 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
753 return; 758 return;
@@ -780,11 +785,11 @@ attr_store_task (void *cls)
780 buf = GNUNET_malloc (buf_size); 785 buf = GNUNET_malloc (buf_size);
781 // Give the ash a new id if unset 786 // Give the ash a new id if unset
782 if (0 == ash->claim->id) 787 if (0 == ash->claim->id)
783 ash->claim->id = 788 ash->claim->id
784 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 789 = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
785 GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf); 790 GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf);
786 label = 791 label = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id,
787 GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof (uint64_t)); 792 sizeof (uint64_t));
788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); 793 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
789 794
790 rd[0].data_size = buf_size; 795 rd[0].data_size = buf_size;
@@ -792,8 +797,8 @@ attr_store_task (void *cls)
792 rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR; 797 rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR;
793 rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 798 rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
794 rd[0].expiration_time = ash->exp.rel_value_us; 799 rd[0].expiration_time = ash->exp.rel_value_us;
795 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &ash->identity, label, 1, 800 ash->ns_qe = GNUNET_NAMESTORE_records_store (
796 rd, &attr_store_cont, ash); 801 nsh, &ash->identity, label, 1, rd, &attr_store_cont, ash);
797 GNUNET_free (buf); 802 GNUNET_free (buf);
798} 803}
799 804
@@ -850,8 +855,8 @@ cleanup_adh (struct AttributeDeleteHandle *adh)
850 if (NULL != adh->claim) 855 if (NULL != adh->claim)
851 GNUNET_free (adh->claim); 856 GNUNET_free (adh->claim);
852 while (NULL != (le = adh->tickets_to_update_head)) { 857 while (NULL != (le = adh->tickets_to_update_head)) {
853 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, 858 GNUNET_CONTAINER_DLL_remove (
854 adh->tickets_to_update_tail, le); 859 adh->tickets_to_update_head, adh->tickets_to_update_tail, le);
855 if (NULL != le->label) 860 if (NULL != le->label)
856 GNUNET_free (le->label); 861 GNUNET_free (le->label);
857 if (NULL != le->data) 862 if (NULL != le->data)
@@ -868,8 +873,8 @@ send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
868 struct GNUNET_MQ_Envelope *env; 873 struct GNUNET_MQ_Envelope *env;
869 struct SuccessResultMessage *acr_msg; 874 struct SuccessResultMessage *acr_msg;
870 875
871 GNUNET_CONTAINER_DLL_remove (adh->client->delete_op_head, 876 GNUNET_CONTAINER_DLL_remove (
872 adh->client->delete_op_tail, adh); 877 adh->client->delete_op_head, adh->client->delete_op_tail, adh);
873 878
874 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); 879 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
875 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); 880 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
@@ -880,8 +885,10 @@ send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
880 885
881 886
882static void 887static void
883ticket_iter (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 888ticket_iter (void *cls,
884 const char *label, unsigned int rd_count, 889 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
890 const char *label,
891 unsigned int rd_count,
885 const struct GNUNET_GNSRECORD_Data *rd) 892 const struct GNUNET_GNSRECORD_Data *rd)
886{ 893{
887 struct AttributeDeleteHandle *adh = cls; 894 struct AttributeDeleteHandle *adh = cls;
@@ -893,7 +900,8 @@ ticket_iter (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
893 continue; 900 continue;
894 if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t))) 901 if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t)))
895 continue; 902 continue;
896 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attribute to delete found (%s)\n", 903 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
904 "Attribute to delete found (%s)\n",
897 adh->label); 905 adh->label);
898 has_changed = GNUNET_YES; 906 has_changed = GNUNET_YES;
899 break; 907 break;
@@ -905,8 +913,8 @@ ticket_iter (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
905 le->rd_count = rd_count; 913 le->rd_count = rd_count;
906 le->label = GNUNET_strdup (label); 914 le->label = GNUNET_strdup (label);
907 GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data); 915 GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
908 GNUNET_CONTAINER_DLL_insert (adh->tickets_to_update_head, 916 GNUNET_CONTAINER_DLL_insert (
909 adh->tickets_to_update_tail, le); 917 adh->tickets_to_update_head, adh->tickets_to_update_tail, le);
910 } 918 }
911 GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1); 919 GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1);
912} 920}
@@ -936,25 +944,26 @@ update_tickets (void *cls)
936 cleanup_adh (adh); 944 cleanup_adh (adh);
937 return; 945 return;
938 } 946 }
939 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating %s\n", 947 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
948 "Updating %s\n",
940 adh->tickets_to_update_head->label); 949 adh->tickets_to_update_head->label);
941 le = adh->tickets_to_update_head; 950 le = adh->tickets_to_update_head;
942 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, 951 GNUNET_CONTAINER_DLL_remove (
943 adh->tickets_to_update_tail, le); 952 adh->tickets_to_update_head, adh->tickets_to_update_tail, le);
944 struct GNUNET_GNSRECORD_Data rd[le->rd_count]; 953 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
945 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1]; 954 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
946 GNUNET_GNSRECORD_records_deserialize (le->data_size, le->data, le->rd_count, 955 GNUNET_GNSRECORD_records_deserialize (
947 rd); 956 le->data_size, le->data, le->rd_count, rd);
948 int j = 0; 957 int j = 0;
949 for (int i = 0; i < le->rd_count; i++) { 958 for (int i = 0; i < le->rd_count; i++) {
950 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) && 959 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
951 (0 == memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t)))) 960 && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t))))
952 continue; 961 continue;
953 rd_new[j] = rd[i]; 962 rd_new[j] = rd[i];
954 j++; 963 j++;
955 } 964 }
956 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &adh->identity, le->label, 965 adh->ns_qe = GNUNET_NAMESTORE_records_store (
957 j, rd_new, &ticket_updated, adh); 966 nsh, &adh->identity, le->label, j, rd_new, &ticket_updated, adh);
958 GNUNET_free (le->label); 967 GNUNET_free (le->label);
959 GNUNET_free (le->data); 968 GNUNET_free (le->data);
960 GNUNET_free (le); 969 GNUNET_free (le);
@@ -975,8 +984,8 @@ ticket_iter_err (void *cls)
975{ 984{
976 struct AttributeDeleteHandle *adh = cls; 985 struct AttributeDeleteHandle *adh = cls;
977 adh->ns_it = NULL; 986 adh->ns_it = NULL;
978 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Namestore error on delete %s\n", 987 GNUNET_log (
979 adh->label); 988 GNUNET_ERROR_TYPE_ERROR, "Namestore error on delete %s\n", adh->label);
980 send_delete_response (adh, GNUNET_SYSERR); 989 send_delete_response (adh, GNUNET_SYSERR);
981 cleanup_adh (adh); 990 cleanup_adh (adh);
982} 991}
@@ -986,9 +995,14 @@ static void
986start_ticket_update (void *cls) 995start_ticket_update (void *cls)
987{ 996{
988 struct AttributeDeleteHandle *adh = cls; 997 struct AttributeDeleteHandle *adh = cls;
989 adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( 998 adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh,
990 nsh, &adh->identity, &ticket_iter_err, adh, &ticket_iter, adh, 999 &adh->identity,
991 &ticket_iter_fin, adh); 1000 &ticket_iter_err,
1001 adh,
1002 &ticket_iter,
1003 adh,
1004 &ticket_iter_fin,
1005 adh);
992} 1006}
993 1007
994 1008
@@ -998,8 +1012,8 @@ attr_delete_cont (void *cls, int32_t success, const char *emsg)
998 struct AttributeDeleteHandle *adh = cls; 1012 struct AttributeDeleteHandle *adh = cls;
999 adh->ns_qe = NULL; 1013 adh->ns_qe = NULL;
1000 if (GNUNET_SYSERR == success) { 1014 if (GNUNET_SYSERR == success) {
1001 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error deleting attribute %s\n", 1015 GNUNET_log (
1002 adh->label); 1016 GNUNET_ERROR_TYPE_ERROR, "Error deleting attribute %s\n", adh->label);
1003 send_delete_response (adh, GNUNET_SYSERR); 1017 send_delete_response (adh, GNUNET_SYSERR);
1004 cleanup_adh (adh); 1018 cleanup_adh (adh);
1005 return; 1019 return;
@@ -1040,13 +1054,13 @@ handle_attribute_delete_message (void *cls,
1040 1054
1041 adh->r_id = ntohl (dam->id); 1055 adh->r_id = ntohl (dam->id);
1042 adh->identity = dam->identity; 1056 adh->identity = dam->identity;
1043 adh->label = 1057 adh->label = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id,
1044 GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof (uint64_t)); 1058 sizeof (uint64_t));
1045 GNUNET_SERVICE_client_continue (idp->client); 1059 GNUNET_SERVICE_client_continue (idp->client);
1046 adh->client = idp; 1060 adh->client = idp;
1047 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); 1061 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1048 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &adh->identity, adh->label, 1062 adh->ns_qe = GNUNET_NAMESTORE_records_store (
1049 0, NULL, &attr_delete_cont, adh); 1063 nsh, &adh->identity, adh->label, 0, NULL, &attr_delete_cont, adh);
1050} 1064}
1051 1065
1052 1066
@@ -1065,8 +1079,8 @@ attr_iter_error (void *cls)
1065{ 1079{
1066 struct AttributeIterator *ai = cls; 1080 struct AttributeIterator *ai = cls;
1067 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); 1081 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
1068 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, 1082 GNUNET_CONTAINER_DLL_remove (
1069 ai->client->attr_iter_tail, ai); 1083 ai->client->attr_iter_head, ai->client->attr_iter_tail, ai);
1070 cleanup_attribute_iter_handle (ai); 1084 cleanup_attribute_iter_handle (ai);
1071 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 1085 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1072} 1086}
@@ -1082,14 +1096,16 @@ attr_iter_finished (void *cls)
1082 arm->id = htonl (ai->request_id); 1096 arm->id = htonl (ai->request_id);
1083 arm->attr_len = htons (0); 1097 arm->attr_len = htons (0);
1084 GNUNET_MQ_send (ai->client->mq, env); 1098 GNUNET_MQ_send (ai->client->mq, env);
1085 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, 1099 GNUNET_CONTAINER_DLL_remove (
1086 ai->client->attr_iter_tail, ai); 1100 ai->client->attr_iter_head, ai->client->attr_iter_tail, ai);
1087 cleanup_attribute_iter_handle (ai); 1101 cleanup_attribute_iter_handle (ai);
1088} 1102}
1089 1103
1090static void 1104static void
1091attr_iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1105attr_iter_cb (void *cls,
1092 const char *label, unsigned int rd_count, 1106 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1107 const char *label,
1108 unsigned int rd_count,
1093 const struct GNUNET_GNSRECORD_Data *rd) 1109 const struct GNUNET_GNSRECORD_Data *rd)
1094{ 1110{
1095 struct AttributeIterator *ai = cls; 1111 struct AttributeIterator *ai = cls;
@@ -1107,8 +1123,8 @@ attr_iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1107 return; 1123 return;
1108 } 1124 }
1109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label); 1125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label);
1110 env = GNUNET_MQ_msg_extra (arm, rd->data_size, 1126 env = GNUNET_MQ_msg_extra (
1111 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); 1127 arm, rd->data_size, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
1112 arm->id = htonl (ai->request_id); 1128 arm->id = htonl (ai->request_id);
1113 arm->attr_len = htons (rd->data_size); 1129 arm->attr_len = htons (rd->data_size);
1114 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); 1130 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
@@ -1132,9 +1148,14 @@ handle_iteration_start (void *cls,
1132 ai->identity = ais_msg->identity; 1148 ai->identity = ais_msg->identity;
1133 1149
1134 GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai); 1150 GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
1135 ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( 1151 ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh,
1136 nsh, &ai->identity, &attr_iter_error, ai, &attr_iter_cb, ai, 1152 &ai->identity,
1137 &attr_iter_finished, ai); 1153 &attr_iter_error,
1154 ai,
1155 &attr_iter_cb,
1156 ai,
1157 &attr_iter_finished,
1158 ai);
1138 GNUNET_SERVICE_client_continue (idp->client); 1159 GNUNET_SERVICE_client_continue (idp->client);
1139} 1160}
1140 1161
@@ -1146,7 +1167,8 @@ handle_iteration_stop (void *cls,
1146 struct AttributeIterator *ai; 1167 struct AttributeIterator *ai;
1147 uint32_t rid; 1168 uint32_t rid;
1148 1169
1149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 1170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1171 "Received `%s' message\n",
1150 "ATTRIBUTE_ITERATION_STOP"); 1172 "ATTRIBUTE_ITERATION_STOP");
1151 rid = ntohl (ais_msg->id); 1173 rid = ntohl (ais_msg->id);
1152 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) 1174 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
@@ -1199,10 +1221,11 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
1199 if (NULL == ticket) { 1221 if (NULL == ticket) {
1200 /* send empty response to indicate end of list */ 1222 /* send empty response to indicate end of list */
1201 env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); 1223 env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
1202 GNUNET_CONTAINER_DLL_remove (ti->client->ticket_iter_head, 1224 GNUNET_CONTAINER_DLL_remove (
1203 ti->client->ticket_iter_tail, ti); 1225 ti->client->ticket_iter_head, ti->client->ticket_iter_tail, ti);
1204 } else { 1226 } else {
1205 env = GNUNET_MQ_msg_extra (trm, sizeof (struct GNUNET_RECLAIM_Ticket), 1227 env = GNUNET_MQ_msg_extra (trm,
1228 sizeof (struct GNUNET_RECLAIM_Ticket),
1206 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); 1229 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
1207 memcpy (&trm[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket)); 1230 memcpy (&trm[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket));
1208 } 1231 }
@@ -1225,10 +1248,10 @@ handle_ticket_iteration_start (
1225 ti->r_id = ntohl (tis_msg->id); 1248 ti->r_id = ntohl (tis_msg->id);
1226 ti->client = client; 1249 ti->client = client;
1227 1250
1228 GNUNET_CONTAINER_DLL_insert (client->ticket_iter_head, 1251 GNUNET_CONTAINER_DLL_insert (
1229 client->ticket_iter_tail, ti); 1252 client->ticket_iter_head, client->ticket_iter_tail, ti);
1230 ti->iter = 1253 ti->iter = RECLAIM_TICKETS_iteration_start (
1231 RECLAIM_TICKETS_iteration_start (&tis_msg->identity, &ticket_iter_cb, ti); 1254 &tis_msg->identity, &ticket_iter_cb, ti);
1232 GNUNET_SERVICE_client_continue (client->client); 1255 GNUNET_SERVICE_client_continue (client->client);
1233} 1256}
1234 1257
@@ -1240,7 +1263,8 @@ handle_ticket_iteration_stop (void *cls,
1240 struct TicketIteration *ti; 1263 struct TicketIteration *ti;
1241 uint32_t rid; 1264 uint32_t rid;
1242 1265
1243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 1266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1267 "Received `%s' message\n",
1244 "TICKET_ITERATION_STOP"); 1268 "TICKET_ITERATION_STOP");
1245 rid = ntohl (tis_msg->id); 1269 rid = ntohl (tis_msg->id);
1246 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next) 1270 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
@@ -1252,8 +1276,8 @@ handle_ticket_iteration_stop (void *cls,
1252 return; 1276 return;
1253 } 1277 }
1254 RECLAIM_TICKETS_iteration_stop (ti->iter); 1278 RECLAIM_TICKETS_iteration_stop (ti->iter);
1255 GNUNET_CONTAINER_DLL_remove (client->ticket_iter_head, 1279 GNUNET_CONTAINER_DLL_remove (
1256 client->ticket_iter_tail, ti); 1280 client->ticket_iter_head, client->ticket_iter_tail, ti);
1257 GNUNET_free (ti); 1281 GNUNET_free (ti);
1258 GNUNET_SERVICE_client_continue (client->client); 1282 GNUNET_SERVICE_client_continue (client->client);
1259} 1283}
@@ -1289,7 +1313,8 @@ handle_ticket_iteration_next (void *cls,
1289 * @param server the service handle 1313 * @param server the service handle
1290 */ 1314 */
1291static void 1315static void
1292run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, 1316run (void *cls,
1317 const struct GNUNET_CONFIGURATION_Handle *c,
1293 struct GNUNET_SERVICE_Handle *server) 1318 struct GNUNET_SERVICE_Handle *server)
1294{ 1319{
1295 cfg = c; 1320 cfg = c;
@@ -1309,10 +1334,13 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c,
1309 1334
1310 identity_handle = GNUNET_IDENTITY_connect (cfg, NULL, NULL); 1335 identity_handle = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
1311 1336
1312 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time ( 1337 if (GNUNET_OK
1313 cfg, "reclaim", "TOKEN_EXPIRATION_INTERVAL", 1338 == GNUNET_CONFIGURATION_get_value_time (cfg,
1314 &token_expiration_interval)) { 1339 "reclaim",
1315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Time window for zone iteration: %s\n", 1340 "TOKEN_EXPIRATION_INTERVAL",
1341 &token_expiration_interval)) {
1342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1343 "Time window for zone iteration: %s\n",
1316 GNUNET_STRINGS_relative_time_to_string ( 1344 GNUNET_STRINGS_relative_time_to_string (
1317 token_expiration_interval, GNUNET_YES)); 1345 token_expiration_interval, GNUNET_YES));
1318 } else { 1346 } else {
@@ -1330,7 +1358,8 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c,
1330 * @param app_ctx @a client 1358 * @param app_ctx @a client
1331 */ 1359 */
1332static void 1360static void
1333client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, 1361client_disconnect_cb (void *cls,
1362 struct GNUNET_SERVICE_Client *client,
1334 void *app_ctx) 1363 void *app_ctx)
1335{ 1364{
1336 struct IdpClient *idp = app_ctx; 1365 struct IdpClient *idp = app_ctx;
@@ -1351,8 +1380,8 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client,
1351 GNUNET_free (iss); 1380 GNUNET_free (iss);
1352 } 1381 }
1353 while (NULL != (ct = idp->consume_op_head)) { 1382 while (NULL != (ct = idp->consume_op_head)) {
1354 GNUNET_CONTAINER_DLL_remove (idp->consume_op_head, idp->consume_op_tail, 1383 GNUNET_CONTAINER_DLL_remove (
1355 ct); 1384 idp->consume_op_head, idp->consume_op_tail, ct);
1356 if (NULL != ct->ch) 1385 if (NULL != ct->ch)
1357 RECLAIM_TICKETS_consume_cancel (ct->ch); 1386 RECLAIM_TICKETS_consume_cancel (ct->ch);
1358 GNUNET_free (ct); 1387 GNUNET_free (ct);
@@ -1377,8 +1406,8 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client,
1377 GNUNET_free (rop); 1406 GNUNET_free (rop);
1378 } 1407 }
1379 while (NULL != (ti = idp->ticket_iter_head)) { 1408 while (NULL != (ti = idp->ticket_iter_head)) {
1380 GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head, idp->ticket_iter_tail, 1409 GNUNET_CONTAINER_DLL_remove (
1381 ti); 1410 idp->ticket_iter_head, idp->ticket_iter_tail, ti);
1382 GNUNET_free (ti); 1411 GNUNET_free (ti);
1383 } 1412 }
1384 GNUNET_free (idp); 1413 GNUNET_free (idp);
@@ -1393,7 +1422,8 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client,
1393 * @return internal namestore client structure for this client 1422 * @return internal namestore client structure for this client
1394 */ 1423 */
1395static void * 1424static void *
1396client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, 1425client_connect_cb (void *cls,
1426 struct GNUNET_SERVICE_Client *client,
1397 struct GNUNET_MQ_Handle *mq) 1427 struct GNUNET_MQ_Handle *mq)
1398{ 1428{
1399 struct IdpClient *idp; 1429 struct IdpClient *idp;
@@ -1408,40 +1438,58 @@ client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client,
1408 * Define "main" method using service macro. 1438 * Define "main" method using service macro.
1409 */ 1439 */
1410GNUNET_SERVICE_MAIN ( 1440GNUNET_SERVICE_MAIN (
1411 "reclaim", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, 1441 "reclaim",
1412 &client_disconnect_cb, NULL, 1442 GNUNET_SERVICE_OPTION_NONE,
1443 &run,
1444 &client_connect_cb,
1445 &client_disconnect_cb,
1446 NULL,
1413 GNUNET_MQ_hd_var_size (attribute_store_message, 1447 GNUNET_MQ_hd_var_size (attribute_store_message,
1414 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, 1448 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE,
1415 struct AttributeStoreMessage, NULL), 1449 struct AttributeStoreMessage,
1450 NULL),
1416 GNUNET_MQ_hd_var_size (attribute_delete_message, 1451 GNUNET_MQ_hd_var_size (attribute_delete_message,
1417 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, 1452 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE,
1418 struct AttributeDeleteMessage, NULL), 1453 struct AttributeDeleteMessage,
1454 NULL),
1419 GNUNET_MQ_hd_fixed_size ( 1455 GNUNET_MQ_hd_fixed_size (
1420 iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, 1456 iteration_start,
1421 struct AttributeIterationStartMessage, NULL), 1457 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START,
1458 struct AttributeIterationStartMessage,
1459 NULL),
1422 GNUNET_MQ_hd_fixed_size ( 1460 GNUNET_MQ_hd_fixed_size (
1423 iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, 1461 iteration_next,
1424 struct AttributeIterationNextMessage, NULL), 1462 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT,
1463 struct AttributeIterationNextMessage,
1464 NULL),
1425 GNUNET_MQ_hd_fixed_size ( 1465 GNUNET_MQ_hd_fixed_size (
1426 iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, 1466 iteration_stop,
1427 struct AttributeIterationStopMessage, NULL), 1467 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP,
1468 struct AttributeIterationStopMessage,
1469 NULL),
1428 GNUNET_MQ_hd_var_size (issue_ticket_message, 1470 GNUNET_MQ_hd_var_size (issue_ticket_message,
1429 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, 1471 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET,
1430 struct IssueTicketMessage, NULL), 1472 struct IssueTicketMessage,
1473 NULL),
1431 GNUNET_MQ_hd_var_size (consume_ticket_message, 1474 GNUNET_MQ_hd_var_size (consume_ticket_message,
1432 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, 1475 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET,
1433 struct ConsumeTicketMessage, NULL), 1476 struct ConsumeTicketMessage,
1477 NULL),
1434 GNUNET_MQ_hd_fixed_size (ticket_iteration_start, 1478 GNUNET_MQ_hd_fixed_size (ticket_iteration_start,
1435 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, 1479 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START,
1436 struct TicketIterationStartMessage, NULL), 1480 struct TicketIterationStartMessage,
1481 NULL),
1437 GNUNET_MQ_hd_fixed_size (ticket_iteration_next, 1482 GNUNET_MQ_hd_fixed_size (ticket_iteration_next,
1438 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, 1483 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT,
1439 struct TicketIterationNextMessage, NULL), 1484 struct TicketIterationNextMessage,
1485 NULL),
1440 GNUNET_MQ_hd_fixed_size (ticket_iteration_stop, 1486 GNUNET_MQ_hd_fixed_size (ticket_iteration_stop,
1441 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, 1487 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP,
1442 struct TicketIterationStopMessage, NULL), 1488 struct TicketIterationStopMessage,
1489 NULL),
1443 GNUNET_MQ_hd_var_size (revoke_ticket_message, 1490 GNUNET_MQ_hd_var_size (revoke_ticket_message,
1444 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, 1491 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET,
1445 struct RevokeTicketMessage, NULL), 1492 struct RevokeTicketMessage,
1493 NULL),
1446 GNUNET_MQ_handler_end ()); 1494 GNUNET_MQ_handler_end ());
1447/* end of gnunet-service-reclaim.c */ 1495/* end of gnunet-service-reclaim.c */