GNUnet 0.21.1
gnunet-service-reclaim.c File Reference
Include dependency graph for gnunet-service-reclaim.c:

Go to the source code of this file.

Data Structures

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

Functions

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

Function Documentation

◆ cleanup_adh()

static void cleanup_adh ( struct AttributeDeleteHandle adh)
static

Cleanup attribute delete handle.

Parameters
adhthe attribute to cleanup

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

487{
488 struct TicketRecordsEntry *le;
489
490 if (NULL != adh->ns_it)
492 if (NULL != adh->ns_qe)
494 if (NULL != adh->label)
495 GNUNET_free (adh->label);
496 if (NULL != adh->claim)
497 GNUNET_free (adh->claim);
498 if (NULL != adh->credential)
499 GNUNET_free (adh->credential);
500 if (NULL != adh->existing_credentials)
502 if (NULL != adh->existing_attributes)
504 while (NULL != (le = adh->tickets_to_update_head))
505 {
508 le);
509 if (NULL != le->label)
510 GNUNET_free (le->label);
511 if (NULL != le->data)
512 GNUNET_free (le->data);
513 GNUNET_free (le);
514 }
515 GNUNET_free (adh);
516}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
void GNUNET_RECLAIM_credential_list_destroy(struct GNUNET_RECLAIM_CredentialList *credentials)
Destroy credential list.
struct GNUNET_RECLAIM_CredentialList * existing_credentials
Existing credentials.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct GNUNET_RECLAIM_Attribute * claim
The attribute to delete.
char * label
Attribute label.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
struct GNUNET_RECLAIM_AttributeList * existing_attributes
Existing attributes.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
struct GNUNET_RECLAIM_Credential * credential
The credential to delete.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.

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

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

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

◆ cleanup_as_handle()

static void cleanup_as_handle ( struct AttributeStoreHandle ash)
static

Cleanup attribute store handle.

Parameters
ashhandle to clean up

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

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

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

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

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

◆ cleanup_client()

static void cleanup_client ( struct IdpClient idp)
static

Cleanup client.

Parameters
idpthe client to clean up

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

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

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

Referenced by client_disconnect_cb().

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

◆ cleanup()

static void cleanup ( )
static

Cleanup task.

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

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

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

Referenced by do_shutdown().

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

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Shutdown task.

Parameters
clsNULL

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

633{
634 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
635 cleanup ();
636}
static void cleanup()
Cleanup task.
@ GNUNET_ERROR_TYPE_INFO

References cleanup(), GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

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

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

◆ send_ticket_result()

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

Sends a ticket result message to the client.

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

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

653{
654 struct TicketResultMessage *irm;
655 struct GNUNET_MQ_Envelope *env;
656 size_t pres_len = 0;
657 size_t tkt_len = 0;
658 char *buf;
659
660 if (NULL != presentations)
661 {
662 pres_len =
664 }
665 if (NULL != ticket)
666 tkt_len = strlen (ticket->gns_name) + 1;
668 pres_len + tkt_len,
670 buf = (char*) &irm[1];
671 if (NULL != ticket)
672 {
673 memcpy (buf, ticket, tkt_len);
674 buf += tkt_len;
675 }
676 // TODO add success member
677 irm->id = htonl (r_id);
678 irm->tkt_len = htons (tkt_len);
679 irm->rp_uri_len = htons (0);
680 irm->presentations_len = htons (pres_len);
681 if (NULL != presentations)
682 {
684 buf);
685 }
686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
687 GNUNET_MQ_send (client->mq, env);
688}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#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:63
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
size_t GNUNET_RECLAIM_presentation_list_serialize(const struct GNUNET_RECLAIM_PresentationList *presentations, char *result)
Serialize a presentation list.
size_t GNUNET_RECLAIM_presentation_list_serialize_get_size(const struct GNUNET_RECLAIM_PresentationList *presentations)
Get required size for serialization buffer.
char gns_name[63 *2+2]
The ticket.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
Ticket result message.
Definition: reclaim.h:492
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:501
uint16_t presentations_len
Length of new presentations created.
Definition: reclaim.h:516
uint16_t tkt_len
Ticket length.
Definition: reclaim.h:506
uint16_t rp_uri_len
RP URI length.
Definition: reclaim.h:511

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

Referenced by issue_ticket_result_cb().

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

◆ issue_ticket_result_cb()

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

Issue ticket result.

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

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

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

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

Referenced by handle_issue_ticket_message().

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

◆ check_issue_ticket_message()

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

Check issue ticket message.

Parameters
clsunused
immessage to check
Returns
GNUNET_OK if message is ok

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

737{
738 uint16_t size;
739 size_t attrs_len;
740 size_t key_len;
741 size_t rp_len;
742
743 size = ntohs (im->header.size);
744 attrs_len = ntohs (im->attr_len);
745 key_len = ntohs (im->key_len);
746 rp_len = ntohs (im->rp_uri_len);
747 if (size != attrs_len + key_len + rp_len + sizeof(struct
749 {
750 GNUNET_break (0);
751 return GNUNET_SYSERR;
752 }
753 return GNUNET_OK;
754}
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.
static unsigned int size
Size of the "table".
Definition: peer.c:68
Ticket issue message.
Definition: reclaim.h:396
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET.
Definition: reclaim.h:400
uint16_t rp_uri_len
The length of the relying party URI.
Definition: reclaim.h:425
uint16_t key_len
The length of the identity private key.
Definition: reclaim.h:420
uint16_t attr_len
length of serialized attribute list
Definition: reclaim.h:415

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

◆ handle_issue_ticket_message()

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

Handle ticket issue message.

Parameters
clsour client
imthe message

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

765{
767 struct IdpClient *idp = cls;
768 struct GNUNET_RECLAIM_AttributeList *attrs;
771 const char *rp;
772 size_t attrs_len;
773 size_t key_len;
774 size_t rp_len;
775 size_t read;
776 char *buf;
777
778 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
779 key_len = ntohs (im->key_len);
780 buf = (char *) &im[1];
781 if ((GNUNET_SYSERR ==
783 &identity, &read)) ||
784 (read != key_len))
785 {
787 "Failed to read private key\n");
789 return;
790 }
791 buf += read;
792 rp_len = ntohs (im->rp_uri_len);
793 rp = buf;
794 buf += rp_len;
796 attrs_len = ntohs (im->attr_len);
798 attrs_len);
799 for (le = attrs->list_head; NULL != le; le = le->next)
801 "List entry: %s\n", le->attribute->name);
802
803 tio->r_id = ntohl (im->id);
804 tio->client = idp;
805 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
807 attrs,
808 rp,
810 tio);
813}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static char * rp
Relying party.
static void issue_ticket_result_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Issue ticket result.
void RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_PrivateKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const char *rp, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes...
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer.
Definition: crypto_pkey.c:163
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2484
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2455
A private key for an identity as per LSD0001.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
const char * name
The name of the attribute.
struct GNUNET_CLIENT_Connection * client
Socket (if available).
Definition: reclaim_api.c:325
An idp client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:405

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

Here is the call graph for this function:

◆ revoke_result_cb()

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

Handles revocation result.

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

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

828{
829 struct TicketRevocationOperation *rop = cls;
830 struct GNUNET_MQ_Envelope *env;
831 struct RevokeTicketResultMessage *trm;
832
834 "Sending REVOKE_TICKET_RESULT message\n");
835 rop->rh = NULL;
837 trm->id = htonl (rop->r_id);
838 trm->success = htonl (success);
839 GNUNET_MQ_send (rop->client->mq, env);
842 rop);
843 GNUNET_free (rop);
844}
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
Ticket revoke message.
Definition: reclaim.h:470
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:479
uint32_t success
Revocation result.
Definition: reclaim.h:484
struct IdpClient * client
Client connection.

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

Referenced by handle_revoke_ticket_message().

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

◆ check_revoke_ticket_message()

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

Check revocation message format.

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

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

856{
857 uint16_t size;
858 size_t key_len;
859 size_t tkt_len;
860
861 size = ntohs (rm->header.size);
862 key_len = ntohs (rm->key_len);
863 tkt_len = ntohs (rm->tkt_len);
864
865 if (size != sizeof(struct RevokeTicketMessage) + key_len + tkt_len)
866 {
867 GNUNET_break (0);
868 return GNUNET_SYSERR;
869 }
870 return GNUNET_OK;
871}
Ticket revoke message.
Definition: reclaim.h:438
uint16_t key_len
The length of the private key.
Definition: reclaim.h:452
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:457
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET.
Definition: reclaim.h:442

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

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

882{
883 struct TicketRevocationOperation *rop;
884 struct IdpClient *idp = cls;
887 size_t key_len;
888 size_t read;
889 char *buf;
890
891 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
892 key_len = ntohs (rm->key_len);
893 buf = (char *) &rm[1];
894 if ((GNUNET_SYSERR ==
896 &identity, &read)) ||
897 (read != key_len))
898 {
900 "Failed to read private key\n");
902 return;
903 }
904 buf += read;
905 ticket = (struct GNUNET_RECLAIM_Ticket *) buf;
907 rop->r_id = ntohl (rm->id);
908 rop->client = idp;
909 GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
910 rop->rh
913}
static void revoke_result_cb(void *cls, int32_t success)
Handles revocation result.
struct RECLAIM_TICKETS_RevokeHandle * RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_CRYPTO_PrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
Revoke a ticket.
The authorization ticket.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:447

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

Here is the call graph for this function:

◆ consume_result_cb()

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

Handle a ticket consume result.

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

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

932{
933 struct ConsumeTicketOperation *cop = cls;
934 struct ConsumeTicketResultMessage *crm;
935 struct GNUNET_MQ_Envelope *env;
936 char *data_tmp;
937 size_t attrs_len = 0;
938 size_t pres_len = 0;
939 size_t key_len;
940 ssize_t written;
941
942 if (GNUNET_OK != success)
943 {
944 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
945 }
948 presentations);
951 "Sending CONSUME_TICKET_RESULT message\n");
953 attrs_len + pres_len + key_len,
955 crm->id = htonl (cop->r_id);
956 crm->attrs_len = htons (attrs_len);
957 crm->presentations_len = htons (pres_len);
958 crm->key_len = htons (key_len);
959 crm->result = htons (success);
960 data_tmp = (char *) &crm[1];
962 data_tmp,
963 key_len);
964 GNUNET_assert (0 <= written);
965 data_tmp += written;
967 data_tmp += attrs_len;
968 GNUNET_RECLAIM_presentation_list_serialize (presentations, data_tmp);
969 GNUNET_MQ_send (cop->client->mq, env);
972 cop);
973 GNUNET_free (cop);
974}
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:85
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer(const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PublicKey to a compact buffer.
Definition: crypto_pkey.c:145
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size(const struct GNUNET_RECLAIM_AttributeList *attrs)
Get required size for serialization buffer.
struct IdpClient * client
Client connection.
Attribute list is returned from the idp.
Definition: reclaim.h:560
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:584
uint16_t presentations_len
Length of presentation data.
Definition: reclaim.h:589
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:569
uint16_t key_len
The length of the identity public key.
Definition: reclaim.h:594
uint32_t result
Result.
Definition: reclaim.h:574
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.

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

Referenced by handle_consume_ticket_message().

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

◆ check_consume_ticket_message()

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

Check a consume ticket message.

Parameters
clsunused
cmthe message to handle

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

985{
986 uint16_t size;
987 uint16_t tkt_size;
988 uint16_t rp_uri_size;
989
990 size = ntohs (cm->header.size);
991 tkt_size = ntohs (cm->tkt_len);
992 rp_uri_size = ntohs (cm->rp_uri_len);
993 if (size < sizeof(struct ConsumeTicketMessage) + tkt_size + rp_uri_size)
994 {
995 GNUNET_break (0);
996 return GNUNET_SYSERR;
997 }
998 return GNUNET_OK;
999}
Ticket consume message.
Definition: reclaim.h:529
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:533
uint16_t rp_uri_len
RP URI length.
Definition: reclaim.h:548
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:543

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

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

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

1010{
1011 struct ConsumeTicketOperation *cop;
1012 struct IdpClient *idp = cls;
1014 char *buf;
1015 const char *rp_uri;
1016
1017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
1018 buf = (char*) &cm[1];
1019 ticket = (struct GNUNET_RECLAIM_Ticket *) buf;
1020 rp_uri = buf + ntohs (cm->tkt_len);
1021 cop = GNUNET_new (struct ConsumeTicketOperation);
1022 cop->r_id = ntohl (cm->id);
1023 cop->client = idp;
1024 cop->ch
1026 rp_uri,
1028 cop);
1029 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
1031}
static void consume_result_cb(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations, int32_t success, const char *emsg)
Handle a ticket consume result.
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:538

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

Here is the call graph for this function:

◆ attr_store_cont()

static void attr_store_cont ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Attribute store result handler.

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

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

1048{
1049 struct AttributeStoreHandle *ash = cls;
1050 struct GNUNET_MQ_Envelope *env;
1051 struct SuccessResultMessage *acr_msg;
1052
1053 ash->ns_qe = NULL;
1055 ash->client->store_op_tail,
1056 ash);
1057
1058 if (GNUNET_EC_NONE != ec)
1059 {
1061 "Failed to store attribute %s\n",
1063 cleanup_as_handle (ash);
1065 return;
1066 }
1067
1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1070 acr_msg->id = htonl (ash->r_id);
1071 acr_msg->op_result = htonl (GNUNET_OK);
1072 GNUNET_MQ_send (ash->client->mq, env);
1073 cleanup_as_handle (ash);
1074}
static void do_shutdown(void *cls)
Shutdown task.
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1305
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
@ GNUNET_EC_NONE
No error (success).
struct IdpClient * client
Client connection.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
Attribute store/delete response message.
Definition: reclaim.h:106
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:115
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:120

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

Referenced by attr_store_task().

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

◆ attr_store_task()

static void attr_store_task ( void *  cls)
static

Add a new attribute.

Parameters
clsthe AttributeStoreHandle

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

1084{
1085 struct AttributeStoreHandle *ash = cls;
1086 struct GNUNET_GNSRECORD_Data rd[1];
1087 char *buf;
1088 char *label;
1089 size_t buf_size;
1090
1091 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
1093 buf = GNUNET_malloc (buf_size);
1094 // Give the ash a new id if unset
1098 label
1100 sizeof (ash->claim->id));
1101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
1102
1103 rd[0].data_size = buf_size;
1104 rd[0].data = buf;
1109 &ash->identity,
1110 label,
1111 1,
1112 rd,
1114 ash);
1115 GNUNET_free (buf);
1116 GNUNET_free (label);
1117}
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static void attr_store_cont(void *cls, enum GNUNET_ErrorCode ec)
Attribute store result handler.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_YES
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
#define GNUNET_RECLAIM_id_is_zero(a)
#define GNUNET_RECLAIM_id_generate(id)
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
identity attribute
struct GNUNET_CRYPTO_PrivateKey identity
Identity.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_RECLAIM_Identifier id
ID.
uint64_t rel_value_us
The actual value.

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

Referenced by handle_attribute_store_message().

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

◆ check_attribute_store_message()

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

Check an attribute store message.

Parameters
clsunused
samthe message to check

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

1129{
1130 uint16_t size;
1131
1132 size = ntohs (sam->header.size);
1133 if (size <= sizeof(struct AttributeStoreMessage))
1134 {
1135 GNUNET_break (0);
1136 return GNUNET_SYSERR;
1137 }
1138 return GNUNET_OK;
1139}
Use to store an identity attribute.
Definition: reclaim.h:41
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45

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

◆ handle_attribute_store_message()

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

Handle an attribute store message.

Parameters
clsour client
samthe message to handle

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

1151{
1152 struct AttributeStoreHandle *ash;
1153 struct IdpClient *idp = cls;
1155 size_t data_len;
1156 size_t key_len;
1157 size_t read;
1158 char *buf;
1159
1160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1161
1162 data_len = ntohs (sam->attr_len);
1163 key_len = ntohs (sam->key_len);
1164 buf = (char *) &sam[1];
1165 if ((GNUNET_SYSERR ==
1167 &identity, &read)) ||
1168 (read != key_len))
1169 {
1171 "Failed to read private key\n");
1173 return;
1174 }
1175 buf += read;
1176 ash = GNUNET_new (struct AttributeStoreHandle);
1178 data_len,
1179 &ash->claim);
1180
1181 ash->r_id = ntohl (sam->id);
1182 ash->identity = identity;
1183 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1185
1187 ash->client = idp;
1188 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1190}
static void attr_store_task(void *cls)
Add a new attribute.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:619
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
struct GNUNET_CRYPTO_PublicKey identity_pkey
Identity pubkey.
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:50
uint16_t key_len
The length of the private key.
Definition: reclaim.h:65
uint16_t attr_len
The length of the attribute.
Definition: reclaim.h:60
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:55

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

Here is the call graph for this function:

◆ cred_store_cont()

static void cred_store_cont ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Credential store result handler.

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

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

1202{
1203 struct AttributeStoreHandle *ash = cls;
1204 struct GNUNET_MQ_Envelope *env;
1205 struct SuccessResultMessage *acr_msg;
1206
1207 ash->ns_qe = NULL;
1209 ash->client->store_op_tail,
1210 ash);
1211
1212 if (GNUNET_EC_NONE != ec)
1213 {
1215 "Failed to store credential: %s\n",
1217 cleanup_as_handle (ash);
1219 return;
1220 }
1221
1222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1224 acr_msg->id = htonl (ash->r_id);
1225 acr_msg->op_result = htonl (GNUNET_OK);
1226 GNUNET_MQ_send (ash->client->mq, env);
1227 cleanup_as_handle (ash);
1228}

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

Referenced by cred_add_cb().

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

◆ cred_error()

static void cred_error ( void *  cls)
static

Error looking up potential credential.

Abort.

Parameters
clsour attribute store handle

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

1238{
1239 struct AttributeStoreHandle *ash = cls;
1241 "Failed to check for existing credential.\n");
1242 cleanup_as_handle (ash);
1244 return;
1245}

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

Referenced by cred_store_task().

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

◆ cred_add_cb()

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

Check for existing record before storing credential.

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

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

1263{
1264 struct AttributeStoreHandle *ash = cls;
1265 struct GNUNET_GNSRECORD_Data rd_new[1];
1266 char *buf;
1267 size_t buf_size;
1268
1270 buf = GNUNET_malloc (buf_size);
1273 "Storing new credential under `%s'.\n",
1274 label);
1275 rd_new[0].data_size = buf_size;
1276 rd_new[0].data = buf;
1277 rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL;
1279 rd_new[0].expiration_time = ash->exp.rel_value_us;
1281 &ash->identity,
1282 label,
1283 1,
1284 rd_new,
1286 ash);
1287 GNUNET_free (buf);
1288 return;
1289}
static void cred_store_cont(void *cls, enum GNUNET_ErrorCode ec)
Credential store result handler.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL
Record type for an attribute attestation (e.g.

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

Referenced by cred_store_task().

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

◆ cred_store_task()

static void cred_store_task ( void *  cls)
static

Add a new credential.

Parameters
clsthe AttributeStoreHandle

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

1299{
1300 struct AttributeStoreHandle *ash = cls;
1301 char *label;
1302
1303 // Give the ash a new id if unset
1307 sizeof (ash->credential->id));
1309 "Looking up existing data under label `%s'\n", label);
1311 &ash->identity,
1312 label,
1313 &cred_error,
1314 ash,
1315 &cred_add_cb,
1316 ash);
1317 GNUNET_free (label);
1318}
static void cred_error(void *cls)
Error looking up potential credential.
static void cred_add_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Check for existing record before storing credential.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
struct GNUNET_RECLAIM_Identifier id
ID.

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

Referenced by handle_credential_store_message().

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

◆ check_credential_store_message()

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

Check an credential store message.

Parameters
clsunused
samthe message to check

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

1330{
1331 uint16_t size;
1332
1333 size = ntohs (sam->header.size);
1334 if (size <= sizeof(struct AttributeStoreMessage))
1335 {
1336 GNUNET_break (0);
1337 return GNUNET_SYSERR;
1338 }
1339 return GNUNET_OK;
1340}

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

◆ handle_credential_store_message()

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

Handle a credential store message.

Parameters
clsour client
samthe message to handle

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

1352{
1353 struct AttributeStoreHandle *ash;
1354 struct IdpClient *idp = cls;
1356 size_t data_len;
1357 size_t key_len;
1358 size_t read;
1359 char *buf;
1360
1361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1362
1363 data_len = ntohs (sam->attr_len);
1364 key_len = ntohs (sam->key_len);
1365 buf = (char *) &sam[1];
1366 if ((GNUNET_SYSERR ==
1368 &identity, &read)) ||
1369 (read != key_len))
1370 {
1372 "Failed to read private key\n");
1374 return;
1375 }
1376 buf += read;
1377 ash = GNUNET_new (struct AttributeStoreHandle);
1379 data_len);
1380
1381 ash->r_id = ntohl (sam->id);
1382 ash->identity = identity;
1383 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1385
1387 ash->client = idp;
1388 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1390}
static void cred_store_task(void *cls)
Add a new credential.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.

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

Here is the call graph for this function:

◆ send_delete_response()

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

Send a deletion success response.

Parameters
adhour attribute deletion handle
successthe success status

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

1401{
1402 struct GNUNET_MQ_Envelope *env;
1403 struct SuccessResultMessage *acr_msg;
1404
1406 adh->client->delete_op_tail,
1407 adh);
1408
1409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1411 acr_msg->id = htonl (adh->r_id);
1412 acr_msg->op_result = htonl (success);
1413 GNUNET_MQ_send (adh->client->mq, env);
1414}
struct IdpClient * client
Client connection.
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.

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

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

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

◆ consistency_iter()

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

Namestore iteration within attribute deletion.

We need to reissue tickets with the deleted attribute removed.

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

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

1433{
1434 struct AttributeDeleteHandle *adh = cls;
1435 struct TicketRecordsEntry *le;
1438 int is_ticket = GNUNET_NO;
1439 for (int i = 0; i < rd_count; i++)
1440 {
1441 switch (rd[i].record_type)
1442 {
1446 rd[i].data_size,
1447 &ale->attribute);
1450 ale);
1451 break;
1455 rd[i].data_size);
1458 cle);
1459 break;
1462 "Ticket to delete found (%s)\n",
1463 label);
1464 is_ticket = GNUNET_YES;
1465 break;
1466 default:
1467 break;
1468 }
1469 if (GNUNET_YES == is_ticket)
1470 break;
1471 }
1472 if (GNUNET_YES == is_ticket)
1473 {
1474 le = GNUNET_new (struct TicketRecordsEntry);
1476 le->data = GNUNET_malloc (le->data_size);
1477 le->rd_count = rd_count;
1478 le->label = GNUNET_strdup (label);
1482 le);
1483 }
1485}
static char * data
The data to insert into the dht.
static unsigned int rd_count
Number of records for currently parsed set.
static size_t data_size
Number of bytes in data.
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.
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.
@ GNUNET_NO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
local ticket reference
struct GNUNET_RECLAIM_AttributeListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_Credential * credential
The credential.
struct GNUNET_RECLAIM_CredentialListEntry * list_head
List head.
struct GNUNET_RECLAIM_CredentialListEntry * list_tail
List tail.
unsigned int rd_count
Record count.

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

Referenced by start_consistency_update().

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

◆ update_tickets()

static void update_tickets ( void *  cls)
static

Recursion prototype for function.

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

Parameters
clsour deletion handle

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

Parameters
clsour attribute deletion handle

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

1522{
1523 struct AttributeDeleteHandle *adh = cls;
1524 struct TicketRecordsEntry *le;
1525
1526 if (NULL == adh->tickets_to_update_head)
1527 {
1529 "Finished updating tickets, success\n");
1531 cleanup_adh (adh);
1532 return;
1533 }
1534 le = adh->tickets_to_update_head;
1537 le);
1538 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1539 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1541 le->data,
1542 le->rd_count,
1543 rd))
1544 {
1546 "Unable to deserialize record data!\n");
1548 cleanup_adh (adh);
1549 return;
1550 }
1551 int j = 0;
1552 int i = 0;
1555 struct GNUNET_RECLAIM_Presentation *presentation;
1556 for (i = 0; i < le->rd_count; i++)
1557 {
1558 switch (rd[i].record_type)
1559 {
1561 for (ale = adh->existing_attributes->list_head; NULL != ale; ale =
1562 ale->next)
1563 {
1565 &ale->attribute->id))
1566 {
1568 "Found attribute %s, readding...\n",
1569 ale->attribute->name);
1570 rd_new[j] = rd[i];
1571 j++;
1572 break; // Found and added
1573 }
1574 }
1575 break;
1578 rd[i].data_size);
1579 for (cle = adh->existing_credentials->list_head; NULL != cle; cle =
1580 cle->next)
1581 {
1583 &presentation->credential_id,
1584 &cle->credential->id))
1585 {
1587 "Found presentation for credential %s, readding...\n",
1588 cle->credential->name);
1589 rd_new[j] = rd[i];
1590 j++;
1591 break; // Found and added
1592 }
1593 }
1594 GNUNET_free (presentation);
1595 break;
1597 rd_new[j] = rd[i];
1598 j++;
1599 break; // Found and added
1600 default:
1601 GNUNET_break (0);
1602 }
1603 }
1605 "Updating ticket with %d entries (%d before)...\n",
1606 j, i);
1608 &adh->identity,
1609 le->label,
1610 j,
1611 rd_new,
1613 adh);
1614 GNUNET_free (le->label);
1615 GNUNET_free (le->data);
1616 GNUNET_free (le);
1617}
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
static void ticket_updated(void *cls, enum GNUNET_ErrorCode ec)
Callback called when a ticket was updated.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
#define GNUNET_RECLAIM_id_is_equal(a, b)
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_deserialize(const char *data, size_t data_size)
Deserialize a presentation.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
for reclaim records
struct GNUNET_CRYPTO_PrivateKey identity
Identity.
struct GNUNET_RECLAIM_CredentialListEntry * next
DLL.
const char * name
The name of the credential.
A credential presentation.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.

References GNUNET_RECLAIM_AttributeListEntry::attribute, cleanup_adh(), GNUNET_RECLAIM_CredentialListEntry::credential, GNUNET_RECLAIM_Presentation::credential_id, data, TicketRecordsEntry::data, data_size, TicketRecordsEntry::data_size, AttributeDeleteHandle::existing_attributes, AttributeDeleteHandle::existing_credentials, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_log, GNUNET_NAMESTORE_record_set_store(), GNUNET_OK, GNUNET_RECLAIM_id_is_equal, GNUNET_RECLAIM_presentation_deserialize(), GNUNET_SYSERR, GNUNET_YES, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Credential::id, AttributeDeleteHandle::identity, TicketRecordsEntry::label, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_CredentialList::list_head, GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_Credential::name, GNUNET_RECLAIM_AttributeListEntry::next, GNUNET_RECLAIM_CredentialListEntry::next, AttributeDeleteHandle::ns_qe, nsh, rd, rd_count, TicketRecordsEntry::rd_count, send_delete_response(), ticket_updated(), AttributeDeleteHandle::tickets_to_update_head, and AttributeDeleteHandle::tickets_to_update_tail.

Referenced by purge_attributes(), and ticket_updated().

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

◆ ticket_updated()

static void ticket_updated ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
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 1504 of file gnunet-service-reclaim.c.

1505{
1506 struct AttributeDeleteHandle *adh = cls;
1507
1508 adh->ns_qe = NULL;
1510}
static void update_tickets(void *cls)
Recursion prototype for function.

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

Referenced by update_tickets().

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

◆ purge_attributes()

static void purge_attributes ( void *  cls)
static

Delete all attributes which reference credentials that no longer exist.

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

1653{
1654 struct AttributeDeleteHandle *adh = cls;
1657
1658 for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next)
1659 {
1660 if (GNUNET_YES ==
1662 continue;
1663
1664 for (cle = adh->existing_credentials->list_head;
1665 NULL != cle; cle = cle->next)
1666 {
1667 if (GNUNET_YES !=
1669 &ale->attribute->credential))
1670 continue;
1671 break;
1672 }
1673 if (NULL == cle)
1674 {
1676 "Found attribute with missing credential\n");
1677 break;
1678 }
1679 }
1680 if (NULL == ale)
1681 {
1683 "Attributes consistent, updating tickets.\n");
1685 return;
1686 }
1688 "Attributes inconsistent, deleting offending attribute.\n");
1689 char *label
1691 sizeof(ale->attribute->id));
1692
1694 &adh->identity,
1695 label,
1696 0,
1697 NULL,
1699 adh);
1702 ale);
1703 GNUNET_free (ale);
1704 GNUNET_free (label);
1705}
static void offending_attr_delete_cont(void *cls, enum GNUNET_ErrorCode ec)
@ GNUNET_ERROR_TYPE_WARNING
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)

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

Referenced by consistency_iter_fin(), and offending_attr_delete_cont().

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

◆ offending_attr_delete_cont()

static void offending_attr_delete_cont ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

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

1629{
1630 struct AttributeDeleteHandle *adh = cls;
1631
1632 adh->ns_qe = NULL;
1633 if (GNUNET_EC_NONE != ec)
1634 {
1636 "Error deleting attribute %s\n",
1637 adh->label);
1639 cleanup_adh (adh);
1640 return;
1641 }
1642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing consistency check...\n");
1644}
static void purge_attributes(void *cls)
Delete all attributes which reference credentials that no longer exist.

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

Referenced by purge_attributes().

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

◆ consistency_iter_fin()

static void consistency_iter_fin ( void *  cls)
static

Done collecting affected tickets, start updating.

Parameters
clsour attribute deletion handle

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

1715{
1716 struct AttributeDeleteHandle *adh = cls;
1717 adh->ns_it = NULL;
1719}

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

Referenced by start_consistency_update().

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

◆ consistency_iter_err()

static void consistency_iter_err ( void *  cls)
static

Error collecting affected tickets.

Abort.

Parameters
clsour attribute deletion handle

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

1729{
1730 struct AttributeDeleteHandle *adh = cls;
1731
1732 adh->ns_it = NULL;
1734 "Namestore error on consistency check\n");
1736 cleanup_adh (adh);
1737}

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

Referenced by start_consistency_update().

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

◆ start_consistency_update()

static void start_consistency_update ( void *  cls)
static

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

Parameters
clsattribute deletion handle

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

1748{
1749 struct AttributeDeleteHandle *adh = cls;
1750
1753
1755 &adh->identity,
1757 adh,
1759 adh,
1761 adh);
1762}
static void consistency_iter(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Namestore iteration within attribute deletion.
static void consistency_iter_err(void *cls)
Error collecting affected tickets.
static void consistency_iter_fin(void *cls)
Done collecting affected tickets, start updating.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
A list of GNUNET_RECLAIM_Credential structures.

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

Referenced by attr_delete_cont(), and cred_delete_cont().

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

◆ attr_delete_cont()

static void attr_delete_cont ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Attribute deleted callback.

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

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

1774{
1775 struct AttributeDeleteHandle *adh = cls;
1776
1777 adh->ns_qe = NULL;
1778 if (GNUNET_EC_NONE != ec)
1779 {
1781 "Error deleting attribute %s\n",
1782 adh->label);
1784 cleanup_adh (adh);
1785 return;
1786 }
1787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1789}
static void start_consistency_update(void *cls)
Start processing tickets which may still contain reference to deleted attribute.

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

Referenced by handle_attribute_delete_message().

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

◆ check_attribute_delete_message()

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

Check attribute delete message format.

Parameters
clsunused
dammessage to check

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

1801{
1802 uint16_t size;
1803
1804 size = ntohs (dam->header.size);
1805 if (size <= sizeof(struct AttributeDeleteMessage))
1806 {
1807 GNUNET_break (0);
1808 return GNUNET_SYSERR;
1809 }
1810 return GNUNET_OK;
1811}
Use to delete an identity attribute.
Definition: reclaim.h:77
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:81

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

◆ handle_attribute_delete_message()

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

Handle attribute deletion.

Parameters
clsour client
damdeletion message

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

1823{
1824 struct AttributeDeleteHandle *adh;
1825 struct IdpClient *idp = cls;
1827 size_t data_len;
1828 size_t key_len;
1829 size_t read;
1830 char *buf;
1831
1832 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1833
1834 data_len = ntohs (dam->attr_len);
1835 key_len = ntohs (dam->key_len);
1836 buf = (char *) &dam[1];
1837 if ((GNUNET_SYSERR ==
1839 &identity, &read)) ||
1840 (read != key_len))
1841 {
1843 "Failed to read private key\n");
1845 return;
1846 }
1847 buf += read;
1848 adh = GNUNET_new (struct AttributeDeleteHandle);
1850 data_len,
1851 &adh->claim);
1852 adh->credential = NULL;
1853
1854 adh->r_id = ntohl (dam->id);
1855 adh->identity = identity;
1856 adh->label
1858 sizeof(adh->claim->id));
1860 adh->client = idp;
1861 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1863 &adh->identity,
1864 adh->label,
1865 0,
1866 NULL,
1868 adh);
1869}
static void attr_delete_cont(void *cls, enum GNUNET_ErrorCode ec)
Attribute deleted callback.
uint16_t key_len
The length of the private key.
Definition: reclaim.h:96
uint16_t attr_len
The length of the attribute.
Definition: reclaim.h:91
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:86

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

Here is the call graph for this function:

◆ cred_delete_cont()

static void cred_delete_cont ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Credential deleted callback.

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

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

1881{
1882 struct AttributeDeleteHandle *adh = cls;
1883
1884 adh->ns_qe = NULL;
1885 if (GNUNET_EC_NONE != ec)
1886 {
1888 "Error deleting credential `%s'\n",
1889 adh->label);
1891 cleanup_adh (adh);
1892 return;
1893 }
1894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1896}

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

Referenced by handle_credential_delete_message().

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

◆ check_credential_delete_message()

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

Check credential delete message format.

Parameters
clsunused
dammessage to check

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

1908{
1909 uint16_t size;
1910
1911 size = ntohs (dam->header.size);
1912 if (size <= sizeof(struct AttributeDeleteMessage))
1913 {
1914 GNUNET_break (0);
1915 return GNUNET_SYSERR;
1916 }
1917 return GNUNET_OK;
1918}

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

◆ handle_credential_delete_message()

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

Handle credential deletion.

Parameters
clsour client
damdeletion message

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

1930{
1931 struct AttributeDeleteHandle *adh;
1932 struct IdpClient *idp = cls;
1934 size_t data_len;
1935 size_t key_len;
1936 size_t read;
1937 char *buf;
1938
1939 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1940
1941 data_len = ntohs (dam->attr_len);
1942 key_len = ntohs (dam->key_len);
1943 buf = (char *) &dam[1];
1944 if ((GNUNET_SYSERR ==
1946 &identity, &read)) ||
1947 (read != key_len))
1948 {
1950 "Failed to read private key\n");
1952 return;
1953 }
1954 buf += read;
1955 adh = GNUNET_new (struct AttributeDeleteHandle);
1957 data_len);
1958 adh->claim = NULL;
1959
1960 adh->r_id = ntohl (dam->id);
1961 adh->identity = identity;
1962 adh->label
1964 sizeof(adh->credential->id));
1966 adh->client = idp;
1967 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1969 &adh->identity,
1970 adh->label,
1971 0,
1972 NULL,
1974 adh);
1975}
static void cred_delete_cont(void *cls, enum GNUNET_ErrorCode ec)
Credential deleted callback.

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

Here is the call graph for this function:

◆ attr_iter_finished()

static void attr_iter_finished ( void *  cls)
static

Done iterating over attributes.

Parameters
clsour iterator handle

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

1990{
1991 struct Iterator *ai = cls;
1992 struct GNUNET_MQ_Envelope *env;
1993 struct AttributeResultMessage *arm;
1994
1995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1997 arm->id = htonl (ai->request_id);
1998 arm->attr_len = htons (0);
1999 arm->pkey_len = htons (0);
2000 GNUNET_MQ_send (ai->client->mq, env);
2001 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
2002 ai->client->attr_iter_tail,
2003 ai);
2004 GNUNET_free (ai);
2005}
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
Attribute is returned from the idp.
Definition: reclaim.h:127
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:146
uint16_t pkey_len
The length of the public key.
Definition: reclaim.h:156
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:136

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

Referenced by attr_iter_error(), and handle_iteration_start().

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

◆ attr_iter_error()

static void attr_iter_error ( void *  cls)
static

Error iterating over attributes.

Abort.

Parameters
clsour attribute iteration handle

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

2015{
2016 struct Iterator *ai = cls;
2017
2018 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
2020}
static void attr_iter_finished(void *cls)
Done iterating over attributes.

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

Referenced by handle_iteration_start().

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

◆ attr_iter_cb()

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

Got record.

Return if it is an attribute.

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

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

2038{
2039 struct Iterator *ai = cls;
2040 struct GNUNET_MQ_Envelope *env;
2042 char *data_tmp;
2043 size_t key_len;
2044 ssize_t written;
2045
2046 if ((rd_count != 1) ||
2048 {
2050 return;
2051 }
2052 struct AttributeResultMessage *arm;
2053 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
2054 label);
2056 "Sending ATTRIBUTE_RESULT message\n");
2059 env = GNUNET_MQ_msg_extra (arm,
2060 rd->data_size + key_len,
2062 arm->id = htonl (ai->request_id);
2063 arm->attr_len = htons (rd->data_size);
2064 data_tmp = (char *) &arm[1];
2065 arm->pkey_len = htons (key_len);
2067 data_tmp,
2068 key_len);
2069 GNUNET_assert (0 <= written);
2070 data_tmp += written;
2071 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2072 GNUNET_MQ_send (ai->client->mq, env);
2073}
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
An identity key as per LSD0001.

References ai, AttributeResultMessage::attr_len, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, env, GNUNET_assert, GNUNET_CRYPTO_key_get_public(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_CRYPTO_write_public_key_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAMESTORE_zone_iterator_next(), AttributeResultMessage::id, identity, AttributeResultMessage::pkey_len, rd, rd_count, and GNUNET_GNSRECORD_Data::record_type.

Referenced by handle_iteration_start().

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

◆ check_iteration_start()

static enum GNUNET_GenericReturnValue check_iteration_start ( void *  cls,
const struct AttributeIterationStartMessage ais_msg 
)
static

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

2080{
2081 uint16_t size;
2082 size_t key_len;
2083
2084 size = ntohs (ais_msg->header.size);
2085 key_len = ntohs (ais_msg->key_len);
2086
2087 if (size < key_len + sizeof(*ais_msg))
2088 {
2089 GNUNET_break (0);
2090 return GNUNET_SYSERR;
2091 }
2092 return GNUNET_OK;
2093}
uint16_t key_len
The length of the private key.
Definition: reclaim.h:221
struct GNUNET_MessageHeader header
Message.
Definition: reclaim.h:206

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, AttributeIterationStartMessage::header, AttributeIterationStartMessage::key_len, GNUNET_MessageHeader::size, and size.

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

2105{
2106 struct IdpClient *idp = cls;
2107 struct Iterator *ai;
2109 size_t key_len;
2110 size_t read;
2111
2113 "Received ATTRIBUTE_ITERATION_START message\n");
2114 key_len = ntohs (ais_msg->key_len);
2115 if ((GNUNET_SYSERR ==
2117 key_len,
2118 &identity,
2119 &read)) ||
2120 (read != key_len))
2121 {
2123 "Failed to read private key.\n");
2125 return;
2126 }
2127 ai = GNUNET_new (struct Iterator);
2128 ai->request_id = ntohl (ais_msg->id);
2129 ai->client = idp;
2130 ai->identity = identity;
2131
2132 GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
2134 &ai->identity,
2136 ai,
2137 &attr_iter_cb,
2138 ai,
2140 ai);
2142}
static void attr_iter_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
static void attr_iter_error(void *cls)
Error iterating over attributes.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:211

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

Here is the call graph for this function:

◆ handle_iteration_stop()

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

Handle iteration stop message from client.

Parameters
clsthe client
ais_msgthe stop message

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

2154{
2155 struct IdpClient *idp = cls;
2156 struct Iterator *ai;
2157 uint32_t rid;
2158
2160 "Received `%s' message\n",
2161 "ATTRIBUTE_ITERATION_STOP");
2162 rid = ntohl (ais_msg->id);
2163 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2164 if (ai->request_id == rid)
2165 break;
2166 if (NULL == ai)
2167 {
2168 GNUNET_break (0);
2170 return;
2171 }
2172 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
2173 GNUNET_free (ai);
2175}
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:324
struct GNUNET_TRANSPORT_AddressIdentifier * next
Kept in a DLL.

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

Here is the call graph for this function:

◆ handle_iteration_next()

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

Client requests next attribute from iterator.

Parameters
clsthe client
ais_msgthe message

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

2187{
2188 struct IdpClient *idp = cls;
2189 struct Iterator *ai;
2190 uint32_t rid;
2191
2193 "Received ATTRIBUTE_ITERATION_NEXT message\n");
2194 rid = ntohl (ais_msg->id);
2195 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
2196 if (ai->request_id == rid)
2197 break;
2198 if (NULL == ai)
2199 {
2200 GNUNET_break (0);
2202 return;
2203 }
2206}
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:242

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

Here is the call graph for this function:

◆ cred_iter_finished()

static void cred_iter_finished ( void *  cls)
static

Done iterating over credentials.

Parameters
clsour iterator handle

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

2221{
2222 struct Iterator *ai = cls;
2223 struct GNUNET_MQ_Envelope *env;
2224 struct CredentialResultMessage *arm;
2225
2226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
2228 arm->id = htonl (ai->request_id);
2229 arm->credential_len = htons (0);
2230 arm->key_len = htons (0);
2231 GNUNET_MQ_send (ai->client->mq, env);
2232 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2233 ai->client->cred_iter_tail,
2234 ai);
2235 GNUNET_free (ai);
2236}
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT
Credential is returned from the idp.
Definition: reclaim.h:169
uint16_t credential_len
Length of serialized attribute data.
Definition: reclaim.h:183
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:178
uint16_t key_len
The length of the public key.
Definition: reclaim.h:188

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

Referenced by cred_iter_error(), and handle_credential_iteration_start().

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

◆ cred_iter_error()

static void cred_iter_error ( void *  cls)
static

Error iterating over credentials.

Abort.

Parameters
clsour attribute iteration handle

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

2246{
2247 struct Iterator *ai = cls;
2248
2249 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over credentials\n");
2251}
static void cred_iter_finished(void *cls)
Done iterating over credentials.

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

Referenced by handle_credential_iteration_start().

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

◆ cred_iter_cb()

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

Got record.

Return credential.

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

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

2269{
2270 struct Iterator *ai = cls;
2271 struct GNUNET_MQ_Envelope *env;
2272 struct CredentialResultMessage *arm;
2274 char *data_tmp;
2275 size_t key_len;
2276 ssize_t written;
2277
2278 if ((rd_count != 1) ||
2280 {
2282 return;
2283 }
2284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found credential under: %s\n",
2285 label);
2287 "Sending CREDENTIAL_RESULT message\n");
2290 env = GNUNET_MQ_msg_extra (arm,
2291 rd->data_size + key_len,
2293 arm->id = htonl (ai->request_id);
2294 arm->credential_len = htons (rd->data_size);
2295 arm->key_len = htons (key_len);
2296 data_tmp = (char *) &arm[1];
2298 data_tmp,
2299 key_len);
2300 GNUNET_assert (written >= 0);
2301 data_tmp += written;
2302 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
2303 GNUNET_MQ_send (ai->client->mq, env);
2304}

References ai, CredentialResultMessage::credential_len, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, env, GNUNET_assert, GNUNET_CRYPTO_key_get_public(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_CRYPTO_write_public_key_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAMESTORE_zone_iterator_next(), CredentialResultMessage::id, identity, CredentialResultMessage::key_len, rd, rd_count, and GNUNET_GNSRECORD_Data::record_type.

Referenced by handle_credential_iteration_start().

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

◆ check_credential_iteration_start()

static enum GNUNET_GenericReturnValue check_credential_iteration_start ( void *  cls,
const struct CredentialIterationStartMessage cis_msg 
)
static

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

2311{
2312 uint16_t size;
2313 size_t key_len;
2314
2315 size = ntohs (cis_msg->header.size);
2316 key_len = ntohs (cis_msg->key_len);
2317
2318 if (size < key_len + sizeof(*cis_msg))
2319 {
2320 GNUNET_break (0);
2321 return GNUNET_SYSERR;
2322 }
2323 return GNUNET_OK;
2324}
struct GNUNET_MessageHeader header
Message.
Definition: reclaim.h:254
uint16_t key_len
The length of the private key.
Definition: reclaim.h:269

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, CredentialIterationStartMessage::header, CredentialIterationStartMessage::key_len, GNUNET_MessageHeader::size, and size.

◆ handle_credential_iteration_start()

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

Iterate over zone to get attributes.

Parameters
clsour client
ais_msgthe iteration message to start

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

2337{
2338 struct IdpClient *idp = cls;
2339 struct Iterator *ai;
2341 size_t key_len;
2342 size_t read;
2343
2345 "Received CREDENTIAL_ITERATION_START message\n");
2346 key_len = ntohs (ais_msg->key_len);
2347 if ((GNUNET_SYSERR ==
2349 key_len,
2350 &identity,
2351 &read)) ||
2352 (read != key_len))
2353 {
2355 "Failed to read private key.\n");
2357 return;
2358 }
2359 ai = GNUNET_new (struct Iterator);
2360 ai->request_id = ntohl (ais_msg->id);
2361 ai->client = idp;
2362 ai->identity = identity;
2363
2364 GNUNET_CONTAINER_DLL_insert (idp->cred_iter_head, idp->cred_iter_tail,
2365 ai);
2367 &ai->identity,
2369 ai,
2370 &cred_iter_cb,
2371 ai,
2373 ai);
2375}
static void cred_iter_error(void *cls)
Error iterating over credentials.
static void cred_iter_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:259

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

Here is the call graph for this function:

◆ handle_credential_iteration_stop()

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

Handle iteration stop message from client.

Parameters
clsthe client
ais_msgthe stop message

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

2388{
2389 struct IdpClient *idp = cls;
2390 struct Iterator *ai;
2391 uint32_t rid;
2392
2394 "Received `%s' message\n",
2395 "CREDENTIAL_ITERATION_STOP");
2396 rid = ntohl (ais_msg->id);
2397 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2398 if (ai->request_id == rid)
2399 break;
2400 if (NULL == ai)
2401 {
2402 GNUNET_break (0);
2404 return;
2405 }
2406 GNUNET_CONTAINER_DLL_remove (idp->cred_iter_head, idp->cred_iter_tail,
2407 ai);
2408 GNUNET_free (ai);
2410}
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:307

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

Here is the call graph for this function:

◆ handle_credential_iteration_next()

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

Client requests next credential from iterator.

Parameters
clsthe client
ais_msgthe message

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

2423{
2424 struct IdpClient *idp = cls;
2425 struct Iterator *ai;
2426 uint32_t rid;
2427
2429 "Received CREDENTIAL_ITERATION_NEXT message\n");
2430 rid = ntohl (ais_msg->id);
2431 for (ai = idp->cred_iter_head; NULL != ai; ai = ai->next)
2432 if (ai->request_id == rid)
2433 break;
2434 if (NULL == ai)
2435 {
2436 GNUNET_break (0);
2438 return;
2439 }
2442}
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:290

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

Here is the call graph for this function:

◆ ticket_iter_cb()

static void ticket_iter_cb ( void *  cls,
struct GNUNET_RECLAIM_Ticket ticket,
const char *  rp_uri 
)
static

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

2452{
2453 struct TicketIteration *ti = cls;
2454 struct GNUNET_MQ_Envelope *env;
2455 struct TicketResultMessage *trm;
2456 size_t tkt_len;
2457 size_t rp_uri_len;
2458
2459 if (NULL == ticket)
2460 tkt_len = 0;
2461 else
2462 tkt_len = strlen (ticket->gns_name) + 1;
2463
2464 if (NULL == rp_uri)
2465 rp_uri_len = 0;
2466 else
2467 rp_uri_len = strlen (rp_uri) + 1;
2468 env = GNUNET_MQ_msg_extra (trm,
2471 if (NULL == ticket)
2472 {
2473 /* send empty response to indicate end of list */
2476 ti);
2477 }
2478 else
2479 {
2480 memcpy (&trm[1], ticket, tkt_len);
2481 }
2482 memcpy ((char*) &trm[1] + tkt_len, rp_uri, rp_uri_len);
2483 trm->id = htonl (ti->r_id);
2484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2485 trm->tkt_len = htons (tkt_len);
2486 trm->rp_uri_len = htons (rp_uri_len);
2487 trm->presentations_len = htons (0);
2488 GNUNET_MQ_send (ti->client->mq, env);
2489 if (NULL == ticket)
2490 GNUNET_free (ti);
2491}
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
struct IdpClient * client
Client which intiated this zone iteration.
uint32_t r_id
The operation id for the iteration in the response for the client.

References TicketIteration::client, env, GNUNET_RECLAIM_Ticket::gns_name, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), TicketResultMessage::id, IdpClient::mq, TicketResultMessage::presentations_len, TicketIteration::r_id, TicketResultMessage::rp_uri_len, ticket, IdpClient::ticket_iter_head, IdpClient::ticket_iter_tail, and TicketResultMessage::tkt_len.

Referenced by handle_ticket_iteration_start().

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

◆ check_ticket_iteration_start()

static enum GNUNET_GenericReturnValue check_ticket_iteration_start ( void *  cls,
const struct TicketIterationStartMessage tis_msg 
)
static

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

2498{
2499 uint16_t size;
2500 size_t key_len;
2501
2502 size = ntohs (tis_msg->header.size);
2503 key_len = ntohs (tis_msg->key_len);
2504
2505 if (size < key_len + sizeof(*tis_msg))
2506 {
2507 GNUNET_break (0);
2508 return GNUNET_SYSERR;
2509 }
2510 return GNUNET_OK;
2511}
uint16_t key_len
The length of the private key.
Definition: reclaim.h:350
struct GNUNET_MessageHeader header
Message.
Definition: reclaim.h:335

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, TicketIterationStartMessage::header, TicketIterationStartMessage::key_len, GNUNET_MessageHeader::size, and size.

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

2524{
2526 struct IdpClient *client = cls;
2527 struct TicketIteration *ti;
2528 size_t key_len;
2529 size_t read;
2530
2532 "Received TICKET_ITERATION_START message\n");
2533 key_len = ntohs (tis_msg->key_len);
2534 if ((GNUNET_SYSERR ==
2536 key_len,
2537 &identity,
2538 &read)) ||
2539 (read != key_len))
2540 {
2542 "Failed to read private key\n");
2544 return;
2545 }
2546 ti = GNUNET_new (struct TicketIteration);
2547 ti->r_id = ntohl (tis_msg->id);
2548 ti->client = client;
2551 ti);
2552 ti->iter
2555}
static void ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri)
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_CRYPTO_PrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
struct GNUNET_SERVICE_Client * client
The client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:340

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

Here is the call graph for this function:

◆ handle_ticket_iteration_stop()

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

Client has had enough tickets.

Parameters
clsthe client
tis_msgthe stop message

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

2567{
2568 struct IdpClient *client = cls;
2569 struct TicketIteration *ti;
2570 uint32_t rid;
2571
2573 "Received `%s' message\n",
2574 "TICKET_ITERATION_STOP");
2575 rid = ntohl (tis_msg->id);
2576 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2577 if (ti->r_id == rid)
2578 break;
2579 if (NULL == ti)
2580 {
2581 GNUNET_break (0);
2583 return;
2584 }
2588 ti);
2589 GNUNET_free (ti);
2591}
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:388
struct TicketIteration * next
DLL.

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

Here is the call graph for this function:

◆ handle_ticket_iteration_next()

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

Client requests next result.

Parameters
clsthe client
tis_msgthe message

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

2603{
2604 struct IdpClient *client = cls;
2605 struct TicketIteration *ti;
2606 uint32_t rid;
2607
2609 "Received TICKET_ITERATION_NEXT message\n");
2610 rid = ntohl (tis_msg->id);
2611 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
2612 if (ti->r_id == rid)
2613 break;
2614 if (NULL == ti)
2615 {
2616 GNUNET_break (0);
2618 return;
2619 }
2622}
void RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
Continue ticket iteration.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:371

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

Here is the call graph for this function:

◆ run()

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

Main function that will be run.

Parameters
clsclosure
cthe configuration used
serverthe service handle

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

2636{
2637 cfg = c;
2638
2640 {
2642 "Unable to initialize TICKETS subsystem.\n");
2644 return;
2645 }
2646 // Connect to identity and namestore services
2648 if (NULL == nsh)
2649 {
2651 "error connecting to namestore");
2652 }
2653
2655}
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1340

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

Here is the call graph for this function:

◆ client_disconnect_cb()

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

Called whenever a client is disconnected.

Parameters
clsclosure
clientidentification of the client
app_ctxclient

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

2669{
2670 struct IdpClient *idp = app_ctx;
2671
2672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
2675 idp);
2677}
static struct IdpClient * client_list_tail
Client list.
static struct IdpClient * client_list_head
Client list.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.

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

Here is the call graph for this function:

◆ client_connect_cb()

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

Add a client to our list of active clients.

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

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

2692{
2693 struct IdpClient *idp;
2694
2695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
2696 idp = GNUNET_new (struct IdpClient);
2697 idp->client = client;
2698 idp->mq = mq;
2701 idp);
2702 return idp;
2703}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:390

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

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "reclaim"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_var_size(attribute_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, struct AttributeStoreMessage, NULL)  ,
GNUNET_MQ_hd_var_size(credential_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, struct AttributeStoreMessage, NULL)  ,
GNUNET_MQ_hd_var_size(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL)  ,
GNUNET_MQ_hd_var_size(credential_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, struct AttributeDeleteMessage, NULL)  ,
GNUNET_MQ_hd_var_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(credential_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, struct CredentialIterationStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(credential_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, struct CredentialIterationNextMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(credential_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, struct CredentialIterationStopMessage, NULL)  ,
GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL)  ,
GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL)  ,
GNUNET_MQ_hd_var_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL)  ,
GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Variable Documentation

◆ nsh

◆ timeout_task

struct GNUNET_SCHEDULER_Task* timeout_task
static

Timeout task.

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

Referenced by cleanup().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

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

Referenced by run().

◆ client_list_head

struct IdpClient* client_list_head = NULL
static

Client list.

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

Referenced by client_connect_cb(), and client_disconnect_cb().

◆ client_list_tail

struct IdpClient* client_list_tail = NULL
static

Client list.

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

Referenced by client_connect_cb(), and client_disconnect_cb().