GNUnet 0.21.1
reclaim_api.c File Reference

api to interact with the reclaim service More...

#include "platform.h"
#include "gnunet_util_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 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_CRYPTO_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_CRYPTO_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_CRYPTO_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_CRYPTO_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_CRYPTO_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_CRYPTO_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_CRYPTO_PrivateKey *iss, const struct GNUNET_CRYPTO_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_CRYPTO_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_CRYPTO_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_CRYPTO_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 33 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 1064 of file reclaim_api.c.

1065{
1067 { GNUNET_MQ_hd_fixed_size (success_response,
1069 struct SuccessResultMessage,
1070 h),
1071 GNUNET_MQ_hd_var_size (attribute_result,
1074 h),
1075 GNUNET_MQ_hd_var_size (credential_result,
1078 h),
1079 GNUNET_MQ_hd_var_size (ticket_result,
1081 struct TicketResultMessage,
1082 h),
1083 GNUNET_MQ_hd_var_size (consume_ticket_result,
1086 h),
1087 GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1090 h),
1093
1094 GNUNET_assert (NULL == h->mq);
1095 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1096
1097 h->mq =
1099 if (NULL == h->mq)
1100 return;
1101 for (op = h->op_head; NULL != op; op = op->next)
1102 GNUNET_MQ_send_copy (h->mq, op->env);
1103}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
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
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:506
#define LOG(kind,...)
Definition: reclaim_api.c:33
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:40
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 419 of file reclaim_api.c.

420{
421 struct GNUNET_RECLAIM_Handle *handle = cls;
422
423 handle->reconnect_task = NULL;
425}
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:1064
Handle to the service.
Definition: reclaim_api.c:316

References handle, and reconnect().

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

435{
437 handle->mq = NULL;
438 handle->reconnect_backoff =
439 GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
440 handle->reconnect_task =
441 GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
443 handle);
444}
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:1278
#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:419
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44

References GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, handle, GNUNET_VPN_Handle::mq, 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 453 of file reclaim_api.c.

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

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

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

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

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

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

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

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

523{
524 struct GNUNET_RECLAIM_Handle *h = cls;
526 uint32_t r_id = ntohl (msg->id);
527 int res;
528 const char *emsg;
529
530 for (op = h->op_head; NULL != op; op = op->next)
531 if (op->r_id == r_id)
532 break;
533 if (NULL == op)
534 return;
535
536 res = ntohl (msg->op_result);
538 "Received SUCCESS_RESPONSE with result %d\n",
539 res);
540
541 /* TODO: add actual error message to response... */
542 if (GNUNET_SYSERR == res)
543 emsg = _ ("failed to store record\n");
544 else
545 emsg = NULL;
546 if (NULL != op->as_cb)
547 op->as_cb (op->cls, res, emsg);
548 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
549 free_op (op);
550}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static char * res
Currently read line or NULL on EOF.
@ 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:487
uint32_t r_id
request id
Definition: reclaim_api.c:105

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

564{
565 size_t msg_len;
566 size_t attrs_len;
567 size_t pl_len;
568 size_t key_len;
569
570 msg_len = ntohs (msg->header.size);
571 attrs_len = ntohs (msg->attrs_len);
572 key_len = ntohs (msg->key_len);
573 pl_len = ntohs (msg->presentations_len);
574 if (msg_len != sizeof(*msg) + attrs_len + pl_len + key_len)
575 {
576 GNUNET_break (0);
577 return GNUNET_SYSERR;
578 }
579 return GNUNET_OK;
580}
@ 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 591 of file reclaim_api.c.

593{
595 struct GNUNET_RECLAIM_Handle *h = cls;
597 size_t attrs_len;
598 size_t pl_len;
599 size_t key_len;
600 size_t read;
601 uint32_t r_id = ntohl (msg->id);
602 char *read_ptr;
603
604 attrs_len = ntohs (msg->attrs_len);
605 key_len = ntohs (msg->key_len);
606 pl_len = ntohs (msg->presentations_len);
607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
608
609
610 for (op = h->op_head; NULL != op; op = op->next)
611 if (op->r_id == r_id)
612 break;
613 if (NULL == op)
614 return;
615
616 {
617 struct GNUNET_RECLAIM_AttributeList *attrs;
621 read_ptr = (char *) &msg[1];
624 key_len,
625 &identity,
626 &read));
627 read_ptr += read;
628 attrs =
629 GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len);
630 read_ptr += attrs_len;
631 pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len);
632 if (NULL != op->atr_cb)
633 {
634 if (NULL == attrs)
635 {
636 op->atr_cb (op->cls, &identity, NULL, NULL);
637 }
638 else
639 {
640 for (le = attrs->list_head; NULL != le; le = le->next)
641 {
642 if (GNUNET_NO ==
644 {
645 for (ple = pl->list_head; NULL != ple; ple = ple->next)
646 {
647 if (GNUNET_YES ==
650 {
651 op->atr_cb (op->cls, &identity,
652 le->attribute, ple->presentation);
653 break;
654 }
655
656 }
657 }
658 else // No credentials
659 {
660 op->atr_cb (op->cls, &identity,
661 le->attribute, NULL);
662 }
663 }
664 }
665 op->atr_cb (op->cls, NULL, NULL, NULL);
666 }
667 if (NULL != attrs)
669 if (NULL != pl)
671 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
672 free_op (op);
673 return;
674 }
675 GNUNET_assert (0);
676}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:103
@ 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.
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)
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.
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_CRYPTO_read_public_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_RECLAIM_attribute_list_deserialize(), GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_id_is_equal, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_presentation_list_deserialize(), GNUNET_RECLAIM_presentation_list_destroy(), GNUNET_SYSERR, GNUNET_YES, h, identity, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_PresentationList::list_head, msg, GNUNET_RECLAIM_AttributeListEntry::next, GNUNET_RECLAIM_PresentationListEntry::next, GNUNET_ARM_Operation::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 688 of file reclaim_api.c.

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

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

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

References GNUNET_RECLAIM_AttributeIterator::finish_cb, GNUNET_RECLAIM_AttributeIterator::finish_cb_cls, force_reconnect(), free_it(), free_op(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, 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 799 of file reclaim_api.c.

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

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

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

References GNUNET_RECLAIM_CredentialIterator::finish_cb, GNUNET_RECLAIM_CredentialIterator::finish_cb_cls, force_reconnect(), free_ait(), free_op(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, 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 916 of file reclaim_api.c.

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

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

943{
944 struct GNUNET_RECLAIM_Handle *handle = cls;
947 struct GNUNET_RECLAIM_PresentationList *presentation;
948 uint32_t r_id = ntohl (msg->id);
950 size_t pres_len;
951 size_t tkt_len;
952 size_t tb_read;
953 char *buf;
954
955 tkt_len = ntohs (msg->tkt_len);
956 pres_len = ntohs (msg->presentations_len);
957 for (op = handle->op_head; NULL != op; op = op->next)
958 if (op->r_id == r_id)
959 break;
960 for (it = handle->ticket_it_head; NULL != it; it = it->next)
961 if (it->r_id == r_id)
962 break;
963 if ((NULL == op) && (NULL == it))
964 return;
965 buf = (char*) &msg[1];
966 if (0 < tkt_len)
967 {
970 tkt_len,
971 &ticket,
972 &tb_read));
973 buf += tb_read;
974 }
975 if (NULL != op)
976 {
977 if (0 < pres_len)
979 buf,
980 pres_len);
981 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
982 if (0 == tb_read)
983 {
984 if (NULL != op->ti_cb)
985 op->ti_cb (op->cls, NULL, NULL);
986 }
987 else
988 {
989 if (NULL != op->ti_cb)
990 op->ti_cb (op->cls,
991 &ticket,
992 (0 < pres_len) ? presentation : NULL);
993 }
994 if (0 < pres_len)
996 free_op (op);
997 return;
998 }
999 else if (NULL != it)
1000 {
1001 if (0 == tkt_len)
1002 {
1003 GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
1004 handle->ticket_it_tail,
1005 it);
1006 it->finish_cb (it->finish_cb_cls);
1007 GNUNET_free (it);
1008 }
1009 else
1010 {
1011 if (NULL != it->tr_cb)
1012 it->tr_cb (it->cls, &ticket);
1013 }
1014 return;
1015 }
1016 GNUNET_break (0);
1017}
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:1752
Handle for a ticket iterator operation.
Definition: reclaim_api.c:118
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:147
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:173
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:137
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:142
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:152
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:122
The authorization ticket.

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

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

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: