diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-04 23:34:10 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-09 20:38:10 +0100 |
commit | 5fb277e8d012d687f4d2d032571cd4b57946bbfb (patch) | |
tree | 2387ee8a40ef9d308e6d34ebd0f8af0dc90feb5f /src/reclaim | |
parent | 065ecd9a0f92ecafd6c552494a6310b92cc08597 (diff) | |
download | gnunet-5fb277e8d012d687f4d2d032571cd4b57946bbfb.tar.gz gnunet-5fb277e8d012d687f4d2d032571cd4b57946bbfb.zip |
towards better API
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 31 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 13 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_openid_connect.c | 3 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 3 | ||||
-rw-r--r-- | src/reclaim/reclaim.h | 5 | ||||
-rw-r--r-- | src/reclaim/reclaim_api.c | 12 |
6 files changed, 53 insertions, 14 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index 3e31fef4c..0170ceff2 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -553,13 +553,27 @@ iter_cb (void *cls, | |||
553 | attr->data_size); | 553 | attr->data_size); |
554 | attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); | 554 | attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); |
555 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); | 555 | id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); |
556 | fprintf (stdout, | 556 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->attestation)) |
557 | "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", | 557 | { |
558 | attr->name, | 558 | fprintf (stdout, |
559 | attr_str, | 559 | "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", |
560 | attr_type, | 560 | attr->name, |
561 | attr->flag, | 561 | attr_str, |
562 | id); | 562 | attr_type, |
563 | attr->flag, | ||
564 | id); | ||
565 | } | ||
566 | else | ||
567 | { | ||
568 | fprintf (stdout, | ||
569 | "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", | ||
570 | attr->name, | ||
571 | attr_str, | ||
572 | attr_type, | ||
573 | attr->flag, | ||
574 | id); | ||
575 | |||
576 | } | ||
563 | GNUNET_free (id); | 577 | GNUNET_free (id); |
564 | } | 578 | } |
565 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); | 579 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); |
@@ -609,7 +623,8 @@ attest_iter_finished (void *cls) | |||
609 | static void | 623 | static void |
610 | attest_iter_cb (void *cls, | 624 | attest_iter_cb (void *cls, |
611 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 625 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
612 | const struct GNUNET_RECLAIM_Attestation *attest) | 626 | const struct GNUNET_RECLAIM_Attestation *attest, |
627 | const struct GNUNET_RECLAIM_AttributeList *attrs) | ||
613 | { | 628 | { |
614 | char *attest_str; | 629 | char *attest_str; |
615 | char *id; | 630 | char *id; |
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 61d029665..99831172b 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -1900,7 +1900,10 @@ attest_iter_cb (void *cls, | |||
1900 | { | 1900 | { |
1901 | struct Iterator *ai = cls; | 1901 | struct Iterator *ai = cls; |
1902 | struct GNUNET_MQ_Envelope *env; | 1902 | struct GNUNET_MQ_Envelope *env; |
1903 | struct GNUNET_RECLAIM_AttributeList *attrs; | ||
1904 | struct GNUNET_RECLAIM_Attestation *att; | ||
1903 | char *data_tmp; | 1905 | char *data_tmp; |
1906 | char *attrs_size; | ||
1904 | 1907 | ||
1905 | if ((rd_count != 1) || | 1908 | if ((rd_count != 1) || |
1906 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd->record_type)) | 1909 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd->record_type)) |
@@ -1908,6 +1911,10 @@ attest_iter_cb (void *cls, | |||
1908 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | 1911 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); |
1909 | return; | 1912 | return; |
1910 | } | 1913 | } |
1914 | att = GNUNET_RECLAIM_attestation_deserialize (rd->data, | ||
1915 | rd->data_size); | ||
1916 | attrs = GNUNET_RECLAIM_attestation_get_attributes (att); | ||
1917 | attrs_size = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); | ||
1911 | 1918 | ||
1912 | struct AttestationResultMessage *arm; | 1919 | struct AttestationResultMessage *arm; |
1913 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", | 1920 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", |
@@ -1915,13 +1922,17 @@ attest_iter_cb (void *cls, | |||
1915 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1922 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1916 | "Sending ATTESTATION_RESULT message\n"); | 1923 | "Sending ATTESTATION_RESULT message\n"); |
1917 | env = GNUNET_MQ_msg_extra (arm, | 1924 | env = GNUNET_MQ_msg_extra (arm, |
1918 | rd->data_size, | 1925 | rd->data_size + attrs_size, |
1919 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); | 1926 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); |
1920 | arm->id = htonl (ai->request_id); | 1927 | arm->id = htonl (ai->request_id); |
1921 | arm->attestation_len = htons (rd->data_size); | 1928 | arm->attestation_len = htons (rd->data_size); |
1922 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); | 1929 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); |
1923 | data_tmp = (char *) &arm[1]; | 1930 | data_tmp = (char *) &arm[1]; |
1924 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 1931 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
1932 | data_tmp += rd->data_size; | ||
1933 | GNUNET_RECLAIM_attribute_list_serialize (attrs, | ||
1934 | data_tmp); | ||
1935 | |||
1925 | GNUNET_MQ_send (ai->client->mq, env); | 1936 | GNUNET_MQ_send (ai->client->mq, env); |
1926 | } | 1937 | } |
1927 | 1938 | ||
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c index 345dbeed6..b296f6d15 100644 --- a/src/reclaim/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c | |||
@@ -988,7 +988,8 @@ oidc_attest_collect_finished_cb (void *cls) | |||
988 | static void | 988 | static void |
989 | oidc_attest_collect (void *cls, | 989 | oidc_attest_collect (void *cls, |
990 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 990 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
991 | const struct GNUNET_RECLAIM_Attestation *attest) | 991 | const struct GNUNET_RECLAIM_Attestation *attest, |
992 | const struct GNUNET_RECLAIM_AttributeList *attrs) | ||
992 | { | 993 | { |
993 | struct RequestHandle *handle = cls; | 994 | struct RequestHandle *handle = cls; |
994 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 995 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 6f7a5987b..cddee9b54 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -619,7 +619,8 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
619 | static void | 619 | static void |
620 | attest_collect (void *cls, | 620 | attest_collect (void *cls, |
621 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 621 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
622 | const struct GNUNET_RECLAIM_Attestation *attest) | 622 | const struct GNUNET_RECLAIM_Attestation *attest, |
623 | const struct GNUNET_RECLAIM_AttributeList *attrs) | ||
623 | { | 624 | { |
624 | struct RequestHandle *handle = cls; | 625 | struct RequestHandle *handle = cls; |
625 | json_t *attr_obj; | 626 | json_t *attr_obj; |
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h index 7b5d7ab19..2cd07e861 100644 --- a/src/reclaim/reclaim.h +++ b/src/reclaim/reclaim.h | |||
@@ -179,6 +179,11 @@ struct AttestationResultMessage | |||
179 | uint16_t attestation_len GNUNET_PACKED; | 179 | uint16_t attestation_len GNUNET_PACKED; |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * Length of serialized attribute data | ||
183 | */ | ||
184 | uint16_t attributes_len GNUNET_PACKED; | ||
185 | |||
186 | /** | ||
182 | * always zero (for alignment) | 187 | * always zero (for alignment) |
183 | */ | 188 | */ |
184 | uint16_t reserved GNUNET_PACKED; | 189 | uint16_t reserved GNUNET_PACKED; |
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index 3820550c9..afab33320 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -801,11 +801,14 @@ handle_attestation_result (void *cls, const struct | |||
801 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; | 801 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; |
802 | struct GNUNET_RECLAIM_Handle *h = cls; | 802 | struct GNUNET_RECLAIM_Handle *h = cls; |
803 | struct GNUNET_RECLAIM_AttestationIterator *it; | 803 | struct GNUNET_RECLAIM_AttestationIterator *it; |
804 | struct GNUNET_RECLAIM_AttributeList *attrs; | ||
804 | struct GNUNET_RECLAIM_Operation *op; | 805 | struct GNUNET_RECLAIM_Operation *op; |
805 | size_t att_len; | 806 | size_t att_len; |
807 | size_t attrs_len; | ||
806 | uint32_t r_id = ntohl (msg->id); | 808 | uint32_t r_id = ntohl (msg->id); |
807 | 809 | ||
808 | att_len = ntohs (msg->attestation_len); | 810 | att_len = ntohs (msg->attestation_len); |
811 | attrs_len = ntohs (msg->attributes_len); | ||
809 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n"); | 812 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n"); |
810 | 813 | ||
811 | 814 | ||
@@ -836,7 +839,7 @@ handle_attestation_result (void *cls, const struct | |||
836 | if (NULL != op) | 839 | if (NULL != op) |
837 | { | 840 | { |
838 | if (NULL != op->at_cb) | 841 | if (NULL != op->at_cb) |
839 | op->at_cb (op->cls, NULL, NULL); | 842 | op->at_cb (op->cls, NULL, NULL, NULL); |
840 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 843 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); |
841 | free_op (op); | 844 | free_op (op); |
842 | } | 845 | } |
@@ -846,17 +849,20 @@ handle_attestation_result (void *cls, const struct | |||
846 | { | 849 | { |
847 | struct GNUNET_RECLAIM_Attestation *att; | 850 | struct GNUNET_RECLAIM_Attestation *att; |
848 | att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len); | 851 | att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len); |
852 | char *read_ptr = ((char *) &msg[1]) + att_len; | ||
853 | attrs = GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len); | ||
849 | if (NULL != it) | 854 | if (NULL != it) |
850 | { | 855 | { |
851 | if (NULL != it->proc) | 856 | if (NULL != it->proc) |
852 | it->proc (it->proc_cls, &msg->identity, att); | 857 | it->proc (it->proc_cls, &msg->identity, att, attrs); |
853 | } | 858 | } |
854 | else if (NULL != op) | 859 | else if (NULL != op) |
855 | { | 860 | { |
856 | if (NULL != op->at_cb) | 861 | if (NULL != op->at_cb) |
857 | op->at_cb (op->cls, &msg->identity, att); | 862 | op->at_cb (op->cls, &msg->identity, att, attrs); |
858 | } | 863 | } |
859 | GNUNET_free (att); | 864 | GNUNET_free (att); |
865 | GNUNET_RECLAIM_attribute_list_destroy (attrs); | ||
860 | return; | 866 | return; |
861 | } | 867 | } |
862 | GNUNET_assert (0); | 868 | GNUNET_assert (0); |