do not check for existing egos...
[oweals/gnunet.git] / src / reclaim / gnunet-service-reclaim_tickets.h
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_namestore_service.h"
39 #include "gnunet_protocols.h"
40 #include "gnunet_reclaim_attribute_lib.h"
41 #include "gnunet_reclaim_service.h"
42 #include "gnunet_signatures.h"
43 #include "gnunet_statistics_service.h"
44 #include "reclaim.h"
45
46 struct RECLAIM_TICKETS_Iterator;
47 struct RECLAIM_TICKETS_ConsumeHandle;
48 struct RECLAIM_TICKETS_RevokeHandle;
49
50
51 struct TicketRecordsEntry
52 {
53   /**
54    * DLL
55    */
56   struct TicketRecordsEntry *next;
57
58   /**
59    * DLL
60    */
61   struct TicketRecordsEntry *prev;
62
63   /**
64    * Record count
65    */
66   unsigned int rd_count;
67
68   /**
69    * Data
70    */
71   char *data;
72
73   /**
74    * Data size
75    */
76   size_t data_size;
77
78   /**
79    * Label
80    */
81   char *label;
82 };
83
84
85 /**
86  * Continuation called with ticket.
87  *
88  * @param cls closure
89  * @param ticket the ticket
90  */
91 typedef void (*RECLAIM_TICKETS_TicketIter) (
92     void *cls, struct GNUNET_RECLAIM_Ticket *ticket);
93
94
95 /**
96  * Continuation called with ticket.
97  *
98  * @param cls closure
99  * @param ticket the ticket
100  * @param success #GNUNET_SYSERR on failure (including timeout/queue
101  * drop/failure to validate) #GNUNET_OK on success
102  * @param emsg NULL on success, otherwise an error message
103  */
104 typedef void (*RECLAIM_TICKETS_TicketResult) (
105     void *cls, struct GNUNET_RECLAIM_Ticket *ticket, int32_t success,
106     const char *emsg);
107
108
109 typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
110     void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
111     const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l, int32_t success,
112     const char *emsg);
113
114
115 typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success);
116
117 struct RECLAIM_TICKETS_RevokeHandle *
118 RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
119                         const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
120                         RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls);
121
122
123 void
124 RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh);
125
126
127 struct RECLAIM_TICKETS_ConsumeHandle *
128 RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
129                          const struct GNUNET_RECLAIM_Ticket *ticket,
130                          RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls);
131
132 void
133 RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
134
135 void
136 RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
137                        const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
138                        const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
139                        RECLAIM_TICKETS_TicketResult cb, void *cb_cls);
140
141 void
142 RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter);
143
144
145 void
146 RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter);
147
148
149 struct RECLAIM_TICKETS_Iterator *
150 RECLAIM_TICKETS_iteration_start (
151     const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
152     RECLAIM_TICKETS_TicketIter cb, void *cb_cls);
153
154
155 int
156 RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c);
157
158 void
159 RECLAIM_TICKETS_deinit (void);
160 #endif