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 349 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().

350 {
351  struct RevokedAttributeEntry *ae;
352  struct TicketRecordsEntry *le;
353 
354  if (NULL != rh->ns_qe)
356  if (NULL != rh->ns_it)
358  while (NULL != (ae = rh->attrs_head))
359  {
361  GNUNET_free (ae);
362  }
363  while (NULL != (le = rh->tickets_to_update_head))
364  {
367  le);
368  if (NULL != le->data)
369  GNUNET_free (le->data);
370  if (NULL != le->label)
371  GNUNET_free (le->label);
372  GNUNET_free (le);
373  }
374  GNUNET_free (rh);
375 }
#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 412 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().

413 {
414  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
415  struct TicketRecordsEntry *le;
416  struct RevokedAttributeEntry *ae;
417 
418  if (NULL == rvk->tickets_to_update_head)
419  {
421  "Finished updatding tickets, success\n");
422  rvk->cb (rvk->cb_cls, GNUNET_OK);
423  cleanup_rvk (rvk);
424  return;
425  }
426  le = rvk->tickets_to_update_head;
429  le);
430  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
432  le->data,
433  le->rd_count,
434  rd))
435  {
437  "Unable to deserialize ticket record(s)\n");
438  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
439  cleanup_rvk (rvk);
440  return;
441  }
442  for (int i = 0; i < le->rd_count; i++)
443  {
445  continue;
446  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
447  {
448  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
449  continue;
450  rd[i].data = &ae->new_id;
451  }
452  }
454  &rvk->identity,
455  le->label,
456  le->rd_count,
457  rd,
459  rvk);
460  GNUNET_free (le->label);
461  GNUNET_free (le->data);
462  GNUNET_free (le);
463 }
#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.
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.
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 397 of file gnunet-service-reclaim_tickets.c.

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

Referenced by process_tickets().

398 {
399  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
400 
401  rvk->ns_qe = NULL;
403 }
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:1296
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 472 of file gnunet-service-reclaim_tickets.c.

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

Referenced by move_attrs().

473 {
474  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
475 
476  rvk->ns_it = NULL;
478 }
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:1296
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 492 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().

497 {
498  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
499  struct TicketRecordsEntry *le;
500  struct RevokedAttributeEntry *ae;
501  int has_changed = GNUNET_NO;
502 
504  for (int i = 0; i < rd_count; i++)
505  {
506  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
507  continue;
508  for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
509  {
510  if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(ae->old_id)))
511  continue;
512  has_changed = GNUNET_YES;
513  break;
514  }
515  if (GNUNET_YES == has_changed)
516  break;
517  }
518  if (GNUNET_YES == has_changed)
519  {
520  le = GNUNET_new (struct TicketRecordsEntry);
521  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
522  le->data = GNUNET_malloc (le->data_size);
523  le->rd_count = rd_count;
524  le->label = GNUNET_strdup (label);
525  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
528  le);
529  }
531 }
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_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.
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 540 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().

541 {
542  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
543 
544  rvk->ns_it = NULL;
545  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
546  cleanup_rvk (rvk);
547 }
Ticket revocation request handle.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
static void cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cleanup revoke handle.
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 556 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().

557 {
558  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
559 
560  rvk->ns_qe = NULL;
561  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
562  cleanup_rvk (rvk);
563 }
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.
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 770 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().

771 {
772  char *label;
773 
774  if (NULL == rvk->move_attr)
775  {
776  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
777  rvk->ns_it =
779  &rvk->identity,
781  rvk,
783  rvk,
785  rvk);
786  return;
787  }
789  sizeof (rvk->move_attr->old_id));
790  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving claim %s\n", label);
791 
793  &rvk->identity,
794  label,
795  &rvk_ns_err,
796  rvk,
798  rvk);
799  GNUNET_free (label);
800 }
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:936
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 585 of file gnunet-service-reclaim_tickets.c.

References move_attrs().

Referenced by del_attr_finished(), and rvk_move_attr_cb().

586 {
587  move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls);
588 }
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 600 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().

601 {
602  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
603 
604  rvk->ns_qe = NULL;
605  if (GNUNET_SYSERR == success)
606  {
608  "Error removing attribute: %s\n",
609  emsg);
610  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
611  cleanup_rvk (rvk);
612  return;
613  }
614  rvk->move_attr = rvk->move_attr->next;
616 }
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:1296
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_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 629 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().

630 {
631  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
632  char *label;
633 
634  rvk->ns_qe = NULL;
635  if (GNUNET_SYSERR == success)
636  {
637  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg);
638  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
639  cleanup_rvk (rvk);
640  return;
641  }
643  sizeof(rvk->move_attr->old_id));
644  GNUNET_assert (NULL != label);
645  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
647  &rvk->identity,
648  label,
649  0,
650  NULL,
652  rvk);
653  GNUNET_free (label);
654 }
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.
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:936
#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 667 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_RevokeHandle::attrs_head, RECLAIM_TICKETS_RevokeHandle::attrs_tail, claim, credential, 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_ATTRIBUTE, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_attribute_deserialize(), GNUNET_RECLAIM_attribute_serialize(), GNUNET_RECLAIM_attribute_serialize_get_size(), GNUNET_RECLAIM_credential_deserialize(), GNUNET_RECLAIM_credential_serialize(), GNUNET_RECLAIM_credential_serialize_get_size(), GNUNET_RECLAIM_id_generate, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Credential::id, RECLAIM_TICKETS_RevokeHandle::identity, RECLAIM_TICKETS_RevokeHandle::move_attr, move_attr_finished(), move_attrs_cont(), GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_Credential::name, RevokedAttributeEntry::new_id, RevokedAttributeEntry::next, RECLAIM_TICKETS_RevokeHandle::ns_qe, and GNUNET_GNSRECORD_Data::record_type.

Referenced by move_attrs().

672 {
673  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
674  struct GNUNET_GNSRECORD_Data new_rd[rd_count];
675  struct RevokedAttributeEntry *le;
676  char *new_label;
677  char *attr_data;
678 
679  rvk->ns_qe = NULL;
680  if (0 == rd_count)
681  {
683  "The claim %s no longer exists!\n",
684  label);
685  le = rvk->move_attr;
686  rvk->move_attr = le->next;
688  GNUNET_free (le);
690  return;
691  }
693  new_label = NULL;
694  attr_data = NULL;
695  // new_rd = *rd;
696  for (int i = 0; i < rd_count; i++)
697  {
698  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type)
699  {
703  rd[i].data_size,
704  &claim);
706  "Attribute to update: Name=%s\n",
707  claim->name);
708  claim->id = rvk->move_attr->new_id;
709  new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize_get_size (claim);
710  attr_data = GNUNET_malloc (rd[i].data_size);
711  new_rd[i].data_size = GNUNET_RECLAIM_attribute_serialize (claim,
712  attr_data);
713  new_rd[i].data = attr_data;
714  new_rd[i].record_type = rd[i].record_type;
715  new_rd[i].flags = rd[i].flags;
716  new_rd[i].expiration_time = rd[i].expiration_time;
717  new_label =
719  sizeof (rvk->move_attr->new_id));
720  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
721  GNUNET_free (claim);
722  }
723  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
724  {
726  credential = GNUNET_RECLAIM_credential_deserialize (rd[i].data,
727  rd[i].data_size);
729  "Credential to update: Name=%s\n",
730  credential->name);
731  credential->id = rvk->move_attr->new_id;
732  new_rd[i].data_size =
734  attr_data = GNUNET_malloc (rd[i].data_size);
735  new_rd[i].data_size = GNUNET_RECLAIM_credential_serialize (credential,
736  attr_data);
737  new_rd[i].data = attr_data;
738  new_rd[i].record_type = rd[i].record_type;
739  new_rd[i].flags = rd[i].flags;
740  new_rd[i].expiration_time = rd[i].expiration_time;
741  new_label =
743  sizeof (rvk->move_attr->new_id));
744  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n",
745  new_label);
746  GNUNET_free (credential);
747  }
748  }
750  &rvk->identity,
751  new_label,
752  rd_count,
753  new_rd,
755  rvk);
756  GNUNET_free (new_label);
757  GNUNET_free (attr_data);
758 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
struct GNUNET_RECLAIM_Identifier id
ID.
Ticket revocation request handle.
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
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.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL
Record type for an attribute attestation.
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.
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:1296
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.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
struct RevokedAttributeEntry * attrs_head
Revoked attributes.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
Record type for identity attributes (of RECLAIM).
const char * name
The name of the credential.
static struct GNUNET_NAMESTORE_Handle * nsh
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
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:936
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 815 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().

816 {
817  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
818 
819  rvk->ns_qe = NULL;
820  if (GNUNET_SYSERR == success)
821  {
822  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
823  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
824  cleanup_rvk (rvk);
825  return;
826  }
827  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
828  if (0 == rvk->ticket_attrs)
829  {
831  "No attributes to move... strange\n");
832  rvk->cb (rvk->cb_cls, GNUNET_OK);
833  cleanup_rvk (rvk);
834  return;
835  }
836  rvk->move_attr = rvk->attrs_head;
837  move_attrs (rvk);
838 }
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.
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_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 852 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().

858 {
859  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
860  struct RevokedAttributeEntry *le;
861 
862  rvk->ns_qe = NULL;
867  for (int i = 0; i < rd_count; i++)
868  {
869  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type)
870  continue;
871  le = GNUNET_new (struct RevokedAttributeEntry);
872  le->old_id = *((struct GNUNET_RECLAIM_Identifier *) rd[i].data);
874  rvk->ticket_attrs++;
875  }
876 
879  &rvk->identity,
880  label,
881  0,
882  NULL,
884  rvk);
885 }
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 894 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().

895 {
896  struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
897 
898  rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
899  cleanup_rvk (rvk);
900 }
Ticket revocation request handle.
RECLAIM_TICKETS_RevokeCallback cb
Callback.
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:

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

919 {
920  struct RECLAIM_TICKETS_RevokeHandle *rvk;
921  char *label;
922 
924  rvk->cb = cb;
925  rvk->cb_cls = cb_cls;
926  rvk->identity = *identity;
927  rvk->ticket = *ticket;
930  label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd,
931  sizeof(ticket->rnd));
932  GNUNET_assert (NULL != label);
934  identity,
935  label,
937  rvk,
939  rvk);
940  GNUNET_free (label);
941  return rvk;
942 }
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:176
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:936
#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 951 of file gnunet-service-reclaim_tickets.c.

References cleanup_rvk(), and GNUNET_assert.

Referenced by cleanup_client().

952 {
953  GNUNET_assert (NULL != rh);
954  cleanup_rvk (rh);
955 }
#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 968 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::attrs, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_GNS_lookup_cancel(), GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_presentation_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, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_tail, and RECLAIM_TICKETS_ConsumeHandle::presentations.

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

969 {
970  struct ParallelLookup *lu;
971 
972  if (NULL != cth->lookup_request)
974  if (NULL != cth->kill_task)
976  while (NULL != (lu = cth->parallel_lookups_head))
977  {
978  if (NULL != lu->lookup_request)
980  GNUNET_free (lu->label);
983  lu);
984  GNUNET_free (lu);
985  }
986 
987  if (NULL != cth->attrs)
989  if (NULL != cth->presentations)
991  GNUNET_free (cth);
992 }
#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.
struct GNUNET_SCHEDULER_Task * kill_task
Kill task.
struct GNUNET_GNS_LookupRequest * lookup_request
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
Definition: gns_api.c: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:972
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 1003 of file gnunet-service-reclaim_tickets.c.

References 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_ATTRIBUTE, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_RECLAIM_attribute_deserialize(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, ParallelLookup::handle, GNUNET_RECLAIM_Ticket::identity, ParallelLookup::label, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_AttributeList::list_tail, ParallelLookup::lookup_start_time, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_head, RECLAIM_TICKETS_ConsumeHandle::parallel_lookups_tail, RECLAIM_TICKETS_ConsumeHandle::presentations, GNUNET_TIME_Relative::rel_value_us, and RECLAIM_TICKETS_ConsumeHandle::ticket.

Referenced by lookup_authz_cb().

1006 {
1007  struct ParallelLookup *parallel_lookup = cls;
1008  struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
1009  struct GNUNET_RECLAIM_AttributeListEntry *attr_le;
1010 
1012  "Parallel lookup finished (count=%u)\n",
1013  rd_count);
1014 
1016  cth->parallel_lookups_tail,
1017  parallel_lookup);
1018  GNUNET_free (parallel_lookup->label);
1019 
1021  "attribute_lookup_time_total",
1023  parallel_lookup->lookup_start_time)
1024  .rel_value_us,
1025  GNUNET_YES);
1026  GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
1027 
1028 
1029  GNUNET_free (parallel_lookup);
1030  if (0 == rd_count)
1031  GNUNET_break (0);
1032  // REMARK: It is possible now to find rd_count > 1
1033  for (int i = 0; i < rd_count; i++)
1034  {
1035  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type)
1036  continue;
1037  attr_le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
1039  &attr_le->attribute);
1041  cth->attrs->list_tail,
1042  attr_le);
1043  }
1044  if (NULL != cth->parallel_lookups_head)
1045  return; // Wait for more
1046  /* Else we are done */
1047  cth->cb (cth->cb_cls, &cth->ticket.identity,
1048  cth->attrs, cth->presentations, GNUNET_OK, NULL);
1049  cleanup_cth (cth);
1050 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
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
#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_PresentationList * presentations
Presentations.
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_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
Record type for identity attributes (of RECLAIM).
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,...)
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 1059 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().

1060 {
1061  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1062  struct ParallelLookup *lu;
1063  struct ParallelLookup *tmp;
1064 
1065  cth->kill_task = NULL;
1066  for (lu = cth->parallel_lookups_head; NULL != lu;)
1067  {
1069  GNUNET_free (lu->label);
1070  tmp = lu->next;
1072  cth->parallel_lookups_tail,
1073  lu);
1074  GNUNET_free (lu);
1075  lu = tmp;
1076  }
1077  cth->cb (cth->cb_cls, NULL, NULL, NULL, GNUNET_SYSERR, "Aborted");
1078 }
#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.
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

Check if record is a credential presentation or an attribute reference.

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

No references found, return empty attribute list

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

References abort_parallel_lookups(), RECLAIM_TICKETS_ConsumeHandle::attrs, RECLAIM_TICKETS_ConsumeHandle::cb, RECLAIM_TICKETS_ConsumeHandle::cb_cls, cleanup_cth(), data, data_size, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_ANY, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_RECLAIM_presentation_deserialize(), 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, GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_PresentationList::list_tail, 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, GNUNET_RECLAIM_PresentationListEntry::presentation, RECLAIM_TICKETS_ConsumeHandle::presentations, process_parallel_lookup_result(), GNUNET_TIME_Relative::rel_value_us, and RECLAIM_TICKETS_ConsumeHandle::ticket.

Referenced by RECLAIM_TICKETS_consume().

1094 {
1095  struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1096  struct ParallelLookup *parallel_lookup;
1097  char *lbl;
1099 
1100  cth->lookup_request = NULL;
1101 
1103  "reclaim_authz_lookup_time_total",
1105  cth->lookup_start_time)
1106  .rel_value_us,
1107  GNUNET_YES);
1109  "reclaim_authz_lookups_count",
1110  1,
1111  GNUNET_YES);
1112 
1113  for (int i = 0; i < rd_count; i++)
1114  {
1119  switch (rd[i].record_type)
1120  {
1123  ale->presentation =
1125  rd[i].data_size);
1127  cth->presentations->list_tail,
1128  ale);
1129  break;
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  break;
1149  default:
1151  "Ignoring unknown record type %d", rd[i].record_type);
1152  }
1153  }
1158  if (NULL != cth->parallel_lookups_head)
1159  {
1163  cth);
1164  return;
1165  }
1169  cth->cb (cth->cb_cls, &cth->ticket.identity,
1170  cth->attrs, NULL, GNUNET_OK, NULL);
1171  cleanup_cth (cth);
1172 }
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;.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
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_PresentationList * presentations
Presentations.
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:1269
#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.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential (used in a ticket record set)
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_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
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,...)
struct GNUNET_RECLAIM_PresentationListEntry * list_tail
List tail.
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:936
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 1187 of file gnunet-service-reclaim_tickets.c.

References RECLAIM_TICKETS_ConsumeHandle::attrs, RECLAIM_TICKETS_ConsumeHandle::cb, RECLAIM_TICKETS_ConsumeHandle::cb_cls, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_RECLAIM_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, RECLAIM_TICKETS_ConsumeHandle::presentations, GNUNET_RECLAIM_Ticket::rnd, TicketReference::ticket, and RECLAIM_TICKETS_ConsumeHandle::ticket.

Referenced by handle_consume_ticket_message().

1191 {
1192  struct RECLAIM_TICKETS_ConsumeHandle *cth;
1193  char *label;
1194 
1196 
1197  cth->identity = *id;
1201  cth->ticket = *ticket;
1202  cth->cb = cb;
1203  cth->cb_cls = cb_cls;
1204  label =
1206  sizeof(cth->ticket.rnd));
1208  "Looking for AuthZ info under %s\n",
1209  label);
1211  cth->lookup_request =
1213  label,
1214  &cth->ticket.identity,
1217  &lookup_authz_cb,
1218  cth);
1219  GNUNET_free (label);
1220  return cth;
1221 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Audience Key.
A list of GNUNET_RECLAIM_Attribute structures.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute lookup_start_time
Lookup time.
struct GNUNET_RECLAIM_AttributeList * attrs
Attributes.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
#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:176
struct GNUNET_GNS_LookupRequest * lookup_request
LookupRequest.
struct GNUNET_RECLAIM_Ticket ticket
Ticket.
A list of GNUNET_RECLAIM_Presentation structures.
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:936
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 1230 of file gnunet-service-reclaim_tickets.c.

References cleanup_cth().

Referenced by cleanup_client().

1231 {
1232  cleanup_cth (cth);
1233  return;
1234 }
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 1246 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().

1247 {
1248  if (NULL != handle->ns_qe)
1249  GNUNET_NAMESTORE_cancel (handle->ns_qe);
1250  GNUNET_free (handle);
1251 }
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 1263 of file gnunet-service-reclaim_tickets.c.

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

Referenced by issue_ticket().

1264 {
1265  struct TicketIssueHandle *handle = cls;
1266 
1267  handle->ns_qe = NULL;
1268  if (GNUNET_SYSERR == success)
1269  {
1270  handle->cb (handle->cb_cls,
1271  &handle->ticket,
1272  NULL,
1273  GNUNET_SYSERR,
1274  "Error storing AuthZ ticket in GNS");
1275  return;
1276  }
1277  handle->cb (handle->cb_cls,
1278  &handle->ticket,
1279  handle->presentations,
1280  GNUNET_OK, NULL);
1281  cleanup_issue_handle (handle);
1282 }
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
static void cleanup_issue_handle(struct TicketIssueHandle *handle)
Cleanup ticket consume handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
Ticket issue request handle.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations to add.
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 1293 of file gnunet-service-reclaim_tickets.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, TicketIssueHandle::attrs, GNUNET_RECLAIM_Attribute::credential, GNUNET_RECLAIM_Presentation::credential_id, data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_NO, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_presentation_deserialize(), GNUNET_RECLAIM_presentation_serialize(), GNUNET_RECLAIM_presentation_serialize_get_size(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_Attribute::id, TicketIssueHandle::identity, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_AttributeListEntry::next, GNUNET_RECLAIM_PresentationListEntry::next, TicketIssueHandle::ns_qe, GNUNET_RECLAIM_PresentationListEntry::presentation, TicketIssueHandle::presentations, 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().

1294 {
1297  struct GNUNET_GNSRECORD_Data *attrs_record;
1298  char *label;
1299  int i;
1300  int j;
1301  int attrs_count = 0;
1302 
1303  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1304  attrs_count++;
1305 
1306  // Worst case we have one presentation per attribute
1307  attrs_record =
1308  GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
1309  i = 0;
1310  for (le = ih->attrs->list_head; NULL != le; le = le->next)
1311  {
1313  "Adding list entry: %s\n", le->attribute->name);
1314 
1315  attrs_record[i].data = &le->attribute->id;
1316  attrs_record[i].data_size = sizeof(le->attribute->id);
1320  i++;
1322  {
1324  "Attribute is backed by credential. Adding...\n");
1325  struct GNUNET_RECLAIM_Presentation *pres = NULL;
1326  for (j = 0; j < i; j++)
1327  {
1328  if (attrs_record[j].record_type
1330  continue;
1331  pres = GNUNET_RECLAIM_presentation_deserialize (attrs_record[j].data,
1332  attrs_record[j].
1333  data_size);
1334  if (NULL == pres)
1335  {
1337  "Failed to deserialize presentation\n");
1338  continue;
1339  }
1340  if (0 == memcmp (&pres->credential_id,
1341  &le->attribute->credential,
1342  sizeof (le->attribute->credential)))
1343  break;
1344  GNUNET_free (pres);
1345  pres = NULL;
1346  }
1347  if (NULL != pres)
1348  {
1349  GNUNET_free (pres);
1350  continue; // Skip as we have already added this credential presentation.
1351  }
1352  for (ple = ih->presentations->list_head; NULL != ple; ple = ple->next)
1353  {
1355  "Checking presentation....\n");
1356 
1357  if (0 != memcmp (&le->attribute->credential,
1358  &ple->presentation->credential_id,
1359  sizeof (le->attribute->credential)))
1360  {
1362  "Presentation does not match credential ID.\n");
1363  continue;
1364  }
1365  char *pres_buf;
1366  size_t pres_size;
1367  pres_size =
1369  pres_buf = GNUNET_malloc (pres_size);
1371  pres_buf);
1372  attrs_record[i].data = pres_buf;
1373  attrs_record[i].data_size = pres_size;
1374  attrs_record[i].expiration_time =
1376  attrs_record[i].record_type =
1379  i++;
1380  break;
1381  }
1382  }
1383  }
1384  attrs_record[i].data = &ih->ticket;
1385  attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
1388  attrs_record[i].flags =
1390  i++;
1391 
1392  label =
1394  sizeof(ih->ticket.rnd));
1395  // Publish record
1397  &ih->identity,
1398  label,
1399  i,
1400  attrs_record,
1402  ih);
1403  for (j = 0; j > i; j++)
1404  {
1405  if (attrs_record[j].record_type
1407  continue;
1408  // Yes, we are allowed to do this because we allocated it above
1409  char *ptr = (char*) attrs_record[j].data;
1410  GNUNET_free (ptr);
1411  }
1412  GNUNET_free (attrs_record);
1413  GNUNET_free (label);
1414 }
The authorization ticket.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
size_t GNUNET_RECLAIM_presentation_serialize(const struct GNUNET_RECLAIM_Presentation *presentation, char *result)
Serialize a presentation.
uint64_t rel_value_us
The actual value.
const char * name
The name of the attribute.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static struct GNUNET_TIME_Relative ticket_refresh_interval
Ticket expiration interval.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
static void store_ticket_issue_cont(void *cls, int32_t success, const char *emsg)
Store finished, abort on error.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
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.
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 credential_id
The credential id of which this is a presentation.
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...
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential (used in a ticket record set)
A credential presentation.
static struct GNUNET_NAMESTORE_Handle * nsh
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
uint32_t record_type
Type of the GNS/DNS record.
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
#define GNUNET_log(kind,...)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
size_t GNUNET_RECLAIM_presentation_serialize_get_size(const struct GNUNET_RECLAIM_Presentation *presentation)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations to add.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:936
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 1428 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().

1429 {
1430  struct TicketIssueHandle *tih = cls;
1431 
1432  tih->ns_it = NULL;
1433  tih->cb (tih->cb_cls,
1434  &tih->ticket,
1435  NULL,
1436  GNUNET_SYSERR,
1437  "Error storing AuthZ ticket in GNS");
1438  cleanup_issue_handle (tih);
1439 }
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.
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 1455 of file gnunet-service-reclaim_tickets.c.

References GNUNET_RECLAIM_AttributeListEntry::attribute, TicketIssueHandle::attrs, GNUNET_RECLAIM_Ticket::audience, TicketIssueHandle::cb, TicketIssueHandle::cb_cls, cleanup_issue_handle(), GNUNET_RECLAIM_Attribute::credential, GNUNET_RECLAIM_Presentation::credential_id, data, data_size, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_RECLAIM_credential_deserialize(), GNUNET_RECLAIM_credential_get_presentation(), GNUNET_RECLAIM_id_is_equal, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_presentation_deserialize(), GNUNET_RECLAIM_presentation_list_destroy(), GNUNET_YES, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Credential::id, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_PresentationList::list_tail, GNUNET_RECLAIM_AttributeListEntry::next, TicketIssueHandle::ns_it, GNUNET_RECLAIM_PresentationListEntry::presentation, TicketIssueHandle::presentations, TicketReference::ticket, and TicketIssueHandle::ticket.

Referenced by RECLAIM_TICKETS_issue().

1460 {
1461  struct TicketIssueHandle *tih = cls;
1462  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1463  struct GNUNET_RECLAIM_Presentation *pres;
1464  struct GNUNET_RECLAIM_PresentationList *ticket_presentations;
1465  struct GNUNET_RECLAIM_Credential *cred;
1468  unsigned int attr_cnt = 0;
1469  unsigned int pres_cnt = 0;
1470 
1471  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1472  {
1473  attr_cnt++;
1475  pres_cnt++;
1476  }
1477 
1478  // ticket search
1479  unsigned int found_attrs_cnt = 0;
1480  unsigned int found_pres_cnt = 0;
1481  ticket_presentations = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
1482 
1483  for (int i = 0; i < rd_count; i++)
1484  {
1485  // found ticket
1486  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1487  {
1488  ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data;
1489  // cmp audience
1490  if (0 == memcmp (&tih->ticket.audience,
1491  &ticket->audience,
1492  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1493  {
1494  tih->ticket = *ticket;
1495  continue;
1496  }
1497  ticket = NULL;
1498  }
1499 
1500  // cmp requested attributes with ticket attributes
1501  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type)
1502  {
1503  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1504  {
1506  &le->attribute->id))
1507  found_attrs_cnt++;
1508  }
1509  }
1510  if (GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL == rd[i].record_type)
1511  {
1513  "Found credential...\n");
1514 
1515  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1516  {
1518  rd[i].data_size);
1519  if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (&cred->id,
1520  &le->attribute->credential))
1521  {
1523  "No match.\n");
1524  GNUNET_free (cred);
1525  continue;
1526  }
1528  "Match, creating presentation...\n");
1530  cred,
1531  tih->attrs,
1532  &pres))
1533  {
1535  "Unable to retrieve presentation from credential\n");
1536  GNUNET_free (cred);
1537  continue;
1538  }
1540  ple->presentation = pres;
1542  tih->presentations->list_tail,
1543  ple);
1544  GNUNET_free (cred);
1545  }
1546  }
1547  if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type)
1548  {
1549  for (le = tih->attrs->list_head; NULL != le; le = le->next)
1550  {
1552  rd[i].data_size);
1553  if (NULL == pres)
1554  {
1556  "Failed to deserialize presentation\n");
1557  continue;
1558  }
1560  &le->attribute->credential))
1561  {
1562  found_pres_cnt++;
1564  ple->presentation = pres;
1565  GNUNET_CONTAINER_DLL_insert (ticket_presentations->list_head,
1566  ticket_presentations->list_tail,
1567  ple);
1568  }
1569  }
1570  }
1571  }
1572 
1577  if ((attr_cnt == found_attrs_cnt) &&
1578  (pres_cnt == found_pres_cnt) &&
1579  (NULL != ticket))
1580  {
1582  tih->cb (tih->cb_cls, &tih->ticket, ticket_presentations, GNUNET_OK, NULL);
1583  GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations);
1584  cleanup_issue_handle (tih);
1585  return;
1586  }
1587 
1588  // ticket not found in current record, checking next record set
1590 }
The authorization ticket.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
struct GNUNET_RECLAIM_Identifier id
ID.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Ticket ticket
Ticket to issue.
#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 GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL
Record type for an attribute attestation.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
int GNUNET_RECLAIM_credential_get_presentation(const struct GNUNET_RECLAIM_Credential *cred, const struct GNUNET_RECLAIM_AttributeList *attrs, struct GNUNET_RECLAIM_Presentation **presentation)
Create a presentation from a credential and a lift of (selected) attributes in the credential...
#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 credential_id
The credential id of which this is a presentation.
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.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential (used in a ticket record set)
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore Iterator.
A credential presentation.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
A list of GNUNET_RECLAIM_Presentation structures.
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_log(kind,...)
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
Ticket issue request handle.
struct GNUNET_RECLAIM_PresentationListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations to add.
RECLAIM_TICKETS_TicketResult cb
Callback.
uint32_t data
The data value.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#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_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 1601 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().

1602 {
1603  struct TicketIssueHandle *tih = cls;
1604 
1607  issue_ticket (tih);
1608 }
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:176
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 1623 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, TicketIssueHandle::presentations, and TicketIssueHandle::ticket.

Referenced by handle_issue_ticket_message().

1628 {
1629  struct TicketIssueHandle *tih;
1630 
1631  tih = GNUNET_new (struct TicketIssueHandle);
1632  tih->cb = cb;
1633  tih->cb_cls = cb_cls;
1636  tih->identity = *identity;
1637  tih->ticket.audience = *audience;
1638 
1639  // First check whether the ticket has already been issued
1640  tih->ns_it =
1642  &tih->identity,
1644  tih,
1646  tih,
1648  tih);
1649 }
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
A list of GNUNET_RECLAIM_Presentation structures.
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
Ticket issue request handle.
struct GNUNET_RECLAIM_PresentationList * presentations
Presentations to add.
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 1662 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().

1663 {
1664  if (NULL != iter->ns_it)
1666  GNUNET_free (iter);
1667 }
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 1682 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().

1687 {
1688  struct RECLAIM_TICKETS_Iterator *iter = cls;
1689 
1690  for (int i = 0; i < rd_count; i++)
1691  {
1692  if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1693  continue;
1694  iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data);
1695  return;
1696  }
1698 }
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 1707 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().

1708 {
1709  struct RECLAIM_TICKETS_Iterator *iter = cls;
1710 
1711  iter->ns_it = NULL;
1712  iter->cb (iter->cb_cls, NULL);
1713  cleanup_iter (iter);
1714 }
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 1723 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().

1724 {
1725  struct RECLAIM_TICKETS_Iterator *iter = cls;
1726 
1727  iter->ns_it = NULL;
1728  iter->cb (iter->cb_cls, NULL);
1729  cleanup_iter (iter);
1730 }
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 1739 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().

1740 {
1742 }
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 1751 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().

1752 {
1754  cleanup_iter (iter);
1755 }
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 1767 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().

1771 {
1772  struct RECLAIM_TICKETS_Iterator *iter;
1773 
1774  iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1775  iter->cb = cb;
1776  iter->cb_cls = cb_cls;
1777  iter->ns_it =
1779  identity,
1781  iter,
1783  iter,
1785  iter);
1786  return iter;
1787 }
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 1797 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().

1798 {
1799  // Get ticket expiration time (relative) from config
1800  if (GNUNET_OK ==
1802  "reclaim",
1803  "TICKET_REFRESH_INTERVAL",
1805  {
1807  "Configured refresh interval for tickets: %s\n",
1809  GNUNET_YES));
1810  }
1811  else
1812  {
1814  }
1815  // Connect to identity and namestore services
1817  if (NULL == nsh)
1818  {
1820  "error connecting to namestore");
1821  return GNUNET_SYSERR;
1822  }
1823  gns = GNUNET_GNS_connect (c);
1824  if (NULL == gns)
1825  {
1826  GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1827  return GNUNET_SYSERR;
1828  }
1829  stats = GNUNET_STATISTICS_create ("reclaim", c);
1830  return GNUNET_OK;
1831 }
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_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:702
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...
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,...)
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 1839 of file gnunet-service-reclaim_tickets.c.

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

Referenced by cleanup().

1840 {
1841  if (NULL != nsh)
1843  nsh = NULL;
1844  if (NULL != gns)
1846  gns = NULL;
1847  if (NULL != stats)
1848  {
1850  stats = NULL;
1851  }
1852 }
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 328 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 332 of file gnunet-service-reclaim_tickets.c.

◆ gns

struct GNUNET_GNS_Handle* gns
static

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

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

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