GNUnet  0.11.x
Data Structures | Macros | Functions
reclaim_api.c File Reference

api to interact with the reclaim service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_mq_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_reclaim_lib.h"
#include "gnunet_reclaim_service.h"
#include "reclaim.h"
Include dependency graph for reclaim_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_RECLAIM_Operation
 Handle for an operation with the service. More...
 
struct  GNUNET_RECLAIM_TicketIterator
 Handle for a ticket iterator operation. More...
 
struct  GNUNET_RECLAIM_AttributeIterator
 Handle for a attribute iterator operation. More...
 
struct  GNUNET_RECLAIM_CredentialIterator
 Handle for a credential iterator operation. More...
 
struct  GNUNET_RECLAIM_Handle
 Handle to the service. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)
 

Functions

static void reconnect (struct GNUNET_RECLAIM_Handle *h)
 Try again to connect to the service. More...
 
static void reconnect_task (void *cls)
 Reconnect. More...
 
static void force_reconnect (struct GNUNET_RECLAIM_Handle *handle)
 Disconnect from service and then reconnect. More...
 
static void free_it (struct GNUNET_RECLAIM_AttributeIterator *it)
 Free it. More...
 
static void free_ait (struct GNUNET_RECLAIM_CredentialIterator *ait)
 Free it. More...
 
static void free_op (struct GNUNET_RECLAIM_Operation *op)
 Free op. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void handle_success_response (void *cls, const struct SuccessResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE. More...
 
static int check_consume_ticket_result (void *cls, const struct ConsumeTicketResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT. More...
 
static void handle_consume_ticket_result (void *cls, const struct ConsumeTicketResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT. More...
 
static int check_attribute_result (void *cls, const struct AttributeResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT. More...
 
static void handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT. More...
 
static int check_credential_result (void *cls, const struct CredentialResultMessage *msg)
 Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT. More...
 
static void handle_credential_result (void *cls, const struct CredentialResultMessage *msg)
 Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT. More...
 
static int check_ticket_result (void *cls, const struct TicketResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT. More...
 
static void handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT. More...
 
static void handle_revoke_ticket_result (void *cls, const struct RevokeTicketResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT. More...
 
struct GNUNET_RECLAIM_HandleGNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the reclaim service. More...
 
void GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op)
 Cancel an operation. More...
 
void GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h)
 Disconnect from service. More...
 
struct GNUNET_RECLAIM_OperationGNUNET_RECLAIM_attribute_store (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
 Store an attribute. More...
 
struct GNUNET_RECLAIM_OperationGNUNET_RECLAIM_attribute_delete (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
 Delete an attribute. More...
 
struct GNUNET_RECLAIM_OperationGNUNET_RECLAIM_credential_store (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
 Store an credential. More...
 
struct GNUNET_RECLAIM_OperationGNUNET_RECLAIM_credential_delete (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
 Delete an credential. More...
 
struct GNUNET_RECLAIM_AttributeIteratorGNUNET_RECLAIM_get_attributes_start (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
 List all attributes for a local identity. More...
 
void GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it)
 Calls the record processor specified in GNUNET_RECLAIM_get_attributes_start for the next record. More...
 
void GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it)
 Stops iteration and releases the handle for further calls. More...
 
struct GNUNET_RECLAIM_CredentialIteratorGNUNET_RECLAIM_get_credentials_start (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_CredentialResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
 List all credentials for a local identity. More...
 
void GNUNET_RECLAIM_get_credentials_next (struct GNUNET_RECLAIM_CredentialIterator *ait)
 Calls the record processor specified in #GNUNET_RECLAIM_get_credential_start for the next record. More...
 
void GNUNET_RECLAIM_get_credentials_stop (struct GNUNET_RECLAIM_CredentialIterator *ait)
 Stops iteration and releases the handle for further calls. More...
 
struct GNUNET_RECLAIM_OperationGNUNET_RECLAIM_ticket_issue (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *iss, const struct GNUNET_IDENTITY_PublicKey *rp, const struct GNUNET_RECLAIM_AttributeList *attrs, GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls)
 Issues a ticket to another relying party. More...
 
struct GNUNET_RECLAIM_OperationGNUNET_RECLAIM_ticket_consume (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls)
 Consumes an issued ticket. More...
 
struct GNUNET_RECLAIM_TicketIteratorGNUNET_RECLAIM_ticket_iteration_start (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
 Lists all tickets that have been issued to remote identites (relying parties) More...
 
void GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it)
 Calls the ticket processor specified in GNUNET_RECLAIM_ticket_iteration_start for the next record. More...
 
void GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it)
 Stops iteration and releases the handle for further calls. More...
 
struct GNUNET_RECLAIM_OperationGNUNET_RECLAIM_ticket_revoke (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
 Revoked an issued ticket. More...
 

Detailed Description

api to interact with the reclaim service

Author
Martin Schanzenbach

Definition in file reclaim_api.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)

Definition at line 35 of file reclaim_api.c.

Function Documentation

◆ reconnect()

static void reconnect ( struct GNUNET_RECLAIM_Handle h)
static

Try again to connect to the service.

Parameters
hhandle to the reclaim service.

Definition at line 1014 of file reclaim_api.c.

1015 {
1017  { GNUNET_MQ_hd_fixed_size (success_response,
1019  struct SuccessResultMessage,
1020  h),
1021  GNUNET_MQ_hd_var_size (attribute_result,
1023  struct AttributeResultMessage,
1024  h),
1025  GNUNET_MQ_hd_var_size (credential_result,
1027  struct CredentialResultMessage,
1028  h),
1029  GNUNET_MQ_hd_var_size (ticket_result,
1031  struct TicketResultMessage,
1032  h),
1033  GNUNET_MQ_hd_var_size (consume_ticket_result,
1036  h),
1037  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1040  h),
1041  GNUNET_MQ_handler_end () };
1042  struct GNUNET_RECLAIM_Operation *op;
1043 
1044  GNUNET_assert (NULL == h->mq);
1045  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1046 
1047  h->mq =
1049  if (NULL == h->mq)
1050  return;
1051  for (op = h->op_head; NULL != op; op = op->next)
1052  GNUNET_MQ_send_copy (h->mq, op->env);
1053 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1064
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
Definition: mq.c:443
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: reclaim_api.c:508
#define LOG(kind,...)
Definition: reclaim_api.c:35
Attribute is returned from the idp.
Definition: reclaim.h:125
Attribute list is returned from the idp.
Definition: reclaim.h:508
Credential is returned from the idp.
Definition: reclaim.h:165
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_ARM_Operation * next
This is a doubly-linked list.
Definition: arm_api.c:45
Message handler for a specific message type.
Handle for an operation with the service.
Definition: reclaim_api.c:42
Ticket revoke message.
Definition: reclaim.h:432
Attribute store/delete response message.
Definition: reclaim.h:104
Ticket result message.
Definition: reclaim.h:454

References GNUNET_ARM_Handle::cfg, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_send_copy(), h, handlers, LOG, GNUNET_ARM_Handle::mq, mq_error_handler(), GNUNET_ARM_Operation::next, and op.

Referenced by GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_ticket_consume(), and reconnect_task().

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

◆ reconnect_task()

static void reconnect_task ( void *  cls)
static

Reconnect.

Parameters
clsthe handle

Definition at line 421 of file reclaim_api.c.

422 {
423  struct GNUNET_RECLAIM_Handle *handle = cls;
424 
425  handle->reconnect_task = NULL;
426  reconnect (handle);
427 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:1014
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
Definition: dns_api.c:81
Handle to the service.
Definition: reclaim_api.c:318

References handle, reconnect(), and GNUNET_DNS_Handle::reconnect_task.

Referenced by force_reconnect().

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

◆ force_reconnect()

static void force_reconnect ( struct GNUNET_RECLAIM_Handle handle)
static

Disconnect from service and then reconnect.

Parameters
handleour service

Definition at line 436 of file reclaim_api.c.

437 {
439  handle->mq = NULL;
440  handle->reconnect_backoff =
441  GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
443  GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
445  handle);
446 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:421
struct GNUNET_MQ_Handle * mq
Connection to DNS service, or NULL.
Definition: dns_api.c:61

References GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, handle, GNUNET_DNS_Handle::mq, GNUNET_DNS_Handle::reconnect_task, and reconnect_task().

Referenced by handle_attribute_result(), handle_credential_result(), and mq_error_handler().

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

◆ free_it()

static void free_it ( struct GNUNET_RECLAIM_AttributeIterator it)
static

Free it.

Parameters
itentry to free

Definition at line 455 of file reclaim_api.c.

456 {
457  struct GNUNET_RECLAIM_Handle *h = it->h;
458 
459  GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it);
460  if (NULL != it->env)
461  GNUNET_MQ_discard (it->env);
462  GNUNET_free (it);
463 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:323
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:197
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:233

References GNUNET_RECLAIM_AttributeIterator::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), h, and GNUNET_RECLAIM_AttributeIterator::h.

Referenced by GNUNET_RECLAIM_get_attributes_stop(), and handle_attribute_result().

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

◆ free_ait()

static void free_ait ( struct GNUNET_RECLAIM_CredentialIterator ait)
static

Free it.

Parameters
aitentry to free

Definition at line 472 of file reclaim_api.c.

473 {
474  struct GNUNET_RECLAIM_Handle *h = ait->h;
475 
476  GNUNET_CONTAINER_DLL_remove (h->ait_head, h->ait_tail, ait);
477  if (NULL != ait->env)
478  GNUNET_MQ_discard (ait->env);
479  GNUNET_free (ait);
480 }
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:300
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:264

References GNUNET_RECLAIM_CredentialIterator::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), h, and GNUNET_RECLAIM_CredentialIterator::h.

Referenced by GNUNET_RECLAIM_get_credentials_stop(), and handle_credential_result().

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

◆ free_op()

static void free_op ( struct GNUNET_RECLAIM_Operation op)
static

Free op.

Parameters
opthe operation to free

Definition at line 489 of file reclaim_api.c.

490 {
491  if (NULL == op)
492  return;
493  if (NULL != op->env)
494  GNUNET_MQ_discard (op->env);
495  GNUNET_free (op);
496 }

References GNUNET_free, GNUNET_MQ_discard(), and op.

Referenced by GNUNET_RECLAIM_cancel(), handle_attribute_result(), handle_consume_ticket_result(), handle_credential_result(), handle_revoke_ticket_result(), handle_success_response(), and handle_ticket_result().

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

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_GNS_Handle *
errorerror code

Definition at line 508 of file reclaim_api.c.

509 {
510  struct GNUNET_RECLAIM_Handle *handle = cls;
511 
513 }
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:436

References force_reconnect(), and handle.

Referenced by reconnect().

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

◆ handle_success_response()

static void handle_success_response ( void *  cls,
const struct SuccessResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE.

Parameters
cls
msgthe message we received

Definition at line 524 of file reclaim_api.c.

525 {
526  struct GNUNET_RECLAIM_Handle *h = cls;
528  uint32_t r_id = ntohl (msg->id);
529  int res;
530  const char *emsg;
531 
532  for (op = h->op_head; NULL != op; op = op->next)
533  if (op->r_id == r_id)
534  break;
535  if (NULL == op)
536  return;
537 
538  res = ntohl (msg->op_result);
540  "Received SUCCESS_RESPONSE with result %d\n",
541  res);
542 
543  /* TODO: add actual error message to response... */
544  if (GNUNET_SYSERR == res)
545  emsg = _ ("failed to store record\n");
546  else
547  emsg = NULL;
548  if (NULL != op->as_cb)
549  op->as_cb (op->cls, res, emsg);
550  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
551  free_op (op);
552 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static int res
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
uint32_t r_id
request id
Definition: reclaim_api.c:107

References _, free_op(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SYSERR, h, LOG, msg, GNUNET_ARM_Operation::next, op, GNUNET_RECLAIM_Operation::r_id, and res.

Here is the call graph for this function:

◆ check_consume_ticket_result()

static int check_consume_ticket_result ( void *  cls,
const struct ConsumeTicketResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT.

Parameters
cls
msgthe message we received
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 564 of file reclaim_api.c.

566 {
567  size_t msg_len;
568  size_t attrs_len;
569  size_t pl_len;
570 
571  msg_len = ntohs (msg->header.size);
572  attrs_len = ntohs (msg->attrs_len);
573  pl_len = ntohs (msg->presentations_len);
574  if (msg_len !=
575  sizeof(struct ConsumeTicketResultMessage) + attrs_len + pl_len)
576  {
577  GNUNET_break (0);
578  return GNUNET_SYSERR;
579  }
580  return GNUNET_OK;
581 }
@ GNUNET_OK
Definition: gnunet_common.h:95
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ handle_consume_ticket_result()

static void handle_consume_ticket_result ( void *  cls,
const struct ConsumeTicketResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT.

Parameters
cls
msgthe message we received

Definition at line 592 of file reclaim_api.c.

594 {
595  struct GNUNET_RECLAIM_Handle *h = cls;
597  size_t attrs_len;
598  size_t pl_len;
599  uint32_t r_id = ntohl (msg->id);
600  char *read_ptr;
601 
602  attrs_len = ntohs (msg->attrs_len);
603  pl_len = ntohs (msg->presentations_len);
604  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
605 
606 
607  for (op = h->op_head; NULL != op; op = op->next)
608  if (op->r_id == r_id)
609  break;
610  if (NULL == op)
611  return;
612 
613  {
614  struct GNUNET_RECLAIM_AttributeList *attrs;
618  attrs =
619  GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len);
620  read_ptr = ((char *) &msg[1]) + attrs_len;
621  pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len);
622  if (NULL != op->atr_cb)
623  {
624  if (NULL == attrs)
625  {
626  op->atr_cb (op->cls, &msg->identity, NULL, NULL);
627  }
628  else
629  {
630  for (le = attrs->list_head; NULL != le; le = le->next)
631  {
632  if (GNUNET_NO ==
634  {
635  for (ple = pl->list_head; NULL != ple; ple = ple->next)
636  {
637  if (GNUNET_YES ==
639  &ple->presentation->credential_id))
640  {
641  op->atr_cb (op->cls, &msg->identity,
642  le->attribute, ple->presentation);
643  break;
644  }
645 
646  }
647  }
648  else // No credentials
649  {
650  op->atr_cb (op->cls, &msg->identity,
651  le->attribute, NULL);
652  }
653  }
654  }
655  op->atr_cb (op->cls, NULL, NULL, NULL);
656  }
657  if (NULL != attrs)
659  if (NULL != pl)
661  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
662  free_op (op);
663  return;
664  }
665  GNUNET_assert (0);
666 }
#define GNUNET_log(kind,...)
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
#define GNUNET_RECLAIM_id_is_equal(a, b)
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
#define GNUNET_RECLAIM_id_is_zero(a)
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize a presentation list.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
A list of GNUNET_RECLAIM_Presentation structures.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.

References GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_Attribute::credential, GNUNET_RECLAIM_Presentation::credential_id, free_op(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_RECLAIM_attribute_list_deserialize(), GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_id_is_equal, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_presentation_list_deserialize(), GNUNET_RECLAIM_presentation_list_destroy(), GNUNET_YES, h, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_PresentationList::list_head, msg, GNUNET_ARM_Operation::next, GNUNET_RECLAIM_AttributeListEntry::next, GNUNET_RECLAIM_PresentationListEntry::next, op, GNUNET_RECLAIM_PresentationListEntry::presentation, and GNUNET_RECLAIM_Operation::r_id.

Here is the call graph for this function:

◆ check_attribute_result()

static int check_attribute_result ( void *  cls,
const struct AttributeResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT.

Parameters
cls
msgthe message we received
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 678 of file reclaim_api.c.

679 {
680  size_t msg_len;
681  size_t attr_len;
682 
683  msg_len = ntohs (msg->header.size);
684  attr_len = ntohs (msg->attr_len);
685  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
686  {
687  GNUNET_break (0);
688  return GNUNET_SYSERR;
689  }
690  return GNUNET_OK;
691 }

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ handle_attribute_result()

static void handle_attribute_result ( void *  cls,
const struct AttributeResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT.

Parameters
cls
msgthe message we received

Definition at line 702 of file reclaim_api.c.

703 {
704  static struct GNUNET_IDENTITY_PrivateKey identity_dummy;
705  struct GNUNET_RECLAIM_Handle *h = cls;
708  size_t attr_len;
709  uint32_t r_id = ntohl (msg->id);
710 
711  attr_len = ntohs (msg->attr_len);
712  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
713 
714 
715  for (it = h->it_head; NULL != it; it = it->next)
716  if (it->r_id == r_id)
717  break;
718  for (op = h->op_head; NULL != op; op = op->next)
719  if (op->r_id == r_id)
720  break;
721  if ((NULL == it) && (NULL == op))
722  return;
723 
724  if ((0 ==
725  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
726  {
727  if ((NULL == it) && (NULL == op))
728  {
729  GNUNET_break (0);
730  force_reconnect (h);
731  return;
732  }
733  if (NULL != it)
734  {
735  if (NULL != it->finish_cb)
736  it->finish_cb (it->finish_cb_cls);
737  free_it (it);
738  }
739  if (NULL != op)
740  {
741  if (NULL != op->ar_cb)
742  op->ar_cb (op->cls, NULL, NULL);
743  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
744  free_op (op);
745  }
746  return;
747  }
748 
749  {
750  struct GNUNET_RECLAIM_Attribute *attr;
751  GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len,
752  &attr);
753  if (NULL != it)
754  {
755  if (NULL != it->proc)
756  it->proc (it->proc_cls, &msg->identity, attr);
757  }
758  else if (NULL != op)
759  {
760  if (NULL != op->ar_cb)
761  op->ar_cb (op->cls, &msg->identity, attr);
762  }
763  GNUNET_free (attr);
764  return;
765  }
766  GNUNET_assert (0);
767 }
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:455
A private key for an identity as per LSD0001.
Handle for a attribute iterator operation.
Definition: reclaim_api.c:183
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:212
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:217
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:202
struct GNUNET_RECLAIM_AttributeIterator * next
Kept in a DLL.
Definition: reclaim_api.c:187
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:243
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:207

References GNUNET_RECLAIM_AttributeIterator::finish_cb, GNUNET_RECLAIM_AttributeIterator::finish_cb_cls, force_reconnect(), free_it(), free_op(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_RECLAIM_attribute_deserialize(), h, LOG, msg, GNUNET_ARM_Operation::next, GNUNET_RECLAIM_AttributeIterator::next, op, GNUNET_RECLAIM_AttributeIterator::proc, GNUNET_RECLAIM_AttributeIterator::proc_cls, GNUNET_RECLAIM_Operation::r_id, and GNUNET_RECLAIM_AttributeIterator::r_id.

Here is the call graph for this function:

◆ check_credential_result()

static int check_credential_result ( void *  cls,
const struct CredentialResultMessage msg 
)
static

Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT.

Parameters
cls
msgthe message we received
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 779 of file reclaim_api.c.

780 {
781  size_t msg_len;
782  size_t cred_len;
783 
784  msg_len = ntohs (msg->header.size);
785  cred_len = ntohs (msg->credential_len);
786  if (msg_len != sizeof(struct CredentialResultMessage) + cred_len)
787  {
788  GNUNET_break (0);
789  return GNUNET_SYSERR;
790  }
791  return GNUNET_OK;
792 }

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ handle_credential_result()

static void handle_credential_result ( void *  cls,
const struct CredentialResultMessage msg 
)
static

Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT.

Parameters
cls
msgthe message we received

Definition at line 803 of file reclaim_api.c.

805 {
806  static struct GNUNET_IDENTITY_PrivateKey identity_dummy;
807  struct GNUNET_RECLAIM_Handle *h = cls;
810  size_t att_len;
811  uint32_t r_id = ntohl (msg->id);
812 
813  att_len = ntohs (msg->credential_len);
814  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
815 
816 
817  for (it = h->ait_head; NULL != it; it = it->next)
818  if (it->r_id == r_id)
819  break;
820  for (op = h->op_head; NULL != op; op = op->next)
821  if (op->r_id == r_id)
822  break;
823  if ((NULL == it) && (NULL == op))
824  return;
825 
826  if ((0 ==
827  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
828  {
829  if ((NULL == it) && (NULL == op))
830  {
831  GNUNET_break (0);
832  force_reconnect (h);
833  return;
834  }
835  if (NULL != it)
836  {
837  if (NULL != it->finish_cb)
838  it->finish_cb (it->finish_cb_cls);
839  free_ait (it);
840  }
841  if (NULL != op)
842  {
843  if (NULL != op->at_cb)
844  op->at_cb (op->cls, NULL, NULL);
845  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
846  free_op (op);
847  }
848  return;
849  }
850 
851  {
852  struct GNUNET_RECLAIM_Credential *att;
853  att = GNUNET_RECLAIM_credential_deserialize ((char *) &msg[1], att_len);
854 
855  if (NULL != it)
856  {
857  if (NULL != it->proc)
858  it->proc (it->proc_cls, &msg->identity, att);
859  }
860  else if (NULL != op)
861  {
862  if (NULL != op->at_cb)
863  op->at_cb (op->cls, &msg->identity, att);
864  }
865  GNUNET_free (att);
866  return;
867  }
868  GNUNET_assert (0);
869 }
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
static void free_ait(struct GNUNET_RECLAIM_CredentialIterator *ait)
Free it.
Definition: reclaim_api.c:472
Handle for a credential iterator operation.
Definition: reclaim_api.c:250
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:269
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:284
GNUNET_RECLAIM_CredentialResult proc
The continuation to call with the results.
Definition: reclaim_api.c:279
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:274
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:310
struct GNUNET_RECLAIM_CredentialIterator * next
Kept in a DLL.
Definition: reclaim_api.c:254

References GNUNET_RECLAIM_CredentialIterator::finish_cb, GNUNET_RECLAIM_CredentialIterator::finish_cb_cls, force_reconnect(), free_ait(), free_op(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_RECLAIM_credential_deserialize(), h, LOG, msg, GNUNET_ARM_Operation::next, GNUNET_RECLAIM_CredentialIterator::next, op, GNUNET_RECLAIM_CredentialIterator::proc, GNUNET_RECLAIM_CredentialIterator::proc_cls, GNUNET_RECLAIM_Operation::r_id, and GNUNET_RECLAIM_CredentialIterator::r_id.

Here is the call graph for this function:

◆ check_ticket_result()

static int check_ticket_result ( void *  cls,
const struct TicketResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT.

Parameters
cls
msgthe message we received
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 881 of file reclaim_api.c.

882 {
883  size_t msg_len;
884  size_t pres_len;
885 
886  msg_len = ntohs (msg->header.size);
887  pres_len = ntohs (msg->presentations_len);
888  if (msg_len != sizeof(struct TicketResultMessage) + pres_len)
889  {
890  GNUNET_break (0);
891  return GNUNET_SYSERR;
892  }
893  return GNUNET_OK;
894 }

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ handle_ticket_result()

static void handle_ticket_result ( void *  cls,
const struct TicketResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT.

Parameters
cls
msgthe message we received

Definition at line 905 of file reclaim_api.c.

906 {
907  struct GNUNET_RECLAIM_Handle *handle = cls;
910  struct GNUNET_RECLAIM_PresentationList *presentation;
911  uint32_t r_id = ntohl (msg->id);
912  static const struct GNUNET_RECLAIM_Ticket ticket;
913  uint32_t pres_len = ntohs (msg->presentations_len);
914 
915  for (op = handle->op_head; NULL != op; op = op->next)
916  if (op->r_id == r_id)
917  break;
918  for (it = handle->ticket_it_head; NULL != it; it = it->next)
919  if (it->r_id == r_id)
920  break;
921  if ((NULL == op) && (NULL == it))
922  return;
923  if (NULL != op)
924  {
925  if (0 < pres_len)
927  (char*) &msg[1],
928  pres_len);
929  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
930  if (0 ==
931  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
932  {
933  if (NULL != op->ti_cb)
934  op->ti_cb (op->cls, NULL, NULL);
935  }
936  else
937  {
938  if (NULL != op->ti_cb)
939  op->ti_cb (op->cls,
940  &msg->ticket,
941  (0 < pres_len) ? presentation : NULL);
942  }
943  if (0 < pres_len)
945  free_op (op);
946  return;
947  }
948  else if (NULL != it)
949  {
950  if (0 ==
951  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
952  {
953  GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
954  handle->ticket_it_tail,
955  it);
956  it->finish_cb (it->finish_cb_cls);
957  GNUNET_free (it);
958  }
959  else
960  {
961  if (NULL != it->tr_cb)
962  it->tr_cb (it->cls, &msg->ticket);
963  }
964  return;
965  }
966  GNUNET_break (0);
967 }
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
Handle for a ticket iterator operation.
Definition: reclaim_api.c:120
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:149
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:175
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:139
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:144
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:154
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:124
The authorization ticket.

References GNUNET_RECLAIM_TicketIterator::cls, GNUNET_RECLAIM_TicketIterator::finish_cb, GNUNET_RECLAIM_TicketIterator::finish_cb_cls, free_op(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_RECLAIM_presentation_list_deserialize(), GNUNET_RECLAIM_presentation_list_destroy(), handle, msg, GNUNET_ARM_Operation::next, GNUNET_RECLAIM_TicketIterator::next, op, GNUNET_RECLAIM_TicketIterator::r_id, ticket, and GNUNET_RECLAIM_TicketIterator::tr_cb.

Here is the call graph for this function:

◆ handle_revoke_ticket_result()

static void handle_revoke_ticket_result ( void *  cls,
const struct RevokeTicketResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT.

Parameters
cls
msgthe message we received

Definition at line 978 of file reclaim_api.c.

980 {
981  struct GNUNET_RECLAIM_Handle *h = cls;
983  uint32_t r_id = ntohl (msg->id);
984  int32_t success;
985 
986  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
987 
988 
989  for (op = h->op_head; NULL != op; op = op->next)
990  if (op->r_id == r_id)
991  break;
992  if (NULL == op)
993  return;
994  success = ntohl (msg->success);
995  {
996  if (NULL != op->rvk_cb)
997  {
998  op->rvk_cb (op->cls, success, NULL);
999  }
1000  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1001  free_op (op);
1002  return;
1003  }
1004  GNUNET_assert (0);
1005 }

References free_op(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, h, LOG, msg, GNUNET_ARM_Operation::next, op, and GNUNET_RECLAIM_Operation::r_id.

Here is the call graph for this function: