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