GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-reclaim_tickets.c File Reference

reclaim tickets More...

#include <inttypes.h>
#include "gnunet-service-reclaim_tickets.h"
Include dependency graph for gnunet-service-reclaim_tickets.c:

Go to the source code of this file.

Data Structures

struct  TicketReference
 A reference to a ticket stored in GNS. More...
 
struct  RECLAIM_TICKETS_ConsumeHandle
 Handle to a consume operation. More...
 
struct  ParallelLookup
 Handle for a parallel GNS lookup job. More...
 
struct  TicketIssueHandle
 Ticket issue request handle. More...
 
struct  RECLAIM_TICKETS_Iterator
 Ticket iterator. More...
 
struct  RevokedAttributeEntry
 
struct  RECLAIM_TICKETS_RevokeHandle
 Ticket revocation request handle. More...
 

Macros

#define DEFAULT_TICKET_REFRESH_INTERVAL   GNUNET_TIME_UNIT_HOURS
 FIXME: the defaul ticket iteration interval should probably be the minimim attribute expiration. More...
 

Functions

static void cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh)
 Cleanup revoke handle. More...
 
static void process_tickets (void *cls)
 For each ticket, store new, updated attribute references (Implementation further below) More...
 
static void ticket_processed (void *cls, int32_t success, const char *emsg)
 Finished storing updated attribute references. More...
 
static void rvk_ticket_update_finished (void *cls)
 Done collecting tickets. More...
 
static void rvk_ticket_update (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 We need to update all other tickets with the new attribute IDs. More...
 
static void rvk_ns_iter_err (void *cls)
 Error iterating namestore. More...
 
static void rvk_ns_err (void *cls)
 Error storing new attribute in namestore. More...
 
static void move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rh)
 We change every attribute ID of the ticket attributes we want to revoke. More...
 
static void move_attrs_cont (void *cls)
 Delayed continuation for move_attrs. More...
 
static void del_attr_finished (void *cls, int32_t success, const char *emsg)
 Done deleting the old record. More...
 
static void move_attr_finished (void *cls, int32_t success, const char *emsg)
 Updated an attribute ID. More...
 
static void rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Got the referenced attribute. More...
 
static void remove_ticket_cont (void *cls, int32_t success, const char *emsg)
 Finished deleting ticket and attribute references. More...
 
static void revoke_attrs_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 We found the attribute references. More...
 
static void rvk_attrs_err_cb (void *cls)
 Failed to query namestore. More...
 
struct RECLAIM_TICKETS_RevokeHandleRECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
 Revoke a ticket. More...
 
void RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh)
 Cancel a revocation. More...
 
static void cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth)
 Cleanup ticket consume handle. More...
 
static void process_parallel_lookup_result (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 We found an attribute record. More...
 
static void abort_parallel_lookups (void *cls)
 Cancel the lookups for attribute records. More...
 
static void lookup_authz_cb (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 GNS result with attribute references. More...
 
struct RECLAIM_TICKETS_ConsumeHandleRECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
 Consume a ticket. More...
 
void RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth)
 Cancel a consume operation. More...
 
static void cleanup_issue_handle (struct TicketIssueHandle *handle)
 Cleanup ticket consume handle. More...
 
static void store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
 Store finished, abort on error. More...
 
static void issue_ticket (struct TicketIssueHandle *ih)
 Issue a new ticket. More...
 
static void filter_tickets_error_cb (void *cls)
 Namestore error on issue. More...
 
static void filter_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Iterator over records. More...
 
static void filter_tickets_finished_cb (void *cls)
 Done iterating over tickets and we apparently did not find an existing, matching ticket. More...
 
void RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
 Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes. More...
 
static void cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter)
 Cleanup ticket iterator. More...
 
static void collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Return each record of type to the caller and proceed with the iteration. More...
 
static void collect_tickets_finished_cb (void *cls)
 Signal ticket iteration has finished. More...
 
static void collect_tickets_error_cb (void *cls)
 Cancel ticket iteration on namestore error. More...
 
void RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter)
 Continue ticket iteration. More...
 
void RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter)
 Stop a running ticket iteration. More...
 
struct RECLAIM_TICKETS_IteratorRECLAIM_TICKETS_iteration_start (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
 Iterate over all tickets issued by an identity. More...
 
int RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Initialize tickets component. More...
 
void RECLAIM_TICKETS_deinit (void)
 Close handles and clean up. More...
 

Variables

static struct GNUNET_TIME_Relative ticket_refresh_interval
 Ticket expiration interval. More...
 
static struct GNUNET_NAMESTORE_Handlensh
 
static struct GNUNET_GNS_Handlegns
 
static struct GNUNET_STATISTICS_Handlestats
 

Detailed Description

reclaim tickets

Author
Martin Schanzenbach

Definition in file gnunet-service-reclaim_tickets.c.

Macro Definition Documentation

◆ DEFAULT_TICKET_REFRESH_INTERVAL

#define DEFAULT_TICKET_REFRESH_INTERVAL   GNUNET_TIME_UNIT_HOURS

FIXME: the defaul ticket iteration interval should probably be the minimim attribute expiration.

Definition at line 35 of file gnunet-service-reclaim_tickets.c.

Referenced by RECLAIM_TICKETS_init().

Function Documentation

◆ cleanup_rvk()

static void cleanup_rvk ( struct RECLAIM_TICKETS_RevokeHandle rh)
static

Cleanup revoke handle.

Parameters
rhthe ticket revocation handle

Definition at line 333 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, RECLAIM_TICKETS_RevokeHandle::attrs_tail, TicketRecordsEntry::data, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_zone_iteration_stop(), TicketRecordsEntry::label, RECLAIM_TICKETS_RevokeHandle::ns_it, RECLAIM_TICKETS_RevokeHandle::ns_qe, process_tickets(), and RECLAIM_TICKETS_RevokeHandle::tickets_to_update_head.

Referenced by del_attr_finished(), move_attr_finished(), process_tickets(), RECLAIM_TICKETS_revoke_cancel(), remove_ticket_cont(), rvk_attrs_err_cb(), rvk_ns_err(), and rvk_ns_iter_err().

334 {
335  struct RevokedAttributeEntry *ae;
336  struct TicketRecordsEntry *le;
337 
338  if (NULL != rh->ns_qe)
340  if (NULL != rh->ns_it)
342  while (NULL != (ae = rh->attrs_head))
343  {
345  GNUNET_free(ae);
346  }
347  while (NULL != (le = rh->tickets_to_update_head))
348  {
351  le);
352  if (NULL != le->data)
353  GNUNET_free(le->data);
354  if (NULL != le->label)
355  GNUNET_free(le->label);
356  GNUNET_free(le);
357  }
358  GNUNET_free(rh);
359 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_tickets()

static void process_tickets ( void *  cls)
static

For each ticket, store new, updated attribute references (Implementation further below)

For each ticket, store new, updated attribute references.

Parameters
clshandle to the operation

Definition at line 396 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, cleanup_rvk(), data, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_OK, GNUNET_SYSERR, RECLAIM_TICKETS_RevokeHandle::identity, RevokedAttributeEntry::new_id, RevokedAttributeEntry::next, RECLAIM_TICKETS_RevokeHandle::ns_qe, RevokedAttributeEntry::old_id, GNUNET_GNSRECORD_Data::record_type, ticket_processed(), RECLAIM_TICKETS_RevokeHandle::tickets_to_update_head, and RECLAIM_TICKETS_RevokeHandle::tickets_to_update_tail.

Referenced by cleanup_rvk(), rvk_ticket_update_finished(), and ticket_processed().

397 {
398  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
399  struct TicketRecordsEntry *le;
400  struct RevokedAttributeEntry *ae;
401 
402  if (NULL == rvk->tickets_to_update_head)
403  {
405  "Finished updatding tickets, success\n");
406  rvk->cb(rvk->cb_cls, GNUNET_OK);
407  cleanup_rvk(rvk);
408  return;
409  }
410  le = rvk->tickets_to_update_head;
413  le);
414  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
416  le->data,
417  le->rd_count,
418  rd))
419  {
421  "Unable to deserialize ticket record(s)\n");
422  rvk->cb(rvk->cb_cls, GNUNET_SYSERR);
423  cleanup_rvk(rvk);
424  return;
425  }
426  for (int i = 0; i < le->rd_count; i++)
427  {
429  continue;
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  }
436  }
438  &rvk->identity,
439  le->label,
440  le->rd_count,
441  rd,
443  rvk);
444  GNUNET_free(le->label);
445  GNUNET_free(le->data);
446  GNUNET_free(le);
447 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Ticket revocation request handle.
static void ticket_processed(void *cls, int32_t success, const char *emsg)
Finished storing updated attribute references.
uint64_t new_id
New ID of the attribute.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct RevokedAttributeEntry * next
DLL.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
unsigned int rd_count
Record count.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_NAMESTORE_Handle * nsh
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_log(kind,...)
uint64_t old_id
Old ID of the attribute.
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_processed()

static void ticket_processed ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Finished storing updated attribute references.

Abort on error, else continue processing tickets

Parameters
clshandle to the operation
successresult of namestore operation
emsg(NULL on success)

Definition at line 381 of file gnunet-service-reclaim_tickets.c.

References GNUNET_SCHEDULER_add_now(), RECLAIM_TICKETS_RevokeHandle::ns_qe, and process_tickets().

Referenced by process_tickets().

382 {
383  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
384 
385  rvk->ns_qe = NULL;
387 }
Ticket revocation request handle.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
static void process_tickets(void *cls)
For each ticket, store new, updated attribute references (Implementation further below) ...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rvk_ticket_update_finished()

static void rvk_ticket_update_finished ( void *  cls)
static

Done collecting tickets.

Start processing.

Parameters
clshandle to the operation

Definition at line 456 of file gnunet-service-reclaim_tickets.c.

References GNUNET_SCHEDULER_add_now(), RECLAIM_TICKETS_RevokeHandle::ns_it, and process_tickets().

Referenced by move_attrs().

457 {
458  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
459 
460  rvk->ns_it = NULL;
462 }
Ticket revocation request handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
static void process_tickets(void *cls)
For each ticket, store new, updated attribute references (Implementation further below) ...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rvk_ticket_update()

static void rvk_ticket_update ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

We need to update all other tickets with the new attribute IDs.

We first collect them all. Processing after.

Parameters
clshandle to the operation
zoneticket issuer private key
labelticket rnd
rd_coundsize of record set
rdrecord set

Let everything point to the old record

Definition at line 476 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, TicketRecordsEntry::data, data, TicketRecordsEntry::data_size, GNUNET_CONTAINER_DLL_insert, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_malloc, GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_YES, TicketRecordsEntry::label, RevokedAttributeEntry::next, RECLAIM_TICKETS_RevokeHandle::ns_it, RevokedAttributeEntry::old_id, TicketRecordsEntry::rd_count, RECLAIM_TICKETS_RevokeHandle::tickets_to_update_head, and RECLAIM_TICKETS_RevokeHandle::tickets_to_update_tail.

Referenced by move_attrs().

481 {
482  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
483  struct TicketRecordsEntry *le;
484  struct RevokedAttributeEntry *ae;
485  int has_changed = GNUNET_NO;
486 
488  for (int i = 0; i < rd_count; i++)
489  {
490  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
491  continue;
492  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
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  }
502  if (GNUNET_YES == has_changed)
503  {
504  le = GNUNET_new(struct TicketRecordsEntry);
505  le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd);
506  le->data = GNUNET_malloc(le->data_size);
507  le->rd_count = rd_count;
508  le->label = GNUNET_strdup(label);
509  GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data);
512  le);
513  }
515 }
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
Ticket revocation request handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
struct RevokedAttributeEntry * next
DLL.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
unsigned int rd_count
Record count.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
#define GNUNET_YES
Definition: gnunet_common.h:77
uint64_t old_id
Old ID of the attribute.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rvk_ns_iter_err()

static void rvk_ns_iter_err ( void *  cls)
static

Error iterating namestore.

Abort.

Parameters
clshandle to the operation

Definition at line 524 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, cleanup_rvk(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SYSERR, RECLAIM_TICKETS_RevokeHandle::move_attr, RECLAIM_TICKETS_RevokeHandle::ns_it, and RevokedAttributeEntry::old_id.

Referenced by move_attrs().

525 {
526  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
527 
528  rvk->ns_it = NULL;
530  "Namestore error on revocation (id=%" PRIu64 "\n",
531  rvk->move_attr->old_id);
532  rvk->cb(rvk->cb_cls, GNUNET_SYSERR);
533  cleanup_rvk(rvk);
534 }
Ticket revocation request handle.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
#define GNUNET_log(kind,...)
uint64_t old_id
Old ID of the attribute.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rvk_ns_err()

static void rvk_ns_err ( void *  cls)
static

Error storing new attribute in namestore.

Abort

Parameters
clshandle to the operation

Definition at line 543 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, cleanup_rvk(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SYSERR, RECLAIM_TICKETS_RevokeHandle::move_attr, move_attrs(), RECLAIM_TICKETS_RevokeHandle::ns_qe, and RevokedAttributeEntry::old_id.

Referenced by move_attrs().

544 {
545  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
546 
547  rvk->ns_qe = NULL;
549  "Namestore error on revocation (id=%" PRIu64 "\n",
550  rvk->move_attr->old_id);
551  rvk->cb(rvk->cb_cls, GNUNET_SYSERR);
552  cleanup_rvk(rvk);
553 }
Ticket revocation request handle.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
uint64_t old_id
Old ID of the attribute.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_attrs()

static void move_attrs ( struct RECLAIM_TICKETS_RevokeHandle rvk)
static

We change every attribute ID of the ticket attributes we want to revoke.

When we are done, we need to update any other ticket which included references to any of the changed attributes. (Implementation further below)

Parameters
rvkhandle to the operation

When we are done, we need to update any other ticket which included references to any of the changed attributes.

Parameters
rvkhandle to the operation

Definition at line 722 of file gnunet-service-reclaim_tickets.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_records_lookup(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_STRINGS_data_to_string_alloc(), RECLAIM_TICKETS_RevokeHandle::identity, RECLAIM_TICKETS_RevokeHandle::move_attr, RECLAIM_TICKETS_RevokeHandle::ns_it, RECLAIM_TICKETS_RevokeHandle::ns_qe, RevokedAttributeEntry::old_id, rvk_move_attr_cb(), rvk_ns_err(), rvk_ns_iter_err(), rvk_ticket_update(), and rvk_ticket_update_finished().

Referenced by move_attrs_cont(), remove_ticket_cont(), and rvk_ns_err().

723 {
724  char *label;
725 
726  if (NULL == rvk->move_attr)
727  {
728  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
729  rvk->ns_it =
731  &rvk->identity,
733  rvk,
735  rvk,
737  rvk);
738  return;
739  }
741  sizeof(uint64_t));
742  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label);
743 
745  &rvk->identity,
746  label,
747  &rvk_ns_err,
748  rvk,
750  rvk);
751  GNUNET_free(label);
752 }
static void rvk_move_attr_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got the referenced attribute.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
static void rvk_ns_iter_err(void *cls)
Error iterating namestore.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
static void rvk_ticket_update_finished(void *cls)
Done collecting tickets.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
#define GNUNET_log(kind,...)
uint64_t old_id
Old ID of the attribute.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
static void rvk_ticket_update(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We need to update all other tickets with the new attribute IDs.
static void rvk_ns_err(void *cls)
Error storing new attribute in namestore.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_attrs_cont()

static void move_attrs_cont ( void *  cls)
static

Delayed continuation for move_attrs.

Parameters
clshandle to the operation.

Definition at line 575 of file gnunet-service-reclaim_tickets.c.

References move_attrs().

Referenced by del_attr_finished(), and rvk_move_attr_cb().

576 {
578 }
Ticket revocation request handle.
static void move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh)
We change every attribute ID of the ticket attributes we want to revoke.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_attr_finished()

static void del_attr_finished ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Done deleting the old record.

Abort on error. Else, continue updating attribute IDs.

Parameters
clshandle to the operation
successresult of the namestore operation
emsgerror message (NULL on success)

Definition at line 590 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, cleanup_rvk(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, RECLAIM_TICKETS_RevokeHandle::move_attr, move_attrs_cont(), RevokedAttributeEntry::next, and RECLAIM_TICKETS_RevokeHandle::ns_qe.

Referenced by move_attr_finished().

591 {
592  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
593 
594  rvk->ns_qe = NULL;
595  if (GNUNET_SYSERR == success)
596  {
598  "Error removing attribute: %s\n",
599  emsg);
600  rvk->cb(rvk->cb_cls, GNUNET_SYSERR);
601  cleanup_rvk(rvk);
602  return;
603  }
604  rvk->move_attr = rvk->move_attr->next;
606 }
Ticket revocation request handle.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct RevokedAttributeEntry * next
DLL.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
static void move_attrs_cont(void *cls)
Delayed continuation for move_attrs.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_attr_finished()

static void move_attr_finished ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Updated an attribute ID.

Abort on error if namestore operation failed. Else, we have to delete the old record.

Parameters
clshandle to the operation
successresult of the store operation
emsgerror message (NULL on success)

Definition at line 619 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, cleanup_rvk(), del_attr_finished(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_SYSERR, RECLAIM_TICKETS_RevokeHandle::identity, RECLAIM_TICKETS_RevokeHandle::move_attr, RECLAIM_TICKETS_RevokeHandle::ns_qe, and RevokedAttributeEntry::old_id.

Referenced by rvk_move_attr_cb().

620 {
621  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
622  char *label;
623 
624  rvk->ns_qe = NULL;
625  if (GNUNET_SYSERR == success)
626  {
627  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg);
628  rvk->cb(rvk->cb_cls, GNUNET_SYSERR);
629  cleanup_rvk(rvk);
630  return;
631  }
633  sizeof(uint64_t));
634  GNUNET_assert(NULL != label);
635  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
637  &rvk->identity,
638  label,
639  0,
640  NULL,
642  rvk);
643  GNUNET_free(label);
644 }
Ticket revocation request handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static void del_attr_finished(void *cls, int32_t success, const char *emsg)
Done deleting the old record.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_NAMESTORE_Handle * nsh
#define GNUNET_log(kind,...)
uint64_t old_id
Old ID of the attribute.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rvk_move_attr_cb()

static void rvk_move_attr_cb ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Got the referenced attribute.

Updating the ID

Parameters
clshandle to the operation
zoneissuer identity
labelattribute ID
rd_countsize of record set (should be 1)
rdrecord set (the attribute)

find a new place for this attribute

Definition at line 657 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, RECLAIM_TICKETS_RevokeHandle::attrs_tail, claim, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_ATTRIBUTE_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_serialize(), GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(), GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, RECLAIM_TICKETS_RevokeHandle::identity, RECLAIM_TICKETS_RevokeHandle::move_attr, move_attr_finished(), move_attrs_cont(), GNUNET_RECLAIM_ATTRIBUTE_Claim::name, RevokedAttributeEntry::new_id, RevokedAttributeEntry::next, and RECLAIM_TICKETS_RevokeHandle::ns_qe.

Referenced by move_attrs().

662 {
663  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
665  struct GNUNET_GNSRECORD_Data new_rd;
666  struct RevokedAttributeEntry *le;
667  char *new_label;
668  char *attr_data;
669 
670  rvk->ns_qe = NULL;
671  if (0 == rd_count)
672  {
674  "The attribute %s no longer exists!\n",
675  label);
676  le = rvk->move_attr;
677  rvk->move_attr = le->next;
679  GNUNET_free(le);
681  return;
682  }
684  rvk->move_attr->new_id =
686  new_rd = *rd;
689  "Attribute to update: Name=%s, ID=%" PRIu64 "\n",
690  claim->name,
691  claim->id);
692  claim->id = rvk->move_attr->new_id;
693  new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(claim);
694  attr_data = GNUNET_malloc(rd->data_size);
695  new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize(claim, attr_data);
696  new_rd.data = attr_data;
698  sizeof(uint64_t));
699  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
701  &rvk->identity,
702  new_label,
703  1,
704  &new_rd,
706  rvk);
707  GNUNET_free(new_label);
708  GNUNET_free(claim);
709  GNUNET_free(attr_data);
710 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
const char * name
The name of the attribute.
Ticket revocation request handle.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
static void move_attr_finished(void *cls, int32_t success, const char *emsg)
Updated an attribute ID.
uint64_t new_id
New ID of the attribute.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
size_t data_size
Number of bytes in data.
struct RevokedAttributeEntry * next
DLL.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct RevokedAttributeEntry * move_attr
Current attribute to move.
const void * data
Binary value stored in the DNS record.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
static void move_attrs_cont(void *cls)
Delayed continuation for move_attrs.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
static struct GNUNET_NAMESTORE_Handle * nsh
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_log(kind,...)
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
Claim to store.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_ticket_cont()

static void remove_ticket_cont ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Finished deleting ticket and attribute references.

Abort on failure. Else, we start changing every attribute ID in the found attribute references so that access is no longer possible.

Parameters
clshandle to the operation
successNamestore operation return value
emsgerror message (NULL on success)

Definition at line 767 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, cleanup_rvk(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, RECLAIM_TICKETS_RevokeHandle::move_attr, move_attrs(), RECLAIM_TICKETS_RevokeHandle::ns_qe, and RECLAIM_TICKETS_RevokeHandle::ticket_attrs.

Referenced by revoke_attrs_cb().

768 {
769  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
770 
771  rvk->ns_qe = NULL;
772  if (GNUNET_SYSERR == success)
773  {
774  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
775  rvk->cb(rvk->cb_cls, GNUNET_SYSERR);
776  cleanup_rvk(rvk);
777  return;
778  }
779  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
780  if (0 == rvk->ticket_attrs)
781  {
783  "No attributes to move... strange\n");
784  rvk->cb(rvk->cb_cls, GNUNET_OK);
785  cleanup_rvk(rvk);
786  return;
787  }
788  rvk->move_attr = rvk->attrs_head;
789  move_attrs(rvk);
790 }
Ticket revocation request handle.
static void move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh)
We change every attribute ID of the ticket attributes we want to revoke.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct RevokedAttributeEntry * move_attr
Current attribute to move.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
unsigned int ticket_attrs
Number of attributes in ticket.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ revoke_attrs_cb()

static void revoke_attrs_cb ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

We found the attribute references.

Store them for later and remove the record set.

Parameters
clshandle to the operation
zonethe issuer key
labelticket rnd
rd_coundsize of record set
rdrecord set

Temporarily store attribute references. We need it later.

Remove attribute references

Definition at line 804 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, RECLAIM_TICKETS_RevokeHandle::attrs_tail, data, GNUNET_CONTAINER_DLL_insert, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_NAMESTORE_records_store(), GNUNET_new, RECLAIM_TICKETS_RevokeHandle::identity, RECLAIM_TICKETS_RevokeHandle::ns_qe, RevokedAttributeEntry::old_id, remove_ticket_cont(), and RECLAIM_TICKETS_RevokeHandle::ticket_attrs.

Referenced by RECLAIM_TICKETS_revoke().

810 {
811  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
812  struct RevokedAttributeEntry *le;
813 
814  rvk->ns_qe = NULL;
819  for (int i = 0; i < rd_count; i++)
820  {
821  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
822  continue;
823  le = GNUNET_new(struct RevokedAttributeEntry);
824  le->old_id = *((uint64_t *)rd[i].data);
826  rvk->ticket_attrs++;
827  }
828 
831  &rvk->identity,
832  label,
833  0,
834  NULL,
836  rvk);
837 }
Ticket revocation request handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
static struct GNUNET_NAMESTORE_Handle * nsh
static void remove_ticket_cont(void *cls, int32_t success, const char *emsg)
Finished deleting ticket and attribute references.
uint64_t old_id
Old ID of the attribute.
uint32_t data
The data value.
unsigned int ticket_attrs
Number of attributes in ticket.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rvk_attrs_err_cb()

static void rvk_attrs_err_cb ( void *  cls)
static

Failed to query namestore.

Abort operation

Parameters
clshandle to the operation

Definition at line 846 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, cleanup_rvk(), and GNUNET_SYSERR.

Referenced by RECLAIM_TICKETS_revoke().

847 {
848  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
849 
850  rvk->cb(rvk->cb_cls, GNUNET_SYSERR);
851  cleanup_rvk(rvk);
852 }
Ticket revocation request handle.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_revoke()

struct RECLAIM_TICKETS_RevokeHandle* RECLAIM_TICKETS_revoke ( const struct GNUNET_RECLAIM_Ticket ticket,
const struct GNUNET_CRYPTO_EcdsaPrivateKey identity,
RECLAIM_TICKETS_RevokeCallback  cb,
void *  cb_cls 
)

Revoke a ticket.

We start by looking up attribute references in order to change attribute IDs.

Parameters
ticketticket to revoke
identityprivate key of issuer
cbrevocation status callback
cb_clscallback closure
Returns
handle to the operation

Get shared attributes

Definition at line 867 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::cb, RECLAIM_TICKETS_RevokeHandle::cb_cls, GNUNET_assert, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_free, GNUNET_NAMESTORE_records_lookup(), GNUNET_new, GNUNET_STRINGS_data_to_string_alloc(), identity, RECLAIM_TICKETS_RevokeHandle::identity, GNUNET_RECLAIM_Ticket::identity, RECLAIM_TICKETS_RevokeHandle::ns_qe, revoke_attrs_cb(), GNUNET_RECLAIM_Ticket::rnd, rvk_attrs_err_cb(), TicketReference::ticket, and RECLAIM_TICKETS_RevokeHandle::ticket.

Referenced by handle_revoke_ticket_message().

871 {
872  struct RECLAIM_TICKETS_RevokeHandle *rvk;
873  char *label;
874 
876  rvk->cb = cb;
877  rvk->cb_cls = cb_cls;
878  rvk->identity = *identity;
879  rvk->ticket = *ticket;
882  label = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t));
883  GNUNET_assert(NULL != label);
885  identity,
886  label,
888  rvk,
890  rvk);
891  GNUNET_free(label);
892  return rvk;
893 }
Ticket revocation request handle.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void revoke_attrs_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We found the attribute references.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void rvk_attrs_err_cb(void *cls)
Failed to query namestore.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:241
uint64_t rnd
The ticket random (NBO)
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_revoke_cancel()

void RECLAIM_TICKETS_revoke_cancel ( struct RECLAIM_TICKETS_RevokeHandle rh)

Cancel a revocation.

Parameters
rhhandle to the operation

Definition at line 902 of file gnunet-service-reclaim_tickets.c.

References cleanup_rvk(), and GNUNET_assert.

Referenced by cleanup_client().

903 {
904  GNUNET_assert(NULL != rh);
905  cleanup_rvk(rh);
906 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_cth()

static void cleanup_cth ( struct RECLAIM_TICKETS_ConsumeHandle cth)
static

Cleanup ticket consume handle.

Parameters
cththe handle to clean up

Definition at line 919 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::attrs, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, GNUNET_GNS_lookup_cancel(), GNUNET_RECLAIM_ATTRIBUTE_list_destroy(), GNUNET_SCHEDULER_cancel(), RECLAIM_TICKETS_ConsumeHandle::kill_task, ParallelLookup::label, RECLAIM_TICKETS_ConsumeHandle::lookup_request, ParallelLookup::lookup_request, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_head, and RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_tail.

Referenced by lookup_authz_cb(), process_parallel_lookup_result(), and RECLAIM_TICKETS_consume_cancel().

920 {
921  struct ParallelLookup *lu;
922 
923  if (NULL != cth->lookup_request)
925  if (NULL != cth->kill_task)
927  while (NULL != (lu = cth->parallel_lookups_head))
928  {
929  if (NULL != lu->lookup_request)
934  lu);
935  GNUNET_free(lu);
936  }
937 
938  if (NULL != cth->attrs)
940  GNUNET_free(cth);
941 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes.
struct GNUNET_SCHEDULER_Task * kill_task
Kill task.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_GNS_LookupRequest * lookup_request
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
Definition: gns_api.c:306
struct ParallelLookup * parallel_lookups_tail
Lookup DLL.
struct ParallelLookup * parallel_lookups_head
Lookup DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Handle for a parallel GNS lookup job.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_parallel_lookup_result()

static void process_parallel_lookup_result ( void *  cls,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

We found an attribute record.

Parameters
clshandle to the operation
rd_coundsize of record set
rdrecord set

Definition at line 952 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::attrs, RECLAIM_TICKETS_ConsumeHandle::cb, RECLAIM_TICKETS_ConsumeHandle::cb_cls, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, cleanup_cth(), GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_RECLAIM_ATTRIBUTE_deserialize(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, ParallelLookup::handle, GNUNET_RECLAIM_Ticket::identity, ParallelLookup::label, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_tail, ParallelLookup::lookup_start_time, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_head, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_tail, GNUNET_GNSRECORD_Data::record_type, GNUNET_TIME_Relative::rel_value_us, and RECLAIM_TICKETS_ConsumeHandle::ticket.

Referenced by lookup_authz_cb().

955 {
956  struct ParallelLookup *parallel_lookup = cls;
957  struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
959 
961  "Parallel lookup finished (count=%u)\n",
962  rd_count);
963 
966  parallel_lookup);
967  GNUNET_free(parallel_lookup->label);
968 
970  "attribute_lookup_time_total",
972  parallel_lookup->lookup_start_time)
973  .rel_value_us,
974  GNUNET_YES);
975  GNUNET_STATISTICS_update(stats, "attribute_lookups_count", 1, GNUNET_YES);
976 
977 
978  GNUNET_free(parallel_lookup);
979  if (1 != rd_count)
980  GNUNET_break(0); // FIXME: We should never find this.
982  {
984  attr_le->claim =
987  cth->attrs->list_tail,
988  attr_le);
989  }
990 
991  if (NULL != cth->parallel_lookups_head)
992  return; // Wait for more
993 
994  /* Else we are done */
995  cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
996  cleanup_cth(cth);
997 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_tail
List tail.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
size_t data_size
Number of bytes in data.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct RECLAIM_TICKETS_ConsumeHandle * handle
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const void * data
Binary value stored in the DNS record.
Handle to a consume operation.
static void cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cleanup ticket consume handle.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
uint32_t record_type
Type of the GNS/DNS record.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
struct ParallelLookup * parallel_lookups_tail
Lookup DLL.
static struct GNUNET_STATISTICS_Handle * stats
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
struct ParallelLookup * parallel_lookups_head
Lookup DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Handle for a parallel GNS lookup job.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ abort_parallel_lookups()

static void abort_parallel_lookups ( void *  cls)
static

Cancel the lookups for attribute records.

Parameters
clshandle to the operation

Definition at line 1006 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::cb, RECLAIM_TICKETS_ConsumeHandle::cb_cls, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_GNS_lookup_cancel(), GNUNET_SYSERR, RECLAIM_TICKETS_ConsumeHandle::kill_task, ParallelLookup::label, ParallelLookup::lookup_request, ParallelLookup::next, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_head, and RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_tail.

Referenced by lookup_authz_cb().

1007 {
1008  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1009  struct ParallelLookup *lu;
1010  struct ParallelLookup *tmp;
1011 
1012  cth->kill_task = NULL;
1013  for (lu = cth->parallel_lookups_head; NULL != lu;)
1014  {
1016  GNUNET_free(lu->label);
1017  tmp = lu->next;
1019  cth->parallel_lookups_tail,
1020  lu);
1021  GNUNET_free(lu);
1022  lu = tmp;
1023  }
1024  cth->cb(cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted");
1025 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_SCHEDULER_Task * kill_task
Kill task.
struct GNUNET_GNS_LookupRequest * lookup_request
Handle to a consume operation.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct ParallelLookup * next
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
Definition: gns_api.c:306
struct ParallelLookup * parallel_lookups_tail
Lookup DLL.
struct ParallelLookup * parallel_lookups_head
Lookup DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Handle for a parallel GNS lookup job.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_authz_cb()

static void lookup_authz_cb ( void *  cls,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

GNS result with attribute references.

For each result, we start a (parallel) lookup of the actual attribute record under the referenced label.

Parameters
clshandle to the operation
rd_coundsize of the record set
rdrecord set

We started lookups. Add a timeout task. FIXME: Really needed here?

No references found, return empty attribute list

Definition at line 1038 of file gnunet-service-reclaim_tickets.c.

References abort_parallel_lookups(), RECLAIM_TICKETS_ConsumeHandle::attrs, RECLAIM_TICKETS_ConsumeHandle::cb, RECLAIM_TICKETS_ConsumeHandle::cb_cls, cleanup_cth(), data, data_size, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, ParallelLookup::handle, GNUNET_RECLAIM_Ticket::identity, RECLAIM_TICKETS_ConsumeHandle::kill_task, ParallelLookup::label, RECLAIM_TICKETS_ConsumeHandle::lookup_request, ParallelLookup::lookup_request, RECLAIM_TICKETS_ConsumeHandle::lookup_start_time, ParallelLookup::lookup_start_time, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_head, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_tail, process_parallel_lookup_result(), GNUNET_TIME_Relative::rel_value_us, and RECLAIM_TICKETS_ConsumeHandle::ticket.

Referenced by RECLAIM_TICKETS_consume().

1041 {
1042  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1043  struct ParallelLookup *parallel_lookup;
1044  char *lbl;
1045 
1046  cth->lookup_request = NULL;
1047 
1049  "reclaim_authz_lookup_time_total",
1051  cth->lookup_start_time)
1052  .rel_value_us,
1053  GNUNET_YES);
1055  "reclaim_authz_lookups_count",
1056  1,
1057  GNUNET_YES);
1058 
1059  for (int i = 0; i < rd_count; i++)
1060  {
1061  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1062  continue;
1064  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
1065  parallel_lookup = GNUNET_new(struct ParallelLookup);
1066  parallel_lookup->handle = cth;
1067  parallel_lookup->label = lbl;
1068  parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get();
1069  parallel_lookup->lookup_request =
1071  lbl,
1072  &cth->ticket.identity,
1076  parallel_lookup);
1078  cth->parallel_lookups_tail,
1079  parallel_lookup);
1080  }
1085  if (NULL != cth->parallel_lookups_head)
1086  {
1090  cth);
1091  return;
1092  }
1096  cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
1097  cleanup_cth(cth);
1098 }
static void abort_parallel_lookups(void *cls)
Cancel the lookups for attribute records.
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
static void process_parallel_lookup_result(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We found an attribute record.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_SCHEDULER_Task * kill_task
Kill task.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct RECLAIM_TICKETS_ConsumeHandle * handle
struct GNUNET_GNS_LookupRequest * lookup_request
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
Handle to a consume operation.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:440
static void cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cleanup ticket consume handle.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
Defaults, look in cache, then in DHT.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS.
Definition: gns_api.c:334
uint32_t data
The data value.
static size_t data_size
Number of bytes in data.
struct ParallelLookup * parallel_lookups_tail
Lookup DLL.
static struct GNUNET_STATISTICS_Handle * stats
static struct GNUNET_GNS_Handle * gns
struct ParallelLookup * parallel_lookups_head
Lookup DLL.
Handle for a parallel GNS lookup job.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_consume()

struct RECLAIM_TICKETS_ConsumeHandle* RECLAIM_TICKETS_consume ( const struct GNUNET_CRYPTO_EcdsaPrivateKey id,
const struct GNUNET_RECLAIM_Ticket ticket,
RECLAIM_TICKETS_ConsumeCallback  cb,
void *  cb_cls 
)

Consume a ticket.

We first looking attribute references under the label ticket.rnd in GNS.

Parameters
idthe audience of the ticket
ticketthe ticket to consume
cbcallback to call with attributes of ticket
cb_clscallback closure
Returns
handle to the operation

Definition at line 1113 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::attrs, RECLAIM_TICKETS_ConsumeHandle::cb, RECLAIM_TICKETS_ConsumeHandle::cb_cls, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_log, GNUNET_new, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_TIME_absolute_get(), id, RECLAIM_TICKETS_ConsumeHandle::identity, GNUNET_RECLAIM_Ticket::identity, RECLAIM_TICKETS_ConsumeHandle::identity_pub, lookup_authz_cb(), RECLAIM_TICKETS_ConsumeHandle::lookup_request, RECLAIM_TICKETS_ConsumeHandle::lookup_start_time, GNUNET_RECLAIM_Ticket::rnd, TicketReference::ticket, and RECLAIM_TICKETS_ConsumeHandle::ticket.

Referenced by handle_consume_ticket_message().

1117 {
1118  struct RECLAIM_TICKETS_ConsumeHandle *cth;
1119  char *label;
1120 
1122 
1123  cth->identity = *id;
1126  cth->ticket = *ticket;
1127  cth->cb = cb;
1128  cth->cb_cls = cb_cls;
1129  label =
1130  GNUNET_STRINGS_data_to_string_alloc(&cth->ticket.rnd, sizeof(uint64_t));
1132  "Looking for AuthZ info under %s\n",
1133  label);
1135  cth->lookup_request =
1137  label,
1138  &cth->ticket.identity,
1141  &lookup_authz_cb,
1142  cth);
1143  GNUNET_free(label);
1144  return cth;
1145 }
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Audience Key.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
Handle to a consume operation.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:241
uint64_t rnd
The ticket random (NBO)
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
#define GNUNET_log(kind,...)
Defaults, look in cache, then in DHT.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS.
Definition: gns_api.c:334
static void lookup_authz_cb(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
GNS result with attribute references.
static struct GNUNET_GNS_Handle * gns
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub
Audience Key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_consume_cancel()

void RECLAIM_TICKETS_consume_cancel ( struct RECLAIM_TICKETS_ConsumeHandle cth)

Cancel a consume operation.

Parameters
cththe operation to cancel

Definition at line 1154 of file gnunet-service-reclaim_tickets.c.

References cleanup_cth().

Referenced by cleanup_client().

1155 {
1156  cleanup_cth(cth);
1157  return;
1158 }
static void cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cleanup ticket consume handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_issue_handle()

static void cleanup_issue_handle ( struct TicketIssueHandle handle)
static

Cleanup ticket consume handle.

Parameters
handlethe handle to clean up

Definition at line 1170 of file gnunet-service-reclaim_tickets.c.

References GNUNET_free, GNUNET_NAMESTORE_cancel(), and TicketIssueHandle::ns_qe.

Referenced by filter_tickets_cb(), filter_tickets_error_cb(), and store_ticket_issue_cont().

1171 {
1172  if (NULL != handle->ns_qe)
1173  GNUNET_NAMESTORE_cancel(handle->ns_qe);
1174  GNUNET_free(handle);
1175 }
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ store_ticket_issue_cont()

static void store_ticket_issue_cont ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Store finished, abort on error.

Else, return new ticket to caller.

Parameters
clshandle to the operation
successstore operation result
emsgerror message (or NULL on success)

Definition at line 1187 of file gnunet-service-reclaim_tickets.c.

References TicketIssueHandle::cb, TicketIssueHandle::cb_cls, cleanup_issue_handle(), GNUNET_OK, GNUNET_SYSERR, handle, TicketIssueHandle::ns_qe, and TicketIssueHandle::ticket.

Referenced by issue_ticket().

1188 {
1189  struct TicketIssueHandle *handle = cls;
1190 
1191  handle->ns_qe = NULL;
1192  if (GNUNET_SYSERR == success)
1193  {
1194  handle->cb(handle->cb_cls,
1195  &handle->ticket,
1196  GNUNET_SYSERR,
1197  "Error storing AuthZ ticket in GNS");
1198  return;
1199  }
1200  handle->cb(handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
1201  cleanup_issue_handle(handle);
1202 }
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Ticket issue request handle.
RECLAIM_TICKETS_TicketResult cb
Callback.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ issue_ticket()

static void issue_ticket ( struct TicketIssueHandle ih)
static

Issue a new ticket.

We store references to attribute record labels and the ticket itself under the label base64(ticket.rnd).

Parameters
ihhandle to the operation containing relevant metadata

FIXME: Should this be the attribute expiration time or ticket refresh interval? Probably min(attrs.expiration)

Definition at line 1213 of file gnunet-service-reclaim_tickets.c.

References TicketIssueHandle::attrs, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_free, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, TicketIssueHandle::identity, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, TicketIssueHandle::ns_qe, GNUNET_GNSRECORD_Data::record_type, GNUNET_TIME_Relative::rel_value_us, GNUNET_RECLAIM_Ticket::rnd, store_ticket_issue_cont(), TicketIssueHandle::ticket, and ticket_refresh_interval.

Referenced by filter_tickets_finished_cb().

1214 {
1216  struct GNUNET_GNSRECORD_Data *attrs_record;
1217  char *label;
1218  size_t list_len = 1;
1219  int i;
1220 
1221  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1222  list_len++;
1223 
1224  attrs_record =
1225  GNUNET_malloc(list_len * sizeof(struct GNUNET_GNSRECORD_Data));
1226  i = 0;
1227  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1228  {
1229  attrs_record[i].data = &le->claim->id;
1230  attrs_record[i].data_size = sizeof(le->claim->id);
1238  i++;
1239  }
1240  attrs_record[i].data = &ih->ticket;
1241  attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
1244  attrs_record[i].flags =
1246 
1247  label =
1248  GNUNET_STRINGS_data_to_string_alloc(&ih->ticket.rnd, sizeof(uint64_t));
1249  // Publish record
1251  &ih->identity,
1252  label,
1253  list_len,
1254  attrs_record,
1256  ih);
1257  GNUNET_free(attrs_record);
1258  GNUNET_free(label);
1259 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
The authorization ticket.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
uint64_t rel_value_us
The actual value.
static struct GNUNET_TIME_Relative ticket_refresh_interval
Ticket expiration interval.
static void store_ticket_issue_cont(void *cls, int32_t success, const char *emsg)
Store finished, abort on error.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
size_t data_size
Number of bytes in data.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
const void * data
Binary value stored in the DNS record.
uint64_t expiration_time
Expiration time for the DNS record.
This is a private record of this peer and it should thus not be handed out to other peers...
uint64_t rnd
The ticket random (NBO)
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes to issue.
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This flag is currently unused; former RF_PENDING flag.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_tickets_error_cb()

static void filter_tickets_error_cb ( void *  cls)
static

Namestore error on issue.

Abort.

Parameters
clshandle to the operation

Definition at line 1272 of file gnunet-service-reclaim_tickets.c.

References TicketIssueHandle::cb, TicketIssueHandle::cb_cls, cleanup_issue_handle(), GNUNET_SYSERR, TicketIssueHandle::ns_it, and TicketIssueHandle::ticket.

Referenced by RECLAIM_TICKETS_issue().

1273 {
1274  struct TicketIssueHandle *tih = cls;
1275 
1276  tih->ns_it = NULL;
1277  tih->cb(tih->cb_cls,
1278  &tih->ticket,
1279  GNUNET_SYSERR,
1280  "Error storing AuthZ ticket in GNS");
1281  cleanup_issue_handle(tih);
1282 }
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore Iterator.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Ticket issue request handle.
RECLAIM_TICKETS_TicketResult cb
Callback.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_tickets_cb()

static void filter_tickets_cb ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Iterator over records.

Check if any previously issued ticket already matches what we need to prevent duplicates and improve resolution synergy.

Parameters
clshandle to the operation
zoneissuer identity
labelticket rnd
rd_countsize of record set
rdrecord set

If we found a matching ticket, return that to the caller and we are done.

Definition at line 1298 of file gnunet-service-reclaim_tickets.c.

References TicketIssueHandle::attrs, GNUNET_RECLAIM_Ticket::audience, TicketIssueHandle::cb, TicketIssueHandle::cb_cls, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, cleanup_issue_handle(), data, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_OK, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, TicketIssueHandle::ns_it, TicketReference::ticket, and TicketIssueHandle::ticket.

Referenced by RECLAIM_TICKETS_issue().

1303 {
1304  struct TicketIssueHandle *tih = cls;
1305  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1306 
1307  // figure out the number of requested attributes
1309  unsigned int attr_cnt = 0;
1310 
1311  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1312  attr_cnt++;
1313 
1314  // ticket search
1315  unsigned int found_attrs_cnt = 0;
1316 
1317  for (int i = 0; i < rd_count; i++)
1318  {
1319  // found ticket
1320  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1321  {
1322  ticket = (struct GNUNET_RECLAIM_Ticket *)rd[i].data;
1323  // cmp audience
1324  if (0 == memcmp(&tih->ticket.audience,
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)
1336  continue;
1337  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1338  {
1339  // cmp attr_ref id with requested attr id
1341  " %" PRIu64 "\n %" PRIu64 "\n",
1342  *((uint64_t *)rd[i].data),
1343  le->claim->id);
1344 
1345 
1346  if (0 == memcmp(rd[i].data, &le->claim->id, sizeof(uint64_t)))
1347  found_attrs_cnt++;
1348  }
1349  }
1350 
1355  if (attr_cnt == found_attrs_cnt && NULL != ticket)
1356  {
1358  tih->cb(tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
1359  cleanup_issue_handle(tih);
1360  return;
1361  }
1362 
1363  // ticket not found in current record, checking next record set
1365 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
The authorization ticket.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore Iterator.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes to issue.
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
Ticket issue request handle.
RECLAIM_TICKETS_TicketResult cb
Callback.
uint32_t data
The data value.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_tickets_finished_cb()

static void filter_tickets_finished_cb ( void *  cls)
static

Done iterating over tickets and we apparently did not find an existing, matching ticket.

Continue by issuing a new ticket.

Parameters
clshandle to the operation

Definition at line 1376 of file gnunet-service-reclaim_tickets.c.

References GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), TicketIssueHandle::identity, GNUNET_RECLAIM_Ticket::identity, issue_ticket(), GNUNET_RECLAIM_Ticket::rnd, and TicketIssueHandle::ticket.

Referenced by RECLAIM_TICKETS_issue().

1377 {
1378  struct TicketIssueHandle *tih = cls;
1379 
1381  tih->ticket.rnd =
1383  issue_ticket(tih);
1384 }
static void issue_ticket(struct TicketIssueHandle *ih)
Issue a new ticket.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:241
uint64_t rnd
The ticket random (NBO)
Ticket issue request handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_issue()

void RECLAIM_TICKETS_issue ( const struct GNUNET_CRYPTO_EcdsaPrivateKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs,
const struct GNUNET_CRYPTO_EcdsaPublicKey audience,
RECLAIM_TICKETS_TicketResult  cb,
void *  cb_cls 
)

Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes.

Parameters
identitythe issuer
attrsthe attributes to share
audiencethe audience to share the attributes with
cbthe callback to call with the ticket result
cb_clsthe callback closure FIXME: Return handle??

Definition at line 1399 of file gnunet-service-reclaim_tickets.c.

References TicketIssueHandle::attrs, GNUNET_RECLAIM_Ticket::audience, TicketIssueHandle::cb, TicketIssueHandle::cb_cls, filter_tickets_cb(), filter_tickets_error_cb(), filter_tickets_finished_cb(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_new, GNUNET_RECLAIM_ATTRIBUTE_list_dup(), identity, TicketIssueHandle::identity, TicketIssueHandle::ns_it, and TicketIssueHandle::ticket.

Referenced by handle_issue_ticket_message().

1404 {
1405  struct TicketIssueHandle *tih;
1406 
1407  tih = GNUNET_new(struct TicketIssueHandle);
1408  tih->cb = cb;
1409  tih->cb_cls = cb_cls;
1411  tih->identity = *identity;
1412  tih->ticket.audience = *audience;
1413 
1414  // First check whether the ticket has already been issued
1415  tih->ns_it =
1417  &tih->identity,
1419  tih,
1421  tih,
1423  tih);
1424 }
static void filter_tickets_finished_cb(void *cls)
Done iterating over tickets and we apparently did not find an existing, matching ticket.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void filter_tickets_error_cb(void *cls)
Namestore error on issue.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore Iterator.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attrs
Attributes to issue.
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
Ticket issue request handle.
RECLAIM_TICKETS_TicketResult cb
Callback.
static void filter_tickets_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Iterator over records.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_dup(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Make a (deep) copy of a claim list.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_iter()

static void cleanup_iter ( struct RECLAIM_TICKETS_Iterator iter)
static

Cleanup ticket iterator.

Parameters
iterhandle to the iteration

Definition at line 1437 of file gnunet-service-reclaim_tickets.c.

References GNUNET_free, GNUNET_NAMESTORE_zone_iteration_stop(), and RECLAIM_TICKETS_Iterator::ns_it.

Referenced by collect_tickets_error_cb(), collect_tickets_finished_cb(), and RECLAIM_TICKETS_iteration_stop().

1438 {
1439  if (NULL != iter->ns_it)
1441  GNUNET_free(iter);
1442 }
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_tickets_cb()

static void collect_tickets_cb ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Return each record of type to the caller and proceed with the iteration.

FIXME: Should we not proceed automatically here?

Parameters
clshandle to the iteration
zonethe ticket issuer
labelthe ticket rnd
rd_countnumber of records in record set
rdrecord set containing a ticket

Definition at line 1457 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_Iterator::cb, RECLAIM_TICKETS_Iterator::cb_cls, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_NAMESTORE_zone_iterator_next(), and RECLAIM_TICKETS_Iterator::ns_it.

Referenced by RECLAIM_TICKETS_iteration_start().

1462 {
1463  struct RECLAIM_TICKETS_Iterator *iter = cls;
1464 
1465  for (int i = 0; i < rd_count; i++)
1466  {
1467  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1468  continue;
1469  iter->cb(iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data);
1470  return;
1471  }
1473 }
The authorization ticket.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
const void * data
Binary value stored in the DNS record.
RECLAIM_TICKETS_TicketIter cb
Iter callback.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_tickets_finished_cb()

static void collect_tickets_finished_cb ( void *  cls)
static

Signal ticket iteration has finished.

Parameters
clshandle to the iteration

Definition at line 1482 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_Iterator::cb, RECLAIM_TICKETS_Iterator::cb_cls, cleanup_iter(), and RECLAIM_TICKETS_Iterator::ns_it.

Referenced by RECLAIM_TICKETS_iteration_start().

1483 {
1484  struct RECLAIM_TICKETS_Iterator *iter = cls;
1485 
1486  iter->ns_it = NULL;
1487  iter->cb(iter->cb_cls, NULL);
1488  cleanup_iter(iter);
1489 }
static void cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter)
Cleanup ticket iterator.
RECLAIM_TICKETS_TicketIter cb
Iter callback.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_tickets_error_cb()

static void collect_tickets_error_cb ( void *  cls)
static

Cancel ticket iteration on namestore error.

Parameters
clsthe iteration handle

Definition at line 1498 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_Iterator::cb, RECLAIM_TICKETS_Iterator::cb_cls, cleanup_iter(), and RECLAIM_TICKETS_Iterator::ns_it.

Referenced by RECLAIM_TICKETS_iteration_start().

1499 {
1500  struct RECLAIM_TICKETS_Iterator *iter = cls;
1501 
1502  iter->ns_it = NULL;
1503  iter->cb(iter->cb_cls, NULL);
1504  cleanup_iter(iter);
1505 }
static void cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter)
Cleanup ticket iterator.
RECLAIM_TICKETS_TicketIter cb
Iter callback.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_iteration_next()

void RECLAIM_TICKETS_iteration_next ( struct RECLAIM_TICKETS_Iterator iter)

Continue ticket iteration.

Parameters
iterthe iteration to continue

Definition at line 1514 of file gnunet-service-reclaim_tickets.c.

References GNUNET_NAMESTORE_zone_iterator_next(), and RECLAIM_TICKETS_Iterator::ns_it.

Referenced by handle_ticket_iteration_next().

1515 {
1517 }
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_iteration_stop()

void RECLAIM_TICKETS_iteration_stop ( struct RECLAIM_TICKETS_Iterator iter)

Stop a running ticket iteration.

Parameters
iteriteration to cancel

Definition at line 1526 of file gnunet-service-reclaim_tickets.c.

References cleanup_iter(), GNUNET_NAMESTORE_zone_iteration_stop(), and RECLAIM_TICKETS_Iterator::ns_it.

Referenced by cleanup_client(), and handle_ticket_iteration_stop().

1527 {
1529  cleanup_iter(iter);
1530 }
static void cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter)
Cleanup ticket iterator.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_iteration_start()

struct RECLAIM_TICKETS_Iterator* RECLAIM_TICKETS_iteration_start ( const struct GNUNET_CRYPTO_EcdsaPrivateKey identity,
RECLAIM_TICKETS_TicketIter  cb,
void *  cb_cls 
)

Iterate over all tickets issued by an identity.

Parameters
identitythe issuing identity
cbticket callback function
cb_clscallback closure
Returns
a handle to the iteration

Definition at line 1542 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_Iterator::cb, RECLAIM_TICKETS_Iterator::cb_cls, collect_tickets_cb(), collect_tickets_error_cb(), collect_tickets_finished_cb(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_new, and RECLAIM_TICKETS_Iterator::ns_it.

Referenced by handle_ticket_iteration_start().

1546 {
1547  struct RECLAIM_TICKETS_Iterator *iter;
1548 
1549  iter = GNUNET_new(struct RECLAIM_TICKETS_Iterator);
1550  iter->cb = cb;
1551  iter->cb_cls = cb_cls;
1552  iter->ns_it =
1554  identity,
1556  iter,
1558  iter,
1560  iter);
1561  return iter;
1562 }
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void collect_tickets_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Return each record of type to the caller and proceed with the iteration.
RECLAIM_TICKETS_TicketIter cb
Iter callback.
static void collect_tickets_error_cb(void *cls)
Cancel ticket iteration on namestore error.
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore queue entry.
static void collect_tickets_finished_cb(void *cls)
Signal ticket iteration has finished.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_init()

int RECLAIM_TICKETS_init ( const struct GNUNET_CONFIGURATION_Handle c)

Initialize tickets component.

Parameters
cthe configuration
Returns
GNUNET_SYSERR on error

Definition at line 1572 of file gnunet-service-reclaim_tickets.c.

References DEFAULT_TICKET_REFRESH_INTERVAL, GNUNET_CONFIGURATION_get_value_time(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_GNS_connect(), GNUNET_log, GNUNET_log_strerror, GNUNET_NAMESTORE_connect(), GNUNET_OK, GNUNET_STATISTICS_create(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_YES, and ticket_refresh_interval.

Referenced by run().

1573 {
1574  // Get ticket expiration time (relative) from config
1575  if (GNUNET_OK ==
1577  "reclaim",
1578  "TICKET_REFRESH_INTERVAL",
1580  {
1582  "Configured refresh interval for tickets: %s\n",
1584  GNUNET_YES));
1585  }
1586  else
1587  {
1589  }
1590  // Connect to identity and namestore services
1592  if (NULL == nsh)
1593  {
1595  "error connecting to namestore");
1596  return GNUNET_SYSERR;
1597  }
1598  gns = GNUNET_GNS_connect(c);
1599  if (NULL == gns)
1600  {
1601  GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1602  return GNUNET_SYSERR;
1603  }
1604  stats = GNUNET_STATISTICS_create("reclaim", c);
1605  return GNUNET_OK;
1606 }
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
static struct GNUNET_TIME_Relative ticket_refresh_interval
Ticket expiration interval.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:260
#define DEFAULT_TICKET_REFRESH_INTERVAL
FIXME: the defaul ticket iteration interval should probably be the minimim attribute expiration...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_STATISTICS_Handle * stats
static struct GNUNET_GNS_Handle * gns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RECLAIM_TICKETS_deinit()

void RECLAIM_TICKETS_deinit ( void  )

Close handles and clean up.

FIXME: cancel all pending operations (gns, ns etc)

Definition at line 1614 of file gnunet-service-reclaim_tickets.c.

References GNUNET_GNS_disconnect(), GNUNET_NAMESTORE_disconnect(), GNUNET_NO, and GNUNET_STATISTICS_destroy().

Referenced by cleanup().

1615 {
1616  if (NULL != nsh)
1618  nsh = NULL;
1619  if (NULL != gns)
1621  gns = NULL;
1622  if (NULL != stats)
1623  {
1625  stats = NULL;
1626  }
1627 }
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:282
static struct GNUNET_NAMESTORE_Handle * nsh
static struct GNUNET_STATISTICS_Handle * stats
static struct GNUNET_GNS_Handle * gns
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ticket_refresh_interval

struct GNUNET_TIME_Relative ticket_refresh_interval
static

Ticket expiration interval.

Definition at line 311 of file gnunet-service-reclaim_tickets.c.

Referenced by issue_ticket(), and RECLAIM_TICKETS_init().

◆ nsh

struct GNUNET_NAMESTORE_Handle* nsh
static

Definition at line 315 of file gnunet-service-reclaim_tickets.c.

◆ gns

struct GNUNET_GNS_Handle* gns
static

Definition at line 319 of file gnunet-service-reclaim_tickets.c.

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

Definition at line 323 of file gnunet-service-reclaim_tickets.c.