2 This file is part of GNUnet.
3 Copyright (C) 2012-2015 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Martin Schanzenbach
23 * @file src/reclaim/gnunet-service-reclaim_tickets.h
24 * @brief reclaim tickets
28 #ifndef GNUNET_SERVICE_RECLAIM_TICKETS_H
29 #define GNUNET_SERVICE_RECLAIM_TICKETS_H
33 #include "gnunet_util_lib.h"
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_attribute_lib.h"
40 #include "gnunet_reclaim_service.h"
41 #include "gnunet_signatures.h"
42 #include "gnunet_statistics_service.h"
48 struct RECLAIM_TICKETS_Iterator;
52 * Handle to a consume operation
54 struct RECLAIM_TICKETS_ConsumeHandle;
58 * Ticket revocation request handle
60 struct RECLAIM_TICKETS_RevokeHandle;
66 struct TicketRecordsEntry
71 struct TicketRecordsEntry *next;
76 struct TicketRecordsEntry *prev;
81 unsigned int rd_count;
101 * Continuation called with ticket.
104 * @param ticket the ticket
106 typedef void (*RECLAIM_TICKETS_TicketIter) (
108 struct GNUNET_RECLAIM_Ticket *ticket);
112 * Continuation called with ticket.
115 * @param ticket the ticket
116 * @param success #GNUNET_SYSERR on failure (including timeout/queue
117 * drop/failure to validate) #GNUNET_OK on success
118 * @param emsg NULL on success, otherwise an error message
120 typedef void (*RECLAIM_TICKETS_TicketResult) (
122 struct GNUNET_RECLAIM_Ticket *ticket,
131 * @param identity the issuer of the ticket/attributes
132 * @param l attribute list retrieved through ticket
133 * @param success GNUNET_OK on success
134 * @param emsg error message (NULL on success)
136 typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
138 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
139 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l,
145 * Revocation callback.
148 * @param success GNUNET_OK on success
150 typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success);
155 * We start by looking up attribute references in order
156 * to change attribute IDs.
158 * @param ticket ticket to revoke
159 * @param identity private key of issuer
160 * @param cb revocation status callback
161 * @param cb_cls callback closure
162 * @return handle to the operation
164 struct RECLAIM_TICKETS_RevokeHandle *
165 RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
166 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
167 RECLAIM_TICKETS_RevokeCallback cb,
172 * Cancel a revocation.
174 * @param rh handle to the operation
177 RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh);
182 * We first looking attribute references under the label
185 * @param id the audience of the ticket
186 * @param ticket the ticket to consume
187 * @param cb callback to call with attributes of ticket
188 * @param cb_cls callback closure
189 * @return handle to the operation
191 struct RECLAIM_TICKETS_ConsumeHandle *
192 RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
193 const struct GNUNET_RECLAIM_Ticket *ticket,
194 RECLAIM_TICKETS_ConsumeCallback cb,
199 * Cancel a consume operation
201 * @param cth the operation to cancel
204 RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
208 * Issue a new reclaim ticket, thereby authorizing
209 * the audience to access the set of provided attributes.
211 * @param identity the issuer
212 * @param attrs the attributes to share
213 * @param audience the audience to share the attributes with
214 * @param cb the callback to call with the ticket result
215 * @param cb_cls the callback closure
216 * FIXME: Return handle??
219 RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
220 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
221 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
222 RECLAIM_TICKETS_TicketResult cb,
227 * Continue ticket iteration
229 * @param iter the iteration to continue
232 RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter);
236 * Stop a running ticket iteration
238 * @param iter iteration to cancel
241 RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter);
245 * Iterate over all tickets issued by an identity
247 * @param identity the issuing identity
248 * @param cb ticket callback function
249 * @param cb_cls callback closure
250 * @return a handle to the iteration
252 struct RECLAIM_TICKETS_Iterator *
253 RECLAIM_TICKETS_iteration_start (
254 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
255 RECLAIM_TICKETS_TicketIter cb,
260 * Initialize tickets component
262 * @param c the configuration
263 * @return GNUNET_SYSERR on error
266 RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c);
270 * Close handles and clean up.
271 * FIXME: cancel all pending operations (gns, ns etc)
274 RECLAIM_TICKETS_deinit (void);