2 * This file is part of GNUnet
3 * Copyright (C) 2013 GNUnet e.V.
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.
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.
17 * @file psycstore/psycstore.h
18 * @brief Common type definitions for the PSYCstore service and API.
19 * @author Gabor X Toth
22 #ifndef GNUNET_PSYCSTORE_H
23 #define GNUNET_PSYCSTORE_H
25 #include "gnunet_common.h"
28 GNUNET_NETWORK_STRUCT_BEGIN
31 * Answer from service to client about last operation.
33 struct OperationResult
36 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
38 struct GNUNET_MessageHeader header;
40 uint32_t reserved GNUNET_PACKED;
45 uint64_t op_id GNUNET_PACKED;
48 * Status code for the operation.
50 uint64_t result_code GNUNET_PACKED;
52 /* followed by 0-terminated error message (on error) */
58 * Answer from service to client about master counters.
60 * @see GNUNET_PSYCSTORE_counters_get()
65 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS
67 struct GNUNET_MessageHeader header;
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.
75 uint32_t result_code GNUNET_PACKED;
80 uint64_t op_id GNUNET_PACKED;
82 uint64_t max_fragment_id GNUNET_PACKED;
84 uint64_t max_message_id GNUNET_PACKED;
86 uint64_t max_group_generation GNUNET_PACKED;
88 uint64_t max_state_message_id GNUNET_PACKED;
93 * Answer from service to client containing a message fragment.
98 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
100 struct GNUNET_MessageHeader header;
102 uint32_t psycstore_flags GNUNET_PACKED;
107 uint64_t op_id GNUNET_PACKED;
109 /* Followed by GNUNET_MULTICAST_MessageHeader */
114 * Answer from service to client containing a state variable.
119 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
121 struct GNUNET_MessageHeader header;
123 uint16_t name_size GNUNET_PACKED;
125 uint16_t reserved GNUNET_PACKED;
130 uint64_t op_id GNUNET_PACKED;
132 /* Followed by name and value */
137 * Generic operation request.
139 struct OperationRequest
141 struct GNUNET_MessageHeader header;
143 uint32_t reserved GNUNET_PACKED;
148 uint64_t op_id GNUNET_PACKED;
150 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
155 * @see GNUNET_PSYCSTORE_membership_store()
157 struct MembershipStoreRequest
160 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE
162 struct GNUNET_MessageHeader header;
164 uint32_t reserved GNUNET_PACKED;
169 uint64_t op_id GNUNET_PACKED;
172 * Channel's public key.
174 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
177 * Slave's public key.
179 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
181 uint64_t announced_at GNUNET_PACKED;
182 uint64_t effective_since GNUNET_PACKED;
183 uint64_t group_generation GNUNET_PACKED;
189 * @see GNUNET_PSYCSTORE_membership_test()
191 struct MembershipTestRequest
194 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST
196 struct GNUNET_MessageHeader header;
198 uint32_t reserved GNUNET_PACKED;
203 uint64_t op_id GNUNET_PACKED;
206 * Channel's public key.
208 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
211 * Slave's public key.
213 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
215 uint64_t message_id GNUNET_PACKED;
217 uint64_t group_generation GNUNET_PACKED;
222 * @see GNUNET_PSYCSTORE_fragment_store()
224 struct FragmentStoreRequest
227 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE
229 struct GNUNET_MessageHeader header;
232 * enum GNUNET_PSYCSTORE_MessageFlags
234 uint32_t psycstore_flags GNUNET_PACKED;
237 * Channel's public key.
239 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
246 /* Followed by fragment */
251 * @see GNUNET_PSYCSTORE_fragment_get()
253 struct FragmentGetRequest
256 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET
258 struct GNUNET_MessageHeader header;
260 uint32_t reserved GNUNET_PACKED;
265 uint64_t op_id GNUNET_PACKED;
268 * Channel's public key.
270 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
273 * Slave's public key.
275 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
278 * First fragment ID to request.
280 uint64_t first_fragment_id GNUNET_PACKED;
283 * Last fragment ID to request.
285 uint64_t last_fragment_id GNUNET_PACKED;
288 * Maximum number of fragments to retrieve.
290 uint64_t fragment_limit GNUNET_PACKED;
293 * Do membership test with @a slave_key before returning fragment?
294 * #GNUNET_YES or #GNUNET_NO
296 uint8_t do_membership_test;
301 * @see GNUNET_PSYCSTORE_message_get()
303 struct MessageGetRequest
306 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET
308 struct GNUNET_MessageHeader header;
310 uint32_t reserved GNUNET_PACKED;
315 uint64_t op_id GNUNET_PACKED;
318 * Channel's public key.
320 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
323 * Slave's public key.
325 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
328 * First message ID to request.
330 uint64_t first_message_id GNUNET_PACKED;
333 * Last message ID to request.
335 uint64_t last_message_id GNUNET_PACKED;
338 * Maximum number of messages to retrieve.
340 uint64_t message_limit GNUNET_PACKED;
343 * Maximum number of fragments to retrieve.
345 uint64_t fragment_limit GNUNET_PACKED;
348 * Do membership test with @a slave_key before returning fragment?
349 * #GNUNET_YES or #GNUNET_NO
351 uint8_t do_membership_test;
353 /* Followed by method_prefix */
358 * @see GNUNET_PSYCSTORE_message_get_fragment()
360 struct MessageGetFragmentRequest
363 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_FRAGMENT_GET
365 struct GNUNET_MessageHeader header;
367 uint32_t reserved GNUNET_PACKED;
372 uint64_t op_id GNUNET_PACKED;
375 * Channel's public key.
377 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
380 * Slave's public key.
382 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
385 * Requested message ID.
387 uint64_t message_id GNUNET_PACKED;
390 * Requested fragment offset.
392 uint64_t fragment_offset GNUNET_PACKED;
395 * Do membership test with @a slave_key before returning fragment?
396 * #GNUNET_YES or #GNUNET_NO
398 uint8_t do_membership_test;
403 * @see GNUNET_PSYCSTORE_state_hash_update()
405 struct StateHashUpdateRequest
408 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE
410 struct GNUNET_MessageHeader header;
412 uint32_t reserved GNUNET_PACKED;
417 uint64_t op_id GNUNET_PACKED;
420 * Channel's public key.
422 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
424 struct GNUNET_HashCode hash;
430 STATE_OP_FIRST = 1 << 0,
431 STATE_OP_LAST = 1 << 1
436 * @see GNUNET_PSYCSTORE_state_modify()
438 struct StateModifyRequest
441 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY
443 struct GNUNET_MessageHeader header;
448 uint64_t op_id GNUNET_PACKED;
451 * ID of the message to apply the state changes in.
453 uint64_t message_id GNUNET_PACKED;
456 * State delta of the message with ID @a message_id.
458 uint64_t state_delta GNUNET_PACKED;
461 * Channel's public key.
463 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
468 * @see GNUNET_PSYCSTORE_state_sync()
470 struct StateSyncRequest
473 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC
475 struct GNUNET_MessageHeader header;
478 * Size of name, including NUL terminator.
480 uint16_t name_size GNUNET_PACKED;
492 uint64_t op_id GNUNET_PACKED;
495 * ID of the message that contains the state_hash PSYC header variable.
497 uint64_t state_hash_message_id GNUNET_PACKED;
500 * ID of the last stateful message before @a state_hash_message_id.
502 uint64_t max_state_message_id GNUNET_PACKED;
505 * Channel's public key.
507 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
509 /* Followed by NUL-terminated name, then the value. */
513 GNUNET_NETWORK_STRUCT_END