aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/reclaim_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-05-22 16:25:38 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-05-22 16:25:38 +0200
commitb2e257ecb9c82b19f6ab23431faa3605718d3f01 (patch)
tree767b8cf35d6e1c9a741ee7e87f33dc852a6593cc /src/reclaim/reclaim_api.c
parentf9c41505dd2ad80d08d6b516c534df0a66ea55fc (diff)
downloadgnunet-b2e257ecb9c82b19f6ab23431faa3605718d3f01.tar.gz
gnunet-b2e257ecb9c82b19f6ab23431faa3605718d3f01.zip
clang-format and cleanup
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r--src/reclaim/reclaim_api.c142
1 files changed, 70 insertions, 72 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 2e64a27b6..5a9b9d4a9 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -1,22 +1,22 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V. 3 Copyright (C) 2016 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License, 7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file reclaim/reclaim_api.c 22 * @file reclaim/reclaim_api.c
@@ -24,9 +24,7 @@
24 * @author Martin Schanzenbach 24 * @author Martin Schanzenbach
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27
28#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
29
30#include "gnunet_constants.h" 28#include "gnunet_constants.h"
31#include "gnunet_mq_lib.h" 29#include "gnunet_mq_lib.h"
32#include "gnunet_protocols.h" 30#include "gnunet_protocols.h"
@@ -351,9 +349,9 @@ force_reconnect (struct GNUNET_RECLAIM_Handle *handle)
351 GNUNET_MQ_destroy (handle->mq); 349 GNUNET_MQ_destroy (handle->mq);
352 handle->mq = NULL; 350 handle->mq = NULL;
353 handle->reconnect_backoff = 351 handle->reconnect_backoff =
354 GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); 352 GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
355 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed ( 353 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (
356 handle->reconnect_backoff, &reconnect_task, handle); 354 handle->reconnect_backoff, &reconnect_task, handle);
357} 355}
358 356
359 357
@@ -498,7 +496,7 @@ handle_consume_ticket_result (void *cls,
498 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 496 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
499 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 497 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
500 attrs = 498 attrs =
501 GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *)&msg[1], attrs_len); 499 GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *)&msg[1], attrs_len);
502 if (NULL != op->ar_cb) { 500 if (NULL != op->ar_cb) {
503 if (NULL == attrs) { 501 if (NULL == attrs) {
504 op->ar_cb (op->cls, &msg->identity, NULL); 502 op->ar_cb (op->cls, &msg->identity, NULL);
@@ -735,29 +733,29 @@ static void
735reconnect (struct GNUNET_RECLAIM_Handle *h) 733reconnect (struct GNUNET_RECLAIM_Handle *h)
736{ 734{
737 struct GNUNET_MQ_MessageHandler handlers[] = { 735 struct GNUNET_MQ_MessageHandler handlers[] = {
738 GNUNET_MQ_hd_fixed_size (success_response, 736 GNUNET_MQ_hd_fixed_size (success_response,
739 GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, 737 GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE,
740 struct SuccessResultMessage, h), 738 struct SuccessResultMessage, h),
741 GNUNET_MQ_hd_var_size (attribute_result, 739 GNUNET_MQ_hd_var_size (attribute_result,
742 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, 740 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT,
743 struct AttributeResultMessage, h), 741 struct AttributeResultMessage, h),
744 GNUNET_MQ_hd_var_size (ticket_result, 742 GNUNET_MQ_hd_var_size (ticket_result,
745 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 743 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
746 struct TicketResultMessage, h), 744 struct TicketResultMessage, h),
747 GNUNET_MQ_hd_var_size (consume_ticket_result, 745 GNUNET_MQ_hd_var_size (consume_ticket_result,
748 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, 746 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT,
749 struct ConsumeTicketResultMessage, h), 747 struct ConsumeTicketResultMessage, h),
750 GNUNET_MQ_hd_fixed_size (revoke_ticket_result, 748 GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
751 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, 749 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT,
752 struct RevokeTicketResultMessage, h), 750 struct RevokeTicketResultMessage, h),
753 GNUNET_MQ_handler_end ()}; 751 GNUNET_MQ_handler_end ()};
754 struct GNUNET_RECLAIM_Operation *op; 752 struct GNUNET_RECLAIM_Operation *op;
755 753
756 GNUNET_assert (NULL == h->mq); 754 GNUNET_assert (NULL == h->mq);
757 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n"); 755 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
758 756
759 h->mq = 757 h->mq =
760 GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h); 758 GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
761 if (NULL == h->mq) 759 if (NULL == h->mq)
762 return; 760 return;
763 for (op = h->op_head; NULL != op; op = op->next) 761 for (op = h->op_head; NULL != op; op = op->next)
@@ -840,11 +838,11 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h)
840 */ 838 */
841struct GNUNET_RECLAIM_Operation * 839struct GNUNET_RECLAIM_Operation *
842GNUNET_RECLAIM_attribute_store ( 840GNUNET_RECLAIM_attribute_store (
843 struct GNUNET_RECLAIM_Handle *h, 841 struct GNUNET_RECLAIM_Handle *h,
844 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 842 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
845 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 843 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
846 const struct GNUNET_TIME_Relative *exp_interval, 844 const struct GNUNET_TIME_Relative *exp_interval,
847 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls) 845 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
848{ 846{
849 struct GNUNET_RECLAIM_Operation *op; 847 struct GNUNET_RECLAIM_Operation *op;
850 struct AttributeStoreMessage *sam; 848 struct AttributeStoreMessage *sam;
@@ -885,10 +883,10 @@ GNUNET_RECLAIM_attribute_store (
885 */ 883 */
886struct GNUNET_RECLAIM_Operation * 884struct GNUNET_RECLAIM_Operation *
887GNUNET_RECLAIM_attribute_delete ( 885GNUNET_RECLAIM_attribute_delete (
888 struct GNUNET_RECLAIM_Handle *h, 886 struct GNUNET_RECLAIM_Handle *h,
889 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 887 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
890 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 888 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
891 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls) 889 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
892{ 890{
893 struct GNUNET_RECLAIM_Operation *op; 891 struct GNUNET_RECLAIM_Operation *op;
894 struct AttributeDeleteMessage *dam; 892 struct AttributeDeleteMessage *dam;
@@ -940,11 +938,11 @@ GNUNET_RECLAIM_attribute_delete (
940 */ 938 */
941struct GNUNET_RECLAIM_AttributeIterator * 939struct GNUNET_RECLAIM_AttributeIterator *
942GNUNET_RECLAIM_get_attributes_start ( 940GNUNET_RECLAIM_get_attributes_start (
943 struct GNUNET_RECLAIM_Handle *h, 941 struct GNUNET_RECLAIM_Handle *h,
944 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 942 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
945 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, 943 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
946 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, 944 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
947 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls) 945 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
948{ 946{
949 struct GNUNET_RECLAIM_AttributeIterator *it; 947 struct GNUNET_RECLAIM_AttributeIterator *it;
950 struct GNUNET_MQ_Envelope *env; 948 struct GNUNET_MQ_Envelope *env;
@@ -989,7 +987,7 @@ GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it)
989 struct GNUNET_MQ_Envelope *env; 987 struct GNUNET_MQ_Envelope *env;
990 988
991 env = 989 env =
992 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); 990 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT);
993 msg->id = htonl (it->r_id); 991 msg->id = htonl (it->r_id);
994 GNUNET_MQ_send (h->mq, env); 992 GNUNET_MQ_send (h->mq, env);
995} 993}
@@ -1034,11 +1032,11 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it)
1034 */ 1032 */
1035struct GNUNET_RECLAIM_Operation * 1033struct GNUNET_RECLAIM_Operation *
1036GNUNET_RECLAIM_ticket_issue ( 1034GNUNET_RECLAIM_ticket_issue (
1037 struct GNUNET_RECLAIM_Handle *h, 1035 struct GNUNET_RECLAIM_Handle *h,
1038 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 1036 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1039 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 1037 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1040 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 1038 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1041 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls) 1039 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls)
1042{ 1040{
1043 struct GNUNET_RECLAIM_Operation *op; 1041 struct GNUNET_RECLAIM_Operation *op;
1044 struct IssueTicketMessage *tim; 1042 struct IssueTicketMessage *tim;
@@ -1080,10 +1078,10 @@ GNUNET_RECLAIM_ticket_issue (
1080 */ 1078 */
1081struct GNUNET_RECLAIM_Operation * 1079struct GNUNET_RECLAIM_Operation *
1082GNUNET_RECLAIM_ticket_consume ( 1080GNUNET_RECLAIM_ticket_consume (
1083 struct GNUNET_RECLAIM_Handle *h, 1081 struct GNUNET_RECLAIM_Handle *h,
1084 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1082 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1085 const struct GNUNET_RECLAIM_Ticket *ticket, 1083 const struct GNUNET_RECLAIM_Ticket *ticket,
1086 GNUNET_RECLAIM_AttributeResult cb, void *cb_cls) 1084 GNUNET_RECLAIM_AttributeResult cb, void *cb_cls)
1087{ 1085{
1088 struct GNUNET_RECLAIM_Operation *op; 1086 struct GNUNET_RECLAIM_Operation *op;
1089 struct ConsumeTicketMessage *ctm; 1087 struct ConsumeTicketMessage *ctm;
@@ -1095,8 +1093,8 @@ GNUNET_RECLAIM_ticket_consume (
1095 op->r_id = h->r_id_gen++; 1093 op->r_id = h->r_id_gen++;
1096 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1094 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1097 op->env = 1095 op->env =
1098 GNUNET_MQ_msg_extra (ctm, sizeof (const struct GNUNET_RECLAIM_Ticket), 1096 GNUNET_MQ_msg_extra (ctm, sizeof (const struct GNUNET_RECLAIM_Ticket),
1099 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); 1097 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
1100 ctm->identity = *identity; 1098 ctm->identity = *identity;
1101 ctm->id = htonl (op->r_id); 1099 ctm->id = htonl (op->r_id);
1102 1100
@@ -1128,11 +1126,11 @@ GNUNET_RECLAIM_ticket_consume (
1128 */ 1126 */
1129struct GNUNET_RECLAIM_TicketIterator * 1127struct GNUNET_RECLAIM_TicketIterator *
1130GNUNET_RECLAIM_ticket_iteration_start ( 1128GNUNET_RECLAIM_ticket_iteration_start (
1131 struct GNUNET_RECLAIM_Handle *h, 1129 struct GNUNET_RECLAIM_Handle *h,
1132 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1130 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1133 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, 1131 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
1134 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, 1132 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls,
1135 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls) 1133 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
1136{ 1134{
1137 struct GNUNET_RECLAIM_TicketIterator *it; 1135 struct GNUNET_RECLAIM_TicketIterator *it;
1138 struct GNUNET_MQ_Envelope *env; 1136 struct GNUNET_MQ_Envelope *env;
@@ -1196,7 +1194,7 @@ GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it)
1196 1194
1197 if (NULL != h->mq) { 1195 if (NULL != h->mq) {
1198 env = 1196 env =
1199 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); 1197 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP);
1200 msg->id = htonl (it->r_id); 1198 msg->id = htonl (it->r_id);
1201 GNUNET_MQ_send (h->mq, env); 1199 GNUNET_MQ_send (h->mq, env);
1202 } 1200 }
@@ -1219,10 +1217,10 @@ GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it)
1219 */ 1217 */
1220struct GNUNET_RECLAIM_Operation * 1218struct GNUNET_RECLAIM_Operation *
1221GNUNET_RECLAIM_ticket_revoke ( 1219GNUNET_RECLAIM_ticket_revoke (
1222 struct GNUNET_RECLAIM_Handle *h, 1220 struct GNUNET_RECLAIM_Handle *h,
1223 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1221 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1224 const struct GNUNET_RECLAIM_Ticket *ticket, 1222 const struct GNUNET_RECLAIM_Ticket *ticket,
1225 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls) 1223 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
1226{ 1224{
1227 struct GNUNET_RECLAIM_Operation *op; 1225 struct GNUNET_RECLAIM_Operation *op;
1228 struct RevokeTicketMessage *msg; 1226 struct RevokeTicketMessage *msg;