GNUnet  0.20.0
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_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 identity provider 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 *credential, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
 Store a 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 a 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_credentials_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 a 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...
 
size_t GNUNET_RECLAIM_ticket_serialize_get_size (const struct GNUNET_RECLAIM_Ticket *tkt)
 Get serialized ticket size. More...
 
enum GNUNET_GenericReturnValue GNUNET_RECLAIM_read_ticket_from_buffer (const void *buffer, size_t len, struct GNUNET_RECLAIM_Ticket *tkt, size_t *tb_read)
 Deserializes a ticket. More...
 
ssize_t GNUNET_RECLAIM_write_ticket_to_buffer (const struct GNUNET_RECLAIM_Ticket *tkt, void *buffer, size_t len)
 Serializes a 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 34 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 1062 of file reclaim_api.c.

1063 {
1065  { GNUNET_MQ_hd_fixed_size (success_response,
1067  struct SuccessResultMessage,
1068  h),
1069  GNUNET_MQ_hd_var_size (attribute_result,
1071  struct AttributeResultMessage,
1072  h),
1073  GNUNET_MQ_hd_var_size (credential_result,
1075  struct CredentialResultMessage,
1076  h),
1077  GNUNET_MQ_hd_var_size (ticket_result,
1079  struct TicketResultMessage,
1080  h),
1081  GNUNET_MQ_hd_var_size (consume_ticket_result,
1084  h),
1085  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1088  h),
1089  GNUNET_MQ_handler_end () };
1090  struct GNUNET_RECLAIM_Operation *op;
1091 
1092  GNUNET_assert (NULL == h->mq);
1093  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1094 
1095  h->mq =
1097  if (NULL == h->mq)
1098  return;
1099  for (op = h->op_head; NULL != op; op = op->next)
1100  GNUNET_MQ_send_copy (h->mq, op->env);
1101 }
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:1057
#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:370
#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:507
#define LOG(kind,...)
Definition: reclaim_api.c:34
Attribute is returned from the idp.
Definition: reclaim.h:127
Attribute list is returned from the idp.
Definition: reclaim.h:554
Credential is returned from the idp.
Definition: reclaim.h:169
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:41
Ticket revoke message.
Definition: reclaim.h:470
Attribute store/delete response message.
Definition: reclaim.h:106
Ticket result message.
Definition: reclaim.h:492

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 420 of file reclaim_api.c.

421 {
422  struct GNUNET_RECLAIM_Handle *handle = cls;
423 
424  handle->reconnect_task = NULL;
425  reconnect (handle);
426 }
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:1062
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:317

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 435 of file reclaim_api.c.

436 {
438  handle->mq = NULL;
439  handle->reconnect_backoff =
440  GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
442  GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
444  handle);
445 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
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:1272
#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:420
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 454 of file reclaim_api.c.

455 {
456  struct GNUNET_RECLAIM_Handle *h = it->h;
457 
458  GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it);
459  if (NULL != it->env)
460  GNUNET_MQ_discard (it->env);
461  GNUNET_free (it);
462 }
#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:285
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:196
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:232

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 471 of file reclaim_api.c.

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

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 488 of file reclaim_api.c.

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

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 507 of file reclaim_api.c.

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

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 523 of file reclaim_api.c.

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

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 563 of file reclaim_api.c.

565 {
566  size_t msg_len;
567  size_t attrs_len;
568  size_t pl_len;
569  size_t key_len;
570 
571  msg_len = ntohs (msg->header.size);
572  attrs_len = ntohs (msg->attrs_len);
573  key_len = ntohs (msg->key_len);
574  pl_len = ntohs (msg->presentations_len);
575  if (msg_len != sizeof(*msg) + attrs_len + pl_len + key_len)
576  {
577  GNUNET_break (0);
578  return GNUNET_SYSERR;
579  }
580  return GNUNET_OK;
581 }
@ GNUNET_OK
#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 {
596  struct GNUNET_RECLAIM_Handle *h = cls;
598  size_t attrs_len;
599  size_t pl_len;
600  size_t key_len;
601  size_t read;
602  uint32_t r_id = ntohl (msg->id);
603  char *read_ptr;
604 
605  attrs_len = ntohs (msg->attrs_len);
606  key_len = ntohs (msg->key_len);
607  pl_len = ntohs (msg->presentations_len);
608  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
609 
610 
611  for (op = h->op_head; NULL != op; op = op->next)
612  if (op->r_id == r_id)
613  break;
614  if (NULL == op)
615  return;
616 
617  {
618  struct GNUNET_RECLAIM_AttributeList *attrs;
622  read_ptr = (char *) &msg[1];
625  key_len,
626  &identity,
627  &read));
628  read_ptr += read;
629  attrs =
630  GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len);
631  read_ptr += attrs_len;
632  pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len);
633  if (NULL != op->atr_cb)
634  {
635  if (NULL == attrs)
636  {
637  op->atr_cb (op->cls, &identity, NULL, NULL);
638  }
639  else
640  {
641  for (le = attrs->list_head; NULL != le; le = le->next)
642  {
643  if (GNUNET_NO ==
645  {
646  for (ple = pl->list_head; NULL != ple; ple = ple->next)
647  {
648  if (GNUNET_YES ==
650  &ple->presentation->credential_id))
651  {
652  op->atr_cb (op->cls, &identity,
653  le->attribute, ple->presentation);
654  break;
655  }
656 
657  }
658  }
659  else // No credentials
660  {
661  op->atr_cb (op->cls, &identity,
662  le->attribute, NULL);
663  }
664  }
665  }
666  op->atr_cb (op->cls, NULL, NULL, NULL);
667  }
668  if (NULL != attrs)
670  if (NULL != pl)
672  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
673  free_op (op);
674  return;
675  }
676  GNUNET_assert (0);
677 }
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PublicKey *key, size_t *kb_read)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
Definition: identity_api.c:865
#define GNUNET_log(kind,...)
@ GNUNET_YES
@ GNUNET_NO
#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.
An identity key as per LSD0001.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
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_IDENTITY_read_public_key_from_buffer(), 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_SYSERR, GNUNET_YES, h, identity, 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 689 of file reclaim_api.c.

690 {
691  size_t msg_len;
692  size_t attr_len;
693  size_t key_len;
694 
695  msg_len = ntohs (msg->header.size);
696  attr_len = ntohs (msg->attr_len);
697  key_len = ntohs (msg->pkey_len);
698  if (msg_len != sizeof(*msg) + attr_len + key_len)
699  {
700  GNUNET_break (0);
701  return GNUNET_SYSERR;
702  }
703  return GNUNET_OK;
704 }

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 715 of file reclaim_api.c.

716 {
717  static struct GNUNET_IDENTITY_PublicKey identity;
718  struct GNUNET_RECLAIM_Handle *h = cls;
721  size_t attr_len;
722  size_t key_len;
723  size_t read;
724  uint32_t r_id = ntohl (msg->id);
725  char *buf;
726 
727  attr_len = ntohs (msg->attr_len);
728  key_len = ntohs (msg->pkey_len);
729  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
730 
731  for (it = h->it_head; NULL != it; it = it->next)
732  if (it->r_id == r_id)
733  break;
734  for (op = h->op_head; NULL != op; op = op->next)
735  if (op->r_id == r_id)
736  break;
737  if ((NULL == it) && (NULL == op))
738  return;
739 
740  buf = (char *) &msg[1];
741  if (0 == key_len)
742  {
743  if ((NULL == it) && (NULL == op))
744  {
745  GNUNET_break (0);
746  force_reconnect (h);
747  return;
748  }
749  if (NULL != it)
750  {
751  if (NULL != it->finish_cb)
752  it->finish_cb (it->finish_cb_cls);
753  free_it (it);
754  }
755  if (NULL != op)
756  {
757  if (NULL != op->ar_cb)
758  op->ar_cb (op->cls, NULL, NULL);
759  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
760  free_op (op);
761  }
762  return;
763  }
764 
765  {
766  struct GNUNET_RECLAIM_Attribute *attr;
769  key_len,
770  &identity,
771  &read));
772  buf += read;
773  GNUNET_RECLAIM_attribute_deserialize (buf, attr_len, &attr);
774  if (NULL != it)
775  {
776  if (NULL != it->proc)
777  it->proc (it->proc_cls, &identity, attr);
778  }
779  else if (NULL != op)
780  {
781  if (NULL != op->ar_cb)
782  op->ar_cb (op->cls, &identity, attr);
783  }
784  GNUNET_free (attr);
785  return;
786  }
787  GNUNET_assert (0);
788 }
static char buf[2048]
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:454
Handle for a attribute iterator operation.
Definition: reclaim_api.c:182
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:211
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:216
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:201
struct GNUNET_RECLAIM_AttributeIterator * next
Kept in a DLL.
Definition: reclaim_api.c:186
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:242
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:206

References buf, 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_IDENTITY_read_public_key_from_buffer(), GNUNET_RECLAIM_attribute_deserialize(), GNUNET_SYSERR, h, identity, 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 800 of file reclaim_api.c.

801 {
802  size_t msg_len;
803  size_t cred_len;
804  size_t key_len;
805 
806  msg_len = ntohs (msg->header.size);
807  cred_len = ntohs (msg->credential_len);
808  key_len = ntohs (msg->key_len);
809  if (msg_len != sizeof(*msg) + cred_len + key_len)
810  {
811  GNUNET_break (0);
812  return GNUNET_SYSERR;
813  }
814  return GNUNET_OK;
815 }

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 826 of file reclaim_api.c.

828 {
830  struct GNUNET_RECLAIM_Handle *h = cls;
833  size_t att_len;
834  size_t key_len;
835  size_t read;
836  uint32_t r_id = ntohl (msg->id);
837  char *buf;
838 
839  key_len = ntohs (msg->key_len);
840  att_len = ntohs (msg->credential_len);
841  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
842 
843 
844  for (it = h->ait_head; NULL != it; it = it->next)
845  if (it->r_id == r_id)
846  break;
847  for (op = h->op_head; NULL != op; op = op->next)
848  if (op->r_id == r_id)
849  break;
850  if ((NULL == it) && (NULL == op))
851  return;
852 
853  buf = (char *) &msg[1];
854  if (0 < key_len)
855  {
858  key_len,
859  &identity,
860  &read));
861  buf += read;
862  }
863  if (0 == key_len)
864  {
865  if ((NULL == it) && (NULL == op))
866  {
867  GNUNET_break (0);
868  force_reconnect (h);
869  return;
870  }
871  if (NULL != it)
872  {
873  if (NULL != it->finish_cb)
874  it->finish_cb (it->finish_cb_cls);
875  free_ait (it);
876  }
877  if (NULL != op)
878  {
879  if (NULL != op->at_cb)
880  op->at_cb (op->cls, NULL, NULL);
881  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
882  free_op (op);
883  }
884  return;
885  }
886 
887  {
888  struct GNUNET_RECLAIM_Credential *att;
890 
891  if (NULL != it)
892  {
893  if (NULL != it->proc)
894  it->proc (it->proc_cls, &identity, att);
895  }
896  else if (NULL != op)
897  {
898  if (NULL != op->at_cb)
899  op->at_cb (op->cls, &identity, att);
900  }
901  GNUNET_free (att);
902  return;
903  }
904  GNUNET_assert (0);
905 }
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:471
Handle for a credential iterator operation.
Definition: reclaim_api.c:249
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:268
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:283
GNUNET_RECLAIM_CredentialResult proc
The continuation to call with the results.
Definition: reclaim_api.c:278
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:273
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:309
struct GNUNET_RECLAIM_CredentialIterator * next
Kept in a DLL.
Definition: reclaim_api.c:253

References buf, 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_IDENTITY_read_public_key_from_buffer(), GNUNET_RECLAIM_credential_deserialize(), GNUNET_SYSERR, h, identity, 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 917 of file reclaim_api.c.

918 {
919  size_t msg_len;
920  size_t pres_len;
921  size_t tkt_len;
922 
923  msg_len = ntohs (msg->header.size);
924  pres_len = ntohs (msg->presentations_len);
925  tkt_len = ntohs (msg->tkt_len);
926  if (msg_len != sizeof(*msg) + pres_len + tkt_len)
927  {
928  GNUNET_break (0);
929  return GNUNET_SYSERR;
930  }
931  return GNUNET_OK;
932 }

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 943 of file reclaim_api.c.

944 {
945  struct GNUNET_RECLAIM_Handle *handle = cls;
948  struct GNUNET_RECLAIM_PresentationList *presentation;
949  uint32_t r_id = ntohl (msg->id);
951  size_t pres_len;
952  size_t tkt_len;
953  size_t tb_read;
954  char *buf;
955 
956  tkt_len = ntohs (msg->tkt_len);
957  pres_len = ntohs (msg->presentations_len);
958  for (op = handle->op_head; NULL != op; op = op->next)
959  if (op->r_id == r_id)
960  break;
961  for (it = handle->ticket_it_head; NULL != it; it = it->next)
962  if (it->r_id == r_id)
963  break;
964  if ((NULL == op) && (NULL == it))
965  return;
966  buf = (char*) &msg[1];
969  tkt_len,
970  &ticket,
971  &tb_read));
972  buf += tb_read;
973  if (NULL != op)
974  {
975  if (0 < pres_len)
977  buf,
978  pres_len);
979  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
980  if (0 == tb_read)
981  {
982  if (NULL != op->ti_cb)
983  op->ti_cb (op->cls, NULL, NULL);
984  }
985  else
986  {
987  if (NULL != op->ti_cb)
988  op->ti_cb (op->cls,
989  &ticket,
990  (0 < pres_len) ? presentation : NULL);
991  }
992  if (0 < pres_len)
994  free_op (op);
995  return;
996  }
997  else if (NULL != it)
998  {
999  if (0 == tkt_len)
1000  {
1001  GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
1002  handle->ticket_it_tail,
1003  it);
1004  it->finish_cb (it->finish_cb_cls);
1005  GNUNET_free (it);
1006  }
1007  else
1008  {
1009  if (NULL != it->tr_cb)
1010  it->tr_cb (it->cls, &ticket);
1011  }
1012  return;
1013  }
1014  GNUNET_break (0);
1015 }
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
enum GNUNET_GenericReturnValue GNUNET_RECLAIM_read_ticket_from_buffer(const void *buffer, size_t len, struct GNUNET_RECLAIM_Ticket *tkt, size_t *tb_read)
Deserializes a ticket.
Definition: reclaim_api.c:1750
Handle for a ticket iterator operation.
Definition: reclaim_api.c:119
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:148
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:174
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:138
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:143
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:153
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:123
The authorization ticket.

References buf, GNUNET_RECLAIM_TicketIterator::cls, GNUNET_RECLAIM_TicketIterator::finish_cb, GNUNET_RECLAIM_TicketIterator::finish_cb_cls, free_op(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_RECLAIM_presentation_list_deserialize(), GNUNET_RECLAIM_presentation_list_destroy(), GNUNET_RECLAIM_read_ticket_from_buffer(), GNUNET_SYSERR, 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 1026 of file reclaim_api.c.

1028 {
1029  struct GNUNET_RECLAIM_Handle *h = cls;
1030  struct GNUNET_RECLAIM_Operation *op;
1031  uint32_t r_id = ntohl (msg->id);
1032  int32_t success;
1033 
1034  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
1035 
1036 
1037  for (op = h->op_head; NULL != op; op = op->next)
1038  if (op->r_id == r_id)
1039  break;
1040  if (NULL == op)
1041  return;
1042  success = ntohl (msg->success);
1043  {
1044  if (NULL != op->rvk_cb)
1045  {
1046  op->rvk_cb (op->cls, success, NULL);
1047  }
1048  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1049  free_op (op);
1050  return;
1051  }
1052  GNUNET_assert (0);
1053 }

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: