diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-04-14 00:09:18 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-04-14 10:01:24 +0200 |
commit | eb2d072aa1096c9d77cbfde239a1004cab642e64 (patch) | |
tree | b44e82f972c503a64a6f2679edd340f7a1ecdda6 /src | |
parent | af90492d9f86b3bcce93a8459383744939318bc3 (diff) | |
download | gnunet-eb2d072aa1096c9d77cbfde239a1004cab642e64.tar.gz gnunet-eb2d072aa1096c9d77cbfde239a1004cab642e64.zip |
RECLAIM: Simplify logic
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 79 | ||||
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 68 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 1 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 237 | ||||
-rw-r--r-- | src/reclaim/plugin_gnsrecord_reclaim.c | 27 |
5 files changed, 146 insertions, 266 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 8b3a6b720..a92cdc2e7 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -100,7 +100,7 @@ extern "C" { | |||
100 | /** | 100 | /** |
101 | * Record type for local ticket references | 101 | * Record type for local ticket references |
102 | */ | 102 | */ |
103 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF 65545 | 103 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545 |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * 65546 reserved | 106 | * 65546 reserved |
@@ -358,8 +358,9 @@ typedef void (*GNUNET_GNSRECORD_RecordCallback) ( | |||
358 | * @param data_size number of bytes in @a data | 358 | * @param data_size number of bytes in @a data |
359 | * @return NULL on error, otherwise human-readable representation of the value | 359 | * @return NULL on error, otherwise human-readable representation of the value |
360 | */ | 360 | */ |
361 | char *GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data, | 361 | char * |
362 | size_t data_size); | 362 | GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data, |
363 | size_t data_size); | ||
363 | 364 | ||
364 | 365 | ||
365 | /** | 366 | /** |
@@ -372,8 +373,9 @@ char *GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data, | |||
372 | * @param data_size set to number of bytes in @a data | 373 | * @param data_size set to number of bytes in @a data |
373 | * @return #GNUNET_OK on success | 374 | * @return #GNUNET_OK on success |
374 | */ | 375 | */ |
375 | int GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data, | 376 | int |
376 | size_t *data_size); | 377 | GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data, |
378 | size_t *data_size); | ||
377 | 379 | ||
378 | 380 | ||
379 | /** | 381 | /** |
@@ -382,7 +384,8 @@ int GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data, | |||
382 | * @param dns_typename name to convert | 384 | * @param dns_typename name to convert |
383 | * @return corresponding number, UINT32_MAX on error | 385 | * @return corresponding number, UINT32_MAX on error |
384 | */ | 386 | */ |
385 | uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename); | 387 | uint32_t |
388 | GNUNET_GNSRECORD_typename_to_number (const char *dns_typename); | ||
386 | 389 | ||
387 | 390 | ||
388 | /** | 391 | /** |
@@ -391,7 +394,8 @@ uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename); | |||
391 | * @param type number of a type to convert | 394 | * @param type number of a type to convert |
392 | * @return corresponding typestring, NULL on error | 395 | * @return corresponding typestring, NULL on error |
393 | */ | 396 | */ |
394 | const char *GNUNET_GNSRECORD_number_to_typename (uint32_t type); | 397 | const char * |
398 | GNUNET_GNSRECORD_number_to_typename (uint32_t type); | ||
395 | 399 | ||
396 | 400 | ||
397 | /* convenience APIs for serializing / deserializing GNS records */ | 401 | /* convenience APIs for serializing / deserializing GNS records */ |
@@ -433,9 +437,10 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count, | |||
433 | * @param dest where to put the data | 437 | * @param dest where to put the data |
434 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 438 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
435 | */ | 439 | */ |
436 | int GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src, | 440 | int |
437 | unsigned int rd_count, | 441 | GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src, |
438 | struct GNUNET_GNSRECORD_Data *dest); | 442 | unsigned int rd_count, |
443 | struct GNUNET_GNSRECORD_Data *dest); | ||
439 | 444 | ||
440 | 445 | ||
441 | /* ******* general APIs relating to blocks, records and labels ******** */ | 446 | /* ******* general APIs relating to blocks, records and labels ******** */ |
@@ -448,7 +453,8 @@ int GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src, | |||
448 | * @return #GNUNET_YES if the record is expired, | 453 | * @return #GNUNET_YES if the record is expired, |
449 | * #GNUNET_NO if not | 454 | * #GNUNET_NO if not |
450 | */ | 455 | */ |
451 | int GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd); | 456 | int |
457 | GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd); | ||
452 | 458 | ||
453 | 459 | ||
454 | /** | 460 | /** |
@@ -456,7 +462,8 @@ int GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd); | |||
456 | * @param src source string | 462 | * @param src source string |
457 | * @return converted result | 463 | * @return converted result |
458 | */ | 464 | */ |
459 | char *GNUNET_GNSRECORD_string_to_lowercase (const char *src); | 465 | char * |
466 | GNUNET_GNSRECORD_string_to_lowercase (const char *src); | ||
460 | 467 | ||
461 | 468 | ||
462 | /** | 469 | /** |
@@ -468,7 +475,8 @@ char *GNUNET_GNSRECORD_string_to_lowercase (const char *src); | |||
468 | * @return string form; will be overwritten by next call to | 475 | * @return string form; will be overwritten by next call to |
469 | * #GNUNET_GNSRECORD_z2s. | 476 | * #GNUNET_GNSRECORD_z2s. |
470 | */ | 477 | */ |
471 | const char *GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z); | 478 | const char * |
479 | GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z); | ||
472 | 480 | ||
473 | 481 | ||
474 | /** | 482 | /** |
@@ -494,8 +502,9 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); | |||
494 | * @param pkey set to a public key on the eliptic curve | 502 | * @param pkey set to a public key on the eliptic curve |
495 | * @return #GNUNET_SYSERR if @a zkey has the wrong syntax | 503 | * @return #GNUNET_SYSERR if @a zkey has the wrong syntax |
496 | */ | 504 | */ |
497 | int GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | 505 | int |
498 | struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); | 506 | GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, |
507 | struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); | ||
499 | 508 | ||
500 | 509 | ||
501 | /** | 510 | /** |
@@ -505,7 +514,8 @@ int GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | |||
505 | * @param label label of the record | 514 | * @param label label of the record |
506 | * @param query hash to use for the query | 515 | * @param query hash to use for the query |
507 | */ | 516 | */ |
508 | void GNUNET_GNSRECORD_query_from_private_key ( | 517 | void |
518 | GNUNET_GNSRECORD_query_from_private_key ( | ||
509 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, | 519 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, |
510 | struct GNUNET_HashCode *query); | 520 | struct GNUNET_HashCode *query); |
511 | 521 | ||
@@ -517,7 +527,8 @@ void GNUNET_GNSRECORD_query_from_private_key ( | |||
517 | * @param label label of the record | 527 | * @param label label of the record |
518 | * @param query hash to use for the query | 528 | * @param query hash to use for the query |
519 | */ | 529 | */ |
520 | void GNUNET_GNSRECORD_query_from_public_key ( | 530 | void |
531 | GNUNET_GNSRECORD_query_from_public_key ( | ||
521 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, | 532 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, |
522 | struct GNUNET_HashCode *query); | 533 | struct GNUNET_HashCode *query); |
523 | 534 | ||
@@ -531,10 +542,12 @@ void GNUNET_GNSRECORD_query_from_public_key ( | |||
531 | * @param rd record data | 542 | * @param rd record data |
532 | * @param rd_count number of records in @a rd | 543 | * @param rd_count number of records in @a rd |
533 | */ | 544 | */ |
534 | struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create ( | 545 | struct GNUNET_GNSRECORD_Block * |
535 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 546 | GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
536 | struct GNUNET_TIME_Absolute expire, const char *label, | 547 | struct GNUNET_TIME_Absolute expire, |
537 | const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count); | 548 | const char *label, |
549 | const struct GNUNET_GNSRECORD_Data *rd, | ||
550 | unsigned int rd_count); | ||
538 | 551 | ||
539 | 552 | ||
540 | /** | 553 | /** |
@@ -548,10 +561,12 @@ struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create ( | |||
548 | * @param rd record data | 561 | * @param rd record data |
549 | * @param rd_count number of records in @a rd | 562 | * @param rd_count number of records in @a rd |
550 | */ | 563 | */ |
551 | struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create2 ( | 564 | struct GNUNET_GNSRECORD_Block * |
552 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 565 | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
553 | struct GNUNET_TIME_Absolute expire, const char *label, | 566 | struct GNUNET_TIME_Absolute expire, |
554 | const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count); | 567 | const char *label, |
568 | const struct GNUNET_GNSRECORD_Data *rd, | ||
569 | unsigned int rd_count); | ||
555 | 570 | ||
556 | 571 | ||
557 | /** | 572 | /** |
@@ -561,7 +576,8 @@ struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create2 ( | |||
561 | * @param block block to verify | 576 | * @param block block to verify |
562 | * @return #GNUNET_OK if the signature is valid | 577 | * @return #GNUNET_OK if the signature is valid |
563 | */ | 578 | */ |
564 | int GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | 579 | int |
580 | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | ||
565 | 581 | ||
566 | 582 | ||
567 | /** | 583 | /** |
@@ -575,7 +591,8 @@ int GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | |||
575 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was | 591 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was |
576 | * not well-formed | 592 | * not well-formed |
577 | */ | 593 | */ |
578 | int GNUNET_GNSRECORD_block_decrypt ( | 594 | int |
595 | GNUNET_GNSRECORD_block_decrypt ( | ||
579 | const struct GNUNET_GNSRECORD_Block *block, | 596 | const struct GNUNET_GNSRECORD_Block *block, |
580 | const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, | 597 | const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, |
581 | GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls); | 598 | GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls); |
@@ -588,8 +605,9 @@ int GNUNET_GNSRECORD_block_decrypt ( | |||
588 | * @param b another record | 605 | * @param b another record |
589 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. | 606 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. |
590 | */ | 607 | */ |
591 | int GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, | 608 | int |
592 | const struct GNUNET_GNSRECORD_Data *b); | 609 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, |
610 | const struct GNUNET_GNSRECORD_Data *b); | ||
593 | 611 | ||
594 | 612 | ||
595 | /** | 613 | /** |
@@ -601,7 +619,8 @@ int GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, | |||
601 | * @param rd array of records | 619 | * @param rd array of records |
602 | * @return absolute expiration time | 620 | * @return absolute expiration time |
603 | */ | 621 | */ |
604 | struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time ( | 622 | struct GNUNET_TIME_Absolute |
623 | GNUNET_GNSRECORD_record_get_expiration_time ( | ||
605 | unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd); | 624 | unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd); |
606 | 625 | ||
607 | 626 | ||
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index 0e5591d69..1c3b4174d 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -157,7 +157,8 @@ 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 | static void do_cleanup (void *cls) | 160 | static void |
161 | do_cleanup (void *cls) | ||
161 | { | 162 | { |
162 | cleanup_task = NULL; | 163 | cleanup_task = NULL; |
163 | if (NULL != timeout) | 164 | if (NULL != timeout) |
@@ -178,8 +179,8 @@ static void do_cleanup (void *cls) | |||
178 | GNUNET_free (attr_list); | 179 | GNUNET_free (attr_list); |
179 | } | 180 | } |
180 | 181 | ||
181 | static void ticket_issue_cb (void *cls, | 182 | static void |
182 | const struct GNUNET_RECLAIM_Ticket *ticket) | 183 | ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) |
183 | { | 184 | { |
184 | char *ticket_str; | 185 | char *ticket_str; |
185 | reclaim_op = NULL; | 186 | reclaim_op = NULL; |
@@ -192,7 +193,8 @@ static void ticket_issue_cb (void *cls, | |||
192 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 193 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
193 | } | 194 | } |
194 | 195 | ||
195 | static void store_attr_cont (void *cls, int32_t success, const char *emsg) | 196 | static void |
197 | store_attr_cont (void *cls, int32_t success, const char *emsg) | ||
196 | { | 198 | { |
197 | reclaim_op = NULL; | 199 | reclaim_op = NULL; |
198 | if (GNUNET_SYSERR == success) { | 200 | if (GNUNET_SYSERR == success) { |
@@ -201,9 +203,9 @@ static void store_attr_cont (void *cls, int32_t success, const char *emsg) | |||
201 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 203 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
202 | } | 204 | } |
203 | 205 | ||
204 | static void process_attrs (void *cls, | 206 | static void |
205 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 207 | process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
206 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | 208 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
207 | { | 209 | { |
208 | char *value_str; | 210 | char *value_str; |
209 | const char *attr_type; | 211 | const char *attr_type; |
@@ -224,33 +226,45 @@ static void process_attrs (void *cls, | |||
224 | attr_type, attr->version, attr->id); | 226 | attr_type, attr->version, attr->id); |
225 | } | 227 | } |
226 | 228 | ||
227 | static void ticket_iter_err (void *cls) | 229 | static void |
230 | ticket_iter_err (void *cls) | ||
228 | { | 231 | { |
229 | ticket_iterator = NULL; | 232 | ticket_iterator = NULL; |
230 | fprintf (stderr, "Failed to iterate over tickets\n"); | 233 | fprintf (stderr, "Failed to iterate over tickets\n"); |
231 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 234 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
232 | } | 235 | } |
233 | 236 | ||
234 | static void ticket_iter_fin (void *cls) | 237 | static void |
238 | ticket_iter_fin (void *cls) | ||
235 | { | 239 | { |
236 | ticket_iterator = NULL; | 240 | ticket_iterator = NULL; |
237 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 241 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
238 | } | 242 | } |
239 | 243 | ||
240 | static void ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | 244 | static void |
245 | ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | ||
241 | { | 246 | { |
242 | fprintf (stdout, "Found ticket\n"); | 247 | char *aud; |
248 | char *ref; | ||
249 | |||
250 | aud = GNUNET_STRINGS_data_to_string_alloc ( | ||
251 | &ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
252 | ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); | ||
253 | |||
254 | fprintf (stdout, "Ticket ID: %s | Audience: %s\n", ref, aud); | ||
243 | GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); | 255 | GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); |
244 | } | 256 | } |
245 | 257 | ||
246 | static void iter_error (void *cls) | 258 | static void |
259 | iter_error (void *cls) | ||
247 | { | 260 | { |
248 | attr_iterator = NULL; | 261 | attr_iterator = NULL; |
249 | fprintf (stderr, "Failed to iterate over attributes\n"); | 262 | fprintf (stderr, "Failed to iterate over attributes\n"); |
250 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 263 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
251 | } | 264 | } |
252 | 265 | ||
253 | static void timeout_task (void *cls) | 266 | static void |
267 | timeout_task (void *cls) | ||
254 | { | 268 | { |
255 | timeout = NULL; | 269 | timeout = NULL; |
256 | ret = 1; | 270 | ret = 1; |
@@ -259,7 +273,8 @@ static void timeout_task (void *cls) | |||
259 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 273 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
260 | } | 274 | } |
261 | 275 | ||
262 | static void process_rvk (void *cls, int success, const char *msg) | 276 | static void |
277 | process_rvk (void *cls, int success, const char *msg) | ||
263 | { | 278 | { |
264 | reclaim_op = NULL; | 279 | reclaim_op = NULL; |
265 | if (GNUNET_OK != success) { | 280 | if (GNUNET_OK != success) { |
@@ -269,7 +284,8 @@ static void process_rvk (void *cls, int success, const char *msg) | |||
269 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 284 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
270 | } | 285 | } |
271 | 286 | ||
272 | static void iter_finished (void *cls) | 287 | static void |
288 | iter_finished (void *cls) | ||
273 | { | 289 | { |
274 | char *data; | 290 | char *data; |
275 | size_t data_size; | 291 | size_t data_size; |
@@ -325,9 +341,9 @@ static void iter_finished (void *cls) | |||
325 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 341 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
326 | } | 342 | } |
327 | 343 | ||
328 | static void iter_cb (void *cls, | 344 | static void |
329 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 345 | iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
330 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | 346 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
331 | { | 347 | { |
332 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 348 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
333 | char *attrs_tmp; | 349 | char *attrs_tmp; |
@@ -367,7 +383,8 @@ static void iter_cb (void *cls, | |||
367 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); | 383 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); |
368 | } | 384 | } |
369 | 385 | ||
370 | static void start_process () | 386 | static void |
387 | start_process () | ||
371 | { | 388 | { |
372 | if (NULL == pkey) { | 389 | if (NULL == pkey) { |
373 | fprintf (stderr, "Ego %s not found\n", ego_name); | 390 | fprintf (stderr, "Ego %s not found\n", ego_name); |
@@ -402,8 +419,9 @@ static void start_process () | |||
402 | 419 | ||
403 | static int init = GNUNET_YES; | 420 | static int init = GNUNET_YES; |
404 | 421 | ||
405 | static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | 422 | static void |
406 | const char *name) | 423 | ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, |
424 | const char *name) | ||
407 | { | 425 | { |
408 | if (NULL == name) { | 426 | if (NULL == name) { |
409 | if (GNUNET_YES == init) { | 427 | if (GNUNET_YES == init) { |
@@ -418,8 +436,9 @@ static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | |||
418 | } | 436 | } |
419 | 437 | ||
420 | 438 | ||
421 | static void run (void *cls, char *const *args, const char *cfgfile, | 439 | static void |
422 | const struct GNUNET_CONFIGURATION_Handle *c) | 440 | run (void *cls, char *const *args, const char *cfgfile, |
441 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
423 | { | 442 | { |
424 | ret = 0; | 443 | ret = 0; |
425 | if (NULL == ego_name) { | 444 | if (NULL == ego_name) { |
@@ -446,7 +465,8 @@ static void run (void *cls, char *const *args, const char *cfgfile, | |||
446 | } | 465 | } |
447 | 466 | ||
448 | 467 | ||
449 | int main (int argc, char *const argv[]) | 468 | int |
469 | main (int argc, char *const argv[]) | ||
450 | { | 470 | { |
451 | exp_interval = GNUNET_TIME_UNIT_HOURS; | 471 | exp_interval = GNUNET_TIME_UNIT_HOURS; |
452 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 472 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 2c74193d1..2bb4f5a74 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -925,6 +925,7 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
925 | } else { | 925 | } else { |
926 | env = GNUNET_MQ_msg_extra (trm, sizeof (struct GNUNET_RECLAIM_Ticket), | 926 | env = GNUNET_MQ_msg_extra (trm, sizeof (struct GNUNET_RECLAIM_Ticket), |
927 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); | 927 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); |
928 | memcpy (&trm[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket)); | ||
928 | } | 929 | } |
929 | trm->id = htonl (ti->r_id); | 930 | trm->id = htonl (ti->r_id); |
930 | GNUNET_MQ_send (ti->client->mq, env); | 931 | GNUNET_MQ_send (ti->client->mq, env); |
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index 5a3190c7f..4a307e635 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -164,21 +164,6 @@ struct TicketIssueHandle { | |||
164 | struct GNUNET_NAMESTORE_QueueEntry *ns_qe; | 164 | struct GNUNET_NAMESTORE_QueueEntry *ns_qe; |
165 | 165 | ||
166 | /** | 166 | /** |
167 | * Ticket reference list | ||
168 | */ | ||
169 | struct TicketReference *ticket_refs_head; | ||
170 | |||
171 | /** | ||
172 | * Ticket reference list | ||
173 | */ | ||
174 | struct TicketReference *ticket_refs_tail; | ||
175 | |||
176 | /** | ||
177 | * Number of references | ||
178 | */ | ||
179 | uint32_t ticket_ref_num; | ||
180 | |||
181 | /** | ||
182 | * Callback | 167 | * Callback |
183 | */ | 168 | */ |
184 | RECLAIM_TICKETS_TicketResult cb; | 169 | RECLAIM_TICKETS_TicketResult cb; |
@@ -194,19 +179,9 @@ struct TicketIssueHandle { | |||
194 | */ | 179 | */ |
195 | struct RECLAIM_TICKETS_Iterator { | 180 | struct RECLAIM_TICKETS_Iterator { |
196 | /** | 181 | /** |
197 | * Issuer Key | ||
198 | */ | ||
199 | struct GNUNET_CRYPTO_EcdsaPrivateKey identity; | ||
200 | |||
201 | /** | ||
202 | * Issuer pubkey | ||
203 | */ | ||
204 | struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub; | ||
205 | |||
206 | /** | ||
207 | * Namestore queue entry | 182 | * Namestore queue entry |
208 | */ | 183 | */ |
209 | struct GNUNET_NAMESTORE_QueueEntry *ns_qe; | 184 | struct GNUNET_NAMESTORE_ZoneIterator *ns_it; |
210 | 185 | ||
211 | /** | 186 | /** |
212 | * Iter callback | 187 | * Iter callback |
@@ -217,16 +192,6 @@ struct RECLAIM_TICKETS_Iterator { | |||
217 | * Iter cls | 192 | * Iter cls |
218 | */ | 193 | */ |
219 | void *cb_cls; | 194 | void *cb_cls; |
220 | |||
221 | /** | ||
222 | * Ticket reference list | ||
223 | */ | ||
224 | struct TicketReference *tickets_head; | ||
225 | |||
226 | /** | ||
227 | * Ticket reference list | ||
228 | */ | ||
229 | struct TicketReference *tickets_tail; | ||
230 | }; | 195 | }; |
231 | 196 | ||
232 | 197 | ||
@@ -870,113 +835,13 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth) | |||
870 | static void | 835 | static void |
871 | cleanup_issue_handle (struct TicketIssueHandle *handle) | 836 | cleanup_issue_handle (struct TicketIssueHandle *handle) |
872 | { | 837 | { |
873 | struct TicketReference *tr; | ||
874 | struct TicketReference *tr_tmp; | ||
875 | if (NULL != handle->attrs) | ||
876 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (handle->attrs); | ||
877 | if (NULL != handle->ns_qe) | 838 | if (NULL != handle->ns_qe) |
878 | GNUNET_NAMESTORE_cancel (handle->ns_qe); | 839 | GNUNET_NAMESTORE_cancel (handle->ns_qe); |
879 | for (tr = handle->ticket_refs_head; NULL != tr;) { | ||
880 | if (NULL != tr->attrs) | ||
881 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs); | ||
882 | tr_tmp = tr; | ||
883 | tr = tr->next; | ||
884 | GNUNET_free (tr_tmp); | ||
885 | } | ||
886 | GNUNET_free (handle); | 840 | GNUNET_free (handle); |
887 | } | 841 | } |
888 | 842 | ||
889 | 843 | ||
890 | static void | 844 | static void |
891 | store_ticket_refs_cont (void *cls, int32_t success, const char *emsg) | ||
892 | { | ||
893 | struct TicketIssueHandle *handle = cls; | ||
894 | handle->ns_qe = NULL; | ||
895 | if (GNUNET_OK != success) { | ||
896 | handle->cb (handle->cb_cls, NULL, GNUNET_SYSERR, | ||
897 | "Error storing updated ticket refs in GNS"); | ||
898 | cleanup_issue_handle (handle); | ||
899 | return; | ||
900 | } | ||
901 | handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); | ||
902 | cleanup_issue_handle (handle); | ||
903 | } | ||
904 | |||
905 | |||
906 | static void | ||
907 | update_ticket_refs (void *cls) | ||
908 | { | ||
909 | struct TicketIssueHandle *handle = cls; | ||
910 | struct GNUNET_GNSRECORD_Data refs_rd[handle->ticket_ref_num]; | ||
911 | struct TicketReference *tr; | ||
912 | |||
913 | tr = handle->ticket_refs_head; | ||
914 | for (int i = 0; i < handle->ticket_ref_num; i++) { | ||
915 | refs_rd[i].data = &tr->ticket; | ||
916 | refs_rd[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket); | ||
917 | refs_rd[i].expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us; | ||
918 | refs_rd[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF; | ||
919 | refs_rd[i].flags = | ||
920 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | ||
921 | tr = tr->next; | ||
922 | } | ||
923 | |||
924 | handle->ns_qe = GNUNET_NAMESTORE_records_store ( | ||
925 | nsh, &handle->identity, GNUNET_GNS_EMPTY_LABEL_AT, handle->ticket_ref_num, | ||
926 | refs_rd, &store_ticket_refs_cont, handle); | ||
927 | } | ||
928 | |||
929 | |||
930 | static void | ||
931 | ticket_lookup_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
932 | const char *label, unsigned int rd_count, | ||
933 | const struct GNUNET_GNSRECORD_Data *rd) | ||
934 | { | ||
935 | struct TicketIssueHandle *handle = cls; | ||
936 | struct TicketReference *tr; | ||
937 | |||
938 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
939 | "Received tickets from local namestore.\n"); | ||
940 | handle->ns_qe = NULL; | ||
941 | for (int i = 0; i < rd_count; i++) { | ||
942 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF != rd[i].record_type) | ||
943 | continue; | ||
944 | tr = GNUNET_new (struct TicketReference); | ||
945 | memcpy (&tr->ticket, rd[i].data, sizeof (struct GNUNET_RECLAIM_Ticket)); | ||
946 | if (0 != memcmp (&tr->ticket.identity, &handle->ticket.identity, | ||
947 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) { | ||
948 | // Not our ticket | ||
949 | GNUNET_free (tr); | ||
950 | continue; | ||
951 | } | ||
952 | GNUNET_CONTAINER_DLL_insert (handle->ticket_refs_head, | ||
953 | handle->ticket_refs_tail, tr); | ||
954 | handle->ticket_ref_num++; | ||
955 | } | ||
956 | tr = GNUNET_new (struct TicketReference); | ||
957 | tr->ticket = handle->ticket; | ||
958 | tr->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (handle->attrs); | ||
959 | GNUNET_CONTAINER_DLL_insert (handle->ticket_refs_head, | ||
960 | handle->ticket_refs_tail, tr); | ||
961 | handle->ticket_ref_num++; | ||
962 | GNUNET_SCHEDULER_add_now (&update_ticket_refs, handle); | ||
963 | } | ||
964 | |||
965 | |||
966 | /** | ||
967 | * TODO maybe we should cleanup the ATTRREFS here? | ||
968 | */ | ||
969 | static void | ||
970 | ticket_lookup_error_cb (void *cls) | ||
971 | { | ||
972 | struct TicketIssueHandle *handle = cls; | ||
973 | handle->ns_qe = NULL; | ||
974 | handle->cb (handle->cb_cls, &handle->ticket, GNUNET_SYSERR, | ||
975 | "Error checking for ticketsin GNS\n"); | ||
976 | cleanup_issue_handle (handle); | ||
977 | } | ||
978 | |||
979 | static void | ||
980 | store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) | 845 | store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) |
981 | { | 846 | { |
982 | struct TicketIssueHandle *handle = cls; | 847 | struct TicketIssueHandle *handle = cls; |
@@ -987,10 +852,8 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) | |||
987 | "Error storing AuthZ ticket in GNS"); | 852 | "Error storing AuthZ ticket in GNS"); |
988 | return; | 853 | return; |
989 | } | 854 | } |
990 | /* First, local references to tickets */ | 855 | handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); |
991 | handle->ns_qe = GNUNET_NAMESTORE_records_lookup ( | 856 | cleanup_issue_handle (handle); |
992 | nsh, &handle->identity, GNUNET_GNS_EMPTY_LABEL_AT, | ||
993 | &ticket_lookup_error_cb, handle, &ticket_lookup_cb, handle); | ||
994 | } | 857 | } |
995 | 858 | ||
996 | 859 | ||
@@ -1000,7 +863,7 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1000 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 863 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
1001 | struct GNUNET_GNSRECORD_Data *attrs_record; | 864 | struct GNUNET_GNSRECORD_Data *attrs_record; |
1002 | char *label; | 865 | char *label; |
1003 | size_t list_len = 0; | 866 | size_t list_len = 1; |
1004 | int i; | 867 | int i; |
1005 | 868 | ||
1006 | for (le = ih->attrs->list_head; NULL != le; le = le->next) | 869 | for (le = ih->attrs->list_head; NULL != le; le = le->next) |
@@ -1017,6 +880,12 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1017 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 880 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1018 | i++; | 881 | i++; |
1019 | } | 882 | } |
883 | attrs_record[i].data = &ih->ticket; | ||
884 | attrs_record[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket); | ||
885 | attrs_record[i].expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us; | ||
886 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; | ||
887 | attrs_record[i].flags = | ||
888 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | ||
1020 | 889 | ||
1021 | label = | 890 | label = |
1022 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); | 891 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); |
@@ -1055,49 +924,11 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | |||
1055 | static void | 924 | static void |
1056 | cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter) | 925 | cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter) |
1057 | { | 926 | { |
1058 | struct TicketReference *tr; | 927 | if (NULL != iter->ns_it) |
1059 | struct TicketReference *tr_tmp; | 928 | GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it); |
1060 | if (NULL != iter->ns_qe) | ||
1061 | GNUNET_NAMESTORE_cancel (iter->ns_qe); | ||
1062 | for (tr = iter->tickets_head; NULL != tr;) { | ||
1063 | if (NULL != tr->attrs) | ||
1064 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs); | ||
1065 | tr_tmp = tr; | ||
1066 | tr = tr->next; | ||
1067 | GNUNET_free (tr_tmp); | ||
1068 | } | ||
1069 | GNUNET_free (iter); | 929 | GNUNET_free (iter); |
1070 | } | 930 | } |
1071 | 931 | ||
1072 | static void | ||
1073 | do_cleanup_iter (void *cls) | ||
1074 | { | ||
1075 | struct RECLAIM_TICKETS_Iterator *iter = cls; | ||
1076 | cleanup_iter (iter); | ||
1077 | } | ||
1078 | |||
1079 | /** | ||
1080 | * Perform ticket iteration step | ||
1081 | * | ||
1082 | * @param ti ticket iterator to process | ||
1083 | */ | ||
1084 | static void | ||
1085 | run_ticket_iteration_round (struct RECLAIM_TICKETS_Iterator *iter) | ||
1086 | { | ||
1087 | struct TicketReference *tr; | ||
1088 | if (NULL == iter->tickets_head) { | ||
1089 | // No more tickets | ||
1090 | iter->cb (iter->cb_cls, NULL); | ||
1091 | GNUNET_SCHEDULER_add_now (&do_cleanup_iter, iter); | ||
1092 | return; | ||
1093 | } | ||
1094 | tr = iter->tickets_head; | ||
1095 | GNUNET_CONTAINER_DLL_remove (iter->tickets_head, iter->tickets_tail, tr); | ||
1096 | iter->cb (iter->cb_cls, &tr->ticket); | ||
1097 | if (NULL != tr->attrs) | ||
1098 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs); | ||
1099 | GNUNET_free (tr); | ||
1100 | } | ||
1101 | 932 | ||
1102 | static void | 933 | static void |
1103 | collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 934 | collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
@@ -1105,46 +936,52 @@ collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
1105 | const struct GNUNET_GNSRECORD_Data *rd) | 936 | const struct GNUNET_GNSRECORD_Data *rd) |
1106 | { | 937 | { |
1107 | struct RECLAIM_TICKETS_Iterator *iter = cls; | 938 | struct RECLAIM_TICKETS_Iterator *iter = cls; |
1108 | struct TicketReference *tr; | ||
1109 | iter->ns_qe = NULL; | ||
1110 | 939 | ||
1111 | for (int i = 0; i < rd_count; i++) { | 940 | for (int i = 0; i < rd_count; i++) { |
1112 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF != rd[i].record_type) | 941 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) |
1113 | continue; | 942 | continue; |
1114 | tr = GNUNET_new (struct TicketReference); | 943 | iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data); |
1115 | memcpy (&tr->ticket, rd[i].data, sizeof (struct GNUNET_RECLAIM_Ticket)); | 944 | return; |
1116 | if (0 != memcmp (&tr->ticket.identity, &iter->identity_pub, | ||
1117 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) { | ||
1118 | // Not our ticket | ||
1119 | GNUNET_free (tr); | ||
1120 | continue; | ||
1121 | } | ||
1122 | GNUNET_CONTAINER_DLL_insert (iter->tickets_head, iter->tickets_tail, tr); | ||
1123 | } | 945 | } |
1124 | run_ticket_iteration_round (iter); | 946 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); |
1125 | } | 947 | } |
1126 | 948 | ||
949 | |||
950 | static void | ||
951 | collect_tickets_finished_cb (void *cls) | ||
952 | { | ||
953 | struct RECLAIM_TICKETS_Iterator *iter = cls; | ||
954 | iter->ns_it = NULL; | ||
955 | iter->cb (iter->cb_cls, NULL); | ||
956 | cleanup_iter (iter); | ||
957 | } | ||
958 | |||
959 | |||
1127 | static void | 960 | static void |
1128 | collect_tickets_error_cb (void *cls) | 961 | collect_tickets_error_cb (void *cls) |
1129 | { | 962 | { |
1130 | struct RECLAIM_TICKETS_Iterator *iter = cls; | 963 | struct RECLAIM_TICKETS_Iterator *iter = cls; |
1131 | iter->ns_qe = NULL; | 964 | iter->ns_it = NULL; |
1132 | iter->cb (iter->cb_cls, NULL); | 965 | iter->cb (iter->cb_cls, NULL); |
1133 | cleanup_iter (iter); | 966 | cleanup_iter (iter); |
1134 | } | 967 | } |
1135 | 968 | ||
969 | |||
1136 | void | 970 | void |
1137 | RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter) | 971 | RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter) |
1138 | { | 972 | { |
1139 | run_ticket_iteration_round (iter); | 973 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); |
1140 | } | 974 | } |
1141 | 975 | ||
976 | |||
1142 | void | 977 | void |
1143 | RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) | 978 | RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) |
1144 | { | 979 | { |
980 | GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it); | ||
1145 | cleanup_iter (iter); | 981 | cleanup_iter (iter); |
1146 | } | 982 | } |
1147 | 983 | ||
984 | |||
1148 | struct RECLAIM_TICKETS_Iterator * | 985 | struct RECLAIM_TICKETS_Iterator * |
1149 | RECLAIM_TICKETS_iteration_start ( | 986 | RECLAIM_TICKETS_iteration_start ( |
1150 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 987 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
@@ -1153,13 +990,11 @@ RECLAIM_TICKETS_iteration_start ( | |||
1153 | struct RECLAIM_TICKETS_Iterator *iter; | 990 | struct RECLAIM_TICKETS_Iterator *iter; |
1154 | 991 | ||
1155 | iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator); | 992 | iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator); |
1156 | iter->identity = *identity; | ||
1157 | GNUNET_CRYPTO_ecdsa_key_get_public (identity, &iter->identity_pub); | ||
1158 | iter->cb = cb; | 993 | iter->cb = cb; |
1159 | iter->cb_cls = cb_cls; | 994 | iter->cb_cls = cb_cls; |
1160 | iter->ns_qe = GNUNET_NAMESTORE_records_lookup ( | 995 | iter->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( |
1161 | nsh, identity, GNUNET_GNS_EMPTY_LABEL_AT, &collect_tickets_error_cb, iter, | 996 | nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter, |
1162 | &collect_tickets_cb, iter); | 997 | &collect_tickets_finished_cb, iter); |
1163 | return iter; | 998 | return iter; |
1164 | } | 999 | } |
1165 | 1000 | ||
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c index 612fec3bd..48cdd9811 100644 --- a/src/reclaim/plugin_gnsrecord_reclaim.c +++ b/src/reclaim/plugin_gnsrecord_reclaim.c | |||
@@ -39,8 +39,8 @@ | |||
39 | * @param data_size number of bytes in @a data | 39 | * @param data_size number of bytes in @a data |
40 | * @return NULL on error, otherwise human-readable representation of the value | 40 | * @return NULL on error, otherwise human-readable representation of the value |
41 | */ | 41 | */ |
42 | static char *value_to_string (void *cls, uint32_t type, const void *data, | 42 | static char * |
43 | size_t data_size) | 43 | value_to_string (void *cls, uint32_t type, const void *data, size_t data_size) |
44 | { | 44 | { |
45 | switch (type) { | 45 | switch (type) { |
46 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: | 46 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: |
@@ -49,7 +49,7 @@ static char *value_to_string (void *cls, uint32_t type, const void *data, | |||
49 | case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: | 49 | case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: |
50 | return GNUNET_strndup (data, data_size); | 50 | return GNUNET_strndup (data, data_size); |
51 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: | 51 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: |
52 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF: | 52 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: |
53 | case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: | 53 | case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: |
54 | return GNUNET_STRINGS_data_to_string_alloc (data, data_size); | 54 | return GNUNET_STRINGS_data_to_string_alloc (data, data_size); |
55 | default: | 55 | default: |
@@ -69,8 +69,9 @@ static char *value_to_string (void *cls, uint32_t type, const void *data, | |||
69 | * @param data_size set to number of bytes in @a data | 69 | * @param data_size set to number of bytes in @a data |
70 | * @return #GNUNET_OK on success | 70 | * @return #GNUNET_OK on success |
71 | */ | 71 | */ |
72 | static int string_to_value (void *cls, uint32_t type, const char *s, | 72 | static int |
73 | void **data, size_t *data_size) | 73 | string_to_value (void *cls, uint32_t type, const char *s, void **data, |
74 | size_t *data_size) | ||
74 | { | 75 | { |
75 | if (NULL == s) | 76 | if (NULL == s) |
76 | return GNUNET_SYSERR; | 77 | return GNUNET_SYSERR; |
@@ -84,7 +85,7 @@ static int string_to_value (void *cls, uint32_t type, const char *s, | |||
84 | return GNUNET_OK; | 85 | return GNUNET_OK; |
85 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: | 86 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: |
86 | case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: | 87 | case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: |
87 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF: | 88 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: |
88 | return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size); | 89 | return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size); |
89 | default: | 90 | default: |
90 | return GNUNET_SYSERR; | 91 | return GNUNET_SYSERR; |
@@ -105,7 +106,7 @@ static struct { | |||
105 | {"RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER}, | 106 | {"RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER}, |
106 | {"RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT}, | 107 | {"RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT}, |
107 | {"RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT}, | 108 | {"RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT}, |
108 | {"RECLAIM_TICKETREF", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF}, | 109 | {"RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET}, |
109 | {NULL, UINT32_MAX}}; | 110 | {NULL, UINT32_MAX}}; |
110 | 111 | ||
111 | 112 | ||
@@ -116,7 +117,8 @@ static struct { | |||
116 | * @param dns_typename name to convert | 117 | * @param dns_typename name to convert |
117 | * @return corresponding number, UINT32_MAX on error | 118 | * @return corresponding number, UINT32_MAX on error |
118 | */ | 119 | */ |
119 | static uint32_t typename_to_number (void *cls, const char *dns_typename) | 120 | static uint32_t |
121 | typename_to_number (void *cls, const char *dns_typename) | ||
120 | { | 122 | { |
121 | unsigned int i; | 123 | unsigned int i; |
122 | 124 | ||
@@ -135,7 +137,8 @@ static uint32_t typename_to_number (void *cls, const char *dns_typename) | |||
135 | * @param type number of a type to convert | 137 | * @param type number of a type to convert |
136 | * @return corresponding typestring, NULL on error | 138 | * @return corresponding typestring, NULL on error |
137 | */ | 139 | */ |
138 | static const char *number_to_typename (void *cls, uint32_t type) | 140 | static const char * |
141 | number_to_typename (void *cls, uint32_t type) | ||
139 | { | 142 | { |
140 | unsigned int i; | 143 | unsigned int i; |
141 | 144 | ||
@@ -152,7 +155,8 @@ static const char *number_to_typename (void *cls, uint32_t type) | |||
152 | * @param cls NULL | 155 | * @param cls NULL |
153 | * @return the exported block API | 156 | * @return the exported block API |
154 | */ | 157 | */ |
155 | void *libgnunet_plugin_gnsrecord_reclaim_init (void *cls) | 158 | void * |
159 | libgnunet_plugin_gnsrecord_reclaim_init (void *cls) | ||
156 | { | 160 | { |
157 | struct GNUNET_GNSRECORD_PluginFunctions *api; | 161 | struct GNUNET_GNSRECORD_PluginFunctions *api; |
158 | 162 | ||
@@ -171,7 +175,8 @@ void *libgnunet_plugin_gnsrecord_reclaim_init (void *cls) | |||
171 | * @param cls the return value from #libgnunet_plugin_block_test_init | 175 | * @param cls the return value from #libgnunet_plugin_block_test_init |
172 | * @return NULL | 176 | * @return NULL |
173 | */ | 177 | */ |
174 | void *libgnunet_plugin_gnsrecord_reclaim_done (void *cls) | 178 | void * |
179 | libgnunet_plugin_gnsrecord_reclaim_done (void *cls) | ||
175 | { | 180 | { |
176 | struct GNUNET_GNSRECORD_PluginFunctions *api = cls; | 181 | struct GNUNET_GNSRECORD_PluginFunctions *api = cls; |
177 | 182 | ||