aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-12 16:34:16 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 10:01:23 +0200
commitdfe11b6b541b47c85cdf56e55ebb816d6793db31 (patch)
treeb1c05be186902b4e510ab803e489094402b8149a /src
parenta12b8c2c4cbf952c8c305cde193bb25c13a0912b (diff)
downloadgnunet-dfe11b6b541b47c85cdf56e55ebb816d6793db31.tar.gz
gnunet-dfe11b6b541b47c85cdf56e55ebb816d6793db31.zip
RECLAIM: Towards -sql
Diffstat (limited to 'src')
-rw-r--r--src/reclaim/gnunet-reclaim.c57
-rw-r--r--src/reclaim/gnunet-service-reclaim.c168
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c189
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.h31
-rw-r--r--src/reclaim/reclaim.h10
-rw-r--r--src/reclaim/reclaim_api.c66
6 files changed, 305 insertions, 216 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index df6ebc66f..c36955a04 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -77,6 +77,11 @@ static char* type_str;
77static char* revoke_ticket; 77static char* revoke_ticket;
78 78
79/** 79/**
80 * Ticket listing
81 */
82static int list_tickets;
83
84/**
80 * Ego name 85 * Ego name
81 */ 86 */
82static char* ego_name; 87static char* ego_name;
@@ -102,6 +107,11 @@ static struct GNUNET_RECLAIM_Operation *reclaim_op;
102static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator; 107static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator;
103 108
104/** 109/**
110 * Ticket iterator
111 */
112static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator;
113
114/**
105 * Master ABE key 115 * Master ABE key
106 */ 116 */
107static struct GNUNET_CRYPTO_AbeMasterKey *abe_key; 117static struct GNUNET_CRYPTO_AbeMasterKey *abe_key;
@@ -156,6 +166,8 @@ do_cleanup(void *cls)
156 GNUNET_RECLAIM_cancel (reclaim_op); 166 GNUNET_RECLAIM_cancel (reclaim_op);
157 if (NULL != attr_iterator) 167 if (NULL != attr_iterator)
158 GNUNET_RECLAIM_get_attributes_stop (attr_iterator); 168 GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
169 if (NULL != ticket_iterator)
170 GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
159 if (NULL != reclaim_handle) 171 if (NULL != reclaim_handle)
160 GNUNET_RECLAIM_disconnect (reclaim_handle); 172 GNUNET_RECLAIM_disconnect (reclaim_handle);
161 if (NULL != identity_handle) 173 if (NULL != identity_handle)
@@ -223,6 +235,30 @@ process_attrs (void *cls,
223 attr->name, value_str, attr_type, attr->version, attr->id); 235 attr->name, value_str, attr_type, attr->version, attr->id);
224} 236}
225 237
238static void
239ticket_iter_err (void *cls)
240{
241 ticket_iterator = NULL;
242 fprintf (stderr,
243 "Failed to iterate over tickets\n");
244 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
245}
246
247static void
248ticket_iter_fin (void *cls)
249{
250 ticket_iterator = NULL;
251 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
252}
253
254static void
255ticket_iter (void *cls,
256 const struct GNUNET_RECLAIM_Ticket *ticket)
257{
258 fprintf (stdout,
259 "Found ticket\n");
260 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
261}
226 262
227static void 263static void
228iter_error (void *cls) 264iter_error (void *cls)
@@ -396,7 +432,7 @@ iter_cb (void *cls,
396} 432}
397 433
398static void 434static void
399start_get_attributes () 435start_process ()
400{ 436{
401 if (NULL == pkey) 437 if (NULL == pkey)
402 { 438 {
@@ -406,6 +442,19 @@ start_get_attributes ()
406 return; 442 return;
407 } 443 }
408 444
445 if (list_tickets)
446 {
447 ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
448 pkey,
449 &ticket_iter_err,
450 NULL,
451 &ticket_iter,
452 NULL,
453 &ticket_iter_fin,
454 NULL);
455 return;
456 }
457
409 if (NULL != rp) 458 if (NULL != rp)
410 GNUNET_CRYPTO_ecdsa_public_key_from_string (rp, 459 GNUNET_CRYPTO_ecdsa_public_key_from_string (rp,
411 strlen (rp), 460 strlen (rp),
@@ -446,7 +495,7 @@ ego_cb (void *cls,
446 if (NULL == name) { 495 if (NULL == name) {
447 if (GNUNET_YES == init) { 496 if (GNUNET_YES == init) {
448 init = GNUNET_NO; 497 init = GNUNET_NO;
449 start_get_attributes(); 498 start_process ();
450 } 499 }
451 return; 500 return;
452 } 501 }
@@ -548,6 +597,10 @@ main(int argc, char *const argv[])
548 "TYPE", 597 "TYPE",
549 gettext_noop ("Type of attribute"), 598 gettext_noop ("Type of attribute"),
550 &type_str), 599 &type_str),
600 GNUNET_GETOPT_option_flag ('T',
601 "tickets",
602 gettext_noop ("List tickets of ego"),
603 &list_tickets),
551 GNUNET_GETOPT_option_relative_time ('E', 604 GNUNET_GETOPT_option_relative_time ('E',
552 "expiration", 605 "expiration",
553 "INTERVAL", 606 "INTERVAL",
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index b963b0a9b..634de0dfe 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -135,29 +135,14 @@ struct TicketIteration
135 struct IdpClient *client; 135 struct IdpClient *client;
136 136
137 /** 137 /**
138 * Key of the identity we are iterating over.
139 */
140 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
141
142 /**
143 * Identity is audience
144 */
145 uint32_t is_audience;
146
147 /**
148 * The operation id fot the iteration in the response for the client 138 * The operation id fot the iteration in the response for the client
149 */ 139 */
150 uint32_t r_id; 140 uint32_t r_id;
151 141
152 /** 142 /**
153 * Offset of the iteration used to address next result of the 143 * The ticket iterator
154 * iteration in the store
155 *
156 * Initialy set to 0 in handle_iteration_start
157 * Incremented with by every call to handle_iteration_next
158 */ 144 */
159 uint32_t offset; 145 struct RECLAIM_TICKETS_Iterator *iter;
160
161}; 146};
162 147
163 148
@@ -592,6 +577,7 @@ cleanup()
592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 577 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
593 "Cleaning up\n"); 578 "Cleaning up\n");
594 579
580 RECLAIM_TICKETS_deinit ();
595 if (NULL != stats) 581 if (NULL != stats)
596 { 582 {
597 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 583 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -1870,134 +1856,32 @@ handle_iteration_next (void *cls,
1870 GNUNET_SERVICE_client_continue (idp->client); 1856 GNUNET_SERVICE_client_continue (idp->client);
1871} 1857}
1872 1858
1873/**
1874 * Ticket iteration processor result
1875 */
1876enum ZoneIterationResult
1877{
1878 /**
1879 * Iteration start.
1880 */
1881 IT_START = 0,
1882
1883 /**
1884 * Found tickets,
1885 * Continue to iterate with next iteration_next call
1886 */
1887 IT_SUCCESS_MORE_AVAILABLE = 1,
1888
1889 /**
1890 * Iteration complete
1891 */
1892 IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE = 2
1893};
1894
1895
1896/**
1897 * Context for ticket iteration
1898 */
1899struct TicketIterationProcResult
1900{
1901 /**
1902 * The ticket iteration handle
1903 */
1904 struct TicketIteration *ti;
1905
1906 /**
1907 * Iteration result: iteration done?
1908 * #IT_SUCCESS_MORE_AVAILABLE: if there may be more results overall but
1909 * we got one for now and have sent it to the client
1910 * #IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE: if there are no further results,
1911 * #IT_START: if we are still trying to find a result.
1912 */
1913 int res_iteration_finished;
1914
1915};
1916
1917static void 1859static void
1918cleanup_ticket_iter_handle (struct TicketIteration *ti) 1860ticket_iter_cb (void *cls,
1861 struct GNUNET_RECLAIM_Ticket *ticket)
1919{ 1862{
1920 GNUNET_free (ti); 1863 struct TicketIteration *ti = cls;
1921}
1922
1923/**
1924 * Process ticket from database
1925 *
1926 * @param cls struct TicketIterationProcResult
1927 * @param ticket the ticket
1928 * @param attrs the attributes
1929 */
1930static void
1931ticket_iterate_proc (void *cls,
1932 const struct GNUNET_RECLAIM_Ticket *ticket,
1933 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
1934{
1935 struct TicketIterationProcResult *proc = cls;
1936
1937 if (NULL == ticket)
1938 {
1939 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1940 "Iteration done\n");
1941 proc->res_iteration_finished = IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE;
1942 return;
1943 }
1944 proc->res_iteration_finished = IT_SUCCESS_MORE_AVAILABLE;
1945 send_ticket_result (proc->ti->client,
1946 proc->ti->r_id,
1947 ticket,
1948 GNUNET_OK);
1949
1950}
1951
1952/**
1953 * Perform ticket iteration step
1954 *
1955 * @param ti ticket iterator to process
1956 */
1957static void
1958run_ticket_iteration_round (struct TicketIteration *ti)
1959{
1960 struct TicketIterationProcResult proc;
1961 struct GNUNET_MQ_Envelope *env; 1864 struct GNUNET_MQ_Envelope *env;
1962 struct TicketResultMessage *trm; 1865 struct TicketResultMessage *trm;
1963 int ret;
1964 1866
1965 memset (&proc, 0, sizeof (proc)); 1867 if (NULL == ticket)
1966 proc.ti = ti;
1967 proc.res_iteration_finished = IT_START;
1968 while (IT_START == proc.res_iteration_finished)
1969 {
1970 if (GNUNET_SYSERR ==
1971 (ret = TKT_database->iterate_tickets (TKT_database->cls,
1972 &ti->identity,
1973 ti->is_audience,
1974 ti->offset,
1975 &ticket_iterate_proc,
1976 &proc)))
1977 {
1978 GNUNET_break (0);
1979 break;
1980 }
1981 if (GNUNET_NO == ret)
1982 proc.res_iteration_finished = IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE;
1983 ti->offset++;
1984 }
1985 if (IT_SUCCESS_MORE_AVAILABLE == proc.res_iteration_finished)
1986 { 1868 {
1987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1869 /* send empty response to indicate end of list */
1988 "More results available\n"); 1870 env = GNUNET_MQ_msg (trm,
1989 return; /* more later */ 1871 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
1872 GNUNET_CONTAINER_DLL_remove (ti->client->ticket_iter_head,
1873 ti->client->ticket_iter_tail,
1874 ti);
1875 } else {
1876 env = GNUNET_MQ_msg_extra (trm,
1877 sizeof (struct GNUNET_RECLAIM_Ticket),
1878 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
1990 } 1879 }
1991 /* send empty response to indicate end of list */
1992 env = GNUNET_MQ_msg (trm,
1993 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
1994 trm->id = htonl (ti->r_id); 1880 trm->id = htonl (ti->r_id);
1995 GNUNET_MQ_send (ti->client->mq, 1881 GNUNET_MQ_send (ti->client->mq,
1996 env); 1882 env);
1997 GNUNET_CONTAINER_DLL_remove (ti->client->ticket_iter_head, 1883 if (NULL == ticket)
1998 ti->client->ticket_iter_tail, 1884 GNUNET_free (ti);
1999 ti);
2000 cleanup_ticket_iter_handle (ti);
2001} 1885}
2002 1886
2003static void 1887static void
@@ -2011,15 +1895,14 @@ handle_ticket_iteration_start (void *cls,
2011 "Received TICKET_ITERATION_START message\n"); 1895 "Received TICKET_ITERATION_START message\n");
2012 ti = GNUNET_new (struct TicketIteration); 1896 ti = GNUNET_new (struct TicketIteration);
2013 ti->r_id = ntohl (tis_msg->id); 1897 ti->r_id = ntohl (tis_msg->id);
2014 ti->offset = 0;
2015 ti->client = client; 1898 ti->client = client;
2016 ti->identity = tis_msg->identity;
2017 ti->is_audience = ntohl (tis_msg->is_audience);
2018 1899
2019 GNUNET_CONTAINER_DLL_insert (client->ticket_iter_head, 1900 GNUNET_CONTAINER_DLL_insert (client->ticket_iter_head,
2020 client->ticket_iter_tail, 1901 client->ticket_iter_tail,
2021 ti); 1902 ti);
2022 run_ticket_iteration_round (ti); 1903 ti->iter = RECLAIM_TICKETS_iteration_start (&tis_msg->identity,
1904 &ticket_iter_cb,
1905 ti);
2023 GNUNET_SERVICE_client_continue (client->client); 1906 GNUNET_SERVICE_client_continue (client->client);
2024} 1907}
2025 1908
@@ -2045,10 +1928,11 @@ handle_ticket_iteration_stop (void *cls,
2045 GNUNET_SERVICE_client_drop (client->client); 1928 GNUNET_SERVICE_client_drop (client->client);
2046 return; 1929 return;
2047 } 1930 }
1931 RECLAIM_TICKETS_iteration_stop (ti->iter);
2048 GNUNET_CONTAINER_DLL_remove (client->ticket_iter_head, 1932 GNUNET_CONTAINER_DLL_remove (client->ticket_iter_head,
2049 client->ticket_iter_tail, 1933 client->ticket_iter_tail,
2050 ti); 1934 ti);
2051 cleanup_ticket_iter_handle (ti); 1935 GNUNET_free (ti);
2052 GNUNET_SERVICE_client_continue (client->client); 1936 GNUNET_SERVICE_client_continue (client->client);
2053} 1937}
2054 1938
@@ -2073,7 +1957,7 @@ handle_ticket_iteration_next (void *cls,
2073 GNUNET_SERVICE_client_drop (client->client); 1957 GNUNET_SERVICE_client_drop (client->client);
2074 return; 1958 return;
2075 } 1959 }
2076 run_ticket_iteration_round (ti); 1960 RECLAIM_TICKETS_iteration_next (ti->iter);
2077 GNUNET_SERVICE_client_continue (client->client); 1961 GNUNET_SERVICE_client_continue (client->client);
2078} 1962}
2079 1963
@@ -2226,7 +2110,7 @@ client_disconnect_cb (void *cls,
2226 GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head, 2110 GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head,
2227 idp->ticket_iter_tail, 2111 idp->ticket_iter_tail,
2228 ti); 2112 ti);
2229 cleanup_ticket_iter_handle (ti); 2113 GNUNET_free (ti);
2230 } 2114 }
2231 GNUNET_free (idp); 2115 GNUNET_free (idp);
2232} 2116}
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index f93e934ee..033684f71 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -105,6 +105,47 @@ struct TicketIssueHandle
105 105
106}; 106};
107 107
108/**
109 * Ticket iterator
110 */
111struct RECLAIM_TICKETS_Iterator
112{
113 /**
114 * Issuer Key
115 */
116 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
117
118 /**
119 * Issuer pubkey
120 */
121 struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub;
122
123 /**
124 * Namestore queue entry
125 */
126 struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
127
128 /**
129 * Iter callback
130 */
131 RECLAIM_TICKETS_TicketIter cb;
132
133 /**
134 * Iter cls
135 */
136 void *cb_cls;
137
138 /**
139 * Ticket reference list
140 */
141 struct TicketReference *tickets_head;
142
143 /**
144 * Ticket reference list
145 */
146 struct TicketReference *tickets_tail;
147};
148
108static struct GNUNET_NAMESTORE_Handle *nsh; 149static struct GNUNET_NAMESTORE_Handle *nsh;
109 150
110/** 151/**
@@ -440,6 +481,146 @@ RECLAIM_TICKETS_issue_ticket (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identi
440} 481}
441 482
442 483
484static void
485cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter)
486{
487 struct TicketReference *tr;
488 struct TicketReference *tr_tmp;
489 if (NULL != iter->ns_qe)
490 GNUNET_NAMESTORE_cancel (iter->ns_qe);
491 for (tr = iter->tickets_head; NULL != tr;)
492 {
493 if (NULL != tr->attrs)
494 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
495 tr_tmp = tr;
496 tr = tr->next;
497 GNUNET_free (tr_tmp);
498 }
499 GNUNET_free (iter);
500}
501
502static void
503do_cleanup_iter (void* cls)
504{
505 struct RECLAIM_TICKETS_Iterator *iter = cls;
506 cleanup_iter (iter);
507}
508
509/**
510 * Perform ticket iteration step
511 *
512 * @param ti ticket iterator to process
513 */
514static void
515run_ticket_iteration_round (struct RECLAIM_TICKETS_Iterator *iter)
516{
517 struct TicketReference *tr;
518 if (NULL == iter->tickets_head)
519 {
520 //No more tickets
521 iter->cb (iter->cb_cls,
522 NULL);
523 GNUNET_SCHEDULER_add_now (&do_cleanup_iter, iter);
524 return;
525 }
526 tr = iter->tickets_head;
527 GNUNET_CONTAINER_DLL_remove (iter->tickets_head,
528 iter->tickets_tail,
529 tr);
530 iter->cb (iter->cb_cls,
531 &tr->ticket);
532 if (NULL != tr->attrs)
533 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (tr->attrs);
534 GNUNET_free (tr);
535}
536
537static void
538collect_tickets_cb (void *cls,
539 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
540 const char *label,
541 unsigned int rd_count,
542 const struct GNUNET_GNSRECORD_Data *rd)
543{
544 struct RECLAIM_TICKETS_Iterator *iter = cls;
545 struct TicketReference *tr;
546 size_t attr_data_len;
547 const char* attr_data;
548 iter->ns_qe = NULL;
549
550 for (int i = 0; i < rd_count; i++)
551 {
552 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKETREF != rd[i].record_type)
553 continue;
554 tr = GNUNET_new (struct TicketReference);
555 memcpy (&tr->ticket, rd[i].data,
556 sizeof (struct GNUNET_RECLAIM_Ticket));
557 if (0 != memcmp (&tr->ticket.identity,
558 &iter->identity_pub,
559 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
560 {
561 //Not our ticket
562 GNUNET_free (tr);
563 continue;
564 }
565 attr_data = rd[i].data + sizeof (struct GNUNET_RECLAIM_Ticket);
566 attr_data_len = rd[i].data_size - sizeof (struct GNUNET_RECLAIM_Ticket);
567 tr->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (attr_data,
568 attr_data_len);
569 GNUNET_CONTAINER_DLL_insert (iter->tickets_head,
570 iter->tickets_tail,
571 tr);
572 }
573 run_ticket_iteration_round (iter);
574}
575
576static void
577collect_tickets_error_cb (void *cls)
578{
579 struct RECLAIM_TICKETS_Iterator *iter = cls;
580 iter->ns_qe = NULL;
581 iter->cb (iter->cb_cls,
582 NULL);
583 cleanup_iter (iter);
584}
585
586void
587RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter)
588{
589 run_ticket_iteration_round (iter);
590}
591
592void
593RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter)
594{
595 cleanup_iter (iter);
596}
597
598struct RECLAIM_TICKETS_Iterator*
599RECLAIM_TICKETS_iteration_start (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
600 RECLAIM_TICKETS_TicketIter cb,
601 void* cb_cls)
602{
603 struct RECLAIM_TICKETS_Iterator *iter;
604
605 iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
606 iter->identity = *identity;
607 GNUNET_CRYPTO_ecdsa_key_get_public (identity,
608 &iter->identity_pub);
609 iter->cb = cb;
610 iter->cb_cls = cb_cls;
611 iter->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
612 identity,
613 GNUNET_GNS_EMPTY_LABEL_AT,
614 &collect_tickets_error_cb,
615 iter,
616 &collect_tickets_cb,
617 iter);
618 return iter;
619}
620
621
622
623
443int 624int
444RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) 625RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c)
445{ 626{
@@ -453,3 +634,11 @@ RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c)
453 } 634 }
454 return GNUNET_OK; 635 return GNUNET_OK;
455} 636}
637
638void
639RECLAIM_TICKETS_deinit (void)
640{
641 if (NULL != nsh)
642 GNUNET_NAMESTORE_disconnect (nsh);
643 nsh = NULL;
644}
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h
index 7ad86dba5..81455fe53 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.h
+++ b/src/reclaim/gnunet-service-reclaim_tickets.h
@@ -30,6 +30,19 @@
30#include "gnunet_signatures.h" 30#include "gnunet_signatures.h"
31#include "reclaim.h" 31#include "reclaim.h"
32 32
33struct RECLAIM_TICKETS_Iterator;
34
35/**
36 * Continuation called with ticket.
37 *
38 * @param cls closure
39 * @param ticket the ticket
40 */
41typedef void
42(*RECLAIM_TICKETS_TicketIter) (void *cls,
43 struct GNUNET_RECLAIM_Ticket *ticket);
44
45
33/** 46/**
34 * Continuation called with ticket. 47 * Continuation called with ticket.
35 * 48 *
@@ -59,5 +72,23 @@ RECLAIM_TICKETS_issue_ticket (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identi
59 RECLAIM_TICKETS_TicketResult cb, 72 RECLAIM_TICKETS_TicketResult cb,
60 void* cb_cls); 73 void* cb_cls);
61 74
75void
76RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter);
77
78
79void
80RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter);
81
82
83struct RECLAIM_TICKETS_Iterator*
84RECLAIM_TICKETS_iteration_start (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
85 RECLAIM_TICKETS_TicketIter cb,
86 void* cb_cls);
87
88
62int 89int
63RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c); 90RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c);
91
92void
93RECLAIM_TICKETS_deinit (void);
94
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index 38f32426a..cff12c6e4 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -76,7 +76,7 @@ struct AttributeStoreResultMessage
76 * Message header 76 * Message header
77 */ 77 */
78 struct GNUNET_MessageHeader header; 78 struct GNUNET_MessageHeader header;
79 79
80 /** 80 /**
81 * Unique identifier for this request (for key collisions). 81 * Unique identifier for this request (for key collisions).
82 */ 82 */
@@ -201,12 +201,8 @@ struct TicketIterationStartMessage
201 /** 201 /**
202 * Identity. 202 * Identity.
203 */ 203 */
204 struct GNUNET_CRYPTO_EcdsaPublicKey identity; 204 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
205 205
206 /**
207 * Identity is audience or issuer
208 */
209 uint32_t is_audience GNUNET_PACKED;
210}; 206};
211 207
212 208
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index c8fde121b..dd6a249b5 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -1192,69 +1192,6 @@ GNUNET_RECLAIM_ticket_iteration_start (struct GNUNET_RECLAIM_Handle *h,
1192 void *finish_cb_cls) 1192 void *finish_cb_cls)
1193{ 1193{
1194 struct GNUNET_RECLAIM_TicketIterator *it; 1194 struct GNUNET_RECLAIM_TicketIterator *it;
1195 struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub;
1196 struct GNUNET_MQ_Envelope *env;
1197 struct TicketIterationStartMessage *msg;
1198 uint32_t rid;
1199
1200 GNUNET_CRYPTO_ecdsa_key_get_public (identity,
1201 &identity_pub);
1202 rid = h->r_id_gen++;
1203 it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator);
1204 it->h = h;
1205 it->error_cb = error_cb;
1206 it->error_cb_cls = error_cb_cls;
1207 it->finish_cb = finish_cb;
1208 it->finish_cb_cls = finish_cb_cls;
1209 it->tr_cb = proc;
1210 it->cls = proc_cls;
1211 it->r_id = rid;
1212 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head,
1213 h->ticket_it_tail,
1214 it);
1215 env = GNUNET_MQ_msg (msg,
1216 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START);
1217 msg->id = htonl (rid);
1218 msg->identity = identity_pub;
1219 msg->is_audience = htonl (GNUNET_NO);
1220 if (NULL == h->mq)
1221 it->env = env;
1222 else
1223 GNUNET_MQ_send (h->mq,
1224 env);
1225 return it;
1226
1227}
1228
1229
1230/**
1231 * Lists all tickets that have been issued to remote
1232 * identites (relying parties)
1233 *
1234 * @param h the reclaim to use
1235 * @param identity the issuing identity
1236 * @param error_cb function to call on error (i.e. disconnect),
1237 * the handle is afterwards invalid
1238 * @param error_cb_cls closure for @a error_cb
1239 * @param proc function to call on each ticket; it
1240 * will be called repeatedly with a value (if available)
1241 * @param proc_cls closure for @a proc
1242 * @param finish_cb function to call on completion
1243 * the handle is afterwards invalid
1244 * @param finish_cb_cls closure for @a finish_cb
1245 * @return an iterator handle to use for iteration
1246 */
1247struct GNUNET_RECLAIM_TicketIterator *
1248GNUNET_RECLAIM_ticket_iteration_start_rp (struct GNUNET_RECLAIM_Handle *h,
1249 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1250 GNUNET_SCHEDULER_TaskCallback error_cb,
1251 void *error_cb_cls,
1252 GNUNET_RECLAIM_TicketCallback proc,
1253 void *proc_cls,
1254 GNUNET_SCHEDULER_TaskCallback finish_cb,
1255 void *finish_cb_cls)
1256{
1257 struct GNUNET_RECLAIM_TicketIterator *it;
1258 struct GNUNET_MQ_Envelope *env; 1195 struct GNUNET_MQ_Envelope *env;
1259 struct TicketIterationStartMessage *msg; 1196 struct TicketIterationStartMessage *msg;
1260 uint32_t rid; 1197 uint32_t rid;
@@ -1276,7 +1213,6 @@ GNUNET_RECLAIM_ticket_iteration_start_rp (struct GNUNET_RECLAIM_Handle *h,
1276 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); 1213 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START);
1277 msg->id = htonl (rid); 1214 msg->id = htonl (rid);
1278 msg->identity = *identity; 1215 msg->identity = *identity;
1279 msg->is_audience = htonl (GNUNET_YES);
1280 if (NULL == h->mq) 1216 if (NULL == h->mq)
1281 it->env = env; 1217 it->env = env;
1282 else 1218 else
@@ -1284,9 +1220,9 @@ GNUNET_RECLAIM_ticket_iteration_start_rp (struct GNUNET_RECLAIM_Handle *h,
1284 env); 1220 env);
1285 return it; 1221 return it;
1286 1222
1287
1288} 1223}
1289 1224
1225
1290/** 1226/**
1291 * Calls the record processor specified in #GNUNET_RECLAIM_ticket_iteration_start 1227 * Calls the record processor specified in #GNUNET_RECLAIM_ticket_iteration_start
1292 * for the next record. 1228 * for the next record.