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__)

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

References GNUNET_RECLAIM_Handle::cfg, GNUNET_RECLAIM_Operation::env, 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(), LOG, GNUNET_RECLAIM_Handle::mq, mq_error_handler(), GNUNET_RECLAIM_Operation::next, op, and GNUNET_RECLAIM_Handle::op_head.

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

1016 {
1018  { GNUNET_MQ_hd_fixed_size (success_response,
1020  struct SuccessResultMessage,
1021  h),
1022  GNUNET_MQ_hd_var_size (attribute_result,
1024  struct AttributeResultMessage,
1025  h),
1026  GNUNET_MQ_hd_var_size (credential_result,
1028  struct CredentialResultMessage,
1029  h),
1030  GNUNET_MQ_hd_var_size (ticket_result,
1032  struct TicketResultMessage,
1033  h),
1034  GNUNET_MQ_hd_var_size (consume_ticket_result,
1037  h),
1038  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1041  h),
1042  GNUNET_MQ_handler_end () };
1043  struct GNUNET_RECLAIM_Operation *op;
1044 
1045  GNUNET_assert (NULL == h->mq);
1046  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1047 
1048  h->mq =
1049  GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
1050  if (NULL == h->mq)
1051  return;
1052  for (op = h->op_head; NULL != op; op = op->next)
1053  GNUNET_MQ_send_copy (h->mq, op->env);
1054 }
#define LOG(kind,...)
Definition: reclaim_api.c:35
Ticket result message.
Definition: reclaim.h:453
Attribute list is returned from the idp.
Definition: reclaim.h:507
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
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:1063
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT
Handle for an operation with the service.
Definition: reclaim_api.c:41
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:392
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:102
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
Message handler for a specific message type.
Attribute store/delete response message.
Definition: reclaim.h:103
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:322
Ticket revoke message.
Definition: reclaim.h:431
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
Attribute is returned from the idp.
Definition: reclaim.h:124
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Credential is returned from the idp.
Definition: reclaim.h:164
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
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
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.

References GNUNET_RECLAIM_Operation::cls, handle, reconnect(), and GNUNET_RECLAIM_Handle::reconnect_task.

Referenced by force_reconnect().

422 {
423  struct GNUNET_RECLAIM_Handle *handle = cls;
424 
425  handle->reconnect_task = NULL;
426  reconnect (handle);
427 }
Handle to the service.
Definition: reclaim_api.c:317
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:382
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:1015
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
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.

References GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, GNUNET_RECLAIM_Handle::mq, GNUNET_RECLAIM_Handle::reconnect_backoff, GNUNET_RECLAIM_Handle::reconnect_task, and reconnect_task().

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

437 {
438  GNUNET_MQ_destroy (handle->mq);
439  handle->mq = NULL;
440  handle->reconnect_backoff =
442  handle->reconnect_task =
445  handle);
446 }
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:382
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:392
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...
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:387
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:421
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.

References GNUNET_RECLAIM_AttributeIterator::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), GNUNET_RECLAIM_Operation::h, GNUNET_RECLAIM_AttributeIterator::h, GNUNET_RECLAIM_Handle::it_head, and GNUNET_RECLAIM_Handle::it_tail.

Referenced by GNUNET_RECLAIM_get_attributes_stop(), and handle_attribute_result().

456 {
457  struct GNUNET_RECLAIM_Handle *h = it->h;
458 
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.
Handle to the service.
Definition: reclaim_api.c:317
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:352
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:323
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:233
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:347
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:197
#define GNUNET_free(ptr)
Wrapper around free.
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.

References GNUNET_RECLAIM_Handle::ait_head, GNUNET_RECLAIM_Handle::ait_tail, GNUNET_RECLAIM_CredentialIterator::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), GNUNET_RECLAIM_Operation::h, and GNUNET_RECLAIM_CredentialIterator::h.

Referenced by GNUNET_RECLAIM_get_credentials_stop(), and handle_credential_result().

473 {
474  struct GNUNET_RECLAIM_Handle *h = ait->h;
475 
477  if (NULL != ait->env)
478  GNUNET_MQ_discard (ait->env);
479  GNUNET_free (ait);
480 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle to the service.
Definition: reclaim_api.c:317
struct GNUNET_RECLAIM_CredentialIterator * ait_tail
Tail of active iterations.
Definition: reclaim_api.c:362
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:300
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
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:264
struct GNUNET_RECLAIM_CredentialIterator * ait_head
Head of active iterations.
Definition: reclaim_api.c:357
#define GNUNET_free(ptr)
Wrapper around free.
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.

References GNUNET_RECLAIM_Operation::env, GNUNET_free, and GNUNET_MQ_discard().

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

490 {
491  if (NULL == op)
492  return;
493  if (NULL != op->env)
494  GNUNET_MQ_discard (op->env);
495  GNUNET_free (op);
496 }
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:102
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:323
#define GNUNET_free(ptr)
Wrapper around free.
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.

References GNUNET_RECLAIM_Operation::cls, force_reconnect(), and handle.

Referenced by reconnect().

509 {
510  struct GNUNET_RECLAIM_Handle *handle = cls;
511 
512  force_reconnect (handle);
513 }
Handle to the service.
Definition: reclaim_api.c:317
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:436
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
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.

References _, GNUNET_RECLAIM_Operation::as_cb, GNUNET_RECLAIM_Operation::cls, free_op(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SYSERR, GNUNET_RECLAIM_Operation::h, SuccessResultMessage::id, LOG, GNUNET_RECLAIM_Operation::next, op, GNUNET_RECLAIM_Handle::op_head, SuccessResultMessage::op_result, GNUNET_RECLAIM_Handle::op_tail, GNUNET_RECLAIM_Operation::r_id, and res.

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);
551  free_op (op);
552 }
#define LOG(kind,...)
Definition: reclaim_api.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle to the service.
Definition: reclaim_api.c:317
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:112
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:67
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
Handle for an operation with the service.
Definition: reclaim_api.c:41
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:342
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
static int res
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
uint32_t r_id
request id
Definition: reclaim_api.c:107
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.

References ConsumeTicketResultMessage::attrs_len, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, ConsumeTicketResultMessage::header, ConsumeTicketResultMessage::presentations_len, and GNUNET_MessageHeader::size.

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 }
Attribute list is returned from the idp.
Definition: reclaim.h:507
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...
uint16_t presentations_len
Length of presentation data.
Definition: reclaim.h:532
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:527
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:512

◆ 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.

References GNUNET_RECLAIM_Operation::atr_cb, GNUNET_RECLAIM_AttributeListEntry::attribute, ConsumeTicketResultMessage::attrs_len, GNUNET_RECLAIM_Operation::cls, GNUNET_RECLAIM_Attribute::credential, GNUNET_RECLAIM_Presentation::credential_id, free_op(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, 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, GNUNET_RECLAIM_Operation::h, ConsumeTicketResultMessage::id, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_PresentationList::list_head, GNUNET_RECLAIM_Operation::next, GNUNET_RECLAIM_AttributeListEntry::next, GNUNET_RECLAIM_PresentationListEntry::next, op, GNUNET_RECLAIM_Handle::op_head, GNUNET_RECLAIM_Handle::op_tail, GNUNET_RECLAIM_PresentationListEntry::presentation, ConsumeTicketResultMessage::presentations_len, and GNUNET_RECLAIM_Operation::r_id.

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  if (NULL != attrs)
656  if (NULL != pl)
658  attrs = NULL;
659  pl = NULL;
660  }
661  op->atr_cb (op->cls, NULL, NULL, NULL);
662  }
664  free_op (op);
665  GNUNET_free (attrs);
666  return;
667  }
668  GNUNET_assert (0);
669 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle to the service.
Definition: reclaim_api.c:317
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:112
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
GNUNET_RECLAIM_AttributeTicketResult atr_cb
Attribute result callback.
Definition: reclaim_api.c:77
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:517
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
A list of GNUNET_RECLAIM_Attribute structures.
Handle for an operation with the service.
Definition: reclaim_api.c:41
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:342
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:542
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
uint16_t presentations_len
Length of presentation data.
Definition: reclaim.h:532
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
A list of GNUNET_RECLAIM_Presentation structures.
#define GNUNET_RECLAIM_id_is_equal(a, b)
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:527
#define GNUNET_log(kind,...)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize a presentation list.
#define GNUNET_RECLAIM_id_is_zero(a)
uint32_t r_id
request id
Definition: reclaim_api.c:107
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 681 of file reclaim_api.c.

References AttributeResultMessage::attr_len, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, AttributeResultMessage::header, and GNUNET_MessageHeader::size.

682 {
683  size_t msg_len;
684  size_t attr_len;
685 
686  msg_len = ntohs (msg->header.size);
687  attr_len = ntohs (msg->attr_len);
688  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
689  {
690  GNUNET_break (0);
691  return GNUNET_SYSERR;
692  }
693  return GNUNET_OK;
694 }
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...
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:129

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

References GNUNET_RECLAIM_Operation::ar_cb, AttributeResultMessage::attr_len, GNUNET_RECLAIM_Operation::cls, 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(), GNUNET_RECLAIM_Operation::h, AttributeResultMessage::id, AttributeResultMessage::identity, GNUNET_RECLAIM_Handle::it_head, LOG, GNUNET_RECLAIM_Operation::next, GNUNET_RECLAIM_AttributeIterator::next, op, GNUNET_RECLAIM_Handle::op_head, GNUNET_RECLAIM_Handle::op_tail, GNUNET_RECLAIM_AttributeIterator::proc, GNUNET_RECLAIM_AttributeIterator::proc_cls, GNUNET_RECLAIM_Operation::r_id, and GNUNET_RECLAIM_AttributeIterator::r_id.

706 {
707  static struct GNUNET_IDENTITY_PrivateKey identity_dummy;
708  struct GNUNET_RECLAIM_Handle *h = cls;
711  size_t attr_len;
712  uint32_t r_id = ntohl (msg->id);
713 
714  attr_len = ntohs (msg->attr_len);
715  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
716 
717 
718  for (it = h->it_head; NULL != it; it = it->next)
719  if (it->r_id == r_id)
720  break;
721  for (op = h->op_head; NULL != op; op = op->next)
722  if (op->r_id == r_id)
723  break;
724  if ((NULL == it) && (NULL == op))
725  return;
726 
727  if ((0 ==
728  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
729  {
730  if ((NULL == it) && (NULL == op))
731  {
732  GNUNET_break (0);
733  force_reconnect (h);
734  return;
735  }
736  if (NULL != it)
737  {
738  if (NULL != it->finish_cb)
739  it->finish_cb (it->finish_cb_cls);
740  free_it (it);
741  }
742  if (NULL != op)
743  {
744  if (NULL != op->ar_cb)
745  op->ar_cb (op->cls, NULL, NULL);
747  free_op (op);
748  }
749  return;
750  }
751 
752  {
753  struct GNUNET_RECLAIM_Attribute *attr;
754  GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len,
755  &attr);
756  if (NULL != it)
757  {
758  if (NULL != it->proc)
759  it->proc (it->proc_cls, &msg->identity, attr);
760  }
761  else if (NULL != op)
762  {
763  if (NULL != op->ar_cb)
764  op->ar_cb (op->cls, &msg->identity, attr);
765  }
766  GNUNET_free (attr);
767  return;
768  }
769  GNUNET_assert (0);
770 }
#define LOG(kind,...)
Definition: reclaim_api.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
Handle to the service.
Definition: reclaim_api.c:317
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:112
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
A private key for an identity as per LSD0001.
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:207
Handle for an operation with the service.
Definition: reclaim_api.c:41
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:212
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:217
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:436
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:342
Handle for a attribute iterator operation.
Definition: reclaim_api.c:182
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
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
GNUNET_RECLAIM_AttributeResult ar_cb
Attribute result callback.
Definition: reclaim_api.c:72
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:347
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:455
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:202
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:154
uint32_t r_id
request id
Definition: reclaim_api.c:107
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 782 of file reclaim_api.c.

References CredentialResultMessage::credential_len, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, CredentialResultMessage::header, and GNUNET_MessageHeader::size.

783 {
784  size_t msg_len;
785  size_t cred_len;
786 
787  msg_len = ntohs (msg->header.size);
788  cred_len = ntohs (msg->credential_len);
789  if (msg_len != sizeof(struct CredentialResultMessage) + cred_len)
790  {
791  GNUNET_break (0);
792  return GNUNET_SYSERR;
793  }
794  return GNUNET_OK;
795 }
uint16_t credential_len
Length of serialized attribute data.
Definition: reclaim.h:179
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
Message header.
Definition: reclaim.h:169
Credential is returned from the idp.
Definition: reclaim.h:164

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

References GNUNET_RECLAIM_Handle::ait_head, GNUNET_RECLAIM_Operation::at_cb, GNUNET_RECLAIM_Operation::cls, CredentialResultMessage::credential_len, 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(), GNUNET_RECLAIM_Operation::h, CredentialResultMessage::id, CredentialResultMessage::identity, LOG, GNUNET_RECLAIM_Operation::next, GNUNET_RECLAIM_CredentialIterator::next, op, GNUNET_RECLAIM_Handle::op_head, GNUNET_RECLAIM_Handle::op_tail, GNUNET_RECLAIM_CredentialIterator::proc, GNUNET_RECLAIM_CredentialIterator::proc_cls, GNUNET_RECLAIM_Operation::r_id, and GNUNET_RECLAIM_CredentialIterator::r_id.

808 {
809  static struct GNUNET_IDENTITY_PrivateKey identity_dummy;
810  struct GNUNET_RECLAIM_Handle *h = cls;
813  size_t att_len;
814  uint32_t r_id = ntohl (msg->id);
815 
816  att_len = ntohs (msg->credential_len);
817  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
818 
819 
820  for (it = h->ait_head; NULL != it; it = it->next)
821  if (it->r_id == r_id)
822  break;
823  for (op = h->op_head; NULL != op; op = op->next)
824  if (op->r_id == r_id)
825  break;
826  if ((NULL == it) && (NULL == op))
827  return;
828 
829  if ((0 ==
830  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
831  {
832  if ((NULL == it) && (NULL == op))
833  {
834  GNUNET_break (0);
835  force_reconnect (h);
836  return;
837  }
838  if (NULL != it)
839  {
840  if (NULL != it->finish_cb)
841  it->finish_cb (it->finish_cb_cls);
842  free_ait (it);
843  }
844  if (NULL != op)
845  {
846  if (NULL != op->at_cb)
847  op->at_cb (op->cls, NULL, NULL);
849  free_op (op);
850  }
851  return;
852  }
853 
854  {
855  struct GNUNET_RECLAIM_Credential *att;
856  att = GNUNET_RECLAIM_credential_deserialize ((char *) &msg[1], att_len);
857 
858  if (NULL != it)
859  {
860  if (NULL != it->proc)
861  it->proc (it->proc_cls, &msg->identity, att);
862  }
863  else if (NULL != op)
864  {
865  if (NULL != op->at_cb)
866  op->at_cb (op->cls, &msg->identity, att);
867  }
868  GNUNET_free (att);
869  return;
870  }
871  GNUNET_assert (0);
872 }
#define LOG(kind,...)
Definition: reclaim_api.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:310
uint16_t credential_len
Length of serialized attribute data.
Definition: reclaim.h:179
Handle to the service.
Definition: reclaim_api.c:317
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:112
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A private key for an identity as per LSD0001.
Handle for an operation with the service.
Definition: reclaim_api.c:41
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:189
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:174
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:436
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:342
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
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
struct GNUNET_RECLAIM_CredentialIterator * next
Kept in a DLL.
Definition: reclaim_api.c:254
GNUNET_RECLAIM_CredentialResult at_cb
Credential result callback.
Definition: reclaim_api.c:82
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:274
static void free_ait(struct GNUNET_RECLAIM_CredentialIterator *ait)
Free it.
Definition: reclaim_api.c:472
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:269
struct GNUNET_RECLAIM_CredentialIterator * ait_head
Head of active iterations.
Definition: reclaim_api.c:357
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
Handle for a credential iterator operation.
Definition: reclaim_api.c:249
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t r_id
request id
Definition: reclaim_api.c:107
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 883 of file reclaim_api.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, TicketResultMessage::header, TicketResultMessage::presentations_len, and GNUNET_MessageHeader::size.

884 {
885  size_t msg_len;
886  size_t pres_len;
887 
888  msg_len = ntohs (msg->header.size);
889  pres_len = ntohs (msg->presentations_len);
890  if (msg_len != sizeof(struct TicketResultMessage) + pres_len)
891  {
892  GNUNET_break (0);
893  return GNUNET_SYSERR;
894  }
895  return GNUNET_OK;
896 }
Ticket result message.
Definition: reclaim.h:453
uint32_t presentations_len
Length of new presentations created.
Definition: reclaim.h:468
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT.
Definition: reclaim.h:458
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...

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

References GNUNET_RECLAIM_Operation::cls, 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, TicketResultMessage::id, GNUNET_RECLAIM_Operation::next, GNUNET_RECLAIM_TicketIterator::next, op, GNUNET_RECLAIM_Handle::op_head, GNUNET_RECLAIM_Handle::op_tail, TicketResultMessage::presentations_len, GNUNET_RECLAIM_Operation::r_id, GNUNET_RECLAIM_TicketIterator::r_id, GNUNET_RECLAIM_Operation::ti_cb, TicketResultMessage::ticket, GNUNET_RECLAIM_Handle::ticket_it_head, GNUNET_RECLAIM_Handle::ticket_it_tail, and GNUNET_RECLAIM_TicketIterator::tr_cb.

908 {
909  struct GNUNET_RECLAIM_Handle *handle = cls;
912  struct GNUNET_RECLAIM_PresentationList *pres;
913  uint32_t r_id = ntohl (msg->id);
914  static const struct GNUNET_RECLAIM_Ticket ticket;
915  uint32_t pres_len = ntohs (msg->presentations_len);
916 
917  for (op = handle->op_head; NULL != op; op = op->next)
918  if (op->r_id == r_id)
919  break;
920  for (it = handle->ticket_it_head; NULL != it; it = it->next)
921  if (it->r_id == r_id)
922  break;
923  if ((NULL == op) && (NULL == it))
924  return;
925  if (NULL != op)
926  {
927  if (0 < pres_len)
928  pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*)&msg[1],
929  pres_len);
930  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
931  if (0 ==
932  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
933  {
934  if (NULL != op->ti_cb)
935  op->ti_cb (op->cls, NULL, NULL);
936  }
937  else
938  {
939  if (NULL != op->ti_cb)
940  op->ti_cb (op->cls,
941  &msg->ticket,
942  (0 < pres_len) ? pres : NULL);
943  }
944  if (0 < pres_len)
946  free_op (op);
947  return;
948  }
949  else if (NULL != it)
950  {
951  if (0 ==
952  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
953  {
955  handle->ticket_it_tail,
956  it);
957  it->finish_cb (it->finish_cb_cls);
958  GNUNET_free (it);
959  }
960  else
961  {
962  if (NULL != it->tr_cb)
963  it->tr_cb (it->cls, &msg->ticket);
964  }
965  return;
966  }
967  GNUNET_break (0);
968 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_RECLAIM_TicketIterator * ticket_it_tail
Tail of active iterations.
Definition: reclaim_api.c:372
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:463
Handle to the service.
Definition: reclaim_api.c:317
The authorization ticket.
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:473
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:112
uint32_t presentations_len
Length of new presentations created.
Definition: reclaim.h:468
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:144
Handle for an operation with the service.
Definition: reclaim_api.c:41
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:342
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:175
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
GNUNET_RECLAIM_IssueTicketCallback ti_cb
Ticket issue result callback.
Definition: reclaim_api.c:97
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:154
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:124
A list of GNUNET_RECLAIM_Presentation structures.
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:149
Handle for a ticket iterator operation.
Definition: reclaim_api.c:119
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:139
struct GNUNET_RECLAIM_TicketIterator * ticket_it_head
Head of active iterations.
Definition: reclaim_api.c:367
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize a presentation list.
uint32_t r_id
request id
Definition: reclaim_api.c:107
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 979 of file reclaim_api.c.

References GNUNET_RECLAIM_Operation::cls, free_op(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_RECLAIM_Operation::h, RevokeTicketResultMessage::id, LOG, GNUNET_RECLAIM_Operation::next, op, GNUNET_RECLAIM_Handle::op_head, GNUNET_RECLAIM_Handle::op_tail, GNUNET_RECLAIM_Operation::r_id, GNUNET_RECLAIM_Operation::rvk_cb, and RevokeTicketResultMessage::success.

981 {
982  struct GNUNET_RECLAIM_Handle *h = cls;
984  uint32_t r_id = ntohl (msg->id);
985  int32_t success;
986 
987  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
988 
989 
990  for (op = h->op_head; NULL != op; op = op->next)
991  if (op->r_id == r_id)
992  break;
993  if (NULL == op)
994  return;
995  success = ntohl (msg->success);
996  {
997  if (NULL != op->rvk_cb)
998  {
999  op->rvk_cb (op->cls, success, NULL);
1000  }
1002  free_op (op);
1003  return;
1004  }
1005  GNUNET_assert (0);
1006 }
#define LOG(kind,...)
Definition: reclaim_api.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle to the service.
Definition: reclaim_api.c:317
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:112
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Handle for an operation with the service.
Definition: reclaim_api.c:41
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:87
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:342
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:441
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
uint32_t success
Revocation result.
Definition: reclaim.h:446
uint32_t r_id
request id
Definition: reclaim_api.c:107
Here is the call graph for this function: