summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_gnsrecord_lib.h79
-rw-r--r--src/reclaim/gnunet-reclaim.c68
-rw-r--r--src/reclaim/gnunet-service-reclaim.c1
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c237
-rw-r--r--src/reclaim/plugin_gnsrecord_reclaim.c27
5 files changed, 146 insertions, 266 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 8b3a6b720..a92cdc2e7 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -100,7 +100,7 @@ extern "C" {
/**
* Record type for local ticket references
*/
-#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF 65545
+#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545
/**
* 65546 reserved
@@ -358,8 +358,9 @@ typedef void (*GNUNET_GNSRECORD_RecordCallback) (
* @param data_size number of bytes in @a data
* @return NULL on error, otherwise human-readable representation of the value
*/
-char *GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data,
- size_t data_size);
+char *
+GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data,
+ size_t data_size);
/**
@@ -372,8 +373,9 @@ char *GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data,
* @param data_size set to number of bytes in @a data
* @return #GNUNET_OK on success
*/
-int GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data,
- size_t *data_size);
+int
+GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data,
+ size_t *data_size);
/**
@@ -382,7 +384,8 @@ int GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data,
* @param dns_typename name to convert
* @return corresponding number, UINT32_MAX on error
*/
-uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename);
+uint32_t
+GNUNET_GNSRECORD_typename_to_number (const char *dns_typename);
/**
@@ -391,7 +394,8 @@ uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename);
* @param type number of a type to convert
* @return corresponding typestring, NULL on error
*/
-const char *GNUNET_GNSRECORD_number_to_typename (uint32_t type);
+const char *
+GNUNET_GNSRECORD_number_to_typename (uint32_t type);
/* convenience APIs for serializing / deserializing GNS records */
@@ -433,9 +437,10 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
* @param dest where to put the data
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
-int GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src,
- unsigned int rd_count,
- struct GNUNET_GNSRECORD_Data *dest);
+int
+GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src,
+ unsigned int rd_count,
+ struct GNUNET_GNSRECORD_Data *dest);
/* ******* general APIs relating to blocks, records and labels ******** */
@@ -448,7 +453,8 @@ int GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src,
* @return #GNUNET_YES if the record is expired,
* #GNUNET_NO if not
*/
-int GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd);
+int
+GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd);
/**
@@ -456,7 +462,8 @@ int GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd);
* @param src source string
* @return converted result
*/
-char *GNUNET_GNSRECORD_string_to_lowercase (const char *src);
+char *
+GNUNET_GNSRECORD_string_to_lowercase (const char *src);
/**
@@ -468,7 +475,8 @@ char *GNUNET_GNSRECORD_string_to_lowercase (const char *src);
* @return string form; will be overwritten by next call to
* #GNUNET_GNSRECORD_z2s.
*/
-const char *GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z);
+const char *
+GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z);
/**
@@ -494,8 +502,9 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey);
* @param pkey set to a public key on the eliptic curve
* @return #GNUNET_SYSERR if @a zkey has the wrong syntax
*/
-int GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
- struct GNUNET_CRYPTO_EcdsaPublicKey *pkey);
+int
+GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
+ struct GNUNET_CRYPTO_EcdsaPublicKey *pkey);
/**
@@ -505,7 +514,8 @@ int GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
* @param label label of the record
* @param query hash to use for the query
*/
-void GNUNET_GNSRECORD_query_from_private_key (
+void
+GNUNET_GNSRECORD_query_from_private_key (
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label,
struct GNUNET_HashCode *query);
@@ -517,7 +527,8 @@ void GNUNET_GNSRECORD_query_from_private_key (
* @param label label of the record
* @param query hash to use for the query
*/
-void GNUNET_GNSRECORD_query_from_public_key (
+void
+GNUNET_GNSRECORD_query_from_public_key (
const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label,
struct GNUNET_HashCode *query);
@@ -531,10 +542,12 @@ void GNUNET_GNSRECORD_query_from_public_key (
* @param rd record data
* @param rd_count number of records in @a rd
*/
-struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create (
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
- struct GNUNET_TIME_Absolute expire, const char *label,
- const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count);
+struct GNUNET_GNSRECORD_Block *
+GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
+ struct GNUNET_TIME_Absolute expire,
+ const char *label,
+ const struct GNUNET_GNSRECORD_Data *rd,
+ unsigned int rd_count);
/**
@@ -548,10 +561,12 @@ struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create (
* @param rd record data
* @param rd_count number of records in @a rd
*/
-struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create2 (
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
- struct GNUNET_TIME_Absolute expire, const char *label,
- const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count);
+struct GNUNET_GNSRECORD_Block *
+GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
+ struct GNUNET_TIME_Absolute expire,
+ const char *label,
+ const struct GNUNET_GNSRECORD_Data *rd,
+ unsigned int rd_count);
/**
@@ -561,7 +576,8 @@ struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create2 (
* @param block block to verify
* @return #GNUNET_OK if the signature is valid
*/
-int GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block);
+int
+GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block);
/**
@@ -575,7 +591,8 @@ int GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block);
* @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was
* not well-formed
*/
-int GNUNET_GNSRECORD_block_decrypt (
+int
+GNUNET_GNSRECORD_block_decrypt (
const struct GNUNET_GNSRECORD_Block *block,
const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label,
GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls);
@@ -588,8 +605,9 @@ int GNUNET_GNSRECORD_block_decrypt (
* @param b another record
* @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not.
*/
-int GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a,
- const struct GNUNET_GNSRECORD_Data *b);
+int
+GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a,
+ const struct GNUNET_GNSRECORD_Data *b);
/**
@@ -601,7 +619,8 @@ int GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a,
* @param rd array of records
* @return absolute expiration time
*/
-struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time (
+struct GNUNET_TIME_Absolute
+GNUNET_GNSRECORD_record_get_expiration_time (
unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 0e5591d69..1c3b4174d 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -157,7 +157,8 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task;
*/
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
-static void do_cleanup (void *cls)
+static void
+do_cleanup (void *cls)
{
cleanup_task = NULL;
if (NULL != timeout)
@@ -178,8 +179,8 @@ static void do_cleanup (void *cls)
GNUNET_free (attr_list);
}
-static void ticket_issue_cb (void *cls,
- const struct GNUNET_RECLAIM_Ticket *ticket)
+static void
+ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
{
char *ticket_str;
reclaim_op = NULL;
@@ -192,7 +193,8 @@ static void ticket_issue_cb (void *cls,
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void store_attr_cont (void *cls, int32_t success, const char *emsg)
+static void
+store_attr_cont (void *cls, int32_t success, const char *emsg)
{
reclaim_op = NULL;
if (GNUNET_SYSERR == success) {
@@ -201,9 +203,9 @@ static void store_attr_cont (void *cls, int32_t success, const char *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)
+static void
+process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
+ const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
{
char *value_str;
const char *attr_type;
@@ -224,33 +226,45 @@ static void process_attrs (void *cls,
attr_type, attr->version, attr->id);
}
-static void ticket_iter_err (void *cls)
+static void
+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);
}
-static void ticket_iter_fin (void *cls)
+static void
+ticket_iter_fin (void *cls)
{
ticket_iterator = NULL;
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
+static void
+ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
{
- fprintf (stdout, "Found ticket\n");
+ char *aud;
+ char *ref;
+
+ 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));
+
+ fprintf (stdout, "Ticket ID: %s | Audience: %s\n", ref, aud);
GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
}
-static void iter_error (void *cls)
+static void
+iter_error (void *cls)
{
attr_iterator = NULL;
fprintf (stderr, "Failed to iterate over attributes\n");
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void timeout_task (void *cls)
+static void
+timeout_task (void *cls)
{
timeout = NULL;
ret = 1;
@@ -259,7 +273,8 @@ static void timeout_task (void *cls)
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void process_rvk (void *cls, int success, const char *msg)
+static void
+process_rvk (void *cls, int success, const char *msg)
{
reclaim_op = NULL;
if (GNUNET_OK != success) {
@@ -269,7 +284,8 @@ static void process_rvk (void *cls, int success, const char *msg)
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void iter_finished (void *cls)
+static void
+iter_finished (void *cls)
{
char *data;
size_t data_size;
@@ -325,9 +341,9 @@ static void iter_finished (void *cls)
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)
+static void
+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;
@@ -367,7 +383,8 @@ static void iter_cb (void *cls,
GNUNET_RECLAIM_get_attributes_next (attr_iterator);
}
-static void start_process ()
+static void
+start_process ()
{
if (NULL == pkey) {
fprintf (stderr, "Ego %s not found\n", ego_name);
@@ -402,8 +419,9 @@ static void start_process ()
static int init = GNUNET_YES;
-static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
- const char *name)
+static void
+ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
+ const char *name)
{
if (NULL == name) {
if (GNUNET_YES == init) {
@@ -418,8 +436,9 @@ static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
}
-static void run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
ret = 0;
if (NULL == ego_name) {
@@ -446,7 +465,8 @@ static void run (void *cls, char *const *args, const char *cfgfile,
}
-int main (int argc, char *const argv[])
+int
+main (int argc, char *const argv[])
{
exp_interval = GNUNET_TIME_UNIT_HOURS;
struct GNUNET_GETOPT_CommandLineOption options[] = {
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 2c74193d1..2bb4f5a74 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -925,6 +925,7 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
} else {
env = GNUNET_MQ_msg_extra (trm, sizeof (struct GNUNET_RECLAIM_Ticket),
GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
+ memcpy (&trm[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket));
}
trm->id = htonl (ti->r_id);
GNUNET_MQ_send (ti->client->mq, env);
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index 5a3190c7f..4a307e635 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -164,21 +164,6 @@ struct TicketIssueHandle {
struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
/**
- * Ticket reference list
- */
- struct TicketReference *ticket_refs_head;
-
- /**
- * Ticket reference list
- */
- struct TicketReference *ticket_refs_tail;
-
- /**
- * Number of references
- */
- uint32_t ticket_ref_num;
-
- /**
* Callback
*/
RECLAIM_TICKETS_TicketResult cb;
@@ -194,19 +179,9 @@ struct TicketIssueHandle {
*/
struct RECLAIM_TICKETS_Iterator {
/**
- * Issuer Key
- */
- struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
-
- /**
- * Issuer pubkey
- */
- struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub;
-
- /**
* Namestore queue entry
*/
- struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
+ struct GNUNET_NAMESTORE_ZoneIterator *ns_it;
/**
* Iter callback
@@ -217,16 +192,6 @@ struct RECLAIM_TICKETS_Iterator {
* Iter cls
*/
void *cb_cls;
-
- /**
- * Ticket reference list
- */
- struct TicketReference *tickets_head;
-
- /**
- * Ticket reference list
- */
- struct TicketReference *tickets_tail;
};
@@ -870,113 +835,13 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth)
static void
cleanup_issue_handle (struct TicketIssueHandle *handle)
{
- struct TicketReference *tr;
- struct TicketReference *tr_tmp;
- if (NULL != handle->attrs)
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (handle->attrs);
if (NULL != handle->ns_qe)
GNUNET_NAMESTORE_cancel (handle->ns_qe);
- for (tr = handle->ticket_refs_head; NULL != tr;) {
- if (NULL != tr->attrs)
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
- tr_tmp = tr;
- tr = tr->next;
- GNUNET_free (tr_tmp);
- }
GNUNET_free (handle);
}
static void
-store_ticket_refs_cont (void *cls, int32_t success, const char *emsg)
-{
- struct TicketIssueHandle *handle = cls;
- handle->ns_qe = NULL;
- if (GNUNET_OK != success) {
- handle->cb (handle->cb_cls, NULL, GNUNET_SYSERR,
- "Error storing updated ticket refs in GNS");
- cleanup_issue_handle (handle);
- return;
- }
- handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
- cleanup_issue_handle (handle);
-}
-
-
-static void
-update_ticket_refs (void *cls)
-{
- struct TicketIssueHandle *handle = cls;
- struct GNUNET_GNSRECORD_Data refs_rd[handle->ticket_ref_num];
- struct TicketReference *tr;
-
- tr = handle->ticket_refs_head;
- for (int i = 0; i < handle->ticket_ref_num; i++) {
- refs_rd[i].data = &tr->ticket;
- refs_rd[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket);
- refs_rd[i].expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us;
- refs_rd[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF;
- refs_rd[i].flags =
- GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
- tr = tr->next;
- }
-
- handle->ns_qe = GNUNET_NAMESTORE_records_store (
- nsh, &handle->identity, GNUNET_GNS_EMPTY_LABEL_AT, handle->ticket_ref_num,
- refs_rd, &store_ticket_refs_cont, handle);
-}
-
-
-static void
-ticket_lookup_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
- const char *label, unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
-{
- struct TicketIssueHandle *handle = cls;
- struct TicketReference *tr;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received tickets from local namestore.\n");
- handle->ns_qe = NULL;
- for (int i = 0; i < rd_count; i++) {
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF != rd[i].record_type)
- continue;
- tr = GNUNET_new (struct TicketReference);
- memcpy (&tr->ticket, rd[i].data, sizeof (struct GNUNET_RECLAIM_Ticket));
- if (0 != memcmp (&tr->ticket.identity, &handle->ticket.identity,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) {
- // Not our ticket
- GNUNET_free (tr);
- continue;
- }
- GNUNET_CONTAINER_DLL_insert (handle->ticket_refs_head,
- handle->ticket_refs_tail, tr);
- handle->ticket_ref_num++;
- }
- tr = GNUNET_new (struct TicketReference);
- tr->ticket = handle->ticket;
- tr->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (handle->attrs);
- GNUNET_CONTAINER_DLL_insert (handle->ticket_refs_head,
- handle->ticket_refs_tail, tr);
- handle->ticket_ref_num++;
- GNUNET_SCHEDULER_add_now (&update_ticket_refs, handle);
-}
-
-
-/**
- * TODO maybe we should cleanup the ATTRREFS here?
- */
-static void
-ticket_lookup_error_cb (void *cls)
-{
- struct TicketIssueHandle *handle = cls;
- handle->ns_qe = NULL;
- handle->cb (handle->cb_cls, &handle->ticket, GNUNET_SYSERR,
- "Error checking for ticketsin GNS\n");
- cleanup_issue_handle (handle);
-}
-
-static void
store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
{
struct TicketIssueHandle *handle = cls;
@@ -987,10 +852,8 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
"Error storing AuthZ ticket in GNS");
return;
}
- /* First, local references to tickets */
- handle->ns_qe = GNUNET_NAMESTORE_records_lookup (
- nsh, &handle->identity, GNUNET_GNS_EMPTY_LABEL_AT,
- &ticket_lookup_error_cb, handle, &ticket_lookup_cb, handle);
+ handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
+ cleanup_issue_handle (handle);
}
@@ -1000,7 +863,7 @@ issue_ticket (struct TicketIssueHandle *ih)
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
struct GNUNET_GNSRECORD_Data *attrs_record;
char *label;
- size_t list_len = 0;
+ size_t list_len = 1;
int i;
for (le = ih->attrs->list_head; NULL != le; le = le->next)
@@ -1017,6 +880,12 @@ issue_ticket (struct TicketIssueHandle *ih)
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 = GNUNET_TIME_UNIT_DAYS.rel_value_us;
+ attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET;
+ attrs_record[i].flags =
+ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
label =
GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t));
@@ -1055,49 +924,11 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
static void
cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter)
{
- struct TicketReference *tr;
- struct TicketReference *tr_tmp;
- if (NULL != iter->ns_qe)
- GNUNET_NAMESTORE_cancel (iter->ns_qe);
- for (tr = iter->tickets_head; NULL != tr;) {
- if (NULL != tr->attrs)
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
- tr_tmp = tr;
- tr = tr->next;
- GNUNET_free (tr_tmp);
- }
+ if (NULL != iter->ns_it)
+ GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
GNUNET_free (iter);
}
-static void
-do_cleanup_iter (void *cls)
-{
- struct RECLAIM_TICKETS_Iterator *iter = cls;
- cleanup_iter (iter);
-}
-
-/**
- * Perform ticket iteration step
- *
- * @param ti ticket iterator to process
- */
-static void
-run_ticket_iteration_round (struct RECLAIM_TICKETS_Iterator *iter)
-{
- struct TicketReference *tr;
- if (NULL == iter->tickets_head) {
- // No more tickets
- iter->cb (iter->cb_cls, NULL);
- GNUNET_SCHEDULER_add_now (&do_cleanup_iter, iter);
- return;
- }
- tr = iter->tickets_head;
- GNUNET_CONTAINER_DLL_remove (iter->tickets_head, iter->tickets_tail, tr);
- iter->cb (iter->cb_cls, &tr->ticket);
- if (NULL != tr->attrs)
- GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
- GNUNET_free (tr);
-}
static void
collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
@@ -1105,46 +936,52 @@ collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const struct GNUNET_GNSRECORD_Data *rd)
{
struct RECLAIM_TICKETS_Iterator *iter = cls;
- struct TicketReference *tr;
- iter->ns_qe = NULL;
for (int i = 0; i < rd_count; i++) {
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF != rd[i].record_type)
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
continue;
- tr = GNUNET_new (struct TicketReference);
- memcpy (&tr->ticket, rd[i].data, sizeof (struct GNUNET_RECLAIM_Ticket));
- if (0 != memcmp (&tr->ticket.identity, &iter->identity_pub,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) {
- // Not our ticket
- GNUNET_free (tr);
- continue;
- }
- GNUNET_CONTAINER_DLL_insert (iter->tickets_head, iter->tickets_tail, tr);
+ iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data);
+ return;
}
- run_ticket_iteration_round (iter);
+ GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
}
+
+static void
+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);
+}
+
+
static void
collect_tickets_error_cb (void *cls)
{
struct RECLAIM_TICKETS_Iterator *iter = cls;
- iter->ns_qe = NULL;
+ iter->ns_it = NULL;
iter->cb (iter->cb_cls, NULL);
cleanup_iter (iter);
}
+
void
RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter)
{
- run_ticket_iteration_round (iter);
+ GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
}
+
void
RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter)
{
+ GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
cleanup_iter (iter);
}
+
struct RECLAIM_TICKETS_Iterator *
RECLAIM_TICKETS_iteration_start (
const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
@@ -1153,13 +990,11 @@ RECLAIM_TICKETS_iteration_start (
struct RECLAIM_TICKETS_Iterator *iter;
iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
- iter->identity = *identity;
- GNUNET_CRYPTO_ecdsa_key_get_public (identity, &iter->identity_pub);
iter->cb = cb;
iter->cb_cls = cb_cls;
- iter->ns_qe = GNUNET_NAMESTORE_records_lookup (
- nsh, identity, GNUNET_GNS_EMPTY_LABEL_AT, &collect_tickets_error_cb, iter,
- &collect_tickets_cb, iter);
+ iter->ns_it = GNUNET_NAMESTORE_zone_iteration_start (
+ nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter,
+ &collect_tickets_finished_cb, iter);
return iter;
}
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c
index 612fec3bd..48cdd9811 100644
--- a/src/reclaim/plugin_gnsrecord_reclaim.c
+++ b/src/reclaim/plugin_gnsrecord_reclaim.c
@@ -39,8 +39,8 @@
* @param data_size number of bytes in @a data
* @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)
+static char *
+value_to_string (void *cls, uint32_t type, const void *data, size_t data_size)
{
switch (type) {
case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
@@ -49,7 +49,7 @@ static char *value_to_string (void *cls, uint32_t type, const void *data,
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_TICKETREF:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
default:
@@ -69,8 +69,9 @@ static char *value_to_string (void *cls, uint32_t type, const void *data,
* @param data_size set to number of bytes in @a data
* @return #GNUNET_OK on success
*/
-static int string_to_value (void *cls, uint32_t type, const char *s,
- void **data, size_t *data_size)
+static int
+string_to_value (void *cls, uint32_t type, const char *s, void **data,
+ size_t *data_size)
{
if (NULL == s)
return GNUNET_SYSERR;
@@ -84,7 +85,7 @@ static int string_to_value (void *cls, uint32_t type, const char *s,
return GNUNET_OK;
case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF:
case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
- case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF:
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
default:
return GNUNET_SYSERR;
@@ -105,7 +106,7 @@ static struct {
{"RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER},
{"RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT},
{"RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT},
- {"RECLAIM_TICKETREF", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF},
+ {"RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET},
{NULL, UINT32_MAX}};
@@ -116,7 +117,8 @@ static struct {
* @param dns_typename name to convert
* @return corresponding number, UINT32_MAX on error
*/
-static uint32_t typename_to_number (void *cls, const char *dns_typename)
+static uint32_t
+typename_to_number (void *cls, const char *dns_typename)
{
unsigned int i;
@@ -135,7 +137,8 @@ static uint32_t typename_to_number (void *cls, const char *dns_typename)
* @param type number of a type to convert
* @return corresponding typestring, NULL on error
*/
-static const char *number_to_typename (void *cls, uint32_t type)
+static const char *
+number_to_typename (void *cls, uint32_t type)
{
unsigned int i;
@@ -152,7 +155,8 @@ static const char *number_to_typename (void *cls, uint32_t type)
* @param cls NULL
* @return the exported block API
*/
-void *libgnunet_plugin_gnsrecord_reclaim_init (void *cls)
+void *
+libgnunet_plugin_gnsrecord_reclaim_init (void *cls)
{
struct GNUNET_GNSRECORD_PluginFunctions *api;
@@ -171,7 +175,8 @@ void *libgnunet_plugin_gnsrecord_reclaim_init (void *cls)
* @param cls the return value from #libgnunet_plugin_block_test_init
* @return NULL
*/
-void *libgnunet_plugin_gnsrecord_reclaim_done (void *cls)
+void *
+libgnunet_plugin_gnsrecord_reclaim_done (void *cls)
{
struct GNUNET_GNSRECORD_PluginFunctions *api = cls;