gnunet-service-reclaim_tickets.h 6.5 KB

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