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.
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file psycstore/psycstore.h
21 * @brief Common type definitions for the PSYCstore service and API.
22 * @author Gabor X Toth
25 #ifndef GNUNET_PSYCSTORE_H
26 #define GNUNET_PSYCSTORE_H
28 #include "gnunet_common.h"
31 GNUNET_NETWORK_STRUCT_BEGIN
34 * Answer from service to client about last operation.
36 struct OperationResult
39 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
41 struct GNUNET_MessageHeader header;
43 uint32_t reserved GNUNET_PACKED;
48 uint64_t op_id GNUNET_PACKED;
51 * Status code for the operation.
53 uint64_t result_code GNUNET_PACKED;
55 /* followed by 0-terminated error message (on error) */
61 * Answer from service to client about master counters.
63 * @see GNUNET_PSYCSTORE_counters_get()
68 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS
70 struct GNUNET_MessageHeader header;
73 * Status code for the operation:
74 * #GNUNET_OK: success, counter values are returned.
75 * #GNUNET_NO: no message has been sent to the channel yet.
76 * #GNUNET_SYSERR: an error occurred.
78 uint32_t result_code GNUNET_PACKED;
83 uint64_t op_id GNUNET_PACKED;
85 uint64_t max_fragment_id GNUNET_PACKED;
87 uint64_t max_message_id GNUNET_PACKED;
89 uint64_t max_group_generation GNUNET_PACKED;
91 uint64_t max_state_message_id GNUNET_PACKED;
96 * Answer from service to client containing a message fragment.
101 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
103 struct GNUNET_MessageHeader header;
105 uint32_t psycstore_flags GNUNET_PACKED;
110 uint64_t op_id GNUNET_PACKED;
112 /* Followed by GNUNET_MULTICAST_MessageHeader */
117 * Answer from service to client containing a state variable.
122 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
124 struct GNUNET_MessageHeader header;
126 uint16_t name_size GNUNET_PACKED;
128 uint16_t reserved GNUNET_PACKED;
133 uint64_t op_id GNUNET_PACKED;
135 /* Followed by name and value */
140 * Generic operation request.
142 struct OperationRequest
144 struct GNUNET_MessageHeader header;
146 uint32_t reserved GNUNET_PACKED;
151 uint64_t op_id GNUNET_PACKED;
153 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
158 * @see GNUNET_PSYCSTORE_membership_store()
160 struct MembershipStoreRequest
163 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE
165 struct GNUNET_MessageHeader header;
167 uint32_t reserved GNUNET_PACKED;
172 uint64_t op_id GNUNET_PACKED;
175 * Channel's public key.
177 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
180 * Slave's public key.
182 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
184 uint64_t announced_at GNUNET_PACKED;
185 uint64_t effective_since GNUNET_PACKED;
186 uint64_t group_generation GNUNET_PACKED;
192 * @see GNUNET_PSYCSTORE_membership_test()
194 struct MembershipTestRequest
197 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST
199 struct GNUNET_MessageHeader header;
201 uint32_t reserved GNUNET_PACKED;
206 uint64_t op_id GNUNET_PACKED;
209 * Channel's public key.
211 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
214 * Slave's public key.
216 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
218 uint64_t message_id GNUNET_PACKED;
220 uint64_t group_generation GNUNET_PACKED;
225 * @see GNUNET_PSYCSTORE_fragment_store()
227 struct FragmentStoreRequest
230 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE
232 struct GNUNET_MessageHeader header;
235 * enum GNUNET_PSYCSTORE_MessageFlags
237 uint32_t psycstore_flags GNUNET_PACKED;
240 * Channel's public key.
242 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
249 /* Followed by fragment */
254 * @see GNUNET_PSYCSTORE_fragment_get()
256 struct FragmentGetRequest
259 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET
261 struct GNUNET_MessageHeader header;
263 uint32_t reserved GNUNET_PACKED;
268 uint64_t op_id GNUNET_PACKED;
271 * Channel's public key.
273 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
276 * Slave's public key.
278 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
281 * First fragment ID to request.
283 uint64_t first_fragment_id GNUNET_PACKED;
286 * Last fragment ID to request.
288 uint64_t last_fragment_id GNUNET_PACKED;
291 * Maximum number of fragments to retrieve.
293 uint64_t fragment_limit GNUNET_PACKED;
296 * Do membership test with @a slave_key before returning fragment?
297 * #GNUNET_YES or #GNUNET_NO
299 uint8_t do_membership_test;
304 * @see GNUNET_PSYCSTORE_message_get()
306 struct MessageGetRequest
309 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET
311 struct GNUNET_MessageHeader header;
313 uint32_t reserved GNUNET_PACKED;
318 uint64_t op_id GNUNET_PACKED;
321 * Channel's public key.
323 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
326 * Slave's public key.
328 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
331 * First message ID to request.
333 uint64_t first_message_id GNUNET_PACKED;
336 * Last message ID to request.
338 uint64_t last_message_id GNUNET_PACKED;
341 * Maximum number of messages to retrieve.
343 uint64_t message_limit GNUNET_PACKED;
346 * Maximum number of fragments to retrieve.
348 uint64_t fragment_limit GNUNET_PACKED;
351 * Do membership test with @a slave_key before returning fragment?
352 * #GNUNET_YES or #GNUNET_NO
354 uint8_t do_membership_test;
356 /* Followed by method_prefix */
361 * @see GNUNET_PSYCSTORE_message_get_fragment()
363 struct MessageGetFragmentRequest
366 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_FRAGMENT_GET
368 struct GNUNET_MessageHeader header;
370 uint32_t reserved GNUNET_PACKED;
375 uint64_t op_id GNUNET_PACKED;
378 * Channel's public key.
380 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
383 * Slave's public key.
385 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
388 * Requested message ID.
390 uint64_t message_id GNUNET_PACKED;
393 * Requested fragment offset.
395 uint64_t fragment_offset GNUNET_PACKED;
398 * Do membership test with @a slave_key before returning fragment?
399 * #GNUNET_YES or #GNUNET_NO
401 uint8_t do_membership_test;
406 * @see GNUNET_PSYCSTORE_state_hash_update()
408 struct StateHashUpdateRequest
411 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE
413 struct GNUNET_MessageHeader header;
415 uint32_t reserved GNUNET_PACKED;
420 uint64_t op_id GNUNET_PACKED;
423 * Channel's public key.
425 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
427 struct GNUNET_HashCode hash;
433 STATE_OP_FIRST = 1 << 0,
434 STATE_OP_LAST = 1 << 1
439 * @see GNUNET_PSYCSTORE_state_modify()
441 struct StateModifyRequest
444 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY
446 struct GNUNET_MessageHeader header;
451 uint64_t op_id GNUNET_PACKED;
454 * ID of the message to apply the state changes in.
456 uint64_t message_id GNUNET_PACKED;
459 * State delta of the message with ID @a message_id.
461 uint64_t state_delta GNUNET_PACKED;
464 * Channel's public key.
466 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
471 * @see GNUNET_PSYCSTORE_state_sync()
473 struct StateSyncRequest
476 * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC
478 struct GNUNET_MessageHeader header;
481 * Size of name, including NUL terminator.
483 uint16_t name_size GNUNET_PACKED;
495 uint64_t op_id GNUNET_PACKED;
498 * ID of the message that contains the state_hash PSYC header variable.
500 uint64_t state_hash_message_id GNUNET_PACKED;
503 * ID of the last stateful message before @a state_hash_message_id.
505 uint64_t max_state_message_id GNUNET_PACKED;
508 * Channel's public key.
510 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
512 /* Followed by NUL-terminated name, then the value. */
516 GNUNET_NETWORK_STRUCT_END