From c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 5 Oct 2019 15:09:28 +0200 Subject: global reindent, now with uncrustify hook enabled --- src/reclaim/gnunet-reclaim.c | 708 +++++++-------- src/reclaim/gnunet-service-reclaim.c | 1191 +++++++++++++------------- src/reclaim/gnunet-service-reclaim_tickets.c | 1115 ++++++++++++------------ src/reclaim/gnunet-service-reclaim_tickets.h | 43 +- src/reclaim/json_reclaim.c | 209 ++--- src/reclaim/json_reclaim.h | 4 +- src/reclaim/oidc_helper.h | 44 +- src/reclaim/plugin_gnsrecord_reclaim.c | 91 +- src/reclaim/plugin_rest_reclaim.c | 917 ++++++++++---------- src/reclaim/reclaim.h | 48 +- src/reclaim/reclaim_api.c | 568 ++++++------ 11 files changed, 2493 insertions(+), 2445 deletions(-) (limited to 'src/reclaim') diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index 5160aef7f..c5f0ed4fa 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c @@ -168,176 +168,176 @@ static char *attr_delete; static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete; static void -do_cleanup(void *cls) +do_cleanup (void *cls) { cleanup_task = NULL; if (NULL != timeout) - GNUNET_SCHEDULER_cancel(timeout); + GNUNET_SCHEDULER_cancel (timeout); if (NULL != reclaim_op) - GNUNET_RECLAIM_cancel(reclaim_op); + GNUNET_RECLAIM_cancel (reclaim_op); if (NULL != attr_iterator) - GNUNET_RECLAIM_get_attributes_stop(attr_iterator); + GNUNET_RECLAIM_get_attributes_stop (attr_iterator); if (NULL != ticket_iterator) - GNUNET_RECLAIM_ticket_iteration_stop(ticket_iterator); + GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator); if (NULL != reclaim_handle) - GNUNET_RECLAIM_disconnect(reclaim_handle); + GNUNET_RECLAIM_disconnect (reclaim_handle); if (NULL != identity_handle) - GNUNET_IDENTITY_disconnect(identity_handle); + GNUNET_IDENTITY_disconnect (identity_handle); if (NULL != abe_key) - GNUNET_free(abe_key); + GNUNET_free (abe_key); if (NULL != attr_list) - GNUNET_free(attr_list); + GNUNET_free (attr_list); if (NULL != attr_to_delete) - GNUNET_free(attr_to_delete); + GNUNET_free (attr_to_delete); } static void -ticket_issue_cb(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) +ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) { char *ticket_str; reclaim_op = NULL; if (NULL != ticket) - { - ticket_str = - GNUNET_STRINGS_data_to_string_alloc(ticket, - sizeof( - struct GNUNET_RECLAIM_Ticket)); - printf("%s\n", ticket_str); - GNUNET_free(ticket_str); - } - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + { + ticket_str = + GNUNET_STRINGS_data_to_string_alloc (ticket, + sizeof( + struct GNUNET_RECLAIM_Ticket)); + printf ("%s\n", ticket_str); + GNUNET_free (ticket_str); + } + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -store_attr_cont(void *cls, int32_t success, const char *emsg) +store_attr_cont (void *cls, int32_t success, const char *emsg) { reclaim_op = NULL; if (GNUNET_SYSERR == success) - { - fprintf(stderr, "%s\n", emsg); - } - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + { + fprintf (stderr, "%s\n", emsg); + } + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -process_attrs(void *cls, - const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, - const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) +process_attrs (void *cls, + const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, + const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) { char *value_str; char *id; const char *attr_type; if (NULL == identity) - { - reclaim_op = NULL; - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); - return; - } + { + reclaim_op = NULL; + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); + return; + } if (NULL == attr) - { - ret = 1; - return; - } - value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, - attr->data, - attr->data_size); - attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(attr->type); - id = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); - fprintf(stdout, - "Name: %s; Value: %s (%s); Version %u; ID: %s\n", - attr->name, - value_str, - attr_type, - attr->version, - id); - GNUNET_free(id); + { + ret = 1; + return; + } + value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, + attr->data, + attr->data_size); + attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); + id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + fprintf (stdout, + "Name: %s; Value: %s (%s); Version %u; ID: %s\n", + attr->name, + value_str, + attr_type, + attr->version, + id); + GNUNET_free (id); } static void -ticket_iter_err(void *cls) +ticket_iter_err (void *cls) { ticket_iterator = NULL; - fprintf(stderr, "Failed to iterate over tickets\n"); - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + fprintf (stderr, "Failed to iterate over tickets\n"); + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -ticket_iter_fin(void *cls) +ticket_iter_fin (void *cls) { ticket_iterator = NULL; - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -ticket_iter(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) +ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) { char *aud; char *ref; char *tkt; aud = - GNUNET_STRINGS_data_to_string_alloc(&ticket->audience, - sizeof(struct - GNUNET_CRYPTO_EcdsaPublicKey)); - ref = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); + GNUNET_STRINGS_data_to_string_alloc (&ticket->audience, + sizeof(struct + GNUNET_CRYPTO_EcdsaPublicKey)); + ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); tkt = - GNUNET_STRINGS_data_to_string_alloc(ticket, - sizeof(struct GNUNET_RECLAIM_Ticket)); - fprintf(stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud); - GNUNET_free(aud); - GNUNET_free(ref); - GNUNET_free(tkt); - GNUNET_RECLAIM_ticket_iteration_next(ticket_iterator); + GNUNET_STRINGS_data_to_string_alloc (ticket, + sizeof(struct GNUNET_RECLAIM_Ticket)); + fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud); + GNUNET_free (aud); + GNUNET_free (ref); + GNUNET_free (tkt); + GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); } static void -iter_error(void *cls) +iter_error (void *cls) { attr_iterator = NULL; - fprintf(stderr, "Failed to iterate over attributes\n"); - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + fprintf (stderr, "Failed to iterate over attributes\n"); + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -timeout_task(void *cls) +timeout_task (void *cls) { timeout = NULL; ret = 1; - fprintf(stderr, "Timeout\n"); + fprintf (stderr, "Timeout\n"); if (NULL == cleanup_task) - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -process_rvk(void *cls, int success, const char *msg) +process_rvk (void *cls, int success, const char *msg) { reclaim_op = NULL; if (GNUNET_OK != success) - { - fprintf(stderr, "Revocation failed.\n"); - ret = 1; - } - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + { + fprintf (stderr, "Revocation failed.\n"); + ret = 1; + } + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -process_delete(void *cls, int success, const char *msg) +process_delete (void *cls, int success, const char *msg) { reclaim_op = NULL; if (GNUNET_OK != success) - { - fprintf(stderr, "Deletion failed.\n"); - ret = 1; - } - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + { + fprintf (stderr, "Deletion failed.\n"); + ret = 1; + } + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -iter_finished(void *cls) +iter_finished (void *cls) { char *data; size_t data_size; @@ -345,97 +345,97 @@ iter_finished(void *cls) attr_iterator = NULL; if (list) - { - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); - return; - } + { + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); + return; + } if (issue_attrs) - { - reclaim_op = GNUNET_RECLAIM_ticket_issue(reclaim_handle, - pkey, - &rp_key, - attr_list, - &ticket_issue_cb, - NULL); - return; - } + { + reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle, + pkey, + &rp_key, + attr_list, + &ticket_issue_cb, + NULL); + return; + } if (consume_ticket) - { - reclaim_op = GNUNET_RECLAIM_ticket_consume(reclaim_handle, - pkey, - &ticket, - &process_attrs, - NULL); - timeout = GNUNET_SCHEDULER_add_delayed( - GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), - &timeout_task, - NULL); - return; - } - if (revoke_ticket) - { - reclaim_op = GNUNET_RECLAIM_ticket_revoke(reclaim_handle, + { + reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle, pkey, &ticket, - &process_rvk, + &process_attrs, NULL); - return; - } + timeout = GNUNET_SCHEDULER_add_delayed ( + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), + &timeout_task, + NULL); + return; + } + if (revoke_ticket) + { + reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle, + pkey, + &ticket, + &process_rvk, + NULL); + return; + } if (attr_delete) + { + if (NULL == attr_to_delete) { - if (NULL == attr_to_delete) - { - fprintf(stdout, "No such attribute ``%s''\n", attr_delete); - return; - } - reclaim_op = GNUNET_RECLAIM_attribute_delete(reclaim_handle, - pkey, - attr_to_delete, - &process_delete, - NULL); + fprintf (stdout, "No such attribute ``%s''\n", attr_delete); return; } + reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle, + pkey, + attr_to_delete, + &process_delete, + NULL); + return; + } if (attr_name) - { - if (NULL == type_str) - type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; - else - type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(type_str); - - GNUNET_assert(GNUNET_SYSERR != - GNUNET_RECLAIM_ATTRIBUTE_string_to_value(type, + { + if (NULL == type_str) + type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; + else + type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); + + GNUNET_assert (GNUNET_SYSERR != + GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, attr_value, - (void **)&data, + (void **) &data, &data_size)); - if (NULL != claim) - { - claim->type = type; - claim->data = data; - claim->data_size = data_size; - } - else - { - claim = - GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr_name, type, data, data_size); - } - reclaim_op = GNUNET_RECLAIM_attribute_store(reclaim_handle, - pkey, - claim, - &exp_interval, - &store_attr_cont, - NULL); - GNUNET_free(data); - GNUNET_free(claim); - return; + if (NULL != claim) + { + claim->type = type; + claim->data = data; + claim->data_size = data_size; } - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); + else + { + claim = + GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size); + } + reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, + pkey, + claim, + &exp_interval, + &store_attr_cont, + NULL); + GNUNET_free (data); + GNUNET_free (claim); + return; + } + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } static void -iter_cb(void *cls, - const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, - const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) +iter_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, + const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) { struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; char *attrs_tmp; @@ -445,260 +445,260 @@ iter_cb(void *cls, const char *attr_type; if ((NULL != attr_name) && (NULL != claim)) + { + if (0 == strcasecmp (attr_name, attr->name)) { - if (0 == strcasecmp(attr_name, attr->name)) - { - claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr->name, - attr->type, - attr->data, - attr->data_size); - } + claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, + attr->type, + attr->data, + attr->data_size); } + } else if (issue_attrs) + { + attrs_tmp = GNUNET_strdup (issue_attrs); + attr_str = strtok (attrs_tmp, ","); + while (NULL != attr_str) { - attrs_tmp = GNUNET_strdup(issue_attrs); - attr_str = strtok(attrs_tmp, ","); - while (NULL != attr_str) - { - if (0 != strcasecmp(attr_str, attr->name)) - { - attr_str = strtok(NULL, ","); - continue; - } - le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); - le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr->name, - attr->type, - attr->data, - attr->data_size); - le->claim->version = attr->version; - le->claim->id = attr->id; - GNUNET_CONTAINER_DLL_insert(attr_list->list_head, - attr_list->list_tail, - le); - break; - } - GNUNET_free(attrs_tmp); + if (0 != strcasecmp (attr_str, attr->name)) + { + attr_str = strtok (NULL, ","); + continue; + } + le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); + le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, + attr->type, + attr->data, + attr->data_size); + le->claim->version = attr->version; + le->claim->id = attr->id; + GNUNET_CONTAINER_DLL_insert (attr_list->list_head, + attr_list->list_tail, + le); + break; } + GNUNET_free (attrs_tmp); + } else if (attr_delete && (NULL == attr_to_delete)) + { + label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + if (0 == strcasecmp (attr_delete, label)) { - label = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); - if (0 == strcasecmp(attr_delete, label)) - { - attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr->name, - attr->type, - attr->data, - attr->data_size); - attr_to_delete->id = attr->id; - } - GNUNET_free(label); + attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, + attr->type, + attr->data, + attr->data_size); + attr_to_delete->id = attr->id; } + GNUNET_free (label); + } else if (list) - { - attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, - attr->data, - attr->data_size); - attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(attr->type); - id = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); - fprintf(stdout, - "Name: %s; Value: %s (%s); Version %u; ID: %s\n", - attr->name, - attr_str, - attr_type, - attr->version, - id); - GNUNET_free(id); - } - GNUNET_RECLAIM_get_attributes_next(attr_iterator); + { + attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, + attr->data, + attr->data_size); + attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); + id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + fprintf (stdout, + "Name: %s; Value: %s (%s); Version %u; ID: %s\n", + attr->name, + attr_str, + attr_type, + attr->version, + id); + GNUNET_free (id); + } + GNUNET_RECLAIM_get_attributes_next (attr_iterator); } static void -start_process() +start_process () { if (NULL == pkey) - { - fprintf(stderr, "Ego %s not found\n", ego_name); - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); - return; - } + { + fprintf (stderr, "Ego %s not found\n", ego_name); + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); + return; + } if (list_tickets) - { - ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start(reclaim_handle, - pkey, - &ticket_iter_err, - NULL, - &ticket_iter, - NULL, - &ticket_iter_fin, - NULL); - return; - } + { + ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle, + pkey, + &ticket_iter_err, + NULL, + &ticket_iter, + NULL, + &ticket_iter_fin, + NULL); + return; + } if ((NULL != rp) && - GNUNET_OK != - GNUNET_CRYPTO_ecdsa_public_key_from_string(rp, strlen(rp), &rp_key)) - { - fprintf(stderr, "%s is not a public key!\n", rp); - cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); - return; - } + (GNUNET_OK != + GNUNET_CRYPTO_ecdsa_public_key_from_string (rp, strlen (rp), &rp_key)) ) + { + fprintf (stderr, "%s is not a public key!\n", rp); + cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); + return; + } if (NULL != consume_ticket) - GNUNET_STRINGS_string_to_data(consume_ticket, - strlen(consume_ticket), - &ticket, - sizeof(struct GNUNET_RECLAIM_Ticket)); + GNUNET_STRINGS_string_to_data (consume_ticket, + strlen (consume_ticket), + &ticket, + sizeof(struct GNUNET_RECLAIM_Ticket)); if (NULL != revoke_ticket) - GNUNET_STRINGS_string_to_data(revoke_ticket, - strlen(revoke_ticket), - &ticket, - sizeof(struct GNUNET_RECLAIM_Ticket)); + GNUNET_STRINGS_string_to_data (revoke_ticket, + strlen (revoke_ticket), + &ticket, + sizeof(struct GNUNET_RECLAIM_Ticket)); - attr_list = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); + attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); claim = NULL; - attr_iterator = GNUNET_RECLAIM_get_attributes_start(reclaim_handle, - pkey, - &iter_error, - NULL, - &iter_cb, - NULL, - &iter_finished, - NULL); + attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, + pkey, + &iter_error, + NULL, + &iter_cb, + NULL, + &iter_finished, + NULL); } static int init = GNUNET_YES; static void -ego_cb(void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ctx, - const char *name) +ego_cb (void *cls, + struct GNUNET_IDENTITY_Ego *ego, + void **ctx, + const char *name) { if (NULL == name) + { + if (GNUNET_YES == init) { - if (GNUNET_YES == init) - { - init = GNUNET_NO; - start_process(); - } - return; + init = GNUNET_NO; + start_process (); } - if (0 != strcmp(name, ego_name)) return; - pkey = GNUNET_IDENTITY_ego_get_private_key(ego); + } + if (0 != strcmp (name, ego_name)) + return; + pkey = GNUNET_IDENTITY_ego_get_private_key (ego); } static void -run(void *cls, - char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, + char *const *args, + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { ret = 0; if (NULL == ego_name) - { - ret = 1; - fprintf(stderr, _("Ego is required\n")); - return; - } + { + ret = 1; + fprintf (stderr, _ ("Ego is required\n")); + return; + } if ((NULL == attr_value) && (NULL != attr_name)) - { - ret = 1; - fprintf(stderr, _("Attribute value missing!\n")); - return; - } + { + ret = 1; + fprintf (stderr, _ ("Attribute value missing!\n")); + return; + } if ((NULL == rp) && (NULL != issue_attrs)) - { - ret = 1; - fprintf(stderr, _("Requesting party key is required!\n")); - return; - } + { + ret = 1; + fprintf (stderr, _ ("Requesting party key is required!\n")); + return; + } - reclaim_handle = GNUNET_RECLAIM_connect(c); + reclaim_handle = GNUNET_RECLAIM_connect (c); // Get Ego - identity_handle = GNUNET_IDENTITY_connect(c, &ego_cb, NULL); + identity_handle = GNUNET_IDENTITY_connect (c, &ego_cb, NULL); } int -main(int argc, char *const argv[]) +main (int argc, char *const argv[]) { exp_interval = GNUNET_TIME_UNIT_HOURS; struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_option_string('a', - "add", - "NAME", - gettext_noop("Add an attribute NAME"), - &attr_name), - GNUNET_GETOPT_option_string('d', - "delete", - "ID", - gettext_noop("Delete the attribute with ID"), - &attr_delete), - GNUNET_GETOPT_option_string('V', - "value", - "VALUE", - gettext_noop("The attribute VALUE"), - &attr_value), - GNUNET_GETOPT_option_string('e', - "ego", - "EGO", - gettext_noop("The EGO to use"), - &ego_name), - GNUNET_GETOPT_option_string('r', - "rp", - "RP", - gettext_noop( - "Specify the relying party for issue"), - &rp), - GNUNET_GETOPT_option_flag('D', - "dump", - gettext_noop("List attributes for EGO"), - &list), - GNUNET_GETOPT_option_string( + GNUNET_GETOPT_option_string ('a', + "add", + "NAME", + gettext_noop ("Add an attribute NAME"), + &attr_name), + GNUNET_GETOPT_option_string ('d', + "delete", + "ID", + gettext_noop ("Delete the attribute with ID"), + &attr_delete), + GNUNET_GETOPT_option_string ('V', + "value", + "VALUE", + gettext_noop ("The attribute VALUE"), + &attr_value), + GNUNET_GETOPT_option_string ('e', + "ego", + "EGO", + gettext_noop ("The EGO to use"), + &ego_name), + GNUNET_GETOPT_option_string ('r', + "rp", + "RP", + gettext_noop ( + "Specify the relying party for issue"), + &rp), + GNUNET_GETOPT_option_flag ('D', + "dump", + gettext_noop ("List attributes for EGO"), + &list), + GNUNET_GETOPT_option_string ( 'i', "issue", "A1,A2,...", - gettext_noop( + gettext_noop ( "Issue a ticket for a set of attributes separated by comma"), &issue_attrs), - GNUNET_GETOPT_option_string('C', - "consume", - "TICKET", - gettext_noop("Consume a ticket"), - &consume_ticket), - GNUNET_GETOPT_option_string('R', - "revoke", - "TICKET", - gettext_noop("Revoke a ticket"), - &revoke_ticket), - GNUNET_GETOPT_option_string('t', - "type", - "TYPE", - gettext_noop("Type of attribute"), - &type_str), - GNUNET_GETOPT_option_flag('T', - "tickets", - gettext_noop("List tickets of ego"), - &list_tickets), - GNUNET_GETOPT_option_relative_time('E', - "expiration", - "INTERVAL", - gettext_noop( - "Expiration interval of the attribute"), - &exp_interval), + GNUNET_GETOPT_option_string ('C', + "consume", + "TICKET", + gettext_noop ("Consume a ticket"), + &consume_ticket), + GNUNET_GETOPT_option_string ('R', + "revoke", + "TICKET", + gettext_noop ("Revoke a ticket"), + &revoke_ticket), + GNUNET_GETOPT_option_string ('t', + "type", + "TYPE", + gettext_noop ("Type of attribute"), + &type_str), + GNUNET_GETOPT_option_flag ('T', + "tickets", + gettext_noop ("List tickets of ego"), + &list_tickets), + GNUNET_GETOPT_option_relative_time ('E', + "expiration", + "INTERVAL", + gettext_noop ( + "Expiration interval of the attribute"), + &exp_interval), GNUNET_GETOPT_OPTION_END }; - if (GNUNET_OK != GNUNET_PROGRAM_run(argc, - argv, - "gnunet-reclaim", - _("re:claimID command line tool"), - options, - &run, - NULL)) + if (GNUNET_OK != GNUNET_PROGRAM_run (argc, + argv, + "gnunet-reclaim", + _ ("re:claimID command line tool"), + options, + &run, + NULL)) return 1; else return ret; diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 23a5db1ed..440656343 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c @@ -58,7 +58,8 @@ struct IdpClient; /** * A ticket iteration operation. */ -struct TicketIteration { +struct TicketIteration +{ /** * DLL */ @@ -89,7 +90,8 @@ struct TicketIteration { /** * An attribute iteration operation. */ -struct AttributeIterator { +struct AttributeIterator +{ /** * Next element in the DLL */ @@ -125,7 +127,8 @@ struct AttributeIterator { /** * An idp client */ -struct IdpClient { +struct IdpClient +{ /** * DLL */ @@ -224,7 +227,8 @@ struct IdpClient { /** * Handle for attribute deletion request */ -struct AttributeDeleteHandle { +struct AttributeDeleteHandle +{ /** * DLL */ @@ -286,7 +290,8 @@ struct AttributeDeleteHandle { /** * Handle for attribute store request */ -struct AttributeStoreHandle { +struct AttributeStoreHandle +{ /** * DLL */ @@ -337,7 +342,8 @@ struct AttributeStoreHandle { /** * Handle for ticket consume request */ -struct ConsumeTicketOperation { +struct ConsumeTicketOperation +{ /** * DLL */ @@ -368,7 +374,8 @@ struct ConsumeTicketOperation { /** * Ticket revocation request handle */ -struct TicketRevocationOperation { +struct TicketRevocationOperation +{ /** * DLL */ @@ -399,7 +406,8 @@ struct TicketRevocationOperation { /** * Ticket issue operation handle */ -struct TicketIssueOperation { +struct TicketIssueOperation +{ /** * DLL */ @@ -439,30 +447,30 @@ static struct IdpClient *client_list_tail = NULL; * @param adh the attribute to cleanup */ static void -cleanup_adh(struct AttributeDeleteHandle *adh) +cleanup_adh (struct AttributeDeleteHandle *adh) { struct TicketRecordsEntry *le; if (NULL != adh->ns_it) - GNUNET_NAMESTORE_zone_iteration_stop(adh->ns_it); + GNUNET_NAMESTORE_zone_iteration_stop (adh->ns_it); if (NULL != adh->ns_qe) - GNUNET_NAMESTORE_cancel(adh->ns_qe); + GNUNET_NAMESTORE_cancel (adh->ns_qe); if (NULL != adh->label) - GNUNET_free(adh->label); + GNUNET_free (adh->label); if (NULL != adh->claim) - GNUNET_free(adh->claim); + GNUNET_free (adh->claim); while (NULL != (le = adh->tickets_to_update_head)) - { - GNUNET_CONTAINER_DLL_remove(adh->tickets_to_update_head, - adh->tickets_to_update_tail, - le); - if (NULL != le->label) - GNUNET_free(le->label); - if (NULL != le->data) - GNUNET_free(le->data); - GNUNET_free(le); - } - GNUNET_free(adh); + { + GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, + adh->tickets_to_update_tail, + le); + if (NULL != le->label) + GNUNET_free (le->label); + if (NULL != le->data) + GNUNET_free (le->data); + GNUNET_free (le); + } + GNUNET_free (adh); } @@ -472,13 +480,13 @@ cleanup_adh(struct AttributeDeleteHandle *adh) * @param handle handle to clean up */ static void -cleanup_as_handle(struct AttributeStoreHandle *ash) +cleanup_as_handle (struct AttributeStoreHandle *ash) { if (NULL != ash->ns_qe) - GNUNET_NAMESTORE_cancel(ash->ns_qe); + GNUNET_NAMESTORE_cancel (ash->ns_qe); if (NULL != ash->claim) - GNUNET_free(ash->claim); - GNUNET_free(ash); + GNUNET_free (ash->claim); + GNUNET_free (ash); } @@ -488,7 +496,7 @@ cleanup_as_handle(struct AttributeStoreHandle *ash) * @param idp the client to clean up */ static void -cleanup_client(struct IdpClient *idp) +cleanup_client (struct IdpClient *idp) { struct AttributeIterator *ai; struct TicketIteration *ti; @@ -499,52 +507,52 @@ cleanup_client(struct IdpClient *idp) struct AttributeDeleteHandle *adh; while (NULL != (iss = idp->issue_op_head)) - { - GNUNET_CONTAINER_DLL_remove(idp->issue_op_head, idp->issue_op_tail, iss); - GNUNET_free(iss); - } + { + GNUNET_CONTAINER_DLL_remove (idp->issue_op_head, idp->issue_op_tail, iss); + GNUNET_free (iss); + } while (NULL != (ct = idp->consume_op_head)) - { - GNUNET_CONTAINER_DLL_remove(idp->consume_op_head, - idp->consume_op_tail, - ct); - if (NULL != ct->ch) - RECLAIM_TICKETS_consume_cancel(ct->ch); - GNUNET_free(ct); - } + { + GNUNET_CONTAINER_DLL_remove (idp->consume_op_head, + idp->consume_op_tail, + ct); + if (NULL != ct->ch) + RECLAIM_TICKETS_consume_cancel (ct->ch); + GNUNET_free (ct); + } while (NULL != (as = idp->store_op_head)) - { - GNUNET_CONTAINER_DLL_remove(idp->store_op_head, idp->store_op_tail, as); - cleanup_as_handle(as); - } + { + GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as); + cleanup_as_handle (as); + } while (NULL != (adh = idp->delete_op_head)) - { - GNUNET_CONTAINER_DLL_remove(idp->delete_op_head, idp->delete_op_tail, adh); - cleanup_adh(adh); - } + { + GNUNET_CONTAINER_DLL_remove (idp->delete_op_head, idp->delete_op_tail, adh); + cleanup_adh (adh); + } while (NULL != (ai = idp->attr_iter_head)) - { - GNUNET_CONTAINER_DLL_remove(idp->attr_iter_head, idp->attr_iter_tail, ai); - GNUNET_free(ai); - } + { + GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); + GNUNET_free (ai); + } while (NULL != (rop = idp->revoke_op_head)) - { - GNUNET_CONTAINER_DLL_remove(idp->revoke_op_head, idp->revoke_op_tail, rop); - if (NULL != rop->rh) - RECLAIM_TICKETS_revoke_cancel(rop->rh); - GNUNET_free(rop); - } + { + GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); + if (NULL != rop->rh) + RECLAIM_TICKETS_revoke_cancel (rop->rh); + GNUNET_free (rop); + } while (NULL != (ti = idp->ticket_iter_head)) - { - GNUNET_CONTAINER_DLL_remove(idp->ticket_iter_head, - idp->ticket_iter_tail, - ti); - if (NULL != ti->iter) - RECLAIM_TICKETS_iteration_stop(ti->iter); - GNUNET_free(ti); - } - GNUNET_free(idp); + { + GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head, + idp->ticket_iter_tail, + ti); + if (NULL != ti->iter) + RECLAIM_TICKETS_iteration_stop (ti->iter); + GNUNET_free (ti); + } + GNUNET_free (idp); } @@ -552,24 +560,24 @@ cleanup_client(struct IdpClient *idp) * Cleanup task */ static void -cleanup() +cleanup () { struct IdpClient *cl; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); while (NULL != (cl = client_list_head)) - { - GNUNET_CONTAINER_DLL_remove(client_list_head, - client_list_tail, - cl); - cleanup_client(cl); - } - RECLAIM_TICKETS_deinit(); + { + GNUNET_CONTAINER_DLL_remove (client_list_head, + client_list_tail, + cl); + cleanup_client (cl); + } + RECLAIM_TICKETS_deinit (); if (NULL != timeout_task) - GNUNET_SCHEDULER_cancel(timeout_task); + GNUNET_SCHEDULER_cancel (timeout_task); if (NULL != nsh) - GNUNET_NAMESTORE_disconnect(nsh); + GNUNET_NAMESTORE_disconnect (nsh); } @@ -579,10 +587,10 @@ cleanup() * @param cls NULL */ static void -do_shutdown(void *cls) +do_shutdown (void *cls) { - GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down...\n"); - cleanup(); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n"); + cleanup (); } @@ -595,24 +603,24 @@ do_shutdown(void *cls) * @param success the success status of the request */ static void -send_ticket_result(const struct IdpClient *client, - uint32_t r_id, - const struct GNUNET_RECLAIM_Ticket *ticket, - uint32_t success) +send_ticket_result (const struct IdpClient *client, + uint32_t r_id, + const struct GNUNET_RECLAIM_Ticket *ticket, + uint32_t success) { struct TicketResultMessage *irm; struct GNUNET_MQ_Envelope *env; - env = GNUNET_MQ_msg(irm, - GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); + env = GNUNET_MQ_msg (irm, + GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); if (NULL != ticket) - { - irm->ticket = *ticket; - } + { + irm->ticket = *ticket; + } // TODO add success member - irm->id = htonl(r_id); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); - GNUNET_MQ_send(client->mq, env); + irm->id = htonl (r_id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); + GNUNET_MQ_send (client->mq, env); } @@ -625,28 +633,28 @@ send_ticket_result(const struct IdpClient *client, * @param emsg error message (NULL of success is GNUNET_OK) */ static void -issue_ticket_result_cb(void *cls, - struct GNUNET_RECLAIM_Ticket *ticket, - int32_t success, - const char *emsg) +issue_ticket_result_cb (void *cls, + struct GNUNET_RECLAIM_Ticket *ticket, + int32_t success, + const char *emsg) { struct TicketIssueOperation *tio = cls; if (GNUNET_OK != success) - { - send_ticket_result(tio->client, tio->r_id, NULL, GNUNET_SYSERR); - GNUNET_CONTAINER_DLL_remove(tio->client->issue_op_head, - tio->client->issue_op_tail, - tio); - GNUNET_free(tio); - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg); - return; - } - send_ticket_result(tio->client, tio->r_id, ticket, GNUNET_SYSERR); - GNUNET_CONTAINER_DLL_remove(tio->client->issue_op_head, - tio->client->issue_op_tail, - tio); - GNUNET_free(tio); + { + send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR); + GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head, + tio->client->issue_op_tail, + tio); + GNUNET_free (tio); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg); + return; + } + send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR); + GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head, + tio->client->issue_op_tail, + tio); + GNUNET_free (tio); } @@ -658,16 +666,16 @@ issue_ticket_result_cb(void *cls, * @return GNUNET_OK if message is ok */ static int -check_issue_ticket_message(void *cls, const struct IssueTicketMessage *im) +check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) { uint16_t size; - size = ntohs(im->header.size); + size = ntohs (im->header.size); if (size <= sizeof(struct IssueTicketMessage)) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -679,27 +687,28 @@ check_issue_ticket_message(void *cls, const struct IssueTicketMessage *im) * @param im the message */ static void -handle_issue_ticket_message(void *cls, const struct IssueTicketMessage *im) +handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) { struct TicketIssueOperation *tio; struct IdpClient *idp = cls; struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; size_t attrs_len; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); - tio = GNUNET_new(struct TicketIssueOperation); - attrs_len = ntohs(im->attr_len); - attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize((char *)&im[1], attrs_len); - tio->r_id = ntohl(im->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); + tio = GNUNET_new (struct TicketIssueOperation); + attrs_len = ntohs (im->attr_len); + attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &im[1], + attrs_len); + tio->r_id = ntohl (im->id); tio->client = idp; - GNUNET_CONTAINER_DLL_insert(idp->issue_op_head, idp->issue_op_tail, tio); - RECLAIM_TICKETS_issue(&im->identity, - attrs, - &im->rp, - &issue_ticket_result_cb, - tio); - GNUNET_SERVICE_client_continue(idp->client); - GNUNET_RECLAIM_ATTRIBUTE_list_destroy(attrs); + GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio); + RECLAIM_TICKETS_issue (&im->identity, + attrs, + &im->rp, + &issue_ticket_result_cb, + tio); + GNUNET_SERVICE_client_continue (idp->client); + GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); } @@ -715,22 +724,23 @@ handle_issue_ticket_message(void *cls, const struct IssueTicketMessage *im) * @param success revocation result (GNUNET_OK if successful) */ static void -revoke_result_cb(void *cls, int32_t success) +revoke_result_cb (void *cls, int32_t success) { struct TicketRevocationOperation *rop = cls; struct GNUNET_MQ_Envelope *env; struct RevokeTicketResultMessage *trm; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending REVOKE_TICKET_RESULT message\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending REVOKE_TICKET_RESULT message\n"); rop->rh = NULL; - env = GNUNET_MQ_msg(trm, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT); - trm->id = htonl(rop->r_id); - trm->success = htonl(success); - GNUNET_MQ_send(rop->client->mq, env); - GNUNET_CONTAINER_DLL_remove(rop->client->revoke_op_head, - rop->client->revoke_op_tail, - rop); - GNUNET_free(rop); + env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT); + trm->id = htonl (rop->r_id); + trm->success = htonl (success); + GNUNET_MQ_send (rop->client->mq, env); + GNUNET_CONTAINER_DLL_remove (rop->client->revoke_op_head, + rop->client->revoke_op_tail, + rop); + GNUNET_free (rop); } @@ -742,16 +752,16 @@ revoke_result_cb(void *cls, int32_t success) * @return GNUNET_OK if message is ok */ static int -check_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *im) +check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im) { uint16_t size; - size = ntohs(im->header.size); + size = ntohs (im->header.size); if (size != sizeof(struct RevokeTicketMessage)) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -763,19 +773,20 @@ check_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *im) * @param rm the message to handle */ static void -handle_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *rm) +handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) { struct TicketRevocationOperation *rop; struct IdpClient *idp = cls; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n"); - rop = GNUNET_new(struct TicketRevocationOperation); - rop->r_id = ntohl(rm->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n"); + rop = GNUNET_new (struct TicketRevocationOperation); + rop->r_id = ntohl (rm->id); rop->client = idp; - GNUNET_CONTAINER_DLL_insert(idp->revoke_op_head, idp->revoke_op_tail, rop); + GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop); rop->rh - = RECLAIM_TICKETS_revoke(&rm->ticket, &rm->identity, &revoke_result_cb, rop); - GNUNET_SERVICE_client_continue(idp->client); + = RECLAIM_TICKETS_revoke (&rm->ticket, &rm->identity, &revoke_result_cb, + rop); + GNUNET_SERVICE_client_continue (idp->client); } @@ -789,11 +800,11 @@ handle_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *rm) * @param emsg error message (NULL if success=GNUNET_OK) */ static void -consume_result_cb(void *cls, - const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, - const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, - int32_t success, - const char *emsg) +consume_result_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, + const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, + int32_t success, + const char *emsg) { struct ConsumeTicketOperation *cop = cls; struct ConsumeTicketResultMessage *crm; @@ -802,25 +813,26 @@ consume_result_cb(void *cls, size_t attrs_len; if (GNUNET_OK != success) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); - } - attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(attrs); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending CONSUME_TICKET_RESULT message\n"); - env = GNUNET_MQ_msg_extra(crm, - attrs_len, - GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); - crm->id = htonl(cop->r_id); - crm->attrs_len = htons(attrs_len); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); + } + attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending CONSUME_TICKET_RESULT message\n"); + env = GNUNET_MQ_msg_extra (crm, + attrs_len, + GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); + crm->id = htonl (cop->r_id); + crm->attrs_len = htons (attrs_len); crm->identity = *identity; - crm->result = htonl(success); - data_tmp = (char *)&crm[1]; - GNUNET_RECLAIM_ATTRIBUTE_list_serialize(attrs, data_tmp); - GNUNET_MQ_send(cop->client->mq, env); - GNUNET_CONTAINER_DLL_remove(cop->client->consume_op_head, - cop->client->consume_op_tail, - cop); - GNUNET_free(cop); + crm->result = htonl (success); + data_tmp = (char *) &crm[1]; + GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp); + GNUNET_MQ_send (cop->client->mq, env); + GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, + cop->client->consume_op_tail, + cop); + GNUNET_free (cop); } @@ -831,16 +843,16 @@ consume_result_cb(void *cls, * @param cm the message to handle */ static int -check_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm) +check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) { uint16_t size; - size = ntohs(cm->header.size); + size = ntohs (cm->header.size); if (size != sizeof(struct ConsumeTicketMessage)) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -852,19 +864,20 @@ check_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm) * @cm the message to handle */ static void -handle_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm) +handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) { struct ConsumeTicketOperation *cop; struct IdpClient *idp = cls; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); - cop = GNUNET_new(struct ConsumeTicketOperation); - cop->r_id = ntohl(cm->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); + cop = GNUNET_new (struct ConsumeTicketOperation); + cop->r_id = ntohl (cm->id); cop->client = idp; cop->ch - = RECLAIM_TICKETS_consume(&cm->identity, &cm->ticket, &consume_result_cb, cop); - GNUNET_CONTAINER_DLL_insert(idp->consume_op_head, idp->consume_op_tail, cop); - GNUNET_SERVICE_client_continue(idp->client); + = RECLAIM_TICKETS_consume (&cm->identity, &cm->ticket, &consume_result_cb, + cop); + GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop); + GNUNET_SERVICE_client_continue (idp->client); } /***************************************** @@ -880,33 +893,33 @@ handle_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm) * @param emsg error message (NULL if success=GNUNET_OK) */ static void -attr_store_cont(void *cls, int32_t success, const char *emsg) +attr_store_cont (void *cls, int32_t success, const char *emsg) { struct AttributeStoreHandle *ash = cls; struct GNUNET_MQ_Envelope *env; struct SuccessResultMessage *acr_msg; ash->ns_qe = NULL; - GNUNET_CONTAINER_DLL_remove(ash->client->store_op_head, - ash->client->store_op_tail, - ash); + GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, + ash->client->store_op_tail, + ash); if (GNUNET_SYSERR == success) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Failed to store attribute %s\n", - emsg); - cleanup_as_handle(ash); - GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); - return; - } - - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); - env = GNUNET_MQ_msg(acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); - acr_msg->id = htonl(ash->r_id); - acr_msg->op_result = htonl(GNUNET_OK); - GNUNET_MQ_send(ash->client->mq, env); - cleanup_as_handle(ash); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to store attribute %s\n", + emsg); + cleanup_as_handle (ash); + GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); + return; + } + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); + env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); + acr_msg->id = htonl (ash->r_id); + acr_msg->op_result = htonl (GNUNET_OK); + GNUNET_MQ_send (ash->client->mq, env); + cleanup_as_handle (ash); } @@ -916,7 +929,7 @@ attr_store_cont(void *cls, int32_t success, const char *emsg) * @param cls the AttributeStoreHandle */ static void -attr_store_task(void *cls) +attr_store_task (void *cls) { struct AttributeStoreHandle *ash = cls; struct GNUNET_GNSRECORD_Data rd[1]; @@ -924,32 +937,32 @@ attr_store_task(void *cls) char *label; size_t buf_size; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); - buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(ash->claim); - buf = GNUNET_malloc(buf_size); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); + buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim); + buf = GNUNET_malloc (buf_size); // Give the ash a new id if unset if (0 == ash->claim->id) ash->claim->id - = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); - GNUNET_RECLAIM_ATTRIBUTE_serialize(ash->claim, buf); + = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf); label - = GNUNET_STRINGS_data_to_string_alloc(&ash->claim->id, sizeof(uint64_t)); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); + = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof(uint64_t)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); rd[0].data_size = buf_size; rd[0].data = buf; rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR; rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; rd[0].expiration_time = ash->exp.rel_value_us; - ash->ns_qe = GNUNET_NAMESTORE_records_store(nsh, - &ash->identity, - label, - 1, - rd, - &attr_store_cont, - ash); - GNUNET_free(buf); - GNUNET_free(label); + ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, + &ash->identity, + label, + 1, + rd, + &attr_store_cont, + ash); + GNUNET_free (buf); + GNUNET_free (label); } @@ -960,17 +973,17 @@ attr_store_task(void *cls) * @param sam the message to check */ static int -check_attribute_store_message(void *cls, - const struct AttributeStoreMessage *sam) +check_attribute_store_message (void *cls, + const struct AttributeStoreMessage *sam) { uint16_t size; - size = ntohs(sam->header.size); + size = ntohs (sam->header.size); if (size <= sizeof(struct AttributeStoreMessage)) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -982,29 +995,30 @@ check_attribute_store_message(void *cls, * @param sam the message to handle */ static void -handle_attribute_store_message(void *cls, - const struct AttributeStoreMessage *sam) +handle_attribute_store_message (void *cls, + const struct AttributeStoreMessage *sam) { struct AttributeStoreHandle *ash; struct IdpClient *idp = cls; size_t data_len; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); - data_len = ntohs(sam->attr_len); + data_len = ntohs (sam->attr_len); - ash = GNUNET_new(struct AttributeStoreHandle); - ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&sam[1], data_len); + ash = GNUNET_new (struct AttributeStoreHandle); + ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &sam[1], + data_len); - ash->r_id = ntohl(sam->id); + ash->r_id = ntohl (sam->id); ash->identity = sam->identity; - ash->exp.rel_value_us = GNUNET_ntohll(sam->exp); - GNUNET_CRYPTO_ecdsa_key_get_public(&sam->identity, &ash->identity_pkey); + ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); + GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey); - GNUNET_SERVICE_client_continue(idp->client); + GNUNET_SERVICE_client_continue (idp->client); ash->client = idp; - GNUNET_CONTAINER_DLL_insert(idp->store_op_head, idp->store_op_tail, ash); - GNUNET_SCHEDULER_add_now(&attr_store_task, ash); + GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash); + GNUNET_SCHEDULER_add_now (&attr_store_task, ash); } @@ -1015,20 +1029,20 @@ handle_attribute_store_message(void *cls, * @param success the success status */ static void -send_delete_response(struct AttributeDeleteHandle *adh, int32_t success) +send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) { struct GNUNET_MQ_Envelope *env; struct SuccessResultMessage *acr_msg; - GNUNET_CONTAINER_DLL_remove(adh->client->delete_op_head, - adh->client->delete_op_tail, - adh); + GNUNET_CONTAINER_DLL_remove (adh->client->delete_op_head, + adh->client->delete_op_tail, + adh); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); - env = GNUNET_MQ_msg(acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); - acr_msg->id = htonl(adh->r_id); - acr_msg->op_result = htonl(success); - GNUNET_MQ_send(adh->client->mq, env); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); + env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); + acr_msg->id = htonl (adh->r_id); + acr_msg->op_result = htonl (success); + GNUNET_MQ_send (adh->client->mq, env); } @@ -1043,41 +1057,41 @@ send_delete_response(struct AttributeDeleteHandle *adh, int32_t success) * @param rd record data */ static void -ticket_iter(void *cls, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, - const char *label, - unsigned int rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +ticket_iter (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct AttributeDeleteHandle *adh = cls; struct TicketRecordsEntry *le; int has_changed = GNUNET_NO; for (int i = 0; i < rd_count; i++) - { - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) - continue; - if (0 != memcmp(rd[i].data, &adh->claim->id, sizeof(uint64_t))) - continue; - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Attribute to delete found (%s)\n", - adh->label); - has_changed = GNUNET_YES; - break; - } + { + if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + continue; + if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) + continue; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Attribute to delete found (%s)\n", + adh->label); + has_changed = GNUNET_YES; + break; + } if (GNUNET_YES == has_changed) - { - le = GNUNET_new(struct TicketRecordsEntry); - le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd); - le->data = GNUNET_malloc(le->data_size); - le->rd_count = rd_count; - le->label = GNUNET_strdup(label); - GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data); - GNUNET_CONTAINER_DLL_insert(adh->tickets_to_update_head, - adh->tickets_to_update_tail, - le); - } - GNUNET_NAMESTORE_zone_iterator_next(adh->ns_it, 1); + { + le = GNUNET_new (struct TicketRecordsEntry); + le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); + le->data = GNUNET_malloc (le->data_size); + le->rd_count = rd_count; + le->label = GNUNET_strdup (label); + GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data); + GNUNET_CONTAINER_DLL_insert (adh->tickets_to_update_head, + adh->tickets_to_update_tail, + le); + } + GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1); } @@ -1086,7 +1100,7 @@ ticket_iter(void *cls, * @param cls our deletion handle */ static void -update_tickets(void *cls); +update_tickets (void *cls); /** @@ -1097,12 +1111,12 @@ update_tickets(void *cls); * @param emsg error message (NULL if success=GNUNET_OK) */ static void -ticket_updated(void *cls, int32_t success, const char *emsg) +ticket_updated (void *cls, int32_t success, const char *emsg) { struct AttributeDeleteHandle *adh = cls; adh->ns_qe = NULL; - GNUNET_SCHEDULER_add_now(&update_tickets, adh); + GNUNET_SCHEDULER_add_now (&update_tickets, adh); } @@ -1114,58 +1128,58 @@ ticket_updated(void *cls, int32_t success, const char *emsg) * @param cls our attribute deletion handle */ static void -update_tickets(void *cls) +update_tickets (void *cls) { struct AttributeDeleteHandle *adh = cls; struct TicketRecordsEntry *le; if (NULL == adh->tickets_to_update_head) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Finished updatding tickets, success\n"); - send_delete_response(adh, GNUNET_OK); - cleanup_adh(adh); - return; - } - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Updating %s\n", - adh->tickets_to_update_head->label); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Finished updatding tickets, success\n"); + send_delete_response (adh, GNUNET_OK); + cleanup_adh (adh); + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Updating %s\n", + adh->tickets_to_update_head->label); le = adh->tickets_to_update_head; - GNUNET_CONTAINER_DLL_remove(adh->tickets_to_update_head, - adh->tickets_to_update_tail, - le); + GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, + adh->tickets_to_update_tail, + le); struct GNUNET_GNSRECORD_Data rd[le->rd_count]; struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1]; - if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize(le->data_size, - le->data, - le->rd_count, - rd)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Unable to deserialize record data!\n"); - send_delete_response(adh, GNUNET_SYSERR); - cleanup_adh(adh); - return; - } + if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (le->data_size, + le->data, + le->rd_count, + rd)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unable to deserialize record data!\n"); + send_delete_response (adh, GNUNET_SYSERR); + cleanup_adh (adh); + return; + } int j = 0; for (int i = 0; i < le->rd_count; i++) - { - if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) - && (0 == memcmp(rd[i].data, &adh->claim->id, sizeof(uint64_t)))) - continue; - rd_new[j] = rd[i]; - j++; - } - adh->ns_qe = GNUNET_NAMESTORE_records_store(nsh, - &adh->identity, - le->label, - j, - rd_new, - &ticket_updated, - adh); - GNUNET_free(le->label); - GNUNET_free(le->data); - GNUNET_free(le); + { + if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) + && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) + continue; + rd_new[j] = rd[i]; + j++; + } + adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, + &adh->identity, + le->label, + j, + rd_new, + &ticket_updated, + adh); + GNUNET_free (le->label); + GNUNET_free (le->data); + GNUNET_free (le); } @@ -1175,12 +1189,12 @@ update_tickets(void *cls) * @param cls our attribute deletion handle */ static void -ticket_iter_fin(void *cls) +ticket_iter_fin (void *cls) { struct AttributeDeleteHandle *adh = cls; adh->ns_it = NULL; - GNUNET_SCHEDULER_add_now(&update_tickets, adh); + GNUNET_SCHEDULER_add_now (&update_tickets, adh); } @@ -1190,16 +1204,16 @@ ticket_iter_fin(void *cls) * @param cls our attribute deletion handle */ static void -ticket_iter_err(void *cls) +ticket_iter_err (void *cls) { struct AttributeDeleteHandle *adh = cls; adh->ns_it = NULL; - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Namestore error on delete %s\n", - adh->label); - send_delete_response(adh, GNUNET_SYSERR); - cleanup_adh(adh); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Namestore error on delete %s\n", + adh->label); + send_delete_response (adh, GNUNET_SYSERR); + cleanup_adh (adh); } @@ -1210,18 +1224,18 @@ ticket_iter_err(void *cls) * @param cls attribute deletion handle */ static void -start_ticket_update(void *cls) +start_ticket_update (void *cls) { struct AttributeDeleteHandle *adh = cls; - adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start(nsh, - &adh->identity, - &ticket_iter_err, - adh, - &ticket_iter, - adh, - &ticket_iter_fin, - adh); + adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, + &adh->identity, + &ticket_iter_err, + adh, + &ticket_iter, + adh, + &ticket_iter_fin, + adh); } @@ -1233,22 +1247,22 @@ start_ticket_update(void *cls) * @param emsg error message (NULL if success=GNUNET_OK) */ static void -attr_delete_cont(void *cls, int32_t success, const char *emsg) +attr_delete_cont (void *cls, int32_t success, const char *emsg) { struct AttributeDeleteHandle *adh = cls; adh->ns_qe = NULL; if (GNUNET_SYSERR == success) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Error deleting attribute %s\n", - adh->label); - send_delete_response(adh, GNUNET_SYSERR); - cleanup_adh(adh); - return; - } - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); - GNUNET_SCHEDULER_add_now(&start_ticket_update, adh); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Error deleting attribute %s\n", + adh->label); + send_delete_response (adh, GNUNET_SYSERR); + cleanup_adh (adh); + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); + GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); } @@ -1259,17 +1273,17 @@ attr_delete_cont(void *cls, int32_t success, const char *emsg) * @dam message to check */ static int -check_attribute_delete_message(void *cls, - const struct AttributeDeleteMessage *dam) +check_attribute_delete_message (void *cls, + const struct AttributeDeleteMessage *dam) { uint16_t size; - size = ntohs(dam->header.size); + size = ntohs (dam->header.size); if (size <= sizeof(struct AttributeDeleteMessage)) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -1281,34 +1295,35 @@ check_attribute_delete_message(void *cls, * @param dam deletion message */ static void -handle_attribute_delete_message(void *cls, - const struct AttributeDeleteMessage *dam) +handle_attribute_delete_message (void *cls, + const struct AttributeDeleteMessage *dam) { struct AttributeDeleteHandle *adh; struct IdpClient *idp = cls; size_t data_len; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n"); - data_len = ntohs(dam->attr_len); + data_len = ntohs (dam->attr_len); - adh = GNUNET_new(struct AttributeDeleteHandle); - adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&dam[1], data_len); + adh = GNUNET_new (struct AttributeDeleteHandle); + adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1], + data_len); - adh->r_id = ntohl(dam->id); + adh->r_id = ntohl (dam->id); adh->identity = dam->identity; adh->label - = GNUNET_STRINGS_data_to_string_alloc(&adh->claim->id, sizeof(uint64_t)); - GNUNET_SERVICE_client_continue(idp->client); + = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof(uint64_t)); + GNUNET_SERVICE_client_continue (idp->client); adh->client = idp; - GNUNET_CONTAINER_DLL_insert(idp->delete_op_head, idp->delete_op_tail, adh); - adh->ns_qe = GNUNET_NAMESTORE_records_store(nsh, - &adh->identity, - adh->label, - 0, - NULL, - &attr_delete_cont, - adh); + GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); + adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, + &adh->identity, + adh->label, + 0, + NULL, + &attr_delete_cont, + adh); } @@ -1323,21 +1338,21 @@ handle_attribute_delete_message(void *cls, * @param cls our iterator handle */ static void -attr_iter_finished(void *cls) +attr_iter_finished (void *cls) { struct AttributeIterator *ai = cls; struct GNUNET_MQ_Envelope *env; struct AttributeResultMessage *arm; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); - env = GNUNET_MQ_msg(arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); - arm->id = htonl(ai->request_id); - arm->attr_len = htons(0); - GNUNET_MQ_send(ai->client->mq, env); - GNUNET_CONTAINER_DLL_remove(ai->client->attr_iter_head, - ai->client->attr_iter_tail, - ai); - GNUNET_free(ai); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); + env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); + arm->id = htonl (ai->request_id); + arm->attr_len = htons (0); + GNUNET_MQ_send (ai->client->mq, env); + GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, + ai->client->attr_iter_tail, + ai); + GNUNET_free (ai); } /** @@ -1346,12 +1361,12 @@ attr_iter_finished(void *cls) * @param cls our attribute iteration handle */ static void -attr_iter_error(void *cls) +attr_iter_error (void *cls) { struct AttributeIterator *ai = cls; - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); - attr_iter_finished(ai); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); + attr_iter_finished (ai); } @@ -1365,11 +1380,11 @@ attr_iter_error(void *cls) * @param rd records */ static void -attr_iter_cb(void *cls, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, - const char *label, - unsigned int rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +attr_iter_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct AttributeIterator *ai = cls; struct AttributeResultMessage *arm; @@ -1377,27 +1392,27 @@ attr_iter_cb(void *cls, char *data_tmp; if (rd_count != 1) - { - GNUNET_NAMESTORE_zone_iterator_next(ai->ns_it, 1); - return; - } + { + GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); + return; + } if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd->record_type) - { - GNUNET_NAMESTORE_zone_iterator_next(ai->ns_it, 1); - return; - } - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); - env = GNUNET_MQ_msg_extra(arm, - rd->data_size, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); - arm->id = htonl(ai->request_id); - arm->attr_len = htons(rd->data_size); - GNUNET_CRYPTO_ecdsa_key_get_public(zone, &arm->identity); - data_tmp = (char *)&arm[1]; - GNUNET_memcpy(data_tmp, rd->data, rd->data_size); - GNUNET_MQ_send(ai->client->mq, env); + { + GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); + env = GNUNET_MQ_msg_extra (arm, + rd->data_size, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); + arm->id = htonl (ai->request_id); + arm->attr_len = htons (rd->data_size); + GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); + data_tmp = (char *) &arm[1]; + GNUNET_memcpy (data_tmp, rd->data, rd->data_size); + GNUNET_MQ_send (ai->client->mq, env); } @@ -1408,29 +1423,29 @@ attr_iter_cb(void *cls, * @param ais_msg the iteration message to start */ static void -handle_iteration_start(void *cls, - const struct AttributeIterationStartMessage *ais_msg) +handle_iteration_start (void *cls, + const struct AttributeIterationStartMessage *ais_msg) { struct IdpClient *idp = cls; struct AttributeIterator *ai; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Received ATTRIBUTE_ITERATION_START message\n"); - ai = GNUNET_new(struct AttributeIterator); - ai->request_id = ntohl(ais_msg->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received ATTRIBUTE_ITERATION_START message\n"); + ai = GNUNET_new (struct AttributeIterator); + ai->request_id = ntohl (ais_msg->id); ai->client = idp; ai->identity = ais_msg->identity; - GNUNET_CONTAINER_DLL_insert(idp->attr_iter_head, idp->attr_iter_tail, ai); - ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start(nsh, - &ai->identity, - &attr_iter_error, - ai, - &attr_iter_cb, - ai, - &attr_iter_finished, - ai); - GNUNET_SERVICE_client_continue(idp->client); + GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai); + ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, + &ai->identity, + &attr_iter_error, + ai, + &attr_iter_cb, + ai, + &attr_iter_finished, + ai); + GNUNET_SERVICE_client_continue (idp->client); } @@ -1441,29 +1456,29 @@ handle_iteration_start(void *cls, * @param ais_msg the stop message */ static void -handle_iteration_stop(void *cls, - const struct AttributeIterationStopMessage *ais_msg) +handle_iteration_stop (void *cls, + const struct AttributeIterationStopMessage *ais_msg) { struct IdpClient *idp = cls; struct AttributeIterator *ai; uint32_t rid; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' message\n", - "ATTRIBUTE_ITERATION_STOP"); - rid = ntohl(ais_msg->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received `%s' message\n", + "ATTRIBUTE_ITERATION_STOP"); + rid = ntohl (ais_msg->id); for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) if (ai->request_id == rid) break; if (NULL == ai) - { - GNUNET_break(0); - GNUNET_SERVICE_client_drop(idp->client); - return; - } - GNUNET_CONTAINER_DLL_remove(idp->attr_iter_head, idp->attr_iter_tail, ai); - GNUNET_free(ai); - GNUNET_SERVICE_client_continue(idp->client); + { + GNUNET_break (0); + GNUNET_SERVICE_client_drop (idp->client); + return; + } + GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); + GNUNET_free (ai); + GNUNET_SERVICE_client_continue (idp->client); } @@ -1474,27 +1489,27 @@ handle_iteration_stop(void *cls, * @param ais_msg the message */ static void -handle_iteration_next(void *cls, - const struct AttributeIterationNextMessage *ais_msg) +handle_iteration_next (void *cls, + const struct AttributeIterationNextMessage *ais_msg) { struct IdpClient *idp = cls; struct AttributeIterator *ai; uint32_t rid; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Received ATTRIBUTE_ITERATION_NEXT message\n"); - rid = ntohl(ais_msg->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received ATTRIBUTE_ITERATION_NEXT message\n"); + rid = ntohl (ais_msg->id); for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) if (ai->request_id == rid) break; if (NULL == ai) - { - GNUNET_break(0); - GNUNET_SERVICE_client_drop(idp->client); - return; - } - GNUNET_NAMESTORE_zone_iterator_next(ai->ns_it, 1); - GNUNET_SERVICE_client_continue(idp->client); + { + GNUNET_break (0); + GNUNET_SERVICE_client_drop (idp->client); + return; + } + GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); + GNUNET_SERVICE_client_continue (idp->client); } /****************************************************** @@ -1508,29 +1523,29 @@ handle_iteration_next(void *cls, * @param ticket the ticket */ static void -ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket) +ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) { struct TicketIteration *ti = cls; struct GNUNET_MQ_Envelope *env; struct TicketResultMessage *trm; - env = GNUNET_MQ_msg(trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); + env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); if (NULL == ticket) - { - /* send empty response to indicate end of list */ - GNUNET_CONTAINER_DLL_remove(ti->client->ticket_iter_head, - ti->client->ticket_iter_tail, - ti); - } + { + /* send empty response to indicate end of list */ + GNUNET_CONTAINER_DLL_remove (ti->client->ticket_iter_head, + ti->client->ticket_iter_tail, + ti); + } else - { - trm->ticket = *ticket; - } - trm->id = htonl(ti->r_id); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); - GNUNET_MQ_send(ti->client->mq, env); + { + trm->ticket = *ticket; + } + trm->id = htonl (ti->r_id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); + GNUNET_MQ_send (ti->client->mq, env); if (NULL == ticket) - GNUNET_free(ti); + GNUNET_free (ti); } @@ -1541,25 +1556,25 @@ ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket) * @param tis_msg the iteration request message */ static void -handle_ticket_iteration_start( +handle_ticket_iteration_start ( void *cls, const struct TicketIterationStartMessage *tis_msg) { struct IdpClient *client = cls; struct TicketIteration *ti; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Received TICKET_ITERATION_START message\n"); - ti = GNUNET_new(struct TicketIteration); - ti->r_id = ntohl(tis_msg->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received TICKET_ITERATION_START message\n"); + ti = GNUNET_new (struct TicketIteration); + ti->r_id = ntohl (tis_msg->id); ti->client = client; - GNUNET_CONTAINER_DLL_insert(client->ticket_iter_head, - client->ticket_iter_tail, - ti); + GNUNET_CONTAINER_DLL_insert (client->ticket_iter_head, + client->ticket_iter_tail, + ti); ti->iter - = RECLAIM_TICKETS_iteration_start(&tis_msg->identity, &ticket_iter_cb, ti); - GNUNET_SERVICE_client_continue(client->client); + = RECLAIM_TICKETS_iteration_start (&tis_msg->identity, &ticket_iter_cb, ti); + GNUNET_SERVICE_client_continue (client->client); } @@ -1570,32 +1585,32 @@ handle_ticket_iteration_start( * @param tis_msg the stop message */ static void -handle_ticket_iteration_stop(void *cls, - const struct TicketIterationStopMessage *tis_msg) +handle_ticket_iteration_stop (void *cls, + const struct TicketIterationStopMessage *tis_msg) { struct IdpClient *client = cls; struct TicketIteration *ti; uint32_t rid; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' message\n", - "TICKET_ITERATION_STOP"); - rid = ntohl(tis_msg->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received `%s' message\n", + "TICKET_ITERATION_STOP"); + rid = ntohl (tis_msg->id); for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next) if (ti->r_id == rid) break; if (NULL == ti) - { - GNUNET_break(0); - GNUNET_SERVICE_client_drop(client->client); - return; - } - RECLAIM_TICKETS_iteration_stop(ti->iter); - GNUNET_CONTAINER_DLL_remove(client->ticket_iter_head, - client->ticket_iter_tail, - ti); - GNUNET_free(ti); - GNUNET_SERVICE_client_continue(client->client); + { + GNUNET_break (0); + GNUNET_SERVICE_client_drop (client->client); + return; + } + RECLAIM_TICKETS_iteration_stop (ti->iter); + GNUNET_CONTAINER_DLL_remove (client->ticket_iter_head, + client->ticket_iter_tail, + ti); + GNUNET_free (ti); + GNUNET_SERVICE_client_continue (client->client); } @@ -1606,27 +1621,27 @@ handle_ticket_iteration_stop(void *cls, * @param tis_msg the message */ static void -handle_ticket_iteration_next(void *cls, - const struct TicketIterationNextMessage *tis_msg) +handle_ticket_iteration_next (void *cls, + const struct TicketIterationNextMessage *tis_msg) { struct IdpClient *client = cls; struct TicketIteration *ti; uint32_t rid; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Received TICKET_ITERATION_NEXT message\n"); - rid = ntohl(tis_msg->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received TICKET_ITERATION_NEXT message\n"); + rid = ntohl (tis_msg->id); for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next) if (ti->r_id == rid) break; if (NULL == ti) - { - GNUNET_break(0); - GNUNET_SERVICE_client_drop(client->client); - return; - } - RECLAIM_TICKETS_iteration_next(ti->iter); - GNUNET_SERVICE_client_continue(client->client); + { + GNUNET_break (0); + GNUNET_SERVICE_client_drop (client->client); + return; + } + RECLAIM_TICKETS_iteration_next (ti->iter); + GNUNET_SERVICE_client_continue (client->client); } @@ -1638,28 +1653,28 @@ handle_ticket_iteration_next(void *cls, * @param server the service handle */ static void -run(void *cls, - const struct GNUNET_CONFIGURATION_Handle *c, - struct GNUNET_SERVICE_Handle *server) +run (void *cls, + const struct GNUNET_CONFIGURATION_Handle *c, + struct GNUNET_SERVICE_Handle *server) { cfg = c; - if (GNUNET_OK != RECLAIM_TICKETS_init(cfg)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Unable to initialize TICKETS subsystem.\n"); - GNUNET_SCHEDULER_shutdown(); - return; - } + if (GNUNET_OK != RECLAIM_TICKETS_init (cfg)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unable to initialize TICKETS subsystem.\n"); + GNUNET_SCHEDULER_shutdown (); + return; + } // Connect to identity and namestore services - nsh = GNUNET_NAMESTORE_connect(cfg); + nsh = GNUNET_NAMESTORE_connect (cfg); if (NULL == nsh) - { - GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, - "error connecting to namestore"); - } + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, + "error connecting to namestore"); + } - GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); } @@ -1671,17 +1686,17 @@ run(void *cls, * @param app_ctx @a client */ static void -client_disconnect_cb(void *cls, - struct GNUNET_SERVICE_Client *client, - void *app_ctx) +client_disconnect_cb (void *cls, + struct GNUNET_SERVICE_Client *client, + void *app_ctx) { struct IdpClient *idp = app_ctx; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); - GNUNET_CONTAINER_DLL_remove(client_list_head, - client_list_tail, - idp); - cleanup_client(idp); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); + GNUNET_CONTAINER_DLL_remove (client_list_head, + client_list_tail, + idp); + cleanup_client (idp); } @@ -1694,19 +1709,19 @@ client_disconnect_cb(void *cls, * @return internal namestore client structure for this client */ static void * -client_connect_cb(void *cls, - struct GNUNET_SERVICE_Client *client, - struct GNUNET_MQ_Handle *mq) +client_connect_cb (void *cls, + struct GNUNET_SERVICE_Client *client, + struct GNUNET_MQ_Handle *mq) { struct IdpClient *idp; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client); - idp = GNUNET_new(struct IdpClient); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client); + idp = GNUNET_new (struct IdpClient); idp->client = client; idp->mq = mq; - GNUNET_CONTAINER_DLL_insert(client_list_head, - client_list_tail, - idp); + GNUNET_CONTAINER_DLL_insert (client_list_head, + client_list_tail, + idp); return idp; } @@ -1714,57 +1729,57 @@ client_connect_cb(void *cls, /** * Define "main" method using service macro. */ -GNUNET_SERVICE_MAIN( +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( + 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()); + 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 b38a5eb25..57c9e2167 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c @@ -44,7 +44,8 @@ struct ParallelLookup; /** * A reference to a ticket stored in GNS */ -struct TicketReference { +struct TicketReference +{ /** * DLL */ @@ -70,7 +71,8 @@ struct TicketReference { /** * Handle to a consume operation */ -struct RECLAIM_TICKETS_ConsumeHandle { +struct RECLAIM_TICKETS_ConsumeHandle +{ /** * Ticket */ @@ -131,7 +133,8 @@ struct RECLAIM_TICKETS_ConsumeHandle { /** * Handle for a parallel GNS lookup job */ -struct ParallelLookup { +struct ParallelLookup +{ /* DLL */ struct ParallelLookup *next; @@ -157,7 +160,8 @@ struct ParallelLookup { /** * Ticket issue request handle */ -struct TicketIssueHandle { +struct TicketIssueHandle +{ /** * Attributes to issue */ @@ -198,7 +202,8 @@ struct TicketIssueHandle { /** * Ticket iterator */ -struct RECLAIM_TICKETS_Iterator { +struct RECLAIM_TICKETS_Iterator +{ /** * Namestore queue entry */ @@ -216,7 +221,8 @@ struct RECLAIM_TICKETS_Iterator { }; -struct RevokedAttributeEntry { +struct RevokedAttributeEntry +{ /** * DLL */ @@ -242,7 +248,8 @@ struct RevokedAttributeEntry { /** * Ticket revocation request handle */ -struct RECLAIM_TICKETS_RevokeHandle { +struct RECLAIM_TICKETS_RevokeHandle +{ /** * Issuer Key */ @@ -330,32 +337,32 @@ static struct GNUNET_STATISTICS_Handle *stats; * @param rh the ticket revocation handle */ static void -cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh) +cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh) { struct RevokedAttributeEntry *ae; struct TicketRecordsEntry *le; if (NULL != rh->ns_qe) - GNUNET_NAMESTORE_cancel(rh->ns_qe); + GNUNET_NAMESTORE_cancel (rh->ns_qe); if (NULL != rh->ns_it) - GNUNET_NAMESTORE_zone_iteration_stop(rh->ns_it); + GNUNET_NAMESTORE_zone_iteration_stop (rh->ns_it); while (NULL != (ae = rh->attrs_head)) - { - GNUNET_CONTAINER_DLL_remove(rh->attrs_head, rh->attrs_tail, ae); - GNUNET_free(ae); - } + { + GNUNET_CONTAINER_DLL_remove (rh->attrs_head, rh->attrs_tail, ae); + GNUNET_free (ae); + } while (NULL != (le = rh->tickets_to_update_head)) - { - GNUNET_CONTAINER_DLL_remove(rh->tickets_to_update_head, - rh->tickets_to_update_head, - le); - if (NULL != le->data) - GNUNET_free(le->data); - if (NULL != le->label) - GNUNET_free(le->label); - GNUNET_free(le); - } - GNUNET_free(rh); + { + GNUNET_CONTAINER_DLL_remove (rh->tickets_to_update_head, + rh->tickets_to_update_head, + le); + if (NULL != le->data) + GNUNET_free (le->data); + if (NULL != le->label) + GNUNET_free (le->label); + GNUNET_free (le); + } + GNUNET_free (rh); } @@ -366,7 +373,7 @@ cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh) * @param cls handle to the operation */ static void -process_tickets(void *cls); +process_tickets (void *cls); /** @@ -378,12 +385,12 @@ process_tickets(void *cls); * @param emsg (NULL on success) */ static void -ticket_processed(void *cls, int32_t success, const char *emsg) +ticket_processed (void *cls, int32_t success, const char *emsg) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_qe = NULL; - GNUNET_SCHEDULER_add_now(&process_tickets, rvk); + GNUNET_SCHEDULER_add_now (&process_tickets, rvk); } @@ -393,57 +400,57 @@ ticket_processed(void *cls, int32_t success, const char *emsg) * @param cls handle to the operation */ static void -process_tickets(void *cls) +process_tickets (void *cls) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; struct TicketRecordsEntry *le; struct RevokedAttributeEntry *ae; if (NULL == rvk->tickets_to_update_head) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Finished updatding tickets, success\n"); - rvk->cb(rvk->cb_cls, GNUNET_OK); - cleanup_rvk(rvk); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Finished updatding tickets, success\n"); + rvk->cb (rvk->cb_cls, GNUNET_OK); + cleanup_rvk (rvk); + return; + } le = rvk->tickets_to_update_head; - GNUNET_CONTAINER_DLL_remove(rvk->tickets_to_update_head, - rvk->tickets_to_update_tail, - le); + GNUNET_CONTAINER_DLL_remove (rvk->tickets_to_update_head, + rvk->tickets_to_update_tail, + le); struct GNUNET_GNSRECORD_Data rd[le->rd_count]; - if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize(le->data_size, - le->data, - le->rd_count, - rd)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Unable to deserialize ticket record(s)\n"); - rvk->cb(rvk->cb_cls, GNUNET_SYSERR); - cleanup_rvk(rvk); - return; - } + if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (le->data_size, + le->data, + le->rd_count, + rd)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unable to deserialize ticket record(s)\n"); + rvk->cb (rvk->cb_cls, GNUNET_SYSERR); + cleanup_rvk (rvk); + return; + } for (int i = 0; i < le->rd_count; i++) + { + if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + continue; + for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) { - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t))) continue; - for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) - { - if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t))) - continue; - rd[i].data = &ae->new_id; - } + rd[i].data = &ae->new_id; } - rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, - &rvk->identity, - le->label, - le->rd_count, - rd, - &ticket_processed, - rvk); - GNUNET_free(le->label); - GNUNET_free(le->data); - GNUNET_free(le); + } + rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, + &rvk->identity, + le->label, + le->rd_count, + rd, + &ticket_processed, + rvk); + GNUNET_free (le->label); + GNUNET_free (le->data); + GNUNET_free (le); } @@ -453,12 +460,12 @@ process_tickets(void *cls) * @param cls handle to the operation */ static void -rvk_ticket_update_finished(void *cls) +rvk_ticket_update_finished (void *cls) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_it = NULL; - GNUNET_SCHEDULER_add_now(&process_tickets, rvk); + GNUNET_SCHEDULER_add_now (&process_tickets, rvk); } @@ -473,11 +480,11 @@ rvk_ticket_update_finished(void *cls) * @param rd record set */ static void -rvk_ticket_update(void *cls, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, - const char *label, - unsigned int rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +rvk_ticket_update (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; struct TicketRecordsEntry *le; @@ -486,32 +493,32 @@ rvk_ticket_update(void *cls, /** Let everything point to the old record **/ for (int i = 0; i < rd_count; i++) + { + if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + continue; + for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) { - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t))) continue; - for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) - { - if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t))) - continue; - has_changed = GNUNET_YES; - break; - } - if (GNUNET_YES == has_changed) - break; + has_changed = GNUNET_YES; + break; } + if (GNUNET_YES == has_changed) + break; + } if (GNUNET_YES == has_changed) - { - le = GNUNET_new(struct TicketRecordsEntry); - le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd); - le->data = GNUNET_malloc(le->data_size); - le->rd_count = rd_count; - le->label = GNUNET_strdup(label); - GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data); - GNUNET_CONTAINER_DLL_insert(rvk->tickets_to_update_head, - rvk->tickets_to_update_tail, - le); - } - GNUNET_NAMESTORE_zone_iterator_next(rvk->ns_it, 1); + { + le = GNUNET_new (struct TicketRecordsEntry); + le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); + le->data = GNUNET_malloc (le->data_size); + le->rd_count = rd_count; + le->label = GNUNET_strdup (label); + GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data); + GNUNET_CONTAINER_DLL_insert (rvk->tickets_to_update_head, + rvk->tickets_to_update_tail, + le); + } + GNUNET_NAMESTORE_zone_iterator_next (rvk->ns_it, 1); } @@ -521,16 +528,16 @@ rvk_ticket_update(void *cls, * @param cls handle to the operation */ static void -rvk_ns_iter_err(void *cls) +rvk_ns_iter_err (void *cls) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_it = NULL; - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Namestore error on revocation (id=%" PRIu64 "\n", - rvk->move_attr->old_id); - rvk->cb(rvk->cb_cls, GNUNET_SYSERR); - cleanup_rvk(rvk); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Namestore error on revocation (id=%" PRIu64 "\n", + rvk->move_attr->old_id); + rvk->cb (rvk->cb_cls, GNUNET_SYSERR); + cleanup_rvk (rvk); } @@ -540,16 +547,16 @@ rvk_ns_iter_err(void *cls) * @param cls handle to the operation */ static void -rvk_ns_err(void *cls) +rvk_ns_err (void *cls) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_qe = NULL; - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Namestore error on revocation (id=%" PRIu64 "\n", - rvk->move_attr->old_id); - rvk->cb(rvk->cb_cls, GNUNET_SYSERR); - cleanup_rvk(rvk); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Namestore error on revocation (id=%" PRIu64 "\n", + rvk->move_attr->old_id); + rvk->cb (rvk->cb_cls, GNUNET_SYSERR); + cleanup_rvk (rvk); } @@ -563,7 +570,7 @@ rvk_ns_err(void *cls) * @param rvk handle to the operation */ static void -move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh); +move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rh); /** @@ -572,9 +579,9 @@ move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh); * @param cls handle to the operation. */ static void -move_attrs_cont(void *cls) +move_attrs_cont (void *cls) { - move_attrs((struct RECLAIM_TICKETS_RevokeHandle *)cls); + move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls); } @@ -587,22 +594,22 @@ move_attrs_cont(void *cls) * @param emsg error message (NULL on success) */ static void -del_attr_finished(void *cls, int32_t success, const char *emsg) +del_attr_finished (void *cls, int32_t success, const char *emsg) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_qe = NULL; if (GNUNET_SYSERR == success) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Error removing attribute: %s\n", - emsg); - rvk->cb(rvk->cb_cls, GNUNET_SYSERR); - cleanup_rvk(rvk); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Error removing attribute: %s\n", + emsg); + rvk->cb (rvk->cb_cls, GNUNET_SYSERR); + cleanup_rvk (rvk); + return; + } rvk->move_attr = rvk->move_attr->next; - GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); + GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk); } @@ -616,31 +623,31 @@ del_attr_finished(void *cls, int32_t success, const char *emsg) * @param emsg error message (NULL on success) */ static void -move_attr_finished(void *cls, int32_t success, const char *emsg) +move_attr_finished (void *cls, int32_t success, const char *emsg) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; char *label; rvk->ns_qe = NULL; if (GNUNET_SYSERR == success) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); - rvk->cb(rvk->cb_cls, GNUNET_SYSERR); - cleanup_rvk(rvk); - return; - } - label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, - sizeof(uint64_t)); - GNUNET_assert(NULL != label); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); - rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, - &rvk->identity, - label, - 0, - NULL, - &del_attr_finished, - rvk); - GNUNET_free(label); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); + rvk->cb (rvk->cb_cls, GNUNET_SYSERR); + cleanup_rvk (rvk); + return; + } + label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, + sizeof(uint64_t)); + GNUNET_assert (NULL != label); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); + rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, + &rvk->identity, + label, + 0, + NULL, + &del_attr_finished, + rvk); + GNUNET_free (label); } @@ -654,11 +661,11 @@ move_attr_finished(void *cls, int32_t success, const char *emsg) * @param rd record set (the attribute) */ static void -rvk_move_attr_cb(void *cls, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, - const char *label, - unsigned int rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +rvk_move_attr_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; @@ -669,44 +676,44 @@ rvk_move_attr_cb(void *cls, rvk->ns_qe = NULL; if (0 == rd_count) - { - GNUNET_log(GNUNET_ERROR_TYPE_WARNING, - "The attribute %s no longer exists!\n", - label); - le = rvk->move_attr; - rvk->move_attr = le->next; - GNUNET_CONTAINER_DLL_remove(rvk->attrs_head, rvk->attrs_tail, le); - GNUNET_free(le); - GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "The attribute %s no longer exists!\n", + label); + le = rvk->move_attr; + rvk->move_attr = le->next; + GNUNET_CONTAINER_DLL_remove (rvk->attrs_head, rvk->attrs_tail, le); + GNUNET_free (le); + GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk); + return; + } /** 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, - "Attribute to update: Name=%s, ID=%" PRIu64 "\n", - claim->name, - claim->id); + claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Attribute to update: Name=%s, ID=%" PRIu64 "\n", + claim->name, + claim->id); claim->id = rvk->move_attr->new_id; - new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(claim); - attr_data = GNUNET_malloc(rd->data_size); - new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize(claim, attr_data); + new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); + attr_data = GNUNET_malloc (rd->data_size); + new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data); new_rd.data = attr_data; - new_label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->new_id, - 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); - GNUNET_free(new_label); - GNUNET_free(claim); - GNUNET_free(attr_data); + new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, + 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); + GNUNET_free (new_label); + GNUNET_free (claim); + GNUNET_free (attr_data); } @@ -719,36 +726,36 @@ rvk_move_attr_cb(void *cls, * @param rvk handle to the operation */ static void -move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rvk) +move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) { char *label; 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); - return; - } - label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, - sizeof(uint64_t)); - 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); - GNUNET_free(label); + { + 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); + return; + } + label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, + sizeof(uint64_t)); + 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); + GNUNET_free (label); } @@ -764,29 +771,29 @@ move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rvk) * @param emsg error message (NULL on success) */ static void -remove_ticket_cont(void *cls, int32_t success, const char *emsg) +remove_ticket_cont (void *cls, int32_t success, const char *emsg) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; rvk->ns_qe = NULL; if (GNUNET_SYSERR == success) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); - rvk->cb(rvk->cb_cls, GNUNET_SYSERR); - cleanup_rvk(rvk); - return; - } - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); + rvk->cb (rvk->cb_cls, GNUNET_SYSERR); + cleanup_rvk (rvk); + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); if (0 == rvk->ticket_attrs) - { - GNUNET_log(GNUNET_ERROR_TYPE_WARNING, - "No attributes to move... strange\n"); - rvk->cb(rvk->cb_cls, GNUNET_OK); - cleanup_rvk(rvk); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "No attributes to move... strange\n"); + rvk->cb (rvk->cb_cls, GNUNET_OK); + cleanup_rvk (rvk); + return; + } rvk->move_attr = rvk->attrs_head; - move_attrs(rvk); + move_attrs (rvk); } @@ -801,11 +808,11 @@ remove_ticket_cont(void *cls, int32_t success, const char *emsg) * @param rd record set */ static void -revoke_attrs_cb(void *cls, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, - const char *label, - unsigned int rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +revoke_attrs_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; @@ -817,23 +824,23 @@ revoke_attrs_cb(void *cls, * We need it later. */ for (int i = 0; i < rd_count; i++) - { - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) - continue; - le = GNUNET_new(struct RevokedAttributeEntry); - le->old_id = *((uint64_t *)rd[i].data); - GNUNET_CONTAINER_DLL_insert(rvk->attrs_head, rvk->attrs_tail, le); - rvk->ticket_attrs++; - } + { + if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + continue; + le = GNUNET_new (struct RevokedAttributeEntry); + le->old_id = *((uint64_t *) rd[i].data); + GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le); + rvk->ticket_attrs++; + } /** Remove attribute references **/ - rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, - &rvk->identity, - label, - 0, - NULL, - &remove_ticket_cont, - rvk); + rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, + &rvk->identity, + label, + 0, + NULL, + &remove_ticket_cont, + rvk); } @@ -843,12 +850,12 @@ revoke_attrs_cb(void *cls, * @param cls handle to the operation */ static void -rvk_attrs_err_cb(void *cls) +rvk_attrs_err_cb (void *cls) { struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; - rvk->cb(rvk->cb_cls, GNUNET_SYSERR); - cleanup_rvk(rvk); + rvk->cb (rvk->cb_cls, GNUNET_SYSERR); + cleanup_rvk (rvk); } @@ -864,31 +871,31 @@ rvk_attrs_err_cb(void *cls) * @return handle to the operation */ struct RECLAIM_TICKETS_RevokeHandle * -RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - RECLAIM_TICKETS_RevokeCallback cb, - void *cb_cls) +RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + RECLAIM_TICKETS_RevokeCallback cb, + void *cb_cls) { struct RECLAIM_TICKETS_RevokeHandle *rvk; char *label; - rvk = GNUNET_new(struct RECLAIM_TICKETS_RevokeHandle); + rvk = GNUNET_new (struct RECLAIM_TICKETS_RevokeHandle); rvk->cb = cb; rvk->cb_cls = cb_cls; rvk->identity = *identity; rvk->ticket = *ticket; - GNUNET_CRYPTO_ecdsa_key_get_public(&rvk->identity, &rvk->ticket.identity); + GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity); /** Get shared attributes **/ - label = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); - GNUNET_assert(NULL != label); - rvk->ns_qe = GNUNET_NAMESTORE_records_lookup(nsh, - identity, - label, - &rvk_attrs_err_cb, - rvk, - &revoke_attrs_cb, - rvk); - GNUNET_free(label); + label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); + GNUNET_assert (NULL != label); + rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, + identity, + label, + &rvk_attrs_err_cb, + rvk, + &revoke_attrs_cb, + rvk); + GNUNET_free (label); return rvk; } @@ -899,10 +906,10 @@ RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, * @param rh handle to the operation */ void -RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh) +RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh) { - GNUNET_assert(NULL != rh); - cleanup_rvk(rh); + GNUNET_assert (NULL != rh); + cleanup_rvk (rh); } @@ -916,28 +923,28 @@ RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh) * @param cth the handle to clean up */ static void -cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth) +cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) { struct ParallelLookup *lu; if (NULL != cth->lookup_request) - GNUNET_GNS_lookup_cancel(cth->lookup_request); + GNUNET_GNS_lookup_cancel (cth->lookup_request); if (NULL != cth->kill_task) - GNUNET_SCHEDULER_cancel(cth->kill_task); + GNUNET_SCHEDULER_cancel (cth->kill_task); while (NULL != (lu = cth->parallel_lookups_head)) - { - if (NULL != lu->lookup_request) - GNUNET_GNS_lookup_cancel(lu->lookup_request); - GNUNET_free_non_null(lu->label); - GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, - cth->parallel_lookups_tail, - lu); - GNUNET_free(lu); - } + { + if (NULL != lu->lookup_request) + GNUNET_GNS_lookup_cancel (lu->lookup_request); + GNUNET_free_non_null (lu->label); + GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, + cth->parallel_lookups_tail, + lu); + GNUNET_free (lu); + } if (NULL != cth->attrs) - GNUNET_RECLAIM_ATTRIBUTE_list_destroy(cth->attrs); - GNUNET_free(cth); + GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cth->attrs); + GNUNET_free (cth); } @@ -949,51 +956,51 @@ cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth) * @param rd record set */ static void -process_parallel_lookup_result(void *cls, - uint32_t rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +process_parallel_lookup_result (void *cls, + uint32_t rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct ParallelLookup *parallel_lookup = cls; struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Parallel lookup finished (count=%u)\n", - rd_count); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Parallel lookup finished (count=%u)\n", + rd_count); - GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, - cth->parallel_lookups_tail, - parallel_lookup); - GNUNET_free(parallel_lookup->label); + GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, + cth->parallel_lookups_tail, + parallel_lookup); + 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); - GNUNET_STATISTICS_update(stats, "attribute_lookups_count", 1, GNUNET_YES); + GNUNET_STATISTICS_update (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); - GNUNET_free(parallel_lookup); + GNUNET_free (parallel_lookup); if (1 != rd_count) - GNUNET_break(0); // FIXME: We should never find this. + GNUNET_break (0); // FIXME: We should never find this. 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_CONTAINER_DLL_insert(cth->attrs->list_head, - cth->attrs->list_tail, - attr_le); - } + { + attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); + attr_le->claim = + GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); + GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, + cth->attrs->list_tail, + attr_le); + } if (NULL != cth->parallel_lookups_head) return; // Wait for more /* Else we are done */ - cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); - cleanup_cth(cth); + cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); + cleanup_cth (cth); } @@ -1003,7 +1010,7 @@ process_parallel_lookup_result(void *cls, * @param cls handle to the operation */ static void -abort_parallel_lookups(void *cls) +abort_parallel_lookups (void *cls) { struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; struct ParallelLookup *lu; @@ -1011,17 +1018,17 @@ abort_parallel_lookups(void *cls) cth->kill_task = NULL; for (lu = cth->parallel_lookups_head; NULL != lu;) - { - GNUNET_GNS_lookup_cancel(lu->lookup_request); - GNUNET_free(lu->label); - tmp = lu->next; - GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, - cth->parallel_lookups_tail, - lu); - GNUNET_free(lu); - lu = tmp; - } - cth->cb(cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); + { + GNUNET_GNS_lookup_cancel (lu->lookup_request); + GNUNET_free (lu->label); + tmp = lu->next; + GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, + cth->parallel_lookups_tail, + lu); + GNUNET_free (lu); + lu = tmp; + } + cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); } @@ -1035,9 +1042,9 @@ abort_parallel_lookups(void *cls) * @param rd record set */ static void -lookup_authz_cb(void *cls, - uint32_t rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +lookup_authz_cb (void *cls, + uint32_t rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; struct ParallelLookup *parallel_lookup; @@ -1045,56 +1052,56 @@ lookup_authz_cb(void *cls, 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); - GNUNET_STATISTICS_update(stats, - "reclaim_authz_lookups_count", - 1, - GNUNET_YES); + GNUNET_STATISTICS_update (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); for (int i = 0; i < rd_count; i++) - { - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) - continue; - lbl = GNUNET_STRINGS_data_to_string_alloc(rd[i].data, rd[i].data_size); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); - parallel_lookup = GNUNET_new(struct ParallelLookup); - parallel_lookup->handle = cth; - 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); - GNUNET_CONTAINER_DLL_insert(cth->parallel_lookups_head, - cth->parallel_lookups_tail, - parallel_lookup); - } + { + if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + continue; + lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); + parallel_lookup = GNUNET_new (struct ParallelLookup); + parallel_lookup->handle = cth; + 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); + GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, + cth->parallel_lookups_tail, + parallel_lookup); + } /** * We started lookups. Add a timeout task. * FIXME: Really needed here? */ 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); - return; - } + { + cth->kill_task = GNUNET_SCHEDULER_add_delayed ( + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), + &abort_parallel_lookups, + cth); + return; + } /** * No references found, return empty attribute list */ - cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); - cleanup_cth(cth); + cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); + cleanup_cth (cth); } @@ -1110,37 +1117,37 @@ lookup_authz_cb(void *cls, * @return handle to the operation */ struct RECLAIM_TICKETS_ConsumeHandle * -RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, - const struct GNUNET_RECLAIM_Ticket *ticket, - RECLAIM_TICKETS_ConsumeCallback cb, - void *cb_cls) +RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, + const struct GNUNET_RECLAIM_Ticket *ticket, + RECLAIM_TICKETS_ConsumeCallback cb, + void *cb_cls) { struct RECLAIM_TICKETS_ConsumeHandle *cth; char *label; - cth = GNUNET_new(struct RECLAIM_TICKETS_ConsumeHandle); + cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle); cth->identity = *id; - GNUNET_CRYPTO_ecdsa_key_get_public(&cth->identity, &cth->identity_pub); - cth->attrs = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); + GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); + cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); cth->ticket = *ticket; cth->cb = cb; cth->cb_cls = cb_cls; label = - 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(); + 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); - GNUNET_free(label); + GNUNET_GNS_lookup (gns, + label, + &cth->ticket.identity, + GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, + GNUNET_GNS_LO_DEFAULT, + &lookup_authz_cb, + cth); + GNUNET_free (label); return cth; } @@ -1151,9 +1158,9 @@ RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, * @param cth the operation to cancel */ void -RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth) +RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth) { - cleanup_cth(cth); + cleanup_cth (cth); return; } @@ -1167,11 +1174,11 @@ RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth) * @param handle the handle to clean up */ static void -cleanup_issue_handle(struct TicketIssueHandle *handle) +cleanup_issue_handle (struct TicketIssueHandle *handle) { if (NULL != handle->ns_qe) - GNUNET_NAMESTORE_cancel(handle->ns_qe); - GNUNET_free(handle); + GNUNET_NAMESTORE_cancel (handle->ns_qe); + GNUNET_free (handle); } @@ -1184,21 +1191,21 @@ cleanup_issue_handle(struct TicketIssueHandle *handle) * @param emsg error message (or NULL on success) */ static void -store_ticket_issue_cont(void *cls, int32_t success, const char *emsg) +store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) { struct TicketIssueHandle *handle = cls; handle->ns_qe = NULL; if (GNUNET_SYSERR == success) - { - handle->cb(handle->cb_cls, - &handle->ticket, - GNUNET_SYSERR, - "Error storing AuthZ ticket in GNS"); - return; - } - handle->cb(handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); - cleanup_issue_handle(handle); + { + handle->cb (handle->cb_cls, + &handle->ticket, + GNUNET_SYSERR, + "Error storing AuthZ ticket in GNS"); + return; + } + handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); + cleanup_issue_handle (handle); } @@ -1210,7 +1217,7 @@ store_ticket_issue_cont(void *cls, int32_t success, const char *emsg) * @param ih handle to the operation containing relevant metadata */ static void -issue_ticket(struct TicketIssueHandle *ih) +issue_ticket (struct TicketIssueHandle *ih) { struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; struct GNUNET_GNSRECORD_Data *attrs_record; @@ -1222,21 +1229,21 @@ 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; - attrs_record[i].data_size = sizeof(le->claim->id); - /** - * FIXME: Should this be the attribute expiration time or ticket - * refresh interval? Probably min(attrs.expiration) - */ - attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; - attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; - attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; - i++; - } + { + attrs_record[i].data = &le->claim->id; + attrs_record[i].data_size = sizeof(le->claim->id); + /** + * FIXME: Should this be the attribute expiration time or ticket + * refresh interval? Probably min(attrs.expiration) + */ + attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; + attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; + attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; + i++; + } attrs_record[i].data = &ih->ticket; attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket); attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; @@ -1245,17 +1252,17 @@ issue_ticket(struct TicketIssueHandle *ih) 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, - &store_ticket_issue_cont, - ih); - GNUNET_free(attrs_record); - GNUNET_free(label); + ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, + &ih->identity, + label, + list_len, + attrs_record, + &store_ticket_issue_cont, + ih); + GNUNET_free (attrs_record); + GNUNET_free (label); } /************************************************* @@ -1269,16 +1276,16 @@ issue_ticket(struct TicketIssueHandle *ih) * @param cls handle to the operation */ static void -filter_tickets_error_cb(void *cls) +filter_tickets_error_cb (void *cls) { struct TicketIssueHandle *tih = cls; tih->ns_it = NULL; - tih->cb(tih->cb_cls, - &tih->ticket, - GNUNET_SYSERR, - "Error storing AuthZ ticket in GNS"); - cleanup_issue_handle(tih); + tih->cb (tih->cb_cls, + &tih->ticket, + GNUNET_SYSERR, + "Error storing AuthZ ticket in GNS"); + cleanup_issue_handle (tih); } @@ -1295,11 +1302,11 @@ filter_tickets_error_cb(void *cls) * @param rd record set */ static void -filter_tickets_cb(void *cls, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, - const char *label, - unsigned int rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +filter_tickets_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct TicketIssueHandle *tih = cls; struct GNUNET_RECLAIM_Ticket *ticket = NULL; @@ -1315,53 +1322,53 @@ filter_tickets_cb(void *cls, unsigned int found_attrs_cnt = 0; for (int i = 0; i < rd_count; i++) + { + // found ticket + if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) { - // found ticket - if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) - { - ticket = (struct GNUNET_RECLAIM_Ticket *)rd[i].data; - // cmp audience - if (0 == memcmp(&tih->ticket.audience, - &ticket->audience, - sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) - { - tih->ticket = *ticket; - continue; - } - ticket = NULL; - } - - // cmp requested attributes with ticket attributes - if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data; + // cmp audience + if (0 == memcmp (&tih->ticket.audience, + &ticket->audience, + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) + { + tih->ticket = *ticket; continue; - for (le = tih->attrs->list_head; NULL != le; le = le->next) - { - // cmp attr_ref id with requested attr id - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - " %" PRIu64 "\n %" PRIu64 "\n", - *((uint64_t *)rd[i].data), - le->claim->id); - - - if (0 == memcmp(rd[i].data, &le->claim->id, sizeof(uint64_t))) - found_attrs_cnt++; - } + } + ticket = NULL; } + // cmp requested attributes with ticket attributes + if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) + continue; + for (le = tih->attrs->list_head; NULL != le; le = le->next) + { + // cmp attr_ref id with requested attr id + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + " %" PRIu64 "\n %" PRIu64 "\n", + *((uint64_t *) rd[i].data), + le->claim->id); + + + if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(uint64_t))) + found_attrs_cnt++; + } + } + /** * If we found a matching ticket, return that to the caller and * we are done. */ - if (attr_cnt == found_attrs_cnt && NULL != ticket) - { - GNUNET_NAMESTORE_zone_iteration_stop(tih->ns_it); - tih->cb(tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); - cleanup_issue_handle(tih); - return; - } + if ((attr_cnt == found_attrs_cnt)&&(NULL != ticket)) + { + GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it); + tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); + cleanup_issue_handle (tih); + return; + } // ticket not found in current record, checking next record set - GNUNET_NAMESTORE_zone_iterator_next(tih->ns_it, 1); + GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1); } @@ -1373,14 +1380,14 @@ filter_tickets_cb(void *cls, * @param cls handle to the operation */ static void -filter_tickets_finished_cb(void *cls) +filter_tickets_finished_cb (void *cls) { struct TicketIssueHandle *tih = cls; - GNUNET_CRYPTO_ecdsa_key_get_public(&tih->identity, &tih->ticket.identity); + GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity); tih->ticket.rnd = - GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); - issue_ticket(tih); + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); + issue_ticket (tih); } @@ -1396,31 +1403,31 @@ filter_tickets_finished_cb(void *cls) * FIXME: Return handle?? */ void -RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, - const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, - RECLAIM_TICKETS_TicketResult cb, - void *cb_cls) +RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, + const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, + RECLAIM_TICKETS_TicketResult cb, + void *cb_cls) { struct TicketIssueHandle *tih; - tih = GNUNET_new(struct TicketIssueHandle); + tih = GNUNET_new (struct TicketIssueHandle); tih->cb = cb; tih->cb_cls = cb_cls; - tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup(attrs); + tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs); tih->identity = *identity; tih->ticket.audience = *audience; // First check whether the ticket has already been issued tih->ns_it = - GNUNET_NAMESTORE_zone_iteration_start(nsh, - &tih->identity, - &filter_tickets_error_cb, - tih, - &filter_tickets_cb, - tih, - &filter_tickets_finished_cb, - tih); + GNUNET_NAMESTORE_zone_iteration_start (nsh, + &tih->identity, + &filter_tickets_error_cb, + tih, + &filter_tickets_cb, + tih, + &filter_tickets_finished_cb, + tih); } @@ -1434,11 +1441,11 @@ RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, * @param iter handle to the iteration */ static void -cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter) +cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter) { if (NULL != iter->ns_it) - GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); - GNUNET_free(iter); + GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it); + GNUNET_free (iter); } @@ -1454,22 +1461,22 @@ cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter) * @param rd record set containing a ticket */ static void -collect_tickets_cb(void *cls, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, - const char *label, - unsigned int rd_count, - const struct GNUNET_GNSRECORD_Data *rd) +collect_tickets_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) { struct RECLAIM_TICKETS_Iterator *iter = cls; for (int i = 0; i < rd_count; i++) - { - if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) - continue; - iter->cb(iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data); - return; - } - GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); + { + if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) + continue; + iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data); + return; + } + GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); } @@ -1479,13 +1486,13 @@ collect_tickets_cb(void *cls, * @param cls handle to the iteration */ static void -collect_tickets_finished_cb(void *cls) +collect_tickets_finished_cb (void *cls) { struct RECLAIM_TICKETS_Iterator *iter = cls; iter->ns_it = NULL; - iter->cb(iter->cb_cls, NULL); - cleanup_iter(iter); + iter->cb (iter->cb_cls, NULL); + cleanup_iter (iter); } @@ -1495,13 +1502,13 @@ collect_tickets_finished_cb(void *cls) * @param cls the iteration handle */ static void -collect_tickets_error_cb(void *cls) +collect_tickets_error_cb (void *cls) { struct RECLAIM_TICKETS_Iterator *iter = cls; iter->ns_it = NULL; - iter->cb(iter->cb_cls, NULL); - cleanup_iter(iter); + iter->cb (iter->cb_cls, NULL); + cleanup_iter (iter); } @@ -1511,9 +1518,9 @@ collect_tickets_error_cb(void *cls) * @param iter the iteration to continue */ void -RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter) +RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter) { - GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); + GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); } @@ -1523,10 +1530,10 @@ RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter) * @param iter iteration to cancel */ void -RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter) +RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) { - GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); - cleanup_iter(iter); + GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it); + cleanup_iter (iter); } @@ -1539,25 +1546,25 @@ RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter) * @return a handle to the iteration */ struct RECLAIM_TICKETS_Iterator * -RECLAIM_TICKETS_iteration_start( +RECLAIM_TICKETS_iteration_start ( const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls) { struct RECLAIM_TICKETS_Iterator *iter; - iter = GNUNET_new(struct RECLAIM_TICKETS_Iterator); + iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator); 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); + GNUNET_NAMESTORE_zone_iteration_start (nsh, + identity, + &collect_tickets_error_cb, + iter, + &collect_tickets_cb, + iter, + &collect_tickets_finished_cb, + iter); return iter; } @@ -1569,39 +1576,39 @@ RECLAIM_TICKETS_iteration_start( * @return GNUNET_SYSERR on error */ int -RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c) +RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) { // Get ticket expiration time (relative) from config if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_time(c, - "reclaim", - "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_CONFIGURATION_get_value_time (c, + "reclaim", + "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)); - } + } else - { - ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; - } + { + ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; + } // Connect to identity and namestore services - nsh = GNUNET_NAMESTORE_connect(c); + nsh = GNUNET_NAMESTORE_connect (c); if (NULL == nsh) - { - GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, - "error connecting to namestore"); - return GNUNET_SYSERR; - } - gns = GNUNET_GNS_connect(c); + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, + "error connecting to namestore"); + return GNUNET_SYSERR; + } + gns = GNUNET_GNS_connect (c); if (NULL == gns) - { - GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); - return GNUNET_SYSERR; - } - stats = GNUNET_STATISTICS_create("reclaim", c); + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); + return GNUNET_SYSERR; + } + stats = GNUNET_STATISTICS_create ("reclaim", c); return GNUNET_OK; } @@ -1611,17 +1618,17 @@ RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c) * FIXME: cancel all pending operations (gns, ns etc) */ void -RECLAIM_TICKETS_deinit(void) +RECLAIM_TICKETS_deinit (void) { if (NULL != nsh) - GNUNET_NAMESTORE_disconnect(nsh); + GNUNET_NAMESTORE_disconnect (nsh); nsh = NULL; if (NULL != gns) - GNUNET_GNS_disconnect(gns); + GNUNET_GNS_disconnect (gns); gns = NULL; if (NULL != stats) - { - GNUNET_STATISTICS_destroy(stats, GNUNET_NO); - stats = NULL; - } + { + GNUNET_STATISTICS_destroy (stats, GNUNET_NO); + stats = NULL; + } } diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h index 20a7a8e6f..c75cefc03 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.h +++ b/src/reclaim/gnunet-service-reclaim_tickets.h @@ -63,7 +63,8 @@ struct RECLAIM_TICKETS_RevokeHandle; /** * List of tickets */ -struct TicketRecordsEntry { +struct TicketRecordsEntry +{ /** * DLL */ @@ -161,10 +162,10 @@ typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success); * @return handle to the operation */ struct RECLAIM_TICKETS_RevokeHandle * -RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - RECLAIM_TICKETS_RevokeCallback cb, - void *cb_cls); +RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + RECLAIM_TICKETS_RevokeCallback cb, + void *cb_cls); /** @@ -173,7 +174,7 @@ RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, * @param rh handle to the operation */ void -RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh); +RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh); /** @@ -188,10 +189,10 @@ RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh); * @return handle to the operation */ struct RECLAIM_TICKETS_ConsumeHandle * -RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, - const struct GNUNET_RECLAIM_Ticket *ticket, - RECLAIM_TICKETS_ConsumeCallback cb, - void *cb_cls); +RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, + const struct GNUNET_RECLAIM_Ticket *ticket, + RECLAIM_TICKETS_ConsumeCallback cb, + void *cb_cls); /** @@ -200,7 +201,7 @@ RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, * @param cth the operation to cancel */ void -RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth); +RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth); /** @@ -215,11 +216,11 @@ RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth); * FIXME: Return handle?? */ void -RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, - const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, - const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, - RECLAIM_TICKETS_TicketResult cb, - void *cb_cls); +RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, + const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, + const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, + RECLAIM_TICKETS_TicketResult cb, + void *cb_cls); /** @@ -228,7 +229,7 @@ RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, * @param iter the iteration to continue */ void -RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter); +RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter); /** @@ -237,7 +238,7 @@ RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter); * @param iter iteration to cancel */ void -RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter); +RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter); /** @@ -249,7 +250,7 @@ RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter); * @return a handle to the iteration */ struct RECLAIM_TICKETS_Iterator * -RECLAIM_TICKETS_iteration_start( +RECLAIM_TICKETS_iteration_start ( const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls); @@ -262,7 +263,7 @@ RECLAIM_TICKETS_iteration_start( * @return GNUNET_SYSERR on error */ int -RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c); +RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c); /** @@ -270,6 +271,6 @@ RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c); * FIXME: cancel all pending operations (gns, ns etc) */ void -RECLAIM_TICKETS_deinit(void); +RECLAIM_TICKETS_deinit (void); #endif diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c index a98dec717..fa3901e43 100644 --- a/src/reclaim/json_reclaim.c +++ b/src/reclaim/json_reclaim.c @@ -41,7 +41,7 @@ * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ static int -parse_attr(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) +parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) { struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; const char *name_str = NULL; @@ -53,52 +53,52 @@ parse_attr(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) uint32_t type; size_t data_size; - GNUNET_assert(NULL != root); + GNUNET_assert (NULL != root); - if (!json_is_object(root)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Error json is not array nor object!\n"); - return GNUNET_SYSERR; - } + if (! json_is_object (root)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Error json is not array nor object!\n"); + return GNUNET_SYSERR; + } // 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); + 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); if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_str) || (NULL == type_str)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Error json object has a wrong format!\n"); - return GNUNET_SYSERR; - } - type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(type_str); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Error json object has a wrong format!\n"); + return GNUNET_SYSERR; + } + 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))) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n"); - return GNUNET_SYSERR; - } - attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new(name_str, type, data, data_size); - if ((NULL == id_str) || (0 == strlen(id_str))) + (GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, + val_str, + (void **) &data, + &data_size))) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n"); + return GNUNET_SYSERR; + } + attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size); + if ((NULL == id_str) || (0 == strlen (id_str))) attr->id = 0; else - GNUNET_STRINGS_string_to_data(id_str, - strlen(id_str), - &attr->id, - sizeof(uint64_t)); + GNUNET_STRINGS_string_to_data (id_str, + strlen (id_str), + &attr->id, + sizeof(uint64_t)); - *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **)spec->ptr = attr; + *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr = attr; return GNUNET_OK; } @@ -109,16 +109,16 @@ parse_attr(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) * @param[out] spec where to free the data */ static void -clean_attr(void *cls, struct GNUNET_JSON_Specification *spec) +clean_attr (void *cls, struct GNUNET_JSON_Specification *spec) { struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr; - attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **)spec->ptr; + attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr; if (NULL != *attr) - { - GNUNET_free(*attr); - *attr = NULL; - } + { + GNUNET_free (*attr); + *attr = NULL; + } } /** @@ -128,7 +128,7 @@ clean_attr(void *cls, struct GNUNET_JSON_Specification *spec) * @return JSON Specification */ struct GNUNET_JSON_Specification -GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr) +GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr) { struct GNUNET_JSON_Specification ret = { .parser = &parse_attr, .cleaner = &clean_attr, @@ -150,7 +150,7 @@ GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr) * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ static int -parse_ticket(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) +parse_ticket (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) { struct GNUNET_RECLAIM_Ticket *ticket; const char *rnd_str; @@ -158,63 +158,64 @@ parse_ticket(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) const char *id_str; int unpack_state; - GNUNET_assert(NULL != root); + GNUNET_assert (NULL != root); - if (!json_is_object(root)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Error json is not array nor object!\n"); - return GNUNET_SYSERR; - } + if (! json_is_object (root)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Error json is not array nor object!\n"); + return GNUNET_SYSERR; + } // interpret single ticket - unpack_state = json_unpack(root, - "{s:s, s:s, s:s!}", - "rnd", - &rnd_str, - "audience", - &aud_str, - "issuer", - &id_str); + unpack_state = json_unpack (root, + "{s:s, s:s, s:s!}", + "rnd", + &rnd_str, + "audience", + &aud_str, + "issuer", + &id_str); if (0 != unpack_state) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Error json object has a wrong format!\n"); - return GNUNET_SYSERR; - } - ticket = GNUNET_new(struct GNUNET_RECLAIM_Ticket); - if (GNUNET_OK != GNUNET_STRINGS_string_to_data(rnd_str, - strlen(rnd_str), - &ticket->rnd, - sizeof(uint64_t))) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Rnd invalid\n"); - GNUNET_free(ticket); - return GNUNET_SYSERR; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Error json object has a wrong format!\n"); + return GNUNET_SYSERR; + } + ticket = GNUNET_new (struct GNUNET_RECLAIM_Ticket); + if (GNUNET_OK != GNUNET_STRINGS_string_to_data (rnd_str, + strlen (rnd_str), + &ticket->rnd, + sizeof(uint64_t))) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Rnd invalid\n"); + GNUNET_free (ticket); + return GNUNET_SYSERR; + } if (GNUNET_OK != - GNUNET_STRINGS_string_to_data(id_str, - strlen(id_str), - &ticket->identity, - sizeof( - struct GNUNET_CRYPTO_EcdsaPublicKey))) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n"); - GNUNET_free(ticket); - return GNUNET_SYSERR; - } + GNUNET_STRINGS_string_to_data (id_str, + strlen (id_str), + &ticket->identity, + sizeof( + struct GNUNET_CRYPTO_EcdsaPublicKey))) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n"); + GNUNET_free (ticket); + return GNUNET_SYSERR; + } if (GNUNET_OK != - GNUNET_STRINGS_string_to_data(aud_str, - strlen(aud_str), - &ticket->audience, - sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n"); - GNUNET_free(ticket); - return GNUNET_SYSERR; - } + GNUNET_STRINGS_string_to_data (aud_str, + strlen (aud_str), + &ticket->audience, + sizeof(struct + GNUNET_CRYPTO_EcdsaPublicKey))) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n"); + GNUNET_free (ticket); + return GNUNET_SYSERR; + } - *(struct GNUNET_RECLAIM_Ticket **)spec->ptr = ticket; + *(struct GNUNET_RECLAIM_Ticket **) spec->ptr = ticket; return GNUNET_OK; } @@ -225,16 +226,16 @@ parse_ticket(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) * @param[out] spec where to free the data */ static void -clean_ticket(void *cls, struct GNUNET_JSON_Specification *spec) +clean_ticket (void *cls, struct GNUNET_JSON_Specification *spec) { struct GNUNET_RECLAIM_Ticket **ticket; - ticket = (struct GNUNET_RECLAIM_Ticket **)spec->ptr; + ticket = (struct GNUNET_RECLAIM_Ticket **) spec->ptr; if (NULL != *ticket) - { - GNUNET_free(*ticket); - *ticket = NULL; - } + { + GNUNET_free (*ticket); + *ticket = NULL; + } } /** @@ -244,7 +245,7 @@ clean_ticket(void *cls, struct GNUNET_JSON_Specification *spec) * @return JSON Specification */ struct GNUNET_JSON_Specification -GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket) +GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket) { struct GNUNET_JSON_Specification ret = { .parser = &parse_ticket, .cleaner = &clean_ticket, diff --git a/src/reclaim/json_reclaim.h b/src/reclaim/json_reclaim.h index 28db6937e..3fd26167f 100644 --- a/src/reclaim/json_reclaim.h +++ b/src/reclaim/json_reclaim.h @@ -36,7 +36,7 @@ * @return JSON Specification */ struct GNUNET_JSON_Specification -GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr); +GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr); /** * JSON Specification for Reclaim tickets. @@ -45,4 +45,4 @@ GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr); * @return JSON Specification */ struct GNUNET_JSON_Specification -GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket); +GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket); diff --git a/src/reclaim/oidc_helper.h b/src/reclaim/oidc_helper.h index 46bd804e7..fa3d7f2d9 100644 --- a/src/reclaim/oidc_helper.h +++ b/src/reclaim/oidc_helper.h @@ -49,12 +49,12 @@ * @return a new base64-encoded JWT string. */ char* -OIDC_id_token_new(const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, - const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, - const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, - const struct GNUNET_TIME_Relative *expiration_time, - const char *nonce, - const char *secret_key); +OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, + const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, + const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, + const struct GNUNET_TIME_Relative *expiration_time, + const char *nonce, + const char *secret_key); /** * Builds an OIDC authorization code including @@ -68,11 +68,11 @@ OIDC_id_token_new(const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, * @return a new authorization code (caller must free) */ char* -OIDC_build_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, - const struct GNUNET_RECLAIM_Ticket *ticket, - struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, - const char *nonce, - const char *code_challenge); +OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, + const struct GNUNET_RECLAIM_Ticket *ticket, + struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, + const char *nonce, + const char *code_challenge); /** * Parse reclaim ticket and nonce from @@ -88,12 +88,12 @@ OIDC_build_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, * @return GNUNET_OK if successful, else GNUNET_SYSERR */ int -OIDC_parse_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv, - const char *code, - const char *code_verifier, - struct GNUNET_RECLAIM_Ticket *ticket, - struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs, - char **nonce); +OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv, + const char *code, + const char *code_verifier, + struct GNUNET_RECLAIM_Ticket *ticket, + struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs, + char **nonce); /** * Build a token response for a token request @@ -105,15 +105,15 @@ OIDC_parse_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv, * @param token_response where to store the response */ void -OIDC_build_token_response(const char *access_token, - const char *id_token, - const struct GNUNET_TIME_Relative *expiration_time, - char **token_response); +OIDC_build_token_response (const char *access_token, + const char *id_token, + const struct GNUNET_TIME_Relative *expiration_time, + char **token_response); /** * Generate a new access token */ char* -OIDC_access_token_new(); +OIDC_access_token_new (); #endif diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c index 708142774..e4d1adfde 100644 --- a/src/reclaim/plugin_gnsrecord_reclaim.c +++ b/src/reclaim/plugin_gnsrecord_reclaim.c @@ -40,25 +40,25 @@ * @return NULL on error, otherwise human-readable representation of the value */ static char * -value_to_string(void *cls, uint32_t type, const void *data, size_t data_size) +value_to_string (void *cls, uint32_t type, const void *data, size_t data_size) { switch (type) - { - case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: - return GNUNET_STRINGS_data_to_string_alloc(data, data_size); - - case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: - case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: - return GNUNET_strndup(data, data_size); - - case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: - case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: - case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: - return GNUNET_STRINGS_data_to_string_alloc(data, data_size); - - default: - return NULL; - } + { + case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: + return GNUNET_STRINGS_data_to_string_alloc (data, data_size); + + case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: + case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: + return GNUNET_strndup (data, data_size); + + case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: + case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: + case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: + return GNUNET_STRINGS_data_to_string_alloc (data, data_size); + + default: + return NULL; + } } @@ -74,30 +74,30 @@ value_to_string(void *cls, uint32_t type, const void *data, size_t data_size) * @return #GNUNET_OK on success */ static int -string_to_value(void *cls, uint32_t type, const char *s, void **data, - size_t *data_size) +string_to_value (void *cls, uint32_t type, const char *s, void **data, + size_t *data_size) { if (NULL == s) return GNUNET_SYSERR; switch (type) - { - case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: - return GNUNET_STRINGS_string_to_data(s, strlen(s), *data, *data_size); - - case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: - case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: - *data = GNUNET_strdup(s); - *data_size = strlen(s); - return GNUNET_OK; - - case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: - case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: - case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: - return GNUNET_STRINGS_string_to_data(s, strlen(s), *data, *data_size); - - default: - return GNUNET_SYSERR; - } + { + case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: + return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size); + + case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: + case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: + *data = GNUNET_strdup (s); + *data_size = strlen (s); + return GNUNET_OK; + + case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: + case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: + case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: + return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size); + + default: + return GNUNET_SYSERR; + } } @@ -105,7 +105,8 @@ string_to_value(void *cls, uint32_t type, const char *s, void **data, * Mapping of record type numbers to human-readable * record type names. */ -static struct { +static struct +{ const char *name; uint32_t number; } name_map[] = { @@ -127,13 +128,13 @@ static struct { * @return corresponding number, UINT32_MAX on error */ static uint32_t -typename_to_number(void *cls, const char *dns_typename) +typename_to_number (void *cls, const char *dns_typename) { unsigned int i; i = 0; while ((NULL != name_map[i].name) && - (0 != strcasecmp(dns_typename, name_map[i].name))) + (0 != strcasecmp (dns_typename, name_map[i].name))) i++; return name_map[i].number; } @@ -147,7 +148,7 @@ typename_to_number(void *cls, const char *dns_typename) * @return corresponding typestring, NULL on error */ static const char * -number_to_typename(void *cls, uint32_t type) +number_to_typename (void *cls, uint32_t type) { unsigned int i; @@ -165,11 +166,11 @@ number_to_typename(void *cls, uint32_t type) * @return the exported block API */ void * -libgnunet_plugin_gnsrecord_reclaim_init(void *cls) +libgnunet_plugin_gnsrecord_reclaim_init (void *cls) { struct GNUNET_GNSRECORD_PluginFunctions *api; - api = GNUNET_new(struct GNUNET_GNSRECORD_PluginFunctions); + api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions); api->value_to_string = &value_to_string; api->string_to_value = &string_to_value; api->typename_to_number = &typename_to_number; @@ -185,11 +186,11 @@ libgnunet_plugin_gnsrecord_reclaim_init(void *cls) * @return NULL */ void * -libgnunet_plugin_gnsrecord_reclaim_done(void *cls) +libgnunet_plugin_gnsrecord_reclaim_done (void *cls) { struct GNUNET_GNSRECORD_PluginFunctions *api = cls; - GNUNET_free(api); + GNUNET_free (api); return NULL; } diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 176f46ffc..fd35059d7 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c @@ -86,14 +86,16 @@ static char *allow_methods; /** * @brief struct returned by the initialization function of the plugin */ -struct Plugin { +struct Plugin +{ const struct GNUNET_CONFIGURATION_Handle *cfg; }; /** * The ego list */ -struct EgoEntry { +struct EgoEntry +{ /** * DLL */ @@ -121,7 +123,8 @@ struct EgoEntry { }; -struct RequestHandle { +struct RequestHandle +{ /** * Ego list */ @@ -238,56 +241,56 @@ struct RequestHandle { * @param handle Handle to clean up */ static void -cleanup_handle(struct RequestHandle *handle) +cleanup_handle (struct RequestHandle *handle) { struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry; struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp; struct EgoEntry *ego_entry; struct EgoEntry *ego_tmp; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); if (NULL != handle->resp_object) - json_decref(handle->resp_object); + json_decref (handle->resp_object); if (NULL != handle->timeout_task) - GNUNET_SCHEDULER_cancel(handle->timeout_task); + GNUNET_SCHEDULER_cancel (handle->timeout_task); if (NULL != handle->identity_handle) - GNUNET_IDENTITY_disconnect(handle->identity_handle); + GNUNET_IDENTITY_disconnect (handle->identity_handle); if (NULL != handle->attr_it) - GNUNET_RECLAIM_get_attributes_stop(handle->attr_it); + GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); if (NULL != handle->ticket_it) - GNUNET_RECLAIM_ticket_iteration_stop(handle->ticket_it); + GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); if (NULL != handle->idp) - GNUNET_RECLAIM_disconnect(handle->idp); + GNUNET_RECLAIM_disconnect (handle->idp); if (NULL != handle->url) - GNUNET_free(handle->url); + GNUNET_free (handle->url); if (NULL != handle->emsg) - GNUNET_free(handle->emsg); + GNUNET_free (handle->emsg); if (NULL != handle->attr_list) + { + for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;) { - for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;) - { - claim_tmp = claim_entry; - claim_entry = claim_entry->next; - GNUNET_free(claim_tmp->claim); - GNUNET_free(claim_tmp); - } - GNUNET_free(handle->attr_list); + claim_tmp = claim_entry; + claim_entry = claim_entry->next; + GNUNET_free (claim_tmp->claim); + GNUNET_free (claim_tmp); } + GNUNET_free (handle->attr_list); + } for (ego_entry = handle->ego_head; NULL != ego_entry;) - { - ego_tmp = ego_entry; - ego_entry = ego_entry->next; - GNUNET_free(ego_tmp->identifier); - GNUNET_free(ego_tmp->keystring); - GNUNET_free(ego_tmp); - } - GNUNET_free(handle); + { + ego_tmp = ego_entry; + ego_entry = ego_entry->next; + GNUNET_free (ego_tmp->identifier); + GNUNET_free (ego_tmp->keystring); + GNUNET_free (ego_tmp); + } + GNUNET_free (handle); } static void -cleanup_handle_delayed(void *cls) +cleanup_handle_delayed (void *cls) { - cleanup_handle(cls); + cleanup_handle (cls); } @@ -297,22 +300,22 @@ cleanup_handle_delayed(void *cls) * @param cls the `struct RequestHandle` */ static void -do_error(void *cls) +do_error (void *cls) { struct RequestHandle *handle = cls; struct MHD_Response *resp; char *json_error; - GNUNET_asprintf(&json_error, "{ \"error\" : \"%s\" }", handle->emsg); + GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg); if (0 == handle->response_code) - { - handle->response_code = MHD_HTTP_BAD_REQUEST; - } - resp = GNUNET_REST_create_response(json_error); - MHD_add_response_header(resp, "Content-Type", "application/json"); - handle->proc(handle->proc_cls, resp, handle->response_code); - GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); - GNUNET_free(json_error); + { + handle->response_code = MHD_HTTP_BAD_REQUEST; + } + resp = GNUNET_REST_create_response (json_error); + MHD_add_response_header (resp, "Content-Type", "application/json"); + handle->proc (handle->proc_cls, resp, handle->response_code); + GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); + GNUNET_free (json_error); } @@ -322,37 +325,37 @@ do_error(void *cls) * @param cls the `struct RequestHandle` */ static void -do_timeout(void *cls) +do_timeout (void *cls) { struct RequestHandle *handle = cls; handle->timeout_task = NULL; - do_error(handle); + do_error (handle); } static void -collect_error_cb(void *cls) +collect_error_cb (void *cls) { struct RequestHandle *handle = cls; - do_error(handle); + do_error (handle); } static void -finished_cont(void *cls, int32_t success, const char *emsg) +finished_cont (void *cls, int32_t success, const char *emsg) { struct RequestHandle *handle = cls; struct MHD_Response *resp; - resp = GNUNET_REST_create_response(emsg); + resp = GNUNET_REST_create_response (emsg); if (GNUNET_OK != success) - { - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } - handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); - GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); + { + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); + GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); } @@ -362,29 +365,29 @@ finished_cont(void *cls, int32_t success, const char *emsg) * @param cls the request handle */ static void -return_response(void *cls) +return_response (void *cls) { char *result_str; struct RequestHandle *handle = cls; struct MHD_Response *resp; - result_str = json_dumps(handle->resp_object, 0); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); - resp = GNUNET_REST_create_response(result_str); - handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); - GNUNET_free(result_str); - cleanup_handle(handle); + result_str = json_dumps (handle->resp_object, 0); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); + resp = GNUNET_REST_create_response (result_str); + handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); + GNUNET_free (result_str); + cleanup_handle (handle); } static void -collect_finished_cb(void *cls) +collect_finished_cb (void *cls) { struct RequestHandle *handle = cls; // Done handle->attr_it = NULL; handle->ticket_it = NULL; - GNUNET_SCHEDULER_add_now(&return_response, handle); + GNUNET_SCHEDULER_add_now (&return_response, handle); } @@ -393,38 +396,38 @@ collect_finished_cb(void *cls) * */ static void -ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) +ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) { json_t *json_resource; struct RequestHandle *handle = cls; json_t *value; char *tmp; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n"); - tmp = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); - json_resource = json_object(); - GNUNET_free(tmp); - json_array_append(handle->resp_object, json_resource); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n"); + tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); + json_resource = json_object (); + GNUNET_free (tmp); + json_array_append (handle->resp_object, json_resource); tmp = - GNUNET_STRINGS_data_to_string_alloc(&ticket->identity, - sizeof(struct - GNUNET_CRYPTO_EcdsaPublicKey)); - value = json_string(tmp); - json_object_set_new(json_resource, "issuer", value); - GNUNET_free(tmp); + GNUNET_STRINGS_data_to_string_alloc (&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)); - value = json_string(tmp); - json_object_set_new(json_resource, "audience", value); - GNUNET_free(tmp); - tmp = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); - value = json_string(tmp); - json_object_set_new(json_resource, "rnd", value); - GNUNET_free(tmp); - GNUNET_RECLAIM_ticket_iteration_next(handle->ticket_it); + GNUNET_STRINGS_data_to_string_alloc (&ticket->audience, + sizeof(struct + GNUNET_CRYPTO_EcdsaPublicKey)); + value = json_string (tmp); + json_object_set_new (json_resource, "audience", value); + GNUNET_free (tmp); + tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t)); + value = json_string (tmp); + json_object_set_new (json_resource, "rnd", value); + GNUNET_free (tmp); + GNUNET_RECLAIM_ticket_iteration_next (handle->ticket_it); } @@ -436,57 +439,57 @@ ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) * @param cls the RequestHandle */ static void -list_tickets_cont(struct GNUNET_REST_RequestHandle *con_handle, - const char *url, - void *cls) +list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, + const char *url, + void *cls) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; struct RequestHandle *handle = cls; struct EgoEntry *ego_entry; char *identity; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Getting tickets for %s.\n", - handle->url); - if (strlen(GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen(handle->url)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } - identity = handle->url + strlen(GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Getting tickets for %s.\n", + handle->url); + if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1; for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) - if (0 == strcmp(identity, ego_entry->identifier)) + if (0 == strcmp (identity, ego_entry->identifier)) break; - handle->resp_object = json_array(); + handle->resp_object = json_array (); if (NULL == ego_entry) - { - // Done - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); - GNUNET_SCHEDULER_add_now(&return_response, handle); - return; - } - priv_key = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); - handle->idp = GNUNET_RECLAIM_connect(cfg); + { + // Done + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); + GNUNET_SCHEDULER_add_now (&return_response, handle); + return; + } + 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); + GNUNET_RECLAIM_ticket_iteration_start (handle->idp, + priv_key, + &collect_error_cb, + handle, + &ticket_collect, + handle, + &collect_finished_cb, + handle); } static void -add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, - const char *url, - void *cls) +add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, + const char *url, + void *cls) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; const char *identity; @@ -498,68 +501,68 @@ 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_log(GNUNET_ERROR_TYPE_DEBUG, - "Adding an attribute for %s.\n", - handle->url); - if (strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen(handle->url)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } - identity = handle->url + strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; + { GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end () }; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Adding an attribute for %s.\n", + handle->url); + if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) - if (0 == strcmp(identity, ego_entry->identifier)) + if (0 == strcmp (identity, ego_entry->identifier)) break; if (NULL == ego_entry) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity); - return; - } - identity_priv = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity); + return; + } + identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); if (0 >= handle->rest_handle->data_size) - { - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } + { + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } term_data[handle->rest_handle->data_size] = '\0'; - GNUNET_memcpy(term_data, - handle->rest_handle->data, - handle->rest_handle->data_size); - data_json = json_loads(term_data, JSON_DECODE_ANY, &err); - GNUNET_assert(GNUNET_OK == - GNUNET_JSON_parse(data_json, attrspec, NULL, NULL)); - json_decref(data_json); + GNUNET_memcpy (term_data, + handle->rest_handle->data, + handle->rest_handle->data_size); + data_json = json_loads (term_data, JSON_DECODE_ANY, &err); + GNUNET_assert (GNUNET_OK == + GNUNET_JSON_parse (data_json, attrspec, NULL, NULL)); + json_decref (data_json); if (NULL == attribute) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Unable to parse attribute from %s\n", - term_data); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unable to parse attribute from %s\n", + term_data); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } /** * New ID for attribute */ if (0 == attribute->id) attribute->id = - GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); - handle->idp = GNUNET_RECLAIM_connect(cfg); + 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); - GNUNET_JSON_parse_free(attrspec); + handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp, + identity_priv, + attribute, + &exp, + &finished_cont, + handle); + GNUNET_JSON_parse_free (attrspec); } @@ -568,9 +571,9 @@ add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, * */ static void -attr_collect(void *cls, - const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, - const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) +attr_collect (void *cls, + const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, + const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) { struct RequestHandle *handle = cls; json_t *attr_obj; @@ -579,28 +582,28 @@ attr_collect(void *cls, char *id_str; if ((NULL == attr->name) || (NULL == attr->data)) - { - GNUNET_RECLAIM_get_attributes_next(handle->attr_it); - return; - } - - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); - - tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, - attr->data, - attr->data_size); - - attr_obj = json_object(); - json_object_set_new(attr_obj, "value", json_string(tmp_value)); - json_object_set_new(attr_obj, "name", json_string(attr->name)); - type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(attr->type); - json_object_set_new(attr_obj, "type", json_string(type)); - id_str = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); - json_object_set_new(attr_obj, "id", json_string(id_str)); - json_array_append(handle->resp_object, attr_obj); - json_decref(attr_obj); - GNUNET_free(tmp_value); - GNUNET_RECLAIM_get_attributes_next(handle->attr_it); + { + GNUNET_RECLAIM_get_attributes_next (handle->attr_it); + return; + } + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); + + tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, + attr->data, + attr->data_size); + + attr_obj = json_object (); + json_object_set_new (attr_obj, "value", json_string (tmp_value)); + json_object_set_new (attr_obj, "name", json_string (attr->name)); + type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); + json_object_set_new (attr_obj, "type", json_string (type)); + id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + json_object_set_new (attr_obj, "id", json_string (id_str)); + json_array_append (handle->resp_object, attr_obj); + json_decref (attr_obj); + GNUNET_free (tmp_value); + GNUNET_RECLAIM_get_attributes_next (handle->attr_it); } @@ -612,67 +615,67 @@ attr_collect(void *cls, * @param cls the RequestHandle */ static void -list_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, - const char *url, - void *cls) +list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, + const char *url, + void *cls) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; struct RequestHandle *handle = cls; struct EgoEntry *ego_entry; char *identity; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Getting attributes for %s.\n", - handle->url); - if (strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen(handle->url)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } - identity = handle->url + strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Getting attributes for %s.\n", + handle->url); + if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) - if (0 == strcmp(identity, ego_entry->identifier)) + if (0 == strcmp (identity, ego_entry->identifier)) break; - handle->resp_object = json_array(); + handle->resp_object = json_array (); if (NULL == ego_entry) - { - // Done - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); - GNUNET_SCHEDULER_add_now(&return_response, handle); - return; - } - 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); + { + // Done + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); + GNUNET_SCHEDULER_add_now (&return_response, handle); + return; + } + 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); } static void -delete_finished_cb(void *cls, int32_t success, const char *emsg) +delete_finished_cb (void *cls, int32_t success, const char *emsg) { struct RequestHandle *handle = cls; struct MHD_Response *resp; - resp = GNUNET_REST_create_response(emsg); + resp = GNUNET_REST_create_response (emsg); if (GNUNET_OK != success) - { - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } - handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); - GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); + { + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); + GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); } @@ -684,9 +687,9 @@ delete_finished_cb(void *cls, int32_t success, const char *emsg) * @param cls the RequestHandle */ static void -delete_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, - const char *url, - void *cls) +delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, + const char *url, + void *cls) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; struct RequestHandle *handle = cls; @@ -696,56 +699,56 @@ delete_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, char *identity; char *id; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n"); - if (strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen(handle->url)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n"); + if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } identity_id_str = - strdup(handle->url + strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1); - identity = strtok(identity_id_str, "/"); - id = strtok(NULL, "/"); + strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1); + identity = strtok (identity_id_str, "/"); + id = strtok (NULL, "/"); if ((NULL == identity) || (NULL == id)) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n"); - GNUNET_free(identity_id_str); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n"); + GNUNET_free (identity_id_str); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) - if (0 == strcmp(identity, ego_entry->identifier)) + if (0 == strcmp (identity, ego_entry->identifier)) break; - handle->resp_object = json_array(); + handle->resp_object = json_array (); if (NULL == ego_entry) - { - // Done - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); - GNUNET_free(identity_id_str); - GNUNET_SCHEDULER_add_now(&return_response, handle); - return; - } - priv_key = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); - handle->idp = GNUNET_RECLAIM_connect(cfg); - memset(&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)); - GNUNET_STRINGS_string_to_data(id, strlen(id), &attr.id, sizeof(uint64_t)); + { + // Done + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); + GNUNET_free (identity_id_str); + GNUNET_SCHEDULER_add_now (&return_response, handle); + return; + } + priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); + handle->idp = GNUNET_RECLAIM_connect (cfg); + memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)); + 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); - GNUNET_free(identity_id_str); + handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp, + priv_key, + &attr, + &delete_finished_cb, + handle); + GNUNET_free (identity_id_str); } static void -revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, - const char *url, - void *cls) +revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, + const char *url, + void *cls) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; struct RequestHandle *handle = cls; @@ -756,101 +759,101 @@ 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); - return; - } + { + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } term_data[handle->rest_handle->data_size] = '\0'; - GNUNET_memcpy(term_data, - handle->rest_handle->data, - handle->rest_handle->data_size); - data_json = json_loads(term_data, JSON_DECODE_ANY, &err); + GNUNET_memcpy (term_data, + handle->rest_handle->data, + handle->rest_handle->data_size); + data_json = json_loads (term_data, JSON_DECODE_ANY, &err); if ((NULL == data_json) || - (GNUNET_OK != GNUNET_JSON_parse(data_json, tktspec, NULL, NULL))) - { - handle->emsg = GNUNET_strdup("Not a ticket!\n"); - GNUNET_SCHEDULER_add_now(&do_error, handle); - GNUNET_JSON_parse_free(tktspec); - if (NULL != data_json) - json_decref(data_json); - return; - } - json_decref(data_json); + (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))) + { + handle->emsg = GNUNET_strdup ("Not a ticket!\n"); + GNUNET_SCHEDULER_add_now (&do_error, handle); + GNUNET_JSON_parse_free (tktspec); + if (NULL != data_json) + json_decref (data_json); + return; + } + json_decref (data_json); if (NULL == ticket) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Unable to parse ticket from %s\n", - term_data); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unable to parse ticket from %s\n", + term_data); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) - { - GNUNET_IDENTITY_ego_get_public_key(ego_entry->ego, &tmp_pk); - if (0 == memcmp(&ticket->identity, - &tmp_pk, - sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) - break; - } + { + GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk); + if (0 == memcmp (&ticket->identity, + &tmp_pk, + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) + break; + } if (NULL == ego_entry) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); - GNUNET_JSON_parse_free(tktspec); - return; - } - identity_priv = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); - - handle->idp = GNUNET_RECLAIM_connect(cfg); - handle->idp_op = GNUNET_RECLAIM_ticket_revoke(handle->idp, - identity_priv, - ticket, - &finished_cont, - handle); - GNUNET_JSON_parse_free(tktspec); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); + GNUNET_JSON_parse_free (tktspec); + return; + } + identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); + + handle->idp = GNUNET_RECLAIM_connect (cfg); + handle->idp_op = GNUNET_RECLAIM_ticket_revoke (handle->idp, + identity_priv, + ticket, + &finished_cont, + handle); + GNUNET_JSON_parse_free (tktspec); } static void -consume_cont(void *cls, - const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, - const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) +consume_cont (void *cls, + const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, + const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) { struct RequestHandle *handle = cls; char *val_str; json_t *value; if (NULL == identity) - { - GNUNET_SCHEDULER_add_now(&return_response, handle); - return; - } - - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); - val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, - attr->data, - attr->data_size); + { + GNUNET_SCHEDULER_add_now (&return_response, handle); + return; + } + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); + val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, + attr->data, + attr->data_size); if (NULL == val_str) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Failed to parse value for: %s\n", - attr->name); - return; - } - value = json_string(val_str); - json_object_set_new(handle->resp_object, attr->name, value); - json_decref(value); - GNUNET_free(val_str); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to parse value for: %s\n", + attr->name); + return; + } + value = json_string (val_str); + json_object_set_new (handle->resp_object, attr->name, value); + json_decref (value); + GNUNET_free (val_str); } static void -consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, - const char *url, - void *cls) +consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, + const char *url, + void *cls) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; struct RequestHandle *handle = cls; @@ -861,59 +864,59 @@ 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); - return; - } + { + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } term_data[handle->rest_handle->data_size] = '\0'; - GNUNET_memcpy(term_data, - handle->rest_handle->data, - handle->rest_handle->data_size); - data_json = json_loads(term_data, JSON_DECODE_ANY, &err); + GNUNET_memcpy (term_data, + handle->rest_handle->data, + handle->rest_handle->data_size); + data_json = json_loads (term_data, JSON_DECODE_ANY, &err); if (NULL == data_json) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Unable to parse JSON Object from %s\n", - term_data); - GNUNET_SCHEDULER_add_now(&do_error, handle); - return; - } - if (GNUNET_OK != GNUNET_JSON_parse(data_json, tktspec, NULL, NULL)) - { - handle->emsg = GNUNET_strdup("Not a ticket!\n"); - GNUNET_SCHEDULER_add_now(&do_error, handle); - GNUNET_JSON_parse_free(tktspec); - json_decref(data_json); - return; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unable to parse JSON Object from %s\n", + term_data); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)) + { + handle->emsg = GNUNET_strdup ("Not a ticket!\n"); + GNUNET_SCHEDULER_add_now (&do_error, handle); + GNUNET_JSON_parse_free (tktspec); + json_decref (data_json); + return; + } for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) - { - GNUNET_IDENTITY_ego_get_public_key(ego_entry->ego, &tmp_pk); - if (0 == memcmp(&ticket->audience, - &tmp_pk, - sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) - break; - } + { + GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk); + if (0 == memcmp (&ticket->audience, + &tmp_pk, + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) + break; + } if (NULL == ego_entry) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); - GNUNET_JSON_parse_free(tktspec); - return; - } - identity_priv = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); - 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); - GNUNET_JSON_parse_free(tktspec); + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); + GNUNET_JSON_parse_free (tktspec); + return; + } + identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); + 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); + GNUNET_JSON_parse_free (tktspec); } @@ -925,18 +928,18 @@ consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, * @param cls the RequestHandle */ static void -options_cont(struct GNUNET_REST_RequestHandle *con_handle, - const char *url, - void *cls) +options_cont (struct GNUNET_REST_RequestHandle *con_handle, + const char *url, + void *cls) { struct MHD_Response *resp; struct RequestHandle *handle = cls; // For now, independent of path return all options - resp = GNUNET_REST_create_response(NULL); - MHD_add_response_header(resp, "Access-Control-Allow-Methods", allow_methods); - handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); - cleanup_handle(handle); + resp = GNUNET_REST_create_response (NULL); + MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); + handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); + cleanup_handle (handle); return; } @@ -946,7 +949,7 @@ options_cont(struct GNUNET_REST_RequestHandle *con_handle, * @param handle the request handle */ static void -init_cont(struct RequestHandle *handle) +init_cont (struct RequestHandle *handle) { struct GNUNET_REST_RequestHandlerError err; static const struct GNUNET_REST_RequestHandler handlers[] = @@ -954,29 +957,29 @@ init_cont(struct RequestHandle *handle) GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &list_attribute_cont }, { MHD_HTTP_METHOD_POST, - GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, - &add_attribute_cont }, + GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, + &add_attribute_cont }, { MHD_HTTP_METHOD_DELETE, - GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, - &delete_attribute_cont }, + GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, + &delete_attribute_cont }, { MHD_HTTP_METHOD_GET, - GNUNET_REST_API_NS_IDENTITY_TICKETS, - &list_tickets_cont }, + GNUNET_REST_API_NS_IDENTITY_TICKETS, + &list_tickets_cont }, { MHD_HTTP_METHOD_POST, - GNUNET_REST_API_NS_IDENTITY_REVOKE, - &revoke_ticket_cont }, + GNUNET_REST_API_NS_IDENTITY_REVOKE, + &revoke_ticket_cont }, { MHD_HTTP_METHOD_POST, - GNUNET_REST_API_NS_IDENTITY_CONSUME, - &consume_ticket_cont }, + 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)) - { - handle->response_code = err.error_code; - GNUNET_SCHEDULER_add_now(&do_error, handle); - } + GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) + { + handle->response_code = err.error_code; + GNUNET_SCHEDULER_add_now (&do_error, handle); + } } /** @@ -1013,40 +1016,40 @@ init_cont(struct RequestHandle *handle) * must thus no longer be used */ static void -list_ego(void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ctx, - const char *identifier) +list_ego (void *cls, + struct GNUNET_IDENTITY_Ego *ego, + void **ctx, + const char *identifier) { struct RequestHandle *handle = cls; struct EgoEntry *ego_entry; struct GNUNET_CRYPTO_EcdsaPublicKey pk; if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state)) - { - handle->state = ID_REST_STATE_POST_INIT; - init_cont(handle); - return; - } + { + handle->state = ID_REST_STATE_POST_INIT; + init_cont (handle); + return; + } if (ID_REST_STATE_INIT == handle->state) - { - ego_entry = GNUNET_new(struct EgoEntry); - GNUNET_IDENTITY_ego_get_public_key(ego, &pk); - ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string(&pk); - ego_entry->ego = ego; - ego_entry->identifier = GNUNET_strdup(identifier); - GNUNET_CONTAINER_DLL_insert_tail(handle->ego_head, - handle->ego_tail, - ego_entry); - } + { + ego_entry = GNUNET_new (struct EgoEntry); + GNUNET_IDENTITY_ego_get_public_key (ego, &pk); + ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); + ego_entry->ego = ego; + ego_entry->identifier = GNUNET_strdup (identifier); + GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head, + handle->ego_tail, + ego_entry); + } } static void -rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, - GNUNET_REST_ResultProcessor proc, - void *proc_cls) +rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, + GNUNET_REST_ResultProcessor proc, + void *proc_cls) { - struct RequestHandle *handle = GNUNET_new(struct RequestHandle); + struct RequestHandle *handle = GNUNET_new (struct RequestHandle); handle->response_code = 0; handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; @@ -1055,14 +1058,14 @@ rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, handle->state = ID_REST_STATE_INIT; handle->rest_handle = rest_handle; - handle->url = GNUNET_strdup(rest_handle->url); - if (handle->url[strlen(handle->url) - 1] == '/') - 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->url = GNUNET_strdup (rest_handle->url); + if (handle->url[strlen (handle->url) - 1] == '/') + 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->timeout_task = - GNUNET_SCHEDULER_add_delayed(handle->timeout, &do_timeout, handle); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); + GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); } /** @@ -1072,7 +1075,7 @@ rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, * @return NULL on error, otherwise the plugin context */ void * -libgnunet_plugin_rest_reclaim_init(void *cls) +libgnunet_plugin_rest_reclaim_init (void *cls) { static struct Plugin plugin; struct GNUNET_REST_Plugin *api; @@ -1080,22 +1083,22 @@ libgnunet_plugin_rest_reclaim_init(void *cls) cfg = cls; if (NULL != plugin.cfg) return NULL; /* can only initialize once! */ - memset(&plugin, 0, sizeof(struct Plugin)); + memset (&plugin, 0, sizeof(struct Plugin)); plugin.cfg = cfg; - api = GNUNET_new(struct GNUNET_REST_Plugin); + api = GNUNET_new (struct GNUNET_REST_Plugin); api->cls = &plugin; api->name = GNUNET_REST_API_NS_RECLAIM; api->process_request = &rest_identity_process_request; - GNUNET_asprintf(&allow_methods, - "%s, %s, %s, %s, %s", - MHD_HTTP_METHOD_GET, - MHD_HTTP_METHOD_POST, - MHD_HTTP_METHOD_PUT, - MHD_HTTP_METHOD_DELETE, - MHD_HTTP_METHOD_OPTIONS); - - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - _("Identity Provider REST API initialized\n")); + GNUNET_asprintf (&allow_methods, + "%s, %s, %s, %s, %s", + MHD_HTTP_METHOD_GET, + MHD_HTTP_METHOD_POST, + MHD_HTTP_METHOD_PUT, + MHD_HTTP_METHOD_DELETE, + MHD_HTTP_METHOD_OPTIONS); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _ ("Identity Provider REST API initialized\n")); return api; } @@ -1107,17 +1110,17 @@ libgnunet_plugin_rest_reclaim_init(void *cls) * @return always NULL */ void * -libgnunet_plugin_rest_reclaim_done(void *cls) +libgnunet_plugin_rest_reclaim_done (void *cls) { struct GNUNET_REST_Plugin *api = cls; struct Plugin *plugin = api->cls; plugin->cfg = NULL; - GNUNET_free_non_null(allow_methods); - GNUNET_free(api); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Identity Provider REST plugin is finished\n"); + GNUNET_free_non_null (allow_methods); + GNUNET_free (api); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Identity Provider REST plugin is finished\n"); return NULL; } diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h index 87e343b51..8e731812e 100644 --- a/src/reclaim/reclaim.h +++ b/src/reclaim/reclaim.h @@ -37,7 +37,8 @@ GNUNET_NETWORK_STRUCT_BEGIN /** * Use to store an identity attribute */ -struct AttributeStoreMessage { +struct AttributeStoreMessage +{ /** * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT */ @@ -70,7 +71,8 @@ struct AttributeStoreMessage { /** * Use to delete an identity attribute */ -struct AttributeDeleteMessage { +struct AttributeDeleteMessage +{ /** * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT */ @@ -98,7 +100,8 @@ struct AttributeDeleteMessage { /** * Attribute store/delete response message */ -struct SuccessResultMessage { +struct SuccessResultMessage +{ /** * Message header */ @@ -118,7 +121,8 @@ struct SuccessResultMessage { /** * Attribute is returned from the idp. */ -struct AttributeResultMessage { +struct AttributeResultMessage +{ /** * Message header */ @@ -153,7 +157,8 @@ struct AttributeResultMessage { /** * Start a attribute iteration for the given identity */ -struct AttributeIterationStartMessage { +struct AttributeIterationStartMessage +{ /** * Message */ @@ -174,7 +179,8 @@ struct AttributeIterationStartMessage { /** * Ask for next result of attribute iteration for the given operation */ -struct AttributeIterationNextMessage { +struct AttributeIterationNextMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT */ @@ -190,7 +196,8 @@ struct AttributeIterationNextMessage { /** * Stop attribute iteration for the given operation */ -struct AttributeIterationStopMessage { +struct AttributeIterationStopMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP */ @@ -205,7 +212,8 @@ struct AttributeIterationStopMessage { /** * Start a ticket iteration for the given identity */ -struct TicketIterationStartMessage { +struct TicketIterationStartMessage +{ /** * Message */ @@ -226,7 +234,8 @@ struct TicketIterationStartMessage { /** * Ask for next result of ticket iteration for the given operation */ -struct TicketIterationNextMessage { +struct TicketIterationNextMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT */ @@ -242,7 +251,8 @@ struct TicketIterationNextMessage { /** * Stop ticket iteration for the given operation */ -struct TicketIterationStopMessage { +struct TicketIterationStopMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP */ @@ -258,7 +268,8 @@ struct TicketIterationStopMessage { /** * Ticket issue message */ -struct IssueTicketMessage { +struct IssueTicketMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET */ @@ -290,7 +301,8 @@ struct IssueTicketMessage { /** * Ticket revoke message */ -struct RevokeTicketMessage { +struct RevokeTicketMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET */ @@ -320,7 +332,8 @@ struct RevokeTicketMessage { /** * Ticket revoke message */ -struct RevokeTicketResultMessage { +struct RevokeTicketResultMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT */ @@ -341,7 +354,8 @@ struct RevokeTicketResultMessage { /** * Ticket result message */ -struct TicketResultMessage { +struct TicketResultMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT */ @@ -361,7 +375,8 @@ struct TicketResultMessage { /** * Ticket consume message */ -struct ConsumeTicketMessage { +struct ConsumeTicketMessage +{ /** * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET */ @@ -386,7 +401,8 @@ struct ConsumeTicketMessage { /** * Attribute list is returned from the idp. */ -struct ConsumeTicketResultMessage { +struct ConsumeTicketResultMessage +{ /** * Message header */ diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index a8790cd8e..3e03d973b 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c @@ -32,13 +32,14 @@ #include "gnunet_reclaim_service.h" #include "reclaim.h" -#define LOG(kind, ...) GNUNET_log_from(kind, "reclaim-api", __VA_ARGS__) +#define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__) /** * Handle for an operation with the service. */ -struct GNUNET_RECLAIM_Operation { +struct GNUNET_RECLAIM_Operation +{ /** * Main handle. */ @@ -100,7 +101,8 @@ struct GNUNET_RECLAIM_Operation { /** * Handle for a ticket iterator operation */ -struct GNUNET_RECLAIM_TicketIterator { +struct GNUNET_RECLAIM_TicketIterator +{ /** * Kept in a DLL. */ @@ -162,7 +164,8 @@ struct GNUNET_RECLAIM_TicketIterator { /** * Handle for a attribute iterator operation */ -struct GNUNET_RECLAIM_AttributeIterator { +struct GNUNET_RECLAIM_AttributeIterator +{ /** * Kept in a DLL. */ @@ -229,7 +232,8 @@ struct GNUNET_RECLAIM_AttributeIterator { /** * Handle to the service. */ -struct GNUNET_RECLAIM_Handle { +struct GNUNET_RECLAIM_Handle +{ /** * Configuration to use. */ @@ -313,7 +317,7 @@ struct GNUNET_RECLAIM_Handle { * @param h handle to the reclaim service. */ static void -reconnect(struct GNUNET_RECLAIM_Handle *h); +reconnect (struct GNUNET_RECLAIM_Handle *h); /** @@ -322,12 +326,12 @@ reconnect(struct GNUNET_RECLAIM_Handle *h); * @param cls the handle */ static void -reconnect_task(void *cls) +reconnect_task (void *cls) { struct GNUNET_RECLAIM_Handle *handle = cls; handle->reconnect_task = NULL; - reconnect(handle); + reconnect (handle); } @@ -337,16 +341,16 @@ reconnect_task(void *cls) * @param handle our service */ static void -force_reconnect(struct GNUNET_RECLAIM_Handle *handle) +force_reconnect (struct GNUNET_RECLAIM_Handle *handle) { - GNUNET_MQ_destroy(handle->mq); + 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); + GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, + &reconnect_task, + handle); } @@ -356,14 +360,14 @@ force_reconnect(struct GNUNET_RECLAIM_Handle *handle) * @param it entry to free */ static void -free_it(struct GNUNET_RECLAIM_AttributeIterator *it) +free_it (struct GNUNET_RECLAIM_AttributeIterator *it) { struct GNUNET_RECLAIM_Handle *h = it->h; - GNUNET_CONTAINER_DLL_remove(h->it_head, h->it_tail, it); + GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it); if (NULL != it->env) - GNUNET_MQ_discard(it->env); - GNUNET_free(it); + GNUNET_MQ_discard (it->env); + GNUNET_free (it); } /** @@ -372,13 +376,13 @@ free_it(struct GNUNET_RECLAIM_AttributeIterator *it) * @param op the operation to free */ static void -free_op(struct GNUNET_RECLAIM_Operation *op) +free_op (struct GNUNET_RECLAIM_Operation *op) { if (NULL == op) return; if (NULL != op->env) - GNUNET_MQ_discard(op->env); - GNUNET_free(op); + GNUNET_MQ_discard (op->env); + GNUNET_free (op); } @@ -391,11 +395,11 @@ free_op(struct GNUNET_RECLAIM_Operation *op) * @param error error code */ static void -mq_error_handler(void *cls, enum GNUNET_MQ_Error error) +mq_error_handler (void *cls, enum GNUNET_MQ_Error error) { struct GNUNET_RECLAIM_Handle *handle = cls; - force_reconnect(handle); + force_reconnect (handle); } @@ -407,11 +411,11 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error) * @param msg the message we received */ static void -handle_success_response(void *cls, const struct SuccessResultMessage *msg) +handle_success_response (void *cls, const struct SuccessResultMessage *msg) { struct GNUNET_RECLAIM_Handle *h = cls; struct GNUNET_RECLAIM_Operation *op; - uint32_t r_id = ntohl(msg->id); + uint32_t r_id = ntohl (msg->id); int res; const char *emsg; @@ -421,20 +425,20 @@ handle_success_response(void *cls, const struct SuccessResultMessage *msg) if (NULL == op) return; - res = ntohl(msg->op_result); - LOG(GNUNET_ERROR_TYPE_DEBUG, - "Received SUCCESS_RESPONSE with result %d\n", - res); + res = ntohl (msg->op_result); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received SUCCESS_RESPONSE with result %d\n", + res); /* TODO: add actual error message to response... */ if (GNUNET_SYSERR == res) - emsg = _("failed to store record\n"); + emsg = _ ("failed to store record\n"); else emsg = NULL; if (NULL != op->as_cb) - op->as_cb(op->cls, res, emsg); - GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); - free_op(op); + op->as_cb (op->cls, res, emsg); + GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); + free_op (op); } @@ -447,19 +451,19 @@ handle_success_response(void *cls, const struct SuccessResultMessage *msg) * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ static int -check_consume_ticket_result(void *cls, - const struct ConsumeTicketResultMessage *msg) +check_consume_ticket_result (void *cls, + const struct ConsumeTicketResultMessage *msg) { size_t msg_len; size_t attrs_len; - msg_len = ntohs(msg->header.size); - attrs_len = ntohs(msg->attrs_len); + msg_len = ntohs (msg->header.size); + attrs_len = ntohs (msg->attrs_len); if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -472,16 +476,16 @@ check_consume_ticket_result(void *cls, * @param msg the message we received */ static void -handle_consume_ticket_result(void *cls, - const struct ConsumeTicketResultMessage *msg) +handle_consume_ticket_result (void *cls, + const struct ConsumeTicketResultMessage *msg) { struct GNUNET_RECLAIM_Handle *h = cls; struct GNUNET_RECLAIM_Operation *op; size_t attrs_len; - uint32_t r_id = ntohl(msg->id); + uint32_t r_id = ntohl (msg->id); - attrs_len = ntohs(msg->attrs_len); - LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); + attrs_len = ntohs (msg->attrs_len); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); for (op = h->op_head; NULL != op; op = op->next) @@ -494,28 +498,28 @@ 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) { - if (NULL == attrs) - { - op->ar_cb(op->cls, &msg->identity, NULL); - } - else - { - for (le = attrs->list_head; NULL != le; le = le->next) - op->ar_cb(op->cls, &msg->identity, le->claim); - GNUNET_RECLAIM_ATTRIBUTE_list_destroy(attrs); - attrs = NULL; - } - op->ar_cb(op->cls, NULL, NULL); + op->ar_cb (op->cls, &msg->identity, NULL); } - GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); - free_op(op); - GNUNET_free_non_null(attrs); + else + { + for (le = attrs->list_head; NULL != le; le = le->next) + op->ar_cb (op->cls, &msg->identity, le->claim); + GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); + attrs = NULL; + } + op->ar_cb (op->cls, NULL, NULL); + } + GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); + free_op (op); + GNUNET_free_non_null (attrs); return; } - GNUNET_assert(0); + GNUNET_assert (0); } @@ -528,18 +532,18 @@ handle_consume_ticket_result(void *cls, * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ static int -check_attribute_result(void *cls, const struct AttributeResultMessage *msg) +check_attribute_result (void *cls, const struct AttributeResultMessage *msg) { size_t msg_len; size_t attr_len; - msg_len = ntohs(msg->header.size); - attr_len = ntohs(msg->attr_len); + msg_len = ntohs (msg->header.size); + attr_len = ntohs (msg->attr_len); if (msg_len != sizeof(struct AttributeResultMessage) + attr_len) - { - GNUNET_break(0); - return GNUNET_SYSERR; - } + { + GNUNET_break (0); + return GNUNET_SYSERR; + } return GNUNET_OK; } @@ -552,17 +556,17 @@ check_attribute_result(void *cls, const struct AttributeResultMessage *msg) * @param msg the message we received */ static void -handle_attribute_result(void *cls, const struct AttributeResultMessage *msg) +handle_attribute_result (void *cls, const struct AttributeResultMessage *msg) { static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; struct GNUNET_RECLAIM_Handle *h = cls; struct GNUNET_RECLAIM_AttributeIterator *it; struct GNUNET_RECLAIM_Operation *op; size_t attr_len; - uint32_t r_id = ntohl(msg->id); + uint32_t r_id = ntohl (msg->id); - attr_len = ntohs(msg->attr_len); - LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); + attr_len = ntohs (msg->attr_len); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); for (it = h->it_head; NULL != it; it = it->next) @@ -575,47 +579,47 @@ handle_attribute_result(void *cls, const struct AttributeResultMessage *msg) return; if ((0 == - (memcmp(&msg->identity, &identity_dummy, sizeof(identity_dummy))))) + (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy))))) + { + if ((NULL == it) && (NULL == op)) { - if ((NULL == it) && (NULL == op)) - { - GNUNET_break(0); - force_reconnect(h); - return; - } - if (NULL != it) - { - if (NULL != it->finish_cb) - it->finish_cb(it->finish_cb_cls); - free_it(it); - } - if (NULL != op) - { - if (NULL != op->ar_cb) - op->ar_cb(op->cls, NULL, NULL); - GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); - free_op(op); - } + GNUNET_break (0); + force_reconnect (h); return; } + if (NULL != it) + { + if (NULL != it->finish_cb) + it->finish_cb (it->finish_cb_cls); + free_it (it); + } + if (NULL != op) + { + if (NULL != op->ar_cb) + op->ar_cb (op->cls, NULL, NULL); + GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); + free_op (op); + } + return; + } { struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; - attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&msg[1], attr_len); + attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len); if (NULL != it) - { - if (NULL != it->proc) - it->proc(it->proc_cls, &msg->identity, attr); - } + { + if (NULL != it->proc) + it->proc (it->proc_cls, &msg->identity, attr); + } else if (NULL != op) - { - if (NULL != op->ar_cb) - op->ar_cb(op->cls, &msg->identity, attr); - } - GNUNET_free(attr); + { + if (NULL != op->ar_cb) + op->ar_cb (op->cls, &msg->identity, attr); + } + GNUNET_free (attr); return; } - GNUNET_assert(0); + GNUNET_assert (0); } @@ -627,12 +631,12 @@ handle_attribute_result(void *cls, const struct AttributeResultMessage *msg) * @param msg the message we received */ static void -handle_ticket_result(void *cls, const struct TicketResultMessage *msg) +handle_ticket_result (void *cls, const struct TicketResultMessage *msg) { struct GNUNET_RECLAIM_Handle *handle = cls; struct GNUNET_RECLAIM_Operation *op; struct GNUNET_RECLAIM_TicketIterator *it; - uint32_t r_id = ntohl(msg->id); + uint32_t r_id = ntohl (msg->id); static const struct GNUNET_RECLAIM_Ticket ticket; for (op = handle->op_head; NULL != op; op = op->next) @@ -644,41 +648,41 @@ handle_ticket_result(void *cls, const struct TicketResultMessage *msg) if ((NULL == op) && (NULL == it)) return; if (NULL != op) + { + GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); + if (0 == + memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) { - GNUNET_CONTAINER_DLL_remove(handle->op_head, handle->op_tail, op); - if (0 == - memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) - { - if (NULL != op->tr_cb) - op->tr_cb(op->cls, NULL); - } - else - { - if (NULL != op->tr_cb) - op->tr_cb(op->cls, &msg->ticket); - } - free_op(op); - return; + if (NULL != op->tr_cb) + op->tr_cb (op->cls, NULL); } + else + { + if (NULL != op->tr_cb) + op->tr_cb (op->cls, &msg->ticket); + } + free_op (op); + return; + } else if (NULL != it) + { + if (0 == + memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) { - if (0 == - memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) - { - GNUNET_CONTAINER_DLL_remove(handle->ticket_it_head, - handle->ticket_it_tail, - it); - it->finish_cb(it->finish_cb_cls); - GNUNET_free(it); - } - else - { - if (NULL != it->tr_cb) - it->tr_cb(it->cls, &msg->ticket); - } - return; + GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head, + handle->ticket_it_tail, + it); + it->finish_cb (it->finish_cb_cls); + GNUNET_free (it); + } + else + { + if (NULL != it->tr_cb) + it->tr_cb (it->cls, &msg->ticket); } - GNUNET_break(0); + return; + } + GNUNET_break (0); } @@ -690,15 +694,15 @@ handle_ticket_result(void *cls, const struct TicketResultMessage *msg) * @param msg the message we received */ static void -handle_revoke_ticket_result(void *cls, - const struct RevokeTicketResultMessage *msg) +handle_revoke_ticket_result (void *cls, + const struct RevokeTicketResultMessage *msg) { struct GNUNET_RECLAIM_Handle *h = cls; struct GNUNET_RECLAIM_Operation *op; - uint32_t r_id = ntohl(msg->id); + uint32_t r_id = ntohl (msg->id); int32_t success; - LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n"); for (op = h->op_head; NULL != op; op = op->next) @@ -706,17 +710,17 @@ handle_revoke_ticket_result(void *cls, break; if (NULL == op) return; - success = ntohl(msg->success); + success = ntohl (msg->success); { if (NULL != op->rvk_cb) - { - op->rvk_cb(op->cls, success, NULL); - } - GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); - free_op(op); + { + op->rvk_cb (op->cls, success, NULL); + } + GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); + free_op (op); return; } - GNUNET_assert(0); + GNUNET_assert (0); } @@ -726,41 +730,41 @@ handle_revoke_ticket_result(void *cls, * @param h handle to the reclaim service. */ static void -reconnect(struct GNUNET_RECLAIM_Handle *h) +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_fixed_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_fixed_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"); + 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) - GNUNET_MQ_send_copy(h->mq, op->env); + GNUNET_MQ_send_copy (h->mq, op->env); } @@ -771,18 +775,18 @@ reconnect(struct GNUNET_RECLAIM_Handle *h) * @return handle to use */ struct GNUNET_RECLAIM_Handle * -GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) +GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_RECLAIM_Handle *h; - h = GNUNET_new(struct GNUNET_RECLAIM_Handle); + h = GNUNET_new (struct GNUNET_RECLAIM_Handle); h->cfg = cfg; - reconnect(h); + reconnect (h); if (NULL == h->mq) - { - GNUNET_free(h); - return NULL; - } + { + GNUNET_free (h); + return NULL; + } return h; } @@ -796,12 +800,12 @@ GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) * @param op operation to cancel */ void -GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op) +GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op) { struct GNUNET_RECLAIM_Handle *h = op->h; - GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); - free_op(op); + GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); + free_op (op); } @@ -811,21 +815,21 @@ GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op) * @param h handle to destroy */ void -GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h) +GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h) { - GNUNET_assert(NULL != h); + GNUNET_assert (NULL != h); if (NULL != h->mq) - { - GNUNET_MQ_destroy(h->mq); - h->mq = NULL; - } + { + GNUNET_MQ_destroy (h->mq); + h->mq = NULL; + } if (NULL != h->reconnect_task) - { - GNUNET_SCHEDULER_cancel(h->reconnect_task); - h->reconnect_task = NULL; - } - GNUNET_assert(NULL == h->op_head); - GNUNET_free(h); + { + GNUNET_SCHEDULER_cancel (h->reconnect_task); + h->reconnect_task = NULL; + } + GNUNET_assert (NULL == h->op_head); + GNUNET_free (h); } /** @@ -841,7 +845,7 @@ GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h) * @return handle to abort the request */ struct GNUNET_RECLAIM_Operation * -GNUNET_RECLAIM_attribute_store( +GNUNET_RECLAIM_attribute_store ( struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, @@ -853,25 +857,25 @@ GNUNET_RECLAIM_attribute_store( struct AttributeStoreMessage *sam; size_t attr_len; - op = GNUNET_new(struct GNUNET_RECLAIM_Operation); + op = GNUNET_new (struct GNUNET_RECLAIM_Operation); op->h = h; op->as_cb = cont; op->cls = cont_cls; op->r_id = h->r_id_gen++; - GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); - attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(attr); - op->env = GNUNET_MQ_msg_extra(sam, - attr_len, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); + GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); + attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); + op->env = GNUNET_MQ_msg_extra (sam, + attr_len, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); sam->identity = *pkey; - sam->id = htonl(op->r_id); - sam->exp = GNUNET_htonll(exp_interval->rel_value_us); + sam->id = htonl (op->r_id); + sam->exp = GNUNET_htonll (exp_interval->rel_value_us); - GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&sam[1]); + GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]); - sam->attr_len = htons(attr_len); + sam->attr_len = htons (attr_len); if (NULL != h->mq) - GNUNET_MQ_send_copy(h->mq, op->env); + GNUNET_MQ_send_copy (h->mq, op->env); return op; } @@ -888,7 +892,7 @@ GNUNET_RECLAIM_attribute_store( * @return handle Used to to abort the request */ struct GNUNET_RECLAIM_Operation * -GNUNET_RECLAIM_attribute_delete( +GNUNET_RECLAIM_attribute_delete ( struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, @@ -899,23 +903,23 @@ GNUNET_RECLAIM_attribute_delete( struct AttributeDeleteMessage *dam; size_t attr_len; - op = GNUNET_new(struct GNUNET_RECLAIM_Operation); + op = GNUNET_new (struct GNUNET_RECLAIM_Operation); op->h = h; op->as_cb = cont; op->cls = cont_cls; op->r_id = h->r_id_gen++; - GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); - attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(attr); - op->env = GNUNET_MQ_msg_extra(dam, - attr_len, - GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); + GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); + attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); + op->env = GNUNET_MQ_msg_extra (dam, + attr_len, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); dam->identity = *pkey; - dam->id = htonl(op->r_id); - GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&dam[1]); + dam->id = htonl (op->r_id); + GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]); - dam->attr_len = htons(attr_len); + dam->attr_len = htons (attr_len); if (NULL != h->mq) - GNUNET_MQ_send_copy(h->mq, op->env); + GNUNET_MQ_send_copy (h->mq, op->env); return op; } @@ -945,7 +949,7 @@ GNUNET_RECLAIM_attribute_delete( * @return an iterator Handle to use for iteration */ struct GNUNET_RECLAIM_AttributeIterator * -GNUNET_RECLAIM_get_attributes_start( +GNUNET_RECLAIM_get_attributes_start ( struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, @@ -961,7 +965,7 @@ GNUNET_RECLAIM_get_attributes_start( uint32_t rid; rid = h->r_id_gen++; - it = GNUNET_new(struct GNUNET_RECLAIM_AttributeIterator); + it = GNUNET_new (struct GNUNET_RECLAIM_AttributeIterator); it->h = h; it->error_cb = error_cb; it->error_cb_cls = error_cb_cls; @@ -971,15 +975,15 @@ GNUNET_RECLAIM_get_attributes_start( it->proc_cls = proc_cls; it->r_id = rid; it->identity = *identity; - GNUNET_CONTAINER_DLL_insert_tail(h->it_head, h->it_tail, it); + GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it); env = - GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); - msg->id = htonl(rid); + GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); + msg->id = htonl (rid); msg->identity = *identity; if (NULL == h->mq) it->env = env; else - GNUNET_MQ_send(h->mq, env); + GNUNET_MQ_send (h->mq, env); return it; } @@ -991,16 +995,16 @@ GNUNET_RECLAIM_get_attributes_start( * @param it the iterator */ void -GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it) +GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it) { struct GNUNET_RECLAIM_Handle *h = it->h; struct AttributeIterationNextMessage *msg; struct GNUNET_MQ_Envelope *env; env = - GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); - msg->id = htonl(it->r_id); - GNUNET_MQ_send(h->mq, env); + GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); + msg->id = htonl (it->r_id); + GNUNET_MQ_send (h->mq, env); } @@ -1012,20 +1016,20 @@ GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it) * @param it the iterator */ void -GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it) +GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) { struct GNUNET_RECLAIM_Handle *h = it->h; struct GNUNET_MQ_Envelope *env; struct AttributeIterationStopMessage *msg; if (NULL != h->mq) - { - env = - GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP); - msg->id = htonl(it->r_id); - GNUNET_MQ_send(h->mq, env); - } - free_it(it); + { + env = + GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP); + msg->id = htonl (it->r_id); + GNUNET_MQ_send (h->mq, env); + } + free_it (it); } @@ -1043,7 +1047,7 @@ GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it) * @return handle to abort the operation */ struct GNUNET_RECLAIM_Operation * -GNUNET_RECLAIM_ticket_issue( +GNUNET_RECLAIM_ticket_issue ( struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, @@ -1055,26 +1059,26 @@ GNUNET_RECLAIM_ticket_issue( struct IssueTicketMessage *tim; size_t attr_len; - fprintf(stderr, "Issuing ticket\n"); - op = GNUNET_new(struct GNUNET_RECLAIM_Operation); + fprintf (stderr, "Issuing ticket\n"); + op = GNUNET_new (struct GNUNET_RECLAIM_Operation); op->h = h; op->tr_cb = cb; op->cls = cb_cls; op->r_id = h->r_id_gen++; - GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); - attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(attrs); - op->env = GNUNET_MQ_msg_extra(tim, - attr_len, - GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); + GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); + attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); + op->env = GNUNET_MQ_msg_extra (tim, + attr_len, + GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); tim->identity = *iss; tim->rp = *rp; - tim->id = htonl(op->r_id); + tim->id = htonl (op->r_id); - GNUNET_RECLAIM_ATTRIBUTE_list_serialize(attrs, (char *)&tim[1]); + GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]); - tim->attr_len = htons(attr_len); + tim->attr_len = htons (attr_len); if (NULL != h->mq) - GNUNET_MQ_send_copy(h->mq, op->env); + GNUNET_MQ_send_copy (h->mq, op->env); return op; } @@ -1092,7 +1096,7 @@ GNUNET_RECLAIM_ticket_issue( * @return handle to abort the operation */ struct GNUNET_RECLAIM_Operation * -GNUNET_RECLAIM_ticket_consume( +GNUNET_RECLAIM_ticket_consume ( struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, @@ -1102,18 +1106,18 @@ GNUNET_RECLAIM_ticket_consume( struct GNUNET_RECLAIM_Operation *op; struct ConsumeTicketMessage *ctm; - op = GNUNET_new(struct GNUNET_RECLAIM_Operation); + op = GNUNET_new (struct GNUNET_RECLAIM_Operation); op->h = h; op->ar_cb = cb; op->cls = cb_cls; op->r_id = h->r_id_gen++; - GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); - op->env = GNUNET_MQ_msg(ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); + GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); + op->env = GNUNET_MQ_msg (ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); ctm->identity = *identity; - ctm->id = htonl(op->r_id); + ctm->id = htonl (op->r_id); ctm->ticket = *ticket; if (NULL != h->mq) - GNUNET_MQ_send_copy(h->mq, op->env); + GNUNET_MQ_send_copy (h->mq, op->env); return op; } @@ -1136,7 +1140,7 @@ GNUNET_RECLAIM_ticket_consume( * @return an iterator handle to use for iteration */ struct GNUNET_RECLAIM_TicketIterator * -GNUNET_RECLAIM_ticket_iteration_start( +GNUNET_RECLAIM_ticket_iteration_start ( struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, @@ -1152,7 +1156,7 @@ GNUNET_RECLAIM_ticket_iteration_start( uint32_t rid; rid = h->r_id_gen++; - it = GNUNET_new(struct GNUNET_RECLAIM_TicketIterator); + it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator); it->h = h; it->error_cb = error_cb; it->error_cb_cls = error_cb_cls; @@ -1161,14 +1165,14 @@ GNUNET_RECLAIM_ticket_iteration_start( it->tr_cb = proc; it->cls = proc_cls; it->r_id = rid; - GNUNET_CONTAINER_DLL_insert_tail(h->ticket_it_head, h->ticket_it_tail, it); - env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); - msg->id = htonl(rid); + GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it); + env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); + msg->id = htonl (rid); msg->identity = *identity; if (NULL == h->mq) it->env = env; else - GNUNET_MQ_send(h->mq, env); + GNUNET_MQ_send (h->mq, env); return it; } @@ -1180,15 +1184,15 @@ GNUNET_RECLAIM_ticket_iteration_start( * @param it the iterator */ void -GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it) +GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it) { struct GNUNET_RECLAIM_Handle *h = it->h; struct TicketIterationNextMessage *msg; struct GNUNET_MQ_Envelope *env; - env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT); - msg->id = htonl(it->r_id); - GNUNET_MQ_send(h->mq, env); + env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT); + msg->id = htonl (it->r_id); + GNUNET_MQ_send (h->mq, env); } @@ -1200,20 +1204,20 @@ GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it) * @param it the iterator */ void -GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it) +GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it) { struct GNUNET_RECLAIM_Handle *h = it->h; struct GNUNET_MQ_Envelope *env; struct TicketIterationStopMessage *msg; if (NULL != h->mq) - { - env = - GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); - msg->id = htonl(it->r_id); - GNUNET_MQ_send(h->mq, env); - } - GNUNET_free(it); + { + env = + GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); + msg->id = htonl (it->r_id); + GNUNET_MQ_send (h->mq, env); + } + GNUNET_free (it); } @@ -1231,7 +1235,7 @@ GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it) * @return handle to abort the operation */ struct GNUNET_RECLAIM_Operation * -GNUNET_RECLAIM_ticket_revoke( +GNUNET_RECLAIM_ticket_revoke ( struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, @@ -1243,21 +1247,21 @@ GNUNET_RECLAIM_ticket_revoke( uint32_t rid; rid = h->r_id_gen++; - op = GNUNET_new(struct GNUNET_RECLAIM_Operation); + op = GNUNET_new (struct GNUNET_RECLAIM_Operation); op->h = h; op->rvk_cb = cb; op->cls = cb_cls; op->r_id = rid; - GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); - op->env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); - msg->id = htonl(rid); + GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); + op->env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); + msg->id = htonl (rid); msg->identity = *identity; msg->ticket = *ticket; if (NULL != h->mq) - { - GNUNET_MQ_send(h->mq, op->env); - op->env = NULL; - } + { + GNUNET_MQ_send (h->mq, op->env); + op->env = NULL; + } return op; } -- cgit v1.2.3