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

reclaim Service More...

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

Go to the source code of this file.

Data Structures

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

Functions

static void cleanup_adh (struct AttributeDeleteHandle *adh)
 Cleanup attribute delete handle. More...
 
static void cleanup_as_handle (struct AttributeStoreHandle *ash)
 Cleanup attribute store handle. More...
 
static void cleanup_client (struct IdpClient *idp)
 Cleanup client. More...
 
static void cleanup ()
 Cleanup task. More...
 
static void do_shutdown (void *cls)
 Shutdown task. More...
 
static void send_ticket_result (const struct IdpClient *client, uint32_t r_id, const struct GNUNET_RECLAIM_Ticket *ticket, uint32_t success)
 Sends a ticket result message to the client. More...
 
static void issue_ticket_result_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket, int32_t success, const char *emsg)
 Issue ticket result. More...
 
static int check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
 Check issue ticket message. More...
 
static void handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
 Handle ticket issue message. More...
 
static void revoke_result_cb (void *cls, int32_t success)
 Handles revocation result. More...
 
static int check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im)
 Check revocation message format. More...
 
static void handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
 Handle a revocation message to a ticket. More...
 
static void consume_result_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, int32_t success, const char *emsg)
 Handle a ticket consume result. More...
 
static int check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
 Check a consume ticket message. More...
 
static void handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
 Handle a consume ticket message. More...
 
static void attr_store_cont (void *cls, int32_t success, const char *emsg)
 Attribute store result handler. More...
 
static void attr_store_task (void *cls)
 Add a new attribute. More...
 
static int check_attribute_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Check an attribute store message. More...
 
static void handle_attribute_store_message (void *cls, const struct AttributeStoreMessage *sam)
 Handle an attribute store message. More...
 
static void send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
 Send a deletion success response. More...
 
static void ticket_iter (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Namestore iteration within attribute deletion. More...
 
static void update_tickets (void *cls)
 Recursion prototype for function. More...
 
static void ticket_updated (void *cls, int32_t success, const char *emsg)
 Callback called when a ticket was updated. More...
 
static void ticket_iter_fin (void *cls)
 Done collecting affected tickets, start updating. More...
 
static void ticket_iter_err (void *cls)
 Error collecting affected tickets. More...
 
static void start_ticket_update (void *cls)
 Start processing tickets which may still contain reference to deleted attribute. More...
 
static void attr_delete_cont (void *cls, int32_t success, const char *emsg)
 Attribute deleted callback. More...
 
static int check_attribute_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Check attribute delete message format. More...
 
static void handle_attribute_delete_message (void *cls, const struct AttributeDeleteMessage *dam)
 Handle attribute deletion. More...
 
static void attr_iter_finished (void *cls)
 Done iterating over attributes. More...
 
static void attr_iter_error (void *cls)
 Error iterating over attributes. More...
 
static void attr_iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Got record. More...
 
static void handle_iteration_start (void *cls, const struct AttributeIterationStartMessage *ais_msg)
 Iterate over zone to get attributes. More...
 
static void handle_iteration_stop (void *cls, const struct AttributeIterationStopMessage *ais_msg)
 Handle iteration stop message from client. More...
 
static void handle_iteration_next (void *cls, const struct AttributeIterationNextMessage *ais_msg)
 Client requests next attribute from iterator. More...
 
static void ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
 Got a ticket. More...
 
static void handle_ticket_iteration_start (void *cls, const struct TicketIterationStartMessage *tis_msg)
 Client requests a ticket iteration. More...
 
static void handle_ticket_iteration_stop (void *cls, const struct TicketIterationStopMessage *tis_msg)
 Client has had enough tickets. More...
 
static void handle_ticket_iteration_next (void *cls, const struct TicketIterationNextMessage *tis_msg)
 Client requests next result. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *server)
 Main function that will be run. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Called whenever a client is disconnected. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Add a client to our list of active clients. More...
 
 GNUNET_SERVICE_MAIN ("reclaim", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(attribute_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, struct AttributeIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, struct AttributeIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, struct AttributeIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL), GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

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

Detailed Description

reclaim Service

Author
Martin Schanzenbach

Definition in file gnunet-service-reclaim.c.

Function Documentation

◆ cleanup_adh()

static void cleanup_adh ( struct AttributeDeleteHandle adh)
static

Cleanup attribute delete handle.

Parameters
adhthe attribute to cleanup

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

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

Referenced by attr_delete_cont(), cleanup_client(), ticket_iter_err(), and update_tickets().

451 {
452  struct TicketRecordsEntry *le;
453 
454  if (NULL != adh->ns_it)
456  if (NULL != adh->ns_qe)
458  if (NULL != adh->label)
459  GNUNET_free (adh->label);
460  if (NULL != adh->claim)
461  GNUNET_free (adh->claim);
462  while (NULL != (le = adh->tickets_to_update_head))
463  {
466  le);
467  if (NULL != le->label)
468  GNUNET_free (le->label);
469  if (NULL != le->data)
470  GNUNET_free (le->data);
471  GNUNET_free (le);
472  }
473  GNUNET_free (adh);
474 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
char * label
Attribute label.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_as_handle()

static void cleanup_as_handle ( struct AttributeStoreHandle ash)
static

Cleanup attribute store handle.

Parameters
handlehandle to clean up

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

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

Referenced by attr_store_cont(), and cleanup_client().

484 {
485  if (NULL != ash->ns_qe)
487  if (NULL != ash->claim)
488  GNUNET_free (ash->claim);
489  GNUNET_free (ash);
490 }
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to store.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_client()

static void cleanup_client ( struct IdpClient idp)
static

Cleanup client.

Parameters
idpthe client to clean up

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

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

Referenced by cleanup(), and client_disconnect_cb().

500 {
501  struct AttributeIterator *ai;
502  struct TicketIteration *ti;
503  struct TicketRevocationOperation *rop;
504  struct TicketIssueOperation *iss;
505  struct ConsumeTicketOperation *ct;
506  struct AttributeStoreHandle *as;
507  struct AttributeDeleteHandle *adh;
508 
509  while (NULL != (iss = idp->issue_op_head))
510  {
512  GNUNET_free (iss);
513  }
514  while (NULL != (ct = idp->consume_op_head))
515  {
517  idp->consume_op_tail,
518  ct);
519  if (NULL != ct->ch)
521  GNUNET_free (ct);
522  }
523  while (NULL != (as = idp->store_op_head))
524  {
526  cleanup_as_handle (as);
527  }
528  while (NULL != (adh = idp->delete_op_head))
529  {
531  cleanup_adh (adh);
532  }
533 
534  while (NULL != (ai = idp->attr_iter_head))
535  {
537  GNUNET_free (ai);
538  }
539  while (NULL != (rop = idp->revoke_op_head))
540  {
542  if (NULL != rop->rh)
544  GNUNET_free (rop);
545  }
546  while (NULL != (ti = idp->ticket_iter_head))
547  {
549  idp->ticket_iter_tail,
550  ti);
551  if (NULL != ti->iter)
553  GNUNET_free (ti);
554  }
555  GNUNET_free (idp);
556 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle for attribute deletion request.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
Ticket issue operation handle.
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
struct RECLAIM_TICKETS_ConsumeHandle * ch
Ticket consume handle.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
A ticket iteration operation.
Ticket revocation request handle.
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
Handle for ticket consume request.
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
An attribute iteration operation.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

static void cleanup ( )
static

Cleanup task.

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

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

Referenced by do_shutdown().

564 {
565  struct IdpClient *cl;
566 
567  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
568 
569  while (NULL != (cl = client_list_head))
570  {
573  cl);
574  cleanup_client (cl);
575  }
577  if (NULL != timeout_task)
579  if (NULL != nsh)
581 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
An idp client.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
static struct IdpClient * client_list_head
Client list.
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
static struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
static struct IdpClient * client_list_tail
Client list.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Shutdown task.

Parameters
clsNULL

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

References cleanup(), GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

Referenced by attr_store_cont(), and run().

591 {
592  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
593  cleanup ();
594 }
static void cleanup()
Cleanup task.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_ticket_result()

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

Sends a ticket result message to the client.

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

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

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

Referenced by issue_ticket_result_cb().

610 {
611  struct TicketResultMessage *irm;
612  struct GNUNET_MQ_Envelope *env;
613 
614  env = GNUNET_MQ_msg (irm,
616  if (NULL != ticket)
617  {
618  irm->ticket = *ticket;
619  }
620  // TODO add success member
621  irm->id = htonl (r_id);
622  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
623  GNUNET_MQ_send (client->mq, env);
624 }
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:367
Ticket result message.
Definition: reclaim.h:357
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:372
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ issue_ticket_result_cb()

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

Issue ticket result.

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

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

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

Referenced by handle_issue_ticket_message().

640 {
641  struct TicketIssueOperation *tio = cls;
642 
643  if (GNUNET_OK != success)
644  {
645  send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR);
647  tio->client->issue_op_tail,
648  tio);
649  GNUNET_free (tio);
650  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
651  return;
652  }
653  send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR);
655  tio->client->issue_op_tail,
656  tio);
657  GNUNET_free (tio);
658 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
struct IdpClient * client
Client connection.
Ticket issue operation handle.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
uint32_t r_id
request id
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
#define GNUNET_log(kind,...)
static void send_ticket_result(const struct IdpClient *client, uint32_t r_id, const struct GNUNET_RECLAIM_Ticket *ticket, uint32_t success)
Sends a ticket result message to the client.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_issue_ticket_message()

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

Check issue ticket message.

unused message to check

Returns
GNUNET_OK if message is ok

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

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

670 {
671  uint16_t size;
672 
673  size = ntohs (im->header.size);
674  if (size <= sizeof(struct IssueTicketMessage))
675  {
676  GNUNET_break (0);
677  return GNUNET_SYSERR;
678  }
679  return GNUNET_OK;
680 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET.
Definition: reclaim.h:276
Ticket issue message.
Definition: reclaim.h:271
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_issue_ticket_message()

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

Handle ticket issue message.

Parameters
clsour client
imthe message

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

References IssueTicketMessage::attr_len, IdpClient::client, TicketIssueOperation::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_list_destroy(), GNUNET_SERVICE_client_continue(), IdpClient::issue_op_head, IdpClient::issue_op_tail, issue_ticket_result_cb(), TicketIssueOperation::r_id, RECLAIM_TICKETS_issue(), and tio.

691 {
692  struct TicketIssueOperation *tio;
693  struct IdpClient *idp = cls;
695  size_t attrs_len;
696 
697  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
698  tio = GNUNET_new (struct TicketIssueOperation);
699  attrs_len = ntohs (im->attr_len);
700  attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &im[1],
701  attrs_len);
702  tio->r_id = ntohl (im->id);
703  tio->client = idp;
706  attrs,
707  &im->rp,
709  tio);
712 }
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:291
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
struct IdpClient * client
Client connection.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
Ticket issue operation handle.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
uint32_t r_id
request id
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:286
struct GNUNET_SERVICE_Client * client
The client.
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
static void issue_ticket_result_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, int32_t success, const char *emsg)
Issue ticket result.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:281
uint32_t attr_len
length of serialized attribute list
Definition: reclaim.h:296
void RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes...
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
Here is the call graph for this function:

◆ revoke_result_cb()

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

Handles revocation result.

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

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

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

Referenced by handle_revoke_ticket_message().

727 {
728  struct TicketRevocationOperation *rop = cls;
729  struct GNUNET_MQ_Envelope *env;
730  struct RevokeTicketResultMessage *trm;
731 
733  "Sending REVOKE_TICKET_RESULT message\n");
734  rop->rh = NULL;
736  trm->id = htonl (rop->r_id);
737  trm->success = htonl (success);
738  GNUNET_MQ_send (rop->client->mq, env);
740  rop->client->revoke_op_tail,
741  rop);
742  GNUNET_free (rop);
743 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
struct IdpClient * client
Client connection.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
Ticket revocation request handle.
Ticket revoke message.
Definition: reclaim.h:335
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:345
#define GNUNET_log(kind,...)
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t success
Revocation result.
Definition: reclaim.h:350
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_revoke_ticket_message()

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

Check revocation message format.

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

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

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

755 {
756  uint16_t size;
757 
758  size = ntohs (im->header.size);
759  if (size != sizeof(struct RevokeTicketMessage))
760  {
761  GNUNET_break (0);
762  return GNUNET_SYSERR;
763  }
764  return GNUNET_OK;
765 }
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET.
Definition: reclaim.h:309
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
Ticket revoke message.
Definition: reclaim.h:304

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

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

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

◆ consume_result_cb()

static void consume_result_cb ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs,
int32_t  success,
const char *  emsg 
)
static

Handle a ticket consume result.

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

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

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

Referenced by handle_consume_ticket_message().

807 {
808  struct ConsumeTicketOperation *cop = cls;
809  struct ConsumeTicketResultMessage *crm;
810  struct GNUNET_MQ_Envelope *env;
811  char *data_tmp;
812  size_t attrs_len;
813 
814  if (GNUNET_OK != success)
815  {
816  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
817  }
820  "Sending CONSUME_TICKET_RESULT message\n");
821  env = GNUNET_MQ_msg_extra (crm,
822  attrs_len,
824  crm->id = htonl (cop->r_id);
825  crm->attrs_len = htons (attrs_len);
826  crm->identity = *identity;
827  crm->result = htonl (success);
828  data_tmp = (char *) &crm[1];
829  GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp);
830  GNUNET_MQ_send (cop->client->mq, env);
832  cop->client->consume_op_tail,
833  cop);
834  GNUNET_free (cop);
835 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Attribute list is returned from the idp.
Definition: reclaim.h:404
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:414
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint32_t result
Result.
Definition: reclaim.h:419
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct IdpClient * client
Client connection.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:434
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:424
#define GNUNET_log(kind,...)
Handle for ticket consume request.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result)
Serialize an attribute list.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_consume_ticket_message()

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

Check a consume ticket message.

Parameters
clsunused
cmthe message to handle

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

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

846 {
847  uint16_t size;
848 
849  size = ntohs (cm->header.size);
850  if (size != sizeof(struct ConsumeTicketMessage))
851  {
852  GNUNET_break (0);
853  return GNUNET_SYSERR;
854  }
855  return GNUNET_OK;
856 }
Ticket consume message.
Definition: reclaim.h:378
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:383

◆ handle_consume_ticket_message()

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

Handle a consume ticket message.

Parameters
clsour client handle the message to handle

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

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

867 {
868  struct ConsumeTicketOperation *cop;
869  struct IdpClient *idp = cls;
870 
871  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
872  cop = GNUNET_new (struct ConsumeTicketOperation);
873  cop->r_id = ntohl (cm->id);
874  cop->client = idp;
875  cop->ch
877  cop);
880 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void consume_result_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, int32_t success, const char *emsg)
Handle a ticket consume result.
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
An idp client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:393
struct IdpClient * client
Client connection.
struct RECLAIM_TICKETS_ConsumeHandle * ch
Ticket consume handle.
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:398
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
#define GNUNET_log(kind,...)
Handle for ticket consume request.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:388
Here is the call graph for this function:

◆ attr_store_cont()

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

Attribute store result handler.

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

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

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

Referenced by attr_store_task().

897 {
898  struct AttributeStoreHandle *ash = cls;
899  struct GNUNET_MQ_Envelope *env;
900  struct SuccessResultMessage *acr_msg;
901 
902  ash->ns_qe = NULL;
904  ash->client->store_op_tail,
905  ash);
906 
907  if (GNUNET_SYSERR == success)
908  {
910  "Failed to store attribute %s\n",
911  emsg);
912  cleanup_as_handle (ash);
914  return;
915  }
916 
917  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
919  acr_msg->id = htonl (ash->r_id);
920  acr_msg->op_result = htonl (GNUNET_OK);
921  GNUNET_MQ_send (ash->client->mq, env);
922  cleanup_as_handle (ash);
923 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
uint32_t r_id
request id
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
Attribute store/delete response message.
Definition: reclaim.h:103
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_log(kind,...)
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
static void do_shutdown(void *cls)
Shutdown task.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_store_task()

static void attr_store_task ( void *  cls)
static

Add a new attribute.

Parameters
clsthe AttributeStoreHandle

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

References attr_store_cont(), buf, AttributeStoreHandle::claim, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, AttributeStoreHandle::exp, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_log, GNUNET_malloc, GNUNET_NAMESTORE_records_store(), GNUNET_RECLAIM_ATTRIBUTE_serialize(), GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, AttributeStoreHandle::identity, AttributeStoreHandle::ns_qe, GNUNET_GNSRECORD_Data::record_type, and GNUNET_TIME_Relative::rel_value_us.

Referenced by handle_attribute_store_message().

933 {
934  struct AttributeStoreHandle *ash = cls;
935  struct GNUNET_GNSRECORD_Data rd[1];
936  char *buf;
937  char *label;
938  size_t buf_size;
939 
940  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
942  buf = GNUNET_malloc (buf_size);
943  // Give the ash a new id if unset
944  if (0 == ash->claim->id)
945  ash->claim->id
948  label
949  = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof(uint64_t));
950  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
951 
952  rd[0].data_size = buf_size;
953  rd[0].data = buf;
954  rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR;
956  rd[0].expiration_time = ash->exp.rel_value_us;
958  &ash->identity,
959  label,
960  1,
961  rd,
963  ash);
964  GNUNET_free (buf);
965  GNUNET_free (label);
966 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
uint64_t rel_value_us
The actual value.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
static void attr_store_cont(void *cls, int32_t success, const char *emsg)
Attribute store result handler.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to store.
Handle for attribute store request.
static char buf[2048]
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
This flag is currently unused; former RF_PENDING flag.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_attribute_store_message()

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

Check an attribute store message.

Parameters
clsunused
samthe message to check

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

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

978 {
979  uint16_t size;
980 
981  size = ntohs (sam->header.size);
982  if (size <= sizeof(struct AttributeStoreMessage))
983  {
984  GNUNET_break (0);
985  return GNUNET_SYSERR;
986  }
987  return GNUNET_OK;
988 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Use to store an identity attribute.
Definition: reclaim.h:40
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_attribute_store_message()

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

Handle an attribute store message.

Parameters
clsour client
samthe message to handle

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

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

1000 {
1001  struct AttributeStoreHandle *ash;
1002  struct IdpClient *idp = cls;
1003  size_t data_len;
1004 
1005  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1006 
1007  data_len = ntohs (sam->attr_len);
1008 
1009  ash = GNUNET_new (struct AttributeStoreHandle);
1010  ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &sam[1],
1011  data_len);
1012 
1013  ash->r_id = ntohl (sam->id);
1014  ash->identity = sam->identity;
1015  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1017 
1019  ash->client = idp;
1022 }
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:65
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
struct GNUNET_SERVICE_Client * client
The client.
uint32_t r_id
request id
static void attr_store_task(void *cls)
Add a new attribute.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to store.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
Handle for attribute store request.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
struct IdpClient * client
Client connection.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:55
struct GNUNET_CRYPTO_EcdsaPublicKey identity_pkey
Identity pubkey.
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:60
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:239
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
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 1032 of file gnunet-service-reclaim.c.

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

Referenced by attr_delete_cont(), ticket_iter_err(), and update_tickets().

1033 {
1034  struct GNUNET_MQ_Envelope *env;
1035  struct SuccessResultMessage *acr_msg;
1036 
1038  adh->client->delete_op_tail,
1039  adh);
1040 
1041  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1043  acr_msg->id = htonl (adh->r_id);
1044  acr_msg->op_result = htonl (success);
1045  GNUNET_MQ_send (adh->client->mq, env);
1046 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
Attribute store/delete response message.
Definition: reclaim.h:103
struct IdpClient * client
Client connection.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_log(kind,...)
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_iter()

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

Namestore iteration within attribute deletion.

We need to reissue tickets with the deleted attribute removed.

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

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

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

Referenced by start_ticket_update().

1065 {
1066  struct AttributeDeleteHandle *adh = cls;
1067  struct TicketRecordsEntry *le;
1068  int has_changed = GNUNET_NO;
1069 
1070  for (int i = 0; i < rd_count; i++)
1071  {
1072  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1073  continue;
1074  if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))
1075  continue;
1077  "Attribute to delete found (%s)\n",
1078  adh->label);
1079  has_changed = GNUNET_YES;
1080  break;
1081  }
1082  if (GNUNET_YES == has_changed)
1083  {
1084  le = GNUNET_new (struct TicketRecordsEntry);
1085  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
1086  le->data = GNUNET_malloc (le->data_size);
1087  le->rd_count = rd_count;
1088  le->label = GNUNET_strdup (label);
1089  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
1092  le);
1093  }
1095 }
Handle for attribute deletion request.
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
unsigned int rd_count
Record count.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
char * label
Attribute label.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

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

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

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

1132 {
1133  struct AttributeDeleteHandle *adh = cls;
1134  struct TicketRecordsEntry *le;
1135 
1136  if (NULL == adh->tickets_to_update_head)
1137  {
1139  "Finished updatding tickets, success\n");
1141  cleanup_adh (adh);
1142  return;
1143  }
1145  "Updating %s\n",
1147  le = adh->tickets_to_update_head;
1150  le);
1151  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1152  struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1154  le->data,
1155  le->rd_count,
1156  rd))
1157  {
1159  "Unable to deserialize record data!\n");
1161  cleanup_adh (adh);
1162  return;
1163  }
1164  int j = 0;
1165  for (int i = 0; i < le->rd_count; i++)
1166  {
1168  && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))))
1169  continue;
1170  rd_new[j] = rd[i];
1171  j++;
1172  }
1174  &adh->identity,
1175  le->label,
1176  j,
1177  rd_new,
1178  &ticket_updated,
1179  adh);
1180  GNUNET_free (le->label);
1181  GNUNET_free (le->data);
1182  GNUNET_free (le);
1183 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle for attribute deletion request.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
unsigned int rd_count
Record count.
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static void ticket_updated(void *cls, int32_t success, const char *emsg)
Callback called when a ticket was updated.
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_updated()

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

Callback called when a ticket was updated.

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

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

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

Referenced by update_tickets().

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

◆ ticket_iter_fin()

static void ticket_iter_fin ( void *  cls)
static

Done collecting affected tickets, start updating.

Parameters
clsour attribute deletion handle

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

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

Referenced by start_ticket_update().

1193 {
1194  struct AttributeDeleteHandle *adh = cls;
1195 
1196  adh->ns_it = NULL;
1198 }
Handle for attribute deletion request.
static void update_tickets(void *cls)
Recursion prototype for function.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_iter_err()

static void ticket_iter_err ( void *  cls)
static

Error collecting affected tickets.

Abort.

Parameters
clsour attribute deletion handle

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

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

Referenced by start_ticket_update().

1208 {
1209  struct AttributeDeleteHandle *adh = cls;
1210 
1211  adh->ns_it = NULL;
1213  "Namestore error on delete %s\n",
1214  adh->label);
1216  cleanup_adh (adh);
1217 }
Handle for attribute deletion request.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
char * label
Attribute label.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_ticket_update()

static void start_ticket_update ( void *  cls)
static

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

Parameters
clsattribute deletion handle

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

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

Referenced by attr_delete_cont().

1228 {
1229  struct AttributeDeleteHandle *adh = cls;
1230 
1232  &adh->identity,
1233  &ticket_iter_err,
1234  adh,
1235  &ticket_iter,
1236  adh,
1237  &ticket_iter_fin,
1238  adh);
1239 }
Handle for attribute deletion request.
static void ticket_iter_err(void *cls)
Error collecting affected tickets.
static void ticket_iter(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Namestore iteration within attribute deletion.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
static void ticket_iter_fin(void *cls)
Done collecting affected tickets, start updating.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_delete_cont()

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

Attribute deleted callback.

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

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

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

Referenced by handle_attribute_delete_message().

1251 {
1252  struct AttributeDeleteHandle *adh = cls;
1253 
1254  adh->ns_qe = NULL;
1255  if (GNUNET_SYSERR == success)
1256  {
1258  "Error deleting attribute %s\n",
1259  adh->label);
1261  cleanup_adh (adh);
1262  return;
1263  }
1264  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1266 }
Handle for attribute deletion request.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static void start_ticket_update(void *cls)
Start processing tickets which may still contain reference to deleted attribute.
char * label
Attribute label.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_attribute_delete_message()

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

Check attribute delete message format.

unused message to check

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

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

1278 {
1279  uint16_t size;
1280 
1281  size = ntohs (dam->header.size);
1282  if (size <= sizeof(struct AttributeDeleteMessage))
1283  {
1284  GNUNET_break (0);
1285  return GNUNET_SYSERR;
1286  }
1287  return GNUNET_OK;
1288 }
Use to delete an identity attribute.
Definition: reclaim.h:74
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:79
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_attribute_delete_message()

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

Handle attribute deletion.

Parameters
clsour client
damdeletion message

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

References attr_delete_cont(), AttributeDeleteMessage::attr_len, AttributeDeleteHandle::claim, IdpClient::client, AttributeDeleteHandle::client, IdpClient::delete_op_head, IdpClient::delete_op_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_records_store(), GNUNET_new, GNUNET_RECLAIM_ATTRIBUTE_deserialize(), GNUNET_SERVICE_client_continue(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, AttributeDeleteHandle::identity, AttributeDeleteHandle::label, AttributeDeleteHandle::ns_qe, and AttributeDeleteHandle::r_id.

1300 {
1301  struct AttributeDeleteHandle *adh;
1302  struct IdpClient *idp = cls;
1303  size_t data_len;
1304 
1305  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1306 
1307  data_len = ntohs (dam->attr_len);
1308 
1309  adh = GNUNET_new (struct AttributeDeleteHandle);
1310  adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1],
1311  data_len);
1312 
1313  adh->r_id = ntohl (dam->id);
1314  adh->identity = dam->identity;
1315  adh->label
1316  = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof(uint64_t));
1318  adh->client = idp;
1321  &adh->identity,
1322  adh->label,
1323  0,
1324  NULL,
1326  adh);
1327 }
Handle for attribute deletion request.
static void attr_delete_cont(void *cls, int32_t success, const char *emsg)
Attribute deleted callback.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:94
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
char * label
Attribute label.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84
struct IdpClient * client
Client connection.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
#define GNUNET_log(kind,...)
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
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 1341 of file gnunet-service-reclaim.c.

References ai, IdpClient::attr_iter_head, IdpClient::attr_iter_tail, AttributeResultMessage::attr_len, AttributeIterator::client, env, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), AttributeResultMessage::id, IdpClient::mq, and AttributeIterator::request_id.

Referenced by attr_iter_error(), and handle_iteration_start().

1342 {
1343  struct AttributeIterator *ai = cls;
1344  struct GNUNET_MQ_Envelope *env;
1345  struct AttributeResultMessage *arm;
1346 
1347  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1349  arm->id = htonl (ai->request_id);
1350  arm->attr_len = htons (0);
1351  GNUNET_MQ_send (ai->client->mq, env);
1353  ai->client->attr_iter_tail,
1354  ai);
1355  GNUNET_free (ai);
1356 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
#define GNUNET_log(kind,...)
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct IdpClient * client
IDP client which intiated this zone iteration.
An attribute iteration operation.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_iter_error()

static void attr_iter_error ( void *  cls)
static

Error iterating over attributes.

Abort.

Parameters
clsour attribute iteration handle

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

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

Referenced by handle_iteration_start().

1366 {
1367  struct AttributeIterator *ai = cls;
1368 
1369  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
1370  attr_iter_finished (ai);
1371 }
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
static void attr_iter_finished(void *cls)
Done iterating over attributes.
An attribute iteration operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_iter_cb()

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

Got record.

Return if it is an attribute.

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

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

References ai, AttributeResultMessage::attr_len, AttributeIterator::client, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, env, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAMESTORE_zone_iterator_next(), AttributeResultMessage::id, AttributeResultMessage::identity, IdpClient::mq, AttributeIterator::ns_it, GNUNET_GNSRECORD_Data::record_type, and AttributeIterator::request_id.

Referenced by handle_iteration_start().

1389 {
1390  struct AttributeIterator *ai = cls;
1391  struct AttributeResultMessage *arm;
1392  struct GNUNET_MQ_Envelope *env;
1393  char *data_tmp;
1394 
1395  if (rd_count != 1)
1396  {
1398  return;
1399  }
1400 
1402  {
1404  return;
1405  }
1406  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label);
1407  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1408  env = GNUNET_MQ_msg_extra (arm,
1409  rd->data_size,
1411  arm->id = htonl (ai->request_id);
1412  arm->attr_len = htons (rd->data_size);
1414  data_tmp = (char *) &arm[1];
1415  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
1416  GNUNET_MQ_send (ai->client->mq, env);
1417 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
size_t data_size
Number of bytes in data.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
const void * data
Binary value stored in the DNS record.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:239
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t record_type
Type of the GNS/DNS record.
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
#define GNUNET_log(kind,...)
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:149
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct IdpClient * client
IDP client which intiated this zone iteration.
An attribute iteration operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_iteration_start()

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

Iterate over zone to get attributes.

Parameters
clsour client
ais_msgthe iteration message to start

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

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

1429 {
1430  struct IdpClient *idp = cls;
1431  struct AttributeIterator *ai;
1432 
1434  "Received ATTRIBUTE_ITERATION_START message\n");
1435  ai = GNUNET_new (struct AttributeIterator);
1436  ai->request_id = ntohl (ais_msg->id);
1437  ai->client = idp;
1438  ai->identity = ais_msg->identity;
1439 
1442  &ai->identity,
1443  &attr_iter_error,
1444  ai,
1445  &attr_iter_cb,
1446  ai,
1448  ai);
1450 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
static void attr_iter_error(void *cls)
Error iterating over attributes.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Key of the zone we are iterating over.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:175
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:170
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
static void attr_iter_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
static void attr_iter_finished(void *cls)
Done iterating over attributes.
struct IdpClient * client
IDP client which intiated this zone iteration.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
An attribute iteration operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
Here is the call graph for this function:

◆ handle_iteration_stop()

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

Handle iteration stop message from client.

Parameters
clsthe client
ais_msgthe stop message

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

References ai, IdpClient::attr_iter_head, IdpClient::attr_iter_tail, IdpClient::client, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), AttributeIterationStopMessage::id, AttributeIterator::next, and AttributeIterator::request_id.

1462 {
1463  struct IdpClient *idp = cls;
1464  struct AttributeIterator *ai;
1465  uint32_t rid;
1466 
1468  "Received `%s' message\n",
1469  "ATTRIBUTE_ITERATION_STOP");
1470  rid = ntohl (ais_msg->id);
1471  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1472  if (ai->request_id == rid)
1473  break;
1474  if (NULL == ai)
1475  {
1476  GNUNET_break (0);
1478  return;
1479  }
1481  GNUNET_free (ai);
1483 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
An idp client.
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SERVICE_Client * client
The client.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:209
struct AttributeIterator * next
Next element in the DLL.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
An attribute iteration operation.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ handle_iteration_next()

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

Client requests next attribute from iterator.

Parameters
clsthe client
ais_msgthe message

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

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

1495 {
1496  struct IdpClient *idp = cls;
1497  struct AttributeIterator *ai;
1498  uint32_t rid;
1499 
1501  "Received ATTRIBUTE_ITERATION_NEXT message\n");
1502  rid = ntohl (ais_msg->id);
1503  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1504  if (ai->request_id == rid)
1505  break;
1506  if (NULL == ai)
1507  {
1508  GNUNET_break (0);
1510  return;
1511  }
1514 }
An idp client.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SERVICE_Client * client
The client.
struct AttributeIterator * next
Next element in the DLL.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:192
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_log(kind,...)
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
An attribute iteration operation.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
Here is the call graph for this function:

◆ ticket_iter_cb()

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

Got a ticket.

Return to client

Parameters
clsour ticket iterator
ticketthe ticket

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

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

Referenced by handle_ticket_iteration_start().

1529 {
1530  struct TicketIteration *ti = cls;
1531  struct GNUNET_MQ_Envelope *env;
1532  struct TicketResultMessage *trm;
1533 
1535  if (NULL == ticket)
1536  {
1537  /* send empty response to indicate end of list */
1539  ti->client->ticket_iter_tail,
1540  ti);
1541  }
1542  else
1543  {
1544  trm->ticket = *ticket;
1545  }
1546  trm->id = htonl (ti->r_id);
1547  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
1548  GNUNET_MQ_send (ti->client->mq, env);
1549  if (NULL == ticket)
1550  GNUNET_free (ti);
1551 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:367
Ticket result message.
Definition: reclaim.h:357
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:372
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint32_t r_id
The operation id fot the iteration in the response for the client.
struct IdpClient * client
Client which intiated this zone iteration.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
A ticket iteration operation.
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_ticket_iteration_start()

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

Client requests a ticket iteration.

Parameters
clsthe client
tis_msgthe iteration request message

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

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

1564 {
1565  struct IdpClient *client = cls;
1566  struct TicketIteration *ti;
1567 
1569  "Received TICKET_ITERATION_START message\n");
1570  ti = GNUNET_new (struct TicketIteration);
1571  ti->r_id = ntohl (tis_msg->id);
1572  ti->client = client;
1573 
1575  client->ticket_iter_tail,
1576  ti);
1577  ti->iter
1580 }
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:230
An idp client.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t r_id
The operation id fot the iteration in the response for the client.
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
struct IdpClient * client
Client which intiated this zone iteration.
struct GNUNET_SERVICE_Client * client
The client.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
A ticket iteration operation.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:225
#define GNUNET_log(kind,...)
static void ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Got a ticket.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Here is the call graph for this function:

◆ handle_ticket_iteration_stop()

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

Client has had enough tickets.

Parameters
clsthe client
tis_msgthe stop message

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

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

1592 {
1593  struct IdpClient *client = cls;
1594  struct TicketIteration *ti;
1595  uint32_t rid;
1596 
1598  "Received `%s' message\n",
1599  "TICKET_ITERATION_STOP");
1600  rid = ntohl (tis_msg->id);
1601  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1602  if (ti->r_id == rid)
1603  break;
1604  if (NULL == ti)
1605  {
1606  GNUNET_break (0);
1608  return;
1609  }
1612  client->ticket_iter_tail,
1613  ti);
1614  GNUNET_free (ti);
1616 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
An idp client.
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
uint32_t r_id
The operation id fot the iteration in the response for the client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SERVICE_Client * client
The client.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
struct TicketIteration * next
DLL.
A ticket iteration operation.
#define GNUNET_log(kind,...)
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:264
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ handle_ticket_iteration_next()

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

Client requests next result.

Parameters
clsthe client
tis_msgthe message

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

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

1628 {
1629  struct IdpClient *client = cls;
1630  struct TicketIteration *ti;
1631  uint32_t rid;
1632 
1634  "Received TICKET_ITERATION_NEXT message\n");
1635  rid = ntohl (tis_msg->id);
1636  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1637  if (ti->r_id == rid)
1638  break;
1639  if (NULL == ti)
1640  {
1641  GNUNET_break (0);
1643  return;
1644  }
1647 }
An idp client.
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
uint32_t r_id
The operation id fot the iteration in the response for the client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SERVICE_Client * client
The client.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:247
void RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
Continue ticket iteration.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
struct TicketIteration * next
DLL.
A ticket iteration operation.
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Here is the call graph for this function:

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

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

Referenced by client_connect_cb().

1661 {
1662  cfg = c;
1663 
1665  {
1667  "Unable to initialize TICKETS subsystem.\n");
1669  return;
1670  }
1671  // Connect to identity and namestore services
1673  if (NULL == nsh)
1674  {
1676  "error connecting to namestore");
1677  }
1678 
1680 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
static void do_shutdown(void *cls)
Shutdown task.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
Here is the call graph for this function:
Here is the caller 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 1691 of file gnunet-service-reclaim.c.

References cleanup_client(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.

Referenced by client_connect_cb().

1694 {
1695  struct IdpClient *idp = app_ctx;
1696 
1697  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1700  idp);
1701  cleanup_client (idp);
1702 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
An idp client.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.
static struct IdpClient * client_list_head
Client list.
#define GNUNET_log(kind,...)
static struct IdpClient * client_list_tail
Client list.
Here is the call graph for this function:
Here is the caller 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 1714 of file gnunet-service-reclaim.c.

References TicketIteration::client, IdpClient::client, client_disconnect_cb(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, iteration_start(), mq, IdpClient::mq, and run().

1717 {
1718  struct IdpClient *idp;
1719 
1720  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1721  idp = GNUNET_new (struct IdpClient);
1722  idp->client = client;
1723  idp->mq = mq;
1726  idp);
1727  return idp;
1728 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
An idp client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SERVICE_Client * client
The client.
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
static struct IdpClient * client_list_head
Client list.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
static struct IdpClient * client_list_tail
Client list.
Here is the call graph for this function:

◆ 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(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, struct AttributeIterationStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, struct AttributeIterationNextMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, struct AttributeIterationStopMessage, NULL)  ,
GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL)  ,
GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL)  ,
GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Referenced by client_connect_cb().

Here is the caller graph for this function:

Variable Documentation

◆ nsh

struct GNUNET_NAMESTORE_Handle* nsh
static

Namestore handle.

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

◆ timeout_task

struct GNUNET_SCHEDULER_Task* timeout_task
static

Timeout task.

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

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

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

◆ client_list_head

struct IdpClient* client_list_head = NULL
static

Client list.

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

◆ client_list_tail

struct IdpClient* client_list_tail = NULL
static

Client list.

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