diff options
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.h')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.h | 139 |
1 files changed, 128 insertions, 11 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h index 6e69355fa..05f834b1e 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.h +++ b/src/reclaim/gnunet-service-reclaim_tickets.h | |||
@@ -42,11 +42,27 @@ | |||
42 | #include "gnunet_statistics_service.h" | 42 | #include "gnunet_statistics_service.h" |
43 | #include "reclaim.h" | 43 | #include "reclaim.h" |
44 | 44 | ||
45 | /** | ||
46 | * Ticket iterator | ||
47 | */ | ||
45 | struct RECLAIM_TICKETS_Iterator; | 48 | struct RECLAIM_TICKETS_Iterator; |
49 | |||
50 | |||
51 | /** | ||
52 | * Handle to a consume operation | ||
53 | */ | ||
46 | struct RECLAIM_TICKETS_ConsumeHandle; | 54 | struct RECLAIM_TICKETS_ConsumeHandle; |
55 | |||
56 | |||
57 | /** | ||
58 | * Ticket revocation request handle | ||
59 | */ | ||
47 | struct RECLAIM_TICKETS_RevokeHandle; | 60 | struct RECLAIM_TICKETS_RevokeHandle; |
48 | 61 | ||
49 | 62 | ||
63 | /** | ||
64 | * List of tickets | ||
65 | */ | ||
50 | struct TicketRecordsEntry | 66 | struct TicketRecordsEntry |
51 | { | 67 | { |
52 | /** | 68 | /** |
@@ -88,7 +104,8 @@ struct TicketRecordsEntry | |||
88 | * @param ticket the ticket | 104 | * @param ticket the ticket |
89 | */ | 105 | */ |
90 | typedef void (*RECLAIM_TICKETS_TicketIter) ( | 106 | typedef void (*RECLAIM_TICKETS_TicketIter) ( |
91 | void *cls, struct GNUNET_RECLAIM_Ticket *ticket); | 107 | void *cls, |
108 | struct GNUNET_RECLAIM_Ticket *ticket); | ||
92 | 109 | ||
93 | 110 | ||
94 | /** | 111 | /** |
@@ -101,59 +118,159 @@ typedef void (*RECLAIM_TICKETS_TicketIter) ( | |||
101 | * @param emsg NULL on success, otherwise an error message | 118 | * @param emsg NULL on success, otherwise an error message |
102 | */ | 119 | */ |
103 | typedef void (*RECLAIM_TICKETS_TicketResult) ( | 120 | typedef void (*RECLAIM_TICKETS_TicketResult) ( |
104 | void *cls, struct GNUNET_RECLAIM_Ticket *ticket, int32_t success, | 121 | void *cls, |
105 | const char *emsg); | 122 | struct GNUNET_RECLAIM_Ticket *ticket, |
123 | int32_t success, | ||
124 | const char *emsg); | ||
106 | 125 | ||
107 | 126 | ||
127 | /** | ||
128 | * Consume callback. | ||
129 | * | ||
130 | * @param cls closure | ||
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) | ||
135 | */ | ||
108 | typedef void (*RECLAIM_TICKETS_ConsumeCallback) ( | 136 | typedef void (*RECLAIM_TICKETS_ConsumeCallback) ( |
109 | void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 137 | void *cls, |
110 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l, int32_t success, | 138 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
111 | const char *emsg); | 139 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l, |
140 | int32_t success, | ||
141 | const char *emsg); | ||
112 | 142 | ||
113 | 143 | ||
144 | /** | ||
145 | * Revocation callback. | ||
146 | * | ||
147 | * @param cls closure | ||
148 | * @param success GNUNET_OK on success | ||
149 | */ | ||
114 | typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success); | 150 | typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success); |
115 | 151 | ||
152 | |||
153 | /** | ||
154 | * Revoke a ticket. | ||
155 | * We start by looking up attribute references in order | ||
156 | * to change attribute IDs. | ||
157 | * | ||
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 | ||
163 | */ | ||
116 | struct RECLAIM_TICKETS_RevokeHandle * | 164 | struct RECLAIM_TICKETS_RevokeHandle * |
117 | RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, | 165 | RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, |
118 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 166 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
119 | RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls); | 167 | RECLAIM_TICKETS_RevokeCallback cb, |
168 | void *cb_cls); | ||
120 | 169 | ||
121 | 170 | ||
171 | /** | ||
172 | * Cancel a revocation. | ||
173 | * | ||
174 | * @param rh handle to the operation | ||
175 | */ | ||
122 | void | 176 | void |
123 | RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh); | 177 | RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh); |
124 | 178 | ||
125 | 179 | ||
180 | /** | ||
181 | * Consume a ticket. | ||
182 | * We first looking attribute references under the label | ||
183 | * ticket.rnd in GNS. | ||
184 | * | ||
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 | ||
190 | */ | ||
126 | struct RECLAIM_TICKETS_ConsumeHandle * | 191 | struct RECLAIM_TICKETS_ConsumeHandle * |
127 | RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | 192 | RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, |
128 | const struct GNUNET_RECLAIM_Ticket *ticket, | 193 | const struct GNUNET_RECLAIM_Ticket *ticket, |
129 | RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls); | 194 | RECLAIM_TICKETS_ConsumeCallback cb, |
195 | void *cb_cls); | ||
130 | 196 | ||
197 | |||
198 | /** | ||
199 | * Cancel a consume operation | ||
200 | * | ||
201 | * @param cth the operation to cancel | ||
202 | */ | ||
131 | void | 203 | void |
132 | RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth); | 204 | RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth); |
133 | 205 | ||
206 | |||
207 | /** | ||
208 | * Issue a new reclaim ticket, thereby authorizing | ||
209 | * the audience to access the set of provided attributes. | ||
210 | * | ||
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?? | ||
217 | */ | ||
134 | void | 218 | void |
135 | RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 219 | RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
136 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 220 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
137 | const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | 221 | const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, |
138 | RECLAIM_TICKETS_TicketResult cb, void *cb_cls); | 222 | RECLAIM_TICKETS_TicketResult cb, |
223 | void *cb_cls); | ||
224 | |||
139 | 225 | ||
226 | /** | ||
227 | * Continue ticket iteration | ||
228 | * | ||
229 | * @param iter the iteration to continue | ||
230 | */ | ||
140 | void | 231 | void |
141 | RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter); | 232 | RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter); |
142 | 233 | ||
143 | 234 | ||
235 | /** | ||
236 | * Stop a running ticket iteration | ||
237 | * | ||
238 | * @param iter iteration to cancel | ||
239 | */ | ||
144 | void | 240 | void |
145 | RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter); | 241 | RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter); |
146 | 242 | ||
147 | 243 | ||
244 | /** | ||
245 | * Iterate over all tickets issued by an identity | ||
246 | * | ||
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 | ||
251 | */ | ||
148 | struct RECLAIM_TICKETS_Iterator * | 252 | struct RECLAIM_TICKETS_Iterator * |
149 | RECLAIM_TICKETS_iteration_start ( | 253 | RECLAIM_TICKETS_iteration_start ( |
150 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 254 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
151 | RECLAIM_TICKETS_TicketIter cb, void *cb_cls); | 255 | RECLAIM_TICKETS_TicketIter cb, |
256 | void *cb_cls); | ||
152 | 257 | ||
153 | 258 | ||
259 | /** | ||
260 | * Initialize tickets component | ||
261 | * | ||
262 | * @param c the configuration | ||
263 | * @return GNUNET_SYSERR on error | ||
264 | */ | ||
154 | int | 265 | int |
155 | RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c); | 266 | RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c); |
156 | 267 | ||
268 | |||
269 | /** | ||
270 | * Close handles and clean up. | ||
271 | * FIXME: cancel all pending operations (gns, ns etc) | ||
272 | */ | ||
157 | void | 273 | void |
158 | RECLAIM_TICKETS_deinit (void); | 274 | RECLAIM_TICKETS_deinit (void); |
275 | |||
159 | #endif | 276 | #endif |