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