diff options
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 955 |
1 files changed, 323 insertions, 632 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 556006af0..d4d44c3fc 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
30 | #include "gnunet_gnsrecord_lib.h" | 30 | #include "gnunet_gnsrecord_lib.h" |
31 | #include "gnunet_protocols.h" | 31 | #include "gnunet_protocols.h" |
32 | #include "gnunet_reclaim_attribute_lib.h" | 32 | #include "gnunet_reclaim_lib.h" |
33 | #include "gnunet_reclaim_service.h" | 33 | #include "gnunet_reclaim_service.h" |
34 | #include "gnunet_signatures.h" | 34 | #include "gnunet_signatures.h" |
35 | #include "reclaim.h" | 35 | #include "reclaim.h" |
@@ -90,17 +90,17 @@ struct TicketIteration | |||
90 | /** | 90 | /** |
91 | * An attribute iteration operation. | 91 | * An attribute iteration operation. |
92 | */ | 92 | */ |
93 | struct AttributeIterator | 93 | struct Iterator |
94 | { | 94 | { |
95 | /** | 95 | /** |
96 | * Next element in the DLL | 96 | * Next element in the DLL |
97 | */ | 97 | */ |
98 | struct AttributeIterator *next; | 98 | struct Iterator *next; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Previous element in the DLL | 101 | * Previous element in the DLL |
102 | */ | 102 | */ |
103 | struct AttributeIterator *prev; | 103 | struct Iterator *prev; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * IDP client which intiated this zone iteration | 106 | * IDP client which intiated this zone iteration |
@@ -121,6 +121,11 @@ struct AttributeIterator | |||
121 | * The operation id fot the zone iteration in the response for the client | 121 | * The operation id fot the zone iteration in the response for the client |
122 | */ | 122 | */ |
123 | uint32_t request_id; | 123 | uint32_t request_id; |
124 | |||
125 | /** | ||
126 | * Context | ||
127 | */ | ||
128 | void *ctx; | ||
124 | }; | 129 | }; |
125 | 130 | ||
126 | 131 | ||
@@ -154,14 +159,28 @@ struct IdpClient | |||
154 | * Attribute iteration operations in | 159 | * Attribute iteration operations in |
155 | * progress initiated by this client | 160 | * progress initiated by this client |
156 | */ | 161 | */ |
157 | struct AttributeIterator *attr_iter_head; | 162 | struct Iterator *attr_iter_head; |
163 | |||
164 | /** | ||
165 | * Tail of the DLL of | ||
166 | * Attribute iteration operations | ||
167 | * in progress initiated by this client | ||
168 | */ | ||
169 | struct Iterator *attr_iter_tail; | ||
170 | |||
171 | /** | ||
172 | * Head of the DLL of | ||
173 | * Attribute iteration operations in | ||
174 | * progress initiated by this client | ||
175 | */ | ||
176 | struct Iterator *attest_iter_head; | ||
158 | 177 | ||
159 | /** | 178 | /** |
160 | * Tail of the DLL of | 179 | * Tail of the DLL of |
161 | * Attribute iteration operations | 180 | * Attribute iteration operations |
162 | * in progress initiated by this client | 181 | * in progress initiated by this client |
163 | */ | 182 | */ |
164 | struct AttributeIterator *attr_iter_tail; | 183 | struct Iterator *attest_iter_tail; |
165 | 184 | ||
166 | /** | 185 | /** |
167 | * Head of DLL of ticket iteration ops | 186 | * Head of DLL of ticket iteration ops |
@@ -263,18 +282,14 @@ struct AttributeDeleteHandle | |||
263 | /** | 282 | /** |
264 | * The attribute to delete | 283 | * The attribute to delete |
265 | */ | 284 | */ |
266 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 285 | struct GNUNET_RECLAIM_Attribute *claim; |
267 | 286 | ||
268 | /** | 287 | /** |
269 | * The attestation to delete | 288 | * The attestation to delete |
270 | */ | 289 | */ |
271 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | 290 | struct GNUNET_RECLAIM_Attestation *attest; |
272 | 291 | ||
273 | /** | 292 | /** |
274 | * The reference to delete | ||
275 | */ | ||
276 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; | ||
277 | /** | ||
278 | * Tickets to update | 293 | * Tickets to update |
279 | */ | 294 | */ |
280 | struct TicketRecordsEntry *tickets_to_update_head; | 295 | struct TicketRecordsEntry *tickets_to_update_head; |
@@ -334,17 +349,12 @@ struct AttributeStoreHandle | |||
334 | /** | 349 | /** |
335 | * The attribute to store | 350 | * The attribute to store |
336 | */ | 351 | */ |
337 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 352 | struct GNUNET_RECLAIM_Attribute *claim; |
338 | 353 | ||
339 | /** | 354 | /** |
340 | * The attestation to store | 355 | * The attestation to store |
341 | */ | 356 | */ |
342 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | 357 | struct GNUNET_RECLAIM_Attestation *attest; |
343 | |||
344 | /** | ||
345 | * The reference to store | ||
346 | */ | ||
347 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; | ||
348 | 358 | ||
349 | /** | 359 | /** |
350 | * The attribute expiration interval | 360 | * The attribute expiration interval |
@@ -480,8 +490,6 @@ cleanup_adh (struct AttributeDeleteHandle *adh) | |||
480 | GNUNET_free (adh->claim); | 490 | GNUNET_free (adh->claim); |
481 | if (NULL != adh->attest) | 491 | if (NULL != adh->attest) |
482 | GNUNET_free (adh->attest); | 492 | GNUNET_free (adh->attest); |
483 | if (NULL != adh->reference) | ||
484 | GNUNET_free (adh->reference); | ||
485 | while (NULL != (le = adh->tickets_to_update_head)) | 493 | while (NULL != (le = adh->tickets_to_update_head)) |
486 | { | 494 | { |
487 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | 495 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, |
@@ -511,8 +519,6 @@ cleanup_as_handle (struct AttributeStoreHandle *ash) | |||
511 | GNUNET_free (ash->claim); | 519 | GNUNET_free (ash->claim); |
512 | if (NULL != ash->attest) | 520 | if (NULL != ash->attest) |
513 | GNUNET_free (ash->attest); | 521 | GNUNET_free (ash->attest); |
514 | if (NULL != ash->reference) | ||
515 | GNUNET_free (ash->reference); | ||
516 | GNUNET_free (ash); | 522 | GNUNET_free (ash); |
517 | } | 523 | } |
518 | 524 | ||
@@ -525,7 +531,7 @@ cleanup_as_handle (struct AttributeStoreHandle *ash) | |||
525 | static void | 531 | static void |
526 | cleanup_client (struct IdpClient *idp) | 532 | cleanup_client (struct IdpClient *idp) |
527 | { | 533 | { |
528 | struct AttributeIterator *ai; | 534 | struct Iterator *ai; |
529 | struct TicketIteration *ti; | 535 | struct TicketIteration *ti; |
530 | struct TicketRevocationOperation *rop; | 536 | struct TicketRevocationOperation *rop; |
531 | struct TicketIssueOperation *iss; | 537 | struct TicketIssueOperation *iss; |
@@ -563,6 +569,13 @@ cleanup_client (struct IdpClient *idp) | |||
563 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); | 569 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); |
564 | GNUNET_free (ai); | 570 | GNUNET_free (ai); |
565 | } | 571 | } |
572 | while (NULL != (ai = idp->attest_iter_head)) | ||
573 | { | ||
574 | GNUNET_CONTAINER_DLL_remove (idp->attest_iter_head, idp->attest_iter_tail, | ||
575 | ai); | ||
576 | GNUNET_free (ai); | ||
577 | } | ||
578 | |||
566 | while (NULL != (rop = idp->revoke_op_head)) | 579 | while (NULL != (rop = idp->revoke_op_head)) |
567 | { | 580 | { |
568 | GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); | 581 | GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); |
@@ -718,13 +731,13 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
718 | { | 731 | { |
719 | struct TicketIssueOperation *tio; | 732 | struct TicketIssueOperation *tio; |
720 | struct IdpClient *idp = cls; | 733 | struct IdpClient *idp = cls; |
721 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; | 734 | struct GNUNET_RECLAIM_AttributeList *attrs; |
722 | size_t attrs_len; | 735 | size_t attrs_len; |
723 | 736 | ||
724 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); | 737 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); |
725 | tio = GNUNET_new (struct TicketIssueOperation); | 738 | tio = GNUNET_new (struct TicketIssueOperation); |
726 | attrs_len = ntohs (im->attr_len); | 739 | attrs_len = ntohs (im->attr_len); |
727 | attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &im[1], | 740 | attrs = GNUNET_RECLAIM_attribute_list_deserialize ((char *) &im[1], |
728 | attrs_len); | 741 | attrs_len); |
729 | tio->r_id = ntohl (im->id); | 742 | tio->r_id = ntohl (im->id); |
730 | tio->client = idp; | 743 | tio->client = idp; |
@@ -735,7 +748,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
735 | &issue_ticket_result_cb, | 748 | &issue_ticket_result_cb, |
736 | tio); | 749 | tio); |
737 | GNUNET_SERVICE_client_continue (idp->client); | 750 | GNUNET_SERVICE_client_continue (idp->client); |
738 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); | 751 | GNUNET_RECLAIM_attribute_list_destroy (attrs); |
739 | } | 752 | } |
740 | 753 | ||
741 | 754 | ||
@@ -828,7 +841,8 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | |||
828 | static void | 841 | static void |
829 | consume_result_cb (void *cls, | 842 | consume_result_cb (void *cls, |
830 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 843 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
831 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 844 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
845 | const struct GNUNET_RECLAIM_AttestationList *attests, | ||
832 | int32_t success, | 846 | int32_t success, |
833 | const char *emsg) | 847 | const char *emsg) |
834 | { | 848 | { |
@@ -837,23 +851,28 @@ consume_result_cb (void *cls, | |||
837 | struct GNUNET_MQ_Envelope *env; | 851 | struct GNUNET_MQ_Envelope *env; |
838 | char *data_tmp; | 852 | char *data_tmp; |
839 | size_t attrs_len; | 853 | size_t attrs_len; |
854 | size_t attests_len; | ||
840 | 855 | ||
841 | if (GNUNET_OK != success) | 856 | if (GNUNET_OK != success) |
842 | { | 857 | { |
843 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); | 858 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); |
844 | } | 859 | } |
845 | attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); | 860 | attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); |
861 | attests_len = GNUNET_RECLAIM_attestation_list_serialize_get_size (attests); | ||
846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 862 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
847 | "Sending CONSUME_TICKET_RESULT message\n"); | 863 | "Sending CONSUME_TICKET_RESULT message\n"); |
848 | env = GNUNET_MQ_msg_extra (crm, | 864 | env = GNUNET_MQ_msg_extra (crm, |
849 | attrs_len, | 865 | attrs_len + attests_len, |
850 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); | 866 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); |
851 | crm->id = htonl (cop->r_id); | 867 | crm->id = htonl (cop->r_id); |
852 | crm->attrs_len = htons (attrs_len); | 868 | crm->attrs_len = htons (attrs_len); |
869 | crm->attestations_len = htons (attests_len); | ||
853 | crm->identity = *identity; | 870 | crm->identity = *identity; |
854 | crm->result = htonl (success); | 871 | crm->result = htonl (success); |
855 | data_tmp = (char *) &crm[1]; | 872 | data_tmp = (char *) &crm[1]; |
856 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp); | 873 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); |
874 | data_tmp += attrs_len; | ||
875 | GNUNET_RECLAIM_attestation_list_serialize (attests, data_tmp); | ||
857 | GNUNET_MQ_send (cop->client->mq, env); | 876 | GNUNET_MQ_send (cop->client->mq, env); |
858 | GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, | 877 | GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, |
859 | cop->client->consume_op_tail, | 878 | cop->client->consume_op_tail, |
@@ -965,20 +984,20 @@ attr_store_task (void *cls) | |||
965 | size_t buf_size; | 984 | size_t buf_size; |
966 | 985 | ||
967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); | 986 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); |
968 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim); | 987 | buf_size = GNUNET_RECLAIM_attribute_serialize_get_size (ash->claim); |
969 | buf = GNUNET_malloc (buf_size); | 988 | buf = GNUNET_malloc (buf_size); |
970 | // Give the ash a new id if unset | 989 | // Give the ash a new id if unset |
971 | if (0 == ash->claim->id) | 990 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->claim->id)) |
972 | ash->claim->id | 991 | GNUNET_RECLAIM_id_generate (&ash->claim->id); |
973 | = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 992 | GNUNET_RECLAIM_attribute_serialize (ash->claim, buf); |
974 | GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf); | ||
975 | label | 993 | label |
976 | = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof(uint64_t)); | 994 | = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, |
995 | sizeof (ash->claim->id)); | ||
977 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | 996 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); |
978 | 997 | ||
979 | rd[0].data_size = buf_size; | 998 | rd[0].data_size = buf_size; |
980 | rd[0].data = buf; | 999 | rd[0].data = buf; |
981 | rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR; | 1000 | rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE; |
982 | rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1001 | rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
983 | rd[0].expiration_time = ash->exp.rel_value_us; | 1002 | rd[0].expiration_time = ash->exp.rel_value_us; |
984 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1003 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
@@ -1034,7 +1053,7 @@ handle_attribute_store_message (void *cls, | |||
1034 | data_len = ntohs (sam->attr_len); | 1053 | data_len = ntohs (sam->attr_len); |
1035 | 1054 | ||
1036 | ash = GNUNET_new (struct AttributeStoreHandle); | 1055 | ash = GNUNET_new (struct AttributeStoreHandle); |
1037 | ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &sam[1], | 1056 | ash->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &sam[1], |
1038 | data_len); | 1057 | data_len); |
1039 | 1058 | ||
1040 | ash->r_id = ntohl (sam->id); | 1059 | ash->r_id = ntohl (sam->id); |
@@ -1086,30 +1105,6 @@ attest_store_cont (void *cls, int32_t success, const char *emsg) | |||
1086 | cleanup_as_handle (ash); | 1105 | cleanup_as_handle (ash); |
1087 | } | 1106 | } |
1088 | 1107 | ||
1089 | /** | ||
1090 | * Send a reference error response | ||
1091 | * | ||
1092 | * @param ash our attribute store handle | ||
1093 | * @param success the success status | ||
1094 | */ | ||
1095 | static void | ||
1096 | send_ref_error (struct AttributeStoreHandle *ash) | ||
1097 | { | ||
1098 | struct GNUNET_MQ_Envelope *env; | ||
1099 | struct SuccessResultMessage *acr_msg; | ||
1100 | |||
1101 | ash->ns_qe = NULL; | ||
1102 | GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, | ||
1103 | ash->client->store_op_tail, | ||
1104 | ash); | ||
1105 | |||
1106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); | ||
1107 | env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); | ||
1108 | acr_msg->id = htonl (ash->r_id); | ||
1109 | acr_msg->op_result = htonl (GNUNET_SYSERR); | ||
1110 | GNUNET_MQ_send (ash->client->mq, env); | ||
1111 | cleanup_as_handle (ash); | ||
1112 | } | ||
1113 | 1108 | ||
1114 | /** | 1109 | /** |
1115 | * Error looking up potential attestation. Abort. | 1110 | * Error looking up potential attestation. Abort. |
@@ -1127,8 +1122,9 @@ attest_error (void *cls) | |||
1127 | return; | 1122 | return; |
1128 | } | 1123 | } |
1129 | 1124 | ||
1125 | |||
1130 | /** | 1126 | /** |
1131 | * Check for existing record before storing reference | 1127 | * Check for existing record before storing attestation |
1132 | * | 1128 | * |
1133 | * @param cls our attribute store handle | 1129 | * @param cls our attribute store handle |
1134 | * @param zone zone we are iterating | 1130 | * @param zone zone we are iterating |
@@ -1146,58 +1142,30 @@ attest_add_cb (void *cls, | |||
1146 | struct AttributeStoreHandle *ash = cls; | 1142 | struct AttributeStoreHandle *ash = cls; |
1147 | char *buf; | 1143 | char *buf; |
1148 | size_t buf_size; | 1144 | size_t buf_size; |
1149 | buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest); | 1145 | buf_size = GNUNET_RECLAIM_attestation_serialize_get_size (ash->attest); |
1150 | buf = GNUNET_malloc (buf_size); | 1146 | buf = GNUNET_malloc (buf_size); |
1151 | GNUNET_RECLAIM_ATTESTATION_serialize (ash->attest, buf); | 1147 | GNUNET_RECLAIM_attestation_serialize (ash->attest, buf); |
1152 | if (0 == rd_count ) | 1148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1153 | { | 1149 | "Storing new Attestation\n"); |
1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1150 | struct GNUNET_GNSRECORD_Data rd_new[1]; |
1155 | "Storing new Attestation\n"); | ||
1156 | struct GNUNET_GNSRECORD_Data rd_new[1]; | ||
1157 | rd_new[0].data_size = buf_size; | ||
1158 | rd_new[0].data = buf; | ||
1159 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR; | ||
1160 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1161 | rd_new[0].expiration_time = ash->exp.rel_value_us; | ||
1162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | ||
1163 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1164 | &ash->identity, | ||
1165 | label, | ||
1166 | 1, | ||
1167 | rd_new, | ||
1168 | &attest_store_cont, | ||
1169 | ash); | ||
1170 | GNUNET_free (buf); | ||
1171 | return; | ||
1172 | } | ||
1173 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
1174 | { | ||
1175 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1176 | "Existing Attestation location is not an Attestation\n"); | ||
1177 | send_ref_error (ash); | ||
1178 | return; | ||
1179 | } | ||
1180 | struct GNUNET_GNSRECORD_Data rd_new[rd_count]; | ||
1181 | for (int i = 0; i<rd_count; i++) | ||
1182 | { | ||
1183 | rd_new[i] = rd[i]; | ||
1184 | } | ||
1185 | rd_new[0].data_size = buf_size; | 1151 | rd_new[0].data_size = buf_size; |
1186 | rd_new[0].data = buf; | 1152 | rd_new[0].data = buf; |
1187 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR; | 1153 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION; |
1188 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1154 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1189 | rd_new[0].expiration_time = ash->exp.rel_value_us; | 1155 | rd_new[0].expiration_time = ash->exp.rel_value_us; |
1190 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | 1156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); |
1191 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1157 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
1192 | &ash->identity, | 1158 | &ash->identity, |
1193 | label, | 1159 | label, |
1194 | rd_count, | 1160 | 1, |
1195 | rd_new, | 1161 | rd_new, |
1196 | &attest_store_cont, | 1162 | &attest_store_cont, |
1197 | ash); | 1163 | ash); |
1198 | GNUNET_free (buf); | 1164 | GNUNET_free (buf); |
1165 | return; | ||
1199 | } | 1166 | } |
1200 | 1167 | ||
1168 | |||
1201 | /** | 1169 | /** |
1202 | * Add a new attestation | 1170 | * Add a new attestation |
1203 | * | 1171 | * |
@@ -1210,11 +1178,10 @@ attest_store_task (void *cls) | |||
1210 | char *label; | 1178 | char *label; |
1211 | 1179 | ||
1212 | // Give the ash a new id if unset | 1180 | // Give the ash a new id if unset |
1213 | if (0 == ash->attest->id) | 1181 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->attest->id)) |
1214 | ash->attest->id | 1182 | GNUNET_RECLAIM_id_generate (&ash->attest->id); |
1215 | = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | ||
1216 | label = GNUNET_STRINGS_data_to_string_alloc (&ash->attest->id, | 1183 | label = GNUNET_STRINGS_data_to_string_alloc (&ash->attest->id, |
1217 | sizeof(uint64_t)); | 1184 | sizeof (ash->attest->id)); |
1218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1185 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1219 | "Looking up existing data under label %s\n", label); | 1186 | "Looking up existing data under label %s\n", label); |
1220 | // Test for the content of the existing ID | 1187 | // Test for the content of the existing ID |
@@ -1228,6 +1195,7 @@ attest_store_task (void *cls) | |||
1228 | GNUNET_free (label); | 1195 | GNUNET_free (label); |
1229 | } | 1196 | } |
1230 | 1197 | ||
1198 | |||
1231 | /** | 1199 | /** |
1232 | * Check an attestation store message | 1200 | * Check an attestation store message |
1233 | * | 1201 | * |
@@ -1249,6 +1217,7 @@ check_attestation_store_message (void *cls, | |||
1249 | return GNUNET_OK; | 1217 | return GNUNET_OK; |
1250 | } | 1218 | } |
1251 | 1219 | ||
1220 | |||
1252 | /** | 1221 | /** |
1253 | * Handle an attestation store message | 1222 | * Handle an attestation store message |
1254 | * | 1223 | * |
@@ -1268,7 +1237,7 @@ handle_attestation_store_message (void *cls, | |||
1268 | data_len = ntohs (sam->attr_len); | 1237 | data_len = ntohs (sam->attr_len); |
1269 | 1238 | ||
1270 | ash = GNUNET_new (struct AttributeStoreHandle); | 1239 | ash = GNUNET_new (struct AttributeStoreHandle); |
1271 | ash->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &sam[1], | 1240 | ash->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &sam[1], |
1272 | data_len); | 1241 | data_len); |
1273 | 1242 | ||
1274 | ash->r_id = ntohl (sam->id); | 1243 | ash->r_id = ntohl (sam->id); |
@@ -1282,246 +1251,8 @@ handle_attestation_store_message (void *cls, | |||
1282 | GNUNET_SCHEDULER_add_now (&attest_store_task, ash); | 1251 | GNUNET_SCHEDULER_add_now (&attest_store_task, ash); |
1283 | } | 1252 | } |
1284 | 1253 | ||
1285 | /** | ||
1286 | * Error looking up potential reference value. Abort. | ||
1287 | * | ||
1288 | * @param cls our attribute store handle | ||
1289 | */ | ||
1290 | static void | ||
1291 | ref_error (void *cls) | ||
1292 | { | ||
1293 | struct AttributeStoreHandle *ash = cls; | ||
1294 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1295 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1296 | cleanup_as_handle (ash); | ||
1297 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1298 | return; | ||
1299 | } | ||
1300 | |||
1301 | /** | ||
1302 | * Error looking up potential reference value. Abort. | ||
1303 | * | ||
1304 | * @param cls our attribute delete handle | ||
1305 | */ | ||
1306 | static void | ||
1307 | ref_del_error (void *cls) | ||
1308 | { | ||
1309 | struct AttributeDeleteHandle *adh = cls; | ||
1310 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1311 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1312 | cleanup_adh (adh); | ||
1313 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1314 | return; | ||
1315 | } | ||
1316 | /** | ||
1317 | * Reference store result handler | ||
1318 | * | ||
1319 | * @param cls our attribute store handle | ||
1320 | * @param success GNUNET_OK if successful | ||
1321 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1322 | */ | ||
1323 | static void | ||
1324 | reference_store_cont (void *cls, int32_t success, const char *emsg) | ||
1325 | { | ||
1326 | struct AttributeStoreHandle *ash = cls; | ||
1327 | struct GNUNET_MQ_Envelope *env; | ||
1328 | struct SuccessResultMessage *acr_msg; | ||
1329 | |||
1330 | ash->ns_qe = NULL; | ||
1331 | GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, | ||
1332 | ash->client->store_op_tail, | ||
1333 | ash); | ||
1334 | |||
1335 | if (GNUNET_SYSERR == success) | ||
1336 | { | ||
1337 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1338 | "Failed to store reference %s\n", | ||
1339 | emsg); | ||
1340 | cleanup_as_handle (ash); | ||
1341 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1342 | return; | ||
1343 | } | ||
1344 | |||
1345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); | ||
1346 | env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); | ||
1347 | acr_msg->id = htonl (ash->r_id); | ||
1348 | acr_msg->op_result = htonl (GNUNET_OK); | ||
1349 | GNUNET_MQ_send (ash->client->mq, env); | ||
1350 | cleanup_as_handle (ash); | ||
1351 | } | ||
1352 | |||
1353 | 1254 | ||
1354 | /** | 1255 | /** |
1355 | * Check for existing record before storing reference | ||
1356 | * | ||
1357 | * @param cls our attribute store handle | ||
1358 | * @param zone zone we are iterating | ||
1359 | * @param label label of the records | ||
1360 | * @param rd_count record count | ||
1361 | * @param rd records | ||
1362 | */ | ||
1363 | static void | ||
1364 | ref_add_cb (void *cls, | ||
1365 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
1366 | const char *label, | ||
1367 | unsigned int rd_count, | ||
1368 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1369 | { | ||
1370 | struct AttributeStoreHandle *ash = cls; | ||
1371 | char *buf; | ||
1372 | size_t buf_size; | ||
1373 | buf_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (ash->reference); | ||
1374 | buf = GNUNET_malloc (buf_size); | ||
1375 | GNUNET_RECLAIM_ATTESTATION_REF_serialize (ash->reference, buf); | ||
1376 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; | ||
1377 | char *data_tmp; | ||
1378 | if (0 == rd_count ) | ||
1379 | { | ||
1380 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1381 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1382 | send_ref_error (ash); | ||
1383 | return; | ||
1384 | } | ||
1385 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
1386 | { | ||
1387 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1388 | "Intended Reference storage location is not an attestation\n"); | ||
1389 | send_ref_error (ash); | ||
1390 | return; | ||
1391 | } | ||
1392 | struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1]; | ||
1393 | int i; | ||
1394 | for (i = 0; i<rd_count; i++) | ||
1395 | { | ||
1396 | data_tmp = GNUNET_malloc (rd[i].data_size); | ||
1397 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
1398 | ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, htons ( | ||
1399 | rd[i].data_size)); | ||
1400 | rd_new[i] = rd[i]; | ||
1401 | if ((strcmp (ash->reference->name,ref->name) == 0)&& | ||
1402 | (strcmp (ash->reference->reference_value,ref->reference_value)==0) ) | ||
1403 | { | ||
1404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1405 | "Reference already stored\n"); | ||
1406 | reference_store_cont (ash,GNUNET_OK, NULL); | ||
1407 | return; | ||
1408 | } | ||
1409 | } | ||
1410 | rd_new[rd_count].data_size = buf_size; | ||
1411 | rd_new[rd_count].data = buf; | ||
1412 | rd_new[rd_count].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE; | ||
1413 | rd_new[rd_count].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1414 | rd_new[rd_count].expiration_time = ash->exp.rel_value_us; | ||
1415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | ||
1416 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1417 | &ash->identity, | ||
1418 | label, | ||
1419 | rd_count + 1, | ||
1420 | rd_new, | ||
1421 | &reference_store_cont, | ||
1422 | ash); | ||
1423 | GNUNET_free (buf); | ||
1424 | } | ||
1425 | |||
1426 | /** | ||
1427 | * Add a new reference | ||
1428 | * | ||
1429 | * @param cls the AttributeStoreHandle | ||
1430 | */ | ||
1431 | static void | ||
1432 | reference_store_task (void *cls) | ||
1433 | { | ||
1434 | struct AttributeStoreHandle *ash = cls; | ||
1435 | char *label; | ||
1436 | |||
1437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing reference\n"); | ||
1438 | |||
1439 | // Give the ash a new id if unset | ||
1440 | if (0 == ash->reference->id) | ||
1441 | { | ||
1442 | if (0 == ash->reference->id_attest) | ||
1443 | { | ||
1444 | ash->reference->id = GNUNET_CRYPTO_random_u64 ( | ||
1445 | GNUNET_CRYPTO_QUALITY_STRONG, | ||
1446 | UINT64_MAX); | ||
1447 | } | ||
1448 | else | ||
1449 | { | ||
1450 | ash->reference->id = ash->reference->id_attest; | ||
1451 | } | ||
1452 | } | ||
1453 | |||
1454 | label = GNUNET_STRINGS_data_to_string_alloc (&ash->reference->id, | ||
1455 | sizeof(uint64_t)); | ||
1456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1457 | "Looking up existing data under label %s\n", label); | ||
1458 | // Test for the content of the existing ID | ||
1459 | |||
1460 | ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | ||
1461 | &ash->identity, | ||
1462 | label, | ||
1463 | &ref_error, | ||
1464 | ash, | ||
1465 | &ref_add_cb, | ||
1466 | ash); | ||
1467 | GNUNET_free (label); | ||
1468 | } | ||
1469 | |||
1470 | /** | ||
1471 | * Check an attestation reference store message | ||
1472 | * | ||
1473 | * @param cls unused | ||
1474 | * @param sam the message to check | ||
1475 | */ | ||
1476 | static int | ||
1477 | check_reference_store_message (void *cls, | ||
1478 | const struct | ||
1479 | AttributeStoreMessage *sam) | ||
1480 | { | ||
1481 | uint16_t size; | ||
1482 | |||
1483 | size = ntohs (sam->header.size); | ||
1484 | if (size <= sizeof(struct AttributeStoreMessage)) | ||
1485 | { | ||
1486 | GNUNET_break (0); | ||
1487 | return GNUNET_SYSERR; | ||
1488 | } | ||
1489 | return GNUNET_OK; | ||
1490 | } | ||
1491 | |||
1492 | |||
1493 | /** | ||
1494 | * Handle an attestation reference store message | ||
1495 | * | ||
1496 | * @param cls our client | ||
1497 | * @param sam the message to handle | ||
1498 | */ | ||
1499 | static void | ||
1500 | handle_reference_store_message (void *cls, | ||
1501 | const struct AttributeStoreMessage *sam) | ||
1502 | { | ||
1503 | struct AttributeStoreHandle *ash; | ||
1504 | struct IdpClient *idp = cls; | ||
1505 | size_t data_len; | ||
1506 | |||
1507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_STORE message\n"); | ||
1508 | |||
1509 | data_len = ntohs (sam->attr_len); | ||
1510 | ash = GNUNET_new (struct AttributeStoreHandle); | ||
1511 | ash->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &sam[1], | ||
1512 | data_len); | ||
1513 | ash->r_id = ntohl (sam->id); | ||
1514 | ash->identity = sam->identity; | ||
1515 | ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); | ||
1516 | GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey); | ||
1517 | |||
1518 | |||
1519 | GNUNET_SERVICE_client_continue (idp->client); | ||
1520 | ash->client = idp; | ||
1521 | GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash); | ||
1522 | GNUNET_SCHEDULER_add_now (&reference_store_task, ash); | ||
1523 | } | ||
1524 | /** | ||
1525 | * Send a deletion success response | 1256 | * Send a deletion success response |
1526 | * | 1257 | * |
1527 | * @param adh our attribute deletion handle | 1258 | * @param adh our attribute deletion handle |
@@ -1567,19 +1298,18 @@ ticket_iter (void *cls, | |||
1567 | int has_changed = GNUNET_NO; | 1298 | int has_changed = GNUNET_NO; |
1568 | for (int i = 0; i < rd_count; i++) | 1299 | for (int i = 0; i < rd_count; i++) |
1569 | { | 1300 | { |
1570 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 1301 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) |
1571 | continue; | 1302 | continue; |
1572 | if (adh->claim != NULL) | 1303 | if (adh->claim != NULL) |
1573 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) | 1304 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1305 | &adh->claim->id)) | ||
1574 | continue; | 1306 | continue; |
1575 | if (adh->attest != NULL) | 1307 | if (adh->attest != NULL) |
1576 | if (0 != memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t))) | 1308 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1577 | continue; | 1309 | &adh->attest->id)) |
1578 | if (adh->reference != NULL) | ||
1579 | if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t))) | ||
1580 | continue; | 1310 | continue; |
1581 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1311 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1582 | "Attribute or Attestation/Reference to delete found (%s)\n", | 1312 | "Attribute or Attestation to delete found (%s)\n", |
1583 | adh->label); | 1313 | adh->label); |
1584 | has_changed = GNUNET_YES; | 1314 | has_changed = GNUNET_YES; |
1585 | break; | 1315 | break; |
@@ -1670,16 +1400,14 @@ update_tickets (void *cls) | |||
1670 | for (int i = 0; i < le->rd_count; i++) | 1400 | for (int i = 0; i < le->rd_count; i++) |
1671 | { | 1401 | { |
1672 | if (adh->claim != NULL) | 1402 | if (adh->claim != NULL) |
1673 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) | 1403 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) |
1674 | && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) | 1404 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1405 | &adh->claim->id))) | ||
1675 | continue; | 1406 | continue; |
1676 | if (adh->attest != NULL) | 1407 | if (adh->attest != NULL) |
1677 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) | 1408 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) |
1678 | && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))) | 1409 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1679 | continue; | 1410 | &adh->attest->id))) |
1680 | if (adh->reference != NULL) | ||
1681 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) | ||
1682 | && (0 == memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t)))) | ||
1683 | continue; | 1411 | continue; |
1684 | rd_new[j] = rd[i]; | 1412 | rd_new[j] = rd[i]; |
1685 | j++; | 1413 | j++; |
@@ -1820,15 +1548,15 @@ handle_attribute_delete_message (void *cls, | |||
1820 | data_len = ntohs (dam->attr_len); | 1548 | data_len = ntohs (dam->attr_len); |
1821 | 1549 | ||
1822 | adh = GNUNET_new (struct AttributeDeleteHandle); | 1550 | adh = GNUNET_new (struct AttributeDeleteHandle); |
1823 | adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1], | 1551 | adh->claim = GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1], |
1824 | data_len); | 1552 | data_len); |
1825 | adh->reference = NULL; | ||
1826 | adh->attest = NULL; | 1553 | adh->attest = NULL; |
1827 | 1554 | ||
1828 | adh->r_id = ntohl (dam->id); | 1555 | adh->r_id = ntohl (dam->id); |
1829 | adh->identity = dam->identity; | 1556 | adh->identity = dam->identity; |
1830 | adh->label | 1557 | adh->label |
1831 | = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof(uint64_t)); | 1558 | = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, |
1559 | sizeof(adh->claim->id)); | ||
1832 | GNUNET_SERVICE_client_continue (idp->client); | 1560 | GNUNET_SERVICE_client_continue (idp->client); |
1833 | adh->client = idp; | 1561 | adh->client = idp; |
1834 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | 1562 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); |
@@ -1841,6 +1569,7 @@ handle_attribute_delete_message (void *cls, | |||
1841 | adh); | 1569 | adh); |
1842 | } | 1570 | } |
1843 | 1571 | ||
1572 | |||
1844 | /** | 1573 | /** |
1845 | * Attestation deleted callback | 1574 | * Attestation deleted callback |
1846 | * | 1575 | * |
@@ -1867,6 +1596,7 @@ attest_delete_cont (void *cls, int32_t success, const char *emsg) | |||
1867 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | 1596 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); |
1868 | } | 1597 | } |
1869 | 1598 | ||
1599 | |||
1870 | /** | 1600 | /** |
1871 | * Check attestation delete message format | 1601 | * Check attestation delete message format |
1872 | * | 1602 | * |
@@ -1908,15 +1638,15 @@ handle_attestation_delete_message (void *cls, | |||
1908 | data_len = ntohs (dam->attr_len); | 1638 | data_len = ntohs (dam->attr_len); |
1909 | 1639 | ||
1910 | adh = GNUNET_new (struct AttributeDeleteHandle); | 1640 | adh = GNUNET_new (struct AttributeDeleteHandle); |
1911 | adh->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &dam[1], | 1641 | adh->attest = GNUNET_RECLAIM_attestation_deserialize ((char *) &dam[1], |
1912 | data_len); | 1642 | data_len); |
1913 | adh->reference = NULL; | ||
1914 | adh->claim = NULL; | 1643 | adh->claim = NULL; |
1915 | 1644 | ||
1916 | adh->r_id = ntohl (dam->id); | 1645 | adh->r_id = ntohl (dam->id); |
1917 | adh->identity = dam->identity; | 1646 | adh->identity = dam->identity; |
1918 | adh->label | 1647 | adh->label |
1919 | = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, sizeof(uint64_t)); | 1648 | = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, |
1649 | sizeof(adh->attest->id)); | ||
1920 | GNUNET_SERVICE_client_continue (idp->client); | 1650 | GNUNET_SERVICE_client_continue (idp->client); |
1921 | adh->client = idp; | 1651 | adh->client = idp; |
1922 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | 1652 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); |
@@ -1930,214 +1660,236 @@ handle_attestation_delete_message (void *cls, | |||
1930 | } | 1660 | } |
1931 | 1661 | ||
1932 | 1662 | ||
1663 | /************************************************* | ||
1664 | * Attrubute iteration | ||
1665 | *************************************************/ | ||
1666 | |||
1933 | 1667 | ||
1934 | /** | 1668 | /** |
1935 | * Reference deleted callback | 1669 | * Done iterating over attributes |
1936 | * | 1670 | * |
1937 | * @param cls our handle | 1671 | * @param cls our iterator handle |
1938 | * @param success success status | 1672 | */ |
1939 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1940 | */ | ||
1941 | static void | 1673 | static void |
1942 | reference_delete_cont (void *cls, int32_t success, const char *emsg) | 1674 | attr_iter_finished (void *cls) |
1943 | { | 1675 | { |
1944 | struct AttributeDeleteHandle *adh = cls; | 1676 | struct Iterator *ai = cls; |
1677 | struct GNUNET_MQ_Envelope *env; | ||
1678 | struct AttributeResultMessage *arm; | ||
1945 | 1679 | ||
1946 | adh->ns_qe = NULL; | 1680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); |
1947 | if (GNUNET_SYSERR == success) | 1681 | env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); |
1948 | { | 1682 | arm->id = htonl (ai->request_id); |
1949 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1683 | arm->attr_len = htons (0); |
1950 | "Error deleting reference %s\n", | 1684 | GNUNET_MQ_send (ai->client->mq, env); |
1951 | adh->label); | 1685 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, |
1952 | send_delete_response (adh, GNUNET_SYSERR); | 1686 | ai->client->attr_iter_tail, |
1953 | cleanup_adh (adh); | 1687 | ai); |
1954 | return; | 1688 | GNUNET_free (ai); |
1955 | } | ||
1956 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); | ||
1957 | //GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | ||
1958 | send_delete_response (adh, GNUNET_OK); | ||
1959 | cleanup_adh (adh); | ||
1960 | return; | ||
1961 | } | 1689 | } |
1962 | 1690 | ||
1691 | |||
1692 | /** | ||
1693 | * Error iterating over attributes. Abort. | ||
1694 | * | ||
1695 | * @param cls our attribute iteration handle | ||
1696 | */ | ||
1963 | static void | 1697 | static void |
1964 | ref_del_cb (void *cls, | 1698 | attr_iter_error (void *cls) |
1965 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
1966 | const char *label, | ||
1967 | unsigned int rd_count, | ||
1968 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1969 | { | 1699 | { |
1700 | struct Iterator *ai = cls; | ||
1970 | 1701 | ||
1971 | struct AttributeDeleteHandle *adh = cls; | 1702 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); |
1703 | attr_iter_finished (ai); | ||
1704 | } | ||
1705 | |||
1706 | |||
1707 | /** | ||
1708 | * Got record. Return if it is an attribute or attestation. | ||
1709 | * | ||
1710 | * @param cls our attribute iterator | ||
1711 | * @param zone zone we are iterating | ||
1712 | * @param label label of the records | ||
1713 | * @param rd_count record count | ||
1714 | * @param rd records | ||
1715 | */ | ||
1716 | static void | ||
1717 | attr_iter_cb (void *cls, | ||
1718 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
1719 | const char *label, | ||
1720 | unsigned int rd_count, | ||
1721 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1722 | { | ||
1723 | struct Iterator *ai = cls; | ||
1724 | struct GNUNET_MQ_Envelope *env; | ||
1972 | char *data_tmp; | 1725 | char *data_tmp; |
1973 | struct GNUNET_GNSRECORD_Data rd_new[rd_count - 1]; | ||
1974 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; | ||
1975 | size_t attr_len; | ||
1976 | 1726 | ||
1977 | if (0 == rd_count ) | 1727 | if ((rd_count != 1) || |
1978 | { | 1728 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd->record_type)) |
1979 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1980 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1981 | cleanup_adh (adh); | ||
1982 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1983 | return; | ||
1984 | } | ||
1985 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
1986 | { | 1729 | { |
1987 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1730 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); |
1988 | "Intended Reference location is not an attestation\n"); | ||
1989 | cleanup_adh (adh); | ||
1990 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1991 | return; | 1731 | return; |
1992 | } | 1732 | } |
1993 | rd_new[0] = rd[0]; | 1733 | struct AttributeResultMessage *arm; |
1994 | int i; | 1734 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", |
1995 | int j = 1; | 1735 | label); |
1996 | for (i = 1; i<rd_count; i++) | 1736 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1997 | { | 1737 | "Sending ATTRIBUTE_RESULT message\n"); |
1998 | data_tmp = GNUNET_malloc (rd[i].data_size); | 1738 | env = GNUNET_MQ_msg_extra (arm, |
1999 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | 1739 | rd->data_size, |
2000 | attr_len = htons (rd[i].data_size); | 1740 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); |
2001 | ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, attr_len); | 1741 | arm->id = htonl (ai->request_id); |
2002 | if (NULL == ref ) | 1742 | arm->attr_len = htons (rd->data_size); |
2003 | { | 1743 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); |
2004 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1744 | data_tmp = (char *) &arm[1]; |
2005 | "Unable to parse attestation reference from %s\n", | 1745 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
2006 | data_tmp); | 1746 | GNUNET_MQ_send (ai->client->mq, env); |
2007 | rd_new[j] = rd[i]; | ||
2008 | j += 1; | ||
2009 | continue; | ||
2010 | } | ||
2011 | if ((strcmp (adh->reference->name,ref->name) == 0)&& | ||
2012 | (strcmp (adh->reference->reference_value,ref->reference_value)==0) ) | ||
2013 | { | ||
2014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2015 | "Found reference to delete.\n"); | ||
2016 | } | ||
2017 | else | ||
2018 | { | ||
2019 | rd_new[j] = rd[i]; | ||
2020 | j += 1; | ||
2021 | } | ||
2022 | GNUNET_free (data_tmp); | ||
2023 | } | ||
2024 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
2025 | &adh->identity, | ||
2026 | label, | ||
2027 | j, | ||
2028 | rd_new, | ||
2029 | &reference_delete_cont, | ||
2030 | adh); | ||
2031 | } | 1747 | } |
2032 | 1748 | ||
1749 | |||
2033 | /** | 1750 | /** |
2034 | * Check an attestation reference delete message | 1751 | * Iterate over zone to get attributes |
2035 | * | 1752 | * |
2036 | * @param cls unused | 1753 | * @param cls our client |
2037 | * @param sam the message to check | 1754 | * @param ais_msg the iteration message to start |
2038 | */ | 1755 | */ |
2039 | static int | 1756 | static void |
2040 | check_reference_delete_message (void *cls, | 1757 | handle_iteration_start (void *cls, |
2041 | const struct AttributeDeleteMessage *dam) | 1758 | const struct AttributeIterationStartMessage *ais_msg) |
2042 | { | 1759 | { |
2043 | uint16_t size; | 1760 | struct IdpClient *idp = cls; |
1761 | struct Iterator *ai; | ||
2044 | 1762 | ||
2045 | size = ntohs (dam->header.size); | 1763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2046 | if (size <= sizeof(struct AttributeDeleteMessage)) | 1764 | "Received ATTRIBUTE_ITERATION_START message\n"); |
1765 | ai = GNUNET_new (struct Iterator); | ||
1766 | ai->request_id = ntohl (ais_msg->id); | ||
1767 | ai->client = idp; | ||
1768 | ai->identity = ais_msg->identity; | ||
1769 | |||
1770 | GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai); | ||
1771 | ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, | ||
1772 | &ai->identity, | ||
1773 | &attr_iter_error, | ||
1774 | ai, | ||
1775 | &attr_iter_cb, | ||
1776 | ai, | ||
1777 | &attr_iter_finished, | ||
1778 | ai); | ||
1779 | GNUNET_SERVICE_client_continue (idp->client); | ||
1780 | } | ||
1781 | |||
1782 | |||
1783 | /** | ||
1784 | * Handle iteration stop message from client | ||
1785 | * | ||
1786 | * @param cls the client | ||
1787 | * @param ais_msg the stop message | ||
1788 | */ | ||
1789 | static void | ||
1790 | handle_iteration_stop (void *cls, | ||
1791 | const struct AttributeIterationStopMessage *ais_msg) | ||
1792 | { | ||
1793 | struct IdpClient *idp = cls; | ||
1794 | struct Iterator *ai; | ||
1795 | uint32_t rid; | ||
1796 | |||
1797 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1798 | "Received `%s' message\n", | ||
1799 | "ATTRIBUTE_ITERATION_STOP"); | ||
1800 | rid = ntohl (ais_msg->id); | ||
1801 | for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) | ||
1802 | if (ai->request_id == rid) | ||
1803 | break; | ||
1804 | if (NULL == ai) | ||
2047 | { | 1805 | { |
2048 | GNUNET_break (0); | 1806 | GNUNET_break (0); |
2049 | return GNUNET_SYSERR; | 1807 | GNUNET_SERVICE_client_drop (idp->client); |
1808 | return; | ||
2050 | } | 1809 | } |
2051 | return GNUNET_OK; | 1810 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); |
1811 | GNUNET_free (ai); | ||
1812 | GNUNET_SERVICE_client_continue (idp->client); | ||
2052 | } | 1813 | } |
2053 | 1814 | ||
1815 | |||
2054 | /** | 1816 | /** |
2055 | * Handle reference deletion | 1817 | * Client requests next attribute from iterator |
2056 | * | 1818 | * |
2057 | * @param cls our client | 1819 | * @param cls the client |
2058 | * @param dam deletion message | 1820 | * @param ais_msg the message |
2059 | */ | 1821 | */ |
2060 | static void | 1822 | static void |
2061 | handle_reference_delete_message (void *cls, | 1823 | handle_iteration_next (void *cls, |
2062 | const struct AttributeDeleteMessage *dam) | 1824 | const struct AttributeIterationNextMessage *ais_msg) |
2063 | { | 1825 | { |
2064 | struct AttributeDeleteHandle *adh; | ||
2065 | struct IdpClient *idp = cls; | 1826 | struct IdpClient *idp = cls; |
2066 | size_t data_len; | 1827 | struct Iterator *ai; |
2067 | 1828 | uint32_t rid; | |
2068 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_DELETE message\n"); | ||
2069 | data_len = ntohs (dam->attr_len); | ||
2070 | adh = GNUNET_new (struct AttributeDeleteHandle); | ||
2071 | adh->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &dam[1], | ||
2072 | data_len); | ||
2073 | adh->attest = NULL; | ||
2074 | adh->claim = NULL; | ||
2075 | 1829 | ||
2076 | adh->r_id = ntohl (dam->id); | 1830 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2077 | adh->identity = dam->identity; | 1831 | "Received ATTRIBUTE_ITERATION_NEXT message\n"); |
2078 | adh->label | 1832 | rid = ntohl (ais_msg->id); |
2079 | = GNUNET_STRINGS_data_to_string_alloc (&adh->reference->id, | 1833 | for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) |
2080 | sizeof(uint64_t)); | 1834 | if (ai->request_id == rid) |
1835 | break; | ||
1836 | if (NULL == ai) | ||
1837 | { | ||
1838 | GNUNET_break (0); | ||
1839 | GNUNET_SERVICE_client_drop (idp->client); | ||
1840 | return; | ||
1841 | } | ||
1842 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | ||
2081 | GNUNET_SERVICE_client_continue (idp->client); | 1843 | GNUNET_SERVICE_client_continue (idp->client); |
2082 | adh->client = idp; | ||
2083 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | ||
2084 | adh->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | ||
2085 | &adh->identity, | ||
2086 | adh->label, | ||
2087 | &ref_del_error, | ||
2088 | adh, | ||
2089 | &ref_del_cb, | ||
2090 | adh); | ||
2091 | } | 1844 | } |
2092 | 1845 | ||
2093 | 1846 | ||
2094 | |||
2095 | /************************************************* | 1847 | /************************************************* |
2096 | * Attrubute iteration | 1848 | * Attestation iteration |
2097 | *************************************************/ | 1849 | *************************************************/ |
2098 | 1850 | ||
2099 | 1851 | ||
2100 | /** | 1852 | /** |
2101 | * Done iterating over attributes | 1853 | * Done iterating over attestations |
2102 | * | 1854 | * |
2103 | * @param cls our iterator handle | 1855 | * @param cls our iterator handle |
2104 | */ | 1856 | */ |
2105 | static void | 1857 | static void |
2106 | attr_iter_finished (void *cls) | 1858 | attest_iter_finished (void *cls) |
2107 | { | 1859 | { |
2108 | struct AttributeIterator *ai = cls; | 1860 | struct Iterator *ai = cls; |
2109 | struct GNUNET_MQ_Envelope *env; | 1861 | struct GNUNET_MQ_Envelope *env; |
2110 | struct AttributeResultMessage *arm; | 1862 | struct AttestationResultMessage *arm; |
2111 | 1863 | ||
2112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); | 1864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTESTATION_RESULT message\n"); |
2113 | env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); | 1865 | env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); |
2114 | arm->id = htonl (ai->request_id); | 1866 | arm->id = htonl (ai->request_id); |
2115 | arm->attr_len = htons (0); | 1867 | arm->attestation_len = htons (0); |
2116 | GNUNET_MQ_send (ai->client->mq, env); | 1868 | GNUNET_MQ_send (ai->client->mq, env); |
2117 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, | 1869 | GNUNET_CONTAINER_DLL_remove (ai->client->attest_iter_head, |
2118 | ai->client->attr_iter_tail, | 1870 | ai->client->attest_iter_tail, |
2119 | ai); | 1871 | ai); |
2120 | GNUNET_free (ai); | 1872 | GNUNET_free (ai); |
2121 | } | 1873 | } |
2122 | 1874 | ||
2123 | 1875 | ||
2124 | /** | 1876 | /** |
2125 | * Error iterating over attributes. Abort. | 1877 | * Error iterating over attestations. Abort. |
2126 | * | 1878 | * |
2127 | * @param cls our attribute iteration handle | 1879 | * @param cls our attribute iteration handle |
2128 | */ | 1880 | */ |
2129 | static void | 1881 | static void |
2130 | attr_iter_error (void *cls) | 1882 | attest_iter_error (void *cls) |
2131 | { | 1883 | { |
2132 | struct AttributeIterator *ai = cls; | 1884 | struct Iterator *ai = cls; |
2133 | 1885 | ||
2134 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); | 1886 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attestations\n"); |
2135 | attr_iter_finished (ai); | 1887 | attest_iter_finished (ai); |
2136 | } | 1888 | } |
2137 | 1889 | ||
2138 | 1890 | ||
2139 | /** | 1891 | /** |
2140 | * Got record. Return if it is an attribute or attestation/reference. | 1892 | * Got record. Return attestation. |
2141 | * | 1893 | * |
2142 | * @param cls our attribute iterator | 1894 | * @param cls our attribute iterator |
2143 | * @param zone zone we are iterating | 1895 | * @param zone zone we are iterating |
@@ -2146,110 +1898,40 @@ attr_iter_error (void *cls) | |||
2146 | * @param rd records | 1898 | * @param rd records |
2147 | */ | 1899 | */ |
2148 | static void | 1900 | static void |
2149 | attr_iter_cb (void *cls, | 1901 | attest_iter_cb (void *cls, |
2150 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1902 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
2151 | const char *label, | 1903 | const char *label, |
2152 | unsigned int rd_count, | 1904 | unsigned int rd_count, |
2153 | const struct GNUNET_GNSRECORD_Data *rd) | 1905 | const struct GNUNET_GNSRECORD_Data *rd) |
2154 | { | 1906 | { |
2155 | struct AttributeIterator *ai = cls; | 1907 | struct Iterator *ai = cls; |
2156 | struct GNUNET_MQ_Envelope *env; | 1908 | struct GNUNET_MQ_Envelope *env; |
1909 | struct AttestationResultMessage *arm; | ||
2157 | char *data_tmp; | 1910 | char *data_tmp; |
2158 | 1911 | ||
2159 | if (rd_count == 0) | 1912 | if ((rd_count != 1) || |
1913 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd->record_type)) | ||
2160 | { | 1914 | { |
2161 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | 1915 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); |
2162 | return; | 1916 | return; |
2163 | } | 1917 | } |
2164 | if (rd_count > 1) | 1918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", |
2165 | { | 1919 | label); |
2166 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[0].record_type) | 1920 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2167 | { | 1921 | "Sending ATTESTATION_RESULT message\n"); |
2168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1922 | env = GNUNET_MQ_msg_extra (arm, |
2169 | "Found Ticket. Ignoring.\n"); | 1923 | rd->data_size, |
2170 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | 1924 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); |
2171 | return; | 1925 | arm->id = htonl (ai->request_id); |
2172 | } | 1926 | arm->attestation_len = htons (rd->data_size); |
2173 | else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | 1927 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); |
2174 | { | 1928 | data_tmp = (char *) &arm[1]; |
2175 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1929 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
2176 | "Non-Attestation record with multiple entries found: %u\n", | ||
2177 | rd[0].record_type); | ||
2178 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | ||
2179 | return; | ||
2180 | } | ||
2181 | } | ||
2182 | 1930 | ||
2183 | for (int i = 0; i<rd_count; i++) | 1931 | GNUNET_MQ_send (ai->client->mq, env); |
2184 | { | ||
2185 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd[i].record_type) && | ||
2186 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) && | ||
2187 | (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE != rd[i].record_type)) | ||
2188 | { | ||
2189 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | ||
2190 | return; | ||
2191 | } | ||
2192 | |||
2193 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type ) | ||
2194 | { | ||
2195 | struct AttributeResultMessage *arm; | ||
2196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", | ||
2197 | label); | ||
2198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2199 | "Sending ATTRIBUTE_RESULT message\n"); | ||
2200 | env = GNUNET_MQ_msg_extra (arm, | ||
2201 | rd[i].data_size, | ||
2202 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); | ||
2203 | arm->id = htonl (ai->request_id); | ||
2204 | arm->attr_len = htons (rd[i].data_size); | ||
2205 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); | ||
2206 | data_tmp = (char *) &arm[1]; | ||
2207 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
2208 | GNUNET_MQ_send (ai->client->mq, env); | ||
2209 | } | ||
2210 | else | ||
2211 | { | ||
2212 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type ) | ||
2213 | { | ||
2214 | struct AttributeResultMessage *arm; | ||
2215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", | ||
2216 | label); | ||
2217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2218 | "Sending ATTESTATION_RESULT message\n"); | ||
2219 | env = GNUNET_MQ_msg_extra (arm, | ||
2220 | rd[i].data_size, | ||
2221 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); | ||
2222 | arm->id = htonl (ai->request_id); | ||
2223 | arm->attr_len = htons (rd[i].data_size); | ||
2224 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); | ||
2225 | data_tmp = (char *) &arm[1]; | ||
2226 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
2227 | GNUNET_MQ_send (ai->client->mq, env); | ||
2228 | } | ||
2229 | else | ||
2230 | { | ||
2231 | struct ReferenceResultMessage *rrm; | ||
2232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n", | ||
2233 | label); | ||
2234 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2235 | "Sending REFERENCE_RESULT message\n"); | ||
2236 | env = GNUNET_MQ_msg_extra (rrm, | ||
2237 | rd[i].data_size + rd[0].data_size, | ||
2238 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT); | ||
2239 | rrm->id = htonl (ai->request_id); | ||
2240 | rrm->attest_len = htons (rd[0].data_size); | ||
2241 | rrm->ref_len = htons (rd[i].data_size); | ||
2242 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity); | ||
2243 | data_tmp = (char *) &rrm[1]; | ||
2244 | GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size); | ||
2245 | data_tmp += rd[0].data_size; | ||
2246 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
2247 | GNUNET_MQ_send (ai->client->mq, env); | ||
2248 | } | ||
2249 | } | ||
2250 | } | ||
2251 | } | 1932 | } |
2252 | 1933 | ||
1934 | |||
2253 | /** | 1935 | /** |
2254 | * Iterate over zone to get attributes | 1936 | * Iterate over zone to get attributes |
2255 | * | 1937 | * |
@@ -2257,27 +1939,29 @@ attr_iter_cb (void *cls, | |||
2257 | * @param ais_msg the iteration message to start | 1939 | * @param ais_msg the iteration message to start |
2258 | */ | 1940 | */ |
2259 | static void | 1941 | static void |
2260 | handle_iteration_start (void *cls, | 1942 | handle_attestation_iteration_start (void *cls, |
2261 | const struct AttributeIterationStartMessage *ais_msg) | 1943 | const struct |
1944 | AttestationIterationStartMessage *ais_msg) | ||
2262 | { | 1945 | { |
2263 | struct IdpClient *idp = cls; | 1946 | struct IdpClient *idp = cls; |
2264 | struct AttributeIterator *ai; | 1947 | struct Iterator *ai; |
2265 | 1948 | ||
2266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1949 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2267 | "Received ATTRIBUTE_ITERATION_START message\n"); | 1950 | "Received ATTESTATION_ITERATION_START message\n"); |
2268 | ai = GNUNET_new (struct AttributeIterator); | 1951 | ai = GNUNET_new (struct Iterator); |
2269 | ai->request_id = ntohl (ais_msg->id); | 1952 | ai->request_id = ntohl (ais_msg->id); |
2270 | ai->client = idp; | 1953 | ai->client = idp; |
2271 | ai->identity = ais_msg->identity; | 1954 | ai->identity = ais_msg->identity; |
2272 | 1955 | ||
2273 | GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai); | 1956 | GNUNET_CONTAINER_DLL_insert (idp->attest_iter_head, idp->attest_iter_tail, |
1957 | ai); | ||
2274 | ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, | 1958 | ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
2275 | &ai->identity, | 1959 | &ai->identity, |
2276 | &attr_iter_error, | 1960 | &attest_iter_error, |
2277 | ai, | 1961 | ai, |
2278 | &attr_iter_cb, | 1962 | &attest_iter_cb, |
2279 | ai, | 1963 | ai, |
2280 | &attr_iter_finished, | 1964 | &attest_iter_finished, |
2281 | ai); | 1965 | ai); |
2282 | GNUNET_SERVICE_client_continue (idp->client); | 1966 | GNUNET_SERVICE_client_continue (idp->client); |
2283 | } | 1967 | } |
@@ -2290,18 +1974,19 @@ handle_iteration_start (void *cls, | |||
2290 | * @param ais_msg the stop message | 1974 | * @param ais_msg the stop message |
2291 | */ | 1975 | */ |
2292 | static void | 1976 | static void |
2293 | handle_iteration_stop (void *cls, | 1977 | handle_attestation_iteration_stop (void *cls, |
2294 | const struct AttributeIterationStopMessage *ais_msg) | 1978 | const struct |
1979 | AttestationIterationStopMessage *ais_msg) | ||
2295 | { | 1980 | { |
2296 | struct IdpClient *idp = cls; | 1981 | struct IdpClient *idp = cls; |
2297 | struct AttributeIterator *ai; | 1982 | struct Iterator *ai; |
2298 | uint32_t rid; | 1983 | uint32_t rid; |
2299 | 1984 | ||
2300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2301 | "Received `%s' message\n", | 1986 | "Received `%s' message\n", |
2302 | "ATTRIBUTE_ITERATION_STOP"); | 1987 | "ATTESTATION_ITERATION_STOP"); |
2303 | rid = ntohl (ais_msg->id); | 1988 | rid = ntohl (ais_msg->id); |
2304 | for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) | 1989 | for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next) |
2305 | if (ai->request_id == rid) | 1990 | if (ai->request_id == rid) |
2306 | break; | 1991 | break; |
2307 | if (NULL == ai) | 1992 | if (NULL == ai) |
@@ -2310,30 +1995,32 @@ handle_iteration_stop (void *cls, | |||
2310 | GNUNET_SERVICE_client_drop (idp->client); | 1995 | GNUNET_SERVICE_client_drop (idp->client); |
2311 | return; | 1996 | return; |
2312 | } | 1997 | } |
2313 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); | 1998 | GNUNET_CONTAINER_DLL_remove (idp->attest_iter_head, idp->attest_iter_tail, |
1999 | ai); | ||
2314 | GNUNET_free (ai); | 2000 | GNUNET_free (ai); |
2315 | GNUNET_SERVICE_client_continue (idp->client); | 2001 | GNUNET_SERVICE_client_continue (idp->client); |
2316 | } | 2002 | } |
2317 | 2003 | ||
2318 | 2004 | ||
2319 | /** | 2005 | /** |
2320 | * Client requests next attribute from iterator | 2006 | * Client requests next attestation from iterator |
2321 | * | 2007 | * |
2322 | * @param cls the client | 2008 | * @param cls the client |
2323 | * @param ais_msg the message | 2009 | * @param ais_msg the message |
2324 | */ | 2010 | */ |
2325 | static void | 2011 | static void |
2326 | handle_iteration_next (void *cls, | 2012 | handle_attestation_iteration_next (void *cls, |
2327 | const struct AttributeIterationNextMessage *ais_msg) | 2013 | const struct |
2014 | AttestationIterationNextMessage *ais_msg) | ||
2328 | { | 2015 | { |
2329 | struct IdpClient *idp = cls; | 2016 | struct IdpClient *idp = cls; |
2330 | struct AttributeIterator *ai; | 2017 | struct Iterator *ai; |
2331 | uint32_t rid; | 2018 | uint32_t rid; |
2332 | 2019 | ||
2333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2020 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2334 | "Received ATTRIBUTE_ITERATION_NEXT message\n"); | 2021 | "Received ATTESTATION_ITERATION_NEXT message\n"); |
2335 | rid = ntohl (ais_msg->id); | 2022 | rid = ntohl (ais_msg->id); |
2336 | for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) | 2023 | for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next) |
2337 | if (ai->request_id == rid) | 2024 | if (ai->request_id == rid) |
2338 | break; | 2025 | break; |
2339 | if (NULL == ai) | 2026 | if (NULL == ai) |
@@ -2587,19 +2274,10 @@ GNUNET_SERVICE_MAIN ( | |||
2587 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, | 2274 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, |
2588 | struct AttributeDeleteMessage, | 2275 | struct AttributeDeleteMessage, |
2589 | NULL), | 2276 | NULL), |
2590 | GNUNET_MQ_hd_var_size (reference_store_message, | 2277 | GNUNET_MQ_hd_fixed_size (iteration_start, |
2591 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE, | 2278 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |
2592 | struct AttributeStoreMessage, | 2279 | struct AttributeIterationStartMessage, |
2593 | NULL), | 2280 | NULL), |
2594 | GNUNET_MQ_hd_var_size (reference_delete_message, | ||
2595 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE, | ||
2596 | struct AttributeDeleteMessage, | ||
2597 | NULL), | ||
2598 | GNUNET_MQ_hd_fixed_size ( | ||
2599 | iteration_start, | ||
2600 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, | ||
2601 | struct AttributeIterationStartMessage, | ||
2602 | NULL), | ||
2603 | GNUNET_MQ_hd_fixed_size (iteration_next, | 2281 | GNUNET_MQ_hd_fixed_size (iteration_next, |
2604 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, | 2282 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, |
2605 | struct AttributeIterationNextMessage, | 2283 | struct AttributeIterationNextMessage, |
@@ -2608,6 +2286,19 @@ GNUNET_SERVICE_MAIN ( | |||
2608 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, | 2286 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, |
2609 | struct AttributeIterationStopMessage, | 2287 | struct AttributeIterationStopMessage, |
2610 | NULL), | 2288 | NULL), |
2289 | GNUNET_MQ_hd_fixed_size (attestation_iteration_start, | ||
2290 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START, | ||
2291 | struct AttestationIterationStartMessage, | ||
2292 | NULL), | ||
2293 | GNUNET_MQ_hd_fixed_size (attestation_iteration_next, | ||
2294 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT, | ||
2295 | struct AttestationIterationNextMessage, | ||
2296 | NULL), | ||
2297 | GNUNET_MQ_hd_fixed_size (attestation_iteration_stop, | ||
2298 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP, | ||
2299 | struct AttestationIterationStopMessage, | ||
2300 | NULL), | ||
2301 | |||
2611 | GNUNET_MQ_hd_var_size (issue_ticket_message, | 2302 | GNUNET_MQ_hd_var_size (issue_ticket_message, |
2612 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, | 2303 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, |
2613 | struct IssueTicketMessage, | 2304 | struct IssueTicketMessage, |