diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/reclaim/gnunet-service-reclaim_tickets.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 1154 |
1 files changed, 584 insertions, 570 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index fcfb2267d..b38a5eb25 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Martin Schanzenbach | 22 | * @author Martin Schanzenbach |
@@ -44,8 +44,7 @@ struct ParallelLookup; | |||
44 | /** | 44 | /** |
45 | * A reference to a ticket stored in GNS | 45 | * A reference to a ticket stored in GNS |
46 | */ | 46 | */ |
47 | struct TicketReference | 47 | struct TicketReference { |
48 | { | ||
49 | /** | 48 | /** |
50 | * DLL | 49 | * DLL |
51 | */ | 50 | */ |
@@ -71,8 +70,7 @@ struct TicketReference | |||
71 | /** | 70 | /** |
72 | * Handle to a consume operation | 71 | * Handle to a consume operation |
73 | */ | 72 | */ |
74 | struct RECLAIM_TICKETS_ConsumeHandle | 73 | struct RECLAIM_TICKETS_ConsumeHandle { |
75 | { | ||
76 | /** | 74 | /** |
77 | * Ticket | 75 | * Ticket |
78 | */ | 76 | */ |
@@ -133,8 +131,7 @@ struct RECLAIM_TICKETS_ConsumeHandle | |||
133 | /** | 131 | /** |
134 | * Handle for a parallel GNS lookup job | 132 | * Handle for a parallel GNS lookup job |
135 | */ | 133 | */ |
136 | struct ParallelLookup | 134 | struct ParallelLookup { |
137 | { | ||
138 | /* DLL */ | 135 | /* DLL */ |
139 | struct ParallelLookup *next; | 136 | struct ParallelLookup *next; |
140 | 137 | ||
@@ -160,8 +157,7 @@ struct ParallelLookup | |||
160 | /** | 157 | /** |
161 | * Ticket issue request handle | 158 | * Ticket issue request handle |
162 | */ | 159 | */ |
163 | struct TicketIssueHandle | 160 | struct TicketIssueHandle { |
164 | { | ||
165 | /** | 161 | /** |
166 | * Attributes to issue | 162 | * Attributes to issue |
167 | */ | 163 | */ |
@@ -202,8 +198,7 @@ struct TicketIssueHandle | |||
202 | /** | 198 | /** |
203 | * Ticket iterator | 199 | * Ticket iterator |
204 | */ | 200 | */ |
205 | struct RECLAIM_TICKETS_Iterator | 201 | struct RECLAIM_TICKETS_Iterator { |
206 | { | ||
207 | /** | 202 | /** |
208 | * Namestore queue entry | 203 | * Namestore queue entry |
209 | */ | 204 | */ |
@@ -221,8 +216,7 @@ struct RECLAIM_TICKETS_Iterator | |||
221 | }; | 216 | }; |
222 | 217 | ||
223 | 218 | ||
224 | struct RevokedAttributeEntry | 219 | struct RevokedAttributeEntry { |
225 | { | ||
226 | /** | 220 | /** |
227 | * DLL | 221 | * DLL |
228 | */ | 222 | */ |
@@ -248,8 +242,7 @@ struct RevokedAttributeEntry | |||
248 | /** | 242 | /** |
249 | * Ticket revocation request handle | 243 | * Ticket revocation request handle |
250 | */ | 244 | */ |
251 | struct RECLAIM_TICKETS_RevokeHandle | 245 | struct RECLAIM_TICKETS_RevokeHandle { |
252 | { | ||
253 | /** | 246 | /** |
254 | * Issuer Key | 247 | * Issuer Key |
255 | */ | 248 | */ |
@@ -337,31 +330,32 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
337 | * @param rh the ticket revocation handle | 330 | * @param rh the ticket revocation handle |
338 | */ | 331 | */ |
339 | static void | 332 | static void |
340 | cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh) | 333 | cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh) |
341 | { | 334 | { |
342 | struct RevokedAttributeEntry *ae; | 335 | struct RevokedAttributeEntry *ae; |
343 | struct TicketRecordsEntry *le; | 336 | struct TicketRecordsEntry *le; |
337 | |||
344 | if (NULL != rh->ns_qe) | 338 | if (NULL != rh->ns_qe) |
345 | GNUNET_NAMESTORE_cancel (rh->ns_qe); | 339 | GNUNET_NAMESTORE_cancel(rh->ns_qe); |
346 | if (NULL != rh->ns_it) | 340 | if (NULL != rh->ns_it) |
347 | GNUNET_NAMESTORE_zone_iteration_stop (rh->ns_it); | 341 | GNUNET_NAMESTORE_zone_iteration_stop(rh->ns_it); |
348 | while (NULL != (ae = rh->attrs_head)) | 342 | while (NULL != (ae = rh->attrs_head)) |
349 | { | 343 | { |
350 | GNUNET_CONTAINER_DLL_remove (rh->attrs_head, rh->attrs_tail, ae); | 344 | GNUNET_CONTAINER_DLL_remove(rh->attrs_head, rh->attrs_tail, ae); |
351 | GNUNET_free (ae); | 345 | GNUNET_free(ae); |
352 | } | 346 | } |
353 | while (NULL != (le = rh->tickets_to_update_head)) | 347 | while (NULL != (le = rh->tickets_to_update_head)) |
354 | { | 348 | { |
355 | GNUNET_CONTAINER_DLL_remove (rh->tickets_to_update_head, | 349 | GNUNET_CONTAINER_DLL_remove(rh->tickets_to_update_head, |
356 | rh->tickets_to_update_head, | 350 | rh->tickets_to_update_head, |
357 | le); | 351 | le); |
358 | if (NULL != le->data) | 352 | if (NULL != le->data) |
359 | GNUNET_free (le->data); | 353 | GNUNET_free(le->data); |
360 | if (NULL != le->label) | 354 | if (NULL != le->label) |
361 | GNUNET_free (le->label); | 355 | GNUNET_free(le->label); |
362 | GNUNET_free (le); | 356 | GNUNET_free(le); |
363 | } | 357 | } |
364 | GNUNET_free (rh); | 358 | GNUNET_free(rh); |
365 | } | 359 | } |
366 | 360 | ||
367 | 361 | ||
@@ -372,7 +366,7 @@ cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh) | |||
372 | * @param cls handle to the operation | 366 | * @param cls handle to the operation |
373 | */ | 367 | */ |
374 | static void | 368 | static void |
375 | process_tickets (void *cls); | 369 | process_tickets(void *cls); |
376 | 370 | ||
377 | 371 | ||
378 | /** | 372 | /** |
@@ -384,11 +378,12 @@ process_tickets (void *cls); | |||
384 | * @param emsg (NULL on success) | 378 | * @param emsg (NULL on success) |
385 | */ | 379 | */ |
386 | static void | 380 | static void |
387 | ticket_processed (void *cls, int32_t success, const char *emsg) | 381 | ticket_processed(void *cls, int32_t success, const char *emsg) |
388 | { | 382 | { |
389 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 383 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
384 | |||
390 | rvk->ns_qe = NULL; | 385 | rvk->ns_qe = NULL; |
391 | GNUNET_SCHEDULER_add_now (&process_tickets, rvk); | 386 | GNUNET_SCHEDULER_add_now(&process_tickets, rvk); |
392 | } | 387 | } |
393 | 388 | ||
394 | 389 | ||
@@ -398,56 +393,57 @@ ticket_processed (void *cls, int32_t success, const char *emsg) | |||
398 | * @param cls handle to the operation | 393 | * @param cls handle to the operation |
399 | */ | 394 | */ |
400 | static void | 395 | static void |
401 | process_tickets (void *cls) | 396 | process_tickets(void *cls) |
402 | { | 397 | { |
403 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 398 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
404 | struct TicketRecordsEntry *le; | 399 | struct TicketRecordsEntry *le; |
405 | struct RevokedAttributeEntry *ae; | 400 | struct RevokedAttributeEntry *ae; |
401 | |||
406 | if (NULL == rvk->tickets_to_update_head) | 402 | if (NULL == rvk->tickets_to_update_head) |
407 | { | 403 | { |
408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 404 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
409 | "Finished updatding tickets, success\n"); | 405 | "Finished updatding tickets, success\n"); |
410 | rvk->cb (rvk->cb_cls, GNUNET_OK); | 406 | rvk->cb(rvk->cb_cls, GNUNET_OK); |
411 | cleanup_rvk (rvk); | 407 | cleanup_rvk(rvk); |
412 | return; | 408 | return; |
413 | } | 409 | } |
414 | le = rvk->tickets_to_update_head; | 410 | le = rvk->tickets_to_update_head; |
415 | GNUNET_CONTAINER_DLL_remove (rvk->tickets_to_update_head, | 411 | GNUNET_CONTAINER_DLL_remove(rvk->tickets_to_update_head, |
416 | rvk->tickets_to_update_tail, | 412 | rvk->tickets_to_update_tail, |
417 | le); | 413 | le); |
418 | struct GNUNET_GNSRECORD_Data rd[le->rd_count]; | 414 | struct GNUNET_GNSRECORD_Data rd[le->rd_count]; |
419 | if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (le->data_size, | 415 | if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize(le->data_size, |
420 | le->data, | 416 | le->data, |
421 | le->rd_count, | 417 | le->rd_count, |
422 | rd)) | 418 | rd)) |
423 | { | 419 | { |
424 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 420 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
425 | "Unable to deserialize ticket record(s)\n"); | 421 | "Unable to deserialize ticket record(s)\n"); |
426 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 422 | rvk->cb(rvk->cb_cls, GNUNET_SYSERR); |
427 | cleanup_rvk (rvk); | 423 | cleanup_rvk(rvk); |
428 | return; | 424 | return; |
429 | } | 425 | } |
430 | for (int i = 0; i < le->rd_count; i++) | 426 | for (int i = 0; i < le->rd_count; i++) |
431 | { | ||
432 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | ||
433 | continue; | ||
434 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) | ||
435 | { | 427 | { |
436 | if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t))) | 428 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
437 | continue; | 429 | continue; |
438 | rd[i].data = &ae->new_id; | 430 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) |
431 | { | ||
432 | if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t))) | ||
433 | continue; | ||
434 | rd[i].data = &ae->new_id; | ||
435 | } | ||
439 | } | 436 | } |
440 | } | 437 | rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, |
441 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 438 | &rvk->identity, |
442 | &rvk->identity, | 439 | le->label, |
443 | le->label, | 440 | le->rd_count, |
444 | le->rd_count, | 441 | rd, |
445 | rd, | 442 | &ticket_processed, |
446 | &ticket_processed, | 443 | rvk); |
447 | rvk); | 444 | GNUNET_free(le->label); |
448 | GNUNET_free (le->label); | 445 | GNUNET_free(le->data); |
449 | GNUNET_free (le->data); | 446 | GNUNET_free(le); |
450 | GNUNET_free (le); | ||
451 | } | 447 | } |
452 | 448 | ||
453 | 449 | ||
@@ -457,11 +453,12 @@ process_tickets (void *cls) | |||
457 | * @param cls handle to the operation | 453 | * @param cls handle to the operation |
458 | */ | 454 | */ |
459 | static void | 455 | static void |
460 | rvk_ticket_update_finished (void *cls) | 456 | rvk_ticket_update_finished(void *cls) |
461 | { | 457 | { |
462 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 458 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
459 | |||
463 | rvk->ns_it = NULL; | 460 | rvk->ns_it = NULL; |
464 | GNUNET_SCHEDULER_add_now (&process_tickets, rvk); | 461 | GNUNET_SCHEDULER_add_now(&process_tickets, rvk); |
465 | } | 462 | } |
466 | 463 | ||
467 | 464 | ||
@@ -476,11 +473,11 @@ rvk_ticket_update_finished (void *cls) | |||
476 | * @param rd record set | 473 | * @param rd record set |
477 | */ | 474 | */ |
478 | static void | 475 | static void |
479 | rvk_ticket_update (void *cls, | 476 | rvk_ticket_update(void *cls, |
480 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 477 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
481 | const char *label, | 478 | const char *label, |
482 | unsigned int rd_count, | 479 | unsigned int rd_count, |
483 | const struct GNUNET_GNSRECORD_Data *rd) | 480 | const struct GNUNET_GNSRECORD_Data *rd) |
484 | { | 481 | { |
485 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 482 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
486 | struct TicketRecordsEntry *le; | 483 | struct TicketRecordsEntry *le; |
@@ -489,32 +486,32 @@ rvk_ticket_update (void *cls, | |||
489 | 486 | ||
490 | /** Let everything point to the old record **/ | 487 | /** Let everything point to the old record **/ |
491 | for (int i = 0; i < rd_count; i++) | 488 | for (int i = 0; i < rd_count; i++) |
492 | { | ||
493 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | ||
494 | continue; | ||
495 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) | ||
496 | { | 489 | { |
497 | if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t))) | 490 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
498 | continue; | 491 | continue; |
499 | has_changed = GNUNET_YES; | 492 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) |
500 | break; | 493 | { |
494 | if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t))) | ||
495 | continue; | ||
496 | has_changed = GNUNET_YES; | ||
497 | break; | ||
498 | } | ||
499 | if (GNUNET_YES == has_changed) | ||
500 | break; | ||
501 | } | 501 | } |
502 | if (GNUNET_YES == has_changed) | ||
503 | break; | ||
504 | } | ||
505 | if (GNUNET_YES == has_changed) | 502 | if (GNUNET_YES == has_changed) |
506 | { | 503 | { |
507 | le = GNUNET_new (struct TicketRecordsEntry); | 504 | le = GNUNET_new(struct TicketRecordsEntry); |
508 | le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | 505 | le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd); |
509 | le->data = GNUNET_malloc (le->data_size); | 506 | le->data = GNUNET_malloc(le->data_size); |
510 | le->rd_count = rd_count; | 507 | le->rd_count = rd_count; |
511 | le->label = GNUNET_strdup (label); | 508 | le->label = GNUNET_strdup(label); |
512 | GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data); | 509 | GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data); |
513 | GNUNET_CONTAINER_DLL_insert (rvk->tickets_to_update_head, | 510 | GNUNET_CONTAINER_DLL_insert(rvk->tickets_to_update_head, |
514 | rvk->tickets_to_update_tail, | 511 | rvk->tickets_to_update_tail, |
515 | le); | 512 | le); |
516 | } | 513 | } |
517 | GNUNET_NAMESTORE_zone_iterator_next (rvk->ns_it, 1); | 514 | GNUNET_NAMESTORE_zone_iterator_next(rvk->ns_it, 1); |
518 | } | 515 | } |
519 | 516 | ||
520 | 517 | ||
@@ -524,15 +521,16 @@ rvk_ticket_update (void *cls, | |||
524 | * @param cls handle to the operation | 521 | * @param cls handle to the operation |
525 | */ | 522 | */ |
526 | static void | 523 | static void |
527 | rvk_ns_iter_err (void *cls) | 524 | rvk_ns_iter_err(void *cls) |
528 | { | 525 | { |
529 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 526 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
527 | |||
530 | rvk->ns_it = NULL; | 528 | rvk->ns_it = NULL; |
531 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 529 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
532 | "Namestore error on revocation (id=%" PRIu64 "\n", | 530 | "Namestore error on revocation (id=%" PRIu64 "\n", |
533 | rvk->move_attr->old_id); | 531 | rvk->move_attr->old_id); |
534 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 532 | rvk->cb(rvk->cb_cls, GNUNET_SYSERR); |
535 | cleanup_rvk (rvk); | 533 | cleanup_rvk(rvk); |
536 | } | 534 | } |
537 | 535 | ||
538 | 536 | ||
@@ -542,15 +540,16 @@ rvk_ns_iter_err (void *cls) | |||
542 | * @param cls handle to the operation | 540 | * @param cls handle to the operation |
543 | */ | 541 | */ |
544 | static void | 542 | static void |
545 | rvk_ns_err (void *cls) | 543 | rvk_ns_err(void *cls) |
546 | { | 544 | { |
547 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 545 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
546 | |||
548 | rvk->ns_qe = NULL; | 547 | rvk->ns_qe = NULL; |
549 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 548 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
550 | "Namestore error on revocation (id=%" PRIu64 "\n", | 549 | "Namestore error on revocation (id=%" PRIu64 "\n", |
551 | rvk->move_attr->old_id); | 550 | rvk->move_attr->old_id); |
552 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 551 | rvk->cb(rvk->cb_cls, GNUNET_SYSERR); |
553 | cleanup_rvk (rvk); | 552 | cleanup_rvk(rvk); |
554 | } | 553 | } |
555 | 554 | ||
556 | 555 | ||
@@ -564,7 +563,7 @@ rvk_ns_err (void *cls) | |||
564 | * @param rvk handle to the operation | 563 | * @param rvk handle to the operation |
565 | */ | 564 | */ |
566 | static void | 565 | static void |
567 | move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rh); | 566 | move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh); |
568 | 567 | ||
569 | 568 | ||
570 | /** | 569 | /** |
@@ -573,9 +572,9 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rh); | |||
573 | * @param cls handle to the operation. | 572 | * @param cls handle to the operation. |
574 | */ | 573 | */ |
575 | static void | 574 | static void |
576 | move_attrs_cont (void *cls) | 575 | move_attrs_cont(void *cls) |
577 | { | 576 | { |
578 | move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls); | 577 | move_attrs((struct RECLAIM_TICKETS_RevokeHandle *)cls); |
579 | } | 578 | } |
580 | 579 | ||
581 | 580 | ||
@@ -588,21 +587,22 @@ move_attrs_cont (void *cls) | |||
588 | * @param emsg error message (NULL on success) | 587 | * @param emsg error message (NULL on success) |
589 | */ | 588 | */ |
590 | static void | 589 | static void |
591 | del_attr_finished (void *cls, int32_t success, const char *emsg) | 590 | del_attr_finished(void *cls, int32_t success, const char *emsg) |
592 | { | 591 | { |
593 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 592 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
593 | |||
594 | rvk->ns_qe = NULL; | 594 | rvk->ns_qe = NULL; |
595 | if (GNUNET_SYSERR == success) | 595 | if (GNUNET_SYSERR == success) |
596 | { | 596 | { |
597 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 597 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
598 | "Error removing attribute: %s\n", | 598 | "Error removing attribute: %s\n", |
599 | emsg); | 599 | emsg); |
600 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 600 | rvk->cb(rvk->cb_cls, GNUNET_SYSERR); |
601 | cleanup_rvk (rvk); | 601 | cleanup_rvk(rvk); |
602 | return; | 602 | return; |
603 | } | 603 | } |
604 | rvk->move_attr = rvk->move_attr->next; | 604 | rvk->move_attr = rvk->move_attr->next; |
605 | GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk); | 605 | GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); |
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
@@ -616,30 +616,31 @@ del_attr_finished (void *cls, int32_t success, const char *emsg) | |||
616 | * @param emsg error message (NULL on success) | 616 | * @param emsg error message (NULL on success) |
617 | */ | 617 | */ |
618 | static void | 618 | static void |
619 | move_attr_finished (void *cls, int32_t success, const char *emsg) | 619 | move_attr_finished(void *cls, int32_t success, const char *emsg) |
620 | { | 620 | { |
621 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 621 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
622 | char *label; | 622 | char *label; |
623 | |||
623 | rvk->ns_qe = NULL; | 624 | rvk->ns_qe = NULL; |
624 | if (GNUNET_SYSERR == success) | 625 | if (GNUNET_SYSERR == success) |
625 | { | 626 | { |
626 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); | 627 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); |
627 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 628 | rvk->cb(rvk->cb_cls, GNUNET_SYSERR); |
628 | cleanup_rvk (rvk); | 629 | cleanup_rvk(rvk); |
629 | return; | 630 | return; |
630 | } | 631 | } |
631 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, | 632 | label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, |
632 | sizeof (uint64_t)); | 633 | sizeof(uint64_t)); |
633 | GNUNET_assert (NULL != label); | 634 | GNUNET_assert(NULL != label); |
634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); | 635 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); |
635 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 636 | rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, |
636 | &rvk->identity, | 637 | &rvk->identity, |
637 | label, | 638 | label, |
638 | 0, | 639 | 0, |
639 | NULL, | 640 | NULL, |
640 | &del_attr_finished, | 641 | &del_attr_finished, |
641 | rvk); | 642 | rvk); |
642 | GNUNET_free (label); | 643 | GNUNET_free(label); |
643 | } | 644 | } |
644 | 645 | ||
645 | 646 | ||
@@ -653,11 +654,11 @@ move_attr_finished (void *cls, int32_t success, const char *emsg) | |||
653 | * @param rd record set (the attribute) | 654 | * @param rd record set (the attribute) |
654 | */ | 655 | */ |
655 | static void | 656 | static void |
656 | rvk_move_attr_cb (void *cls, | 657 | rvk_move_attr_cb(void *cls, |
657 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 658 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
658 | const char *label, | 659 | const char *label, |
659 | unsigned int rd_count, | 660 | unsigned int rd_count, |
660 | const struct GNUNET_GNSRECORD_Data *rd) | 661 | const struct GNUNET_GNSRECORD_Data *rd) |
661 | { | 662 | { |
662 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 663 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
663 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 664 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
@@ -665,46 +666,47 @@ rvk_move_attr_cb (void *cls, | |||
665 | struct RevokedAttributeEntry *le; | 666 | struct RevokedAttributeEntry *le; |
666 | char *new_label; | 667 | char *new_label; |
667 | char *attr_data; | 668 | char *attr_data; |
669 | |||
668 | rvk->ns_qe = NULL; | 670 | rvk->ns_qe = NULL; |
669 | if (0 == rd_count) | 671 | if (0 == rd_count) |
670 | { | 672 | { |
671 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 673 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
672 | "The attribute %s no longer exists!\n", | 674 | "The attribute %s no longer exists!\n", |
673 | label); | 675 | label); |
674 | le = rvk->move_attr; | 676 | le = rvk->move_attr; |
675 | rvk->move_attr = le->next; | 677 | rvk->move_attr = le->next; |
676 | GNUNET_CONTAINER_DLL_remove (rvk->attrs_head, rvk->attrs_tail, le); | 678 | GNUNET_CONTAINER_DLL_remove(rvk->attrs_head, rvk->attrs_tail, le); |
677 | GNUNET_free (le); | 679 | GNUNET_free(le); |
678 | GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk); | 680 | GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); |
679 | return; | 681 | return; |
680 | } | 682 | } |
681 | /** find a new place for this attribute **/ | 683 | /** find a new place for this attribute **/ |
682 | rvk->move_attr->new_id = | 684 | rvk->move_attr->new_id = |
683 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 685 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); |
684 | new_rd = *rd; | 686 | new_rd = *rd; |
685 | claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); | 687 | claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize(rd->data, rd->data_size); |
686 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 688 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
687 | "Attribute to update: Name=%s, ID=%" PRIu64 "\n", | 689 | "Attribute to update: Name=%s, ID=%" PRIu64 "\n", |
688 | claim->name, | 690 | claim->name, |
689 | claim->id); | 691 | claim->id); |
690 | claim->id = rvk->move_attr->new_id; | 692 | claim->id = rvk->move_attr->new_id; |
691 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); | 693 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(claim); |
692 | attr_data = GNUNET_malloc (rd->data_size); | 694 | attr_data = GNUNET_malloc(rd->data_size); |
693 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data); | 695 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize(claim, attr_data); |
694 | new_rd.data = attr_data; | 696 | new_rd.data = attr_data; |
695 | new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, | 697 | new_label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->new_id, |
696 | sizeof (uint64_t)); | 698 | sizeof(uint64_t)); |
697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); | 699 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); |
698 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 700 | rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, |
699 | &rvk->identity, | 701 | &rvk->identity, |
700 | new_label, | 702 | new_label, |
701 | 1, | 703 | 1, |
702 | &new_rd, | 704 | &new_rd, |
703 | &move_attr_finished, | 705 | &move_attr_finished, |
704 | rvk); | 706 | rvk); |
705 | GNUNET_free (new_label); | 707 | GNUNET_free(new_label); |
706 | GNUNET_free (claim); | 708 | GNUNET_free(claim); |
707 | GNUNET_free (attr_data); | 709 | GNUNET_free(attr_data); |
708 | } | 710 | } |
709 | 711 | ||
710 | 712 | ||
@@ -717,36 +719,36 @@ rvk_move_attr_cb (void *cls, | |||
717 | * @param rvk handle to the operation | 719 | * @param rvk handle to the operation |
718 | */ | 720 | */ |
719 | static void | 721 | static void |
720 | move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) | 722 | move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rvk) |
721 | { | 723 | { |
722 | char *label; | 724 | char *label; |
723 | 725 | ||
724 | if (NULL == rvk->move_attr) | 726 | if (NULL == rvk->move_attr) |
725 | { | 727 | { |
726 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); | 728 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); |
727 | rvk->ns_it = | 729 | rvk->ns_it = |
728 | GNUNET_NAMESTORE_zone_iteration_start (nsh, | 730 | GNUNET_NAMESTORE_zone_iteration_start(nsh, |
729 | &rvk->identity, | 731 | &rvk->identity, |
730 | &rvk_ns_iter_err, | 732 | &rvk_ns_iter_err, |
731 | rvk, | 733 | rvk, |
732 | &rvk_ticket_update, | 734 | &rvk_ticket_update, |
733 | rvk, | 735 | rvk, |
734 | &rvk_ticket_update_finished, | 736 | &rvk_ticket_update_finished, |
735 | rvk); | 737 | rvk); |
736 | return; | 738 | return; |
737 | } | 739 | } |
738 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, | 740 | label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, |
739 | sizeof (uint64_t)); | 741 | sizeof(uint64_t)); |
740 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); | 742 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); |
741 | 743 | ||
742 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | 744 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup(nsh, |
743 | &rvk->identity, | 745 | &rvk->identity, |
744 | label, | 746 | label, |
745 | &rvk_ns_err, | 747 | &rvk_ns_err, |
746 | rvk, | 748 | rvk, |
747 | &rvk_move_attr_cb, | 749 | &rvk_move_attr_cb, |
748 | rvk); | 750 | rvk); |
749 | GNUNET_free (label); | 751 | GNUNET_free(label); |
750 | } | 752 | } |
751 | 753 | ||
752 | 754 | ||
@@ -762,28 +764,29 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) | |||
762 | * @param emsg error message (NULL on success) | 764 | * @param emsg error message (NULL on success) |
763 | */ | 765 | */ |
764 | static void | 766 | static void |
765 | remove_ticket_cont (void *cls, int32_t success, const char *emsg) | 767 | remove_ticket_cont(void *cls, int32_t success, const char *emsg) |
766 | { | 768 | { |
767 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 769 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
770 | |||
768 | rvk->ns_qe = NULL; | 771 | rvk->ns_qe = NULL; |
769 | if (GNUNET_SYSERR == success) | 772 | if (GNUNET_SYSERR == success) |
770 | { | 773 | { |
771 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); | 774 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); |
772 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 775 | rvk->cb(rvk->cb_cls, GNUNET_SYSERR); |
773 | cleanup_rvk (rvk); | 776 | cleanup_rvk(rvk); |
774 | return; | 777 | return; |
775 | } | 778 | } |
776 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); | 779 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); |
777 | if (0 == rvk->ticket_attrs) | 780 | if (0 == rvk->ticket_attrs) |
778 | { | 781 | { |
779 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 782 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
780 | "No attributes to move... strange\n"); | 783 | "No attributes to move... strange\n"); |
781 | rvk->cb (rvk->cb_cls, GNUNET_OK); | 784 | rvk->cb(rvk->cb_cls, GNUNET_OK); |
782 | cleanup_rvk (rvk); | 785 | cleanup_rvk(rvk); |
783 | return; | 786 | return; |
784 | } | 787 | } |
785 | rvk->move_attr = rvk->attrs_head; | 788 | rvk->move_attr = rvk->attrs_head; |
786 | move_attrs (rvk); | 789 | move_attrs(rvk); |
787 | } | 790 | } |
788 | 791 | ||
789 | 792 | ||
@@ -798,38 +801,39 @@ remove_ticket_cont (void *cls, int32_t success, const char *emsg) | |||
798 | * @param rd record set | 801 | * @param rd record set |
799 | */ | 802 | */ |
800 | static void | 803 | static void |
801 | revoke_attrs_cb (void *cls, | 804 | revoke_attrs_cb(void *cls, |
802 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 805 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
803 | const char *label, | 806 | const char *label, |
804 | unsigned int rd_count, | 807 | unsigned int rd_count, |
805 | const struct GNUNET_GNSRECORD_Data *rd) | 808 | const struct GNUNET_GNSRECORD_Data *rd) |
806 | 809 | ||
807 | { | 810 | { |
808 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 811 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
809 | struct RevokedAttributeEntry *le; | 812 | struct RevokedAttributeEntry *le; |
813 | |||
810 | rvk->ns_qe = NULL; | 814 | rvk->ns_qe = NULL; |
811 | /** | 815 | /** |
812 | * Temporarily store attribute references. | 816 | * Temporarily store attribute references. |
813 | * We need it later. | 817 | * We need it later. |
814 | */ | 818 | */ |
815 | for (int i = 0; i < rd_count; i++) | 819 | for (int i = 0; i < rd_count; i++) |
816 | { | 820 | { |
817 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 821 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
818 | continue; | 822 | continue; |
819 | le = GNUNET_new (struct RevokedAttributeEntry); | 823 | le = GNUNET_new(struct RevokedAttributeEntry); |
820 | le->old_id = *((uint64_t *) rd[i].data); | 824 | le->old_id = *((uint64_t *)rd[i].data); |
821 | GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le); | 825 | GNUNET_CONTAINER_DLL_insert(rvk->attrs_head, rvk->attrs_tail, le); |
822 | rvk->ticket_attrs++; | 826 | rvk->ticket_attrs++; |
823 | } | 827 | } |
824 | 828 | ||
825 | /** Remove attribute references **/ | 829 | /** Remove attribute references **/ |
826 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 830 | rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, |
827 | &rvk->identity, | 831 | &rvk->identity, |
828 | label, | 832 | label, |
829 | 0, | 833 | 0, |
830 | NULL, | 834 | NULL, |
831 | &remove_ticket_cont, | 835 | &remove_ticket_cont, |
832 | rvk); | 836 | rvk); |
833 | } | 837 | } |
834 | 838 | ||
835 | 839 | ||
@@ -839,11 +843,12 @@ revoke_attrs_cb (void *cls, | |||
839 | * @param cls handle to the operation | 843 | * @param cls handle to the operation |
840 | */ | 844 | */ |
841 | static void | 845 | static void |
842 | rvk_attrs_err_cb (void *cls) | 846 | rvk_attrs_err_cb(void *cls) |
843 | { | 847 | { |
844 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 848 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
845 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 849 | |
846 | cleanup_rvk (rvk); | 850 | rvk->cb(rvk->cb_cls, GNUNET_SYSERR); |
851 | cleanup_rvk(rvk); | ||
847 | } | 852 | } |
848 | 853 | ||
849 | 854 | ||
@@ -859,31 +864,31 @@ rvk_attrs_err_cb (void *cls) | |||
859 | * @return handle to the operation | 864 | * @return handle to the operation |
860 | */ | 865 | */ |
861 | struct RECLAIM_TICKETS_RevokeHandle * | 866 | struct RECLAIM_TICKETS_RevokeHandle * |
862 | RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, | 867 | RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, |
863 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 868 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
864 | RECLAIM_TICKETS_RevokeCallback cb, | 869 | RECLAIM_TICKETS_RevokeCallback cb, |
865 | void *cb_cls) | 870 | void *cb_cls) |
866 | { | 871 | { |
867 | struct RECLAIM_TICKETS_RevokeHandle *rvk; | 872 | struct RECLAIM_TICKETS_RevokeHandle *rvk; |
868 | char *label; | 873 | char *label; |
869 | 874 | ||
870 | rvk = GNUNET_new (struct RECLAIM_TICKETS_RevokeHandle); | 875 | rvk = GNUNET_new(struct RECLAIM_TICKETS_RevokeHandle); |
871 | rvk->cb = cb; | 876 | rvk->cb = cb; |
872 | rvk->cb_cls = cb_cls; | 877 | rvk->cb_cls = cb_cls; |
873 | rvk->identity = *identity; | 878 | rvk->identity = *identity; |
874 | rvk->ticket = *ticket; | 879 | rvk->ticket = *ticket; |
875 | GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity); | 880 | GNUNET_CRYPTO_ecdsa_key_get_public(&rvk->identity, &rvk->ticket.identity); |
876 | /** Get shared attributes **/ | 881 | /** Get shared attributes **/ |
877 | label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); | 882 | label = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); |
878 | GNUNET_assert (NULL != label); | 883 | GNUNET_assert(NULL != label); |
879 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | 884 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup(nsh, |
880 | identity, | 885 | identity, |
881 | label, | 886 | label, |
882 | &rvk_attrs_err_cb, | 887 | &rvk_attrs_err_cb, |
883 | rvk, | 888 | rvk, |
884 | &revoke_attrs_cb, | 889 | &revoke_attrs_cb, |
885 | rvk); | 890 | rvk); |
886 | GNUNET_free (label); | 891 | GNUNET_free(label); |
887 | return rvk; | 892 | return rvk; |
888 | } | 893 | } |
889 | 894 | ||
@@ -894,16 +899,16 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, | |||
894 | * @param rh handle to the operation | 899 | * @param rh handle to the operation |
895 | */ | 900 | */ |
896 | void | 901 | void |
897 | RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh) | 902 | RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh) |
898 | { | 903 | { |
899 | GNUNET_assert (NULL != rh); | 904 | GNUNET_assert(NULL != rh); |
900 | cleanup_rvk (rh); | 905 | cleanup_rvk(rh); |
901 | } | 906 | } |
902 | 907 | ||
903 | 908 | ||
904 | /******************************* | 909 | /******************************* |
905 | * Ticket consume | 910 | * Ticket consume |
906 | *******************************/ | 911 | *******************************/ |
907 | 912 | ||
908 | /** | 913 | /** |
909 | * Cleanup ticket consume handle | 914 | * Cleanup ticket consume handle |
@@ -911,27 +916,28 @@ RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh) | |||
911 | * @param cth the handle to clean up | 916 | * @param cth the handle to clean up |
912 | */ | 917 | */ |
913 | static void | 918 | static void |
914 | cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) | 919 | cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth) |
915 | { | 920 | { |
916 | struct ParallelLookup *lu; | 921 | struct ParallelLookup *lu; |
922 | |||
917 | if (NULL != cth->lookup_request) | 923 | if (NULL != cth->lookup_request) |
918 | GNUNET_GNS_lookup_cancel (cth->lookup_request); | 924 | GNUNET_GNS_lookup_cancel(cth->lookup_request); |
919 | if (NULL != cth->kill_task) | 925 | if (NULL != cth->kill_task) |
920 | GNUNET_SCHEDULER_cancel (cth->kill_task); | 926 | GNUNET_SCHEDULER_cancel(cth->kill_task); |
921 | while (NULL != (lu = cth->parallel_lookups_head)) | 927 | while (NULL != (lu = cth->parallel_lookups_head)) |
922 | { | 928 | { |
923 | if (NULL != lu->lookup_request) | 929 | if (NULL != lu->lookup_request) |
924 | GNUNET_GNS_lookup_cancel (lu->lookup_request); | 930 | GNUNET_GNS_lookup_cancel(lu->lookup_request); |
925 | GNUNET_free_non_null (lu->label); | 931 | GNUNET_free_non_null(lu->label); |
926 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 932 | GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, |
927 | cth->parallel_lookups_tail, | 933 | cth->parallel_lookups_tail, |
928 | lu); | 934 | lu); |
929 | GNUNET_free (lu); | 935 | GNUNET_free(lu); |
930 | } | 936 | } |
931 | 937 | ||
932 | if (NULL != cth->attrs) | 938 | if (NULL != cth->attrs) |
933 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cth->attrs); | 939 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy(cth->attrs); |
934 | GNUNET_free (cth); | 940 | GNUNET_free(cth); |
935 | } | 941 | } |
936 | 942 | ||
937 | 943 | ||
@@ -943,50 +949,51 @@ cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) | |||
943 | * @param rd record set | 949 | * @param rd record set |
944 | */ | 950 | */ |
945 | static void | 951 | static void |
946 | process_parallel_lookup_result (void *cls, | 952 | process_parallel_lookup_result(void *cls, |
947 | uint32_t rd_count, | 953 | uint32_t rd_count, |
948 | const struct GNUNET_GNSRECORD_Data *rd) | 954 | const struct GNUNET_GNSRECORD_Data *rd) |
949 | { | 955 | { |
950 | struct ParallelLookup *parallel_lookup = cls; | 956 | struct ParallelLookup *parallel_lookup = cls; |
951 | struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; | 957 | struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; |
952 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; | 958 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; |
953 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
954 | "Parallel lookup finished (count=%u)\n", | ||
955 | rd_count); | ||
956 | 959 | ||
957 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 960 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
958 | cth->parallel_lookups_tail, | 961 | "Parallel lookup finished (count=%u)\n", |
959 | parallel_lookup); | 962 | rd_count); |
960 | GNUNET_free (parallel_lookup->label); | 963 | |
964 | GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, | ||
965 | cth->parallel_lookups_tail, | ||
966 | parallel_lookup); | ||
967 | GNUNET_free(parallel_lookup->label); | ||
961 | 968 | ||
962 | GNUNET_STATISTICS_update (stats, | 969 | GNUNET_STATISTICS_update(stats, |
963 | "attribute_lookup_time_total", | 970 | "attribute_lookup_time_total", |
964 | GNUNET_TIME_absolute_get_duration ( | 971 | GNUNET_TIME_absolute_get_duration( |
965 | parallel_lookup->lookup_start_time) | 972 | parallel_lookup->lookup_start_time) |
966 | .rel_value_us, | 973 | .rel_value_us, |
967 | GNUNET_YES); | 974 | GNUNET_YES); |
968 | GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES); | 975 | GNUNET_STATISTICS_update(stats, "attribute_lookups_count", 1, GNUNET_YES); |
969 | 976 | ||
970 | 977 | ||
971 | GNUNET_free (parallel_lookup); | 978 | GNUNET_free(parallel_lookup); |
972 | if (1 != rd_count) | 979 | if (1 != rd_count) |
973 | GNUNET_break (0); // FIXME: We should never find this. | 980 | GNUNET_break(0); // FIXME: We should never find this. |
974 | if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) | 981 | if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) |
975 | { | 982 | { |
976 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 983 | attr_le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
977 | attr_le->claim = | 984 | attr_le->claim = |
978 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); | 985 | GNUNET_RECLAIM_ATTRIBUTE_deserialize(rd->data, rd->data_size); |
979 | GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, | 986 | GNUNET_CONTAINER_DLL_insert(cth->attrs->list_head, |
980 | cth->attrs->list_tail, | 987 | cth->attrs->list_tail, |
981 | attr_le); | 988 | attr_le); |
982 | } | 989 | } |
983 | 990 | ||
984 | if (NULL != cth->parallel_lookups_head) | 991 | if (NULL != cth->parallel_lookups_head) |
985 | return; // Wait for more | 992 | return; // Wait for more |
986 | 993 | ||
987 | /* Else we are done */ | 994 | /* Else we are done */ |
988 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); | 995 | cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); |
989 | cleanup_cth (cth); | 996 | cleanup_cth(cth); |
990 | } | 997 | } |
991 | 998 | ||
992 | 999 | ||
@@ -996,7 +1003,7 @@ process_parallel_lookup_result (void *cls, | |||
996 | * @param cls handle to the operation | 1003 | * @param cls handle to the operation |
997 | */ | 1004 | */ |
998 | static void | 1005 | static void |
999 | abort_parallel_lookups (void *cls) | 1006 | abort_parallel_lookups(void *cls) |
1000 | { | 1007 | { |
1001 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; | 1008 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; |
1002 | struct ParallelLookup *lu; | 1009 | struct ParallelLookup *lu; |
@@ -1004,17 +1011,17 @@ abort_parallel_lookups (void *cls) | |||
1004 | 1011 | ||
1005 | cth->kill_task = NULL; | 1012 | cth->kill_task = NULL; |
1006 | for (lu = cth->parallel_lookups_head; NULL != lu;) | 1013 | for (lu = cth->parallel_lookups_head; NULL != lu;) |
1007 | { | 1014 | { |
1008 | GNUNET_GNS_lookup_cancel (lu->lookup_request); | 1015 | GNUNET_GNS_lookup_cancel(lu->lookup_request); |
1009 | GNUNET_free (lu->label); | 1016 | GNUNET_free(lu->label); |
1010 | tmp = lu->next; | 1017 | tmp = lu->next; |
1011 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 1018 | GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, |
1012 | cth->parallel_lookups_tail, | 1019 | cth->parallel_lookups_tail, |
1013 | lu); | 1020 | lu); |
1014 | GNUNET_free (lu); | 1021 | GNUNET_free(lu); |
1015 | lu = tmp; | 1022 | lu = tmp; |
1016 | } | 1023 | } |
1017 | cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); | 1024 | cth->cb(cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); |
1018 | } | 1025 | } |
1019 | 1026 | ||
1020 | 1027 | ||
@@ -1028,9 +1035,9 @@ abort_parallel_lookups (void *cls) | |||
1028 | * @param rd record set | 1035 | * @param rd record set |
1029 | */ | 1036 | */ |
1030 | static void | 1037 | static void |
1031 | lookup_authz_cb (void *cls, | 1038 | lookup_authz_cb(void *cls, |
1032 | uint32_t rd_count, | 1039 | uint32_t rd_count, |
1033 | const struct GNUNET_GNSRECORD_Data *rd) | 1040 | const struct GNUNET_GNSRECORD_Data *rd) |
1034 | { | 1041 | { |
1035 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; | 1042 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; |
1036 | struct ParallelLookup *parallel_lookup; | 1043 | struct ParallelLookup *parallel_lookup; |
@@ -1038,56 +1045,56 @@ lookup_authz_cb (void *cls, | |||
1038 | 1045 | ||
1039 | cth->lookup_request = NULL; | 1046 | cth->lookup_request = NULL; |
1040 | 1047 | ||
1041 | GNUNET_STATISTICS_update (stats, | 1048 | GNUNET_STATISTICS_update(stats, |
1042 | "reclaim_authz_lookup_time_total", | 1049 | "reclaim_authz_lookup_time_total", |
1043 | GNUNET_TIME_absolute_get_duration ( | 1050 | GNUNET_TIME_absolute_get_duration( |
1044 | cth->lookup_start_time) | 1051 | cth->lookup_start_time) |
1045 | .rel_value_us, | 1052 | .rel_value_us, |
1046 | GNUNET_YES); | 1053 | GNUNET_YES); |
1047 | GNUNET_STATISTICS_update (stats, | 1054 | GNUNET_STATISTICS_update(stats, |
1048 | "reclaim_authz_lookups_count", | 1055 | "reclaim_authz_lookups_count", |
1049 | 1, | 1056 | 1, |
1050 | GNUNET_YES); | 1057 | GNUNET_YES); |
1051 | 1058 | ||
1052 | for (int i = 0; i < rd_count; i++) | 1059 | for (int i = 0; i < rd_count; i++) |
1053 | { | 1060 | { |
1054 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 1061 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
1055 | continue; | 1062 | continue; |
1056 | lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); | 1063 | lbl = GNUNET_STRINGS_data_to_string_alloc(rd[i].data, rd[i].data_size); |
1057 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); | 1064 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); |
1058 | parallel_lookup = GNUNET_new (struct ParallelLookup); | 1065 | parallel_lookup = GNUNET_new(struct ParallelLookup); |
1059 | parallel_lookup->handle = cth; | 1066 | parallel_lookup->handle = cth; |
1060 | parallel_lookup->label = lbl; | 1067 | parallel_lookup->label = lbl; |
1061 | parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); | 1068 | parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get(); |
1062 | parallel_lookup->lookup_request = | 1069 | parallel_lookup->lookup_request = |
1063 | GNUNET_GNS_lookup (gns, | 1070 | GNUNET_GNS_lookup(gns, |
1064 | lbl, | 1071 | lbl, |
1065 | &cth->ticket.identity, | 1072 | &cth->ticket.identity, |
1066 | GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, | 1073 | GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, |
1067 | GNUNET_GNS_LO_DEFAULT, | 1074 | GNUNET_GNS_LO_DEFAULT, |
1068 | &process_parallel_lookup_result, | 1075 | &process_parallel_lookup_result, |
1069 | parallel_lookup); | 1076 | parallel_lookup); |
1070 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, | 1077 | GNUNET_CONTAINER_DLL_insert(cth->parallel_lookups_head, |
1071 | cth->parallel_lookups_tail, | 1078 | cth->parallel_lookups_tail, |
1072 | parallel_lookup); | 1079 | parallel_lookup); |
1073 | } | 1080 | } |
1074 | /** | 1081 | /** |
1075 | * We started lookups. Add a timeout task. | 1082 | * We started lookups. Add a timeout task. |
1076 | * FIXME: Really needed here? | 1083 | * FIXME: Really needed here? |
1077 | */ | 1084 | */ |
1078 | if (NULL != cth->parallel_lookups_head) | 1085 | if (NULL != cth->parallel_lookups_head) |
1079 | { | 1086 | { |
1080 | cth->kill_task = GNUNET_SCHEDULER_add_delayed ( | 1087 | cth->kill_task = GNUNET_SCHEDULER_add_delayed( |
1081 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), | 1088 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 3), |
1082 | &abort_parallel_lookups, | 1089 | &abort_parallel_lookups, |
1083 | cth); | 1090 | cth); |
1084 | return; | 1091 | return; |
1085 | } | 1092 | } |
1086 | /** | 1093 | /** |
1087 | * No references found, return empty attribute list | 1094 | * No references found, return empty attribute list |
1088 | */ | 1095 | */ |
1089 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); | 1096 | cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); |
1090 | cleanup_cth (cth); | 1097 | cleanup_cth(cth); |
1091 | } | 1098 | } |
1092 | 1099 | ||
1093 | 1100 | ||
@@ -1103,36 +1110,37 @@ lookup_authz_cb (void *cls, | |||
1103 | * @return handle to the operation | 1110 | * @return handle to the operation |
1104 | */ | 1111 | */ |
1105 | struct RECLAIM_TICKETS_ConsumeHandle * | 1112 | struct RECLAIM_TICKETS_ConsumeHandle * |
1106 | RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | 1113 | RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, |
1107 | const struct GNUNET_RECLAIM_Ticket *ticket, | 1114 | const struct GNUNET_RECLAIM_Ticket *ticket, |
1108 | RECLAIM_TICKETS_ConsumeCallback cb, | 1115 | RECLAIM_TICKETS_ConsumeCallback cb, |
1109 | void *cb_cls) | 1116 | void *cb_cls) |
1110 | { | 1117 | { |
1111 | struct RECLAIM_TICKETS_ConsumeHandle *cth; | 1118 | struct RECLAIM_TICKETS_ConsumeHandle *cth; |
1112 | char *label; | 1119 | char *label; |
1113 | cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle); | 1120 | |
1121 | cth = GNUNET_new(struct RECLAIM_TICKETS_ConsumeHandle); | ||
1114 | 1122 | ||
1115 | cth->identity = *id; | 1123 | cth->identity = *id; |
1116 | GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); | 1124 | GNUNET_CRYPTO_ecdsa_key_get_public(&cth->identity, &cth->identity_pub); |
1117 | cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); | 1125 | cth->attrs = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
1118 | cth->ticket = *ticket; | 1126 | cth->ticket = *ticket; |
1119 | cth->cb = cb; | 1127 | cth->cb = cb; |
1120 | cth->cb_cls = cb_cls; | 1128 | cth->cb_cls = cb_cls; |
1121 | label = | 1129 | label = |
1122 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); | 1130 | GNUNET_STRINGS_data_to_string_alloc(&cth->ticket.rnd, sizeof(uint64_t)); |
1123 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1131 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1124 | "Looking for AuthZ info under %s\n", | 1132 | "Looking for AuthZ info under %s\n", |
1125 | label); | 1133 | label); |
1126 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); | 1134 | cth->lookup_start_time = GNUNET_TIME_absolute_get(); |
1127 | cth->lookup_request = | 1135 | cth->lookup_request = |
1128 | GNUNET_GNS_lookup (gns, | 1136 | GNUNET_GNS_lookup(gns, |
1129 | label, | 1137 | label, |
1130 | &cth->ticket.identity, | 1138 | &cth->ticket.identity, |
1131 | GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, | 1139 | GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, |
1132 | GNUNET_GNS_LO_DEFAULT, | 1140 | GNUNET_GNS_LO_DEFAULT, |
1133 | &lookup_authz_cb, | 1141 | &lookup_authz_cb, |
1134 | cth); | 1142 | cth); |
1135 | GNUNET_free (label); | 1143 | GNUNET_free(label); |
1136 | return cth; | 1144 | return cth; |
1137 | } | 1145 | } |
1138 | 1146 | ||
@@ -1143,27 +1151,27 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | |||
1143 | * @param cth the operation to cancel | 1151 | * @param cth the operation to cancel |
1144 | */ | 1152 | */ |
1145 | void | 1153 | void |
1146 | RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth) | 1154 | RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth) |
1147 | { | 1155 | { |
1148 | cleanup_cth (cth); | 1156 | cleanup_cth(cth); |
1149 | return; | 1157 | return; |
1150 | } | 1158 | } |
1151 | 1159 | ||
1152 | 1160 | ||
1153 | /******************************* | 1161 | /******************************* |
1154 | * Ticket issue | 1162 | * Ticket issue |
1155 | *******************************/ | 1163 | *******************************/ |
1156 | 1164 | ||
1157 | /** | 1165 | /** |
1158 | * Cleanup ticket consume handle | 1166 | * Cleanup ticket consume handle |
1159 | * @param handle the handle to clean up | 1167 | * @param handle the handle to clean up |
1160 | */ | 1168 | */ |
1161 | static void | 1169 | static void |
1162 | cleanup_issue_handle (struct TicketIssueHandle *handle) | 1170 | cleanup_issue_handle(struct TicketIssueHandle *handle) |
1163 | { | 1171 | { |
1164 | if (NULL != handle->ns_qe) | 1172 | if (NULL != handle->ns_qe) |
1165 | GNUNET_NAMESTORE_cancel (handle->ns_qe); | 1173 | GNUNET_NAMESTORE_cancel(handle->ns_qe); |
1166 | GNUNET_free (handle); | 1174 | GNUNET_free(handle); |
1167 | } | 1175 | } |
1168 | 1176 | ||
1169 | 1177 | ||
@@ -1176,21 +1184,21 @@ cleanup_issue_handle (struct TicketIssueHandle *handle) | |||
1176 | * @param emsg error message (or NULL on success) | 1184 | * @param emsg error message (or NULL on success) |
1177 | */ | 1185 | */ |
1178 | static void | 1186 | static void |
1179 | store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) | 1187 | store_ticket_issue_cont(void *cls, int32_t success, const char *emsg) |
1180 | { | 1188 | { |
1181 | struct TicketIssueHandle *handle = cls; | 1189 | struct TicketIssueHandle *handle = cls; |
1182 | 1190 | ||
1183 | handle->ns_qe = NULL; | 1191 | handle->ns_qe = NULL; |
1184 | if (GNUNET_SYSERR == success) | 1192 | if (GNUNET_SYSERR == success) |
1185 | { | 1193 | { |
1186 | handle->cb (handle->cb_cls, | 1194 | handle->cb(handle->cb_cls, |
1187 | &handle->ticket, | 1195 | &handle->ticket, |
1188 | GNUNET_SYSERR, | 1196 | GNUNET_SYSERR, |
1189 | "Error storing AuthZ ticket in GNS"); | 1197 | "Error storing AuthZ ticket in GNS"); |
1190 | return; | 1198 | return; |
1191 | } | 1199 | } |
1192 | handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); | 1200 | handle->cb(handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); |
1193 | cleanup_issue_handle (handle); | 1201 | cleanup_issue_handle(handle); |
1194 | } | 1202 | } |
1195 | 1203 | ||
1196 | 1204 | ||
@@ -1202,7 +1210,7 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) | |||
1202 | * @param ih handle to the operation containing relevant metadata | 1210 | * @param ih handle to the operation containing relevant metadata |
1203 | */ | 1211 | */ |
1204 | static void | 1212 | static void |
1205 | issue_ticket (struct TicketIssueHandle *ih) | 1213 | issue_ticket(struct TicketIssueHandle *ih) |
1206 | { | 1214 | { |
1207 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 1215 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
1208 | struct GNUNET_GNSRECORD_Data *attrs_record; | 1216 | struct GNUNET_GNSRECORD_Data *attrs_record; |
@@ -1214,45 +1222,45 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1214 | list_len++; | 1222 | list_len++; |
1215 | 1223 | ||
1216 | attrs_record = | 1224 | attrs_record = |
1217 | GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data)); | 1225 | GNUNET_malloc(list_len * sizeof(struct GNUNET_GNSRECORD_Data)); |
1218 | i = 0; | 1226 | i = 0; |
1219 | for (le = ih->attrs->list_head; NULL != le; le = le->next) | 1227 | for (le = ih->attrs->list_head; NULL != le; le = le->next) |
1220 | { | 1228 | { |
1221 | attrs_record[i].data = &le->claim->id; | 1229 | attrs_record[i].data = &le->claim->id; |
1222 | attrs_record[i].data_size = sizeof (le->claim->id); | 1230 | attrs_record[i].data_size = sizeof(le->claim->id); |
1223 | /** | 1231 | /** |
1224 | * FIXME: Should this be the attribute expiration time or ticket | 1232 | * FIXME: Should this be the attribute expiration time or ticket |
1225 | * refresh interval? Probably min(attrs.expiration) | 1233 | * refresh interval? Probably min(attrs.expiration) |
1226 | */ | 1234 | */ |
1227 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; | 1235 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; |
1228 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; | 1236 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; |
1229 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1237 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1230 | i++; | 1238 | i++; |
1231 | } | 1239 | } |
1232 | attrs_record[i].data = &ih->ticket; | 1240 | attrs_record[i].data = &ih->ticket; |
1233 | attrs_record[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket); | 1241 | attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket); |
1234 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; | 1242 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; |
1235 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; | 1243 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; |
1236 | attrs_record[i].flags = | 1244 | attrs_record[i].flags = |
1237 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | 1245 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; |
1238 | 1246 | ||
1239 | label = | 1247 | label = |
1240 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); | 1248 | GNUNET_STRINGS_data_to_string_alloc(&ih->ticket.rnd, sizeof(uint64_t)); |
1241 | // Publish record | 1249 | // Publish record |
1242 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1250 | ih->ns_qe = GNUNET_NAMESTORE_records_store(nsh, |
1243 | &ih->identity, | 1251 | &ih->identity, |
1244 | label, | 1252 | label, |
1245 | list_len, | 1253 | list_len, |
1246 | attrs_record, | 1254 | attrs_record, |
1247 | &store_ticket_issue_cont, | 1255 | &store_ticket_issue_cont, |
1248 | ih); | 1256 | ih); |
1249 | GNUNET_free (attrs_record); | 1257 | GNUNET_free(attrs_record); |
1250 | GNUNET_free (label); | 1258 | GNUNET_free(label); |
1251 | } | 1259 | } |
1252 | 1260 | ||
1253 | /************************************************* | 1261 | /************************************************* |
1254 | * Ticket iteration (finding a specific ticket) | 1262 | * Ticket iteration (finding a specific ticket) |
1255 | *************************************************/ | 1263 | *************************************************/ |
1256 | 1264 | ||
1257 | 1265 | ||
1258 | /** | 1266 | /** |
@@ -1261,15 +1269,16 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1261 | * @param cls handle to the operation | 1269 | * @param cls handle to the operation |
1262 | */ | 1270 | */ |
1263 | static void | 1271 | static void |
1264 | filter_tickets_error_cb (void *cls) | 1272 | filter_tickets_error_cb(void *cls) |
1265 | { | 1273 | { |
1266 | struct TicketIssueHandle *tih = cls; | 1274 | struct TicketIssueHandle *tih = cls; |
1275 | |||
1267 | tih->ns_it = NULL; | 1276 | tih->ns_it = NULL; |
1268 | tih->cb (tih->cb_cls, | 1277 | tih->cb(tih->cb_cls, |
1269 | &tih->ticket, | 1278 | &tih->ticket, |
1270 | GNUNET_SYSERR, | 1279 | GNUNET_SYSERR, |
1271 | "Error storing AuthZ ticket in GNS"); | 1280 | "Error storing AuthZ ticket in GNS"); |
1272 | cleanup_issue_handle (tih); | 1281 | cleanup_issue_handle(tih); |
1273 | } | 1282 | } |
1274 | 1283 | ||
1275 | 1284 | ||
@@ -1286,11 +1295,11 @@ filter_tickets_error_cb (void *cls) | |||
1286 | * @param rd record set | 1295 | * @param rd record set |
1287 | */ | 1296 | */ |
1288 | static void | 1297 | static void |
1289 | filter_tickets_cb (void *cls, | 1298 | filter_tickets_cb(void *cls, |
1290 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1299 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
1291 | const char *label, | 1300 | const char *label, |
1292 | unsigned int rd_count, | 1301 | unsigned int rd_count, |
1293 | const struct GNUNET_GNSRECORD_Data *rd) | 1302 | const struct GNUNET_GNSRECORD_Data *rd) |
1294 | { | 1303 | { |
1295 | struct TicketIssueHandle *tih = cls; | 1304 | struct TicketIssueHandle *tih = cls; |
1296 | struct GNUNET_RECLAIM_Ticket *ticket = NULL; | 1305 | struct GNUNET_RECLAIM_Ticket *ticket = NULL; |
@@ -1298,6 +1307,7 @@ filter_tickets_cb (void *cls, | |||
1298 | // figure out the number of requested attributes | 1307 | // figure out the number of requested attributes |
1299 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 1308 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
1300 | unsigned int attr_cnt = 0; | 1309 | unsigned int attr_cnt = 0; |
1310 | |||
1301 | for (le = tih->attrs->list_head; NULL != le; le = le->next) | 1311 | for (le = tih->attrs->list_head; NULL != le; le = le->next) |
1302 | attr_cnt++; | 1312 | attr_cnt++; |
1303 | 1313 | ||
@@ -1305,53 +1315,53 @@ filter_tickets_cb (void *cls, | |||
1305 | unsigned int found_attrs_cnt = 0; | 1315 | unsigned int found_attrs_cnt = 0; |
1306 | 1316 | ||
1307 | for (int i = 0; i < rd_count; i++) | 1317 | for (int i = 0; i < rd_count; i++) |
1308 | { | ||
1309 | // found ticket | ||
1310 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) | ||
1311 | { | 1318 | { |
1312 | ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data; | 1319 | // found ticket |
1313 | // cmp audience | 1320 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) |
1314 | if (0 == memcmp (&tih->ticket.audience, | 1321 | { |
1315 | &ticket->audience, | 1322 | ticket = (struct GNUNET_RECLAIM_Ticket *)rd[i].data; |
1316 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 1323 | // cmp audience |
1317 | { | 1324 | if (0 == memcmp(&tih->ticket.audience, |
1318 | tih->ticket = *ticket; | 1325 | &ticket->audience, |
1326 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
1327 | { | ||
1328 | tih->ticket = *ticket; | ||
1329 | continue; | ||
1330 | } | ||
1331 | ticket = NULL; | ||
1332 | } | ||
1333 | |||
1334 | // cmp requested attributes with ticket attributes | ||
1335 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | ||
1319 | continue; | 1336 | continue; |
1320 | } | 1337 | for (le = tih->attrs->list_head; NULL != le; le = le->next) |
1321 | ticket = NULL; | 1338 | { |
1322 | } | 1339 | // cmp attr_ref id with requested attr id |
1323 | 1340 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | |
1324 | // cmp requested attributes with ticket attributes | 1341 | " %" PRIu64 "\n %" PRIu64 "\n", |
1325 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 1342 | *((uint64_t *)rd[i].data), |
1326 | continue; | 1343 | le->claim->id); |
1327 | for (le = tih->attrs->list_head; NULL != le; le = le->next) | 1344 | |
1328 | { | 1345 | |
1329 | // cmp attr_ref id with requested attr id | 1346 | if (0 == memcmp(rd[i].data, &le->claim->id, sizeof(uint64_t))) |
1330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1347 | found_attrs_cnt++; |
1331 | " %" PRIu64 "\n %" PRIu64 "\n", | 1348 | } |
1332 | *((uint64_t *) rd[i].data), | ||
1333 | le->claim->id); | ||
1334 | |||
1335 | |||
1336 | if (0 == memcmp (rd[i].data, &le->claim->id, sizeof (uint64_t))) | ||
1337 | found_attrs_cnt++; | ||
1338 | } | 1349 | } |
1339 | } | ||
1340 | 1350 | ||
1341 | /** | 1351 | /** |
1342 | * If we found a matching ticket, return that to the caller and | 1352 | * If we found a matching ticket, return that to the caller and |
1343 | * we are done. | 1353 | * we are done. |
1344 | */ | 1354 | */ |
1345 | if (attr_cnt == found_attrs_cnt && NULL != ticket) | 1355 | if (attr_cnt == found_attrs_cnt && NULL != ticket) |
1346 | { | 1356 | { |
1347 | GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); | 1357 | GNUNET_NAMESTORE_zone_iteration_stop(tih->ns_it); |
1348 | tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); | 1358 | tih->cb(tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); |
1349 | cleanup_issue_handle (tih); | 1359 | cleanup_issue_handle(tih); |
1350 | return; | 1360 | return; |
1351 | } | 1361 | } |
1352 | 1362 | ||
1353 | // ticket not found in current record, checking next record set | 1363 | // ticket not found in current record, checking next record set |
1354 | GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1); | 1364 | GNUNET_NAMESTORE_zone_iterator_next(tih->ns_it, 1); |
1355 | } | 1365 | } |
1356 | 1366 | ||
1357 | 1367 | ||
@@ -1363,13 +1373,14 @@ filter_tickets_cb (void *cls, | |||
1363 | * @param cls handle to the operation | 1373 | * @param cls handle to the operation |
1364 | */ | 1374 | */ |
1365 | static void | 1375 | static void |
1366 | filter_tickets_finished_cb (void *cls) | 1376 | filter_tickets_finished_cb(void *cls) |
1367 | { | 1377 | { |
1368 | struct TicketIssueHandle *tih = cls; | 1378 | struct TicketIssueHandle *tih = cls; |
1369 | GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity); | 1379 | |
1380 | GNUNET_CRYPTO_ecdsa_key_get_public(&tih->identity, &tih->ticket.identity); | ||
1370 | tih->ticket.rnd = | 1381 | tih->ticket.rnd = |
1371 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 1382 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); |
1372 | issue_ticket (tih); | 1383 | issue_ticket(tih); |
1373 | } | 1384 | } |
1374 | 1385 | ||
1375 | 1386 | ||
@@ -1385,36 +1396,37 @@ filter_tickets_finished_cb (void *cls) | |||
1385 | * FIXME: Return handle?? | 1396 | * FIXME: Return handle?? |
1386 | */ | 1397 | */ |
1387 | void | 1398 | void |
1388 | RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1399 | RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1389 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 1400 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
1390 | const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | 1401 | const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, |
1391 | RECLAIM_TICKETS_TicketResult cb, | 1402 | RECLAIM_TICKETS_TicketResult cb, |
1392 | void *cb_cls) | 1403 | void *cb_cls) |
1393 | { | 1404 | { |
1394 | struct TicketIssueHandle *tih; | 1405 | struct TicketIssueHandle *tih; |
1395 | tih = GNUNET_new (struct TicketIssueHandle); | 1406 | |
1407 | tih = GNUNET_new(struct TicketIssueHandle); | ||
1396 | tih->cb = cb; | 1408 | tih->cb = cb; |
1397 | tih->cb_cls = cb_cls; | 1409 | tih->cb_cls = cb_cls; |
1398 | tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs); | 1410 | tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup(attrs); |
1399 | tih->identity = *identity; | 1411 | tih->identity = *identity; |
1400 | tih->ticket.audience = *audience; | 1412 | tih->ticket.audience = *audience; |
1401 | 1413 | ||
1402 | // First check whether the ticket has already been issued | 1414 | // First check whether the ticket has already been issued |
1403 | tih->ns_it = | 1415 | tih->ns_it = |
1404 | GNUNET_NAMESTORE_zone_iteration_start (nsh, | 1416 | GNUNET_NAMESTORE_zone_iteration_start(nsh, |
1405 | &tih->identity, | 1417 | &tih->identity, |
1406 | &filter_tickets_error_cb, | 1418 | &filter_tickets_error_cb, |
1407 | tih, | 1419 | tih, |
1408 | &filter_tickets_cb, | 1420 | &filter_tickets_cb, |
1409 | tih, | 1421 | tih, |
1410 | &filter_tickets_finished_cb, | 1422 | &filter_tickets_finished_cb, |
1411 | tih); | 1423 | tih); |
1412 | } | 1424 | } |
1413 | 1425 | ||
1414 | 1426 | ||
1415 | /************************************ | 1427 | /************************************ |
1416 | * Ticket iteration | 1428 | * Ticket iteration |
1417 | ************************************/ | 1429 | ************************************/ |
1418 | 1430 | ||
1419 | /** | 1431 | /** |
1420 | * Cleanup ticket iterator | 1432 | * Cleanup ticket iterator |
@@ -1422,11 +1434,11 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | |||
1422 | * @param iter handle to the iteration | 1434 | * @param iter handle to the iteration |
1423 | */ | 1435 | */ |
1424 | static void | 1436 | static void |
1425 | cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter) | 1437 | cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter) |
1426 | { | 1438 | { |
1427 | if (NULL != iter->ns_it) | 1439 | if (NULL != iter->ns_it) |
1428 | GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it); | 1440 | GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); |
1429 | GNUNET_free (iter); | 1441 | GNUNET_free(iter); |
1430 | } | 1442 | } |
1431 | 1443 | ||
1432 | 1444 | ||
@@ -1442,22 +1454,22 @@ cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter) | |||
1442 | * @param rd record set containing a ticket | 1454 | * @param rd record set containing a ticket |
1443 | */ | 1455 | */ |
1444 | static void | 1456 | static void |
1445 | collect_tickets_cb (void *cls, | 1457 | collect_tickets_cb(void *cls, |
1446 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1458 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
1447 | const char *label, | 1459 | const char *label, |
1448 | unsigned int rd_count, | 1460 | unsigned int rd_count, |
1449 | const struct GNUNET_GNSRECORD_Data *rd) | 1461 | const struct GNUNET_GNSRECORD_Data *rd) |
1450 | { | 1462 | { |
1451 | struct RECLAIM_TICKETS_Iterator *iter = cls; | 1463 | struct RECLAIM_TICKETS_Iterator *iter = cls; |
1452 | 1464 | ||
1453 | for (int i = 0; i < rd_count; i++) | 1465 | for (int i = 0; i < rd_count; i++) |
1454 | { | 1466 | { |
1455 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) | 1467 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) |
1456 | continue; | 1468 | continue; |
1457 | iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data); | 1469 | iter->cb(iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data); |
1458 | return; | 1470 | return; |
1459 | } | 1471 | } |
1460 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); | 1472 | GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); |
1461 | } | 1473 | } |
1462 | 1474 | ||
1463 | 1475 | ||
@@ -1467,12 +1479,13 @@ collect_tickets_cb (void *cls, | |||
1467 | * @param cls handle to the iteration | 1479 | * @param cls handle to the iteration |
1468 | */ | 1480 | */ |
1469 | static void | 1481 | static void |
1470 | collect_tickets_finished_cb (void *cls) | 1482 | collect_tickets_finished_cb(void *cls) |
1471 | { | 1483 | { |
1472 | struct RECLAIM_TICKETS_Iterator *iter = cls; | 1484 | struct RECLAIM_TICKETS_Iterator *iter = cls; |
1485 | |||
1473 | iter->ns_it = NULL; | 1486 | iter->ns_it = NULL; |
1474 | iter->cb (iter->cb_cls, NULL); | 1487 | iter->cb(iter->cb_cls, NULL); |
1475 | cleanup_iter (iter); | 1488 | cleanup_iter(iter); |
1476 | } | 1489 | } |
1477 | 1490 | ||
1478 | 1491 | ||
@@ -1482,12 +1495,13 @@ collect_tickets_finished_cb (void *cls) | |||
1482 | * @param cls the iteration handle | 1495 | * @param cls the iteration handle |
1483 | */ | 1496 | */ |
1484 | static void | 1497 | static void |
1485 | collect_tickets_error_cb (void *cls) | 1498 | collect_tickets_error_cb(void *cls) |
1486 | { | 1499 | { |
1487 | struct RECLAIM_TICKETS_Iterator *iter = cls; | 1500 | struct RECLAIM_TICKETS_Iterator *iter = cls; |
1501 | |||
1488 | iter->ns_it = NULL; | 1502 | iter->ns_it = NULL; |
1489 | iter->cb (iter->cb_cls, NULL); | 1503 | iter->cb(iter->cb_cls, NULL); |
1490 | cleanup_iter (iter); | 1504 | cleanup_iter(iter); |
1491 | } | 1505 | } |
1492 | 1506 | ||
1493 | 1507 | ||
@@ -1497,9 +1511,9 @@ collect_tickets_error_cb (void *cls) | |||
1497 | * @param iter the iteration to continue | 1511 | * @param iter the iteration to continue |
1498 | */ | 1512 | */ |
1499 | void | 1513 | void |
1500 | RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter) | 1514 | RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter) |
1501 | { | 1515 | { |
1502 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); | 1516 | GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); |
1503 | } | 1517 | } |
1504 | 1518 | ||
1505 | 1519 | ||
@@ -1509,10 +1523,10 @@ RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter) | |||
1509 | * @param iter iteration to cancel | 1523 | * @param iter iteration to cancel |
1510 | */ | 1524 | */ |
1511 | void | 1525 | void |
1512 | RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) | 1526 | RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter) |
1513 | { | 1527 | { |
1514 | GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it); | 1528 | GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); |
1515 | cleanup_iter (iter); | 1529 | cleanup_iter(iter); |
1516 | } | 1530 | } |
1517 | 1531 | ||
1518 | 1532 | ||
@@ -1525,25 +1539,25 @@ RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) | |||
1525 | * @return a handle to the iteration | 1539 | * @return a handle to the iteration |
1526 | */ | 1540 | */ |
1527 | struct RECLAIM_TICKETS_Iterator * | 1541 | struct RECLAIM_TICKETS_Iterator * |
1528 | RECLAIM_TICKETS_iteration_start ( | 1542 | RECLAIM_TICKETS_iteration_start( |
1529 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1543 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1530 | RECLAIM_TICKETS_TicketIter cb, | 1544 | RECLAIM_TICKETS_TicketIter cb, |
1531 | void *cb_cls) | 1545 | void *cb_cls) |
1532 | { | 1546 | { |
1533 | struct RECLAIM_TICKETS_Iterator *iter; | 1547 | struct RECLAIM_TICKETS_Iterator *iter; |
1534 | 1548 | ||
1535 | iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator); | 1549 | iter = GNUNET_new(struct RECLAIM_TICKETS_Iterator); |
1536 | iter->cb = cb; | 1550 | iter->cb = cb; |
1537 | iter->cb_cls = cb_cls; | 1551 | iter->cb_cls = cb_cls; |
1538 | iter->ns_it = | 1552 | iter->ns_it = |
1539 | GNUNET_NAMESTORE_zone_iteration_start (nsh, | 1553 | GNUNET_NAMESTORE_zone_iteration_start(nsh, |
1540 | identity, | 1554 | identity, |
1541 | &collect_tickets_error_cb, | 1555 | &collect_tickets_error_cb, |
1542 | iter, | 1556 | iter, |
1543 | &collect_tickets_cb, | 1557 | &collect_tickets_cb, |
1544 | iter, | 1558 | iter, |
1545 | &collect_tickets_finished_cb, | 1559 | &collect_tickets_finished_cb, |
1546 | iter); | 1560 | iter); |
1547 | return iter; | 1561 | return iter; |
1548 | } | 1562 | } |
1549 | 1563 | ||
@@ -1555,39 +1569,39 @@ RECLAIM_TICKETS_iteration_start ( | |||
1555 | * @return GNUNET_SYSERR on error | 1569 | * @return GNUNET_SYSERR on error |
1556 | */ | 1570 | */ |
1557 | int | 1571 | int |
1558 | RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) | 1572 | RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c) |
1559 | { | 1573 | { |
1560 | // Get ticket expiration time (relative) from config | 1574 | // Get ticket expiration time (relative) from config |
1561 | if (GNUNET_OK == | 1575 | if (GNUNET_OK == |
1562 | GNUNET_CONFIGURATION_get_value_time (c, | 1576 | GNUNET_CONFIGURATION_get_value_time(c, |
1563 | "reclaim", | 1577 | "reclaim", |
1564 | "TICKET_REFRESH_INTERVAL", | 1578 | "TICKET_REFRESH_INTERVAL", |
1565 | &ticket_refresh_interval)) | 1579 | &ticket_refresh_interval)) |
1566 | { | 1580 | { |
1567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1581 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1568 | "Configured refresh interval for tickets: %s\n", | 1582 | "Configured refresh interval for tickets: %s\n", |
1569 | GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, | 1583 | GNUNET_STRINGS_relative_time_to_string(ticket_refresh_interval, |
1570 | GNUNET_YES)); | 1584 | GNUNET_YES)); |
1571 | } | 1585 | } |
1572 | else | 1586 | else |
1573 | { | 1587 | { |
1574 | ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; | 1588 | ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; |
1575 | } | 1589 | } |
1576 | // Connect to identity and namestore services | 1590 | // Connect to identity and namestore services |
1577 | nsh = GNUNET_NAMESTORE_connect (c); | 1591 | nsh = GNUNET_NAMESTORE_connect(c); |
1578 | if (NULL == nsh) | 1592 | if (NULL == nsh) |
1579 | { | 1593 | { |
1580 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | 1594 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, |
1581 | "error connecting to namestore"); | 1595 | "error connecting to namestore"); |
1582 | return GNUNET_SYSERR; | 1596 | return GNUNET_SYSERR; |
1583 | } | 1597 | } |
1584 | gns = GNUNET_GNS_connect (c); | 1598 | gns = GNUNET_GNS_connect(c); |
1585 | if (NULL == gns) | 1599 | if (NULL == gns) |
1586 | { | 1600 | { |
1587 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); | 1601 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); |
1588 | return GNUNET_SYSERR; | 1602 | return GNUNET_SYSERR; |
1589 | } | 1603 | } |
1590 | stats = GNUNET_STATISTICS_create ("reclaim", c); | 1604 | stats = GNUNET_STATISTICS_create("reclaim", c); |
1591 | return GNUNET_OK; | 1605 | return GNUNET_OK; |
1592 | } | 1606 | } |
1593 | 1607 | ||
@@ -1597,17 +1611,17 @@ RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
1597 | * FIXME: cancel all pending operations (gns, ns etc) | 1611 | * FIXME: cancel all pending operations (gns, ns etc) |
1598 | */ | 1612 | */ |
1599 | void | 1613 | void |
1600 | RECLAIM_TICKETS_deinit (void) | 1614 | RECLAIM_TICKETS_deinit(void) |
1601 | { | 1615 | { |
1602 | if (NULL != nsh) | 1616 | if (NULL != nsh) |
1603 | GNUNET_NAMESTORE_disconnect (nsh); | 1617 | GNUNET_NAMESTORE_disconnect(nsh); |
1604 | nsh = NULL; | 1618 | nsh = NULL; |
1605 | if (NULL != gns) | 1619 | if (NULL != gns) |
1606 | GNUNET_GNS_disconnect (gns); | 1620 | GNUNET_GNS_disconnect(gns); |
1607 | gns = NULL; | 1621 | gns = NULL; |
1608 | if (NULL != stats) | 1622 | if (NULL != stats) |
1609 | { | 1623 | { |
1610 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 1624 | GNUNET_STATISTICS_destroy(stats, GNUNET_NO); |
1611 | stats = NULL; | 1625 | stats = NULL; |
1612 | } | 1626 | } |
1613 | } | 1627 | } |