uint16_t size;
size = ntohs (im->header.size);
- if (size <= sizeof (struct RevokeTicketMessage)) {
+ if (size != sizeof (struct RevokeTicketMessage)) {
GNUNET_break (0);
return GNUNET_SYSERR;
}
{
struct TicketRevocationOperation *rop;
struct IdpClient *idp = cls;
- struct GNUNET_RECLAIM_Ticket *ticket;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
rop = GNUNET_new (struct TicketRevocationOperation);
- ticket = (struct GNUNET_RECLAIM_Ticket *)&rm[1];
rop->r_id = ntohl (rm->id);
rop->client = idp;
GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
rop->rh
- = RECLAIM_TICKETS_revoke (ticket, &rm->identity, &revoke_result_cb, rop);
+ = RECLAIM_TICKETS_revoke (&rm->ticket, &rm->identity, &revoke_result_cb, rop);
GNUNET_SERVICE_client_continue (idp->client);
}
uint16_t size;
size = ntohs (cm->header.size);
- if (size <= sizeof (struct ConsumeTicketMessage)) {
+ if (size != sizeof (struct ConsumeTicketMessage)) {
GNUNET_break (0);
return GNUNET_SYSERR;
}
handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
{
struct ConsumeTicketOperation *cop;
- struct GNUNET_RECLAIM_Ticket *ticket;
struct IdpClient *idp = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
cop = GNUNET_new (struct ConsumeTicketOperation);
cop->r_id = ntohl (cm->id);
cop->client = idp;
- ticket = (struct GNUNET_RECLAIM_Ticket *)&cm[1];
cop->ch
- = RECLAIM_TICKETS_consume (&cm->identity, ticket, &consume_result_cb, cop);
+ = RECLAIM_TICKETS_consume (&cm->identity, &cm->ticket, &consume_result_cb, cop);
GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
GNUNET_SERVICE_client_continue (idp->client);
}
struct GNUNET_MQ_Envelope *env;
struct TicketResultMessage *trm;
+ env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
if (NULL == ticket) {
/* send empty response to indicate end of list */
- env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
GNUNET_CONTAINER_DLL_remove (ti->client->ticket_iter_head,
ti->client->ticket_iter_tail,
ti);
} else {
- env = GNUNET_MQ_msg_extra (trm,
- sizeof (struct GNUNET_RECLAIM_Ticket),
- GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
- memcpy (&trm[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket));
+ trm->ticket = *ticket;
}
trm->id = htonl (ti->r_id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
*/
uint32_t attrs_len GNUNET_PACKED;
- // Followed by a ticket and serialized attribute list
+ /**
+ * The ticket to revoke
+ */
+ struct GNUNET_RECLAIM_Ticket ticket;
};
/**
* Unique identifier for this request (for key collisions).
*/
uint32_t id GNUNET_PACKED;
+
+ /**
+ * The new ticket
+ */
+ struct GNUNET_RECLAIM_Ticket ticket;
};
/**
*/
struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
- // Followed by a serialized ticket
+ /**
+ * The ticket to consume
+ */
+ struct GNUNET_RECLAIM_Ticket ticket;
};
/**
struct GNUNET_RECLAIM_Handle *handle = cls;
struct GNUNET_RECLAIM_Operation *op;
struct GNUNET_RECLAIM_TicketIterator *it;
- const struct GNUNET_RECLAIM_Ticket *ticket;
uint32_t r_id = ntohl (msg->id);
- size_t msg_len;
for (op = handle->op_head; NULL != op; op = op->next)
if (op->r_id == r_id)
break;
if ((NULL == op) && (NULL == it))
return;
- msg_len = ntohs (msg->header.size);
if (NULL != op) {
GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
- if (msg_len == sizeof (struct TicketResultMessage)) {
+ if (memcmp (&msg->ticket, 0, sizeof (struct GNUNET_RECLAIM_Ticket)))
+ {
if (NULL != op->tr_cb)
op->tr_cb (op->cls, NULL);
} else {
- ticket = (struct GNUNET_RECLAIM_Ticket *)&msg[1];
if (NULL != op->tr_cb)
- op->tr_cb (op->cls, ticket);
+ op->tr_cb (op->cls, &msg->ticket);
}
free_op (op);
return;
} else if (NULL != it) {
- if (msg_len == sizeof (struct TicketResultMessage)) {
- if (NULL != it->tr_cb)
- GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
- handle->ticket_it_tail, it);
+ if (memcmp (&msg->ticket, 0, sizeof (struct GNUNET_RECLAIM_Ticket)))
+ {
+ GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
+ handle->ticket_it_tail, it);
it->finish_cb (it->finish_cb_cls);
GNUNET_free (it);
} else {
- ticket = (struct GNUNET_RECLAIM_Ticket *)&msg[1];
if (NULL != it->tr_cb)
- it->tr_cb (it->cls, ticket);
+ it->tr_cb (it->cls, &msg->ticket);
}
return;
}
op->r_id = h->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
op->env =
- GNUNET_MQ_msg_extra (ctm, sizeof (const struct GNUNET_RECLAIM_Ticket),
- GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
+ GNUNET_MQ_msg (ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
ctm->identity = *identity;
ctm->id = htonl (op->r_id);
-
- GNUNET_memcpy ((char *)&ctm[1], ticket,
- sizeof (const struct GNUNET_RECLAIM_Ticket));
-
+ ctm->ticket = *ticket;
if (NULL != h->mq)
GNUNET_MQ_send_copy (h->mq, op->env);
return op;
op->cls = cb_cls;
op->r_id = rid;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- op->env = GNUNET_MQ_msg_extra (msg, sizeof (struct GNUNET_RECLAIM_Ticket),
- GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET);
+ op->env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET);
msg->id = htonl (rid);
msg->identity = *identity;
- GNUNET_memcpy (&msg[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket));
+ msg->ticket = *ticket;
if (NULL != h->mq) {
GNUNET_MQ_send (h->mq, op->env);
op->env = NULL;