aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim_tickets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c126
1 files changed, 58 insertions, 68 deletions
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
31struct ParallelLookup; 31struct ParallelLookup;
32 32
33
34/**
35 * A reference to a ticket stored in GNS
36 */
37struct 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
33struct RECLAIM_TICKETS_ConsumeHandle 61struct 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 */
121struct 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 */
148struct TicketIssueHandle 149struct TicketIssueHandle
@@ -224,39 +225,6 @@ struct RevokedAttributeEntry
224}; 225};
225 226
226 227
227struct 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 (