From b2e257ecb9c82b19f6ab23431faa3605718d3f01 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Wed, 22 May 2019 16:25:38 +0200 Subject: clang-format and cleanup --- src/reclaim/Makefile.am | 3 +- src/reclaim/gnunet-service-reclaim.c | 197 ++++++++------------------- src/reclaim/gnunet-service-reclaim_tickets.c | 71 +++++----- src/reclaim/gnunet-service-reclaim_tickets.h | 1 - src/reclaim/json_reclaim.c | 58 ++++---- src/reclaim/json_reclaim.h | 28 ++-- src/reclaim/oidc_helper.c | 52 +++---- src/reclaim/oidc_helper.h | 28 ++-- src/reclaim/plugin_rest_openid_connect.c | 66 ++++----- src/reclaim/plugin_rest_reclaim.c | 79 +++++------ src/reclaim/reclaim_api.c | 142 ++++++++++--------- 11 files changed, 308 insertions(+), 417 deletions(-) (limited to 'src/reclaim') diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am index fb17a8174..6e5046437 100644 --- a/src/reclaim/Makefile.am +++ b/src/reclaim/Makefile.am @@ -73,7 +73,7 @@ libgnunet_plugin_rest_openid_connect_la_LIBADD = \ $(top_builddir)/src/rest/libgnunetrest.la \ $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \ $(top_builddir)/src/namestore/libgnunetnamestore.la \ -$(top_builddir)/src/gns/libgnunetgns.la \ + $(top_builddir)/src/gns/libgnunetgns.la \ $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ $(LTLIBINTL) -ljansson -lmicrohttpd @@ -98,7 +98,6 @@ gnunet_service_reclaim_LDADD = \ $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/namestore/libgnunetnamestore.la \ - $(top_builddir)/src/identity/libgnunetidentity.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \ libgnunetreclaim.la \ diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 1447f71f6..ffc67c5ae 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c @@ -28,34 +28,12 @@ #include "gnunet-service-reclaim_tickets.h" #include "gnunet_constants.h" #include "gnunet_gnsrecord_lib.h" -#include "gnunet_identity_service.h" -#include "gnunet_namestore_service.h" #include "gnunet_protocols.h" #include "gnunet_reclaim_attribute_lib.h" #include "gnunet_reclaim_service.h" #include "gnunet_signatures.h" #include "reclaim.h" -/** - * First pass state - */ -#define STATE_INIT 0 - -/** - * Normal operation state - */ -#define STATE_POST_INIT 1 - -/** - * Minimum interval between updates - */ -#define MIN_WAIT_TIME GNUNET_TIME_UNIT_MINUTES - - -/** - * Identity handle - */ -static struct GNUNET_IDENTITY_Handle *identity_handle; /** * Namestore handle @@ -67,11 +45,6 @@ static struct GNUNET_NAMESTORE_Handle *nsh; */ static struct GNUNET_SCHEDULER_Task *timeout_task; -/** - * Update task - */ -static struct GNUNET_SCHEDULER_Task *update_task; - /** * Our configuration. */ @@ -398,33 +371,6 @@ struct ConsumeTicketOperation }; -/** - * Updated attribute IDs - */ -struct TicketAttributeUpdateEntry -{ - /** - * DLL - */ - struct TicketAttributeUpdateEntry *next; - - /** - * DLL - */ - struct TicketAttributeUpdateEntry *prev; - - /** - * The old ID - */ - uint64_t old_id; - - /** - * The new ID - */ - uint64_t new_id; -}; - - /** * Ticket revocation request handle */ @@ -484,35 +430,6 @@ struct TicketIssueOperation }; -/** - * DLL for ego handles to egos containing the RECLAIM_ATTRS in a - * map in json_t format - * - */ -struct EgoEntry -{ - /** - * DLL - */ - struct EgoEntry *next; - - /** - * DLL - */ - struct EgoEntry *prev; - - /** - * Ego handle - */ - struct GNUNET_IDENTITY_Ego *ego; - - /** - * Attribute map. Contains the attributes as json_t - */ - struct GNUNET_CONTAINER_MultiHashMap *attr_map; -}; - - /** * Client list */ @@ -649,10 +566,6 @@ cleanup () RECLAIM_TICKETS_deinit (); if (NULL != timeout_task) GNUNET_SCHEDULER_cancel (timeout_task); - if (NULL != update_task) - GNUNET_SCHEDULER_cancel (update_task); - if (NULL != identity_handle) - GNUNET_IDENTITY_disconnect (identity_handle); if (NULL != nsh) GNUNET_NAMESTORE_disconnect (nsh); } @@ -1600,8 +1513,8 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) */ static void handle_ticket_iteration_start ( - void *cls, - const struct TicketIterationStartMessage *tis_msg) + void *cls, + const struct TicketIterationStartMessage *tis_msg) { struct IdpClient *client = cls; struct TicketIteration *ti; @@ -1713,8 +1626,6 @@ run (void *cls, "error connecting to namestore"); } - identity_handle = GNUNET_IDENTITY_connect (cfg, NULL, NULL); - GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); } @@ -1769,56 +1680,56 @@ client_connect_cb (void *cls, * Define "main" method using service macro. */ GNUNET_SERVICE_MAIN ( - "reclaim", - GNUNET_SERVICE_OPTION_NONE, - &run, - &client_connect_cb, - &client_disconnect_cb, - NULL, - GNUNET_MQ_hd_var_size (attribute_store_message, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, - struct AttributeStoreMessage, - NULL), - GNUNET_MQ_hd_var_size (attribute_delete_message, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, - struct AttributeDeleteMessage, - NULL), - GNUNET_MQ_hd_fixed_size ( - iteration_start, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, - struct AttributeIterationStartMessage, - NULL), - GNUNET_MQ_hd_fixed_size (iteration_next, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, - struct AttributeIterationNextMessage, - NULL), - GNUNET_MQ_hd_fixed_size (iteration_stop, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, - struct AttributeIterationStopMessage, - NULL), - GNUNET_MQ_hd_var_size (issue_ticket_message, - GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, - struct IssueTicketMessage, - NULL), - GNUNET_MQ_hd_var_size (consume_ticket_message, - GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, - struct ConsumeTicketMessage, - NULL), - GNUNET_MQ_hd_fixed_size (ticket_iteration_start, - GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, - struct TicketIterationStartMessage, - NULL), - GNUNET_MQ_hd_fixed_size (ticket_iteration_next, - GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, - struct TicketIterationNextMessage, - NULL), - GNUNET_MQ_hd_fixed_size (ticket_iteration_stop, - GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, - struct TicketIterationStopMessage, - NULL), - GNUNET_MQ_hd_var_size (revoke_ticket_message, - GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, - struct RevokeTicketMessage, - NULL), - GNUNET_MQ_handler_end ()); + "reclaim", + GNUNET_SERVICE_OPTION_NONE, + &run, + &client_connect_cb, + &client_disconnect_cb, + NULL, + GNUNET_MQ_hd_var_size (attribute_store_message, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, + struct AttributeStoreMessage, + NULL), + GNUNET_MQ_hd_var_size (attribute_delete_message, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, + struct AttributeDeleteMessage, + NULL), + GNUNET_MQ_hd_fixed_size ( + iteration_start, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, + struct AttributeIterationStartMessage, + NULL), + GNUNET_MQ_hd_fixed_size (iteration_next, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, + struct AttributeIterationNextMessage, + NULL), + GNUNET_MQ_hd_fixed_size (iteration_stop, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, + struct AttributeIterationStopMessage, + NULL), + GNUNET_MQ_hd_var_size (issue_ticket_message, + GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, + struct IssueTicketMessage, + NULL), + GNUNET_MQ_hd_var_size (consume_ticket_message, + GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, + struct ConsumeTicketMessage, + NULL), + GNUNET_MQ_hd_fixed_size (ticket_iteration_start, + GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, + struct TicketIterationStartMessage, + NULL), + GNUNET_MQ_hd_fixed_size (ticket_iteration_next, + GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, + struct TicketIterationNextMessage, + NULL), + GNUNET_MQ_hd_fixed_size (ticket_iteration_stop, + GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, + struct TicketIterationStopMessage, + NULL), + GNUNET_MQ_hd_var_size (revoke_ticket_message, + GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, + struct RevokeTicketMessage, + NULL), + GNUNET_MQ_handler_end ()); /* end of gnunet-service-reclaim.c */ diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index f18b11cb1..d20a4e3bf 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c @@ -25,7 +25,6 @@ * */ #include - #include "gnunet-service-reclaim_tickets.h" #define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS @@ -406,7 +405,7 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, } /** find a new place for this attribute **/ rvk->move_attr->new_id = - GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); new_rd = *rd; claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -421,7 +420,7 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, sizeof (uint64_t)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); rvk->ns_qe = GNUNET_NAMESTORE_records_store ( - nsh, &rvk->identity, new_label, 1, &new_rd, &move_attr_finished, rvk); + nsh, &rvk->identity, new_label, 1, &new_rd, &move_attr_finished, rvk); GNUNET_free (new_label); GNUNET_free (claim); GNUNET_free (attr_data); @@ -506,7 +505,7 @@ process_tickets (void *cls) } } rvk->ns_qe = GNUNET_NAMESTORE_records_store ( - nsh, &rvk->identity, le->label, le->rd_count, rd, &ticket_processed, rvk); + nsh, &rvk->identity, le->label, le->rd_count, rd, &ticket_processed, rvk); GNUNET_free (le->label); GNUNET_free (le->data); GNUNET_free (le); @@ -555,8 +554,8 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) if (NULL == rvk->move_attr) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); rvk->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( - nsh, &rvk->identity, &rvk_ns_iter_err, rvk, &rvk_ticket_update, rvk, - &rvk_ticket_update_finished, rvk); + nsh, &rvk->identity, &rvk_ns_iter_err, rvk, &rvk_ticket_update, rvk, + &rvk_ticket_update_finished, rvk); return; } label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, @@ -564,7 +563,7 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( - nsh, &rvk->identity, label, &rvk_ns_err, rvk, &rvk_move_attr_cb, rvk); + nsh, &rvk->identity, label, &rvk_ns_err, rvk, &rvk_move_attr_cb, rvk); GNUNET_free (label); } @@ -644,7 +643,7 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( - nsh, identity, label, &rvk_attrs_err_cb, rvk, &revoke_attrs_cb, rvk); + nsh, identity, label, &rvk_attrs_err_cb, rvk, &revoke_attrs_cb, rvk); return rvk; } @@ -700,10 +699,10 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count, GNUNET_free (parallel_lookup->label); GNUNET_STATISTICS_update ( - stats, "attribute_lookup_time_total", - GNUNET_TIME_absolute_get_duration (parallel_lookup->lookup_start_time) - .rel_value_us, - GNUNET_YES); + stats, "attribute_lookup_time_total", + GNUNET_TIME_absolute_get_duration (parallel_lookup->lookup_start_time) + .rel_value_us, + GNUNET_YES); GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES); @@ -713,7 +712,7 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count, if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) { attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); attr_le->claim = - GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); + GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, cth->attrs->list_tail, attr_le); } @@ -758,9 +757,9 @@ lookup_authz_cb (void *cls, uint32_t rd_count, cth->lookup_request = NULL; GNUNET_STATISTICS_update ( - stats, "reclaim_authz_lookup_time_total", - GNUNET_TIME_absolute_get_duration (cth->lookup_start_time).rel_value_us, - GNUNET_YES); + stats, "reclaim_authz_lookup_time_total", + GNUNET_TIME_absolute_get_duration (cth->lookup_start_time).rel_value_us, + GNUNET_YES); GNUNET_STATISTICS_update (stats, "reclaim_authz_lookups_count", 1, GNUNET_YES); @@ -774,16 +773,16 @@ lookup_authz_cb (void *cls, uint32_t rd_count, parallel_lookup->label = lbl; parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); parallel_lookup->lookup_request = GNUNET_GNS_lookup ( - gns, lbl, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, - GNUNET_GNS_LO_DEFAULT, &process_parallel_lookup_result, - parallel_lookup); + gns, lbl, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, + GNUNET_GNS_LO_DEFAULT, &process_parallel_lookup_result, + parallel_lookup); GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, cth->parallel_lookups_tail, parallel_lookup); } if (NULL != cth->parallel_lookups_head) { cth->kill_task = GNUNET_SCHEDULER_add_delayed ( - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), - &abort_parallel_lookups, cth); + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), + &abort_parallel_lookups, cth); return; } cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); @@ -807,13 +806,13 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, cth->cb = cb; cth->cb_cls = cb_cls; label = - GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); + GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for AuthZ info under %s\n", label); cth->lookup_start_time = GNUNET_TIME_absolute_get (); cth->lookup_request = GNUNET_GNS_lookup ( - gns, label, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, - GNUNET_GNS_LO_DEFAULT, &lookup_authz_cb, cth); + gns, label, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, + GNUNET_GNS_LO_DEFAULT, &lookup_authz_cb, cth); GNUNET_free (label); return cth; } @@ -872,7 +871,7 @@ issue_ticket (struct TicketIssueHandle *ih) list_len++; attrs_record = - GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data)); + GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data)); i = 0; for (le = ih->attrs->list_head; NULL != le; le = le->next) { attrs_record[i].data = &le->claim->id; @@ -888,10 +887,10 @@ issue_ticket (struct TicketIssueHandle *ih) attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; attrs_record[i].flags = - GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; + GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; label = - GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); + GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); // Publish record ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &ih->identity, label, list_len, attrs_record, @@ -915,7 +914,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, tih->identity = *identity; GNUNET_CRYPTO_ecdsa_key_get_public (identity, &tih->ticket.identity); tih->ticket.rnd = - GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); tih->ticket.audience = *audience; issue_ticket (tih); } @@ -987,8 +986,8 @@ RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start ( - const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - RECLAIM_TICKETS_TicketIter cb, void *cb_cls) + const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + RECLAIM_TICKETS_TicketIter cb, void *cb_cls) { struct RECLAIM_TICKETS_Iterator *iter; @@ -996,8 +995,8 @@ RECLAIM_TICKETS_iteration_start ( iter->cb = cb; iter->cb_cls = cb_cls; iter->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( - nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter, - &collect_tickets_finished_cb, iter); + nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter, + &collect_tickets_finished_cb, iter); return iter; } @@ -1012,10 +1011,10 @@ RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) "TICKET_REFRESH_INTERVAL", &ticket_refresh_interval)) { GNUNET_log ( - GNUNET_ERROR_TYPE_DEBUG, - "Configured refresh interval for tickets: %s\n", - GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, - GNUNET_YES)); + GNUNET_ERROR_TYPE_DEBUG, + "Configured refresh interval for tickets: %s\n", + GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, + GNUNET_YES)); } else { ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; } diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h index 6e704243d..6e69355fa 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.h +++ b/src/reclaim/gnunet-service-reclaim_tickets.h @@ -35,7 +35,6 @@ #include "gnunet_constants.h" #include "gnunet_gns_service.h" #include "gnunet_gnsrecord_lib.h" -#include "gnunet_namestore_service.h" #include "gnunet_protocols.h" #include "gnunet_reclaim_attribute_lib.h" #include "gnunet_reclaim_service.h" diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c index 9c186b64a..3ba4300bb 100644 --- a/src/reclaim/json_reclaim.c +++ b/src/reclaim/json_reclaim.c @@ -1,22 +1,22 @@ /* - This file is part of GNUnet. - Copyright (C) 2009-2018 GNUnet e.V. + This file is part of GNUnet. + Copyright (C) 2009-2018 GNUnet e.V. - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . - SPDX-License-Identifier: AGPL3.0-or-later -*/ + SPDX-License-Identifier: AGPL3.0-or-later + */ /** * @file rest-plugins/json_reclaim.c @@ -62,8 +62,8 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) } // interpret single attribute unpack_state = - json_unpack (root, "{s:s, s?s, s:s, s:s!}", "name", &name_str, "id", - &id_str, "type", &type_str, "value", &val_str); + json_unpack (root, "{s:s, s?s, s:s, s:s!}", "name", &name_str, "id", + &id_str, "type", &type_str, "value", &val_str); if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_str) || (NULL == type_str)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -72,7 +72,7 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) } type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); if (GNUNET_SYSERR == (GNUNET_RECLAIM_ATTRIBUTE_string_to_value ( - type, val_str, (void **)&data, &data_size))) { + type, val_str, (void **)&data, &data_size))) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n"); return GNUNET_SYSERR; } @@ -114,12 +114,12 @@ struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr) { struct GNUNET_JSON_Specification ret = {.parser = &parse_attr, - .cleaner = &clean_attr, - .cls = NULL, - .field = NULL, - .ptr = attr, - .ptr_size = 0, - .size_ptr = NULL}; + .cleaner = &clean_attr, + .cls = NULL, + .field = NULL, + .ptr = attr, + .ptr_size = 0, + .size_ptr = NULL}; *attr = NULL; return ret; } @@ -210,12 +210,12 @@ struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket) { struct GNUNET_JSON_Specification ret = {.parser = &parse_ticket, - .cleaner = &clean_ticket, - .cls = NULL, - .field = NULL, - .ptr = ticket, - .ptr_size = 0, - .size_ptr = NULL}; + .cleaner = &clean_ticket, + .cls = NULL, + .field = NULL, + .ptr = ticket, + .ptr_size = 0, + .size_ptr = NULL}; *ticket = NULL; return ret; } diff --git a/src/reclaim/json_reclaim.h b/src/reclaim/json_reclaim.h index ced2e10dd..36221ccb4 100644 --- a/src/reclaim/json_reclaim.h +++ b/src/reclaim/json_reclaim.h @@ -1,22 +1,22 @@ /* - This file is part of GNUnet. - Copyright (C) 2009-2018 GNUnet e.V. + This file is part of GNUnet. + Copyright (C) 2009-2018 GNUnet e.V. - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . - SPDX-License-Identifier: AGPL3.0-or-later -*/ + SPDX-License-Identifier: AGPL3.0-or-later + */ /** * @file rest-plugins/json_reclaim.h diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c index 167ee1729..6a06d5440 100644 --- a/src/reclaim/oidc_helper.c +++ b/src/reclaim/oidc_helper.c @@ -1,22 +1,22 @@ /* - This file is part of GNUnet - Copyright (C) 2010-2015 GNUnet e.V. + This file is part of GNUnet + Copyright (C) 2010-2015 GNUnet e.V. - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . - SPDX-License-Identifier: AGPL3.0-or-later - */ + SPDX-License-Identifier: AGPL3.0-or-later + */ /** * @file reclaim/oidc_helper.c @@ -26,13 +26,13 @@ #include "platform.h" #include #include - #include "gnunet_util_lib.h" - #include "gnunet_reclaim_attribute_lib.h" #include "gnunet_reclaim_service.h" #include "gnunet_signatures.h" #include "oidc_helper.h" + + static char * create_jwt_header (void) { @@ -308,7 +308,7 @@ derive_aes_key (struct GNUNET_CRYPTO_SymmetricSessionKey *key, NULL); GNUNET_CRYPTO_kdf (iv, sizeof ( - struct GNUNET_CRYPTO_SymmetricInitializationVector), + struct GNUNET_CRYPTO_SymmetricInitializationVector), ctx_iv, strlen (ctx_iv), key_material, @@ -368,7 +368,7 @@ encrypt_payload (const struct GNUNET_CRYPTO_EcdsaPublicKey *ecdsa_pub, calculate_key_pub (&key, &iv, ecdsa_pub, ecdh_priv); GNUNET_break ( - GNUNET_CRYPTO_symmetric_encrypt (payload, payload_len, &key, &iv, buf)); + GNUNET_CRYPTO_symmetric_encrypt (payload, payload_len, &key, &iv, buf)); } @@ -416,9 +416,9 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, attrs_ser); } code_payload_len = sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) + - signature_payload_len + - sizeof (struct GNUNET_CRYPTO_EcdsaSignature); + sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) + + signature_payload_len + + sizeof (struct GNUNET_CRYPTO_EcdsaSignature); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Length of data to encode: %lu\n", code_payload_len); @@ -482,7 +482,7 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, GNUNET_CRYPTO_ecdsa_sign (issuer, purpose, (struct GNUNET_CRYPTO_EcdsaSignature *) - buf_ptr)) + buf_ptr)) { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to sign code\n"); @@ -532,10 +532,10 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv, code_payload_len = GNUNET_STRINGS_base64_decode (code, strlen (code), (void **) &code_payload); if (code_payload_len < sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) + - sizeof (struct GNUNET_RECLAIM_Ticket) + - sizeof (uint32_t) + - sizeof (struct GNUNET_CRYPTO_EcdsaSignature)) + sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) + + sizeof (struct GNUNET_RECLAIM_Ticket) + + sizeof (uint32_t) + + sizeof (struct GNUNET_CRYPTO_EcdsaSignature)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Authorization code malformed\n"); GNUNET_free_non_null (code_payload); diff --git a/src/reclaim/oidc_helper.h b/src/reclaim/oidc_helper.h index 6fe1721d3..6c10a4ab0 100644 --- a/src/reclaim/oidc_helper.h +++ b/src/reclaim/oidc_helper.h @@ -1,22 +1,22 @@ /* - This file is part of GNUnet - Copyright (C) 2010-2015 GNUnet e.V. + This file is part of GNUnet + Copyright (C) 2010-2015 GNUnet e.V. - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . - SPDX-License-Identifier: AGPL3.0-or-later - */ + SPDX-License-Identifier: AGPL3.0-or-later + */ /** * @file reclaim/oidc_helper.h diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c index a29d71c01..93e5ac864 100644 --- a/src/reclaim/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . - SPDX-License-Identifier: AGPL3.0-or-later + SPDX-License-Identifier: AGPL3.0-or-later */ /** * @author Martin Schanzenbach @@ -209,12 +209,12 @@ * OIDC ignored parameter array */ static char *OIDC_ignored_parameter_array[] = {"display", - "prompt", - "ui_locales", - "response_mode", - "id_token_hint", - "login_hint", - "acr_values"}; + "prompt", + "ui_locales", + "response_mode", + "id_token_hint", + "login_hint", + "acr_values"}; /** * OIDC Hash map that keeps track of issued cookies @@ -724,7 +724,7 @@ cookie_identity_interpretation (struct RequestHandle *handle) strlen (OIDC_COOKIE_HEADER_KEY), &cache_key); if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle - ->header_param_map, + ->header_param_map, &cache_key)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No cookie found\n"); @@ -772,9 +772,9 @@ cookie_identity_interpretation (struct RequestHandle *handle) GNUNET_CONTAINER_multihashmap_contains (OIDC_cookie_jar_map, &cache_key)) { GNUNET_log ( - GNUNET_ERROR_TYPE_WARNING, - "Found cookie `%s', but no corresponding expiration entry present...\n", - token); + GNUNET_ERROR_TYPE_WARNING, + "Found cookie `%s', but no corresponding expiration entry present...\n", + token); GNUNET_free (cookies); return; } @@ -1020,10 +1020,10 @@ code_redirect (void *cls) { if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->oidc - ->login_identity, + ->login_identity, strlen ( - handle->oidc - ->login_identity), + handle->oidc + ->login_identity), &pubkey)) { handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_COOKIE); @@ -1191,7 +1191,7 @@ get_url_parameter_copy (const struct RequestHandle *handle, const char *key) char *value; GNUNET_CRYPTO_hash (key, strlen (key), &hc); if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle - ->url_param_map, + ->url_param_map, &hc)) return NULL; value = @@ -1264,7 +1264,7 @@ build_authz_response (void *cls) &cache_key); if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle - ->url_param_map, + ->url_param_map, &cache_key)) { handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_ACCESS_DENIED); @@ -1370,7 +1370,7 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle, if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->oidc->client_id, strlen ( - handle->oidc->client_id), + handle->oidc->client_id), &handle->oidc->client_pkey)) { handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_UNAUTHORIZED_CLIENT); @@ -1455,8 +1455,8 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, { current_time = GNUNET_new (struct GNUNET_TIME_Absolute); *current_time = GNUNET_TIME_relative_to_absolute ( - GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_get_second_ (), - OIDC_COOKIE_EXPIRATION)); + GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_get_second_ (), + OIDC_COOKIE_EXPIRATION)); last_time = GNUNET_CONTAINER_multihashmap_get (OIDC_cookie_jar_map, &cache_key); GNUNET_free_non_null (last_time); @@ -1488,7 +1488,7 @@ check_authorization (struct RequestHandle *handle, strlen (OIDC_AUTHORIZATION_HEADER_KEY), &cache_key); if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle - ->header_param_map, + ->header_param_map, &cache_key)) { handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_CLIENT); @@ -1620,10 +1620,10 @@ persist_access_token (const struct RequestHandle *handle, ticketbuf = GNUNET_new (struct GNUNET_RECLAIM_Ticket); *ticketbuf = *ticket; GNUNET_CONTAINER_multihashmap_put ( - OIDC_access_token_map, - &hc, - ticketbuf, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); + OIDC_access_token_map, + &hc, + ticketbuf, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } /** @@ -1826,7 +1826,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle, strlen (OIDC_AUTHORIZATION_HEADER_KEY), &cache_key); if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle - ->header_param_map, + ->header_param_map, &cache_key)) { handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_TOKEN); @@ -1915,16 +1915,16 @@ init_cont (struct RequestHandle *handle) { struct GNUNET_REST_RequestHandlerError err; static const struct GNUNET_REST_RequestHandler handlers[] = - {{MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_AUTHORIZE, &authorize_endpoint}, - {MHD_HTTP_METHOD_POST, + {{MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_AUTHORIZE, &authorize_endpoint}, + {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_AUTHORIZE, &authorize_endpoint}, // url-encoded - {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_LOGIN, &login_cont}, - {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_TOKEN, &token_endpoint}, - {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_USERINFO, &userinfo_endpoint}, - {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_USERINFO, &userinfo_endpoint}, - {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_OIDC, &options_cont}, - GNUNET_REST_HANDLER_END}; + {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_LOGIN, &login_cont}, + {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_TOKEN, &token_endpoint}, + {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_USERINFO, &userinfo_endpoint}, + {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_USERINFO, &userinfo_endpoint}, + {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_OIDC, &options_cont}, + GNUNET_REST_HANDLER_END}; if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 1a3784e64..7fe5283c4 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . - SPDX-License-Identifier: AGPL3.0-or-later + SPDX-License-Identifier: AGPL3.0-or-later */ /** * @author Martin Schanzenbach @@ -25,21 +25,19 @@ * */ #include "platform.h" - #include "microhttpd.h" #include #include - #include "gnunet_gns_service.h" #include "gnunet_gnsrecord_lib.h" #include "gnunet_identity_service.h" -#include "gnunet_namestore_service.h" #include "gnunet_reclaim_attribute_lib.h" #include "gnunet_reclaim_service.h" #include "gnunet_rest_lib.h" #include "gnunet_rest_plugin.h" #include "gnunet_signatures.h" #include "json_reclaim.h" + /** * REST root namespace */ @@ -162,16 +160,6 @@ struct RequestHandle */ struct GNUNET_REST_RequestHandle *rest_handle; - /** - * Handle to NAMESTORE - */ - struct GNUNET_NAMESTORE_Handle *namestore_handle; - - /** - * Iterator for NAMESTORE - */ - struct GNUNET_NAMESTORE_ZoneIterator *namestore_handle_it; - /** * Attribute claim list */ @@ -276,8 +264,6 @@ cleanup_handle (struct RequestHandle *handle) GNUNET_free (handle->url); if (NULL != handle->emsg) GNUNET_free (handle->emsg); - if (NULL != handle->namestore_handle) - GNUNET_NAMESTORE_disconnect (handle->namestore_handle); if (NULL != handle->attr_list) { for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;) { claim_tmp = claim_entry; @@ -420,12 +406,12 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) json_array_append (handle->resp_object, json_resource); tmp = GNUNET_STRINGS_data_to_string_alloc ( - &ticket->identity, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); + &ticket->identity, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); value = json_string (tmp); json_object_set_new (json_resource, "issuer", value); GNUNET_free (tmp); tmp = GNUNET_STRINGS_data_to_string_alloc ( - &ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); + &ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); value = json_string (tmp); json_object_set_new (json_resource, "audience", value); GNUNET_free (tmp); @@ -477,8 +463,8 @@ list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); handle->idp = GNUNET_RECLAIM_connect (cfg); handle->ticket_it = GNUNET_RECLAIM_ticket_iteration_start ( - handle->idp, priv_key, &collect_error_cb, handle, &ticket_collect, handle, - &collect_finished_cb, handle); + handle->idp, priv_key, &collect_error_cb, handle, &ticket_collect, handle, + &collect_finished_cb, handle); } @@ -496,7 +482,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, json_t *data_json; json_error_t err; struct GNUNET_JSON_Specification attrspec[] = { - GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end ()}; + GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end ()}; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding an attribute for %s.\n", handle->url); @@ -541,11 +527,11 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, */ if (0 == attribute->id) attribute->id = - GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); handle->idp = GNUNET_RECLAIM_connect (cfg); exp = GNUNET_TIME_UNIT_HOURS; handle->idp_op = GNUNET_RECLAIM_attribute_store ( - handle->idp, identity_priv, attribute, &exp, &finished_cont, handle); + handle->idp, identity_priv, attribute, &exp, &finished_cont, handle); GNUNET_JSON_parse_free (attrspec); } @@ -629,8 +615,8 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); handle->idp = GNUNET_RECLAIM_connect (cfg); handle->attr_it = GNUNET_RECLAIM_get_attributes_start ( - handle->idp, priv_key, &collect_error_cb, handle, &attr_collect, handle, - &collect_finished_cb, handle); + handle->idp, priv_key, &collect_error_cb, handle, &attr_collect, handle, + &collect_finished_cb, handle); } @@ -676,7 +662,7 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, return; } identity_id_str = - strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1); + strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1); identity = strtok (identity_id_str, "/"); id = strtok (NULL, "/"); if ((NULL == identity) || (NULL == id)) { @@ -704,7 +690,7 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof (uint64_t)); attr.name = ""; handle->idp_op = GNUNET_RECLAIM_attribute_delete ( - handle->idp, priv_key, &attr, &delete_finished_cb, handle); + handle->idp, priv_key, &attr, &delete_finished_cb, handle); GNUNET_free (identity_id_str); } @@ -722,7 +708,7 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, json_t *data_json; json_error_t err; struct GNUNET_JSON_Specification tktspec[] = { - GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; + GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; if (0 >= handle->rest_handle->data_size) { GNUNET_SCHEDULER_add_now (&do_error, handle); @@ -766,7 +752,7 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, handle->idp = GNUNET_RECLAIM_connect (cfg); handle->idp_op = GNUNET_RECLAIM_ticket_revoke ( - handle->idp, identity_priv, ticket, &finished_cont, handle); + handle->idp, identity_priv, ticket, &finished_cont, handle); GNUNET_JSON_parse_free (tktspec); } @@ -810,7 +796,7 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, json_t *data_json; json_error_t err; struct GNUNET_JSON_Specification tktspec[] = { - GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; + GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; if (0 >= handle->rest_handle->data_size) { GNUNET_SCHEDULER_add_now (&do_error, handle); @@ -850,7 +836,7 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, handle->resp_object = json_object (); handle->idp = GNUNET_RECLAIM_connect (cfg); handle->idp_op = GNUNET_RECLAIM_ticket_consume ( - handle->idp, identity_priv, ticket, &consume_cont, handle); + handle->idp, identity_priv, ticket, &consume_cont, handle); GNUNET_JSON_parse_free (tktspec); } @@ -887,20 +873,20 @@ init_cont (struct RequestHandle *handle) { struct GNUNET_REST_RequestHandlerError err; static const struct GNUNET_REST_RequestHandler handlers[] = { - {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, - &list_attribute_cont}, - {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, - &add_attribute_cont}, - {MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, - &delete_attribute_cont}, - {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TICKETS, - &list_tickets_cont}, - {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_REVOKE, - &revoke_ticket_cont}, - {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_CONSUME, - &consume_ticket_cont}, - {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont}, - GNUNET_REST_HANDLER_END}; + {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, + &list_attribute_cont}, + {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, + &add_attribute_cont}, + {MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, + &delete_attribute_cont}, + {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TICKETS, + &list_tickets_cont}, + {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_REVOKE, + &revoke_ticket_cont}, + {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_CONSUME, + &consume_ticket_cont}, + {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont}, + GNUNET_REST_HANDLER_END}; if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) { @@ -983,9 +969,8 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, handle->url[strlen (handle->url) - 1] = '\0'; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, handle); - handle->namestore_handle = GNUNET_NAMESTORE_connect (cfg); handle->timeout_task = - GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); + GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); } 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 @@ /* - This file is part of GNUnet. - Copyright (C) 2016 GNUnet e.V. + This file is part of GNUnet. + Copyright (C) 2016 GNUnet e.V. - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . - SPDX-License-Identifier: AGPL3.0-or-later -*/ + SPDX-License-Identifier: AGPL3.0-or-later + */ /** * @file reclaim/reclaim_api.c @@ -24,9 +24,7 @@ * @author Martin Schanzenbach */ #include "platform.h" - #include "gnunet_util_lib.h" - #include "gnunet_constants.h" #include "gnunet_mq_lib.h" #include "gnunet_protocols.h" @@ -351,9 +349,9 @@ force_reconnect (struct GNUNET_RECLAIM_Handle *handle) GNUNET_MQ_destroy (handle->mq); handle->mq = NULL; handle->reconnect_backoff = - GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); + GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); handle->reconnect_task = GNUNET_SCHEDULER_add_delayed ( - handle->reconnect_backoff, &reconnect_task, handle); + handle->reconnect_backoff, &reconnect_task, handle); } @@ -498,7 +496,7 @@ handle_consume_ticket_result (void *cls, struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; attrs = - GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *)&msg[1], attrs_len); + GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *)&msg[1], attrs_len); if (NULL != op->ar_cb) { if (NULL == attrs) { op->ar_cb (op->cls, &msg->identity, NULL); @@ -735,29 +733,29 @@ static void reconnect (struct GNUNET_RECLAIM_Handle *h) { struct GNUNET_MQ_MessageHandler handlers[] = { - GNUNET_MQ_hd_fixed_size (success_response, - GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, - struct SuccessResultMessage, h), - GNUNET_MQ_hd_var_size (attribute_result, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, - struct AttributeResultMessage, h), - GNUNET_MQ_hd_var_size (ticket_result, - GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, - struct TicketResultMessage, h), - GNUNET_MQ_hd_var_size (consume_ticket_result, - GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, - struct ConsumeTicketResultMessage, h), - GNUNET_MQ_hd_fixed_size (revoke_ticket_result, - GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, - struct RevokeTicketResultMessage, h), - GNUNET_MQ_handler_end ()}; + GNUNET_MQ_hd_fixed_size (success_response, + GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, + struct SuccessResultMessage, h), + GNUNET_MQ_hd_var_size (attribute_result, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, + struct AttributeResultMessage, h), + GNUNET_MQ_hd_var_size (ticket_result, + GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, + struct TicketResultMessage, h), + GNUNET_MQ_hd_var_size (consume_ticket_result, + GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, + struct ConsumeTicketResultMessage, h), + GNUNET_MQ_hd_fixed_size (revoke_ticket_result, + GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, + struct RevokeTicketResultMessage, h), + GNUNET_MQ_handler_end ()}; struct GNUNET_RECLAIM_Operation *op; GNUNET_assert (NULL == h->mq); LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n"); h->mq = - GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h); + GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h); if (NULL == h->mq) return; for (op = h->op_head; NULL != op; op = op->next) @@ -840,11 +838,11 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h) */ struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store ( - struct GNUNET_RECLAIM_Handle *h, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, - const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, - const struct GNUNET_TIME_Relative *exp_interval, - GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls) + struct GNUNET_RECLAIM_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, + const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, + const struct GNUNET_TIME_Relative *exp_interval, + GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls) { struct GNUNET_RECLAIM_Operation *op; struct AttributeStoreMessage *sam; @@ -885,10 +883,10 @@ GNUNET_RECLAIM_attribute_store ( */ struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete ( - struct GNUNET_RECLAIM_Handle *h, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, - const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, - GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls) + struct GNUNET_RECLAIM_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, + const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, + GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls) { struct GNUNET_RECLAIM_Operation *op; struct AttributeDeleteMessage *dam; @@ -940,11 +938,11 @@ GNUNET_RECLAIM_attribute_delete ( */ struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start ( - struct GNUNET_RECLAIM_Handle *h, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, - GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, - GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls) + struct GNUNET_RECLAIM_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, + GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, + GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls) { struct GNUNET_RECLAIM_AttributeIterator *it; struct GNUNET_MQ_Envelope *env; @@ -989,7 +987,7 @@ GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it) struct GNUNET_MQ_Envelope *env; env = - GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); + GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); msg->id = htonl (it->r_id); GNUNET_MQ_send (h->mq, env); } @@ -1034,11 +1032,11 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) */ struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_issue ( - struct GNUNET_RECLAIM_Handle *h, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, - const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, - const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, - GNUNET_RECLAIM_TicketCallback cb, void *cb_cls) + struct GNUNET_RECLAIM_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, + const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, + const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, + GNUNET_RECLAIM_TicketCallback cb, void *cb_cls) { struct GNUNET_RECLAIM_Operation *op; struct IssueTicketMessage *tim; @@ -1080,10 +1078,10 @@ GNUNET_RECLAIM_ticket_issue ( */ struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume ( - struct GNUNET_RECLAIM_Handle *h, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - const struct GNUNET_RECLAIM_Ticket *ticket, - GNUNET_RECLAIM_AttributeResult cb, void *cb_cls) + struct GNUNET_RECLAIM_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + const struct GNUNET_RECLAIM_Ticket *ticket, + GNUNET_RECLAIM_AttributeResult cb, void *cb_cls) { struct GNUNET_RECLAIM_Operation *op; struct ConsumeTicketMessage *ctm; @@ -1095,8 +1093,8 @@ GNUNET_RECLAIM_ticket_consume ( 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_extra (ctm, sizeof (const struct GNUNET_RECLAIM_Ticket), + GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); ctm->identity = *identity; ctm->id = htonl (op->r_id); @@ -1128,11 +1126,11 @@ GNUNET_RECLAIM_ticket_consume ( */ struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start ( - struct GNUNET_RECLAIM_Handle *h, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, - GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, - GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls) + struct GNUNET_RECLAIM_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, + GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, + GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls) { struct GNUNET_RECLAIM_TicketIterator *it; struct GNUNET_MQ_Envelope *env; @@ -1196,7 +1194,7 @@ GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it) if (NULL != h->mq) { env = - GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); + GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); msg->id = htonl (it->r_id); GNUNET_MQ_send (h->mq, env); } @@ -1219,10 +1217,10 @@ GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it) */ struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke ( - struct GNUNET_RECLAIM_Handle *h, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - const struct GNUNET_RECLAIM_Ticket *ticket, - GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls) + struct GNUNET_RECLAIM_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + const struct GNUNET_RECLAIM_Ticket *ticket, + GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls) { struct GNUNET_RECLAIM_Operation *op; struct RevokeTicketMessage *msg; -- cgit v1.2.3