psycstore: single counters function for master & slave
[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   /**
78    * Status code for the operation.
79    */
80   int64_t result_code 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   /**
103    * Operation ID.
104    */
105   uint32_t op_id GNUNET_PACKED;
106
107   uint32_t psycstore_flags GNUNET_PACKED;
108
109   /* followed by GNUNET_MULTICAST_MessageHeader */
110
111 };
112
113
114 /**
115  * Answer from service to client containing a state variable.
116  */
117 struct StateResult
118 {
119   /**
120    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
121    */
122   struct GNUNET_MessageHeader header;
123
124   /**
125    * Operation ID.
126    */
127   uint32_t op_id GNUNET_PACKED;
128
129   uint16_t name_size  GNUNET_PACKED;
130
131   /* followed by name and value */
132 };
133
134
135 /**
136  * Generic operation request.
137  */
138 struct OperationRequest
139 {
140   struct GNUNET_MessageHeader header;
141
142   /**
143    * Operation ID.
144    */
145   uint32_t op_id GNUNET_PACKED;
146
147   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
148
149 };
150
151
152 /**
153  * @see GNUNET_PSYCSTORE_membership_store()
154  */
155 struct MembershipStoreRequest
156 {
157   /**
158    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE
159    */
160   struct GNUNET_MessageHeader header;
161
162   /**
163    * Operation ID.
164    */
165   uint32_t op_id GNUNET_PACKED;
166
167   /**
168    * Channel's public key.
169    */
170   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
171
172   /**
173    * Slave's public key.
174    */
175   struct GNUNET_CRYPTO_EccPublicSignKey slave_key;
176
177   uint64_t announced_at GNUNET_PACKED;
178   uint64_t effective_since GNUNET_PACKED;
179   uint64_t group_generation GNUNET_PACKED;
180   int did_join GNUNET_PACKED;
181 };
182
183
184 /**
185  * @see GNUNET_PSYCSTORE_membership_test()
186  */
187 struct MembershipTestRequest
188 {
189   /**
190    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST
191    */
192   struct GNUNET_MessageHeader header;
193
194   /**
195    * Operation ID.
196    */
197   uint32_t op_id GNUNET_PACKED;
198
199   /**
200    * Channel's public key.
201    */
202   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
203
204   /**
205    * Slave's public key.
206    */
207   struct GNUNET_CRYPTO_EccPublicSignKey slave_key;
208
209   uint64_t message_id GNUNET_PACKED;
210
211   uint64_t group_generation GNUNET_PACKED;
212 };
213
214
215 /**
216  * @see GNUNET_PSYCSTORE_fragment_store()
217  */
218 struct FragmentStoreRequest
219 {
220   /**
221    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE
222    */
223   struct GNUNET_MessageHeader header;
224
225   /**
226    * Operation ID.
227    */
228   uint32_t op_id GNUNET_PACKED;
229
230   /**
231    * Channel's public key.
232    */
233   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
234
235   uint32_t psycstore_flags GNUNET_PACKED;
236 };
237
238
239 /**
240  * @see GNUNET_PSYCSTORE_fragment_get()
241  */
242 struct FragmentGetRequest
243 {
244   /**
245    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET
246    */
247   struct GNUNET_MessageHeader header;
248
249   /**
250    * Operation ID.
251    */
252   uint32_t op_id GNUNET_PACKED;
253
254   /**
255    * Channel's public key.
256    */
257   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
258
259   uint64_t fragment_id GNUNET_PACKED;
260 };
261
262
263 /**
264  * @see GNUNET_PSYCSTORE_message_get()
265  */
266 struct MessageGetRequest
267 {
268   /**
269    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET
270    */
271   struct GNUNET_MessageHeader header;
272
273   /**
274    * Operation ID.
275    */
276   uint32_t op_id GNUNET_PACKED;
277
278   /**
279    * Channel's public key.
280    */
281   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
282
283   uint64_t message_id GNUNET_PACKED;
284 };
285
286
287 /**
288  * @see GNUNET_PSYCSTORE_message_get_fragment()
289  */
290 struct MessageGetFragmentRequest
291 {
292   /**
293    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_FRAGMENT_GET
294    */
295   struct GNUNET_MessageHeader header;
296
297   /**
298    * Operation ID.
299    */
300   uint32_t op_id GNUNET_PACKED;
301
302   /**
303    * Channel's public key.
304    */
305   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
306
307   uint64_t message_id GNUNET_PACKED;
308
309   uint64_t fragment_offset GNUNET_PACKED;
310 };
311
312
313 /**
314  * @see GNUNET_PSYCSTORE_state_hash_update()
315  */
316 struct StateHashUpdateRequest
317 {
318   /**
319    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE
320    */
321   struct GNUNET_MessageHeader header;
322
323   /**
324    * Operation ID.
325    */
326   uint32_t op_id GNUNET_PACKED;
327
328   /**
329    * Channel's public key.
330    */
331   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
332
333   struct GNUNET_HashCode hash;
334 };
335
336 enum StateOpFlags
337 {
338   STATE_OP_FIRST = 1 << 0,
339   STATE_OP_LAST = 1 << 1
340 };
341
342 /**
343  * @see GNUNET_PSYCSTORE_state_modify()
344  */
345 struct StateModifyRequest
346 {
347   /**
348    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY
349    */
350   struct GNUNET_MessageHeader header;
351
352   /**
353    * Operation ID.
354    */
355   uint32_t op_id GNUNET_PACKED;
356
357   /**
358    * Channel's public key.
359    */
360   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
361
362   uint64_t message_id GNUNET_PACKED;
363
364   uint64_t state_delta GNUNET_PACKED;
365
366   /**
367    * Size of name, including NUL terminator.
368    */
369   uint16_t name_size GNUNET_PACKED;
370
371   /**
372    * OR'd StateOpFlags
373    */
374   uint8_t flags;
375
376   /**
377    * enum GNUNET_ENV_Operator
378    */
379   uint8_t oper;
380
381   /* Followed by NUL-terminated name, then the value. */
382 };
383
384
385 /**
386  * @see GNUNET_PSYCSTORE_state_sync()
387  */
388 struct StateSyncRequest
389 {
390   /**
391    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC
392    */
393   struct GNUNET_MessageHeader header;
394
395   /**
396    * Operation ID.
397    */
398   uint32_t op_id GNUNET_PACKED;
399
400   /**
401    * Channel's public key.
402    */
403   struct GNUNET_CRYPTO_EccPublicSignKey channel_key;
404
405   uint64_t message_id GNUNET_PACKED;
406
407   /**
408    * Size of name, including NUL terminator.
409    */
410   uint16_t name_size GNUNET_PACKED;
411
412   /**
413    * OR'd StateOpFlags
414    */
415   uint8_t flags;
416
417   /* Followed by NUL-terminated name, then the value. */
418 };
419
420
421 GNUNET_NETWORK_STRUCT_END
422
423 #endif