aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/reclaim_api.c
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-10-31 17:47:22 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:04 +0100
commit17af2a636fc8fd0c111c7550484b2582cb7eb64a (patch)
tree96996cb243cdd8d6d7c557d3d7498119d4687800 /src/reclaim/reclaim_api.c
parent6157f0cb7ae89094f91f19fe09b92445efc746e4 (diff)
downloadgnunet-17af2a636fc8fd0c111c7550484b2582cb7eb64a.tar.gz
gnunet-17af2a636fc8fd0c111c7550484b2582cb7eb64a.zip
Prepared Listing of References
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r--src/reclaim/reclaim_api.c121
1 files changed, 112 insertions, 9 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 7c7261522..ede2daf28 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -504,16 +504,16 @@ handle_consume_ticket_result (void *cls,
504 { 504 {
505 if (NULL == attrs) 505 if (NULL == attrs)
506 { 506 {
507 op->ar_cb (op->cls, &msg->identity, NULL, NULL); 507 op->ar_cb (op->cls, &msg->identity, NULL, NULL, NULL);
508 } 508 }
509 else 509 else
510 { 510 {
511 for (le = attrs->list_head; NULL != le; le = le->next) 511 for (le = attrs->list_head; NULL != le; le = le->next)
512 op->ar_cb (op->cls, &msg->identity, le->claim, NULL); 512 op->ar_cb (op->cls, &msg->identity, le->claim, NULL, NULL);
513 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); 513 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
514 attrs = NULL; 514 attrs = NULL;
515 } 515 }
516 op->ar_cb (op->cls, NULL, NULL, NULL); 516 op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
517 } 517 }
518 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 518 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
519 free_op (op); 519 free_op (op);
@@ -597,7 +597,7 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
597 if (NULL != op) 597 if (NULL != op)
598 { 598 {
599 if (NULL != op->ar_cb) 599 if (NULL != op->ar_cb)
600 op->ar_cb (op->cls, NULL, NULL, NULL); 600 op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
601 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 601 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
602 free_op (op); 602 free_op (op);
603 } 603 }
@@ -610,12 +610,12 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
610 if (NULL != it) 610 if (NULL != it)
611 { 611 {
612 if (NULL != it->proc) 612 if (NULL != it->proc)
613 it->proc (it->proc_cls, &msg->identity, attr, NULL); 613 it->proc (it->proc_cls, &msg->identity, attr, NULL, NULL);
614 } 614 }
615 else if (NULL != op) 615 else if (NULL != op)
616 { 616 {
617 if (NULL != op->ar_cb) 617 if (NULL != op->ar_cb)
618 op->ar_cb (op->cls, &msg->identity, attr, NULL); 618 op->ar_cb (op->cls, &msg->identity, attr, NULL, NULL);
619 } 619 }
620 GNUNET_free (attr); 620 GNUNET_free (attr);
621 return; 621 return;
@@ -696,7 +696,7 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg)
696 if (NULL != op) 696 if (NULL != op)
697 { 697 {
698 if (NULL != op->ar_cb) 698 if (NULL != op->ar_cb)
699 op->ar_cb (op->cls, NULL, NULL, NULL); 699 op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
700 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 700 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
701 free_op (op); 701 free_op (op);
702 } 702 }
@@ -709,12 +709,111 @@ handle_attestation_result (void *cls, const struct AttributeResultMessage *msg)
709 if (NULL != it) 709 if (NULL != it)
710 { 710 {
711 if (NULL != it->proc) 711 if (NULL != it->proc)
712 it->proc (it->proc_cls, &msg->identity, NULL, attr); 712 it->proc (it->proc_cls, &msg->identity, NULL, attr, NULL);
713 } 713 }
714 else if (NULL != op) 714 else if (NULL != op)
715 { 715 {
716 if (NULL != op->ar_cb) 716 if (NULL != op->ar_cb)
717 op->ar_cb (op->cls, &msg->identity, NULL, attr); 717 op->ar_cb (op->cls, &msg->identity, NULL, attr, NULL);
718 }
719 GNUNET_free (attr);
720 return;
721 }
722 GNUNET_assert (0);
723}
724
725/**
726 * Handle an incoming message of type
727 * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
728 *
729 * @param cls
730 * @param msg the message we received
731 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
732 */
733static int
734check_reference_result (void *cls, const struct AttributeResultMessage *msg)
735{
736 size_t msg_len;
737 size_t attr_len;
738
739 msg_len = ntohs (msg->header.size);
740 attr_len = ntohs (msg->attr_len);
741 if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
742 {
743 GNUNET_break (0);
744 return GNUNET_SYSERR;
745 }
746 return GNUNET_OK;
747}
748
749/**
750* Handle an incoming message of type
751* #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
752*
753* @param cls
754* @param msg the message we received
755*/
756static void
757handle_reference_result (void *cls, const struct AttributeResultMessage *msg)
758{
759 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
760 struct GNUNET_RECLAIM_Handle *h = cls;
761 struct GNUNET_RECLAIM_AttributeIterator *it;
762 struct GNUNET_RECLAIM_Operation *op;
763 size_t attr_len;
764 uint32_t r_id = ntohl (msg->id);
765
766 attr_len = ntohs (msg->attr_len);
767 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n");
768
769
770 for (it = h->it_head; NULL != it; it = it->next)
771 if (it->r_id == r_id)
772 break;
773 for (op = h->op_head; NULL != op; op = op->next)
774 if (op->r_id == r_id)
775 break;
776 if ((NULL == it) && (NULL == op))
777 return;
778
779 if ((0 ==
780 (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
781 {
782 if ((NULL == it) && (NULL == op))
783 {
784 GNUNET_break (0);
785 force_reconnect (h);
786 return;
787 }
788 if (NULL != it)
789 {
790 if (NULL != it->finish_cb)
791 it->finish_cb (it->finish_cb_cls);
792 free_it (it);
793 }
794 if (NULL != op)
795 {
796 if (NULL != op->ar_cb)
797 op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
798 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
799 free_op (op);
800 }
801 return;
802 }
803
804 {
805 struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
806 attr = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1],
807 attr_len);
808 if (NULL != it)
809 {
810 if (NULL != it->proc)
811 it->proc (it->proc_cls, &msg->identity, NULL, NULL, attr);
812 }
813 else if (NULL != op)
814 {
815 if (NULL != op->ar_cb)
816 op->ar_cb (op->cls, &msg->identity, NULL, NULL, attr);
718 } 817 }
719 GNUNET_free (attr); 818 GNUNET_free (attr);
720 return; 819 return;
@@ -844,6 +943,10 @@ reconnect (struct GNUNET_RECLAIM_Handle *h)
844 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT, 943 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT,
845 struct AttributeResultMessage, 944 struct AttributeResultMessage,
846 h), 945 h),
946 GNUNET_MQ_hd_var_size (reference_result,
947 GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT,
948 struct AttributeResultMessage,
949 h),
847 GNUNET_MQ_hd_fixed_size (ticket_result, 950 GNUNET_MQ_hd_fixed_size (ticket_result,
848 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 951 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
849 struct TicketResultMessage, 952 struct TicketResultMessage,