aboutsummaryrefslogtreecommitdiff
path: root/src/service/reclaim/gnunet-service-reclaim_tickets.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/reclaim/gnunet-service-reclaim_tickets.h')
-rw-r--r--src/service/reclaim/gnunet-service-reclaim_tickets.h282
1 files changed, 282 insertions, 0 deletions
diff --git a/src/service/reclaim/gnunet-service-reclaim_tickets.h b/src/service/reclaim/gnunet-service-reclaim_tickets.h
new file mode 100644
index 000000000..b425a3dba
--- /dev/null
+++ b/src/service/reclaim/gnunet-service-reclaim_tickets.h
@@ -0,0 +1,282 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012-2015 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @author Martin Schanzenbach
23 * @file src/reclaim/gnunet-service-reclaim_tickets.h
24 * @brief reclaim tickets
25 *
26 */
27
28#ifndef GNUNET_SERVICE_RECLAIM_TICKETS_H
29#define GNUNET_SERVICE_RECLAIM_TICKETS_H
30
31#include "platform.h"
32
33#include "gnunet_util_lib.h"
34
35#include "gnunet_constants.h"
36#include "gnunet_gns_service.h"
37#include "gnunet_gnsrecord_lib.h"
38#include "gnunet_protocols.h"
39#include "gnunet_reclaim_lib.h"
40#include "gnunet_reclaim_service.h"
41#include "gnunet_signatures.h"
42#include "gnunet_statistics_service.h"
43#include "reclaim.h"
44
45/**
46 * Ticket iterator
47 */
48struct RECLAIM_TICKETS_Iterator;
49
50
51/**
52 * Handle to a consume operation
53 */
54struct RECLAIM_TICKETS_ConsumeHandle;
55
56
57/**
58 * Ticket revocation request handle
59 */
60struct RECLAIM_TICKETS_RevokeHandle;
61
62
63/**
64 * List of tickets
65 */
66struct TicketRecordsEntry
67{
68 /**
69 * DLL
70 */
71 struct TicketRecordsEntry *next;
72
73 /**
74 * DLL
75 */
76 struct TicketRecordsEntry *prev;
77
78 /**
79 * Record count
80 */
81 unsigned int rd_count;
82
83 /**
84 * Data
85 */
86 char *data;
87
88 /**
89 * Data size
90 */
91 size_t data_size;
92
93 /**
94 * Label
95 */
96 char *label;
97};
98
99
100/**
101 * Continuation called with ticket.
102 *
103 * @param cls closure
104 * @param ticket the ticket
105 * @param rp_uri the RP URI associated with the ticket
106 */
107typedef void (*RECLAIM_TICKETS_TicketIter) (
108 void *cls,
109 struct GNUNET_RECLAIM_Ticket *ticket,
110 const char* rp_uri);
111
112
113/**
114 * Continuation called with ticket.
115 *
116 * @param cls closure
117 * @param ticket the ticket
118 * @param presentations new presentations for ticket (NULL on error)
119 * @param success #GNUNET_SYSERR on failure (including timeout/queue
120 * drop/failure to validate) #GNUNET_OK on success
121 * @param emsg NULL on success, otherwise an error message
122 */
123typedef void (*RECLAIM_TICKETS_TicketResult) (
124 void *cls,
125 struct GNUNET_RECLAIM_Ticket *ticket,
126 struct GNUNET_RECLAIM_PresentationList *presentations,
127 int32_t success,
128 const char *emsg);
129
130
131/**
132 * Consume callback.
133 *
134 * @param cls closure
135 * @param identity the issuer of the ticket/attributes
136 * @param attributes attribute list retrieved through ticket
137 * @param presentations attribute presentations (may be NULL)
138 * @param success GNUNET_OK on success
139 * @param emsg error message (NULL on success)
140 */
141typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
142 void *cls,
143 const struct GNUNET_CRYPTO_PublicKey *identity,
144 const struct GNUNET_RECLAIM_AttributeList *attributes,
145 const struct GNUNET_RECLAIM_PresentationList *presentations,
146 int32_t success,
147 const char *emsg);
148
149
150/**
151 * Revocation callback.
152 *
153 * @param cls closure
154 * @param success GNUNET_OK on success
155 */
156typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success);
157
158
159/**
160 * Revoke a ticket.
161 * We start by looking up attribute references in order
162 * to change attribute IDs.
163 *
164 * @param ticket ticket to revoke
165 * @param identity private key of issuer
166 * @param cb revocation status callback
167 * @param cb_cls callback closure
168 * @return handle to the operation
169 */
170struct RECLAIM_TICKETS_RevokeHandle *
171RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
172 const struct GNUNET_CRYPTO_PrivateKey *identity,
173 RECLAIM_TICKETS_RevokeCallback cb,
174 void *cb_cls);
175
176
177/**
178 * Cancel a revocation.
179 *
180 * @param rh handle to the operation
181 */
182void
183RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh);
184
185
186/**
187 * Consume a ticket.
188 * We first looking attribute references under the label
189 * ticket.rnd in GNS.
190 *
191 * @param ticket the ticket to consume
192 * @param rp_uri the expected RP URI
193 * @param cb callback to call with attributes of ticket
194 * @param cb_cls callback closure
195 * @return handle to the operation
196 */
197struct RECLAIM_TICKETS_ConsumeHandle *
198RECLAIM_TICKETS_consume (const struct GNUNET_RECLAIM_Ticket *ticket,
199 const char *rp_uri,
200 RECLAIM_TICKETS_ConsumeCallback cb,
201 void *cb_cls);
202
203
204/**
205 * Cancel a consume operation
206 *
207 * @param cth the operation to cancel
208 */
209void
210RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
211
212
213/**
214 * Issue a new reclaim ticket, thereby authorizing
215 * the audience to access the set of provided attributes.
216 *
217 * @param identity the issuer
218 * @param attrs the attributes to share
219 * @param rp the RP URI
220 * @param cb the callback to call with the ticket result
221 * @param cb_cls the callback closure
222 * FIXME: Return handle??
223 */
224void
225RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_PrivateKey *identity,
226 const struct GNUNET_RECLAIM_AttributeList *attrs,
227 const char *rp,
228 RECLAIM_TICKETS_TicketResult cb,
229 void *cb_cls);
230
231
232/**
233 * Continue ticket iteration
234 *
235 * @param iter the iteration to continue
236 */
237void
238RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter);
239
240
241/**
242 * Stop a running ticket iteration
243 *
244 * @param iter iteration to cancel
245 */
246void
247RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter);
248
249
250/**
251 * Iterate over all tickets issued by an identity
252 *
253 * @param identity the issuing identity
254 * @param cb ticket callback function
255 * @param cb_cls callback closure
256 * @return a handle to the iteration
257 */
258struct RECLAIM_TICKETS_Iterator *
259RECLAIM_TICKETS_iteration_start (
260 const struct GNUNET_CRYPTO_PrivateKey *identity,
261 RECLAIM_TICKETS_TicketIter cb,
262 void *cb_cls);
263
264
265/**
266 * Initialize tickets component
267 *
268 * @param c the configuration
269 * @return GNUNET_SYSERR on error
270 */
271int
272RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c);
273
274
275/**
276 * Close handles and clean up.
277 * FIXME: cancel all pending operations (gns, ns etc)
278 */
279void
280RECLAIM_TICKETS_deinit (void);
281
282#endif