diff options
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 61 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 356 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 126 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.h | 37 | ||||
-rw-r--r-- | src/reclaim/reclaim.h | 54 | ||||
-rw-r--r-- | src/reclaim/reclaim_api.c | 58 |
6 files changed, 550 insertions, 142 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index 1c3b4174d..a9d6f67d2 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -157,6 +157,16 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task; | |||
157 | */ | 157 | */ |
158 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 158 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
159 | 159 | ||
160 | /** | ||
161 | * Claim to delete | ||
162 | */ | ||
163 | static char *attr_delete; | ||
164 | |||
165 | /** | ||
166 | * Claim object to delete | ||
167 | */ | ||
168 | static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete; | ||
169 | |||
160 | static void | 170 | static void |
161 | do_cleanup (void *cls) | 171 | do_cleanup (void *cls) |
162 | { | 172 | { |
@@ -177,6 +187,8 @@ do_cleanup (void *cls) | |||
177 | GNUNET_free (abe_key); | 187 | GNUNET_free (abe_key); |
178 | if (NULL != attr_list) | 188 | if (NULL != attr_list) |
179 | GNUNET_free (attr_list); | 189 | GNUNET_free (attr_list); |
190 | if (NULL != attr_to_delete) | ||
191 | GNUNET_free (attr_to_delete); | ||
180 | } | 192 | } |
181 | 193 | ||
182 | static void | 194 | static void |
@@ -208,6 +220,7 @@ process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | |||
208 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | 220 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
209 | { | 221 | { |
210 | char *value_str; | 222 | char *value_str; |
223 | char *id; | ||
211 | const char *attr_type; | 224 | const char *attr_type; |
212 | 225 | ||
213 | if (NULL == identity) { | 226 | if (NULL == identity) { |
@@ -222,8 +235,10 @@ process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | |||
222 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, | 235 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, |
223 | attr->data_size); | 236 | attr->data_size); |
224 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); | 237 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); |
225 | fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, value_str, | 238 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t)); |
226 | attr_type, attr->version, attr->id); | 239 | fprintf (stdout, "Name: %s; Value: %s (%s); Version %u; ID: %s\n", attr->name, |
240 | value_str, attr_type, attr->version, id); | ||
241 | GNUNET_free (id); | ||
227 | } | 242 | } |
228 | 243 | ||
229 | static void | 244 | static void |
@@ -284,6 +299,19 @@ process_rvk (void *cls, int success, const char *msg) | |||
284 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 299 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
285 | } | 300 | } |
286 | 301 | ||
302 | |||
303 | static void | ||
304 | process_delete (void *cls, int success, const char *msg) | ||
305 | { | ||
306 | reclaim_op = NULL; | ||
307 | if (GNUNET_OK != success) { | ||
308 | fprintf (stderr, "Deletion failed.\n"); | ||
309 | ret = 1; | ||
310 | } | ||
311 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | ||
312 | } | ||
313 | |||
314 | |||
287 | static void | 315 | static void |
288 | iter_finished (void *cls) | 316 | iter_finished (void *cls) |
289 | { | 317 | { |
@@ -315,6 +343,15 @@ iter_finished (void *cls) | |||
315 | &process_rvk, NULL); | 343 | &process_rvk, NULL); |
316 | return; | 344 | return; |
317 | } | 345 | } |
346 | if (attr_delete) { | ||
347 | if (NULL == attr_to_delete) { | ||
348 | fprintf (stdout, "No such attribute ``%s''\n", attr_delete); | ||
349 | return; | ||
350 | } | ||
351 | reclaim_op = GNUNET_RECLAIM_attribute_delete ( | ||
352 | reclaim_handle, pkey, attr_to_delete, &process_delete, NULL); | ||
353 | return; | ||
354 | } | ||
318 | if (attr_name) { | 355 | if (attr_name) { |
319 | if (NULL == type_str) | 356 | if (NULL == type_str) |
320 | type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; | 357 | type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; |
@@ -348,6 +385,8 @@ iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | |||
348 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 385 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
349 | char *attrs_tmp; | 386 | char *attrs_tmp; |
350 | char *attr_str; | 387 | char *attr_str; |
388 | char *label; | ||
389 | char *id; | ||
351 | const char *attr_type; | 390 | const char *attr_type; |
352 | 391 | ||
353 | if ((NULL != attr_name) && (NULL != claim)) { | 392 | if ((NULL != attr_name) && (NULL != claim)) { |
@@ -373,12 +412,22 @@ iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | |||
373 | break; | 412 | break; |
374 | } | 413 | } |
375 | GNUNET_free (attrs_tmp); | 414 | GNUNET_free (attrs_tmp); |
415 | } else if (attr_delete && (NULL == attr_to_delete)) { | ||
416 | label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t)); | ||
417 | if (0 == strcasecmp (attr_delete, label)) { | ||
418 | attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new ( | ||
419 | attr->name, attr->type, attr->data, attr->data_size); | ||
420 | attr_to_delete->id = attr->id; | ||
421 | } | ||
422 | GNUNET_free (label); | ||
376 | } else if (list) { | 423 | } else if (list) { |
377 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, | 424 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, |
378 | attr->data_size); | 425 | attr->data_size); |
379 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); | 426 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); |
380 | fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, attr_str, | 427 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t)); |
381 | attr_type, attr->version, attr->id); | 428 | fprintf (stdout, "Name: %s; Value: %s (%s); Version %u; ID: %s\n", |
429 | attr->name, attr_str, attr_type, attr->version, id); | ||
430 | GNUNET_free (id); | ||
382 | } | 431 | } |
383 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); | 432 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); |
384 | } | 433 | } |
@@ -474,7 +523,9 @@ main (int argc, char *const argv[]) | |||
474 | GNUNET_GETOPT_option_string ('a', "add", "NAME", | 523 | GNUNET_GETOPT_option_string ('a', "add", "NAME", |
475 | gettext_noop ("Add an attribute NAME"), | 524 | gettext_noop ("Add an attribute NAME"), |
476 | &attr_name), | 525 | &attr_name), |
477 | 526 | GNUNET_GETOPT_option_string ('d', "delete", "ID", | |
527 | gettext_noop ("Add an attribute with ID"), | ||
528 | &attr_delete), | ||
478 | GNUNET_GETOPT_option_string ('V', "value", "VALUE", | 529 | GNUNET_GETOPT_option_string ('V', "value", "VALUE", |
479 | gettext_noop ("The attribute VALUE"), | 530 | gettext_noop ("The attribute VALUE"), |
480 | &attr_value), | 531 | &attr_value), |
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 2bb4f5a74..5deb482e9 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "gnunet_namestore_service.h" | 34 | #include "gnunet_namestore_service.h" |
35 | #include "gnunet_protocols.h" | 35 | #include "gnunet_protocols.h" |
36 | #include "gnunet_reclaim_attribute_lib.h" | 36 | #include "gnunet_reclaim_attribute_lib.h" |
37 | #include "gnunet_reclaim_plugin.h" | 37 | #include "gnunet_reclaim_service.h" |
38 | #include "gnunet_signatures.h" | 38 | #include "gnunet_signatures.h" |
39 | #include "reclaim.h" | 39 | #include "reclaim.h" |
40 | 40 | ||
@@ -64,16 +64,6 @@ | |||
64 | static struct GNUNET_IDENTITY_Handle *identity_handle; | 64 | static struct GNUNET_IDENTITY_Handle *identity_handle; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Database handle | ||
68 | */ | ||
69 | static struct GNUNET_RECLAIM_PluginFunctions *TKT_database; | ||
70 | |||
71 | /** | ||
72 | * Name of DB plugin | ||
73 | */ | ||
74 | static char *db_lib_name; | ||
75 | |||
76 | /** | ||
77 | * Token expiration interval | 67 | * Token expiration interval |
78 | */ | 68 | */ |
79 | static struct GNUNET_TIME_Relative token_expiration_interval; | 69 | static struct GNUNET_TIME_Relative token_expiration_interval; |
@@ -106,7 +96,8 @@ struct IdpClient; | |||
106 | /** | 96 | /** |
107 | * A ticket iteration operation. | 97 | * A ticket iteration operation. |
108 | */ | 98 | */ |
109 | struct TicketIteration { | 99 | struct TicketIteration |
100 | { | ||
110 | /** | 101 | /** |
111 | * DLL | 102 | * DLL |
112 | */ | 103 | */ |
@@ -136,7 +127,8 @@ struct TicketIteration { | |||
136 | /** | 127 | /** |
137 | * An attribute iteration operation. | 128 | * An attribute iteration operation. |
138 | */ | 129 | */ |
139 | struct AttributeIterator { | 130 | struct AttributeIterator |
131 | { | ||
140 | /** | 132 | /** |
141 | * Next element in the DLL | 133 | * Next element in the DLL |
142 | */ | 134 | */ |
@@ -171,7 +163,8 @@ struct AttributeIterator { | |||
171 | /** | 163 | /** |
172 | * An idp client | 164 | * An idp client |
173 | */ | 165 | */ |
174 | struct IdpClient { | 166 | struct IdpClient |
167 | { | ||
175 | 168 | ||
176 | /** | 169 | /** |
177 | * The client | 170 | * The client |
@@ -246,9 +239,80 @@ struct IdpClient { | |||
246 | * Tail of DLL of attribute store ops | 239 | * Tail of DLL of attribute store ops |
247 | */ | 240 | */ |
248 | struct AttributeStoreHandle *store_op_tail; | 241 | struct AttributeStoreHandle *store_op_tail; |
242 | /** | ||
243 | * Head of DLL of attribute delete ops | ||
244 | */ | ||
245 | struct AttributeDeleteHandle *delete_op_head; | ||
246 | |||
247 | /** | ||
248 | * Tail of DLL of attribute delete ops | ||
249 | */ | ||
250 | struct AttributeDeleteHandle *delete_op_tail; | ||
251 | }; | ||
252 | |||
253 | |||
254 | struct AttributeDeleteHandle | ||
255 | { | ||
256 | /** | ||
257 | * DLL | ||
258 | */ | ||
259 | struct AttributeDeleteHandle *next; | ||
260 | |||
261 | /** | ||
262 | * DLL | ||
263 | */ | ||
264 | struct AttributeDeleteHandle *prev; | ||
265 | |||
266 | /** | ||
267 | * Client connection | ||
268 | */ | ||
269 | struct IdpClient *client; | ||
270 | |||
271 | /** | ||
272 | * Identity | ||
273 | */ | ||
274 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | ||
275 | |||
276 | |||
277 | /** | ||
278 | * QueueEntry | ||
279 | */ | ||
280 | struct GNUNET_NAMESTORE_QueueEntry *ns_qe; | ||
281 | |||
282 | /** | ||
283 | * Iterator | ||
284 | */ | ||
285 | struct GNUNET_NAMESTORE_ZoneIterator *ns_it; | ||
286 | |||
287 | /** | ||
288 | * The attribute to delete | ||
289 | */ | ||
290 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | ||
291 | |||
292 | /** | ||
293 | * Tickets to update | ||
294 | */ | ||
295 | struct TicketRecordsEntry *tickets_to_update_head; | ||
296 | |||
297 | /** | ||
298 | * Tickets to update | ||
299 | */ | ||
300 | struct TicketRecordsEntry *tickets_to_update_tail; | ||
301 | |||
302 | /** | ||
303 | * Attribute label | ||
304 | */ | ||
305 | char *label; | ||
306 | |||
307 | /** | ||
308 | * request id | ||
309 | */ | ||
310 | uint32_t r_id; | ||
249 | }; | 311 | }; |
250 | 312 | ||
251 | struct AttributeStoreHandle { | 313 | |
314 | struct AttributeStoreHandle | ||
315 | { | ||
252 | /** | 316 | /** |
253 | * DLL | 317 | * DLL |
254 | */ | 318 | */ |
@@ -295,7 +359,8 @@ struct AttributeStoreHandle { | |||
295 | uint32_t r_id; | 359 | uint32_t r_id; |
296 | }; | 360 | }; |
297 | 361 | ||
298 | struct ConsumeTicketOperation { | 362 | struct ConsumeTicketOperation |
363 | { | ||
299 | /** | 364 | /** |
300 | * DLL | 365 | * DLL |
301 | */ | 366 | */ |
@@ -325,7 +390,8 @@ struct ConsumeTicketOperation { | |||
325 | /** | 390 | /** |
326 | * Updated attribute IDs | 391 | * Updated attribute IDs |
327 | */ | 392 | */ |
328 | struct TicketAttributeUpdateEntry { | 393 | struct TicketAttributeUpdateEntry |
394 | { | ||
329 | /** | 395 | /** |
330 | * DLL | 396 | * DLL |
331 | */ | 397 | */ |
@@ -350,7 +416,8 @@ struct TicketAttributeUpdateEntry { | |||
350 | /** | 416 | /** |
351 | * Ticket revocation request handle | 417 | * Ticket revocation request handle |
352 | */ | 418 | */ |
353 | struct TicketRevocationOperation { | 419 | struct TicketRevocationOperation |
420 | { | ||
354 | /** | 421 | /** |
355 | * DLL | 422 | * DLL |
356 | */ | 423 | */ |
@@ -380,7 +447,8 @@ struct TicketRevocationOperation { | |||
380 | /** | 447 | /** |
381 | * Ticket issue operation handle | 448 | * Ticket issue operation handle |
382 | */ | 449 | */ |
383 | struct TicketIssueOperation { | 450 | struct TicketIssueOperation |
451 | { | ||
384 | /** | 452 | /** |
385 | * DLL | 453 | * DLL |
386 | */ | 454 | */ |
@@ -407,7 +475,8 @@ struct TicketIssueOperation { | |||
407 | * map in json_t format | 475 | * map in json_t format |
408 | * | 476 | * |
409 | */ | 477 | */ |
410 | struct EgoEntry { | 478 | struct EgoEntry |
479 | { | ||
411 | /** | 480 | /** |
412 | * DLL | 481 | * DLL |
413 | */ | 482 | */ |
@@ -438,9 +507,6 @@ cleanup () | |||
438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); | 507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); |
439 | 508 | ||
440 | RECLAIM_TICKETS_deinit (); | 509 | RECLAIM_TICKETS_deinit (); |
441 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, TKT_database)); | ||
442 | GNUNET_free (db_lib_name); | ||
443 | db_lib_name = NULL; | ||
444 | if (NULL != timeout_task) | 510 | if (NULL != timeout_task) |
445 | GNUNET_SCHEDULER_cancel (timeout_task); | 511 | GNUNET_SCHEDULER_cancel (timeout_task); |
446 | if (NULL != update_task) | 512 | if (NULL != update_task) |
@@ -673,7 +739,7 @@ attr_store_cont (void *cls, int32_t success, const char *emsg) | |||
673 | { | 739 | { |
674 | struct AttributeStoreHandle *ash = cls; | 740 | struct AttributeStoreHandle *ash = cls; |
675 | struct GNUNET_MQ_Envelope *env; | 741 | struct GNUNET_MQ_Envelope *env; |
676 | struct AttributeStoreResultMessage *acr_msg; | 742 | struct SuccessResultMessage *acr_msg; |
677 | 743 | ||
678 | ash->ns_qe = NULL; | 744 | ash->ns_qe = NULL; |
679 | GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, | 745 | GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, |
@@ -687,10 +753,8 @@ attr_store_cont (void *cls, int32_t success, const char *emsg) | |||
687 | return; | 753 | return; |
688 | } | 754 | } |
689 | 755 | ||
690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); |
691 | "Sending ATTRIBUTE_STORE_RESPONSE message\n"); | 757 | env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); |
692 | env = GNUNET_MQ_msg (acr_msg, | ||
693 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE); | ||
694 | acr_msg->id = htonl (ash->r_id); | 758 | acr_msg->id = htonl (ash->r_id); |
695 | acr_msg->op_result = htonl (GNUNET_OK); | 759 | acr_msg->op_result = htonl (GNUNET_OK); |
696 | GNUNET_MQ_send (ash->client->mq, env); | 760 | GNUNET_MQ_send (ash->client->mq, env); |
@@ -771,6 +835,220 @@ handle_attribute_store_message (void *cls, | |||
771 | GNUNET_SCHEDULER_add_now (&attr_store_task, ash); | 835 | GNUNET_SCHEDULER_add_now (&attr_store_task, ash); |
772 | } | 836 | } |
773 | 837 | ||
838 | |||
839 | static void | ||
840 | cleanup_adh (struct AttributeDeleteHandle *adh) | ||
841 | { | ||
842 | struct TicketRecordsEntry *le; | ||
843 | if (NULL != adh->ns_it) | ||
844 | GNUNET_NAMESTORE_zone_iteration_stop (adh->ns_it); | ||
845 | if (NULL != adh->ns_qe) | ||
846 | GNUNET_NAMESTORE_cancel (adh->ns_qe); | ||
847 | if (NULL != adh->label) | ||
848 | GNUNET_free (adh->label); | ||
849 | if (NULL != adh->claim) | ||
850 | GNUNET_free (adh->claim); | ||
851 | while (NULL != (le = adh->tickets_to_update_head)) { | ||
852 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | ||
853 | adh->tickets_to_update_tail, le); | ||
854 | if (NULL != le->label) | ||
855 | GNUNET_free (le->label); | ||
856 | if (NULL != le->data) | ||
857 | GNUNET_free (le->data); | ||
858 | GNUNET_free (le); | ||
859 | } | ||
860 | GNUNET_free (adh); | ||
861 | } | ||
862 | |||
863 | |||
864 | static void | ||
865 | send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) | ||
866 | { | ||
867 | struct GNUNET_MQ_Envelope *env; | ||
868 | struct SuccessResultMessage *acr_msg; | ||
869 | |||
870 | GNUNET_CONTAINER_DLL_remove (adh->client->delete_op_head, | ||
871 | adh->client->delete_op_tail, adh); | ||
872 | |||
873 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); | ||
874 | env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); | ||
875 | acr_msg->id = htonl (adh->r_id); | ||
876 | acr_msg->op_result = htonl (success); | ||
877 | GNUNET_MQ_send (adh->client->mq, env); | ||
878 | } | ||
879 | |||
880 | |||
881 | static void | ||
882 | ticket_iter (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
883 | const char *label, unsigned int rd_count, | ||
884 | const struct GNUNET_GNSRECORD_Data *rd) | ||
885 | { | ||
886 | struct AttributeDeleteHandle *adh = cls; | ||
887 | struct TicketRecordsEntry *le; | ||
888 | int has_changed = GNUNET_NO; | ||
889 | |||
890 | for (int i = 0; i < rd_count; i++) { | ||
891 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | ||
892 | continue; | ||
893 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t))) | ||
894 | continue; | ||
895 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attribute to delete found (%s)\n", | ||
896 | adh->label); | ||
897 | has_changed = GNUNET_YES; | ||
898 | break; | ||
899 | } | ||
900 | if (GNUNET_YES == has_changed) { | ||
901 | le = GNUNET_new (struct TicketRecordsEntry); | ||
902 | le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | ||
903 | le->data = GNUNET_malloc (le->data_size); | ||
904 | le->rd_count = rd_count; | ||
905 | le->label = GNUNET_strdup (label); | ||
906 | GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data); | ||
907 | GNUNET_CONTAINER_DLL_insert (adh->tickets_to_update_head, | ||
908 | adh->tickets_to_update_tail, le); | ||
909 | } | ||
910 | GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1); | ||
911 | } | ||
912 | |||
913 | |||
914 | static void | ||
915 | update_tickets (void *cls); | ||
916 | |||
917 | |||
918 | static void | ||
919 | ticket_updated (void *cls, int32_t success, const char *emsg) | ||
920 | { | ||
921 | struct AttributeDeleteHandle *adh = cls; | ||
922 | adh->ns_qe = NULL; | ||
923 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); | ||
924 | } | ||
925 | |||
926 | static void | ||
927 | update_tickets (void *cls) | ||
928 | { | ||
929 | struct AttributeDeleteHandle *adh = cls; | ||
930 | struct TicketRecordsEntry *le; | ||
931 | if (NULL == adh->tickets_to_update_head) { | ||
932 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
933 | "Finished updatding tickets, success\n"); | ||
934 | send_delete_response (adh, GNUNET_OK); | ||
935 | cleanup_adh (adh); | ||
936 | return; | ||
937 | } | ||
938 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating %s\n", | ||
939 | adh->tickets_to_update_head->label); | ||
940 | le = adh->tickets_to_update_head; | ||
941 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | ||
942 | adh->tickets_to_update_tail, le); | ||
943 | struct GNUNET_GNSRECORD_Data rd[le->rd_count]; | ||
944 | struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1]; | ||
945 | GNUNET_GNSRECORD_records_deserialize (le->data_size, le->data, le->rd_count, | ||
946 | rd); | ||
947 | int j = 0; | ||
948 | for (int i = 0; i < le->rd_count; i++) { | ||
949 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) && | ||
950 | (0 == memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t)))) | ||
951 | continue; | ||
952 | rd_new[j] = rd[i]; | ||
953 | j++; | ||
954 | } | ||
955 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &adh->identity, le->label, | ||
956 | j, rd_new, &ticket_updated, adh); | ||
957 | GNUNET_free (le->label); | ||
958 | GNUNET_free (le->data); | ||
959 | GNUNET_free (le); | ||
960 | } | ||
961 | |||
962 | |||
963 | static void | ||
964 | ticket_iter_fin (void *cls) | ||
965 | { | ||
966 | struct AttributeDeleteHandle *adh = cls; | ||
967 | adh->ns_it = NULL; | ||
968 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); | ||
969 | } | ||
970 | |||
971 | |||
972 | static void | ||
973 | ticket_iter_err (void *cls) | ||
974 | { | ||
975 | struct AttributeDeleteHandle *adh = cls; | ||
976 | adh->ns_it = NULL; | ||
977 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Namestore error on delete %s\n", | ||
978 | adh->label); | ||
979 | send_delete_response (adh, GNUNET_SYSERR); | ||
980 | cleanup_adh (adh); | ||
981 | } | ||
982 | |||
983 | |||
984 | static void | ||
985 | start_ticket_update (void *cls) | ||
986 | { | ||
987 | struct AttributeDeleteHandle *adh = cls; | ||
988 | adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( | ||
989 | nsh, &adh->identity, &ticket_iter_err, adh, &ticket_iter, adh, | ||
990 | &ticket_iter_fin, adh); | ||
991 | } | ||
992 | |||
993 | |||
994 | static void | ||
995 | attr_delete_cont (void *cls, int32_t success, const char *emsg) | ||
996 | { | ||
997 | struct AttributeDeleteHandle *adh = cls; | ||
998 | adh->ns_qe = NULL; | ||
999 | if (GNUNET_SYSERR == success) { | ||
1000 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error deleting attribute %s (%s)\n", | ||
1001 | adh->claim->name, adh->label); | ||
1002 | send_delete_response (adh, GNUNET_SYSERR); | ||
1003 | cleanup_adh (adh); | ||
1004 | return; | ||
1005 | } | ||
1006 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating tickets...\n"); | ||
1007 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | ||
1008 | } | ||
1009 | |||
1010 | |||
1011 | static int | ||
1012 | check_attribute_delete_message (void *cls, | ||
1013 | const struct AttributeDeleteMessage *dam) | ||
1014 | { | ||
1015 | uint16_t size; | ||
1016 | |||
1017 | size = ntohs (dam->header.size); | ||
1018 | if (size <= sizeof (struct AttributeDeleteMessage)) { | ||
1019 | GNUNET_break (0); | ||
1020 | return GNUNET_SYSERR; | ||
1021 | } | ||
1022 | return GNUNET_OK; | ||
1023 | } | ||
1024 | |||
1025 | |||
1026 | static void | ||
1027 | handle_attribute_delete_message (void *cls, | ||
1028 | const struct AttributeDeleteMessage *dam) | ||
1029 | { | ||
1030 | struct AttributeDeleteHandle *adh; | ||
1031 | struct IdpClient *idp = cls; | ||
1032 | size_t data_len; | ||
1033 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received ATTRIBUTE_DELETE message\n"); | ||
1034 | |||
1035 | data_len = ntohs (dam->attr_len); | ||
1036 | |||
1037 | adh = GNUNET_new (struct AttributeDeleteHandle); | ||
1038 | adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *)&dam[1], data_len); | ||
1039 | |||
1040 | adh->r_id = ntohl (dam->id); | ||
1041 | adh->identity = dam->identity; | ||
1042 | adh->label = | ||
1043 | GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof (uint64_t)); | ||
1044 | GNUNET_SERVICE_client_continue (idp->client); | ||
1045 | adh->client = idp; | ||
1046 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | ||
1047 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &adh->identity, adh->label, | ||
1048 | 0, NULL, &attr_delete_cont, adh); | ||
1049 | } | ||
1050 | |||
1051 | |||
774 | /************************************************* | 1052 | /************************************************* |
775 | * Attrubute iteration | 1053 | * Attrubute iteration |
776 | *************************************************/ | 1054 | *************************************************/ |
@@ -1013,7 +1291,6 @@ static void | |||
1013 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, | 1291 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, |
1014 | struct GNUNET_SERVICE_Handle *server) | 1292 | struct GNUNET_SERVICE_Handle *server) |
1015 | { | 1293 | { |
1016 | char *database; | ||
1017 | cfg = c; | 1294 | cfg = c; |
1018 | 1295 | ||
1019 | if (GNUNET_OK != RECLAIM_TICKETS_init (cfg)) { | 1296 | if (GNUNET_OK != RECLAIM_TICKETS_init (cfg)) { |
@@ -1030,19 +1307,6 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, | |||
1030 | } | 1307 | } |
1031 | 1308 | ||
1032 | identity_handle = GNUNET_IDENTITY_connect (cfg, NULL, NULL); | 1309 | identity_handle = GNUNET_IDENTITY_connect (cfg, NULL, NULL); |
1033 | /* Loading DB plugin */ | ||
1034 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string ( | ||
1035 | cfg, "reclaim", "database", &database)) | ||
1036 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); | ||
1037 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_reclaim_%s", database); | ||
1038 | TKT_database = GNUNET_PLUGIN_load (db_lib_name, (void *)cfg); | ||
1039 | GNUNET_free (database); | ||
1040 | if (NULL == TKT_database) { | ||
1041 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1042 | "Could not load database backend `%s'\n", db_lib_name); | ||
1043 | GNUNET_SCHEDULER_shutdown (); | ||
1044 | return; | ||
1045 | } | ||
1046 | 1310 | ||
1047 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time ( | 1311 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time ( |
1048 | cfg, "reclaim", "TOKEN_EXPIRATION_INTERVAL", | 1312 | cfg, "reclaim", "TOKEN_EXPIRATION_INTERVAL", |
@@ -1075,6 +1339,7 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, | |||
1075 | struct TicketIssueOperation *iss; | 1339 | struct TicketIssueOperation *iss; |
1076 | struct ConsumeTicketOperation *ct; | 1340 | struct ConsumeTicketOperation *ct; |
1077 | struct AttributeStoreHandle *as; | 1341 | struct AttributeStoreHandle *as; |
1342 | struct AttributeDeleteHandle *adh; | ||
1078 | 1343 | ||
1079 | // TODO other operations | 1344 | // TODO other operations |
1080 | 1345 | ||
@@ -1095,6 +1360,10 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, | |||
1095 | GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as); | 1360 | GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as); |
1096 | cleanup_as_handle (as); | 1361 | cleanup_as_handle (as); |
1097 | } | 1362 | } |
1363 | while (NULL != (adh = idp->delete_op_head)) { | ||
1364 | GNUNET_CONTAINER_DLL_remove (idp->delete_op_head, idp->delete_op_tail, adh); | ||
1365 | cleanup_adh (adh); | ||
1366 | } | ||
1098 | 1367 | ||
1099 | while (NULL != (ai = idp->attr_iter_head)) { | 1368 | while (NULL != (ai = idp->attr_iter_head)) { |
1100 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); | 1369 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); |
@@ -1143,6 +1412,9 @@ GNUNET_SERVICE_MAIN ( | |||
1143 | GNUNET_MQ_hd_var_size (attribute_store_message, | 1412 | GNUNET_MQ_hd_var_size (attribute_store_message, |
1144 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, | 1413 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, |
1145 | struct AttributeStoreMessage, NULL), | 1414 | struct AttributeStoreMessage, NULL), |
1415 | GNUNET_MQ_hd_var_size (attribute_delete_message, | ||
1416 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, | ||
1417 | struct AttributeDeleteMessage, NULL), | ||
1146 | GNUNET_MQ_hd_fixed_size ( | 1418 | GNUNET_MQ_hd_fixed_size ( |
1147 | iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, | 1419 | iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |
1148 | struct AttributeIterationStartMessage, NULL), | 1420 | struct AttributeIterationStartMessage, NULL), |
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index 549ea8c34..1cdd4268d 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -30,6 +30,34 @@ | |||
30 | 30 | ||
31 | struct ParallelLookup; | 31 | struct ParallelLookup; |
32 | 32 | ||
33 | |||
34 | /** | ||
35 | * A reference to a ticket stored in GNS | ||
36 | */ | ||
37 | struct TicketReference | ||
38 | { | ||
39 | /** | ||
40 | * DLL | ||
41 | */ | ||
42 | struct TicketReference *next; | ||
43 | |||
44 | /** | ||
45 | * DLL | ||
46 | */ | ||
47 | struct TicketReference *prev; | ||
48 | |||
49 | /** | ||
50 | * Attributes | ||
51 | */ | ||
52 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; | ||
53 | |||
54 | /** | ||
55 | * Tickets | ||
56 | */ | ||
57 | struct GNUNET_RECLAIM_Ticket ticket; | ||
58 | }; | ||
59 | |||
60 | |||
33 | struct RECLAIM_TICKETS_ConsumeHandle | 61 | struct RECLAIM_TICKETS_ConsumeHandle |
34 | { | 62 | { |
35 | /** | 63 | /** |
@@ -116,33 +144,6 @@ struct ParallelLookup | |||
116 | 144 | ||
117 | 145 | ||
118 | /** | 146 | /** |
119 | * A reference to a ticket stored in GNS | ||
120 | */ | ||
121 | struct TicketReference | ||
122 | { | ||
123 | /** | ||
124 | * DLL | ||
125 | */ | ||
126 | struct TicketReference *next; | ||
127 | |||
128 | /** | ||
129 | * DLL | ||
130 | */ | ||
131 | struct TicketReference *prev; | ||
132 | |||
133 | /** | ||
134 | * Attributes | ||
135 | */ | ||
136 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; | ||
137 | |||
138 | /** | ||
139 | * Tickets | ||
140 | */ | ||
141 | struct GNUNET_RECLAIM_Ticket ticket; | ||
142 | }; | ||
143 | |||
144 | |||
145 | /** | ||
146 | * Ticket issue request handle | 147 | * Ticket issue request handle |
147 | */ | 148 | */ |
148 | struct TicketIssueHandle | 149 | struct TicketIssueHandle |
@@ -224,39 +225,6 @@ struct RevokedAttributeEntry | |||
224 | }; | 225 | }; |
225 | 226 | ||
226 | 227 | ||
227 | struct TicketRecordsEntry | ||
228 | { | ||
229 | /** | ||
230 | * DLL | ||
231 | */ | ||
232 | struct TicketRecordsEntry *next; | ||
233 | |||
234 | /** | ||
235 | * DLL | ||
236 | */ | ||
237 | struct TicketRecordsEntry *prev; | ||
238 | |||
239 | /** | ||
240 | * Record count | ||
241 | */ | ||
242 | unsigned int rd_count; | ||
243 | |||
244 | /** | ||
245 | * Data | ||
246 | */ | ||
247 | char *data; | ||
248 | |||
249 | /** | ||
250 | * Data size | ||
251 | */ | ||
252 | size_t data_size; | ||
253 | |||
254 | /** | ||
255 | * Label | ||
256 | */ | ||
257 | char *label; | ||
258 | }; | ||
259 | |||
260 | /** | 228 | /** |
261 | * Ticket revocation request handle | 229 | * Ticket revocation request handle |
262 | */ | 230 | */ |
@@ -414,8 +382,11 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
414 | const struct GNUNET_GNSRECORD_Data *rd) | 382 | const struct GNUNET_GNSRECORD_Data *rd) |
415 | { | 383 | { |
416 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 384 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
385 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | ||
386 | struct GNUNET_GNSRECORD_Data new_rd; | ||
417 | struct RevokedAttributeEntry *le; | 387 | struct RevokedAttributeEntry *le; |
418 | char *new_label; | 388 | char *new_label; |
389 | char *attr_data; | ||
419 | rvk->ns_qe = NULL; | 390 | rvk->ns_qe = NULL; |
420 | if (0 == rd_count) { | 391 | if (0 == rd_count) { |
421 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 392 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -430,12 +401,24 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
430 | /** find a new place for this attribute **/ | 401 | /** find a new place for this attribute **/ |
431 | rvk->move_attr->new_id = | 402 | rvk->move_attr->new_id = |
432 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 403 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); |
404 | new_rd = *rd; | ||
405 | claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); | ||
406 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
407 | "Attribute to update: Name=%s, ID=%" PRIu64 "\n", claim->name, | ||
408 | claim->id); | ||
409 | claim->id = rvk->move_attr->new_id; | ||
410 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); | ||
411 | attr_data = GNUNET_malloc (rd->data_size); | ||
412 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data); | ||
413 | new_rd.data = attr_data; | ||
433 | new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, | 414 | new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, |
434 | sizeof (uint64_t)); | 415 | sizeof (uint64_t)); |
435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); | 416 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); |
436 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &rvk->identity, new_label, | 417 | rvk->ns_qe = GNUNET_NAMESTORE_records_store ( |
437 | 1, rd, &move_attr_finished, rvk); | 418 | nsh, &rvk->identity, new_label, 1, &new_rd, &move_attr_finished, rvk); |
438 | GNUNET_free (new_label); | 419 | GNUNET_free (new_label); |
420 | GNUNET_free (claim); | ||
421 | GNUNET_free (attr_data); | ||
439 | } | 422 | } |
440 | 423 | ||
441 | 424 | ||
@@ -703,7 +686,7 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count, | |||
703 | struct ParallelLookup *parallel_lookup = cls; | 686 | struct ParallelLookup *parallel_lookup = cls; |
704 | struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; | 687 | struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; |
705 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; | 688 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; |
706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parallel lookup finished (count=%u)\n", | 689 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Parallel lookup finished (count=%u)\n", |
707 | rd_count); | 690 | rd_count); |
708 | 691 | ||
709 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 692 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, |
@@ -777,8 +760,10 @@ lookup_authz_cb (void *cls, uint32_t rd_count, | |||
777 | GNUNET_YES); | 760 | GNUNET_YES); |
778 | 761 | ||
779 | for (int i = 0; i < rd_count; i++) { | 762 | for (int i = 0; i < rd_count; i++) { |
763 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | ||
764 | continue; | ||
780 | lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); | 765 | lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); |
781 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); | 766 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attribute ref found %s\n", lbl); |
782 | parallel_lookup = GNUNET_new (struct ParallelLookup); | 767 | parallel_lookup = GNUNET_new (struct ParallelLookup); |
783 | parallel_lookup->handle = cth; | 768 | parallel_lookup->handle = cth; |
784 | parallel_lookup->label = lbl; | 769 | parallel_lookup->label = lbl; |
@@ -790,9 +775,14 @@ lookup_authz_cb (void *cls, uint32_t rd_count, | |||
790 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, | 775 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, |
791 | cth->parallel_lookups_tail, parallel_lookup); | 776 | cth->parallel_lookups_tail, parallel_lookup); |
792 | } | 777 | } |
793 | cth->kill_task = GNUNET_SCHEDULER_add_delayed ( | 778 | if (NULL != cth->parallel_lookups_head) { |
794 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), | 779 | cth->kill_task = GNUNET_SCHEDULER_add_delayed ( |
795 | &abort_parallel_lookups, cth); | 780 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), |
781 | &abort_parallel_lookups, cth); | ||
782 | return; | ||
783 | } | ||
784 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); | ||
785 | cleanup_cth (cth); | ||
796 | } | 786 | } |
797 | 787 | ||
798 | 788 | ||
@@ -813,7 +803,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | |||
813 | cth->cb_cls = cb_cls; | 803 | cth->cb_cls = cb_cls; |
814 | label = | 804 | label = |
815 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); | 805 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); |
816 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for AuthZ info under %s\n", | 806 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Looking for AuthZ info under %s\n", |
817 | label); | 807 | label); |
818 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); | 808 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); |
819 | cth->lookup_request = GNUNET_GNS_lookup ( | 809 | cth->lookup_request = GNUNET_GNS_lookup ( |
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h index d2b614c46..6e704243d 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.h +++ b/src/reclaim/gnunet-service-reclaim_tickets.h | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "gnunet_namestore_service.h" | 38 | #include "gnunet_namestore_service.h" |
39 | #include "gnunet_protocols.h" | 39 | #include "gnunet_protocols.h" |
40 | #include "gnunet_reclaim_attribute_lib.h" | 40 | #include "gnunet_reclaim_attribute_lib.h" |
41 | #include "gnunet_reclaim_plugin.h" | 41 | #include "gnunet_reclaim_service.h" |
42 | #include "gnunet_signatures.h" | 42 | #include "gnunet_signatures.h" |
43 | #include "gnunet_statistics_service.h" | 43 | #include "gnunet_statistics_service.h" |
44 | #include "reclaim.h" | 44 | #include "reclaim.h" |
@@ -47,6 +47,41 @@ struct RECLAIM_TICKETS_Iterator; | |||
47 | struct RECLAIM_TICKETS_ConsumeHandle; | 47 | struct RECLAIM_TICKETS_ConsumeHandle; |
48 | struct RECLAIM_TICKETS_RevokeHandle; | 48 | struct RECLAIM_TICKETS_RevokeHandle; |
49 | 49 | ||
50 | |||
51 | struct TicketRecordsEntry | ||
52 | { | ||
53 | /** | ||
54 | * DLL | ||
55 | */ | ||
56 | struct TicketRecordsEntry *next; | ||
57 | |||
58 | /** | ||
59 | * DLL | ||
60 | */ | ||
61 | struct TicketRecordsEntry *prev; | ||
62 | |||
63 | /** | ||
64 | * Record count | ||
65 | */ | ||
66 | unsigned int rd_count; | ||
67 | |||
68 | /** | ||
69 | * Data | ||
70 | */ | ||
71 | char *data; | ||
72 | |||
73 | /** | ||
74 | * Data size | ||
75 | */ | ||
76 | size_t data_size; | ||
77 | |||
78 | /** | ||
79 | * Label | ||
80 | */ | ||
81 | char *label; | ||
82 | }; | ||
83 | |||
84 | |||
50 | /** | 85 | /** |
51 | * Continuation called with ticket. | 86 | * Continuation called with ticket. |
52 | * | 87 | * |
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h index c29902ab1..982cd8ae4 100644 --- a/src/reclaim/reclaim.h +++ b/src/reclaim/reclaim.h | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | GNUNET_NETWORK_STRUCT_BEGIN | 34 | GNUNET_NETWORK_STRUCT_BEGIN |
35 | 35 | ||
36 | |||
36 | /** | 37 | /** |
37 | * Use to store an identity attribute | 38 | * Use to store an identity attribute |
38 | */ | 39 | */ |
@@ -64,13 +65,42 @@ struct AttributeStoreMessage | |||
64 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | 65 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; |
65 | 66 | ||
66 | /* followed by the serialized attribute */ | 67 | /* followed by the serialized attribute */ |
68 | }; | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Use to delete an identity attribute | ||
73 | */ | ||
74 | struct AttributeDeleteMessage | ||
75 | { | ||
76 | /** | ||
77 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT | ||
78 | */ | ||
79 | struct GNUNET_MessageHeader header; | ||
80 | |||
81 | /** | ||
82 | * Unique identifier for this request (for key collisions). | ||
83 | */ | ||
84 | uint32_t id GNUNET_PACKED; | ||
85 | |||
86 | /** | ||
87 | * The length of the attribute | ||
88 | */ | ||
89 | uint32_t attr_len GNUNET_PACKED; | ||
90 | |||
91 | /** | ||
92 | * Identity | ||
93 | */ | ||
94 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | ||
67 | 95 | ||
96 | /* followed by the serialized attribute */ | ||
68 | }; | 97 | }; |
69 | 98 | ||
99 | |||
70 | /** | 100 | /** |
71 | * Attribute store response message | 101 | * Attribute store/delete response message |
72 | */ | 102 | */ |
73 | struct AttributeStoreResultMessage | 103 | struct SuccessResultMessage |
74 | { | 104 | { |
75 | /** | 105 | /** |
76 | * Message header | 106 | * Message header |
@@ -86,7 +116,6 @@ struct AttributeStoreResultMessage | |||
86 | * #GNUNET_SYSERR on failure, #GNUNET_OK on success | 116 | * #GNUNET_SYSERR on failure, #GNUNET_OK on success |
87 | */ | 117 | */ |
88 | int32_t op_result GNUNET_PACKED; | 118 | int32_t op_result GNUNET_PACKED; |
89 | |||
90 | }; | 119 | }; |
91 | 120 | ||
92 | /** | 121 | /** |
@@ -99,7 +128,7 @@ struct AttributeResultMessage | |||
99 | */ | 128 | */ |
100 | struct GNUNET_MessageHeader header; | 129 | struct GNUNET_MessageHeader header; |
101 | 130 | ||
102 | /** | 131 | /** |
103 | * Unique identifier for this request (for key collisions). | 132 | * Unique identifier for this request (for key collisions). |
104 | */ | 133 | */ |
105 | uint32_t id GNUNET_PACKED; | 134 | uint32_t id GNUNET_PACKED; |
@@ -144,7 +173,6 @@ struct AttributeIterationStartMessage | |||
144 | * Identity. | 173 | * Identity. |
145 | */ | 174 | */ |
146 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | 175 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; |
147 | |||
148 | }; | 176 | }; |
149 | 177 | ||
150 | 178 | ||
@@ -162,7 +190,6 @@ struct AttributeIterationNextMessage | |||
162 | * Unique identifier for this request (for key collisions). | 190 | * Unique identifier for this request (for key collisions). |
163 | */ | 191 | */ |
164 | uint32_t id GNUNET_PACKED; | 192 | uint32_t id GNUNET_PACKED; |
165 | |||
166 | }; | 193 | }; |
167 | 194 | ||
168 | 195 | ||
@@ -180,7 +207,6 @@ struct AttributeIterationStopMessage | |||
180 | * Unique identifier for this request (for key collisions). | 207 | * Unique identifier for this request (for key collisions). |
181 | */ | 208 | */ |
182 | uint32_t id GNUNET_PACKED; | 209 | uint32_t id GNUNET_PACKED; |
183 | |||
184 | }; | 210 | }; |
185 | 211 | ||
186 | /** | 212 | /** |
@@ -202,7 +228,6 @@ struct TicketIterationStartMessage | |||
202 | * Identity. | 228 | * Identity. |
203 | */ | 229 | */ |
204 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | 230 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; |
205 | |||
206 | }; | 231 | }; |
207 | 232 | ||
208 | 233 | ||
@@ -220,7 +245,6 @@ struct TicketIterationNextMessage | |||
220 | * Unique identifier for this request (for key collisions). | 245 | * Unique identifier for this request (for key collisions). |
221 | */ | 246 | */ |
222 | uint32_t id GNUNET_PACKED; | 247 | uint32_t id GNUNET_PACKED; |
223 | |||
224 | }; | 248 | }; |
225 | 249 | ||
226 | 250 | ||
@@ -238,11 +262,9 @@ struct TicketIterationStopMessage | |||
238 | * Unique identifier for this request (for key collisions). | 262 | * Unique identifier for this request (for key collisions). |
239 | */ | 263 | */ |
240 | uint32_t id GNUNET_PACKED; | 264 | uint32_t id GNUNET_PACKED; |
241 | |||
242 | }; | 265 | }; |
243 | 266 | ||
244 | 267 | ||
245 | |||
246 | /** | 268 | /** |
247 | * Ticket issue message | 269 | * Ticket issue message |
248 | */ | 270 | */ |
@@ -273,7 +295,7 @@ struct IssueTicketMessage | |||
273 | */ | 295 | */ |
274 | uint32_t attr_len GNUNET_PACKED; | 296 | uint32_t attr_len GNUNET_PACKED; |
275 | 297 | ||
276 | //Followed by a serialized attribute list | 298 | // Followed by a serialized attribute list |
277 | }; | 299 | }; |
278 | 300 | ||
279 | /** | 301 | /** |
@@ -301,7 +323,7 @@ struct RevokeTicketMessage | |||
301 | */ | 323 | */ |
302 | uint32_t attrs_len GNUNET_PACKED; | 324 | uint32_t attrs_len GNUNET_PACKED; |
303 | 325 | ||
304 | //Followed by a ticket and serialized attribute list | 326 | // Followed by a ticket and serialized attribute list |
305 | }; | 327 | }; |
306 | 328 | ||
307 | /** | 329 | /** |
@@ -340,7 +362,6 @@ struct TicketResultMessage | |||
340 | * Unique identifier for this request (for key collisions). | 362 | * Unique identifier for this request (for key collisions). |
341 | */ | 363 | */ |
342 | uint32_t id GNUNET_PACKED; | 364 | uint32_t id GNUNET_PACKED; |
343 | |||
344 | }; | 365 | }; |
345 | 366 | ||
346 | /** | 367 | /** |
@@ -363,7 +384,7 @@ struct ConsumeTicketMessage | |||
363 | */ | 384 | */ |
364 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | 385 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; |
365 | 386 | ||
366 | //Followed by a serialized ticket | 387 | // Followed by a serialized ticket |
367 | }; | 388 | }; |
368 | 389 | ||
369 | /** | 390 | /** |
@@ -376,7 +397,7 @@ struct ConsumeTicketResultMessage | |||
376 | */ | 397 | */ |
377 | struct GNUNET_MessageHeader header; | 398 | struct GNUNET_MessageHeader header; |
378 | 399 | ||
379 | /** | 400 | /** |
380 | * Unique identifier for this request (for key collisions). | 401 | * Unique identifier for this request (for key collisions). |
381 | */ | 402 | */ |
382 | uint32_t id GNUNET_PACKED; | 403 | uint32_t id GNUNET_PACKED; |
@@ -407,7 +428,6 @@ struct ConsumeTicketResultMessage | |||
407 | }; | 428 | }; |
408 | 429 | ||
409 | 430 | ||
410 | |||
411 | GNUNET_NETWORK_STRUCT_END | 431 | GNUNET_NETWORK_STRUCT_END |
412 | 432 | ||
413 | #endif | 433 | #endif |
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index 0edae76c2..e0ca9adf3 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -407,14 +407,13 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | |||
407 | 407 | ||
408 | /** | 408 | /** |
409 | * Handle an incoming message of type | 409 | * Handle an incoming message of type |
410 | * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE | 410 | * #GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE |
411 | * | 411 | * |
412 | * @param cls | 412 | * @param cls |
413 | * @param msg the message we received | 413 | * @param msg the message we received |
414 | */ | 414 | */ |
415 | static void | 415 | static void |
416 | handle_attribute_store_response (void *cls, | 416 | handle_success_response (void *cls, const struct SuccessResultMessage *msg) |
417 | const struct AttributeStoreResultMessage *msg) | ||
418 | { | 417 | { |
419 | struct GNUNET_RECLAIM_Handle *h = cls; | 418 | struct GNUNET_RECLAIM_Handle *h = cls; |
420 | struct GNUNET_RECLAIM_Operation *op; | 419 | struct GNUNET_RECLAIM_Operation *op; |
@@ -429,8 +428,8 @@ handle_attribute_store_response (void *cls, | |||
429 | return; | 428 | return; |
430 | 429 | ||
431 | res = ntohl (msg->op_result); | 430 | res = ntohl (msg->op_result); |
432 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 431 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received SUCCESS_RESPONSE with result %d\n", |
433 | "Received ATTRIBUTE_STORE_RESPONSE with result %d\n", res); | 432 | res); |
434 | 433 | ||
435 | /* TODO: add actual error message to response... */ | 434 | /* TODO: add actual error message to response... */ |
436 | if (GNUNET_SYSERR == res) | 435 | if (GNUNET_SYSERR == res) |
@@ -735,10 +734,9 @@ static void | |||
735 | reconnect (struct GNUNET_RECLAIM_Handle *h) | 734 | reconnect (struct GNUNET_RECLAIM_Handle *h) |
736 | { | 735 | { |
737 | struct GNUNET_MQ_MessageHandler handlers[] = { | 736 | struct GNUNET_MQ_MessageHandler handlers[] = { |
738 | GNUNET_MQ_hd_fixed_size ( | 737 | GNUNET_MQ_hd_fixed_size (success_response, |
739 | attribute_store_response, | 738 | GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, |
740 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE, | 739 | struct SuccessResultMessage, h), |
741 | struct AttributeStoreResultMessage, h), | ||
742 | GNUNET_MQ_hd_var_size (attribute_result, | 740 | GNUNET_MQ_hd_var_size (attribute_result, |
743 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, | 741 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, |
744 | struct AttributeResultMessage, h), | 742 | struct AttributeResultMessage, h), |
@@ -874,6 +872,48 @@ GNUNET_RECLAIM_attribute_store ( | |||
874 | 872 | ||
875 | 873 | ||
876 | /** | 874 | /** |
875 | * Delete an attribute. Tickets used to share this attribute are updated | ||
876 | * accordingly. | ||
877 | * | ||
878 | * @param h handle to the re:claimID service | ||
879 | * @param pkey Private key of the identity to add an attribute to | ||
880 | * @param attr The attribute | ||
881 | * @param cont Continuation to call when done | ||
882 | * @param cont_cls Closure for @a cont | ||
883 | * @return handle Used to to abort the request | ||
884 | */ | ||
885 | struct GNUNET_RECLAIM_Operation * | ||
886 | GNUNET_RECLAIM_attribute_delete ( | ||
887 | struct GNUNET_RECLAIM_Handle *h, | ||
888 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | ||
889 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | ||
890 | GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls) | ||
891 | { | ||
892 | struct GNUNET_RECLAIM_Operation *op; | ||
893 | struct AttributeDeleteMessage *dam; | ||
894 | size_t attr_len; | ||
895 | |||
896 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | ||
897 | op->h = h; | ||
898 | op->as_cb = cont; | ||
899 | op->cls = cont_cls; | ||
900 | op->r_id = h->r_id_gen++; | ||
901 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | ||
902 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); | ||
903 | op->env = GNUNET_MQ_msg_extra (dam, attr_len, | ||
904 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); | ||
905 | dam->identity = *pkey; | ||
906 | dam->id = htonl (op->r_id); | ||
907 | GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *)&dam[1]); | ||
908 | |||
909 | dam->attr_len = htons (attr_len); | ||
910 | if (NULL != h->mq) | ||
911 | GNUNET_MQ_send_copy (h->mq, op->env); | ||
912 | return op; | ||
913 | } | ||
914 | |||
915 | |||
916 | /** | ||
877 | * List all attributes for a local identity. | 917 | * List all attributes for a local identity. |
878 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` | 918 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` |
879 | * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and | 919 | * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and |