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_attribute_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  AttributeIterator
 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, 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, 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_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 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 attest_store_cont (void *cls, int32_t success, const char *emsg)
 Attestation store result handler. More...
 
static void send_ref_error (struct AttributeStoreHandle *ash)
 Send a reference error response. More...
 
static void attest_error (void *cls)
 Error looking up potential attestation. More...
 
static void attest_add_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Check for existing record before storing reference. More...
 
static void attest_store_task (void *cls)
 Add a new attestation. More...
 
static int check_attestation_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Check an attestation store message. More...
 
static void handle_attestation_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Handle an attestation store message. More...
 
static void ref_error (void *cls)
 Error looking up potential reference value. More...
 
static void ref_del_error (void *cls)
 Error looking up potential reference value. More...
 
static void reference_store_cont (void *cls, int32_t success, const char *emsg)
 Reference store result handler. More...
 
static void ref_add_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Check for existing record before storing reference. More...
 
static void reference_store_task (void *cls)
 Add a new reference. More...
 
static int check_reference_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Check an attestation reference store message. More...
 
static void handle_reference_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Handle an attestation reference store message. More...
 
static void send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
 Send a deletion success response. More...
 
static void ticket_iter (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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 ticket_iter_fin (void *cls)
 Done collecting affected tickets, start updating. More...
 
static void ticket_iter_err (void *cls)
 Error collecting affected tickets. More...
 
static void start_ticket_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 attest_delete_cont (void *cls, int32_t success, const char *emsg)
 Attestation deleted callback. More...
 
static int check_attestation_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Check attestation delete message format. More...
 
static void handle_attestation_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Handle attestation deletion. More...
 
static void reference_delete_cont (void *cls, int32_t success, const char *emsg)
 Reference deleted callback. More...
 
static void ref_del_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 
static int check_reference_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Check an attestation reference delete message. More...
 
static void handle_reference_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Handle reference 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_CRYPTO_EcdsaPrivateKey *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 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(attestation_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_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(attestation_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_var_size(reference_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(reference_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_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_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 469 of file gnunet-service-reclaim.c.

References AttributeDeleteHandle::attest, AttributeDeleteHandle::claim, TicketRecordsEntry::data, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_zone_iteration_stop(), TicketRecordsEntry::label, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_it, AttributeDeleteHandle::ns_qe, AttributeDeleteHandle::reference, AttributeDeleteHandle::tickets_to_update_head, and AttributeDeleteHandle::tickets_to_update_tail.

Referenced by attest_delete_cont(), attr_delete_cont(), cleanup_client(), ref_del_cb(), ref_del_error(), reference_delete_cont(), ticket_iter_err(), and update_tickets().

470 {
471  struct TicketRecordsEntry *le;
472 
473  if (NULL != adh->ns_it)
475  if (NULL != adh->ns_qe)
477  if (NULL != adh->label)
478  GNUNET_free (adh->label);
479  if (NULL != adh->claim)
480  GNUNET_free (adh->claim);
481  if (NULL != adh->attest)
482  GNUNET_free (adh->attest);
483  if (NULL != adh->reference)
484  GNUNET_free (adh->reference);
485  while (NULL != (le = adh->tickets_to_update_head))
486  {
489  le);
490  if (NULL != le->label)
491  GNUNET_free (le->label);
492  if (NULL != le->data)
493  GNUNET_free (le->data);
494  GNUNET_free (le);
495  }
496  GNUNET_free (adh);
497 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
char * label
Attribute label.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to delete.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to delete.
#define GNUNET_free(ptr)
Wrapper around free.
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 506 of file gnunet-service-reclaim.c.

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

Referenced by attest_error(), attest_store_cont(), attr_store_cont(), cleanup_client(), ref_error(), reference_store_cont(), and send_ref_error().

507 {
508  if (NULL != ash->ns_qe)
510  if (NULL != ash->claim)
511  GNUNET_free (ash->claim);
512  if (NULL != ash->attest)
513  GNUNET_free (ash->attest);
514  if (NULL != ash->reference)
515  GNUNET_free (ash->reference);
516  GNUNET_free (ash);
517 }
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to store.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to store.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to store.
#define GNUNET_free(ptr)
Wrapper around free.
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 526 of file gnunet-service-reclaim.c.

References ai, IdpClient::attr_iter_head, IdpClient::attr_iter_tail, ConsumeTicketOperation::ch, cleanup_adh(), cleanup_as_handle(), IdpClient::consume_op_head, IdpClient::consume_op_tail, IdpClient::delete_op_head, IdpClient::delete_op_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, IdpClient::issue_op_head, IdpClient::issue_op_tail, TicketIteration::iter, RECLAIM_TICKETS_consume_cancel(), RECLAIM_TICKETS_iteration_stop(), RECLAIM_TICKETS_revoke_cancel(), IdpClient::revoke_op_head, IdpClient::revoke_op_tail, TicketRevocationOperation::rh, IdpClient::store_op_head, IdpClient::store_op_tail, IdpClient::ticket_iter_head, and IdpClient::ticket_iter_tail.

Referenced by cleanup(), and client_disconnect_cb().

527 {
528  struct AttributeIterator *ai;
529  struct TicketIteration *ti;
530  struct TicketRevocationOperation *rop;
531  struct TicketIssueOperation *iss;
532  struct ConsumeTicketOperation *ct;
533  struct AttributeStoreHandle *as;
534  struct AttributeDeleteHandle *adh;
535 
536  while (NULL != (iss = idp->issue_op_head))
537  {
539  GNUNET_free (iss);
540  }
541  while (NULL != (ct = idp->consume_op_head))
542  {
544  idp->consume_op_tail,
545  ct);
546  if (NULL != ct->ch)
548  GNUNET_free (ct);
549  }
550  while (NULL != (as = idp->store_op_head))
551  {
553  cleanup_as_handle (as);
554  }
555  while (NULL != (adh = idp->delete_op_head))
556  {
558  cleanup_adh (adh);
559  }
560 
561  while (NULL != (ai = idp->attr_iter_head))
562  {
564  GNUNET_free (ai);
565  }
566  while (NULL != (rop = idp->revoke_op_head))
567  {
569  if (NULL != rop->rh)
571  GNUNET_free (rop);
572  }
573  while (NULL != (ti = idp->ticket_iter_head))
574  {
576  idp->ticket_iter_tail,
577  ti);
578  if (NULL != ti->iter)
580  GNUNET_free (ti);
581  }
582  GNUNET_free (idp);
583 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle for attribute deletion request.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
Ticket issue operation handle.
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
struct RECLAIM_TICKETS_ConsumeHandle * ch
Ticket consume handle.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
A ticket iteration operation.
Ticket revocation request handle.
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
Handle for ticket consume request.
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
An attribute iteration operation.
#define GNUNET_free(ptr)
Wrapper around free.
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 590 of file gnunet-service-reclaim.c.

References cleanup_client(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_disconnect(), GNUNET_SCHEDULER_cancel(), and RECLAIM_TICKETS_deinit().

Referenced by do_shutdown().

591 {
592  struct IdpClient *cl;
593 
594  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
595 
596  while (NULL != (cl = client_list_head))
597  {
600  cl);
601  cleanup_client (cl);
602  }
604  if (NULL != timeout_task)
606  if (NULL != nsh)
608 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
An idp client.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
static struct IdpClient * client_list_head
Client list.
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
static struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
static struct IdpClient * client_list_tail
Client list.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 617 of file gnunet-service-reclaim.c.

References cleanup(), GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

Referenced by attest_error(), attest_store_cont(), attr_store_cont(), ref_del_cb(), ref_del_error(), ref_error(), reference_store_cont(), and run().

618 {
619  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
620  cleanup ();
621 }
static void cleanup()
Cleanup task.
#define GNUNET_log(kind,...)
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,
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 633 of file gnunet-service-reclaim.c.

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), TicketResultMessage::id, IdpClient::mq, ticket, and TicketResultMessage::ticket.

Referenced by issue_ticket_result_cb().

637 {
638  struct TicketResultMessage *irm;
639  struct GNUNET_MQ_Envelope *env;
640 
641  env = GNUNET_MQ_msg (irm,
643  if (NULL != ticket)
644  {
645  irm->ticket = *ticket;
646  }
647  // TODO add success member
648  irm->id = htonl (r_id);
649  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
650  GNUNET_MQ_send (client->mq, env);
651 }
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:406
Ticket result message.
Definition: reclaim.h:396
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:411
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
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:353
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,
int32_t  success,
const char *  emsg 
)
static

Issue ticket result.

Parameters
clsout ticket issue operation handle
ticketthe issued ticket
successissue success status (GNUNET_OK if successful)
emsgerror message (NULL of success is GNUNET_OK)

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

References TicketIssueOperation::client, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, IdpClient::issue_op_head, IdpClient::issue_op_tail, TicketIssueOperation::r_id, send_ticket_result(), and tio.

Referenced by handle_issue_ticket_message().

667 {
668  struct TicketIssueOperation *tio = cls;
669 
670  if (GNUNET_OK != success)
671  {
672  send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR);
674  tio->client->issue_op_tail,
675  tio);
676  GNUNET_free (tio);
677  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
678  return;
679  }
680  send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR);
682  tio->client->issue_op_tail,
683  tio);
684  GNUNET_free (tio);
685 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
struct IdpClient * client
Client connection.
Ticket issue operation handle.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
uint32_t r_id
request id
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
#define GNUNET_log(kind,...)
static void send_ticket_result(const struct IdpClient *client, uint32_t r_id, const struct GNUNET_RECLAIM_Ticket *ticket, uint32_t success)
Sends a ticket result message to the client.
#define GNUNET_free(ptr)
Wrapper around free.
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.

unused message to check

Returns
GNUNET_OK if message is ok

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

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

697 {
698  uint16_t size;
699 
700  size = ntohs (im->header.size);
701  if (size <= sizeof(struct IssueTicketMessage))
702  {
703  GNUNET_break (0);
704  return GNUNET_SYSERR;
705  }
706  return GNUNET_OK;
707 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET.
Definition: reclaim.h:315
Ticket issue message.
Definition: reclaim.h:310
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ 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 717 of file gnunet-service-reclaim.c.

References IssueTicketMessage::attr_len, IdpClient::client, TicketIssueOperation::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(), IdpClient::issue_op_head, IdpClient::issue_op_tail, issue_ticket_result_cb(), TicketIssueOperation::r_id, RECLAIM_TICKETS_issue(), and tio.

718 {
719  struct TicketIssueOperation *tio;
720  struct IdpClient *idp = cls;
722  size_t attrs_len;
723 
724  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
725  tio = GNUNET_new (struct TicketIssueOperation);
726  attrs_len = ntohs (im->attr_len);
727  attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &im[1],
728  attrs_len);
729  tio->r_id = ntohl (im->id);
730  tio->client = idp;
733  attrs,
734  &im->rp,
736  tio);
739 }
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:330
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
struct IdpClient * client
Client connection.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
Ticket issue operation handle.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
uint32_t r_id
request id
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:325
struct GNUNET_SERVICE_Client * client
The client.
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
static void issue_ticket_result_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, int32_t success, const char *emsg)
Issue ticket result.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:320
uint32_t attr_len
length of serialized attribute list
Definition: reclaim.h:335
void RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes...
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
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 753 of file gnunet-service-reclaim.c.

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

754 {
755  struct TicketRevocationOperation *rop = cls;
756  struct GNUNET_MQ_Envelope *env;
757  struct RevokeTicketResultMessage *trm;
758 
760  "Sending REVOKE_TICKET_RESULT message\n");
761  rop->rh = NULL;
763  trm->id = htonl (rop->r_id);
764  trm->success = htonl (success);
765  GNUNET_MQ_send (rop->client->mq, env);
767  rop->client->revoke_op_tail,
768  rop);
769  GNUNET_free (rop);
770 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
struct IdpClient * client
Client connection.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
Ticket revocation request handle.
Ticket revoke message.
Definition: reclaim.h:374
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:384
#define GNUNET_log(kind,...)
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:353
uint32_t success
Revocation result.
Definition: reclaim.h:389
#define GNUNET_free(ptr)
Wrapper around free.
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 781 of file gnunet-service-reclaim.c.

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

782 {
783  uint16_t size;
784 
785  size = ntohs (im->header.size);
786  if (size != sizeof(struct RevokeTicketMessage))
787  {
788  GNUNET_break (0);
789  return GNUNET_SYSERR;
790  }
791  return GNUNET_OK;
792 }
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET.
Definition: reclaim.h:348
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67
Ticket revoke message.
Definition: reclaim.h:343

◆ 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 802 of file gnunet-service-reclaim.c.

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

803 {
804  struct TicketRevocationOperation *rop;
805  struct IdpClient *idp = cls;
806 
807  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
808  rop = GNUNET_new (struct TicketRevocationOperation);
809  rop->r_id = ntohl (rm->id);
810  rop->client = idp;
812  rop->rh
814  rop);
816 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:358
static void revoke_result_cb(void *cls, int32_t success)
Handles revocation result.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:353
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
struct IdpClient * client
Client connection.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:368
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
Ticket revocation request handle.
struct RECLAIM_TICKETS_RevokeHandle * RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
Revoke a ticket.
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Here is the call graph for this function:

◆ consume_result_cb()

static void consume_result_cb ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs,
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 829 of file gnunet-service-reclaim.c.

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(), ConsumeTicketResultMessage::id, identity, ConsumeTicketResultMessage::identity, IdpClient::mq, ConsumeTicketOperation::r_id, and ConsumeTicketResultMessage::result.

Referenced by handle_consume_ticket_message().

834 {
835  struct ConsumeTicketOperation *cop = cls;
836  struct ConsumeTicketResultMessage *crm;
837  struct GNUNET_MQ_Envelope *env;
838  char *data_tmp;
839  size_t attrs_len;
840 
841  if (GNUNET_OK != success)
842  {
843  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
844  }
847  "Sending CONSUME_TICKET_RESULT message\n");
848  env = GNUNET_MQ_msg_extra (crm,
849  attrs_len,
851  crm->id = htonl (cop->r_id);
852  crm->attrs_len = htons (attrs_len);
853  crm->identity = *identity;
854  crm->result = htonl (success);
855  data_tmp = (char *) &crm[1];
856  GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp);
857  GNUNET_MQ_send (cop->client->mq, env);
859  cop->client->consume_op_tail,
860  cop);
861  GNUNET_free (cop);
862 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Attribute list is returned from the idp.
Definition: reclaim.h:443
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:453
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint32_t result
Result.
Definition: reclaim.h:458
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
#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
struct IdpClient * client
Client connection.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:473
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:463
#define GNUNET_log(kind,...)
Handle for ticket consume request.
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:353
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result)
Serialize an attribute list.
#define GNUNET_free(ptr)
Wrapper around free.
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 872 of file gnunet-service-reclaim.c.

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

873 {
874  uint16_t size;
875 
876  size = ntohs (cm->header.size);
877  if (size != sizeof(struct ConsumeTicketMessage))
878  {
879  GNUNET_break (0);
880  return GNUNET_SYSERR;
881  }
882  return GNUNET_OK;
883 }
Ticket consume message.
Definition: reclaim.h:417
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:422

◆ 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 the message to handle

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

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

894 {
895  struct ConsumeTicketOperation *cop;
896  struct IdpClient *idp = cls;
897 
898  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
899  cop = GNUNET_new (struct ConsumeTicketOperation);
900  cop->r_id = ntohl (cm->id);
901  cop->client = idp;
902  cop->ch
904  cop);
907 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void consume_result_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, int32_t success, const char *emsg)
Handle a ticket consume result.
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
An idp client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:432
struct IdpClient * client
Client connection.
struct RECLAIM_TICKETS_ConsumeHandle * ch
Ticket consume handle.
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:437
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
#define GNUNET_log(kind,...)
Handle for ticket consume request.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:427
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 923 of file gnunet-service-reclaim.c.

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

924 {
925  struct AttributeStoreHandle *ash = cls;
926  struct GNUNET_MQ_Envelope *env;
927  struct SuccessResultMessage *acr_msg;
928 
929  ash->ns_qe = NULL;
931  ash->client->store_op_tail,
932  ash);
933 
934  if (GNUNET_SYSERR == success)
935  {
937  "Failed to store attribute %s\n",
938  emsg);
939  cleanup_as_handle (ash);
941  return;
942  }
943 
944  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
946  acr_msg->id = htonl (ash->r_id);
947  acr_msg->op_result = htonl (GNUNET_OK);
948  GNUNET_MQ_send (ash->client->mq, env);
949  cleanup_as_handle (ash);
950 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
uint32_t r_id
request id
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:1280
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
Attribute store/delete response message.
Definition: reclaim.h:103
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_log(kind,...)
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
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:353
static void do_shutdown(void *cls)
Shutdown task.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
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 959 of file gnunet-service-reclaim.c.

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_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_ATTRIBUTE_serialize(), GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, AttributeStoreHandle::identity, AttributeStoreHandle::ns_qe, GNUNET_GNSRECORD_Data::record_type, and GNUNET_TIME_Relative::rel_value_us.

Referenced by handle_attribute_store_message().

960 {
961  struct AttributeStoreHandle *ash = cls;
962  struct GNUNET_GNSRECORD_Data rd[1];
963  char *buf;
964  char *label;
965  size_t buf_size;
966 
967  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
969  buf = GNUNET_malloc (buf_size);
970  // Give the ash a new id if unset
971  if (0 == ash->claim->id)
972  ash->claim->id
975  label
976  = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof(uint64_t));
977  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
978 
979  rd[0].data_size = buf_size;
980  rd[0].data = buf;
981  rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR;
983  rd[0].expiration_time = ash->exp.rel_value_us;
985  &ash->identity,
986  label,
987  1,
988  rd,
990  ash);
991  GNUNET_free (buf);
992  GNUNET_free (label);
993 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
uint64_t rel_value_us
The actual value.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
static void attr_store_cont(void *cls, int32_t success, const char *emsg)
Attribute store result handler.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to store.
Handle for attribute store request.
static char buf[2048]
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
This flag is currently unused; former RF_PENDING flag.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1003 of file gnunet-service-reclaim.c.

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

1005 {
1006  uint16_t size;
1007 
1008  size = ntohs (sam->header.size);
1009  if (size <= sizeof(struct AttributeStoreMessage))
1010  {
1011  GNUNET_break (0);
1012  return GNUNET_SYSERR;
1013  }
1014  return GNUNET_OK;
1015 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Use to store an identity attribute.
Definition: reclaim.h:40
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ 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 1025 of file gnunet-service-reclaim.c.

References AttributeStoreMessage::attr_len, attr_store_task(), AttributeStoreHandle::claim, IdpClient::client, AttributeStoreHandle::client, AttributeStoreHandle::exp, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_ntohll(), GNUNET_RECLAIM_ATTRIBUTE_deserialize(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), AttributeStoreHandle::identity, AttributeStoreHandle::identity_pkey, AttributeStoreHandle::r_id, GNUNET_TIME_Relative::rel_value_us, IdpClient::store_op_head, and IdpClient::store_op_tail.

1027 {
1028  struct AttributeStoreHandle *ash;
1029  struct IdpClient *idp = cls;
1030  size_t data_len;
1031 
1032  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1033 
1034  data_len = ntohs (sam->attr_len);
1035 
1036  ash = GNUNET_new (struct AttributeStoreHandle);
1037  ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &sam[1],
1038  data_len);
1039 
1040  ash->r_id = ntohl (sam->id);
1041  ash->identity = sam->identity;
1042  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1044 
1046  ash->client = idp;
1049 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:65
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct GNUNET_SERVICE_Client * client
The client.
uint32_t r_id
request id
static void attr_store_task(void *cls)
Add a new attribute.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to store.
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:1280
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:55
struct GNUNET_CRYPTO_EcdsaPublicKey identity_pkey
Identity pubkey.
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:60
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:172
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
Here is the call graph for this function:

◆ attest_store_cont()

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

Attestation store result handler.

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

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

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

1061 {
1062  struct AttributeStoreHandle *ash = cls;
1063  struct GNUNET_MQ_Envelope *env;
1064  struct SuccessResultMessage *acr_msg;
1065 
1066  ash->ns_qe = NULL;
1068  ash->client->store_op_tail,
1069  ash);
1070 
1071  if (GNUNET_SYSERR == success)
1072  {
1074  "Failed to store attestation %s\n",
1075  emsg);
1076  cleanup_as_handle (ash);
1078  return;
1079  }
1080 
1081  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1083  acr_msg->id = htonl (ash->r_id);
1084  acr_msg->op_result = htonl (GNUNET_OK);
1085  GNUNET_MQ_send (ash->client->mq, env);
1086  cleanup_as_handle (ash);
1087 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
uint32_t r_id
request id
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:1280
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
Attribute store/delete response message.
Definition: reclaim.h:103
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_log(kind,...)
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
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:353
static void do_shutdown(void *cls)
Shutdown task.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_ref_error()

static void send_ref_error ( struct AttributeStoreHandle ash)
static

Send a reference error response.

Parameters
ashour attribute store handle
successthe success status

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

References cleanup_as_handle(), AttributeStoreHandle::client, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), 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 attest_add_cb(), and ref_add_cb().

1097 {
1098  struct GNUNET_MQ_Envelope *env;
1099  struct SuccessResultMessage *acr_msg;
1100 
1101  ash->ns_qe = NULL;
1103  ash->client->store_op_tail,
1104  ash);
1105 
1106  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1108  acr_msg->id = htonl (ash->r_id);
1109  acr_msg->op_result = htonl (GNUNET_SYSERR);
1110  GNUNET_MQ_send (ash->client->mq, env);
1111  cleanup_as_handle (ash);
1112 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
uint32_t r_id
request id
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
Attribute store/delete response message.
Definition: reclaim.h:103
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_log(kind,...)
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
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:353
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attest_error()

static void attest_error ( void *  cls)
static

Error looking up potential attestation.

Abort.

Parameters
clsour attribute store handle

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

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

Referenced by attest_store_task().

1121 {
1122  struct AttributeStoreHandle *ash = cls;
1124  "Failed to check for existing Attestation\n");
1125  cleanup_as_handle (ash);
1127  return;
1128 }
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
Handle for attribute store request.
#define GNUNET_log(kind,...)
static void do_shutdown(void *cls)
Shutdown task.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attest_add_cb()

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

Check for existing record before storing reference.

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

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

References AttributeStoreHandle::attest, attest_store_cont(), buf, 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_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_ATTESTATION_serialize(), GNUNET_RECLAIM_ATTESTATION_serialize_get_size(), AttributeStoreHandle::identity, AttributeStoreHandle::ns_qe, GNUNET_GNSRECORD_Data::record_type, GNUNET_TIME_Relative::rel_value_us, and send_ref_error().

Referenced by attest_store_task().

1145 {
1146  struct AttributeStoreHandle *ash = cls;
1147  char *buf;
1148  size_t buf_size;
1150  buf = GNUNET_malloc (buf_size);
1152  if (0 == rd_count )
1153  {
1155  "Storing new Attestation\n");
1156  struct GNUNET_GNSRECORD_Data rd_new[1];
1157  rd_new[0].data_size = buf_size;
1158  rd_new[0].data = buf;
1159  rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR;
1160  rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1161  rd_new[0].expiration_time = ash->exp.rel_value_us;
1162  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1164  &ash->identity,
1165  label,
1166  1,
1167  rd_new,
1169  ash);
1170  GNUNET_free (buf);
1171  return;
1172  }
1174  {
1176  "Existing Attestation location is not an Attestation\n");
1177  send_ref_error (ash);
1178  return;
1179  }
1180  struct GNUNET_GNSRECORD_Data rd_new[rd_count];
1181  for (int i = 0; i<rd_count; i++)
1182  {
1183  rd_new[i] = rd[i];
1184  }
1185  rd_new[0].data_size = buf_size;
1186  rd_new[0].data = buf;
1187  rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR;
1188  rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1189  rd_new[0].expiration_time = ash->exp.rel_value_us;
1190  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1192  &ash->identity,
1193  label,
1194  rd_count,
1195  rd_new,
1197  ash);
1198  GNUNET_free (buf);
1199 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
uint64_t rel_value_us
The actual value.
size_t GNUNET_RECLAIM_ATTESTATION_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
Get required size for serialization buffer FIXME:
size_t data_size
Number of bytes in data.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR
Record type for reclaim identity attestation.
static void send_ref_error(struct AttributeStoreHandle *ash)
Send a reference error response.
Handle for attribute store request.
static char buf[2048]
size_t GNUNET_RECLAIM_ATTESTATION_serialize(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, char *result)
Serialize an attestation.
static void attest_store_cont(void *cls, int32_t success, const char *emsg)
Attestation store result handler.
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
This flag is currently unused; former RF_PENDING flag.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to store.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attest_store_task()

static void attest_store_task ( void *  cls)
static

Add a new attestation.

Parameters
clsthe AttributeStoreHandle

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

References AttributeStoreHandle::attest, attest_add_cb(), attest_error(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_records_lookup(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTESTATION_Claim::id, AttributeStoreHandle::identity, and AttributeStoreHandle::ns_qe.

Referenced by handle_attestation_store_message().

1208 {
1209  struct AttributeStoreHandle *ash = cls;
1210  char *label;
1211 
1212  // Give the ash a new id if unset
1213  if (0 == ash->attest->id)
1214  ash->attest->id
1217  sizeof(uint64_t));
1219  "Looking up existing data under label %s\n", label);
1220 // Test for the content of the existing ID
1222  &ash->identity,
1223  label,
1224  &attest_error,
1225  ash,
1226  &attest_add_cb,
1227  ash);
1228  GNUNET_free (label);
1229 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
static void attest_error(void *cls)
Error looking up potential attestation.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
Handle for attribute store request.
static void attest_add_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Check for existing record before storing reference.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to store.
#define GNUNET_free(ptr)
Wrapper around free.
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_attestation_store_message()

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

Check an attestation store message.

Parameters
clsunused
samthe message to check

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

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

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 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Use to store an identity attribute.
Definition: reclaim.h:40
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_attestation_store_message()

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

Handle an attestation store message.

Parameters
clsour client
samthe message to handle

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

References AttributeStoreHandle::attest, attest_store_task(), AttributeStoreMessage::attr_len, IdpClient::client, AttributeStoreHandle::client, AttributeStoreHandle::exp, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_ntohll(), GNUNET_RECLAIM_ATTESTATION_deserialize(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), AttributeStoreHandle::identity, AttributeStoreHandle::identity_pkey, AttributeStoreHandle::r_id, GNUNET_TIME_Relative::rel_value_us, IdpClient::store_op_head, and IdpClient::store_op_tail.

1261 {
1262  struct AttributeStoreHandle *ash;
1263  struct IdpClient *idp = cls;
1264  size_t data_len;
1265 
1266  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_STORE message\n");
1267 
1268  data_len = ntohs (sam->attr_len);
1269 
1270  ash = GNUNET_new (struct AttributeStoreHandle);
1271  ash->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &sam[1],
1272  data_len);
1273 
1274  ash->r_id = ntohl (sam->id);
1275  ash->identity = sam->identity;
1276  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1278 
1280  ash->client = idp;
1283 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:65
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct GNUNET_SERVICE_Client * client
The client.
uint32_t r_id
request id
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
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:1280
struct GNUNET_RECLAIM_ATTESTATION_Claim * GNUNET_RECLAIM_ATTESTATION_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:55
struct GNUNET_CRYPTO_EcdsaPublicKey identity_pkey
Identity pubkey.
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:60
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:172
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to store.
static void attest_store_task(void *cls)
Add a new attestation.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
Here is the call graph for this function:

◆ ref_error()

static void ref_error ( void *  cls)
static

Error looking up potential reference value.

Abort.

Parameters
clsour attribute store handle

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

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

Referenced by reference_store_task().

1292 {
1293  struct AttributeStoreHandle *ash = cls;
1295  "Failed to find Attestation entry for Attestation reference\n");
1296  cleanup_as_handle (ash);
1298  return;
1299 }
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
Handle for attribute store request.
#define GNUNET_log(kind,...)
static void do_shutdown(void *cls)
Shutdown task.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ref_del_error()

static void ref_del_error ( void *  cls)
static

Error looking up potential reference value.

Abort.

Parameters
clsour attribute delete handle

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

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

Referenced by handle_reference_delete_message().

1308 {
1309  struct AttributeDeleteHandle *adh = cls;
1311  "Failed to find Attestation entry for Attestation reference\n");
1312  cleanup_adh (adh);
1314  return;
1315 }
Handle for attribute deletion request.
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:1280
#define GNUNET_log(kind,...)
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
static void do_shutdown(void *cls)
Shutdown task.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reference_store_cont()

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

Reference store result handler.

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

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

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

1325 {
1326  struct AttributeStoreHandle *ash = cls;
1327  struct GNUNET_MQ_Envelope *env;
1328  struct SuccessResultMessage *acr_msg;
1329 
1330  ash->ns_qe = NULL;
1332  ash->client->store_op_tail,
1333  ash);
1334 
1335  if (GNUNET_SYSERR == success)
1336  {
1338  "Failed to store reference %s\n",
1339  emsg);
1340  cleanup_as_handle (ash);
1342  return;
1343  }
1344 
1345  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1347  acr_msg->id = htonl (ash->r_id);
1348  acr_msg->op_result = htonl (GNUNET_OK);
1349  GNUNET_MQ_send (ash->client->mq, env);
1350  cleanup_as_handle (ash);
1351 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
uint32_t r_id
request id
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:1280
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
Attribute store/delete response message.
Definition: reclaim.h:103
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_log(kind,...)
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
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:353
static void do_shutdown(void *cls)
Shutdown task.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ref_add_cb()

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

Check for existing record before storing reference.

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

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

References buf, data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, AttributeStoreHandle::exp, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR, GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NAMESTORE_records_store(), GNUNET_OK, GNUNET_RECLAIM_ATTESTATION_REF_deserialize(), GNUNET_RECLAIM_ATTESTATION_REF_serialize(), GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(), AttributeStoreHandle::identity, GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, AttributeStoreHandle::ns_qe, GNUNET_GNSRECORD_Data::record_type, AttributeStoreHandle::reference, reference_store_cont(), GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value, GNUNET_TIME_Relative::rel_value_us, and send_ref_error().

Referenced by reference_store_task().

1369 {
1370  struct AttributeStoreHandle *ash = cls;
1371  char *buf;
1372  size_t buf_size;
1374  buf = GNUNET_malloc (buf_size);
1377  char *data_tmp;
1378  if (0 == rd_count )
1379  {
1381  "Failed to find Attestation entry for Attestation reference\n");
1382  send_ref_error (ash);
1383  return;
1384  }
1385  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
1386  {
1388  "Intended Reference storage location is not an attestation\n");
1389  send_ref_error (ash);
1390  return;
1391  }
1392  struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1];
1393  int i;
1394  for (i = 0; i<rd_count; i++)
1395  {
1396  data_tmp = GNUNET_malloc (rd[i].data_size);
1397  GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
1398  ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, htons (
1399  rd[i].data_size));
1400  rd_new[i] = rd[i];
1401  if ((strcmp (ash->reference->name,ref->name) == 0)&&
1402  (strcmp (ash->reference->reference_value,ref->reference_value)==0) )
1403  {
1405  "Reference already stored\n");
1406  reference_store_cont (ash,GNUNET_OK, NULL);
1407  return;
1408  }
1409  }
1410  rd_new[rd_count].data_size = buf_size;
1411  rd_new[rd_count].data = buf;
1412  rd_new[rd_count].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE;
1413  rd_new[rd_count].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1414  rd_new[rd_count].expiration_time = ash->exp.rel_value_us;
1415  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1417  &ash->identity,
1418  label,
1419  rd_count + 1,
1420  rd_new,
1422  ash);
1423  GNUNET_free (buf);
1424 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
uint64_t rel_value_us
The actual value.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_REF_deserialize(const char *data, size_t data_size)
Deserialize a reference.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * reference_value
The name of the attribute/attestation reference value.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, char *result)
Serialize a reference.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to store.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE
Record type for reclaim identity references.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR
Record type for reclaim identity attestation.
static void send_ref_error(struct AttributeStoreHandle *ash)
Send a reference error response.
Handle for attribute store request.
static char buf[2048]
static void reference_store_cont(void *cls, int32_t success, const char *emsg)
Reference store result handler.
const char * name
The name of the attribute/attestation reference value.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
Get required size for serialization buffer.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
This flag is currently unused; former RF_PENDING flag.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reference_store_task()

static void reference_store_task ( void *  cls)
static

Add a new reference.

Parameters
clsthe AttributeStoreHandle

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

References GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_records_lookup(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id_attest, AttributeStoreHandle::identity, AttributeStoreHandle::ns_qe, ref_add_cb(), ref_error(), and AttributeStoreHandle::reference.

Referenced by handle_reference_store_message().

1433 {
1434  struct AttributeStoreHandle *ash = cls;
1435  char *label;
1436 
1437  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing reference\n");
1438 
1439  // Give the ash a new id if unset
1440  if (0 == ash->reference->id)
1441  {
1442  if (0 == ash->reference->id_attest)
1443  {
1446  UINT64_MAX);
1447  }
1448  else
1449  {
1450  ash->reference->id = ash->reference->id_attest;
1451  }
1452  }
1453 
1455  sizeof(uint64_t));
1457  "Looking up existing data under label %s\n", label);
1458 // Test for the content of the existing ID
1459 
1461  &ash->identity,
1462  label,
1463  &ref_error,
1464  ash,
1465  &ref_add_cb,
1466  ash);
1467  GNUNET_free (label);
1468 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
uint64_t id_attest
Referenced ID of Attestation.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to store.
Handle for attribute store request.
static void ref_add_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Check for existing record before storing reference.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
static void ref_error(void *cls)
Error looking up potential reference value.
#define GNUNET_free(ptr)
Wrapper around free.
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_reference_store_message()

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

Check an attestation reference store message.

Parameters
clsunused
samthe message to check

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

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

1480 {
1481  uint16_t size;
1482 
1483  size = ntohs (sam->header.size);
1484  if (size <= sizeof(struct AttributeStoreMessage))
1485  {
1486  GNUNET_break (0);
1487  return GNUNET_SYSERR;
1488  }
1489  return GNUNET_OK;
1490 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Use to store an identity attribute.
Definition: reclaim.h:40
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_reference_store_message()

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

Handle an attestation reference store message.

Parameters
clsour client
samthe message to handle

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

References AttributeStoreMessage::attr_len, IdpClient::client, AttributeStoreHandle::client, AttributeStoreHandle::exp, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_ntohll(), GNUNET_RECLAIM_ATTESTATION_REF_deserialize(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), AttributeStoreHandle::identity, AttributeStoreHandle::identity_pkey, AttributeStoreHandle::r_id, AttributeStoreHandle::reference, reference_store_task(), GNUNET_TIME_Relative::rel_value_us, IdpClient::store_op_head, and IdpClient::store_op_tail.

1502 {
1503  struct AttributeStoreHandle *ash;
1504  struct IdpClient *idp = cls;
1505  size_t data_len;
1506 
1507  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_STORE message\n");
1508 
1509  data_len = ntohs (sam->attr_len);
1510  ash = GNUNET_new (struct AttributeStoreHandle);
1511  ash->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &sam[1],
1512  data_len);
1513  ash->r_id = ntohl (sam->id);
1514  ash->identity = sam->identity;
1515  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1517 
1518 
1520  ash->client = idp;
1523 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:65
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
static void reference_store_task(void *cls)
Add a new reference.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_REF_deserialize(const char *data, size_t data_size)
Deserialize a reference.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to store.
uint32_t r_id
request id
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
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:1280
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:55
struct GNUNET_CRYPTO_EcdsaPublicKey identity_pkey
Identity pubkey.
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:60
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:172
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
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 1531 of file gnunet-service-reclaim.c.

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 attest_delete_cont(), attr_delete_cont(), reference_delete_cont(), ticket_iter_err(), and update_tickets().

1532 {
1533  struct GNUNET_MQ_Envelope *env;
1534  struct SuccessResultMessage *acr_msg;
1535 
1537  adh->client->delete_op_tail,
1538  adh);
1539 
1540  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1542  acr_msg->id = htonl (adh->r_id);
1543  acr_msg->op_result = htonl (success);
1544  GNUNET_MQ_send (adh->client->mq, env);
1545 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
Attribute store/delete response message.
Definition: reclaim.h:103
struct IdpClient * client
Client connection.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_log(kind,...)
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
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:353
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_iter()

static void ticket_iter ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey 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 1559 of file gnunet-service-reclaim.c.

References AttributeDeleteHandle::attest, AttributeDeleteHandle::claim, TicketRecordsEntry::data, data, TicketRecordsEntry::data_size, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_YES, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTESTATION_Claim::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, TicketRecordsEntry::label, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_it, TicketRecordsEntry::rd_count, AttributeDeleteHandle::reference, AttributeDeleteHandle::tickets_to_update_head, AttributeDeleteHandle::tickets_to_update_tail, and update_tickets().

Referenced by start_ticket_update().

1564 {
1565  struct AttributeDeleteHandle *adh = cls;
1566  struct TicketRecordsEntry *le;
1567  int has_changed = GNUNET_NO;
1568  for (int i = 0; i < rd_count; i++)
1569  {
1570  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1571  continue;
1572  if (adh->claim != NULL)
1573  if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))
1574  continue;
1575  if (adh->attest != NULL)
1576  if (0 != memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))
1577  continue;
1578  if (adh->reference != NULL)
1579  if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t)))
1580  continue;
1582  "Attribute or Attestation/Reference to delete found (%s)\n",
1583  adh->label);
1584  has_changed = GNUNET_YES;
1585  break;
1586  }
1587  if (GNUNET_YES == has_changed)
1588  {
1589  le = GNUNET_new (struct TicketRecordsEntry);
1590  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
1591  le->data = GNUNET_malloc (le->data_size);
1592  le->rd_count = rd_count;
1593  le->label = GNUNET_strdup (label);
1594  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
1597  le);
1598  }
1600 }
Handle for attribute deletion request.
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.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_NO
Definition: gnunet_common.h:86
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
unsigned int rd_count
Record count.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
char * label
Attribute label.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to delete.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:85
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to delete.
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 1636 of file gnunet-service-reclaim.c.

References AttributeDeleteHandle::attest, AttributeDeleteHandle::claim, cleanup_adh(), data, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_OK, GNUNET_SYSERR, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTESTATION_Claim::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, AttributeDeleteHandle::identity, TicketRecordsEntry::label, AttributeDeleteHandle::ns_qe, GNUNET_GNSRECORD_Data::record_type, AttributeDeleteHandle::reference, send_delete_response(), ticket_updated(), AttributeDeleteHandle::tickets_to_update_head, and AttributeDeleteHandle::tickets_to_update_tail.

Referenced by ticket_iter(), ticket_iter_fin(), and ticket_updated().

1637 {
1638  struct AttributeDeleteHandle *adh = cls;
1639  struct TicketRecordsEntry *le;
1640 
1641  if (NULL == adh->tickets_to_update_head)
1642  {
1644  "Finished updating tickets, success\n");
1646  cleanup_adh (adh);
1647  return;
1648  }
1650  "Updating %s\n",
1652  le = adh->tickets_to_update_head;
1655  le);
1656  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1657  struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1659  le->data,
1660  le->rd_count,
1661  rd))
1662  {
1664  "Unable to deserialize record data!\n");
1666  cleanup_adh (adh);
1667  return;
1668  }
1669  int j = 0;
1670  for (int i = 0; i < le->rd_count; i++)
1671  {
1672  if (adh->claim != NULL)
1674  && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))))
1675  continue;
1676  if (adh->attest != NULL)
1677  if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
1678  && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t))))
1679  continue;
1680  if (adh->reference != NULL)
1681  if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
1682  && (0 == memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t))))
1683  continue;
1684  rd_new[j] = rd[i];
1685  j++;
1686  }
1688  &adh->identity,
1689  le->label,
1690  j,
1691  rd_new,
1692  &ticket_updated,
1693  adh);
1694  GNUNET_free (le->label);
1695  GNUNET_free (le->data);
1696  GNUNET_free (le);
1697 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle for attribute deletion request.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
unsigned int rd_count
Record count.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static void ticket_updated(void *cls, int32_t success, const char *emsg)
Callback called when a ticket was updated.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to delete.
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to delete.
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 1619 of file gnunet-service-reclaim.c.

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

Referenced by update_tickets().

1620 {
1621  struct AttributeDeleteHandle *adh = cls;
1622 
1623  adh->ns_qe = NULL;
1625 }
Handle for attribute deletion request.
static void update_tickets(void *cls)
Recursion prototype for function.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_iter_fin()

static void ticket_iter_fin ( void *  cls)
static

Done collecting affected tickets, start updating.

Parameters
clsour attribute deletion handle

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

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

Referenced by start_ticket_update().

1707 {
1708  struct AttributeDeleteHandle *adh = cls;
1709  adh->ns_it = NULL;
1711 }
Handle for attribute deletion request.
static void update_tickets(void *cls)
Recursion prototype for function.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
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:1280
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_iter_err()

static void ticket_iter_err ( void *  cls)
static

Error collecting affected tickets.

Abort.

Parameters
clsour attribute deletion handle

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

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

Referenced by start_ticket_update().

1721 {
1722  struct AttributeDeleteHandle *adh = cls;
1723 
1724  adh->ns_it = NULL;
1726  "Namestore error on delete %s\n",
1727  adh->label);
1729  cleanup_adh (adh);
1730 }
Handle for attribute deletion request.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
char * label
Attribute label.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
#define GNUNET_log(kind,...)
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_ticket_update()

static void start_ticket_update ( void *  cls)
static

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

Parameters
clsattribute deletion handle

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

References GNUNET_NAMESTORE_zone_iteration_start(), AttributeDeleteHandle::identity, AttributeDeleteHandle::ns_it, ticket_iter(), ticket_iter_err(), and ticket_iter_fin().

Referenced by attest_delete_cont(), and attr_delete_cont().

1741 {
1742  struct AttributeDeleteHandle *adh = cls;
1743 
1745  &adh->identity,
1746  &ticket_iter_err,
1747  adh,
1748  &ticket_iter,
1749  adh,
1750  &ticket_iter_fin,
1751  adh);
1752 }
Handle for attribute deletion request.
static void ticket_iter_err(void *cls)
Error collecting affected tickets.
static void ticket_iter(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Namestore iteration within attribute deletion.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
static void ticket_iter_fin(void *cls)
Done collecting affected tickets, start updating.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
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 1763 of file gnunet-service-reclaim.c.

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

Referenced by handle_attribute_delete_message().

1764 {
1765  struct AttributeDeleteHandle *adh = cls;
1766 
1767  adh->ns_qe = NULL;
1768  if (GNUNET_SYSERR == success)
1769  {
1771  "Error deleting attribute %s\n",
1772  adh->label);
1774  cleanup_adh (adh);
1775  return;
1776  }
1777  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1779 }
Handle for attribute deletion request.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion 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:1280
static void start_ticket_update(void *cls)
Start processing tickets which may still contain reference to deleted attribute.
char * label
Attribute label.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
#define GNUNET_log(kind,...)
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
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.

unused message to check

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

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

1791 {
1792  uint16_t size;
1793 
1794  size = ntohs (dam->header.size);
1795  if (size <= sizeof(struct AttributeDeleteMessage))
1796  {
1797  GNUNET_break (0);
1798  return GNUNET_SYSERR;
1799  }
1800  return GNUNET_OK;
1801 }
Use to delete an identity attribute.
Definition: reclaim.h:74
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:79
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ 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 1811 of file gnunet-service-reclaim.c.

References AttributeDeleteHandle::attest, attr_delete_cont(), AttributeDeleteMessage::attr_len, AttributeDeleteHandle::claim, IdpClient::client, AttributeDeleteHandle::client, IdpClient::delete_op_head, IdpClient::delete_op_tail, 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_Claim::id, AttributeDeleteHandle::identity, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, AttributeDeleteHandle::r_id, and AttributeDeleteHandle::reference.

1813 {
1814  struct AttributeDeleteHandle *adh;
1815  struct IdpClient *idp = cls;
1816  size_t data_len;
1817 
1818  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1819 
1820  data_len = ntohs (dam->attr_len);
1821 
1822  adh = GNUNET_new (struct AttributeDeleteHandle);
1823  adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1],
1824  data_len);
1825  adh->reference = NULL;
1826  adh->attest = NULL;
1827 
1828  adh->r_id = ntohl (dam->id);
1829  adh->identity = dam->identity;
1830  adh->label
1831  = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof(uint64_t));
1833  adh->client = idp;
1836  &adh->identity,
1837  adh->label,
1838  0,
1839  NULL,
1841  adh);
1842 }
Handle for attribute deletion request.
static void attr_delete_cont(void *cls, int32_t success, const char *emsg)
Attribute deleted callback.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:94
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
char * label
Attribute label.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84
struct IdpClient * client
Client connection.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to delete.
#define GNUNET_log(kind,...)
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to delete.
Here is the call graph for this function:

◆ attest_delete_cont()

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

Attestation deleted callback.

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

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

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

Referenced by handle_attestation_delete_message().

1853 {
1854  struct AttributeDeleteHandle *adh = cls;
1855 
1856  adh->ns_qe = NULL;
1857  if (GNUNET_SYSERR == success)
1858  {
1860  "Error deleting attestation %s\n",
1861  adh->label);
1863  cleanup_adh (adh);
1864  return;
1865  }
1866  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1868 }
Handle for attribute deletion request.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion 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:1280
static void start_ticket_update(void *cls)
Start processing tickets which may still contain reference to deleted attribute.
char * label
Attribute label.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
#define GNUNET_log(kind,...)
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_attestation_delete_message()

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

Check attestation delete message format.

unused message to check

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

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

1879 {
1880  uint16_t size;
1881 
1882  size = ntohs (dam->header.size);
1883  if (size <= sizeof(struct AttributeDeleteMessage))
1884  {
1885  GNUNET_break (0);
1886  return GNUNET_SYSERR;
1887  }
1888  return GNUNET_OK;
1889 }
Use to delete an identity attribute.
Definition: reclaim.h:74
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:79
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_attestation_delete_message()

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

Handle attestation deletion.

Parameters
clsour client
damdeletion message

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

References AttributeDeleteHandle::attest, attest_delete_cont(), AttributeDeleteMessage::attr_len, AttributeDeleteHandle::claim, IdpClient::client, AttributeDeleteHandle::client, IdpClient::delete_op_head, IdpClient::delete_op_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_new, GNUNET_RECLAIM_ATTESTATION_deserialize(), GNUNET_SERVICE_client_continue(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTESTATION_Claim::id, AttributeDeleteHandle::identity, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, AttributeDeleteHandle::r_id, and AttributeDeleteHandle::reference.

1901 {
1902  struct AttributeDeleteHandle *adh;
1903  struct IdpClient *idp = cls;
1904  size_t data_len;
1905 
1906  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_DELETE message\n");
1907 
1908  data_len = ntohs (dam->attr_len);
1909 
1910  adh = GNUNET_new (struct AttributeDeleteHandle);
1911  adh->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &dam[1],
1912  data_len);
1913  adh->reference = NULL;
1914  adh->claim = NULL;
1915 
1916  adh->r_id = ntohl (dam->id);
1917  adh->identity = dam->identity;
1918  adh->label
1919  = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, sizeof(uint64_t));
1921  adh->client = idp;
1924  &adh->identity,
1925  adh->label,
1926  0,
1927  NULL,
1929  adh);
1930 }
Handle for attribute deletion request.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:94
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
static void attest_delete_cont(void *cls, int32_t success, const char *emsg)
Attestation deleted callback.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_RECLAIM_ATTESTATION_Claim * GNUNET_RECLAIM_ATTESTATION_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
char * label
Attribute label.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84
struct IdpClient * client
Client connection.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to delete.
#define GNUNET_log(kind,...)
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to delete.
Here is the call graph for this function:

◆ reference_delete_cont()

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

Reference deleted callback.

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

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

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

Referenced by ref_del_cb().

1943 {
1944  struct AttributeDeleteHandle *adh = cls;
1945 
1946  adh->ns_qe = NULL;
1947  if (GNUNET_SYSERR == success)
1948  {
1950  "Error deleting reference %s\n",
1951  adh->label);
1953  cleanup_adh (adh);
1954  return;
1955  }
1956  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1957  //GNUNET_SCHEDULER_add_now (&start_ticket_update, adh);
1959  cleanup_adh (adh);
1960  return;
1961 }
Handle for attribute deletion request.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
char * label
Attribute label.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
#define GNUNET_log(kind,...)
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ref_del_cb()

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

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

References cleanup_adh(), data, data_size, do_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_ATTESTATION_REF_deserialize(), GNUNET_SCHEDULER_add_now(), AttributeDeleteHandle::identity, GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, AttributeDeleteHandle::ns_qe, AttributeDeleteHandle::reference, reference_delete_cont(), and GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value.

Referenced by handle_reference_delete_message().

1969 {
1970 
1971  struct AttributeDeleteHandle *adh = cls;
1972  char *data_tmp;
1973  struct GNUNET_GNSRECORD_Data rd_new[rd_count - 1];
1975  size_t attr_len;
1976 
1977  if (0 == rd_count )
1978  {
1980  "Failed to find Attestation entry for Attestation reference\n");
1981  cleanup_adh (adh);
1983  return;
1984  }
1985  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
1986  {
1988  "Intended Reference location is not an attestation\n");
1989  cleanup_adh (adh);
1991  return;
1992  }
1993  rd_new[0] = rd[0];
1994  int i;
1995  int j = 1;
1996  for (i = 1; i<rd_count; i++)
1997  {
1998  data_tmp = GNUNET_malloc (rd[i].data_size);
1999  GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2000  attr_len = htons (rd[i].data_size);
2001  ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, attr_len);
2002  if (NULL == ref )
2003  {
2005  "Unable to parse attestation reference from %s\n",
2006  data_tmp);
2007  rd_new[j] = rd[i];
2008  j += 1;
2009  continue;
2010  }
2011  if ((strcmp (adh->reference->name,ref->name) == 0)&&
2012  (strcmp (adh->reference->reference_value,ref->reference_value)==0) )
2013  {
2015  "Found reference to delete.\n");
2016  }
2017  else
2018  {
2019  rd_new[j] = rd[i];
2020  j += 1;
2021  }
2022  GNUNET_free (data_tmp);
2023  }
2025  &adh->identity,
2026  label,
2027  j,
2028  rd_new,
2030  adh);
2031 }
Handle for attribute deletion request.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_REF_deserialize(const char *data, size_t data_size)
Deserialize a reference.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * reference_value
The name of the attribute/attestation reference value.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
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:1280
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR
Record type for reclaim identity attestation.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to delete.
const char * name
The name of the attribute/attestation reference value.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
static void do_shutdown(void *cls)
Shutdown task.
uint32_t data
The data value.
static void reference_delete_cont(void *cls, int32_t success, const char *emsg)
Reference deleted callback.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_reference_delete_message()

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

Check an attestation reference delete message.

Parameters
clsunused
samthe message to check

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

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

2042 {
2043  uint16_t size;
2044 
2045  size = ntohs (dam->header.size);
2046  if (size <= sizeof(struct AttributeDeleteMessage))
2047  {
2048  GNUNET_break (0);
2049  return GNUNET_SYSERR;
2050  }
2051  return GNUNET_OK;
2052 }
Use to delete an identity attribute.
Definition: reclaim.h:74
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:79
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_reference_delete_message()

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

Handle reference deletion.

Parameters
clsour client
damdeletion message

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

References AttributeDeleteHandle::attest, AttributeDeleteMessage::attr_len, AttributeDeleteHandle::claim, IdpClient::client, AttributeDeleteHandle::client, IdpClient::delete_op_head, IdpClient::delete_op_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_records_lookup(), GNUNET_new, GNUNET_RECLAIM_ATTESTATION_REF_deserialize(), GNUNET_SERVICE_client_continue(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, AttributeDeleteHandle::identity, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, AttributeDeleteHandle::r_id, ref_del_cb(), ref_del_error(), and AttributeDeleteHandle::reference.

2063 {
2064  struct AttributeDeleteHandle *adh;
2065  struct IdpClient *idp = cls;
2066  size_t data_len;
2067 
2068  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_DELETE message\n");
2069  data_len = ntohs (dam->attr_len);
2070  adh = GNUNET_new (struct AttributeDeleteHandle);
2071  adh->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &dam[1],
2072  data_len);
2073  adh->attest = NULL;
2074  adh->claim = NULL;
2075 
2076  adh->r_id = ntohl (dam->id);
2077  adh->identity = dam->identity;
2078  adh->label
2080  sizeof(uint64_t));
2082  adh->client = idp;
2085  &adh->identity,
2086  adh->label,
2087  &ref_del_error,
2088  adh,
2089  &ref_del_cb,
2090  adh);
2091 }
Handle for attribute deletion request.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:94
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_REF_deserialize(const char *data, size_t data_size)
Deserialize a reference.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
struct GNUNET_SERVICE_Client * client
The client.
static void ref_del_error(void *cls)
Error looking up potential reference value.
char * label
Attribute label.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84
struct IdpClient * client
Client connection.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference to delete.
static void ref_del_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
#define GNUNET_log(kind,...)
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation to delete.
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 2106 of file gnunet-service-reclaim.c.

References ai, IdpClient::attr_iter_head, IdpClient::attr_iter_tail, AttributeResultMessage::attr_len, AttributeIterator::client, 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(), AttributeResultMessage::id, IdpClient::mq, and AttributeIterator::request_id.

Referenced by attr_iter_error(), and handle_iteration_start().

2107 {
2108  struct AttributeIterator *ai = cls;
2109  struct GNUNET_MQ_Envelope *env;
2110  struct AttributeResultMessage *arm;
2111 
2112  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
2114  arm->id = htonl (ai->request_id);
2115  arm->attr_len = htons (0);
2116  GNUNET_MQ_send (ai->client->mq, env);
2118  ai->client->attr_iter_tail,
2119  ai);
2120  GNUNET_free (ai);
2121 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
#define GNUNET_log(kind,...)
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
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:353
struct IdpClient * client
IDP client which intiated this zone iteration.
An attribute iteration operation.
#define GNUNET_free(ptr)
Wrapper around free.
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 2130 of file gnunet-service-reclaim.c.

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

Referenced by handle_iteration_start().

2131 {
2132  struct AttributeIterator *ai = cls;
2133 
2134  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
2135  attr_iter_finished (ai);
2136 }
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
static void attr_iter_finished(void *cls)
Done iterating over attributes.
An attribute iteration operation.
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_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Got record.

Return if it is an attribute or attestation/reference.

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

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

References ai, ReferenceResultMessage::attest_len, AttributeResultMessage::attr_len, AttributeIterator::client, data, data_size, GNUNET_GNSRECORD_Data::data_size, env, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAMESTORE_zone_iterator_next(), AttributeResultMessage::id, ReferenceResultMessage::id, AttributeResultMessage::identity, ReferenceResultMessage::identity, IdpClient::mq, AttributeIterator::ns_it, ReferenceResultMessage::ref_len, and AttributeIterator::request_id.

Referenced by handle_iteration_start().

2154 {
2155  struct AttributeIterator *ai = cls;
2156  struct GNUNET_MQ_Envelope *env;
2157  char *data_tmp;
2158 
2159  if (rd_count == 0)
2160  {
2162  return;
2163  }
2164  if (rd_count > 1)
2165  {
2166  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[0].record_type)
2167  {
2169  "Found Ticket. Ignoring.\n");
2171  return;
2172  }
2173  else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
2174  {
2176  "Non-Attestation record with multiple entries found: %u\n",
2177  rd[0].record_type);
2179  return;
2180  }
2181  }
2182 
2183  for (int i = 0; i<rd_count; i++)
2184  {
2185  if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd[i].record_type) &&
2186  (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) &&
2187  (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE != rd[i].record_type))
2188  {
2190  return;
2191  }
2192 
2193  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type )
2194  {
2195  struct AttributeResultMessage *arm;
2196  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
2197  label);
2199  "Sending ATTRIBUTE_RESULT message\n");
2200  env = GNUNET_MQ_msg_extra (arm,
2201  rd[i].data_size,
2203  arm->id = htonl (ai->request_id);
2204  arm->attr_len = htons (rd[i].data_size);
2206  data_tmp = (char *) &arm[1];
2207  GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2208  GNUNET_MQ_send (ai->client->mq, env);
2209  }
2210  else
2211  {
2212  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type )
2213  {
2214  struct AttributeResultMessage *arm;
2215  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
2216  label);
2218  "Sending ATTESTATION_RESULT message\n");
2219  env = GNUNET_MQ_msg_extra (arm,
2220  rd[i].data_size,
2222  arm->id = htonl (ai->request_id);
2223  arm->attr_len = htons (rd[i].data_size);
2225  data_tmp = (char *) &arm[1];
2226  GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2227  GNUNET_MQ_send (ai->client->mq, env);
2228  }
2229  else
2230  {
2231  struct ReferenceResultMessage *rrm;
2232  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n",
2233  label);
2235  "Sending REFERENCE_RESULT message\n");
2236  env = GNUNET_MQ_msg_extra (rrm,
2237  rd[i].data_size + rd[0].data_size,
2239  rrm->id = htonl (ai->request_id);
2240  rrm->attest_len = htons (rd[0].data_size);
2241  rrm->ref_len = htons (rd[i].data_size);
2243  data_tmp = (char *) &rrm[1];
2244  GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size);
2245  data_tmp += rd[0].data_size;
2246  GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
2247  GNUNET_MQ_send (ai->client->mq, env);
2248  }
2249  }
2250  }
2251 }
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
Reference plus Attestation is returned from the idp.
Definition: reclaim.h:159
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
size_t data_size
Number of bytes in data.
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_MQ_Handle * mq
Message queue for transmission to client.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE
Record type for reclaim identity references.
#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_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR
Record type for reclaim identity attestation.
uint16_t ref_len
Length of serialized reference data.
Definition: reclaim.h:179
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:189
#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:172
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint16_t attest_len
Length of serialized attestation data.
Definition: reclaim.h:174
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
#define GNUNET_log(kind,...)
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:149
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:353
struct IdpClient * client
IDP client which intiated this zone iteration.
uint32_t data
The data value.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:169
An attribute iteration operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
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 2260 of file gnunet-service-reclaim.c.

References ai, attr_iter_cb(), attr_iter_error(), attr_iter_finished(), IdpClient::attr_iter_head, IdpClient::attr_iter_tail, AttributeIterator::client, IdpClient::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_new, GNUNET_SERVICE_client_continue(), AttributeIterationStartMessage::id, AttributeIterator::identity, AttributeIterationStartMessage::identity, AttributeIterator::ns_it, and AttributeIterator::request_id.

2262 {
2263  struct IdpClient *idp = cls;
2264  struct AttributeIterator *ai;
2265 
2267  "Received ATTRIBUTE_ITERATION_START message\n");
2268  ai = GNUNET_new (struct AttributeIterator);
2269  ai->request_id = ntohl (ais_msg->id);
2270  ai->client = idp;
2271  ai->identity = ais_msg->identity;
2272 
2275  &ai->identity,
2276  &attr_iter_error,
2277  ai,
2278  &attr_iter_cb,
2279  ai,
2281  ai);
2283 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
static void attr_iter_error(void *cls)
Error iterating over attributes.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Key of the zone we are iterating over.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:214
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:209
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
static void attr_iter_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
static void attr_iter_finished(void *cls)
Done iterating over attributes.
struct IdpClient * client
IDP client which intiated this zone iteration.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
An attribute iteration operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
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 2293 of file gnunet-service-reclaim.c.

References ai, IdpClient::attr_iter_head, IdpClient::attr_iter_tail, IdpClient::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, AttributeIterator::next, and AttributeIterator::request_id.

2295 {
2296  struct IdpClient *idp = cls;
2297  struct AttributeIterator *ai;
2298  uint32_t rid;
2299 
2301  "Received `%s' message\n",
2302  "ATTRIBUTE_ITERATION_STOP");
2303  rid = ntohl (ais_msg->id);
2304  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2305  if (ai->request_id == rid)
2306  break;
2307  if (NULL == ai)
2308  {
2309  GNUNET_break (0);
2311  return;
2312  }
2314  GNUNET_free (ai);
2316 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
An idp client.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SERVICE_Client * client
The client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:248
struct AttributeIterator * next
Next element in the DLL.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
An attribute iteration operation.
#define GNUNET_free(ptr)
Wrapper around free.
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 2326 of file gnunet-service-reclaim.c.

References ai, IdpClient::attr_iter_head, IdpClient::client, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), AttributeIterationNextMessage::id, AttributeIterator::next, AttributeIterator::ns_it, and AttributeIterator::request_id.

2328 {
2329  struct IdpClient *idp = cls;
2330  struct AttributeIterator *ai;
2331  uint32_t rid;
2332 
2334  "Received ATTRIBUTE_ITERATION_NEXT message\n");
2335  rid = ntohl (ais_msg->id);
2336  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2337  if (ai->request_id == rid)
2338  break;
2339  if (NULL == ai)
2340  {
2341  GNUNET_break (0);
2343  return;
2344  }
2347 }
An idp client.
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...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SERVICE_Client * client
The client.
struct AttributeIterator * next
Next element in the DLL.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:231
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
An attribute iteration operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
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 2361 of file gnunet-service-reclaim.c.

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

2362 {
2363  struct TicketIteration *ti = cls;
2364  struct GNUNET_MQ_Envelope *env;
2365  struct TicketResultMessage *trm;
2366 
2368  if (NULL == ticket)
2369  {
2370  /* send empty response to indicate end of list */
2372  ti->client->ticket_iter_tail,
2373  ti);
2374  }
2375  else
2376  {
2377  trm->ticket = *ticket;
2378  }
2379  trm->id = htonl (ti->r_id);
2380  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2381  GNUNET_MQ_send (ti->client->mq, env);
2382  if (NULL == ticket)
2383  GNUNET_free (ti);
2384 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:406
Ticket result message.
Definition: reclaim.h:396
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:411
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint32_t r_id
The operation id fot the iteration in the response for the client.
struct IdpClient * client
Client which intiated this zone iteration.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
A ticket iteration operation.
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
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:353
#define GNUNET_free(ptr)
Wrapper around free.
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 2394 of file gnunet-service-reclaim.c.

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.

2397 {
2398  struct IdpClient *client = cls;
2399  struct TicketIteration *ti;
2400 
2402  "Received TICKET_ITERATION_START message\n");
2403  ti = GNUNET_new (struct TicketIteration);
2404  ti->r_id = ntohl (tis_msg->id);
2405  ti->client = client;
2406 
2408  client->ticket_iter_tail,
2409  ti);
2410  ti->iter
2413 }
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:269
An idp client.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t r_id
The operation id fot the iteration in the response for the client.
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
struct IdpClient * client
Client which intiated this zone iteration.
struct GNUNET_SERVICE_Client * client
The client.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
A ticket iteration operation.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:264
#define GNUNET_log(kind,...)
static void ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Got a ticket.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
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 2423 of file gnunet-service-reclaim.c.

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.

2425 {
2426  struct IdpClient *client = cls;
2427  struct TicketIteration *ti;
2428  uint32_t rid;
2429 
2431  "Received `%s' message\n",
2432  "TICKET_ITERATION_STOP");
2433  rid = ntohl (tis_msg->id);
2434  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2435  if (ti->r_id == rid)
2436  break;
2437  if (NULL == ti)
2438  {
2439  GNUNET_break (0);
2441  return;
2442  }
2445  client->ticket_iter_tail,
2446  ti);
2447  GNUNET_free (ti);
2449 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
An idp client.
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
uint32_t r_id
The operation id fot the iteration in the response for the client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SERVICE_Client * client
The client.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
struct TicketIteration * next
DLL.
A ticket iteration operation.
#define GNUNET_log(kind,...)
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:303
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
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 2459 of file gnunet-service-reclaim.c.

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.

2461 {
2462  struct IdpClient *client = cls;
2463  struct TicketIteration *ti;
2464  uint32_t rid;
2465 
2467  "Received TICKET_ITERATION_NEXT message\n");
2468  rid = ntohl (tis_msg->id);
2469  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2470  if (ti->r_id == rid)
2471  break;
2472  if (NULL == ti)
2473  {
2474  GNUNET_break (0);
2476  return;
2477  }
2480 }
An idp client.