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