aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/reclaim_api.c
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-10-19 11:30:24 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:02 +0100
commit4eda8d33675ba1e004792635b33342c04c5cbe32 (patch)
tree93eab84b3b93dace71ec4f31988991abcd692a2d /src/reclaim/reclaim_api.c
parent483bc7e3095dff908fe8c032ea96995d44304868 (diff)
downloadgnunet-4eda8d33675ba1e004792635b33342c04c5cbe32.tar.gz
gnunet-4eda8d33675ba1e004792635b33342c04c5cbe32.zip
Listing Attestations through service
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r--src/reclaim/reclaim_api.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index a66bb69f2..860a0f0ab 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -623,6 +623,104 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
623 GNUNET_assert (0); 623 GNUNET_assert (0);
624} 624}
625 625
626/**
627 * Handle an incoming message of type
628 * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
629 *
630 * @param cls
631 * @param msg the message we received
632 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
633 */
634static int
635check_attestation_result (void *cls, const struct AttributeResultMessage *msg)
636{
637 size_t msg_len;
638 size_t attr_len;
639
640 msg_len = ntohs (msg->header.size);
641 attr_len = ntohs (msg->attr_len);
642 if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
643 {
644 GNUNET_break (0);
645 return GNUNET_SYSERR;
646 }
647 return GNUNET_OK;
648}
649
650
651/**
652 * Handle an incoming message of type
653 * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
654 *
655 * @param cls
656 * @param msg the message we received
657 */
658static void
659handle_attestation_result (void *cls, const struct AttributeResultMessage *msg)
660{
661 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
662 struct GNUNET_RECLAIM_Handle *h = cls;
663 struct GNUNET_RECLAIM_AttributeIterator *it;
664 struct GNUNET_RECLAIM_Operation *op;
665 size_t attr_len;
666 uint32_t r_id = ntohl (msg->id);
667
668 attr_len = ntohs (msg->attr_len);
669 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n");
670
671
672 for (it = h->it_head; NULL != it; it = it->next)
673 if (it->r_id == r_id)
674 break;
675 for (op = h->op_head; NULL != op; op = op->next)
676 if (op->r_id == r_id)
677 break;
678 if ((NULL == it) && (NULL == op))
679 return;
680
681 if ((0 ==
682 (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
683 {
684 if ((NULL == it) && (NULL == op))
685 {
686 GNUNET_break (0);
687 force_reconnect (h);
688 return;
689 }
690 if (NULL != it)
691 {
692 if (NULL != it->finish_cb)
693 it->finish_cb (it->finish_cb_cls);
694 free_it (it);
695 }
696 if (NULL != op)
697 {
698 if (NULL != op->ar_cb)
699 op->ar_cb (op->cls, NULL, NULL, NULL);
700 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
701 free_op (op);
702 }
703 return;
704 }
705
706 {
707 struct GNUNET_RECLAIM_ATTESTATION_Claim *attr;
708 attr = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1], attr_len);
709 if (NULL != it)
710 {
711 if (NULL != it->proc)
712 it->proc (it->proc_cls, &msg->identity, NULL, attr);
713 }
714 else if (NULL != op)
715 {
716 if (NULL != op->ar_cb)
717 op->ar_cb (op->cls, &msg->identity, NULL, attr);
718 }
719 GNUNET_free (attr);
720 return;
721 }
722 GNUNET_assert (0);
723}
626 724
627/** 725/**
628 * Handle an incoming message of type 726 * Handle an incoming message of type
@@ -742,6 +840,10 @@ reconnect (struct GNUNET_RECLAIM_Handle *h)
742 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, 840 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT,
743 struct AttributeResultMessage, 841 struct AttributeResultMessage,
744 h), 842 h),
843 GNUNET_MQ_hd_var_size (attestation_result,
844 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT,
845 struct AttributeResultMessage,
846 h),
745 GNUNET_MQ_hd_fixed_size (ticket_result, 847 GNUNET_MQ_hd_fixed_size (ticket_result,
746 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 848 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
747 struct TicketResultMessage, 849 struct TicketResultMessage,