PSYC(store), Multicast: use ECDSA slave/member keys; PSYC: add GNUNET_PSYC_message_cr...
[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   uint64_t fragment_id GNUNET_PACKED;
268 };
269
270
271 /**
272  * @see GNUNET_PSYCSTORE_message_get()
273  */
274 struct MessageGetRequest
275 {
276   /**
277    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET
278    */
279   struct GNUNET_MessageHeader header;
280
281   /**
282    * Operation ID.
283    */
284   uint32_t op_id GNUNET_PACKED;
285
286   /**
287    * Channel's public key.
288    */
289   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
290
291   uint64_t message_id GNUNET_PACKED;
292 };
293
294
295 /**
296  * @see GNUNET_PSYCSTORE_message_get_fragment()
297  */
298 struct MessageGetFragmentRequest
299 {
300   /**
301    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_FRAGMENT_GET
302    */
303   struct GNUNET_MessageHeader header;
304
305   /**
306    * Operation ID.
307    */
308   uint32_t op_id GNUNET_PACKED;
309
310   /**
311    * Channel's public key.
312    */
313   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
314
315   uint64_t message_id GNUNET_PACKED;
316
317   uint64_t fragment_offset GNUNET_PACKED;
318 };
319
320
321 /**
322  * @see GNUNET_PSYCSTORE_state_hash_update()
323  */
324 struct StateHashUpdateRequest
325 {
326   /**
327    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE
328    */
329   struct GNUNET_MessageHeader header;
330
331   /**
332    * Operation ID.
333    */
334   uint32_t op_id GNUNET_PACKED;
335
336   /**
337    * Channel's public key.
338    */
339   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
340
341   struct GNUNET_HashCode hash;
342 };
343
344
345 enum StateOpFlags
346 {
347   STATE_OP_FIRST = 1 << 0,
348   STATE_OP_LAST = 1 << 1
349 };
350
351
352 /**
353  * @see GNUNET_PSYCSTORE_state_modify()
354  */
355 struct StateModifyRequest
356 {
357   /**
358    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY
359    */
360   struct GNUNET_MessageHeader header;
361
362   /**
363    * Operation ID.
364    */
365   uint32_t op_id GNUNET_PACKED;
366
367   /**
368    * Channel's public key.
369    */
370   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
371
372   uint64_t message_id GNUNET_PACKED;
373
374   uint64_t state_delta GNUNET_PACKED;
375
376   /**
377    * Size of name, including NUL terminator.
378    */
379   uint16_t name_size GNUNET_PACKED;
380
381   /**
382    * OR'd StateOpFlags
383    */
384   uint8_t flags;
385
386   /**
387    * enum GNUNET_ENV_Operator
388    */
389   uint8_t oper;
390
391   /* Followed by NUL-terminated name, then the value. */
392 };
393
394
395 /**
396  * @see GNUNET_PSYCSTORE_state_sync()
397  */
398 struct StateSyncRequest
399 {
400   /**
401    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC
402    */
403   struct GNUNET_MessageHeader header;
404
405   /**
406    * Operation ID.
407    */
408   uint32_t op_id GNUNET_PACKED;
409
410   /**
411    * Channel's public key.
412    */
413   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
414
415   uint64_t message_id GNUNET_PACKED;
416
417   /**
418    * Size of name, including NUL terminator.
419    */
420   uint16_t name_size GNUNET_PACKED;
421
422   /**
423    * OR'd StateOpFlags
424    */
425   uint8_t flags;
426
427   /* Followed by NUL-terminated name, then the value. */
428 };
429
430
431 GNUNET_NETWORK_STRUCT_END
432
433 #endif