diff options
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 328 |
1 files changed, 291 insertions, 37 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index d5aeff8d7..6db97fe87 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -24,9 +24,7 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | |||
28 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
29 | |||
30 | #include "gnunet-service-reclaim_tickets.h" | 28 | #include "gnunet-service-reclaim_tickets.h" |
31 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
32 | #include "gnunet_gnsrecord_lib.h" | 30 | #include "gnunet_gnsrecord_lib.h" |
@@ -124,6 +122,7 @@ struct TicketIteration | |||
124 | struct RECLAIM_TICKETS_Iterator *iter; | 122 | struct RECLAIM_TICKETS_Iterator *iter; |
125 | }; | 123 | }; |
126 | 124 | ||
125 | |||
127 | /** | 126 | /** |
128 | * An attribute iteration operation. | 127 | * An attribute iteration operation. |
129 | */ | 128 | */ |
@@ -160,6 +159,7 @@ struct AttributeIterator | |||
160 | uint32_t request_id; | 159 | uint32_t request_id; |
161 | }; | 160 | }; |
162 | 161 | ||
162 | |||
163 | /** | 163 | /** |
164 | * An idp client | 164 | * An idp client |
165 | */ | 165 | */ |
@@ -251,6 +251,9 @@ struct IdpClient | |||
251 | }; | 251 | }; |
252 | 252 | ||
253 | 253 | ||
254 | /** | ||
255 | * Handle for attribute deletion request | ||
256 | */ | ||
254 | struct AttributeDeleteHandle | 257 | struct AttributeDeleteHandle |
255 | { | 258 | { |
256 | /** | 259 | /** |
@@ -311,6 +314,9 @@ struct AttributeDeleteHandle | |||
311 | }; | 314 | }; |
312 | 315 | ||
313 | 316 | ||
317 | /** | ||
318 | * Handle for attribute store request | ||
319 | */ | ||
314 | struct AttributeStoreHandle | 320 | struct AttributeStoreHandle |
315 | { | 321 | { |
316 | /** | 322 | /** |
@@ -359,6 +365,10 @@ struct AttributeStoreHandle | |||
359 | uint32_t r_id; | 365 | uint32_t r_id; |
360 | }; | 366 | }; |
361 | 367 | ||
368 | |||
369 | /** | ||
370 | * Handle for ticket consume request | ||
371 | */ | ||
362 | struct ConsumeTicketOperation | 372 | struct ConsumeTicketOperation |
363 | { | 373 | { |
364 | /** | 374 | /** |
@@ -387,6 +397,7 @@ struct ConsumeTicketOperation | |||
387 | struct RECLAIM_TICKETS_ConsumeHandle *ch; | 397 | struct RECLAIM_TICKETS_ConsumeHandle *ch; |
388 | }; | 398 | }; |
389 | 399 | ||
400 | |||
390 | /** | 401 | /** |
391 | * Updated attribute IDs | 402 | * Updated attribute IDs |
392 | */ | 403 | */ |
@@ -413,6 +424,7 @@ struct TicketAttributeUpdateEntry | |||
413 | uint64_t new_id; | 424 | uint64_t new_id; |
414 | }; | 425 | }; |
415 | 426 | ||
427 | |||
416 | /** | 428 | /** |
417 | * Ticket revocation request handle | 429 | * Ticket revocation request handle |
418 | */ | 430 | */ |
@@ -444,6 +456,7 @@ struct TicketRevocationOperation | |||
444 | uint32_t r_id; | 456 | uint32_t r_id; |
445 | }; | 457 | }; |
446 | 458 | ||
459 | |||
447 | /** | 460 | /** |
448 | * Ticket issue operation handle | 461 | * Ticket issue operation handle |
449 | */ | 462 | */ |
@@ -470,6 +483,7 @@ struct TicketIssueOperation | |||
470 | uint32_t r_id; | 483 | uint32_t r_id; |
471 | }; | 484 | }; |
472 | 485 | ||
486 | |||
473 | /** | 487 | /** |
474 | * DLL for ego handles to egos containing the RECLAIM_ATTRS in a | 488 | * DLL for ego handles to egos containing the RECLAIM_ATTRS in a |
475 | * map in json_t format | 489 | * map in json_t format |
@@ -498,6 +512,7 @@ struct EgoEntry | |||
498 | struct GNUNET_CONTAINER_MultiHashMap *attr_map; | 512 | struct GNUNET_CONTAINER_MultiHashMap *attr_map; |
499 | }; | 513 | }; |
500 | 514 | ||
515 | |||
501 | /** | 516 | /** |
502 | * Cleanup task | 517 | * Cleanup task |
503 | */ | 518 | */ |
@@ -517,6 +532,7 @@ cleanup () | |||
517 | GNUNET_NAMESTORE_disconnect (nsh); | 532 | GNUNET_NAMESTORE_disconnect (nsh); |
518 | } | 533 | } |
519 | 534 | ||
535 | |||
520 | /** | 536 | /** |
521 | * Shutdown task | 537 | * Shutdown task |
522 | * | 538 | * |
@@ -530,6 +546,14 @@ do_shutdown (void *cls) | |||
530 | } | 546 | } |
531 | 547 | ||
532 | 548 | ||
549 | /** | ||
550 | * Sends a ticket result message to the client | ||
551 | * | ||
552 | * @param client the client to send to | ||
553 | * @param r_id the request message ID to reply to | ||
554 | * @param ticket the ticket to include (may be NULL) | ||
555 | * @param success the success status of the request | ||
556 | */ | ||
533 | static void | 557 | static void |
534 | send_ticket_result (const struct IdpClient *client, | 558 | send_ticket_result (const struct IdpClient *client, |
535 | uint32_t r_id, | 559 | uint32_t r_id, |
@@ -555,6 +579,15 @@ send_ticket_result (const struct IdpClient *client, | |||
555 | GNUNET_MQ_send (client->mq, env); | 579 | GNUNET_MQ_send (client->mq, env); |
556 | } | 580 | } |
557 | 581 | ||
582 | |||
583 | /** | ||
584 | * Issue ticket result | ||
585 | * | ||
586 | * @param cls out ticket issue operation handle | ||
587 | * @param ticket the issued ticket | ||
588 | * @param success issue success status (GNUNET_OK if successful) | ||
589 | * @param emsg error message (NULL of success is GNUNET_OK) | ||
590 | */ | ||
558 | static void | 591 | static void |
559 | issue_ticket_result_cb (void *cls, | 592 | issue_ticket_result_cb (void *cls, |
560 | struct GNUNET_RECLAIM_Ticket *ticket, | 593 | struct GNUNET_RECLAIM_Ticket *ticket, |
@@ -578,6 +611,14 @@ issue_ticket_result_cb (void *cls, | |||
578 | GNUNET_free (tio); | 611 | GNUNET_free (tio); |
579 | } | 612 | } |
580 | 613 | ||
614 | |||
615 | /** | ||
616 | * Check issue ticket message | ||
617 | * | ||
618 | * @cls unused | ||
619 | * @im message to check | ||
620 | * @return GNUNET_OK if message is ok | ||
621 | */ | ||
581 | static int | 622 | static int |
582 | check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | 623 | check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) |
583 | { | 624 | { |
@@ -591,6 +632,13 @@ check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
591 | return GNUNET_OK; | 632 | return GNUNET_OK; |
592 | } | 633 | } |
593 | 634 | ||
635 | |||
636 | /** | ||
637 | * Handle ticket issue message | ||
638 | * | ||
639 | * @param cls our client | ||
640 | * @param im the message | ||
641 | */ | ||
594 | static void | 642 | static void |
595 | handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | 643 | handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) |
596 | { | 644 | { |
@@ -615,10 +663,18 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
615 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); | 663 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); |
616 | } | 664 | } |
617 | 665 | ||
666 | |||
667 | |||
618 | /********************************************************** | 668 | /********************************************************** |
619 | * Revocation | 669 | * Revocation |
620 | **********************************************************/ | 670 | **********************************************************/ |
621 | 671 | ||
672 | /** | ||
673 | * Handles revocation result | ||
674 | * | ||
675 | * @param cls our revocation operation handle | ||
676 | * @param success revocation result (GNUNET_OK if successful) | ||
677 | */ | ||
622 | static void | 678 | static void |
623 | revoke_result_cb (void *cls, int32_t success) | 679 | revoke_result_cb (void *cls, int32_t success) |
624 | { | 680 | { |
@@ -639,6 +695,13 @@ revoke_result_cb (void *cls, int32_t success) | |||
639 | } | 695 | } |
640 | 696 | ||
641 | 697 | ||
698 | /** | ||
699 | * Check revocation message format | ||
700 | * | ||
701 | * @param cls unused | ||
702 | * @param im the message to check | ||
703 | * @return GNUNET_OK if message is ok | ||
704 | */ | ||
642 | static int | 705 | static int |
643 | check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im) | 706 | check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im) |
644 | { | 707 | { |
@@ -652,6 +715,13 @@ check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im) | |||
652 | return GNUNET_OK; | 715 | return GNUNET_OK; |
653 | } | 716 | } |
654 | 717 | ||
718 | |||
719 | /** | ||
720 | * Handle a revocation message to a ticket. | ||
721 | * | ||
722 | * @param cls our client | ||
723 | * @param rm the message to handle | ||
724 | */ | ||
655 | static void | 725 | static void |
656 | handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | 726 | handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) |
657 | { | 727 | { |
@@ -670,19 +740,16 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | |||
670 | GNUNET_SERVICE_client_continue (idp->client); | 740 | GNUNET_SERVICE_client_continue (idp->client); |
671 | } | 741 | } |
672 | 742 | ||
673 | static int | ||
674 | check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | ||
675 | { | ||
676 | uint16_t size; | ||
677 | |||
678 | size = ntohs (cm->header.size); | ||
679 | if (size <= sizeof (struct ConsumeTicketMessage)) { | ||
680 | GNUNET_break (0); | ||
681 | return GNUNET_SYSERR; | ||
682 | } | ||
683 | return GNUNET_OK; | ||
684 | } | ||
685 | 743 | ||
744 | /** | ||
745 | * Handle a ticket consume result | ||
746 | * | ||
747 | * @param cls our consume ticket operation handle | ||
748 | * @param identity the attribute authority | ||
749 | * @param attrs the attribute/claim list | ||
750 | * @param success GNUNET_OK if successful | ||
751 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
752 | */ | ||
686 | static void | 753 | static void |
687 | consume_result_cb (void *cls, | 754 | consume_result_cb (void *cls, |
688 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 755 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
@@ -716,6 +783,33 @@ consume_result_cb (void *cls, | |||
716 | GNUNET_free (cop); | 783 | GNUNET_free (cop); |
717 | } | 784 | } |
718 | 785 | ||
786 | |||
787 | /** | ||
788 | * Check a consume ticket message | ||
789 | * | ||
790 | * @param cls unused | ||
791 | * @param cm the message to handle | ||
792 | */ | ||
793 | static int | ||
794 | check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | ||
795 | { | ||
796 | uint16_t size; | ||
797 | |||
798 | size = ntohs (cm->header.size); | ||
799 | if (size <= sizeof (struct ConsumeTicketMessage)) { | ||
800 | GNUNET_break (0); | ||
801 | return GNUNET_SYSERR; | ||
802 | } | ||
803 | return GNUNET_OK; | ||
804 | } | ||
805 | |||
806 | |||
807 | /** | ||
808 | * Handle a consume ticket message | ||
809 | * | ||
810 | * @param cls our client handle | ||
811 | * @cm the message to handle | ||
812 | */ | ||
719 | static void | 813 | static void |
720 | handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | 814 | handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) |
721 | { | 815 | { |
@@ -753,6 +847,14 @@ cleanup_as_handle (struct AttributeStoreHandle *ash) | |||
753 | GNUNET_free (ash); | 847 | GNUNET_free (ash); |
754 | } | 848 | } |
755 | 849 | ||
850 | |||
851 | /** | ||
852 | * Attribute store result handler | ||
853 | * | ||
854 | * @param cls our attribute store handle | ||
855 | * @param success GNUNET_OK if successful | ||
856 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
857 | */ | ||
756 | static void | 858 | static void |
757 | attr_store_cont (void *cls, int32_t success, const char *emsg) | 859 | attr_store_cont (void *cls, int32_t success, const char *emsg) |
758 | { | 860 | { |
@@ -782,8 +884,9 @@ attr_store_cont (void *cls, int32_t success, const char *emsg) | |||
782 | cleanup_as_handle (ash); | 884 | cleanup_as_handle (ash); |
783 | } | 885 | } |
784 | 886 | ||
887 | |||
785 | /** | 888 | /** |
786 | * Adds a new attribute | 889 | * Add a new attribute |
787 | * | 890 | * |
788 | * @param cls the AttributeStoreHandle | 891 | * @param cls the AttributeStoreHandle |
789 | */ | 892 | */ |
@@ -823,6 +926,13 @@ attr_store_task (void *cls) | |||
823 | GNUNET_free (buf); | 926 | GNUNET_free (buf); |
824 | } | 927 | } |
825 | 928 | ||
929 | |||
930 | /** | ||
931 | * Check an attribute store message | ||
932 | * | ||
933 | * @param cls unused | ||
934 | * @param sam the message to check | ||
935 | */ | ||
826 | static int | 936 | static int |
827 | check_attribute_store_message (void *cls, | 937 | check_attribute_store_message (void *cls, |
828 | const struct AttributeStoreMessage *sam) | 938 | const struct AttributeStoreMessage *sam) |
@@ -837,6 +947,13 @@ check_attribute_store_message (void *cls, | |||
837 | return GNUNET_OK; | 947 | return GNUNET_OK; |
838 | } | 948 | } |
839 | 949 | ||
950 | |||
951 | /** | ||
952 | * Handle an attribute store message | ||
953 | * | ||
954 | * @param cls our client | ||
955 | * @param sam the message to handle | ||
956 | */ | ||
840 | static void | 957 | static void |
841 | handle_attribute_store_message (void *cls, | 958 | handle_attribute_store_message (void *cls, |
842 | const struct AttributeStoreMessage *sam) | 959 | const struct AttributeStoreMessage *sam) |
@@ -863,6 +980,11 @@ handle_attribute_store_message (void *cls, | |||
863 | } | 980 | } |
864 | 981 | ||
865 | 982 | ||
983 | /** | ||
984 | * Cleanup attribute delete handle | ||
985 | * | ||
986 | * @param adh the attribute to cleanup | ||
987 | */ | ||
866 | static void | 988 | static void |
867 | cleanup_adh (struct AttributeDeleteHandle *adh) | 989 | cleanup_adh (struct AttributeDeleteHandle *adh) |
868 | { | 990 | { |
@@ -889,6 +1011,12 @@ cleanup_adh (struct AttributeDeleteHandle *adh) | |||
889 | } | 1011 | } |
890 | 1012 | ||
891 | 1013 | ||
1014 | /** | ||
1015 | * Send a deletion success response | ||
1016 | * | ||
1017 | * @param adh our attribute deletion handle | ||
1018 | * @param success the success status | ||
1019 | */ | ||
892 | static void | 1020 | static void |
893 | send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) | 1021 | send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) |
894 | { | 1022 | { |
@@ -907,6 +1035,16 @@ send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) | |||
907 | } | 1035 | } |
908 | 1036 | ||
909 | 1037 | ||
1038 | /** | ||
1039 | * Namestore iteration within attribute deletion. | ||
1040 | * We need to reissue tickets with the deleted attribute removed. | ||
1041 | * | ||
1042 | * @param cls our attribute deletion handle | ||
1043 | * @param zone the private key of the ticket issuer | ||
1044 | * @param label the label of the record | ||
1045 | * @param rd_count number of records | ||
1046 | * @param rd record data | ||
1047 | */ | ||
910 | static void | 1048 | static void |
911 | ticket_iter (void *cls, | 1049 | ticket_iter (void *cls, |
912 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1050 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
@@ -944,10 +1082,21 @@ ticket_iter (void *cls, | |||
944 | } | 1082 | } |
945 | 1083 | ||
946 | 1084 | ||
1085 | /** | ||
1086 | * Recursion prototype for function | ||
1087 | * @param cls our deletion handle | ||
1088 | */ | ||
947 | static void | 1089 | static void |
948 | update_tickets (void *cls); | 1090 | update_tickets (void *cls); |
949 | 1091 | ||
950 | 1092 | ||
1093 | /** | ||
1094 | * Callback called when a ticket was updated | ||
1095 | * | ||
1096 | * @param cls our attribute deletion handle | ||
1097 | * @param success GNUNET_OK if successful | ||
1098 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1099 | */ | ||
951 | static void | 1100 | static void |
952 | ticket_updated (void *cls, int32_t success, const char *emsg) | 1101 | ticket_updated (void *cls, int32_t success, const char *emsg) |
953 | { | 1102 | { |
@@ -956,6 +1105,14 @@ ticket_updated (void *cls, int32_t success, const char *emsg) | |||
956 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); | 1105 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); |
957 | } | 1106 | } |
958 | 1107 | ||
1108 | |||
1109 | /** | ||
1110 | * Update tickets: Remove shared attribute which has just been deleted. | ||
1111 | * This method is called recursively until all tickets are processed. | ||
1112 | * Eventually, the updated tickets are stored using ``update_tickets''. | ||
1113 | * | ||
1114 | * @param cls our attribute deletion handle | ||
1115 | */ | ||
959 | static void | 1116 | static void |
960 | update_tickets (void *cls) | 1117 | update_tickets (void *cls) |
961 | { | 1118 | { |
@@ -1002,6 +1159,11 @@ update_tickets (void *cls) | |||
1002 | } | 1159 | } |
1003 | 1160 | ||
1004 | 1161 | ||
1162 | /** | ||
1163 | * Done collecting affected tickets, start updating. | ||
1164 | * | ||
1165 | * @param cls our attribute deletion handle | ||
1166 | */ | ||
1005 | static void | 1167 | static void |
1006 | ticket_iter_fin (void *cls) | 1168 | ticket_iter_fin (void *cls) |
1007 | { | 1169 | { |
@@ -1011,6 +1173,11 @@ ticket_iter_fin (void *cls) | |||
1011 | } | 1173 | } |
1012 | 1174 | ||
1013 | 1175 | ||
1176 | /** | ||
1177 | * Error collecting affected tickets. Abort. | ||
1178 | * | ||
1179 | * @param cls our attribute deletion handle | ||
1180 | */ | ||
1014 | static void | 1181 | static void |
1015 | ticket_iter_err (void *cls) | 1182 | ticket_iter_err (void *cls) |
1016 | { | 1183 | { |
@@ -1024,6 +1191,12 @@ ticket_iter_err (void *cls) | |||
1024 | } | 1191 | } |
1025 | 1192 | ||
1026 | 1193 | ||
1194 | /** | ||
1195 | * Start processing tickets which may still contain reference to deleted | ||
1196 | * attribute. | ||
1197 | * | ||
1198 | * @param cls attribute deletion handle | ||
1199 | */ | ||
1027 | static void | 1200 | static void |
1028 | start_ticket_update (void *cls) | 1201 | start_ticket_update (void *cls) |
1029 | { | 1202 | { |
@@ -1039,6 +1212,13 @@ start_ticket_update (void *cls) | |||
1039 | } | 1212 | } |
1040 | 1213 | ||
1041 | 1214 | ||
1215 | /** | ||
1216 | * Attribute deleted callback | ||
1217 | * | ||
1218 | * @param cls our handle | ||
1219 | * @param success success status | ||
1220 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1221 | */ | ||
1042 | static void | 1222 | static void |
1043 | attr_delete_cont (void *cls, int32_t success, const char *emsg) | 1223 | attr_delete_cont (void *cls, int32_t success, const char *emsg) |
1044 | { | 1224 | { |
@@ -1052,11 +1232,17 @@ attr_delete_cont (void *cls, int32_t success, const char *emsg) | |||
1052 | cleanup_adh (adh); | 1232 | cleanup_adh (adh); |
1053 | return; | 1233 | return; |
1054 | } | 1234 | } |
1055 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating tickets...\n"); | 1235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); |
1056 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | 1236 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); |
1057 | } | 1237 | } |
1058 | 1238 | ||
1059 | 1239 | ||
1240 | /** | ||
1241 | * Check attribute delete message format | ||
1242 | * | ||
1243 | * @cls unused | ||
1244 | * @dam message to check | ||
1245 | */ | ||
1060 | static int | 1246 | static int |
1061 | check_attribute_delete_message (void *cls, | 1247 | check_attribute_delete_message (void *cls, |
1062 | const struct AttributeDeleteMessage *dam) | 1248 | const struct AttributeDeleteMessage *dam) |
@@ -1072,6 +1258,12 @@ check_attribute_delete_message (void *cls, | |||
1072 | } | 1258 | } |
1073 | 1259 | ||
1074 | 1260 | ||
1261 | /** | ||
1262 | * Handle attribute deletion | ||
1263 | * | ||
1264 | * @param cls our client | ||
1265 | * @param dam deletion message | ||
1266 | */ | ||
1075 | static void | 1267 | static void |
1076 | handle_attribute_delete_message (void *cls, | 1268 | handle_attribute_delete_message (void *cls, |
1077 | const struct AttributeDeleteMessage *dam) | 1269 | const struct AttributeDeleteMessage *dam) |
@@ -1107,24 +1299,12 @@ handle_attribute_delete_message (void *cls, | |||
1107 | * Attrubute iteration | 1299 | * Attrubute iteration |
1108 | *************************************************/ | 1300 | *************************************************/ |
1109 | 1301 | ||
1110 | static void | ||
1111 | cleanup_attribute_iter_handle (struct AttributeIterator *ai) | ||
1112 | { | ||
1113 | GNUNET_free (ai); | ||
1114 | } | ||
1115 | |||
1116 | static void | ||
1117 | attr_iter_error (void *cls) | ||
1118 | { | ||
1119 | struct AttributeIterator *ai = cls; | ||
1120 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); | ||
1121 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, | ||
1122 | ai->client->attr_iter_tail, | ||
1123 | ai); | ||
1124 | cleanup_attribute_iter_handle (ai); | ||
1125 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1126 | } | ||
1127 | 1302 | ||
1303 | /** | ||
1304 | * Done iterating over attributes | ||
1305 | * | ||
1306 | * @param cls our iterator handle | ||
1307 | */ | ||
1128 | static void | 1308 | static void |
1129 | attr_iter_finished (void *cls) | 1309 | attr_iter_finished (void *cls) |
1130 | { | 1310 | { |
@@ -1140,9 +1320,33 @@ attr_iter_finished (void *cls) | |||
1140 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, | 1320 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, |
1141 | ai->client->attr_iter_tail, | 1321 | ai->client->attr_iter_tail, |
1142 | ai); | 1322 | ai); |
1143 | cleanup_attribute_iter_handle (ai); | 1323 | GNUNET_free (ai); |
1324 | } | ||
1325 | |||
1326 | /** | ||
1327 | * Error iterating over attributes. Abort. | ||
1328 | * | ||
1329 | * @param cls our attribute iteration handle | ||
1330 | */ | ||
1331 | static void | ||
1332 | attr_iter_error (void *cls) | ||
1333 | { | ||
1334 | struct AttributeIterator *ai = cls; | ||
1335 | |||
1336 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); | ||
1337 | attr_iter_finished (ai); | ||
1144 | } | 1338 | } |
1145 | 1339 | ||
1340 | |||
1341 | /** | ||
1342 | * Got record. Return if it is an attribute. | ||
1343 | * | ||
1344 | * @param cls our attribute iterator | ||
1345 | * @param zone zone we are iterating | ||
1346 | * @param label label of the records | ||
1347 | * @param rd_count record count | ||
1348 | * @param rd records | ||
1349 | */ | ||
1146 | static void | 1350 | static void |
1147 | attr_iter_cb (void *cls, | 1351 | attr_iter_cb (void *cls, |
1148 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1352 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
@@ -1177,6 +1381,13 @@ attr_iter_cb (void *cls, | |||
1177 | GNUNET_MQ_send (ai->client->mq, env); | 1381 | GNUNET_MQ_send (ai->client->mq, env); |
1178 | } | 1382 | } |
1179 | 1383 | ||
1384 | |||
1385 | /** | ||
1386 | * Iterate over zone to get attributes | ||
1387 | * | ||
1388 | * @param cls our client | ||
1389 | * @param ais_msg the iteration message to start | ||
1390 | */ | ||
1180 | static void | 1391 | static void |
1181 | handle_iteration_start (void *cls, | 1392 | handle_iteration_start (void *cls, |
1182 | const struct AttributeIterationStartMessage *ais_msg) | 1393 | const struct AttributeIterationStartMessage *ais_msg) |
@@ -1203,6 +1414,13 @@ handle_iteration_start (void *cls, | |||
1203 | GNUNET_SERVICE_client_continue (idp->client); | 1414 | GNUNET_SERVICE_client_continue (idp->client); |
1204 | } | 1415 | } |
1205 | 1416 | ||
1417 | |||
1418 | /** | ||
1419 | * Handle iteration stop message from client | ||
1420 | * | ||
1421 | * @param cls the client | ||
1422 | * @param ais_msg the stop message | ||
1423 | */ | ||
1206 | static void | 1424 | static void |
1207 | handle_iteration_stop (void *cls, | 1425 | handle_iteration_stop (void *cls, |
1208 | const struct AttributeIterationStopMessage *ais_msg) | 1426 | const struct AttributeIterationStopMessage *ais_msg) |
@@ -1228,6 +1446,13 @@ handle_iteration_stop (void *cls, | |||
1228 | GNUNET_SERVICE_client_continue (idp->client); | 1446 | GNUNET_SERVICE_client_continue (idp->client); |
1229 | } | 1447 | } |
1230 | 1448 | ||
1449 | |||
1450 | /** | ||
1451 | * Client requests next attribute from iterator | ||
1452 | * | ||
1453 | * @param cls the client | ||
1454 | * @param ais_msg the message | ||
1455 | */ | ||
1231 | static void | 1456 | static void |
1232 | handle_iteration_next (void *cls, | 1457 | handle_iteration_next (void *cls, |
1233 | const struct AttributeIterationNextMessage *ais_msg) | 1458 | const struct AttributeIterationNextMessage *ais_msg) |
@@ -1255,6 +1480,12 @@ handle_iteration_next (void *cls, | |||
1255 | * Ticket iteration | 1480 | * Ticket iteration |
1256 | ******************************************************/ | 1481 | ******************************************************/ |
1257 | 1482 | ||
1483 | /** | ||
1484 | * Got a ticket. Return to client | ||
1485 | * | ||
1486 | * @param cls our ticket iterator | ||
1487 | * @param ticket the ticket | ||
1488 | */ | ||
1258 | static void | 1489 | static void |
1259 | ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | 1490 | ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) |
1260 | { | 1491 | { |
@@ -1281,6 +1512,13 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
1281 | GNUNET_free (ti); | 1512 | GNUNET_free (ti); |
1282 | } | 1513 | } |
1283 | 1514 | ||
1515 | |||
1516 | /** | ||
1517 | * Client requests a ticket iteration | ||
1518 | * | ||
1519 | * @param cls the client | ||
1520 | * @param tis_msg the iteration request message | ||
1521 | */ | ||
1284 | static void | 1522 | static void |
1285 | handle_ticket_iteration_start ( | 1523 | handle_ticket_iteration_start ( |
1286 | void *cls, | 1524 | void *cls, |
@@ -1303,6 +1541,13 @@ handle_ticket_iteration_start ( | |||
1303 | GNUNET_SERVICE_client_continue (client->client); | 1541 | GNUNET_SERVICE_client_continue (client->client); |
1304 | } | 1542 | } |
1305 | 1543 | ||
1544 | |||
1545 | /** | ||
1546 | * Client has had enough tickets | ||
1547 | * | ||
1548 | * @param cls the client | ||
1549 | * @param tis_msg the stop message | ||
1550 | */ | ||
1306 | static void | 1551 | static void |
1307 | handle_ticket_iteration_stop (void *cls, | 1552 | handle_ticket_iteration_stop (void *cls, |
1308 | const struct TicketIterationStopMessage *tis_msg) | 1553 | const struct TicketIterationStopMessage *tis_msg) |
@@ -1331,6 +1576,13 @@ handle_ticket_iteration_stop (void *cls, | |||
1331 | GNUNET_SERVICE_client_continue (client->client); | 1576 | GNUNET_SERVICE_client_continue (client->client); |
1332 | } | 1577 | } |
1333 | 1578 | ||
1579 | |||
1580 | /** | ||
1581 | * Client requests next result. | ||
1582 | * | ||
1583 | * @param cls the client | ||
1584 | * @param tis_msg the message | ||
1585 | */ | ||
1334 | static void | 1586 | static void |
1335 | handle_ticket_iteration_next (void *cls, | 1587 | handle_ticket_iteration_next (void *cls, |
1336 | const struct TicketIterationNextMessage *tis_msg) | 1588 | const struct TicketIterationNextMessage *tis_msg) |
@@ -1354,6 +1606,7 @@ handle_ticket_iteration_next (void *cls, | |||
1354 | GNUNET_SERVICE_client_continue (client->client); | 1606 | GNUNET_SERVICE_client_continue (client->client); |
1355 | } | 1607 | } |
1356 | 1608 | ||
1609 | |||
1357 | /** | 1610 | /** |
1358 | * Main function that will be run | 1611 | * Main function that will be run |
1359 | * | 1612 | * |
@@ -1400,6 +1653,7 @@ run (void *cls, | |||
1400 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 1653 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
1401 | } | 1654 | } |
1402 | 1655 | ||
1656 | |||
1403 | /** | 1657 | /** |
1404 | * Called whenever a client is disconnected. | 1658 | * Called whenever a client is disconnected. |
1405 | * | 1659 | * |
@@ -1421,8 +1675,6 @@ client_disconnect_cb (void *cls, | |||
1421 | struct AttributeStoreHandle *as; | 1675 | struct AttributeStoreHandle *as; |
1422 | struct AttributeDeleteHandle *adh; | 1676 | struct AttributeDeleteHandle *adh; |
1423 | 1677 | ||
1424 | // TODO other operations | ||
1425 | |||
1426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); | 1678 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); |
1427 | 1679 | ||
1428 | while (NULL != (iss = idp->issue_op_head)) { | 1680 | while (NULL != (iss = idp->issue_op_head)) { |
@@ -1448,7 +1700,7 @@ client_disconnect_cb (void *cls, | |||
1448 | 1700 | ||
1449 | while (NULL != (ai = idp->attr_iter_head)) { | 1701 | while (NULL != (ai = idp->attr_iter_head)) { |
1450 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); | 1702 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); |
1451 | cleanup_attribute_iter_handle (ai); | 1703 | GNUNET_free (ai); |
1452 | } | 1704 | } |
1453 | while (NULL != (rop = idp->revoke_op_head)) { | 1705 | while (NULL != (rop = idp->revoke_op_head)) { |
1454 | GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); | 1706 | GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); |
@@ -1465,6 +1717,7 @@ client_disconnect_cb (void *cls, | |||
1465 | GNUNET_free (idp); | 1717 | GNUNET_free (idp); |
1466 | } | 1718 | } |
1467 | 1719 | ||
1720 | |||
1468 | /** | 1721 | /** |
1469 | * Add a client to our list of active clients. | 1722 | * Add a client to our list of active clients. |
1470 | * | 1723 | * |
@@ -1486,6 +1739,7 @@ client_connect_cb (void *cls, | |||
1486 | return idp; | 1739 | return idp; |
1487 | } | 1740 | } |
1488 | 1741 | ||
1742 | |||
1489 | /** | 1743 | /** |
1490 | * Define "main" method using service macro. | 1744 | * Define "main" method using service macro. |
1491 | */ | 1745 | */ |