GNUnet  0.11.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_AttributeList *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 344 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().

345 {
346  struct RevokedAttributeEntry *ae;
347  struct TicketRecordsEntry *le;
348 
349  if (NULL != rh->ns_qe)
351  if (NULL != rh->ns_it)
353  while (NULL != (ae = rh->attrs_head))
354  {
356  GNUNET_free (ae);
357  }
358  while (NULL != (le = rh->tickets_to_update_head))
359  {
362  le);
363  if (NULL != le->data)
364  GNUNET_free (le->data);
365  if (NULL != le->label)
366  GNUNET_free (le->label);
367  GNUNET_free (le);
368  }
369  GNUNET_free (rh);
370 }
#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 407 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_ATTRIBUTE_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().

408 {
409  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
410  struct TicketRecordsEntry *le;
411  struct RevokedAttributeEntry *ae;
412 
413  if (NULL == rvk->tickets_to_update_head)
414  {
416  "Finished updatding tickets, success\n");
417  rvk->cb (rvk->cb_cls, GNUNET_OK);
418  cleanup_rvk (rvk);
419  return;
420  }
421  le = rvk->tickets_to_update_head;
424  le);
425  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
427  le->data,
428  le->rd_count,
429  rd))
430  {
432  "Unable to deserialize ticket record(s)\n");
433  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
434  cleanup_rvk (rvk);
435  return;
436  }
437  for (int i = 0; i < le->rd_count; i++)
438  {
440  continue;
441  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
442  {
443  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
444  continue;
445  rd[i].data = &ae->new_id;
446  }
447  }
449  &rvk->identity,
450  le->label,
451  le->rd_count,
452  rd,
454  rvk);
455  GNUNET_free (le->label);
456  GNUNET_free (le->data);
457  GNUNET_free (le);
458 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Ticket revocation request handle.
struct GNUNET_RECLAIM_Identifier old_id
Old ID of the attribute.
static void ticket_processed(void *cls, int32_t success, const char *emsg)
Finished storing updated attribute references.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
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.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
Record type for reclaim records.
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:84
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_Identifier new_id
New ID of the attribute.
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_log(kind,...)
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 392 of file gnunet-service-reclaim_tickets.c.

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

Referenced by process_tickets().

393 {
394  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
395 
396  rvk->ns_qe = NULL;
398 }
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:1298
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 467 of file gnunet-service-reclaim_tickets.c.

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

Referenced by move_attrs().

468 {
469  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
470 
471  rvk->ns_it = NULL;
473 }
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:1298
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 487 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_ATTRIBUTE_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().

492 {
493  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
494  struct TicketRecordsEntry *le;
495  struct RevokedAttributeEntry *ae;
496  int has_changed = GNUNET_NO;
497 
499  for (int i = 0; i < rd_count; i++)
500  {
501  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
502  continue;
503  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
504  {
505  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
506  continue;
507  has_changed = GNUNET_YES;
508  break;
509  }
510  if (GNUNET_YES == has_changed)
511  break;
512  }
513  if (GNUNET_YES == has_changed)
514  {
515  le = GNUNET_new (struct TicketRecordsEntry);
516  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
517  le->data = GNUNET_malloc (le->data_size);
518  le->rd_count = rd_count;
519  le->label = GNUNET_strdup (label);
520  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
523  le);
524  }
526 }
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.
struct GNUNET_RECLAIM_Identifier old_id
Old ID of the attribute.
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_NO
Definition: gnunet_common.h:86
#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_.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
Record type for reclaim records.
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:85
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 535 of file gnunet-service-reclaim_tickets.c.

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

Referenced by move_attrs().

536 {
537  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
538 
539  rvk->ns_it = NULL;
540  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
541  cleanup_rvk (rvk);
542 }
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:84
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
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 551 of file gnunet-service-reclaim_tickets.c.

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

Referenced by move_attrs().

552 {
553  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
554 
555  rvk->ns_qe = NULL;
556  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
557  cleanup_rvk (rvk);
558 }
Ticket revocation request handle.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
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 764 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().

765 {
766  char *label;
767 
768  if (NULL == rvk->move_attr)
769  {
770  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
771  rvk->ns_it =
773  &rvk->identity,
775  rvk,
777  rvk,
779  rvk);
780  return;
781  }
783  sizeof (rvk->move_attr->old_id));
784  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label);
785 
787  &rvk->identity,
788  label,
789  &rvk_ns_err,
790  rvk,
792  rvk);
793  GNUNET_free (label);
794 }
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_RECLAIM_Identifier old_id
Old ID of the 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,...)
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:923
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 580 of file gnunet-service-reclaim_tickets.c.

References move_attrs().

Referenced by del_attr_finished(), and rvk_move_attr_cb().

581 {
582  move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls);
583 }
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 595 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().

596 {
597  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
598 
599  rvk->ns_qe = NULL;
600  if (GNUNET_SYSERR == success)
601  {
603  "Error removing attribute: %s\n",
604  emsg);
605  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
606  cleanup_rvk (rvk);
607  return;
608  }
609  rvk->move_attr = rvk->move_attr->next;
611 }
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:1298
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:84
#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 624 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().

625 {
626  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
627  char *label;
628 
629  rvk->ns_qe = NULL;
630  if (GNUNET_SYSERR == success)
631  {
632  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg);
633  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
634  cleanup_rvk (rvk);
635  return;
636  }
638  sizeof(rvk->move_attr->old_id));
639  GNUNET_assert (NULL != label);
640  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
642  &rvk->identity,
643  label,
644  0,
645  NULL,
647  rvk);
648  GNUNET_free (label);
649 }
Ticket revocation request handle.
struct GNUNET_RECLAIM_Identifier old_id
Old ID of the attribute.
#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:84
static struct GNUNET_NAMESTORE_Handle * nsh
#define GNUNET_log(kind,...)
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:923
#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 662 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, RECLAIM_TICKETS_RevokeHandle::attrs_tail, claim, data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_attestation_deserialize(), GNUNET_RECLAIM_attestation_serialize(), GNUNET_RECLAIM_attestation_serialize_get_size(), GNUNET_RECLAIM_attribute_deserialize(), GNUNET_RECLAIM_attribute_serialize(), GNUNET_RECLAIM_attribute_serialize_get_size(), GNUNET_RECLAIM_id_generate, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Attestation::id, RECLAIM_TICKETS_RevokeHandle::identity, RECLAIM_TICKETS_RevokeHandle::move_attr, move_attr_finished(), move_attrs_cont(), GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_Attestation::name, RevokedAttributeEntry::new_id, RevokedAttributeEntry::next, RECLAIM_TICKETS_RevokeHandle::ns_qe, and GNUNET_GNSRECORD_Data::record_type.

Referenced by move_attrs().

667 {
668  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
669  struct GNUNET_GNSRECORD_Data new_rd[rd_count];
670  struct RevokedAttributeEntry *le;
671  char *new_label;
672  char *attr_data;
673 
674  rvk->ns_qe = NULL;
675  if (0 == rd_count)
676  {
678  "The claim %s no longer exists!\n",
679  label);
680  le = rvk->move_attr;
681  rvk->move_attr = le->next;
683  GNUNET_free (le);
685  return;
686  }
688  new_label = NULL;
689  attr_data = NULL;
690  // new_rd = *rd;
691  for (int i = 0; i < rd_count; i++)
692  {
693  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
694  {
698  rd[i].data_size);
700  "Attribute to update: Name=%s\n",
701  claim->name);
702  claim->id = rvk->move_attr->new_id;
703  new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize_get_size (claim);
704  attr_data = GNUNET_malloc (rd[i].data_size);
705  new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize (claim,
706  attr_data);
707  new_rd[i].data = attr_data;
708  new_rd[i].record_type = rd[i].record_type;
709  new_rd[i].flags = rd[i].flags;
710  new_rd[i].expiration_time = rd[i].expiration_time;
711  new_label =
713  sizeof (rvk->move_attr->new_id));
714  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
715  GNUNET_free (claim);
716  }
717  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
718  {
719  struct GNUNET_RECLAIM_Attestation *attest;
721  rd[i].data_size);
723  "Attestation to update: Name=%s\n",
724  attest->name);
725  attest->id = rvk->move_attr->new_id;
726  new_rd[i].data_size =
728  attr_data = GNUNET_malloc (rd[i].data_size);
729  new_rd[i].data_size = GNUNET_RECLAIM_attestation_serialize (attest,
730  attr_data);
731  new_rd[i].data = attr_data;
732  new_rd[i].record_type = rd[i].record_type;
733  new_rd[i].flags = rd[i].flags;
734  new_rd[i].expiration_time = rd[i].expiration_time;
735  new_label =
737  sizeof (rvk->move_attr->new_id));
738  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation %s\n",
739  new_label);
740  GNUNET_free (attest);
741  }
742  }
744  &rvk->identity,
745  new_label,
746  rd_count,
747  new_rd,
749  rvk);
750  GNUNET_free (new_label);
751  GNUNET_free (attr_data);
752 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Ticket revocation request handle.
size_t GNUNET_RECLAIM_attestation_serialize(const struct GNUNET_RECLAIM_Attestation *attestation, char *result)
Serialize an attestation.
struct GNUNET_RECLAIM_Attribute * claim
Claim to store.
const char * name
The name of the attribute.
static void move_attr_finished(void *cls, int32_t success, const char *emsg)
Updated an attribute ID.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
struct RevokedAttributeEntry * next
DLL.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
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.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
uint64_t expiration_time
Expiration time for 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:1298
static void move_attrs_cont(void *cls)
Delayed continuation for move_attrs.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
struct GNUNET_RECLAIM_Identifier id
ID.
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
size_t GNUNET_RECLAIM_attestation_serialize_get_size(const struct GNUNET_RECLAIM_Attestation *attestation)
Get required size for serialization buffer.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier id
ID.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION
Record type for an attribute attestation.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
Record type for identity attributes (of RECLAIM).
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_Identifier new_id
New ID of the attribute.
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_log(kind,...)
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:923
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
#define GNUNET_RECLAIM_id_generate(id)
uint32_t data
The data value.
#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:

◆ 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 809 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().

810 {
811  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
812 
813  rvk->ns_qe = NULL;
814  if (GNUNET_SYSERR == success)
815  {
816  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
817  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
818  cleanup_rvk (rvk);
819  return;
820  }
821  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
822  if (0 == rvk->ticket_attrs)
823  {
825  "No attributes to move... strange\n");
826  rvk->cb (rvk->cb_cls, GNUNET_OK);
827  cleanup_rvk (rvk);
828  return;
829  }
830  rvk->move_attr = rvk->attrs_head;
831  move_attrs (rvk);
832 }
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:83
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:84
#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 846 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_ATTRIBUTE_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().

852 {
853  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
854  struct RevokedAttributeEntry *le;
855 
856  rvk->ns_qe = NULL;
861  for (int i = 0; i < rd_count; i++)
862  {
863  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
864  continue;
865  le = GNUNET_new (struct RevokedAttributeEntry);
866  le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
868  rvk->ticket_attrs++;
869  }
870 
873  &rvk->identity,
874  label,
875  0,
876  NULL,
878  rvk);
879 }
Ticket revocation request handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_RECLAIM_Identifier old_id
Old ID of the attribute.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct RevokedAttributeEntry * attrs_tail
Revoked attributes.
#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.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
Record type for reclaim records.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
A reclaim identifier FIXME maybe put this in a different namespace.
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.
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 888 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().

889 {
890  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
891 
892  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
893  cleanup_rvk (rvk);
894 }
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:84
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 909 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().

913 {
914  struct RECLAIM_TICKETS_RevokeHandle *rvk;
915  char *label;
916 
918  rvk->cb = cb;
919  rvk->cb_cls = cb_cls;
920  rvk->identity = *identity;
921  rvk->ticket = *ticket;
924  label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd,
925  sizeof(ticket->rnd));
926  GNUNET_assert (NULL != label);
928  identity,
929  label,
931  rvk,
933  rvk);
934  GNUNET_free (label);
935  return rvk;
936 }
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:172
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
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:923
#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 945 of file gnunet-service-reclaim_tickets.c.

References cleanup_rvk(), and GNUNET_assert.

Referenced by cleanup_client().

946 {
947  GNUNET_assert (NULL != rh);
948  cleanup_rvk (rh);
949 }
#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 962 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::attests, RECLAIM_TICKETS_ConsumeHandle::attrs, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, GNUNET_GNS_lookup_cancel(), GNUNET_RECLAIM_attestation_list_destroy(), 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().

963 {
964  struct ParallelLookup *lu;
965 
966  if (NULL != cth->lookup_request)
968  if (NULL != cth->kill_task)
970  while (NULL != (lu = cth->parallel_lookups_head))
971  {
972  if (NULL != lu->lookup_request)
977  lu);
978  GNUNET_free (lu);
979  }
980 
981  if (NULL != cth->attrs)
983  if (NULL != cth->attests)
985  GNUNET_free (cth);
986 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
void GNUNET_RECLAIM_attestation_list_destroy(struct GNUNET_RECLAIM_AttestationList *attestations)
Destroy claim list.
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
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_AttestationList * attests
Attestations.
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:314
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:974
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 997 of file gnunet-service-reclaim_tickets.c.

References GNUNET_RECLAIM_AttestationListEntry::attestation, RECLAIM_TICKETS_ConsumeHandle::attests, GNUNET_RECLAIM_AttributeListEntry::attribute, RECLAIM_TICKETS_ConsumeHandle::attrs, RECLAIM_TICKETS_ConsumeHandle::cb, RECLAIM_TICKETS_ConsumeHandle::cb_cls, cleanup_cth(), data, data_size, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_RECLAIM_attestation_deserialize(), GNUNET_RECLAIM_attribute_deserialize(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, ParallelLookup::handle, GNUNET_RECLAIM_Ticket::identity, ParallelLookup::label, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_AttestationList::list_head, GNUNET_RECLAIM_AttributeList::list_tail, GNUNET_RECLAIM_AttestationList::list_tail, ParallelLookup::lookup_start_time, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_head, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_tail, GNUNET_TIME_Relative::rel_value_us, and RECLAIM_TICKETS_ConsumeHandle::ticket.

Referenced by lookup_authz_cb().

1000 {
1001  struct ParallelLookup *parallel_lookup = cls;
1002  struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
1003  struct GNUNET_RECLAIM_AttributeListEntry *attr_le;
1004 
1006  "Parallel lookup finished (count=%u)\n",
1007  rd_count);
1008 
1010  cth->parallel_lookups_tail,
1011  parallel_lookup);
1012  GNUNET_free (parallel_lookup->label);
1013 
1015  "attribute_lookup_time_total",
1017  parallel_lookup->lookup_start_time)
1018  .rel_value_us,
1019  GNUNET_YES);
1020  GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
1021 
1022 
1023  GNUNET_free (parallel_lookup);
1024  if (0 == rd_count)
1025  GNUNET_break (0);
1026  // REMARK: It is possible now to find rd_count > 1
1027  for (int i = 0; i < rd_count; i++)
1028  {
1029  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
1030  {
1031  attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1032  attr_le->attribute =
1035  cth->attrs->list_tail,
1036  attr_le);
1037  }
1038  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
1039  {
1042  ale->attestation =
1044  rd[i].data_size);
1046  cth->attests->list_tail,
1047  ale);
1048  }
1049  else
1050  {
1052  "Parallel Lookup of Reference without Attestation");
1053  continue;
1054  }
1055 
1056 
1057  }
1058  if (NULL != cth->parallel_lookups_head)
1059  return; // Wait for more
1060  /* Else we are done */
1061  cth->cb (cth->cb_cls, &cth->ticket.identity,
1062  cth->attrs, cth->attests, GNUNET_OK, NULL);
1063  cleanup_cth (cth);
1064 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
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_TIME_Absolute lookup_start_time
Lookup time.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#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...
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_AttestationList * attests
Attestations.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
Handle to a consume operation.
static void cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cleanup ticket consume handle.
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION
Record type for an attribute attestation.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
Record type for identity attributes (of RECLAIM).
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
struct GNUNET_RECLAIM_AttestationListEntry * list_tail
List tail.
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:375
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:85
uint32_t data
The data value.
struct ParallelLookup * parallel_lookups_tail
Lookup DLL.
static struct GNUNET_STATISTICS_Handle * stats
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
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 1073 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().

1074 {
1075  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1076  struct ParallelLookup *lu;
1077  struct ParallelLookup *tmp;
1078 
1079  cth->kill_task = NULL;
1080  for (lu = cth->parallel_lookups_head; NULL != lu;)
1081  {
1083  GNUNET_free (lu->label);
1084  tmp = lu->next;
1086  cth->parallel_lookups_tail,
1087  lu);
1088  GNUNET_free (lu);
1089  lu = tmp;
1090  }
1091  cth->cb (cth->cb_cls, NULL, NULL, NULL, GNUNET_SYSERR, "Aborted");
1092 }
#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:84
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:314
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 1105 of file gnunet-service-reclaim_tickets.c.

References abort_parallel_lookups(), RECLAIM_TICKETS_ConsumeHandle::attests, 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_ANY, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_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().

1108 {
1109  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1110  struct ParallelLookup *parallel_lookup;
1111  char *lbl;
1112 
1113  cth->lookup_request = NULL;
1114 
1116  "reclaim_authz_lookup_time_total",
1118  cth->lookup_start_time)
1119  .rel_value_us,
1120  GNUNET_YES);
1122  "reclaim_authz_lookups_count",
1123  1,
1124  GNUNET_YES);
1125 
1126  for (int i = 0; i < rd_count; i++)
1127  {
1128  if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
1129  (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type))
1130  continue;
1131  lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1132  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl);
1133  parallel_lookup = GNUNET_new (struct ParallelLookup);
1134  parallel_lookup->handle = cth;
1135  parallel_lookup->label = lbl;
1136  parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get ();
1137  parallel_lookup->lookup_request =
1139  lbl,
1140  &cth->ticket.identity,
1144  parallel_lookup);
1146  cth->parallel_lookups_tail,
1147  parallel_lookup);
1148  }
1153  if (NULL != cth->parallel_lookups_head)
1154  {
1158  cth);
1159  return;
1160  }
1164  cth->cb (cth->cb_cls, &cth->ticket.identity,
1165  cth->attrs, cth->attests, GNUNET_OK, NULL);
1166  cleanup_cth (cth);
1167 }
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.
static void process_parallel_lookup_result(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We found an attribute record.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
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_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_AttestationList * attests
Attestations.
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:1271
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF
Record type for an attestation reference in a ticket.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
Record type for reclaim records.
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:442
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:375
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:85
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:923
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:412
uint32_t data
The data value.
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 1182 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::attests, 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_ATTRIBUTE_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, RECLAIM_TICKETS_ConsumeHandle::ticket, and TicketReference::ticket.

Referenced by handle_consume_ticket_message().

1186 {
1187  struct RECLAIM_TICKETS_ConsumeHandle *cth;
1188  char *label;
1189 
1191 
1192  cth->identity = *id;
1196  cth->ticket = *ticket;
1197  cth->cb = cb;
1198  cth->cb_cls = cb_cls;
1199  label =
1201  sizeof(cth->ticket.rnd));
1203  "Looking for AuthZ info under %s\n",
1204  label);
1206  cth->lookup_request =
1208  label,
1209  &cth->ticket.identity,
1212  &lookup_authz_cb,
1213  cth);
1214  GNUNET_free (label);
1215  return cth;
1216 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Audience Key.
A list of GNUNET_RECLAIM_Attribute structures.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
A list of GNUNET_RECLAIM_Attestation structures.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_RECLAIM_AttestationList * attests
Attestations.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
Record type for reclaim records.
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:172
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
RECLAIM_TICKETS_ConsumeCallback cb
Callback.
#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:923
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:412
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 1225 of file gnunet-service-reclaim_tickets.c.

References cleanup_cth().

Referenced by cleanup_client().

1226 {
1227  cleanup_cth (cth);
1228  return;
1229 }
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 1241 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().

1242 {
1243  if (NULL != handle->ns_qe)
1244  GNUNET_NAMESTORE_cancel (handle->ns_qe);
1245  GNUNET_free (handle);
1246 }
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 1258 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().

1259 {
1260  struct TicketIssueHandle *handle = cls;
1261 
1262  handle->ns_qe = NULL;
1263  if (GNUNET_SYSERR == success)
1264  {
1265  handle->cb (handle->cb_cls,
1266  &handle->ticket,
1267  GNUNET_SYSERR,
1268  "Error storing AuthZ ticket in GNS");
1269  return;
1270  }
1271  handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
1272  cleanup_issue_handle (handle);
1273 }
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:83
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:84
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

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

References GNUNET_RECLAIM_Attribute::attestation, GNUNET_RECLAIM_AttributeListEntry::attribute, TicketIssueHandle::attrs, data, 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_ATTESTATION_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_NO, GNUNET_RECLAIM_id_is_zero, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_Attribute::id, TicketIssueHandle::identity, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_AttributeListEntry::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().

1285 {
1287  struct GNUNET_GNSRECORD_Data *attrs_record;
1288  char *label;
1289  int i;
1290  int attrs_count = 0;
1291 
1292  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1293  attrs_count++;
1294 
1295  //Worst case we have one attestation per attribute
1296  attrs_record =
1297  GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
1298  i = 0;
1299  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1300  {
1301  attrs_record[i].data = &le->attribute->id;
1302  attrs_record[i].data_size = sizeof(le->attribute->id);
1306  i++;
1308  {
1309  int j;
1310  for (j = 0; j < i; j++)
1311  {
1312  if (attrs_record[j].record_type
1314  continue;
1315  if (0 == memcmp (attrs_record[j].data,
1316  &le->attribute->attestation,
1317  sizeof (le->attribute->attestation)))
1318  break;
1319  }
1320  if (j < i)
1321  continue; // Skip as we have already added this attestation.
1322  attrs_record[i].data = &le->attribute->attestation;
1323  attrs_record[i].data_size = sizeof(le->attribute->attestation);
1325  attrs_record[i].record_type =
1328  i++;
1329  }
1330  }
1331  attrs_record[i].data = &ih->ticket;
1332  attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
1335  attrs_record[i].flags =
1337  i++;
1338 
1339  label =
1341  sizeof(ih->ticket.rnd));
1342  // Publish record
1344  &ih->identity,
1345  label,
1346  i,
1347  attrs_record,
1349  ih);
1350  GNUNET_free (attrs_record);
1351  GNUNET_free (label);
1352 }
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_NO
Definition: gnunet_common.h:86
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
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_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF
Record type for an attestation reference in a ticket.
const void * data
Binary value stored in the DNS record.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
Record type for reclaim records.
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes to issue.
struct GNUNET_RECLAIM_Identifier id
ID.
This is a private record of this peer and it should thus not be handed out to other peers...
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
uint32_t record_type
Type of the GNS/DNS record.
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
#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:923
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This expiration time of the record is a relative time (not an absolute time).
uint32_t data
The data value.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_RECLAIM_id_is_zero(a)
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 1366 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().

1367 {
1368  struct TicketIssueHandle *tih = cls;
1369 
1370  tih->ns_it = NULL;
1371  tih->cb (tih->cb_cls,
1372  &tih->ticket,
1373  GNUNET_SYSERR,
1374  "Error storing AuthZ ticket in GNS");
1375  cleanup_issue_handle (tih);
1376 }
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:84
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 1392 of file gnunet-service-reclaim_tickets.c.

References GNUNET_RECLAIM_Attribute::attestation, GNUNET_RECLAIM_AttributeListEntry::attribute, TicketIssueHandle::attrs, GNUNET_RECLAIM_Ticket::audience, TicketIssueHandle::cb, TicketIssueHandle::cb_cls, cleanup_issue_handle(), data, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_NO, GNUNET_OK, GNUNET_RECLAIM_id_is_equal, GNUNET_RECLAIM_id_is_zero, GNUNET_YES, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_AttributeListEntry::next, TicketIssueHandle::ns_it, GNUNET_GNSRECORD_Data::record_type, TicketReference::ticket, and TicketIssueHandle::ticket.

Referenced by RECLAIM_TICKETS_issue().

1397 {
1398  struct TicketIssueHandle *tih = cls;
1399  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1400 
1401  // figure out the number of requested attributes
1403  unsigned int attr_cnt = 0;
1404  unsigned int attest_cnt = 0;
1405 
1406  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1407  {
1408  attr_cnt++;
1410  attest_cnt++;
1411  }
1412 
1413  // ticket search
1414  unsigned int found_attrs_cnt = 0;
1415  unsigned int found_attests_cnt = 0;
1416 
1417  for (int i = 0; i < rd_count; i++)
1418  {
1419  // found ticket
1420  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1421  {
1422  ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data;
1423  // cmp audience
1424  if (0 == memcmp (&tih->ticket.audience,
1425  &ticket->audience,
1426  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1427  {
1428  tih->ticket = *ticket;
1429  continue;
1430  }
1431  ticket = NULL;
1432  }
1433 
1434  // cmp requested attributes with ticket attributes
1435  if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
1437  continue;
1438  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1439  {
1441  &le->attribute->id))
1442  found_attrs_cnt++;
1443  }
1444  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1445  {
1447  &le->attribute->attestation))
1448  found_attests_cnt++;
1449  }
1450  }
1451 
1456  if ((attr_cnt == found_attrs_cnt) &&
1457  (attest_cnt == found_attests_cnt) &&
1458  (NULL != ticket))
1459  {
1461  tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
1462  cleanup_issue_handle (tih);
1463  return;
1464  }
1465 
1466  // ticket not found in current record, checking next record set
1468 }
The authorization ticket.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
#define GNUNET_NO
Definition: gnunet_common.h:86
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
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_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF
Record type for an attestation reference in a ticket.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
Record type for reclaim records.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes to issue.
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
struct GNUNET_RECLAIM_Identifier id
ID.
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_AttributeListEntry * next
DLL.
uint32_t record_type
Type of the GNS/DNS record.
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_RECLAIM_id_is_equal(a, b)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
Ticket issue request handle.
RECLAIM_TICKETS_TicketResult cb
Callback.
#define GNUNET_YES
Definition: gnunet_common.h:85
uint32_t data
The data value.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_RECLAIM_id_is_zero(a)
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 1479 of file gnunet-service-reclaim_tickets.c.

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

Referenced by RECLAIM_TICKETS_issue().

1480 {
1481  struct TicketIssueHandle *tih = cls;
1482 
1485  issue_ticket (tih);
1486 }
static void issue_ticket(struct TicketIssueHandle *ih)
Issue a new ticket.
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:172
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
Ticket issue request handle.
#define GNUNET_RECLAIM_id_generate(id)
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Issuer Key.
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_AttributeList 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 1501 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().

1506 {
1507  struct TicketIssueHandle *tih;
1508 
1509  tih = GNUNET_new (struct TicketIssueHandle);
1510  tih->cb = cb;
1511  tih->cb_cls = cb_cls;
1513  tih->identity = *identity;
1514  tih->ticket.audience = *audience;
1515 
1516  // First check whether the ticket has already been issued
1517  tih->ns_it =
1519  &tih->identity,
1521  tih,
1523  tih,
1525  tih);
1526 }
static void filter_tickets_finished_cb(void *cls)
Done iterating over tickets and we apparently did not find an existing, matching ticket.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_dup(const struct GNUNET_RECLAIM_AttributeList *attrs)
Make a (deep) copy of a claim list.
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_RECLAIM_AttributeList * attrs
Attributes to 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_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_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 1539 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().

1540 {
1541  if (NULL != iter->ns_it)
1543  GNUNET_free (iter);
1544 }
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 1559 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().

1564 {
1565  struct RECLAIM_TICKETS_Iterator *iter = cls;
1566 
1567  for (int i = 0; i < rd_count; i++)
1568  {
1569  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1570  continue;
1571  iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data);
1572  return;
1573  }
1575 }
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 1584 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().

1585 {
1586  struct RECLAIM_TICKETS_Iterator *iter = cls;
1587 
1588  iter->ns_it = NULL;
1589  iter->cb (iter->cb_cls, NULL);
1590  cleanup_iter (iter);
1591 }
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 1600 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().

1601 {
1602  struct RECLAIM_TICKETS_Iterator *iter = cls;
1603 
1604  iter->ns_it = NULL;
1605  iter->cb (iter->cb_cls, NULL);
1606  cleanup_iter (iter);
1607 }
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 1616 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().

1617 {
1619 }
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 1628 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().

1629 {
1631  cleanup_iter (iter);
1632 }
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 1644 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().

1648 {
1649  struct RECLAIM_TICKETS_Iterator *iter;
1650 
1651  iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1652  iter->cb = cb;
1653  iter->cb_cls = cb_cls;
1654  iter->ns_it =
1656  identity,
1658  iter,
1660  iter,
1662  iter);
1663  return iter;
1664 }
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 1674 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().

1675 {
1676  // Get ticket expiration time (relative) from config
1677  if (GNUNET_OK ==
1679  "reclaim",
1680  "TICKET_REFRESH_INTERVAL",
1682  {
1684  "Configured refresh interval for tickets: %s\n",
1686  GNUNET_YES));
1687  }
1688  else
1689  {
1691  }
1692  // Connect to identity and namestore services
1694  if (NULL == nsh)
1695  {
1697  "error connecting to namestore");
1698  return GNUNET_SYSERR;
1699  }
1700  gns = GNUNET_GNS_connect (c);
1701  if (NULL == gns)
1702  {
1703  GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1704  return GNUNET_SYSERR;
1705  }
1706  stats = GNUNET_STATISTICS_create ("reclaim", c);
1707  return GNUNET_OK;
1708 }
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:83
#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:690
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:268
#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:84
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:85
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 1716 of file gnunet-service-reclaim_tickets.c.

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

Referenced by cleanup().

1717 {
1718  if (NULL != nsh)
1720  nsh = NULL;
1721  if (NULL != gns)
1723  gns = NULL;
1724  if (NULL != stats)
1725  {
1727  stats = NULL;
1728  }
1729 }
#define GNUNET_NO
Definition: gnunet_common.h:86
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:290
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 323 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 327 of file gnunet-service-reclaim_tickets.c.

◆ gns

struct GNUNET_GNS_Handle* gns
static

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

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

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