GNUnet  0.10.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_attribute_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_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_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 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_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *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_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
 Delete an attribute. More...
 
struct GNUNET_RECLAIM_AttributeIteratorGNUNET_RECLAIM_get_attributes_start (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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_OperationGNUNET_RECLAIM_ticket_issue (struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, GNUNET_RECLAIM_TicketCallback 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_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeResult 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_CRYPTO_EcdsaPrivateKey *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_CRYPTO_EcdsaPrivateKey *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 729 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_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(), and reconnect_task().

730 {
732  { GNUNET_MQ_hd_fixed_size(success_response,
734  struct SuccessResultMessage,
735  h),
736  GNUNET_MQ_hd_var_size(attribute_result,
738  struct AttributeResultMessage,
739  h),
740  GNUNET_MQ_hd_fixed_size(ticket_result,
742  struct TicketResultMessage,
743  h),
744  GNUNET_MQ_hd_var_size(consume_ticket_result,
747  h),
748  GNUNET_MQ_hd_fixed_size(revoke_ticket_result,
751  h),
754 
755  GNUNET_assert(NULL == h->mq);
756  LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
757 
758  h->mq =
759  GNUNET_CLIENT_connect(h->cfg, "reclaim", handlers, &mq_error_handler, h);
760  if (NULL == h->mq)
761  return;
762  for (op = h->op_head; NULL != op; op = op->next)
763  GNUNET_MQ_send_copy(h->mq, op->env);
764 }
#define LOG(kind,...)
Definition: reclaim_api.c:35
Ticket result message.
Definition: reclaim.h:344
Attribute list is returned from the idp.
Definition: reclaim.h:389
#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:900
#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)
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:296
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:86
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
Message handler for a specific message type.
Attribute store/delete response message.
Definition: reclaim.h:101
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:251
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:236
Ticket revoke message.
Definition: reclaim.h:323
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:430
Attribute is returned from the idp.
Definition: reclaim.h:121
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
#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:394
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 325 of file reclaim_api.c.

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

Referenced by force_reconnect().

326 {
327  struct GNUNET_RECLAIM_Handle *handle = cls;
328 
329  handle->reconnect_task = NULL;
330  reconnect(handle);
331 }
Handle to the service.
Definition: reclaim_api.c:232
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:286
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:729
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 340 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(), and mq_error_handler().

341 {
342  GNUNET_MQ_destroy(handle->mq);
343  handle->mq = NULL;
344  handle->reconnect_backoff =
346  handle->reconnect_task =
349  handle);
350 }
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:286
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:296
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:1237
#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:291
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:325
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 359 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().

360 {
361  struct GNUNET_RECLAIM_Handle *h = it->h;
362 
364  if (NULL != it->env)
365  GNUNET_MQ_discard(it->env);
366  GNUNET_free(it);
367 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle to the service.
Definition: reclaim_api.c:232
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:266
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:319
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:215
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:261
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:179
#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 375 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_revoke_ticket_result(), handle_success_response(), and handle_ticket_result().

376 {
377  if (NULL == op)
378  return;
379  if (NULL != op->env)
380  GNUNET_MQ_discard(op->env);
381  GNUNET_free(op);
382 }
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:86
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:319
#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 394 of file reclaim_api.c.

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

Referenced by reconnect().

395 {
396  struct GNUNET_RECLAIM_Handle *handle = cls;
397 
398  force_reconnect(handle);
399 }
Handle to the service.
Definition: reclaim_api.c:232
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:340
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 410 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.

411 {
412  struct GNUNET_RECLAIM_Handle *h = cls;
414  uint32_t r_id = ntohl(msg->id);
415  int res;
416  const char *emsg;
417 
418  for (op = h->op_head; NULL != op; op = op->next)
419  if (op->r_id == r_id)
420  break;
421  if (NULL == op)
422  return;
423 
424  res = ntohl(msg->op_result);
426  "Received SUCCESS_RESPONSE with result %d\n",
427  res);
428 
429  /* TODO: add actual error message to response... */
430  if (GNUNET_SYSERR == res)
431  emsg = _("failed to store record\n");
432  else
433  emsg = NULL;
434  if (NULL != op->as_cb)
435  op->as_cb(op->cls, res, emsg);
437  free_op(op);
438 }
#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:232
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:96
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:66
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:115
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:94
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:256
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
static int res
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:251
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:375
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:110
uint32_t r_id
request id
Definition: reclaim_api.c:91
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 450 of file reclaim_api.c.

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

452 {
453  size_t msg_len;
454  size_t attrs_len;
455 
456  msg_len = ntohs(msg->header.size);
457  attrs_len = ntohs(msg->attrs_len);
458  if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len)
459  {
460  GNUNET_break(0);
461  return GNUNET_SYSERR;
462  }
463  return GNUNET_OK;
464 }
Attribute list is returned from the idp.
Definition: reclaim.h:389
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:408
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:393

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

References GNUNET_RECLAIM_Operation::ar_cb, ConsumeTicketResultMessage::attrs_len, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_RECLAIM_Operation::cls, free_op(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free_non_null, GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_list_destroy(), GNUNET_RECLAIM_Operation::h, ConsumeTicketResultMessage::id, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, LOG, GNUNET_RECLAIM_Operation::next, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, op, GNUNET_RECLAIM_Handle::op_head, GNUNET_RECLAIM_Handle::op_tail, and GNUNET_RECLAIM_Operation::r_id.

477 {
478  struct GNUNET_RECLAIM_Handle *h = cls;
480  size_t attrs_len;
481  uint32_t r_id = ntohl(msg->id);
482 
483  attrs_len = ntohs(msg->attrs_len);
484  LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
485 
486 
487  for (op = h->op_head; NULL != op; op = op->next)
488  if (op->r_id == r_id)
489  break;
490  if (NULL == op)
491  return;
492 
493  {
496  attrs =
497  GNUNET_RECLAIM_ATTRIBUTE_list_deserialize((char *)&msg[1], attrs_len);
498  if (NULL != op->ar_cb)
499  {
500  if (NULL == attrs)
501  {
502  op->ar_cb(op->cls, &msg->identity, NULL);
503  }
504  else
505  {
506  for (le = attrs->list_head; NULL != le; le = le->next)
507  op->ar_cb(op->cls, &msg->identity, le->claim);
509  attrs = NULL;
510  }
511  op->ar_cb(op->cls, NULL, NULL);
512  }
514  free_op(op);
515  GNUNET_free_non_null(attrs);
516  return;
517  }
518  GNUNET_assert(0);
519 }
#define LOG(kind,...)
Definition: reclaim_api.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
Handle to the service.
Definition: reclaim_api.c:232
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:96
#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:398
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
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:94
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:256
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:251
GNUNET_RECLAIM_AttributeResult ar_cb
Attribute result callback.
Definition: reclaim_api.c:71
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:418
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:408
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:375
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
uint32_t r_id
request id
Definition: reclaim_api.c:91
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 531 of file reclaim_api.c.

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

532 {
533  size_t msg_len;
534  size_t attr_len;
535 
536  msg_len = ntohs(msg->header.size);
537  attr_len = ntohs(msg->attr_len);
538  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
539  {
540  GNUNET_break(0);
541  return GNUNET_SYSERR;
542  }
543  return GNUNET_OK;
544 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Attribute is returned from the idp.
Definition: reclaim.h:121
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:135
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:125

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

556 {
557  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
558  struct GNUNET_RECLAIM_Handle *h = cls;
561  size_t attr_len;
562  uint32_t r_id = ntohl(msg->id);
563 
564  attr_len = ntohs(msg->attr_len);
565  LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
566 
567 
568  for (it = h->it_head; NULL != it; it = it->next)
569  if (it->r_id == r_id)
570  break;
571  for (op = h->op_head; NULL != op; op = op->next)
572  if (op->r_id == r_id)
573  break;
574  if ((NULL == it) && (NULL == op))
575  return;
576 
577  if ((0 ==
578  (memcmp(&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
579  {
580  if ((NULL == it) && (NULL == op))
581  {
582  GNUNET_break(0);
583  force_reconnect(h);
584  return;
585  }
586  if (NULL != it)
587  {
588  if (NULL != it->finish_cb)
589  it->finish_cb(it->finish_cb_cls);
590  free_it(it);
591  }
592  if (NULL != op)
593  {
594  if (NULL != op->ar_cb)
595  op->ar_cb(op->cls, NULL, NULL);
597  free_op(op);
598  }
599  return;
600  }
601 
602  {
603  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
604  attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&msg[1], attr_len);
605  if (NULL != it)
606  {
607  if (NULL != it->proc)
608  it->proc(it->proc_cls, &msg->identity, attr);
609  }
610  else if (NULL != op)
611  {
612  if (NULL != op->ar_cb)
613  op->ar_cb(op->cls, &msg->identity, attr);
614  }
615  GNUNET_free(attr);
616  return;
617  }
618  GNUNET_assert(0);
619 }
#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:232
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:96
#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:130
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:189
Private ECC key encoded for transmission.
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:194
#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:199
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:340
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:256
Handle for a attribute iterator operation.
Definition: reclaim_api.c:165
struct GNUNET_RECLAIM_AttributeIterator * next
Kept in a DLL.
Definition: reclaim_api.c:169
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:225
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:251
GNUNET_RECLAIM_AttributeResult ar_cb
Attribute result callback.
Definition: reclaim_api.c:71
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:261
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:135
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:145
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:359
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:375
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:184
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t r_id
request id
Definition: reclaim_api.c:91
Here is the call graph for this function:

◆ 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 630 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, handle, TicketResultMessage::id, GNUNET_RECLAIM_Operation::next, GNUNET_RECLAIM_TicketIterator::next, op, GNUNET_RECLAIM_Handle::op_head, GNUNET_RECLAIM_Handle::op_tail, GNUNET_RECLAIM_Operation::r_id, GNUNET_RECLAIM_TicketIterator::r_id, TicketResultMessage::ticket, GNUNET_RECLAIM_Handle::ticket_it_head, GNUNET_RECLAIM_Handle::ticket_it_tail, GNUNET_RECLAIM_Operation::tr_cb, and GNUNET_RECLAIM_TicketIterator::tr_cb.

631 {
632  struct GNUNET_RECLAIM_Handle *handle = cls;
635  uint32_t r_id = ntohl(msg->id);
636  static const struct GNUNET_RECLAIM_Ticket ticket;
637 
638  for (op = handle->op_head; NULL != op; op = op->next)
639  if (op->r_id == r_id)
640  break;
641  for (it = handle->ticket_it_head; NULL != it; it = it->next)
642  if (it->r_id == r_id)
643  break;
644  if ((NULL == op) && (NULL == it))
645  return;
646  if (NULL != op)
647  {
648  GNUNET_CONTAINER_DLL_remove(handle->op_head, handle->op_tail, op);
649  if (0 ==
650  memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
651  {
652  if (NULL != op->tr_cb)
653  op->tr_cb(op->cls, NULL);
654  }
655  else
656  {
657  if (NULL != op->tr_cb)
658  op->tr_cb(op->cls, &msg->ticket);
659  }
660  free_op(op);
661  return;
662  }
663  else if (NULL != it)
664  {
665  if (0 ==
666  memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
667  {
669  handle->ticket_it_tail,
670  it);
671  it->finish_cb(it->finish_cb_cls);
672  GNUNET_free(it);
673  }
674  else
675  {
676  if (NULL != it->tr_cb)
677  it->tr_cb(it->cls, &msg->ticket);
678  }
679  return;
680  }
681  GNUNET_break(0);
682 }
#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:276
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:353
Handle to the service.
Definition: reclaim_api.c:232
The authorization ticket.
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:358
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:96
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:127
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:256
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:158
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:137
GNUNET_RECLAIM_TicketCallback tr_cb
Ticket result callback.
Definition: reclaim_api.c:81
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:251
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:107
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:132
Handle for a ticket iterator operation.
Definition: reclaim_api.c:103
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:375
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:122
struct GNUNET_RECLAIM_TicketIterator * ticket_it_head
Head of active iterations.
Definition: reclaim_api.c:271
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t r_id
request id
Definition: reclaim_api.c:91
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 693 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.

695 {
696  struct GNUNET_RECLAIM_Handle *h = cls;
698  uint32_t r_id = ntohl(msg->id);
699  int32_t success;
700 
701  LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
702 
703 
704  for (op = h->op_head; NULL != op; op = op->next)
705  if (op->r_id == r_id)
706  break;
707  if (NULL == op)
708  return;
709  success = ntohl(msg->success);
710  {
711  if (NULL != op->rvk_cb)
712  {
713  op->rvk_cb(op->cls, success, NULL);
714  }
716  free_op(op);
717  return;
718  }
719  GNUNET_assert(0);
720 }
#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:232
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:96
#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:94
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:76
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:256
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:251
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:332
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:375
uint32_t success
Revocation result.
Definition: reclaim.h:337
uint32_t r_id
request id
Definition: reclaim_api.c:91
Here is the call graph for this function: