GNUnet  0.11.x
Data Structures | Functions | Variables
gnunet-service-reclaim.c File Reference

reclaim Service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-reclaim_tickets.h"
#include "gnunet_constants.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_reclaim_lib.h"
#include "gnunet_reclaim_service.h"
#include "gnunet_signatures.h"
#include "reclaim.h"
Include dependency graph for gnunet-service-reclaim.c:

Go to the source code of this file.

Data Structures

struct  TicketIteration
 A ticket iteration operation. More...
 
struct  Iterator
 An attribute iteration operation. More...
 
struct  IdpClient
 An idp client. More...
 
struct  AttributeDeleteHandle
 Handle for attribute deletion request. More...
 
struct  AttributeStoreHandle
 Handle for attribute store request. More...
 
struct  ConsumeTicketOperation
 Handle for ticket consume request. More...
 
struct  TicketRevocationOperation
 Ticket revocation request handle. More...
 
struct  TicketIssueOperation
 Ticket issue operation handle. More...
 

Functions

static void cleanup_adh (struct AttributeDeleteHandle *adh)
 Cleanup attribute delete handle. More...
 
static void cleanup_as_handle (struct AttributeStoreHandle *ash)
 Cleanup attribute store handle. More...
 
static void cleanup_client (struct IdpClient *idp)
 Cleanup client. More...
 
static void cleanup ()
 Cleanup task. More...
 
static void do_shutdown (void *cls)
 Shutdown task. More...
 
static void send_ticket_result (const struct IdpClient *client, uint32_t r_id, const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_RECLAIM_PresentationList *presentations, uint32_t success)
 Sends a ticket result message to the client. More...
 
static void issue_ticket_result_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket, struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
 Issue ticket result. More...
 
static int check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
 Check issue ticket message. More...
 
static void handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
 Handle ticket issue message. More...
 
static void revoke_result_cb (void *cls, int32_t success)
 Handles revocation result. More...
 
static int check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im)
 Check revocation message format. More...
 
static void handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
 Handle a revocation message to a ticket. More...
 
static void consume_result_cb (void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
 Handle a ticket consume result. More...
 
static int check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
 Check a consume ticket message. More...
 
static void handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
 Handle a consume ticket message. More...
 
static void attr_store_cont (void *cls, int32_t success, const char *emsg)
 Attribute store result handler. More...
 
static void attr_store_task (void *cls)
 Add a new attribute. More...
 
static int check_attribute_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Check an attribute store message. More...
 
static void handle_attribute_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Handle an attribute store message. More...
 
static void cred_store_cont (void *cls, int32_t success, const char *emsg)
 Credential store result handler. More...
 
static void cred_error (void *cls)
 Error looking up potential credential. More...
 
static void cred_add_cb (void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Check for existing record before storing credential. More...
 
static void cred_store_task (void *cls)
 Add a new credential. More...
 
static int check_credential_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Check an credential store message. More...
 
static void handle_credential_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Handle a credential store message. More...
 
static void send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
 Send a deletion success response. More...
 
static void consistency_iter (void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Namestore iteration within attribute deletion. More...
 
static void update_tickets (void *cls)
 Recursion prototype for function. More...
 
static void ticket_updated (void *cls, int32_t success, const char *emsg)
 Callback called when a ticket was updated. More...
 
static void purge_attributes (void *cls)
 Delete all attributes which reference credentials that no longer exist. More...
 
static void offending_attr_delete_cont (void *cls, int32_t success, const char *emsg)
 
static void consistency_iter_fin (void *cls)
 Done collecting affected tickets, start updating. More...
 
static void consistency_iter_err (void *cls)
 Error collecting affected tickets. More...
 
static void start_consistency_update (void *cls)
 Start processing tickets which may still contain reference to deleted attribute. More...
 
static void attr_delete_cont (void *cls, int32_t success, const char *emsg)
 Attribute deleted callback. More...
 
static int check_attribute_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Check attribute delete message format. More...
 
static void handle_attribute_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Handle attribute deletion. More...
 
static void cred_delete_cont (void *cls, int32_t success, const char *emsg)
 Credential deleted callback. More...
 
static int check_credential_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Check credential delete message format. More...
 
static void handle_credential_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Handle credential deletion. More...
 
static void attr_iter_finished (void *cls)
 Done iterating over attributes. More...
 
static void attr_iter_error (void *cls)
 Error iterating over attributes. More...
 
static void attr_iter_cb (void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Got record. More...
 
static void handle_iteration_start (void *cls, const struct AttributeIterationStartMessage *ais_msg)
 Iterate over zone to get attributes. More...
 
static void handle_iteration_stop (void *cls, const struct AttributeIterationStopMessage *ais_msg)
 Handle iteration stop message from client. More...
 
static void handle_iteration_next (void *cls, const struct AttributeIterationNextMessage *ais_msg)
 Client requests next attribute from iterator. More...
 
static void cred_iter_finished (void *cls)
 Done iterating over credentials. More...
 
static void cred_iter_error (void *cls)
 Error iterating over credentials. More...
 
static void cred_iter_cb (void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Got record. More...
 
static void handle_credential_iteration_start (void *cls, const struct CredentialIterationStartMessage *ais_msg)
 Iterate over zone to get attributes. More...
 
static void handle_credential_iteration_stop (void *cls, const struct CredentialIterationStopMessage *ais_msg)
 Handle iteration stop message from client. More...
 
static void handle_credential_iteration_next (void *cls, const struct CredentialIterationNextMessage *ais_msg)
 Client requests next credential from iterator. More...
 
static void ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
 Got a ticket. More...
 
static void handle_ticket_iteration_start (void *cls, const struct TicketIterationStartMessage *tis_msg)
 Client requests a ticket iteration. More...
 
static void handle_ticket_iteration_stop (void *cls, const struct TicketIterationStopMessage *tis_msg)
 Client has had enough tickets. More...
 
static void handle_ticket_iteration_next (void *cls, const struct TicketIterationNextMessage *tis_msg)
 Client requests next result. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *server)
 Main function that will be run. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Called whenever a client is disconnected. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Add a client to our list of active clients. More...
 
 GNUNET_SERVICE_MAIN ("reclaim", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(attribute_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(credential_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_var_size(credential_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, struct AttributeIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, struct AttributeIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, struct AttributeIterationStopMessage, NULL), GNUNET_MQ_hd_fixed_size(credential_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, struct CredentialIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(credential_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, struct CredentialIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(credential_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, struct CredentialIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL), GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct GNUNET_NAMESTORE_Handlensh
 Namestore handle. More...
 
static struct GNUNET_SCHEDULER_Tasktimeout_task
 Timeout task. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Our configuration. More...
 
static struct IdpClientclient_list_head = NULL
 Client list. More...
 
static struct IdpClientclient_list_tail = NULL
 Client list. More...
 

Detailed Description

reclaim Service

Author
Martin Schanzenbach

Definition in file gnunet-service-reclaim.c.

Function Documentation

◆ cleanup_adh()

static void cleanup_adh ( struct AttributeDeleteHandle adh)
static

Cleanup attribute delete handle.

Parameters
adhthe attribute to cleanup

Definition at line 489 of file gnunet-service-reclaim.c.

490 {
491  struct TicketRecordsEntry *le;
492 
493  if (NULL != adh->ns_it)
495  if (NULL != adh->ns_qe)
497  if (NULL != adh->label)
498  GNUNET_free (adh->label);
499  if (NULL != adh->claim)
500  GNUNET_free (adh->claim);
501  if (NULL != adh->credential)
502  GNUNET_free (adh->credential);
503  if (NULL != adh->existing_credentials)
505  if (NULL != adh->existing_attributes)
507  while (NULL != (le = adh->tickets_to_update_head))
508  {
511  le);
512  if (NULL != le->label)
513  GNUNET_free (le->label);
514  if (NULL != le->data)
515  GNUNET_free (le->data);
516  GNUNET_free (le);
517  }
518  GNUNET_free (adh);
519 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
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.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
void GNUNET_RECLAIM_credential_list_destroy(struct GNUNET_RECLAIM_CredentialList *credentials)
Destroy claim list.
struct GNUNET_RECLAIM_CredentialList * existing_credentials
Existing credentials.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct GNUNET_RECLAIM_Attribute * claim
The attribute to delete.
char * label
Attribute label.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
struct GNUNET_RECLAIM_AttributeList * existing_attributes
Existing attributes.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_RECLAIM_Credential * credential
The credential to delete.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.

References AttributeDeleteHandle::claim, AttributeDeleteHandle::credential, TicketRecordsEntry::data, AttributeDeleteHandle::existing_attributes, AttributeDeleteHandle::existing_credentials, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_credential_list_destroy(), AttributeDeleteHandle::label, TicketRecordsEntry::label, AttributeDeleteHandle::ns_it, AttributeDeleteHandle::ns_qe, AttributeDeleteHandle::tickets_to_update_head, and AttributeDeleteHandle::tickets_to_update_tail.

Referenced by attr_delete_cont(), cleanup_client(), consistency_iter_err(), cred_delete_cont(), offending_attr_delete_cont(), and update_tickets().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_as_handle()

static void cleanup_as_handle ( struct AttributeStoreHandle ash)
static

Cleanup attribute store handle.

Parameters
handlehandle to clean up

Definition at line 528 of file gnunet-service-reclaim.c.

529 {
530  if (NULL != ash->ns_qe)
532  if (NULL != ash->claim)
533  GNUNET_free (ash->claim);
534  if (NULL != ash->credential)
535  GNUNET_free (ash->credential);
536  GNUNET_free (ash);
537 }
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_RECLAIM_Credential * credential
The credential to store.
struct GNUNET_RECLAIM_Attribute * claim
The attribute to store.

References AttributeStoreHandle::claim, AttributeStoreHandle::credential, GNUNET_free, GNUNET_NAMESTORE_cancel(), and AttributeStoreHandle::ns_qe.

Referenced by attr_store_cont(), cleanup_client(), cred_error(), and cred_store_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_client()

static void cleanup_client ( struct IdpClient idp)
static

Cleanup client.

Parameters
idpthe client to clean up

Definition at line 546 of file gnunet-service-reclaim.c.

547 {
548  struct Iterator *ai;
549  struct TicketIteration *ti;
550  struct TicketRevocationOperation *rop;
551  struct TicketIssueOperation *iss;
552  struct ConsumeTicketOperation *ct;
553  struct AttributeStoreHandle *as;
554  struct AttributeDeleteHandle *adh;
555 
556  while (NULL != (iss = idp->issue_op_head))
557  {
558  GNUNET_CONTAINER_DLL_remove (idp->issue_op_head, idp->issue_op_tail, iss);
559  GNUNET_free (iss);
560  }
561  while (NULL != (ct = idp->consume_op_head))
562  {
563  GNUNET_CONTAINER_DLL_remove (idp->consume_op_head,
564  idp->consume_op_tail,
565  ct);
566  if (NULL != ct->ch)
568  GNUNET_free (ct);
569  }
570  while (NULL != (as = idp->store_op_head))
571  {
572  GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as);
573  cleanup_as_handle (as);
574  }
575  while (NULL != (adh = idp->delete_op_head))
576  {
577  GNUNET_CONTAINER_DLL_remove (idp->delete_op_head, idp->delete_op_tail, adh);
578  cleanup_adh (adh);
579  }
580 
581  while (NULL != (ai = idp->attr_iter_head))
582  {
583  GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
584  GNUNET_free (ai);
585  }
586  while (NULL != (ai = idp->cred_iter_head))
587  {
588  GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
589  ai);
590  GNUNET_free (ai);
591  }
592 
593  while (NULL != (rop = idp->revoke_op_head))
594  {
595  GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop);
596  if (NULL != rop->rh)
598  GNUNET_free (rop);
599  }
600  while (NULL != (ti = idp->ticket_iter_head))
601  {
602  GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head,
603  idp->ticket_iter_tail,
604  ti);
605  if (NULL != ti->iter)
607  GNUNET_free (ti);
608  }
609  GNUNET_free (idp);
610 }
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
Handle for attribute deletion request.
Handle for attribute store request.
Handle for ticket consume request.
struct RECLAIM_TICKETS_ConsumeHandle * ch
Ticket consume handle.
An attribute iteration operation.
Ticket issue operation handle.
A ticket iteration operation.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
Ticket revocation request handle.
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.

References ai, ConsumeTicketOperation::ch, cleanup_adh(), cleanup_as_handle(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, idp, TicketIteration::iter, RECLAIM_TICKETS_consume_cancel(), RECLAIM_TICKETS_iteration_stop(), RECLAIM_TICKETS_revoke_cancel(), and TicketRevocationOperation::rh.

Referenced by client_disconnect_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

static void cleanup ( )
static

Cleanup task.

Definition at line 617 of file gnunet-service-reclaim.c.

618 {
619  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
620 
622  if (NULL != timeout_task)
624  if (NULL != nsh)
626 }
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
static struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_disconnect(), GNUNET_SCHEDULER_cancel(), nsh, RECLAIM_TICKETS_deinit(), and timeout_task.

Referenced by do_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Shutdown task.

Parameters
clsNULL

Definition at line 635 of file gnunet-service-reclaim.c.

636 {
637  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
638  cleanup ();
639 }
static void cleanup()
Cleanup task.
@ GNUNET_ERROR_TYPE_INFO

References cleanup(), GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

Referenced by attr_store_cont(), cred_error(), cred_store_cont(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_ticket_result()

static void send_ticket_result ( const struct IdpClient client,
uint32_t  r_id,
const struct GNUNET_RECLAIM_Ticket ticket,
const struct GNUNET_RECLAIM_PresentationList presentations,
uint32_t  success 
)
static

Sends a ticket result message to the client.

Parameters
clientthe client to send to
r_idthe request message ID to reply to
ticketthe ticket to include (may be NULL)
successthe success status of the request

Definition at line 651 of file gnunet-service-reclaim.c.

656 {
657  struct TicketResultMessage *irm;
658  struct GNUNET_MQ_Envelope *env;
659  size_t pres_len = 0;
660 
661  if (NULL != presentations)
662  {
663  pres_len =
665  }
666  env = GNUNET_MQ_msg_extra (irm,
667  pres_len,
669  if (NULL != ticket)
670  {
671  irm->ticket = *ticket;
672  }
673  // TODO add success member
674  irm->id = htonl (r_id);
675  irm->presentations_len = htons (pres_len);
676  if (NULL != presentations)
677  {
679  (char*) &irm[1]);
680  }
681  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
682  GNUNET_MQ_send (client->mq, env);
683 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:52
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
size_t GNUNET_RECLAIM_presentation_list_serialize(const struct GNUNET_RECLAIM_PresentationList *presentations, char *result)
Serialize a presentation list.
size_t GNUNET_RECLAIM_presentation_list_serialize_get_size(const struct GNUNET_RECLAIM_PresentationList *presentations)
Get required size for serialization buffer.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
Ticket result message.
Definition: reclaim.h:454
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:473
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:463
uint32_t presentations_len
Length of new presentations created.
Definition: reclaim.h:468

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_RECLAIM_presentation_list_serialize(), GNUNET_RECLAIM_presentation_list_serialize_get_size(), TicketResultMessage::id, IdpClient::mq, TicketResultMessage::presentations_len, ticket, and TicketResultMessage::ticket.

Referenced by issue_ticket_result_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ issue_ticket_result_cb()

static void issue_ticket_result_cb ( void *  cls,
struct GNUNET_RECLAIM_Ticket ticket,
struct GNUNET_RECLAIM_PresentationList presentations,
int32_t  success,
const char *  emsg 
)
static

Issue ticket result.

Parameters
clsout ticket issue operation handle
ticketthe issued ticket
presentationsnewly created credential presentations (NULL on error)
successissue success status (GNUNET_OK if successful)
emsgerror message (NULL of success is GNUNET_OK)

Definition at line 696 of file gnunet-service-reclaim.c.

701 {
702  struct TicketIssueOperation *tio = cls;
703 
704  if (GNUNET_OK != success)
705  {
706  send_ticket_result (tio->client, tio->r_id, NULL, NULL, GNUNET_SYSERR);
707  GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
708  tio->client->issue_op_tail,
709  tio);
710  GNUNET_free (tio);
711  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
712  return;
713  }
714  send_ticket_result (tio->client, tio->r_id,
715  ticket, presentations, GNUNET_SYSERR);
716  GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
717  tio->client->issue_op_tail,
718  tio);
719  GNUNET_free (tio);
720 }
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
static void send_ticket_result(const struct IdpClient *client, uint32_t r_id, const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_RECLAIM_PresentationList *presentations, uint32_t success)
Sends a ticket result message to the client.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, send_ticket_result(), ticket, and tio.

Referenced by handle_issue_ticket_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_issue_ticket_message()

static int check_issue_ticket_message ( void *  cls,
const struct IssueTicketMessage im 
)
static

Check issue ticket message.

@cls unused @im message to check

Returns
GNUNET_OK if message is ok

Definition at line 731 of file gnunet-service-reclaim.c.

732 {
733  uint16_t size;
734  size_t attrs_len;
735 
736  size = ntohs (im->header.size);
737  attrs_len = ntohs (im->attr_len);
738 
739  if (attrs_len > size - sizeof(struct IssueTicketMessage))
740  {
741  GNUNET_break (0);
742  return GNUNET_SYSERR;
743  }
744  return GNUNET_OK;
745 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
static unsigned int size
Size of the "table".
Definition: peer.c:67
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Ticket issue message.
Definition: reclaim.h:368
uint32_t attr_len
length of serialized attribute list
Definition: reclaim.h:392
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET.
Definition: reclaim.h:372

References IssueTicketMessage::attr_len, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, IssueTicketMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_issue_ticket_message()

static void handle_issue_ticket_message ( void *  cls,
const struct IssueTicketMessage im 
)
static

Handle ticket issue message.

Parameters
clsour client
imthe message

Definition at line 755 of file gnunet-service-reclaim.c.

756 {
757  struct TicketIssueOperation *tio;
758  struct IdpClient *idp = cls;
759  struct GNUNET_RECLAIM_AttributeList *attrs;
761  size_t attrs_len;
762 
763  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
765  attrs_len = ntohs (im->attr_len);
766  attrs = GNUNET_RECLAIM_attribute_list_deserialize ((char *) &im[1],
767  attrs_len);
768  for (le = attrs->list_head; NULL != le; le = le->next)
770  "List entry: %s\n", le->attribute->name);
771 
772  tio->r_id = ntohl (im->id);
773  tio->client = idp;
774  GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
776  attrs,
777  &im->rp,
779  tio);
782 }
static void issue_ticket_result_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Issue ticket result.
void RECLAIM_TICKETS_issue(const struct GNUNET_IDENTITY_PrivateKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_IDENTITY_PublicKey *audience, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes...
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2244
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
const char * name
The name of the attribute.
struct GNUNET_CLIENT_Connection * client
Socket (if available).
Definition: reclaim_api.c:327
An idp client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:377
struct GNUNET_IDENTITY_PublicKey rp
Requesting party.
Definition: reclaim.h:387
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:382

References IssueTicketMessage::attr_len, GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_Handle::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_attribute_list_deserialize(), GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_SERVICE_client_continue(), IssueTicketMessage::id, IssueTicketMessage::identity, idp, issue_ticket_result_cb(), GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_AttributeListEntry::next, RECLAIM_TICKETS_issue(), IssueTicketMessage::rp, and tio.

Here is the call graph for this function:

◆ revoke_result_cb()

static void revoke_result_cb ( void *  cls,
int32_t  success 
)
static

Handles revocation result.

Parameters
clsour revocation operation handle
successrevocation result (GNUNET_OK if successful)

Definition at line 796 of file gnunet-service-reclaim.c.

797 {
798  struct TicketRevocationOperation *rop = cls;
799  struct GNUNET_MQ_Envelope *env;
800  struct RevokeTicketResultMessage *trm;
801 
803  "Sending REVOKE_TICKET_RESULT message\n");
804  rop->rh = NULL;
806  trm->id = htonl (rop->r_id);
807  trm->success = htonl (success);
808  GNUNET_MQ_send (rop->client->mq, env);
810  rop->client->revoke_op_tail,
811  rop);
812  GNUNET_free (rop);
813 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
Ticket revoke message.
Definition: reclaim.h:432
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:441
uint32_t success
Revocation result.
Definition: reclaim.h:446
struct IdpClient * client
Client connection.

References TicketRevocationOperation::client, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), RevokeTicketResultMessage::id, IdpClient::mq, TicketRevocationOperation::r_id, IdpClient::revoke_op_head, IdpClient::revoke_op_tail, TicketRevocationOperation::rh, and RevokeTicketResultMessage::success.

Referenced by handle_revoke_ticket_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_revoke_ticket_message()

static int check_revoke_ticket_message ( void *  cls,
const struct RevokeTicketMessage im 
)
static

Check revocation message format.

Parameters
clsunused
imthe message to check
Returns
GNUNET_OK if message is ok

Definition at line 824 of file gnunet-service-reclaim.c.

825 {
826  uint16_t size;
827 
828  size = ntohs (im->header.size);
829  if (size != sizeof(struct RevokeTicketMessage))
830  {
831  GNUNET_break (0);
832  return GNUNET_SYSERR;
833  }
834  return GNUNET_OK;
835 }
Ticket revoke message.
Definition: reclaim.h:401
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET.
Definition: reclaim.h:405

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, RevokeTicketMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_revoke_ticket_message()

static void handle_revoke_ticket_message ( void *  cls,
const struct RevokeTicketMessage rm 
)
static

Handle a revocation message to a ticket.

Parameters
clsour client
rmthe message to handle

Definition at line 845 of file gnunet-service-reclaim.c.

846 {
847  struct TicketRevocationOperation *rop;
848  struct IdpClient *idp = cls;
849 
850  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
851  rop = GNUNET_new (struct TicketRevocationOperation);
852  rop->r_id = ntohl (rm->id);
853  rop->client = idp;
854  GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
855  rop->rh
857  rop);
859 }
static void revoke_result_cb(void *cls, int32_t success)
Handles revocation result.
struct RECLAIM_TICKETS_RevokeHandle * RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_IDENTITY_PrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
Revoke a ticket.
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:415
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:410
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:425

References TicketRevocationOperation::client, GNUNET_RECLAIM_Handle::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), RevokeTicketMessage::id, RevokeTicketMessage::identity, idp, TicketRevocationOperation::r_id, RECLAIM_TICKETS_revoke(), revoke_result_cb(), TicketRevocationOperation::rh, and RevokeTicketMessage::ticket.

Here is the call graph for this function:

◆ consume_result_cb()

static void consume_result_cb ( void *  cls,
const struct GNUNET_IDENTITY_PublicKey identity,
const struct GNUNET_RECLAIM_AttributeList attrs,
const struct GNUNET_RECLAIM_PresentationList presentations,
int32_t  success,
const char *  emsg 
)
static

Handle a ticket consume result.

Parameters
clsour consume ticket operation handle
identitythe attribute authority
attrsthe attribute/claim list
successGNUNET_OK if successful
emsgerror message (NULL if success=GNUNET_OK)

Definition at line 872 of file gnunet-service-reclaim.c.

878 {
879  struct ConsumeTicketOperation *cop = cls;
880  struct ConsumeTicketResultMessage *crm;
881  struct GNUNET_MQ_Envelope *env;
882  char *data_tmp;
883  size_t attrs_len = 0;
884  size_t pres_len = 0;
885 
886  if (GNUNET_OK != success)
887  {
888  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
889  }
892  presentations);
894  "Sending CONSUME_TICKET_RESULT message\n");
895  env = GNUNET_MQ_msg_extra (crm,
896  attrs_len + pres_len,
898  crm->id = htonl (cop->r_id);
899  crm->attrs_len = htons (attrs_len);
900  crm->presentations_len = htons (pres_len);
901  crm->identity = *identity;
902  crm->result = htonl (success);
903  data_tmp = (char *) &crm[1];
904  GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp);
905  data_tmp += attrs_len;
906  GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp);
907  GNUNET_MQ_send (cop->client->mq, env);
909  cop->client->consume_op_tail,
910  cop);
911  GNUNET_free (cop);
912 }
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size(const struct GNUNET_RECLAIM_AttributeList *attrs)
Get required size for serialization buffer.
struct IdpClient * client
Client connection.
Attribute list is returned from the idp.
Definition: reclaim.h:508
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:527
uint16_t presentations_len
Length of presentation data.
Definition: reclaim.h:532
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:517
uint32_t result
Result.
Definition: reclaim.h:522
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:542
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.

References ConsumeTicketResultMessage::attrs_len, ConsumeTicketOperation::client, IdpClient::consume_op_head, IdpClient::consume_op_tail, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_RECLAIM_attribute_list_serialize(), GNUNET_RECLAIM_attribute_list_serialize_get_size(), GNUNET_RECLAIM_presentation_list_serialize(), GNUNET_RECLAIM_presentation_list_serialize_get_size(), ConsumeTicketResultMessage::id, identity, ConsumeTicketResultMessage::identity, IdpClient::mq, ConsumeTicketResultMessage::presentations_len, ConsumeTicketOperation::r_id, and ConsumeTicketResultMessage::result.

Referenced by handle_consume_ticket_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_consume_ticket_message()

static int check_consume_ticket_message ( void *  cls,
const struct ConsumeTicketMessage cm 
)
static

Check a consume ticket message.

Parameters
clsunused
cmthe message to handle

Definition at line 922 of file gnunet-service-reclaim.c.

923 {
924  uint16_t size;
925 
926  size = ntohs (cm->header.size);
927  if (size != sizeof(struct ConsumeTicketMessage))
928  {
929  GNUNET_break (0);
930  return GNUNET_SYSERR;
931  }
932  return GNUNET_OK;
933 }
Ticket consume message.
Definition: reclaim.h:482
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:486

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, ConsumeTicketMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_consume_ticket_message()

static void handle_consume_ticket_message ( void *  cls,
const struct ConsumeTicketMessage cm 
)
static

Handle a consume ticket message.

Parameters
clsour client handle @cm the message to handle

Definition at line 943 of file gnunet-service-reclaim.c.

944 {
945  struct ConsumeTicketOperation *cop;
946  struct IdpClient *idp = cls;
947 
948  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
949  cop = GNUNET_new (struct ConsumeTicketOperation);
950  cop->r_id = ntohl (cm->id);
951  cop->client = idp;
952  cop->ch
954  cop);
955  GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
957 }
static void consume_result_cb(void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Handle a ticket consume result.
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_IDENTITY_PrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:501
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:491
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:496

References ConsumeTicketOperation::ch, ConsumeTicketOperation::client, GNUNET_RECLAIM_Handle::client, consume_result_cb(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), ConsumeTicketMessage::id, ConsumeTicketMessage::identity, idp, ConsumeTicketOperation::r_id, RECLAIM_TICKETS_consume(), and ConsumeTicketMessage::ticket.

Here is the call graph for this function:

◆ attr_store_cont()

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

Attribute store result handler.

Parameters
clsour attribute store handle
successGNUNET_OK if successful
emsgerror message (NULL if success=GNUNET_OK)

Definition at line 973 of file gnunet-service-reclaim.c.

974 {
975  struct AttributeStoreHandle *ash = cls;
976  struct GNUNET_MQ_Envelope *env;
977  struct SuccessResultMessage *acr_msg;
978 
979  ash->ns_qe = NULL;
981  ash->client->store_op_tail,
982  ash);
983 
984  if (GNUNET_SYSERR == success)
985  {
987  "Failed to store attribute %s\n",
988  emsg);
989  cleanup_as_handle (ash);
991  return;
992  }
993 
994  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
996  acr_msg->id = htonl (ash->r_id);
997  acr_msg->op_result = htonl (GNUNET_OK);
998  GNUNET_MQ_send (ash->client->mq, env);
999  cleanup_as_handle (ash);
1000 }
static void do_shutdown(void *cls)
Shutdown task.
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
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 IdpClient * client
Client connection.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
Attribute store/delete response message.
Definition: reclaim.h:104
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118

References cleanup_as_handle(), AttributeStoreHandle::client, do_shutdown(), env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, SuccessResultMessage::id, IdpClient::mq, AttributeStoreHandle::ns_qe, SuccessResultMessage::op_result, AttributeStoreHandle::r_id, IdpClient::store_op_head, and IdpClient::store_op_tail.

Referenced by attr_store_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_store_task()

static void attr_store_task ( void *  cls)
static

Add a new attribute.

Parameters
clsthe AttributeStoreHandle

Definition at line 1009 of file gnunet-service-reclaim.c.

1010 {
1011  struct AttributeStoreHandle *ash = cls;
1012  struct GNUNET_GNSRECORD_Data rd[1];
1013  char *buf;
1014  char *label;
1015  size_t buf_size;
1016 
1017  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
1019  buf = GNUNET_malloc (buf_size);
1020  // Give the ash a new id if unset
1021  if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&ash->claim->id))
1024  label
1026  sizeof (ash->claim->id));
1027  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1028 
1029  rd[0].data_size = buf_size;
1030  rd[0].data = buf;
1031  rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE;
1033  rd[0].expiration_time = ash->exp.rel_value_us;
1035  &ash->identity,
1036  label,
1037  1,
1038  rd,
1039  &attr_store_cont,
1040  ash);
1041  GNUNET_free (buf);
1042  GNUNET_free (label);
1043 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
identity attribute
static void attr_store_cont(void *cls, int32_t success, const char *emsg)
Attribute store result handler.
static char buf[2048]
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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_RECLAIM_id_is_zero(a)
#define GNUNET_RECLAIM_id_generate(id)
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:750
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
struct GNUNET_RECLAIM_Identifier id
ID.
uint64_t rel_value_us
The actual value.

References attr_store_cont(), buf, AttributeStoreHandle::claim, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, AttributeStoreHandle::exp, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_attribute_serialize(), GNUNET_RECLAIM_attribute_serialize_get_size(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_YES, GNUNET_RECLAIM_Attribute::id, AttributeStoreHandle::identity, AttributeStoreHandle::ns_qe, nsh, GNUNET_GNSRECORD_Data::record_type, and GNUNET_TIME_Relative::rel_value_us.

Referenced by handle_attribute_store_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_attribute_store_message()

static int check_attribute_store_message ( void *  cls,
const struct AttributeStoreMessage sam 
)
static

Check an attribute store message.

Parameters
clsunused
samthe message to check

Definition at line 1053 of file gnunet-service-reclaim.c.

1055 {
1056  uint16_t size;
1057 
1058  size = ntohs (sam->header.size);
1059  if (size <= sizeof(struct AttributeStoreMessage))
1060  {
1061  GNUNET_break (0);
1062  return GNUNET_SYSERR;
1063  }
1064  return GNUNET_OK;
1065 }
Use to store an identity attribute.
Definition: reclaim.h:41
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, AttributeStoreMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_attribute_store_message()

static void handle_attribute_store_message ( void *  cls,
const struct AttributeStoreMessage sam 
)
static

Handle an attribute store message.

Parameters
clsour client
samthe message to handle

Definition at line 1075 of file gnunet-service-reclaim.c.

1077 {
1078  struct AttributeStoreHandle *ash;
1079  struct IdpClient *idp = cls;
1080  size_t data_len;
1081 
1082  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1083 
1084  data_len = ntohs (sam->attr_len);
1085 
1086  ash = GNUNET_new (struct AttributeStoreHandle);
1087  GNUNET_RECLAIM_attribute_deserialize ((char *) &sam[1],
1088  data_len,
1089  &ash->claim);
1090 
1091  ash->r_id = ntohl (sam->id);
1092  ash->identity = sam->identity;
1093  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1095 
1097  ash->client = idp;
1098  GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1100 }
static void attr_store_task(void *cls)
Add a new attribute.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
struct GNUNET_IDENTITY_PublicKey identity_pkey
Identity pubkey.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:55
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:60
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:65
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50

References AttributeStoreMessage::attr_len, attr_store_task(), AttributeStoreHandle::claim, AttributeStoreHandle::client, GNUNET_RECLAIM_Handle::client, AttributeStoreHandle::exp, AttributeStoreMessage::exp, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_key_get_public(), GNUNET_log, GNUNET_new, GNUNET_ntohll(), GNUNET_RECLAIM_attribute_deserialize(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), AttributeStoreMessage::id, AttributeStoreHandle::identity, AttributeStoreMessage::identity, AttributeStoreHandle::identity_pkey, idp, AttributeStoreHandle::r_id, and GNUNET_TIME_Relative::rel_value_us.

Here is the call graph for this function:

◆ cred_store_cont()

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

Credential store result handler.

Parameters
clsour attribute store handle
successGNUNET_OK if successful
emsgerror message (NULL if success=GNUNET_OK)

Definition at line 1111 of file gnunet-service-reclaim.c.

1112 {
1113  struct AttributeStoreHandle *ash = cls;
1114  struct GNUNET_MQ_Envelope *env;
1115  struct SuccessResultMessage *acr_msg;
1116 
1117  ash->ns_qe = NULL;
1119  ash->client->store_op_tail,
1120  ash);
1121 
1122  if (GNUNET_SYSERR == success)
1123  {
1125  "Failed to store credential: %s\n",
1126  emsg);
1127  cleanup_as_handle (ash);
1129  return;
1130  }
1131 
1132  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1134  acr_msg->id = htonl (ash->r_id);
1135  acr_msg->op_result = htonl (GNUNET_OK);
1136  GNUNET_MQ_send (ash->client->mq, env);
1137  cleanup_as_handle (ash);
1138 }

References cleanup_as_handle(), AttributeStoreHandle::client, do_shutdown(), env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, SuccessResultMessage::id, IdpClient::mq, AttributeStoreHandle::ns_qe, SuccessResultMessage::op_result, AttributeStoreHandle::r_id, IdpClient::store_op_head, and IdpClient::store_op_tail.

Referenced by cred_add_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cred_error()

static void cred_error ( void *  cls)
static

Error looking up potential credential.

Abort.

Parameters
clsour attribute store handle

Definition at line 1147 of file gnunet-service-reclaim.c.

1148 {
1149  struct AttributeStoreHandle *ash = cls;
1151  "Failed to check for existing credential.\n");
1152  cleanup_as_handle (ash);
1154  return;
1155 }

References cleanup_as_handle(), do_shutdown(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, and GNUNET_SCHEDULER_add_now().

Referenced by cred_store_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cred_add_cb()

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

Check for existing record before storing credential.

Parameters
clsour attribute store handle
zonezone we are iterating
labellabel of the records
rd_countrecord count
rdrecords

Definition at line 1168 of file gnunet-service-reclaim.c.

1173 {
1174  struct AttributeStoreHandle *ash = cls;
1175  struct GNUNET_GNSRECORD_Data rd_new[1];
1176  char *buf;
1177  size_t buf_size;
1178 
1180  buf = GNUNET_malloc (buf_size);
1183  "Storing new credential under `%s'.\n",
1184  label);
1185  rd_new[0].data_size = buf_size;
1186  rd_new[0].data = buf;
1187  rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL;
1188  rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1189  rd_new[0].expiration_time = ash->exp.rel_value_us;
1191  &ash->identity,
1192  label,
1193  1,
1194  rd_new,
1195  &cred_store_cont,
1196  ash);
1197  GNUNET_free (buf);
1198  return;
1199 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL
Record type for an attribute attestation (e.g.
static void cred_store_cont(void *cls, int32_t success, const char *emsg)
Credential store result handler.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.

References buf, cred_store_cont(), AttributeStoreHandle::credential, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, AttributeStoreHandle::exp, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_credential_serialize(), GNUNET_RECLAIM_credential_serialize_get_size(), AttributeStoreHandle::identity, AttributeStoreHandle::ns_qe, nsh, GNUNET_GNSRECORD_Data::record_type, and GNUNET_TIME_Relative::rel_value_us.

Referenced by cred_store_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cred_store_task()

static void cred_store_task ( void *  cls)
static

Add a new credential.

Parameters
clsthe AttributeStoreHandle

Definition at line 1208 of file gnunet-service-reclaim.c.

1209 {
1210  struct AttributeStoreHandle *ash = cls;
1211  char *label;
1212 
1213  // Give the ash a new id if unset
1217  sizeof (ash->credential->id));
1219  "Looking up existing data under label `%s'\n", label);
1221  &ash->identity,
1222  label,
1223  &cred_error,
1224  ash,
1225  &cred_add_cb,
1226  ash);
1227  GNUNET_free (label);
1228 }
static void cred_error(void *cls)
Error looking up potential credential.
static void cred_add_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Check for existing record before storing credential.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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_RECLAIM_Identifier id
ID.

References cred_add_cb(), cred_error(), AttributeStoreHandle::credential, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_records_lookup(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_YES, GNUNET_RECLAIM_Credential::id, AttributeStoreHandle::identity, AttributeStoreHandle::ns_qe, and nsh.

Referenced by handle_credential_store_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_credential_store_message()

static int check_credential_store_message ( void *  cls,
const struct AttributeStoreMessage sam 
)
static

Check an credential store message.

Parameters
clsunused
samthe message to check

Definition at line 1238 of file gnunet-service-reclaim.c.

1240 {
1241  uint16_t size;
1242 
1243  size = ntohs (sam->header.size);
1244  if (size <= sizeof(struct AttributeStoreMessage))
1245  {
1246  GNUNET_break (0);
1247  return GNUNET_SYSERR;
1248  }
1249  return GNUNET_OK;
1250 }

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, AttributeStoreMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_credential_store_message()

static void handle_credential_store_message ( void *  cls,
const struct AttributeStoreMessage sam 
)
static

Handle a credential store message.

Parameters
clsour client
samthe message to handle

Definition at line 1260 of file gnunet-service-reclaim.c.

1262 {
1263  struct AttributeStoreHandle *ash;
1264  struct IdpClient *idp = cls;
1265  size_t data_len;
1266 
1267  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1268 
1269  data_len = ntohs (sam->attr_len);
1270 
1271  ash = GNUNET_new (struct AttributeStoreHandle);
1272  ash->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &sam[1],
1273  data_len);
1274 
1275  ash->r_id = ntohl (sam->id);
1276  ash->identity = sam->identity;
1277  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1279 
1281  ash->client = idp;
1282  GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1284 }
static void cred_store_task(void *cls)
Add a new credential.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.

References AttributeStoreMessage::attr_len, AttributeStoreHandle::client, GNUNET_RECLAIM_Handle::client, cred_store_task(), AttributeStoreHandle::credential, AttributeStoreHandle::exp, AttributeStoreMessage::exp, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_key_get_public(), GNUNET_log, GNUNET_new, GNUNET_ntohll(), GNUNET_RECLAIM_credential_deserialize(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), AttributeStoreMessage::id, AttributeStoreHandle::identity, AttributeStoreMessage::identity, AttributeStoreHandle::identity_pkey, idp, AttributeStoreHandle::r_id, and GNUNET_TIME_Relative::rel_value_us.

Here is the call graph for this function:

◆ send_delete_response()

static void send_delete_response ( struct AttributeDeleteHandle adh,
int32_t  success 
)
static

Send a deletion success response.

Parameters
adhour attribute deletion handle
successthe success status

Definition at line 1294 of file gnunet-service-reclaim.c.

1295 {
1296  struct GNUNET_MQ_Envelope *env;
1297  struct SuccessResultMessage *acr_msg;
1298 
1300  adh->client->delete_op_tail,
1301  adh);
1302 
1303  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1305  acr_msg->id = htonl (adh->r_id);
1306  acr_msg->op_result = htonl (success);
1307  GNUNET_MQ_send (adh->client->mq, env);
1308 }
struct IdpClient * client
Client connection.
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.

References AttributeDeleteHandle::client, IdpClient::delete_op_head, IdpClient::delete_op_tail, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), SuccessResultMessage::id, IdpClient::mq, SuccessResultMessage::op_result, and AttributeDeleteHandle::r_id.

Referenced by attr_delete_cont(), consistency_iter_err(), cred_delete_cont(), offending_attr_delete_cont(), and update_tickets().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ consistency_iter()

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

Namestore iteration within attribute deletion.

We need to reissue tickets with the deleted attribute removed.

Parameters
clsour attribute deletion handle
zonethe private key of the ticket issuer
labelthe label of the record
rd_countnumber of records
rdrecord data

Definition at line 1322 of file gnunet-service-reclaim.c.

1327 {
1328  struct AttributeDeleteHandle *adh = cls;
1329  struct TicketRecordsEntry *le;
1332  int is_ticket = GNUNET_NO;
1333  for (int i = 0; i < rd_count; i++)
1334  {
1335  switch (rd[i].record_type)
1336  {
1340  rd[i].data_size,
1341  &ale->attribute);
1344  ale);
1345  break;
1349  rd[i].data_size);
1352  cle);
1353  break;
1356  "Ticket to delete found (%s)\n",
1357  label);
1358  is_ticket = GNUNET_YES;
1359  break;
1360  default:
1361  break;
1362  }
1363  if (GNUNET_YES == is_ticket)
1364  break;
1365  }
1366  if (GNUNET_YES == is_ticket)
1367  {
1368  le = GNUNET_new (struct TicketRecordsEntry);
1369  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
1370  le->data = GNUNET_malloc (le->data_size);
1371  le->rd_count = rd_count;
1372  le->label = GNUNET_strdup (label);
1373  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
1376  le);
1377  }
1379 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
local ticket reference
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t data
The data value.
@ GNUNET_NO
Definition: gnunet_common.h:94
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.
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.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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_AttributeListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_Credential * credential
The credential.
struct GNUNET_RECLAIM_CredentialListEntry * list_head
List head.
struct GNUNET_RECLAIM_CredentialListEntry * list_tail
List tail.
unsigned int rd_count
Record count.

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_CredentialListEntry::credential, TicketRecordsEntry::data, data, data_size, TicketRecordsEntry::data_size, AttributeDeleteHandle::existing_attributes, AttributeDeleteHandle::existing_credentials, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_new, GNUNET_NO, GNUNET_RECLAIM_attribute_deserialize(), GNUNET_RECLAIM_credential_deserialize(), GNUNET_strdup, GNUNET_YES, TicketRecordsEntry::label, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_CredentialList::list_head, GNUNET_RECLAIM_AttributeList::list_tail, GNUNET_RECLAIM_CredentialList::list_tail, AttributeDeleteHandle::ns_it, TicketRecordsEntry::rd_count, AttributeDeleteHandle::tickets_to_update_head, and AttributeDeleteHandle::tickets_to_update_tail.

Referenced by start_consistency_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_tickets()

static void update_tickets ( void *  cls)
static

Recursion prototype for function.

Update tickets: Remove shared attribute which has just been deleted.

Parameters
clsour deletion handle

This method is called recursively until all tickets are processed. Eventually, the updated tickets are stored using `‘update_tickets’'.

Parameters
clsour attribute deletion handle

Definition at line 1415 of file gnunet-service-reclaim.c.

1416 {
1417  struct AttributeDeleteHandle *adh = cls;
1418  struct TicketRecordsEntry *le;
1419 
1420  if (NULL == adh->tickets_to_update_head)
1421  {
1423  "Finished updating tickets, success\n");
1425  cleanup_adh (adh);
1426  return;
1427  }
1428  le = adh->tickets_to_update_head;
1431  le);
1432  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1433  struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1435  le->data,
1436  le->rd_count,
1437  rd))
1438  {
1440  "Unable to deserialize record data!\n");
1442  cleanup_adh (adh);
1443  return;
1444  }
1445  int j = 0;
1446  int i = 0;
1449  struct GNUNET_RECLAIM_Presentation *presentation;
1450  for (i = 0; i < le->rd_count; i++)
1451  {
1452  switch (rd[i].record_type)
1453  {
1455  for (ale = adh->existing_attributes->list_head; NULL != ale; ale =
1456  ale->next)
1457  {
1459  &ale->attribute->id))
1460  {
1462  "Found attribute %s, readding...\n",
1463  ale->attribute->name);
1464  rd_new[j] = rd[i];
1465  j++;
1466  break; // Found and added
1467  }
1468  }
1469  break;
1471  presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1472  rd[i].data_size);
1473  for (cle = adh->existing_credentials->list_head; NULL != cle; cle =
1474  cle->next)
1475  {
1477  &presentation->credential_id,
1478  &cle->credential->id))
1479  {
1481  "Found presentation for credential %s, readding...\n",
1482  cle->credential->name);
1483  rd_new[j] = rd[i];
1484  j++;
1485  break; // Found and added
1486  }
1487  }
1488  GNUNET_free (presentation);
1489  break;
1491  rd_new[j] = rd[i];
1492  j++;
1493  break; // Found and added
1494  default:
1495  GNUNET_break (0);
1496  }
1497  }
1499  "Updating ticket with %d entries (%d before)...\n",
1500  j, i);
1502  &adh->identity,
1503  le->label,
1504  j,
1505  rd_new,
1506  &ticket_updated,
1507  adh);
1508  GNUNET_free (le->label);
1509  GNUNET_free (le->data);
1510  GNUNET_free (le);
1511 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
for reclaim records
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
static void ticket_updated(void *cls, int32_t success, const char *emsg)
Callback called when a ticket was updated.
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.
#define GNUNET_RECLAIM_id_is_equal(a, b)
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
const char * name
The name of the credential.
A credential presentation.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.

References GNUNET_RECLAIM_AttributeListEntry::attribute, cleanup_adh(), GNUNET_RECLAIM_CredentialListEntry::credential, GNUNET_RECLAIM_Presentation::credential_id, TicketRecordsEntry::data, data, data_size, TicketRecordsEntry::data_size, AttributeDeleteHandle::existing_attributes, AttributeDeleteHandle::existing_credentials, GNUNET_break, 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_GNSRECORD_TYPE_RECLAIM_PRESENTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_OK, GNUNET_RECLAIM_id_is_equal, GNUNET_RECLAIM_presentation_deserialize(), GNUNET_SYSERR, GNUNET_YES, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Credential::id, AttributeDeleteHandle::identity, TicketRecordsEntry::label, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_CredentialList::list_head, GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_Credential::name, GNUNET_RECLAIM_AttributeListEntry::next, GNUNET_RECLAIM_CredentialListEntry::next, AttributeDeleteHandle::ns_qe, nsh, TicketRecordsEntry::rd_count, send_delete_response(), ticket_updated(), AttributeDeleteHandle::tickets_to_update_head, and AttributeDeleteHandle::tickets_to_update_tail.

Referenced by purge_attributes(), and ticket_updated().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_updated()

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

Callback called when a ticket was updated.

Parameters
clsour attribute deletion handle
successGNUNET_OK if successful
emsgerror message (NULL if success=GNUNET_OK)

Definition at line 1398 of file gnunet-service-reclaim.c.

1399 {
1400  struct AttributeDeleteHandle *adh = cls;
1401 
1402  adh->ns_qe = NULL;
1404 }
static void update_tickets(void *cls)
Recursion prototype for function.

References GNUNET_SCHEDULER_add_now(), AttributeDeleteHandle::ns_qe, and update_tickets().

Referenced by update_tickets().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ purge_attributes()

static void purge_attributes ( void *  cls)
static

Delete all attributes which reference credentials that no longer exist.

Definition at line 1546 of file gnunet-service-reclaim.c.

1547 {
1548  struct AttributeDeleteHandle *adh = cls;
1551 
1552  for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next)
1553  {
1554  if (GNUNET_YES ==
1556  continue;
1557 
1558  for (cle = adh->existing_credentials->list_head;
1559  NULL != cle; cle = cle->next)
1560  {
1561  if (GNUNET_YES !=
1563  &ale->attribute->credential))
1564  continue;
1565  break;
1566  }
1567  if (NULL == cle)
1568  {
1570  "Found attribute with missing credential\n");
1571  break;
1572  }
1573  }
1574  if (NULL == ale)
1575  {
1577  "Attributes consistent, updating tickets.\n");
1579  return;
1580  }
1582  "Attributes inconsistent, deleting offending attribute.\n");
1583  char *label
1585  sizeof(ale->attribute->id));
1586 
1588  &adh->identity,
1589  label,
1590  0,
1591  NULL,
1593  adh);
1596  ale);
1597  GNUNET_free (ale);
1598  GNUNET_free (label);
1599 }
static void offending_attr_delete_cont(void *cls, int32_t success, const char *emsg)
@ GNUNET_ERROR_TYPE_WARNING
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_Attribute::credential, GNUNET_RECLAIM_CredentialListEntry::credential, AttributeDeleteHandle::existing_attributes, AttributeDeleteHandle::existing_credentials, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_id_is_equal, GNUNET_RECLAIM_id_is_zero, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_YES, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Credential::id, AttributeDeleteHandle::identity, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_CredentialList::list_head, GNUNET_RECLAIM_AttributeList::list_tail, GNUNET_RECLAIM_AttributeListEntry::next, GNUNET_RECLAIM_CredentialListEntry::next, AttributeDeleteHandle::ns_qe, nsh, offending_attr_delete_cont(), and update_tickets().

Referenced by consistency_iter_fin(), and offending_attr_delete_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ offending_attr_delete_cont()

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

Definition at line 1522 of file gnunet-service-reclaim.c.

1523 {
1524  struct AttributeDeleteHandle *adh = cls;
1525 
1526  adh->ns_qe = NULL;
1527  if (GNUNET_SYSERR == success)
1528  {
1530  "Error deleting attribute %s\n",
1531  adh->label);
1533  cleanup_adh (adh);
1534  return;
1535  }
1536  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing consistency check...\n");
1538 }
static void purge_attributes(void *cls)
Delete all attributes which reference credentials that no longer exist.

References cleanup_adh(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, purge_attributes(), and send_delete_response().

Referenced by purge_attributes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ consistency_iter_fin()

static void consistency_iter_fin ( void *  cls)
static

Done collecting affected tickets, start updating.

Parameters
clsour attribute deletion handle

Definition at line 1608 of file gnunet-service-reclaim.c.

1609 {
1610  struct AttributeDeleteHandle *adh = cls;
1611  adh->ns_it = NULL;
1613 }

References GNUNET_SCHEDULER_add_now(), AttributeDeleteHandle::ns_it, and purge_attributes().

Referenced by start_consistency_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ consistency_iter_err()

static void consistency_iter_err ( void *  cls)
static

Error collecting affected tickets.

Abort.

Parameters
clsour attribute deletion handle

Definition at line 1622 of file gnunet-service-reclaim.c.

1623 {
1624  struct AttributeDeleteHandle *adh = cls;
1625 
1626  adh->ns_it = NULL;
1628  "Namestore error on consistency check\n");
1630  cleanup_adh (adh);
1631 }

References cleanup_adh(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SYSERR, AttributeDeleteHandle::ns_it, and send_delete_response().

Referenced by start_consistency_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_consistency_update()

static void start_consistency_update ( void *  cls)
static

Start processing tickets which may still contain reference to deleted attribute.

Parameters
clsattribute deletion handle

Definition at line 1641 of file gnunet-service-reclaim.c.

1642 {
1643  struct AttributeDeleteHandle *adh = cls;
1644 
1647 
1649  &adh->identity,
1651  adh,
1653  adh,
1655  adh);
1656 }
static void consistency_iter(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Namestore iteration within attribute deletion.
static void consistency_iter_err(void *cls)
Error collecting affected tickets.
static void consistency_iter_fin(void *cls)
Done collecting affected tickets, start updating.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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).
A list of GNUNET_RECLAIM_Credential structures.

References consistency_iter(), consistency_iter_err(), consistency_iter_fin(), AttributeDeleteHandle::existing_attributes, AttributeDeleteHandle::existing_credentials, GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_new, AttributeDeleteHandle::identity, AttributeDeleteHandle::ns_it, and nsh.

Referenced by attr_delete_cont(), and cred_delete_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_delete_cont()

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

Attribute deleted callback.

Parameters
clsour handle
successsuccess status
emsgerror message (NULL if success=GNUNET_OK)

Definition at line 1667 of file gnunet-service-reclaim.c.

1668 {
1669  struct AttributeDeleteHandle *adh = cls;
1670 
1671  adh->ns_qe = NULL;
1672  if (GNUNET_SYSERR == success)
1673  {
1675  "Error deleting attribute %s\n",
1676  adh->label);
1678  cleanup_adh (adh);
1679  return;
1680  }
1681  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1683 }
static void start_consistency_update(void *cls)
Start processing tickets which may still contain reference to deleted attribute.

References cleanup_adh(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, send_delete_response(), and start_consistency_update().

Referenced by handle_attribute_delete_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_attribute_delete_message()

static int check_attribute_delete_message ( void *  cls,
const struct AttributeDeleteMessage dam 
)
static

Check attribute delete message format.

@cls unused @dam message to check

Definition at line 1693 of file gnunet-service-reclaim.c.

1695 {
1696  uint16_t size;
1697 
1698  size = ntohs (dam->header.size);
1699  if (size <= sizeof(struct AttributeDeleteMessage))
1700  {
1701  GNUNET_break (0);
1702  return GNUNET_SYSERR;
1703  }
1704  return GNUNET_OK;
1705 }
Use to delete an identity attribute.
Definition: reclaim.h:75
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:79

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, AttributeDeleteMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_attribute_delete_message()

static void handle_attribute_delete_message ( void *  cls,
const struct AttributeDeleteMessage dam 
)
static

Handle attribute deletion.

Parameters
clsour client
damdeletion message

Definition at line 1715 of file gnunet-service-reclaim.c.

1717 {
1718  struct AttributeDeleteHandle *adh;
1719  struct IdpClient *idp = cls;
1720  size_t data_len;
1721 
1722  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1723 
1724  data_len = ntohs (dam->attr_len);
1725 
1726  adh = GNUNET_new (struct AttributeDeleteHandle);
1727  GNUNET_RECLAIM_attribute_deserialize ((char *) &dam[1],
1728  data_len,
1729  &adh->claim);
1730  adh->credential = NULL;
1731 
1732  adh->r_id = ntohl (dam->id);
1733  adh->identity = dam->identity;
1734  adh->label
1736  sizeof(adh->claim->id));
1738  adh->client = idp;
1739  GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1741  &adh->identity,
1742  adh->label,
1743  0,
1744  NULL,
1746  adh);
1747 }
static void attr_delete_cont(void *cls, int32_t success, const char *emsg)
Attribute deleted callback.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:94
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84

References attr_delete_cont(), AttributeDeleteMessage::attr_len, AttributeDeleteHandle::claim, AttributeDeleteHandle::client, GNUNET_RECLAIM_Handle::client, AttributeDeleteHandle::credential, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_new, GNUNET_RECLAIM_attribute_deserialize(), GNUNET_SERVICE_client_continue(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_Attribute::id, AttributeDeleteMessage::id, AttributeDeleteHandle::identity, AttributeDeleteMessage::identity, idp, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, nsh, and AttributeDeleteHandle::r_id.

Here is the call graph for this function:

◆ cred_delete_cont()

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

Credential deleted callback.

Parameters
clsour handle
successsuccess status
emsgerror message (NULL if success=GNUNET_OK)

Definition at line 1758 of file gnunet-service-reclaim.c.

1759 {
1760  struct AttributeDeleteHandle *adh = cls;
1761 
1762  adh->ns_qe = NULL;
1763  if (GNUNET_SYSERR == success)
1764  {
1766  "Error deleting credential `%s'\n",
1767  adh->label);
1769  cleanup_adh (adh);
1770  return;
1771  }
1772  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1774 }

References cleanup_adh(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, send_delete_response(), and start_consistency_update().

Referenced by handle_credential_delete_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_credential_delete_message()

static int check_credential_delete_message ( void *  cls,
const struct AttributeDeleteMessage dam 
)
static

Check credential delete message format.

@cls unused @dam message to check

Definition at line 1784 of file gnunet-service-reclaim.c.

1786 {
1787  uint16_t size;
1788 
1789  size = ntohs (dam->header.size);
1790  if (size <= sizeof(struct AttributeDeleteMessage))
1791  {
1792  GNUNET_break (0);
1793  return GNUNET_SYSERR;
1794  }
1795  return GNUNET_OK;
1796 }

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, AttributeDeleteMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_credential_delete_message()

static void handle_credential_delete_message ( void *  cls,
const struct AttributeDeleteMessage dam 
)
static

Handle credential deletion.

Parameters
clsour client
damdeletion message

Definition at line 1806 of file gnunet-service-reclaim.c.

1808 {
1809  struct AttributeDeleteHandle *adh;
1810  struct IdpClient *idp = cls;
1811  size_t data_len;
1812 
1813  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1814 
1815  data_len = ntohs (dam->attr_len);
1816 
1817  adh = GNUNET_new (struct AttributeDeleteHandle);
1818  adh->credential = GNUNET_RECLAIM_credential_deserialize ((char *) &dam[1],
1819  data_len);
1820  adh->claim = NULL;
1821 
1822  adh->r_id = ntohl (dam->id);
1823  adh->identity = dam->identity;
1824  adh->label
1826  sizeof(adh->credential->id));
1828  adh->client = idp;
1829  GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1831  &adh->identity,
1832  adh->label,
1833  0,
1834  NULL,
1836  adh);
1837 }
static void cred_delete_cont(void *cls, int32_t success, const char *emsg)
Credential deleted callback.

References AttributeDeleteMessage::attr_len, AttributeDeleteHandle::claim, AttributeDeleteHandle::client, GNUNET_RECLAIM_Handle::client, cred_delete_cont(), AttributeDeleteHandle::credential, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_new, GNUNET_RECLAIM_credential_deserialize(), GNUNET_SERVICE_client_continue(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_Credential::id, AttributeDeleteMessage::id, AttributeDeleteHandle::identity, AttributeDeleteMessage::identity, idp, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, nsh, and AttributeDeleteHandle::r_id.

Here is the call graph for this function:

◆ attr_iter_finished()

static void attr_iter_finished ( void *  cls)
static

Done iterating over attributes.

Parameters
clsour iterator handle

Definition at line 1851 of file gnunet-service-reclaim.c.

1852 {
1853  struct Iterator *ai = cls;
1854  struct GNUNET_MQ_Envelope *env;
1855  struct AttributeResultMessage *arm;
1856 
1857  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1859  arm->id = htonl (ai->request_id);
1860  arm->attr_len = htons (0);
1861  GNUNET_MQ_send (ai->client->mq, env);
1862  GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
1863  ai->client->attr_iter_tail,
1864  ai);
1865  GNUNET_free (ai);
1866 }
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
Attribute is returned from the idp.
Definition: reclaim.h:125
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134

References ai, AttributeResultMessage::attr_len, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), and AttributeResultMessage::id.

Referenced by attr_iter_error(), and handle_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_iter_error()

static void attr_iter_error ( void *  cls)
static

Error iterating over attributes.

Abort.

Parameters
clsour attribute iteration handle

Definition at line 1875 of file gnunet-service-reclaim.c.

1876 {
1877  struct Iterator *ai = cls;
1878 
1879  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
1881 }
static void attr_iter_finished(void *cls)
Done iterating over attributes.

References ai, attr_iter_finished(), GNUNET_ERROR_TYPE_ERROR, and GNUNET_log.

Referenced by handle_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_iter_cb()

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

Got record.

Return if it is an attribute.

Parameters
clsour attribute iterator
zonezone we are iterating
labellabel of the records
rd_countrecord count
rdrecords

Definition at line 1894 of file gnunet-service-reclaim.c.

1899 {
1900  struct Iterator *ai = cls;
1901  struct GNUNET_MQ_Envelope *env;
1902  char *data_tmp;
1903 
1904  if ((rd_count != 1) ||
1906  {
1908  return;
1909  }
1910  struct AttributeResultMessage *arm;
1911  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
1912  label);
1914  "Sending ATTRIBUTE_RESULT message\n");
1915  env = GNUNET_MQ_msg_extra (arm,
1916  rd->data_size,
1918  arm->id = htonl (ai->request_id);
1919  arm->attr_len = htons (rd->data_size);
1921  data_tmp = (char *) &arm[1];
1922  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
1923  GNUNET_MQ_send (ai->client->mq, env);
1924 }
static char * zone
Name of the zone being managed.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:154
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.

References ai, AttributeResultMessage::attr_len, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_IDENTITY_key_get_public(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAMESTORE_zone_iterator_next(), AttributeResultMessage::id, AttributeResultMessage::identity, GNUNET_GNSRECORD_Data::record_type, and zone.

Referenced by handle_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_iteration_start()

static void handle_iteration_start ( void *  cls,
const struct AttributeIterationStartMessage ais_msg 
)
static

Iterate over zone to get attributes.

Parameters
clsour client
ais_msgthe iteration message to start

Definition at line 1934 of file gnunet-service-reclaim.c.

1936 {
1937  struct IdpClient *idp = cls;
1938  struct Iterator *ai;
1939 
1941  "Received ATTRIBUTE_ITERATION_START message\n");
1942  ai = GNUNET_new (struct Iterator);
1943  ai->request_id = ntohl (ais_msg->id);
1944  ai->client = idp;
1945  ai->identity = ais_msg->identity;
1946 
1947  GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
1949  &ai->identity,
1950  &attr_iter_error,
1951  ai,
1952  &attr_iter_cb,
1953  ai,
1955  ai);
1957 }
static void attr_iter_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
static void attr_iter_error(void *cls)
Error iterating over attributes.
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:215
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:210

References ai, attr_iter_cb(), attr_iter_error(), attr_iter_finished(), GNUNET_RECLAIM_Handle::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_new, GNUNET_SERVICE_client_continue(), AttributeIterationStartMessage::id, AttributeIterationStartMessage::identity, idp, and nsh.

Here is the call graph for this function:

◆ handle_iteration_stop()

static void handle_iteration_stop ( void *  cls,
const struct AttributeIterationStopMessage ais_msg 
)
static

Handle iteration stop message from client.

Parameters
clsthe client
ais_msgthe stop message

Definition at line 1967 of file gnunet-service-reclaim.c.

1969 {
1970  struct IdpClient *idp = cls;
1971  struct Iterator *ai;
1972  uint32_t rid;
1973 
1975  "Received `%s' message\n",
1976  "ATTRIBUTE_ITERATION_STOP");
1977  rid = ntohl (ais_msg->id);
1978  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1979  if (ai->request_id == rid)
1980  break;
1981  if (NULL == ai)
1982  {
1983  GNUNET_break (0);
1985  return;
1986  }
1987  GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
1988  GNUNET_free (ai);
1990 }
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2325
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:305
struct GNUNET_TRANSPORT_AddressIdentifier * next
Kept in a DLL.

References ai, GNUNET_RECLAIM_Handle::client, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), AttributeIterationStopMessage::id, idp, and GNUNET_TRANSPORT_AddressIdentifier::next.

Here is the call graph for this function:

◆ handle_iteration_next()

static void handle_iteration_next ( void *  cls,
const struct AttributeIterationNextMessage ais_msg 
)
static

Client requests next attribute from iterator.

Parameters
clsthe client
ais_msgthe message

Definition at line 2000 of file gnunet-service-reclaim.c.

2002 {
2003  struct IdpClient *idp = cls;
2004  struct Iterator *ai;
2005  uint32_t rid;
2006 
2008  "Received ATTRIBUTE_ITERATION_NEXT message\n");
2009  rid = ntohl (ais_msg->id);
2010  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2011  if (ai->request_id == rid)
2012  break;
2013  if (NULL == ai)
2014  {
2015  GNUNET_break (0);
2017  return;
2018  }
2021 }
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:232

References ai, GNUNET_RECLAIM_Handle::client, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), AttributeIterationNextMessage::id, idp, and GNUNET_TRANSPORT_AddressIdentifier::next.

Here is the call graph for this function:

◆ cred_iter_finished()

static void cred_iter_finished ( void *  cls)
static

Done iterating over credentials.

Parameters
clsour iterator handle

Definition at line 2035 of file gnunet-service-reclaim.c.

2036 {
2037  struct Iterator *ai = cls;
2038  struct GNUNET_MQ_Envelope *env;
2039  struct CredentialResultMessage *arm;
2040 
2041  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
2043  arm->id = htonl (ai->request_id);
2044  arm->credential_len = htons (0);
2045  GNUNET_MQ_send (ai->client->mq, env);
2046  GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2047  ai->client->cred_iter_tail,
2048  ai);
2049  GNUNET_free (ai);
2050 }
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT
Credential is returned from the idp.
Definition: reclaim.h:165
uint16_t credential_len
Length of serialized attribute data.
Definition: reclaim.h:179
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:174

References ai, CredentialResultMessage::credential_len, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), and CredentialResultMessage::id.

Referenced by cred_iter_error(), and handle_credential_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cred_iter_error()

static void cred_iter_error ( void *  cls)
static

Error iterating over credentials.

Abort.

Parameters
clsour attribute iteration handle

Definition at line 2059 of file gnunet-service-reclaim.c.

2060 {
2061  struct Iterator *ai = cls;
2062 
2063  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over credentials\n");
2065 }
static void cred_iter_finished(void *cls)
Done iterating over credentials.

References ai, cred_iter_finished(), GNUNET_ERROR_TYPE_ERROR, and GNUNET_log.

Referenced by handle_credential_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cred_iter_cb()

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

Got record.

Return credential.

Parameters
clsour attribute iterator
zonezone we are iterating
labellabel of the records
rd_countrecord count
rdrecords

Definition at line 2078 of file gnunet-service-reclaim.c.

2083 {
2084  struct Iterator *ai = cls;
2085  struct GNUNET_MQ_Envelope *env;
2086  struct CredentialResultMessage *arm;
2087  char *data_tmp;
2088 
2089  if ((rd_count != 1) ||
2091  {
2093  return;
2094  }
2095  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n",
2096  label);
2098  "Sending CREDENTIAL_RESULT message\n");
2099  env = GNUNET_MQ_msg_extra (arm,
2100  rd->data_size,
2102  arm->id = htonl (ai->request_id);
2103  arm->credential_len = htons (rd->data_size);
2105  data_tmp = (char *) &arm[1];
2106  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2107 
2108  GNUNET_MQ_send (ai->client->mq, env);
2109 }
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:189

References ai, CredentialResultMessage::credential_len, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_IDENTITY_key_get_public(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAMESTORE_zone_iterator_next(), CredentialResultMessage::id, CredentialResultMessage::identity, GNUNET_GNSRECORD_Data::record_type, and zone.

Referenced by handle_credential_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_credential_iteration_start()

static void handle_credential_iteration_start ( void *  cls,
const struct CredentialIterationStartMessage ais_msg 
)
static

Iterate over zone to get attributes.

Parameters
clsour client
ais_msgthe iteration message to start

Definition at line 2119 of file gnunet-service-reclaim.c.

2122 {
2123  struct IdpClient *idp = cls;
2124  struct Iterator *ai;
2125 
2127  "Received CREDENTIAL_ITERATION_START message\n");
2128  ai = GNUNET_new (struct Iterator);
2129  ai->request_id = ntohl (ais_msg->id);
2130  ai->client = idp;
2131  ai->identity = ais_msg->identity;
2132 
2133  GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail,
2134  ai);
2136  &ai->identity,
2137  &cred_iter_error,
2138  ai,
2139  &cred_iter_cb,
2140  ai,
2142  ai);
2144 }
static void cred_iter_error(void *cls)
Error iterating over credentials.
static void cred_iter_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:249
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:254

References ai, GNUNET_RECLAIM_Handle::client, cred_iter_cb(), cred_iter_error(), cred_iter_finished(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_new, GNUNET_SERVICE_client_continue(), CredentialIterationStartMessage::id, CredentialIterationStartMessage::identity, idp, and nsh.

Here is the call graph for this function:

◆ handle_credential_iteration_stop()

static void handle_credential_iteration_stop ( void *  cls,
const struct CredentialIterationStopMessage ais_msg 
)
static

Handle iteration stop message from client.

Parameters
clsthe client
ais_msgthe stop message

Definition at line 2154 of file gnunet-service-reclaim.c.

2157 {
2158  struct IdpClient *idp = cls;
2159  struct Iterator *ai;
2160  uint32_t rid;
2161 
2163  "Received `%s' message\n",
2164  "CREDENTIAL_ITERATION_STOP");
2165  rid = ntohl (ais_msg->id);
2166  for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2167  if (ai->request_id == rid)
2168  break;
2169  if (NULL == ai)
2170  {
2171  GNUNET_break (0);
2173  return;
2174  }
2175  GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
2176  ai);
2177  GNUNET_free (ai);
2179 }
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:288

References ai, GNUNET_RECLAIM_Handle::client, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), CredentialIterationStopMessage::id, idp, and GNUNET_TRANSPORT_AddressIdentifier::next.

Here is the call graph for this function:

◆ handle_credential_iteration_next()

static void handle_credential_iteration_next ( void *  cls,
const struct CredentialIterationNextMessage ais_msg 
)
static

Client requests next credential from iterator.

Parameters
clsthe client
ais_msgthe message

Definition at line 2189 of file gnunet-service-reclaim.c.

2192 {
2193  struct IdpClient *idp = cls;
2194  struct Iterator *ai;
2195  uint32_t rid;
2196 
2198  "Received CREDENTIAL_ITERATION_NEXT message\n");
2199  rid = ntohl (ais_msg->id);
2200  for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2201  if (ai->request_id == rid)
2202  break;
2203  if (NULL == ai)
2204  {
2205  GNUNET_break (0);
2207  return;
2208  }
2211 }
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:271

References ai, GNUNET_RECLAIM_Handle::client, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), CredentialIterationNextMessage::id, idp, and GNUNET_TRANSPORT_AddressIdentifier::next.

Here is the call graph for this function:

◆ ticket_iter_cb()

static void ticket_iter_cb ( void *  cls,
struct GNUNET_RECLAIM_Ticket ticket 
)
static

Got a ticket.

Return to client

Parameters
clsour ticket iterator
ticketthe ticket

Definition at line 2225 of file gnunet-service-reclaim.c.

2226 {
2227  struct TicketIteration *ti = cls;
2228  struct GNUNET_MQ_Envelope *env;
2229  struct TicketResultMessage *trm;
2230 
2232  if (NULL == ticket)
2233  {
2234  /* send empty response to indicate end of list */
2236  ti->client->ticket_iter_tail,
2237  ti);
2238  }
2239  else
2240  {
2241  trm->ticket = *ticket;
2242  }
2243  trm->id = htonl (ti->r_id);
2244  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2245  GNUNET_MQ_send (ti->client->mq, env);
2246  if (NULL == ticket)
2247  GNUNET_free (ti);
2248 }
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
struct IdpClient * client
Client which intiated this zone iteration.
uint32_t r_id
The operation id for the iteration in the response for the client.

References TicketIteration::client, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), TicketResultMessage::id, IdpClient::mq, TicketIteration::r_id, ticket, TicketResultMessage::ticket, IdpClient::ticket_iter_head, and IdpClient::ticket_iter_tail.

Referenced by handle_ticket_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_ticket_iteration_start()

static void handle_ticket_iteration_start ( void *  cls,
const struct TicketIterationStartMessage tis_msg 
)
static

Client requests a ticket iteration.

Parameters
clsthe client
tis_msgthe iteration request message

Definition at line 2258 of file gnunet-service-reclaim.c.

2261 {
2262  struct IdpClient *client = cls;
2263  struct TicketIteration *ti;
2264 
2266  "Received TICKET_ITERATION_START message\n");
2267  ti = GNUNET_new (struct TicketIteration);
2268  ti->r_id = ntohl (tis_msg->id);
2269  ti->client = client;
2270 
2273  ti);
2274  ti->iter
2277 }
static void ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Got a ticket.
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_IDENTITY_PrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:326
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:321

References TicketIteration::client, IdpClient::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), TicketIterationStartMessage::id, TicketIterationStartMessage::identity, TicketIteration::iter, TicketIteration::r_id, RECLAIM_TICKETS_iteration_start(), ticket_iter_cb(), IdpClient::ticket_iter_head, and IdpClient::ticket_iter_tail.

Here is the call graph for this function:

◆ handle_ticket_iteration_stop()

static void handle_ticket_iteration_stop ( void *  cls,
const struct TicketIterationStopMessage tis_msg 
)
static

Client has had enough tickets.

Parameters
clsthe client
tis_msgthe stop message

Definition at line 2287 of file gnunet-service-reclaim.c.

2289 {
2290  struct IdpClient *client = cls;
2291  struct TicketIteration *ti;
2292  uint32_t rid;
2293 
2295  "Received `%s' message\n",
2296  "TICKET_ITERATION_STOP");
2297  rid = ntohl (tis_msg->id);
2298  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2299  if (ti->r_id == rid)
2300  break;
2301  if (NULL == ti)
2302  {
2303  GNUNET_break (0);
2305  return;
2306  }
2310  ti);
2311  GNUNET_free (ti);
2313 }
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:360
struct TicketIteration * next
DLL.

References TicketIteration::client, IdpClient::client, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), TicketIterationStopMessage::id, TicketIteration::iter, TicketIteration::next, TicketIteration::r_id, RECLAIM_TICKETS_iteration_stop(), IdpClient::ticket_iter_head, and IdpClient::ticket_iter_tail.

Here is the call graph for this function:

◆ handle_ticket_iteration_next()

static void handle_ticket_iteration_next ( void *  cls,
const struct TicketIterationNextMessage tis_msg 
)
static

Client requests next result.

Parameters
clsthe client
tis_msgthe message

Definition at line 2323 of file gnunet-service-reclaim.c.

2325 {
2326  struct IdpClient *client = cls;
2327  struct TicketIteration *ti;
2328  uint32_t rid;
2329 
2331  "Received TICKET_ITERATION_NEXT message\n");
2332  rid = ntohl (tis_msg->id);
2333  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2334  if (ti->r_id == rid)
2335  break;
2336  if (NULL == ti)
2337  {
2338  GNUNET_break (0);
2340  return;
2341  }
2344 }
void RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
Continue ticket iteration.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:343

References TicketIteration::client, IdpClient::client, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), TicketIterationNextMessage::id, TicketIteration::iter, TicketIteration::next, TicketIteration::r_id, RECLAIM_TICKETS_iteration_next(), and IdpClient::ticket_iter_head.

Here is the call graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle server 
)
static

Main function that will be run.

Parameters
clsclosure
cthe configuration used
serverthe service handle

Definition at line 2355 of file gnunet-service-reclaim.c.

2358 {
2359  cfg = c;
2360 
2362  {
2364  "Unable to initialize TICKETS subsystem.\n");
2366  return;
2367  }
2368  // Connect to identity and namestore services
2370  if (NULL == nsh)
2371  {
2373  "error connecting to namestore");
2374  }
2375 
2377 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1331

References cfg, do_shutdown(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_strerror, GNUNET_NAMESTORE_connect(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), nsh, and RECLAIM_TICKETS_init().

Here is the call graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Called whenever a client is disconnected.

Parameters
clsclosure
clientidentification of the client
app_ctxclient

Definition at line 2388 of file gnunet-service-reclaim.c.

2391 {
2392  struct IdpClient *idp = app_ctx;
2393 
2394  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
2397  idp);
2398  cleanup_client (idp);
2399 }
static struct IdpClient * client_list_tail
Client list.
static struct IdpClient * client_list_head
Client list.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.

References cleanup_client(), IdpClient::client, client_list_head, client_list_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and idp.

Here is the call graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Add a client to our list of active clients.

Parameters
clsNULL
clientclient to add
mqmessage queue for client
Returns
internal namestore client structure for this client

Definition at line 2411 of file gnunet-service-reclaim.c.

2414 {
2415  struct IdpClient *idp;
2416 
2417  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
2418  idp = GNUNET_new (struct IdpClient);
2419  idp->client = client;
2420  idp->mq = mq;
2423  idp);
2424  return idp;
2425 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:392

References IdpClient::client, GNUNET_RECLAIM_Handle::client, client_list_head, client_list_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, idp, mq, and GNUNET_RECLAIM_Handle::mq.

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "reclaim"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_var_size(attribute_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, struct AttributeStoreMessage, NULL)  ,
GNUNET_MQ_hd_var_size(credential_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, struct AttributeStoreMessage, NULL)  ,
GNUNET_MQ_hd_var_size(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL)  ,
GNUNET_MQ_hd_var_size(credential_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, struct AttributeDeleteMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, struct AttributeIterationStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, struct AttributeIterationNextMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, struct AttributeIterationStopMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(credential_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, struct CredentialIterationStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(credential_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, struct CredentialIterationNextMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(credential_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, struct CredentialIterationStopMessage, NULL)  ,
GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL)  ,
GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL)  ,
GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Variable Documentation

◆ nsh

struct GNUNET_NAMESTORE_Handle* nsh
static

◆ timeout_task

struct GNUNET_SCHEDULER_Task* timeout_task
static

Timeout task.

Definition at line 46 of file gnunet-service-reclaim.c.

Referenced by cleanup().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

Definition at line 51 of file gnunet-service-reclaim.c.

Referenced by run().

◆ client_list_head

struct IdpClient* client_list_head = NULL
static

Client list.

Definition at line 475 of file gnunet-service-reclaim.c.

Referenced by client_connect_cb(), and client_disconnect_cb().

◆ client_list_tail

struct IdpClient* client_list_tail = NULL
static

Client list.

Definition at line 480 of file gnunet-service-reclaim.c.

Referenced by client_connect_cb(), and client_disconnect_cb().