psycstore: add option to perform membership test when retrieving fragment or message
[oweals/gnunet.git] / src / psycstore / psycstore.h
1 /*
2  * This file is part of GNUnet
3  * (C) 2013 Christian Grothoff (and other contributing authors)
4  *
5  * GNUnet is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 3, or (at your
8  * 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  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with GNUnet; see the file COPYING.  If not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file psycstore/psycstore.h
23  * @brief Common type definitions for the PSYCstore service and API.
24  * @author Gabor X Toth
25  */
26
27 #ifndef GNUNET_PSYCSTORE_H
28 #define GNUNET_PSYCSTORE_H
29
30 #include "gnunet_common.h"
31
32
33 GNUNET_NETWORK_STRUCT_BEGIN
34
35 /**
36  * Answer from service to client about last operation.
37  */
38 struct OperationResult
39 {
40   /**
41    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
42    */
43   struct GNUNET_MessageHeader header;
44
45   /**
46    * Operation ID.
47    */
48   uint32_t op_id GNUNET_PACKED;
49
50   /**
51    * Status code for the operation.
52    */
53   int64_t result_code GNUNET_PACKED;
54
55   /* followed by 0-terminated error message (on error) */
56
57 };
58
59
60 /**
61  * Answer from service to client about master counters.
62  *
63  * @see GNUNET_PSYCSTORE_counters_get()
64  */
65 struct CountersResult
66 {
67   /**
68    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS
69    */
70   struct GNUNET_MessageHeader header;
71
72   /**
73    * Operation ID.
74    */
75   uint32_t op_id GNUNET_PACKED;
76
77   uint64_t max_fragment_id GNUNET_PACKED;
78
79   uint64_t max_message_id GNUNET_PACKED;
80
81   uint64_t max_group_generation GNUNET_PACKED;
82
83   uint64_t max_state_message_id GNUNET_PACKED;
84
85   /**
86    * Status code for the operation:
87    * #GNUNET_OK: success, counter values are returned.
88    * #GNUNET_NO: no message has been sent to the channel yet.
89    * #GNUNET_SYSERR: an error occurred.
90    */
91   int32_t result_code GNUNET_PACKED;
92 };
93
94
95 /**
96  * Answer from service to client containing a message fragment.
97  */
98 struct FragmentResult
99 {
100   /**
101    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
102    */
103   struct GNUNET_MessageHeader header;
104
105   /**
106    * Operation ID.
107    */
108   uint32_t op_id GNUNET_PACKED;
109
110   uint32_t psycstore_flags GNUNET_PACKED;
111
112   /* followed by GNUNET_MULTICAST_MessageHeader */
113
114 };
115
116
117 /**
118  * Answer from service to client containing a state variable.
119  */
120 struct StateResult
121 {
122   /**
123    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
124    */
125   struct GNUNET_MessageHeader header;
126
127   /**
128    * Operation ID.
129    */
130   uint32_t op_id GNUNET_PACKED;
131
132   uint16_t name_size  GNUNET_PACKED;
133
134   /* followed by name and value */
135 };
136
137
138 /**
139  * Generic operation request.
140  */
141 struct OperationRequest
142 {
143   struct GNUNET_MessageHeader header;
144
145   /**
146    * Operation ID.
147    */
148   uint32_t op_id GNUNET_PACKED;
149
150   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
151
152 };
153
154
155 /**
156  * @see GNUNET_PSYCSTORE_membership_store()
157  */
158 struct MembershipStoreRequest
159 {
160   /**
161    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE
162    */
163   struct GNUNET_MessageHeader header;
164
165   /**
166    * Operation ID.
167    */
168   uint32_t op_id GNUNET_PACKED;
169
170   /**
171    * Channel's public key.
172    */
173   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
174
175   /**
176    * Slave's public key.
177    */
178   struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
179
180   uint64_t announced_at GNUNET_PACKED;
181   uint64_t effective_since GNUNET_PACKED;
182   uint64_t group_generation GNUNET_PACKED;
183   int did_join GNUNET_PACKED;
184 };
185
186
187 /**
188  * @see GNUNET_PSYCSTORE_membership_test()
189  */
190 struct MembershipTestRequest
191 {
192   /**
193    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST
194    */
195   struct GNUNET_MessageHeader header;
196
197   /**
198    * Operation ID.
199    */
200   uint32_t op_id GNUNET_PACKED;
201
202   /**
203    * Channel's public key.
204    */
205   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
206
207   /**
208    * Slave's public key.
209    */
210   struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
211
212   uint64_t message_id GNUNET_PACKED;
213
214   uint64_t group_generation GNUNET_PACKED;
215 };
216
217
218 /**
219  * @see GNUNET_PSYCSTORE_fragment_store()
220  */
221 struct FragmentStoreRequest
222 {
223   /**
224    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE
225    */
226   struct GNUNET_MessageHeader header;
227
228   /**
229    * Operation ID.
230    */
231   uint32_t op_id GNUNET_PACKED;
232
233   /**
234    * Channel's public key.
235    */
236   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
237
238   /**
239    * enum GNUNET_PSYCSTORE_MessageFlags
240    */
241   uint32_t psycstore_flags GNUNET_PACKED;
242
243   /* Followed by fragment */
244 };
245
246
247 /**
248  * @see GNUNET_PSYCSTORE_fragment_get()
249  */
250 struct FragmentGetRequest
251 {
252   /**
253    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET
254    */
255   struct GNUNET_MessageHeader header;
256
257   /**
258    * Operation ID.
259    */
260   uint32_t op_id GNUNET_PACKED;
261
262   /**
263    * Channel's public key.
264    */
265   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
266
267   /**
268    * Slave's public key.
269    */
270   struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
271
272   /**
273    * Fragment ID to request.
274    */
275   uint64_t fragment_id GNUNET_PACKED;
276
277   /**
278    * Do membership test with @a slave_key before returning fragment?
279    * #GNUNET_YES or #GNUNET_NO
280    */
281   uint8_t do_membership_test;
282 };
283
284
285 /**
286  * @see GNUNET_PSYCSTORE_message_get()
287  */
288 struct MessageGetRequest
289 {
290   /**
291    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET
292    */
293   struct GNUNET_MessageHeader header;
294
295   /**
296    * Operation ID.
297    */
298   uint32_t op_id GNUNET_PACKED;
299
300   /**
301    * Channel's public key.
302    */
303   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
304
305   /**
306    * Slave's public key.
307    */
308   struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
309
310   /**
311    * Message ID to request.
312    */
313   uint64_t message_id GNUNET_PACKED;
314
315   /**
316    * Do membership test with @a slave_key before returning fragment?
317    * #GNUNET_YES or #GNUNET_NO
318    */
319   uint8_t do_membership_test;
320 };
321
322
323 /**
324  * @see GNUNET_PSYCSTORE_message_get_fragment()
325  */
326 struct MessageGetFragmentRequest
327 {
328   /**
329    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_FRAGMENT_GET
330    */
331   struct GNUNET_MessageHeader header;
332
333   /**
334    * Operation ID.
335    */
336   uint32_t op_id GNUNET_PACKED;
337
338   /**
339    * Channel's public key.
340    */
341   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
342
343   /**
344    * Slave's public key.
345    */
346   struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
347
348   /**
349    * Requested message ID.
350    */
351   uint64_t message_id GNUNET_PACKED;
352
353   /**
354    * Requested fragment offset.
355    */
356   uint64_t fragment_offset GNUNET_PACKED;
357
358   /**
359    * Do membership test with @a slave_key before returning fragment?
360    * #GNUNET_YES or #GNUNET_NO
361    */
362   uint8_t do_membership_test;
363 };
364
365
366 /**
367  * @see GNUNET_PSYCSTORE_state_hash_update()
368  */
369 struct StateHashUpdateRequest
370 {
371   /**
372    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE
373    */
374   struct GNUNET_MessageHeader header;
375
376   /**
377    * Operation ID.
378    */
379   uint32_t op_id GNUNET_PACKED;
380
381   /**
382    * Channel's public key.
383    */
384   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
385
386   struct GNUNET_HashCode hash;
387 };
388
389
390 enum StateOpFlags
391 {
392   STATE_OP_FIRST = 1 << 0,
393   STATE_OP_LAST = 1 << 1
394 };
395
396
397 /**
398  * @see GNUNET_PSYCSTORE_state_modify()
399  */
400 struct StateModifyRequest
401 {
402   /**
403    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY
404    */
405   struct GNUNET_MessageHeader header;
406
407   /**
408    * Operation ID.
409    */
410   uint32_t op_id GNUNET_PACKED;
411
412   /**
413    * Channel's public key.
414    */
415   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
416
417   uint64_t message_id GNUNET_PACKED;
418
419   uint64_t state_delta GNUNET_PACKED;
420
421   /**
422    * Size of name, including NUL terminator.
423    */
424   uint16_t name_size GNUNET_PACKED;
425
426   /**
427    * OR'd StateOpFlags
428    */
429   uint8_t flags;
430
431   /**
432    * enum GNUNET_ENV_Operator
433    */
434   uint8_t oper;
435
436   /* Followed by NUL-terminated name, then the value. */
437 };
438
439
440 /**
441  * @see GNUNET_PSYCSTORE_state_sync()
442  */
443 struct StateSyncRequest
444 {
445   /**
446    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC
447    */
448   struct GNUNET_MessageHeader header;
449
450   /**
451    * Operation ID.
452    */
453   uint32_t op_id GNUNET_PACKED;
454
455   /**
456    * Channel's public key.
457    */
458   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
459
460   uint64_t message_id GNUNET_PACKED;
461
462   /**
463    * Size of name, including NUL terminator.
464    */
465   uint16_t name_size GNUNET_PACKED;
466
467   /**
468    * OR'd StateOpFlags
469    */
470   uint8_t flags;
471
472   /* Followed by NUL-terminated name, then the value. */
473 };
474
475
476 GNUNET_NETWORK_STRUCT_END
477
478 #endif