2 This file is part of GNUnet.
3 Copyright (C) 2012-2014 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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @brief messages used for the set api
23 * @author Florian Dold
24 * @author Christian Grothoff
30 #include "gnunet_common.h"
31 #include "gnunet_set_service.h"
33 GNUNET_NETWORK_STRUCT_BEGIN
36 * Message sent by the client to the service to ask starting
37 * a new set to perform operations with. Includes the desired
40 struct GNUNET_SET_CreateMessage {
42 * Type: #GNUNET_MESSAGE_TYPE_SET_CREATE
44 struct GNUNET_MessageHeader header;
47 * Operation type, values of `enum GNUNET_SET_OperationType`
49 uint32_t operation GNUNET_PACKED;
54 * Message sent by the client to the service to start listening for
55 * incoming requests to perform a certain type of set operation for a
56 * certain type of application.
58 struct GNUNET_SET_ListenMessage {
60 * Type: #GNUNET_MESSAGE_TYPE_SET_LISTEN
62 struct GNUNET_MessageHeader header;
65 * Operation type, values of `enum GNUNET_SET_OperationType`
67 uint32_t operation GNUNET_PACKED;
72 struct GNUNET_HashCode app_id;
77 * Message sent by a listening client to the service to accept
78 * performing the operation with the other peer.
80 struct GNUNET_SET_AcceptMessage {
82 * Type: #GNUNET_MESSAGE_TYPE_SET_ACCEPT
84 struct GNUNET_MessageHeader header;
87 * ID of the incoming request we want to accept.
89 uint32_t accept_reject_id GNUNET_PACKED;
92 * Request ID to identify responses.
94 uint32_t request_id GNUNET_PACKED;
97 * How should results be sent to us?
98 * See `enum GNUNET_SET_ResultMode`.
100 uint32_t result_mode GNUNET_PACKED;
103 * Always use delta operation instead of sending full sets,
104 * even it it's less efficient.
109 * Always send full sets, even if delta operations would
115 * #GNUNET_YES to fail operations where Byzantine faults
121 * Lower bound for the set size, used only when
122 * byzantine mode is enabled.
124 uint8_t byzantine_lower_bound;
129 * Message sent by a listening client to the service to reject
130 * performing the operation with the other peer.
132 struct GNUNET_SET_RejectMessage {
134 * Type: #GNUNET_MESSAGE_TYPE_SET_REJECT
136 struct GNUNET_MessageHeader header;
139 * ID of the incoming request we want to reject.
141 uint32_t accept_reject_id GNUNET_PACKED;
146 * A request for an operation with another client.
148 struct GNUNET_SET_RequestMessage {
150 * Type: #GNUNET_MESSAGE_TYPE_SET_REQUEST.
152 struct GNUNET_MessageHeader header;
155 * ID of the to identify the request when accepting or
158 uint32_t accept_id GNUNET_PACKED;
161 * Identity of the requesting peer.
163 struct GNUNET_PeerIdentity peer_id;
165 /* rest: context message, that is, application-specific
166 message to convince listener to pick up */
171 * Message sent by client to service to initiate a set operation as a
172 * client (not as listener). A set (which determines the operation
173 * type) must already exist in association with this client.
175 struct GNUNET_SET_EvaluateMessage {
177 * Type: #GNUNET_MESSAGE_TYPE_SET_EVALUATE
179 struct GNUNET_MessageHeader header;
182 * How should results be sent to us?
183 * See `enum GNUNET_SET_ResultMode`.
185 uint32_t result_mode GNUNET_PACKED;
188 * Peer to evaluate the operation with
190 struct GNUNET_PeerIdentity target_peer;
195 struct GNUNET_HashCode app_id;
198 * Id of our set to evaluate, chosen implicitly by the client when it
199 * calls #GNUNET_SET_commit().
201 uint32_t request_id GNUNET_PACKED;
204 * Always use delta operation instead of sending full sets,
205 * even it it's less efficient.
210 * Always send full sets, even if delta operations would
216 * #GNUNET_YES to fail operations where Byzantine faults
222 * Lower bound for the set size, used only when
223 * byzantine mode is enabled.
225 uint8_t byzantine_lower_bound;
227 /* rest: context message, that is, application-specific
228 message to convince listener to pick up */
233 * Message sent by the service to the client to indicate an
234 * element that is removed (set intersection) or added
235 * (set union) or part of the final result, depending on
236 * options specified for the operation.
238 struct GNUNET_SET_ResultMessage {
240 * Type: #GNUNET_MESSAGE_TYPE_SET_RESULT
242 struct GNUNET_MessageHeader header;
247 uint64_t current_size;
250 * id the result belongs to
252 uint32_t request_id GNUNET_PACKED;
255 * Was the evaluation successful? Contains
256 * an `enum GNUNET_SET_Status` in NBO.
258 uint16_t result_status GNUNET_PACKED;
261 * Type of the element attachted to the message, if any.
263 uint16_t element_type GNUNET_PACKED;
265 /* rest: the actual element */
270 * Message sent by client to the service to add or remove
271 * an element to/from the set.
273 struct GNUNET_SET_ElementMessage {
275 * Type: #GNUNET_MESSAGE_TYPE_SET_ADD or
276 * #GNUNET_MESSAGE_TYPE_SET_REMOVE
278 struct GNUNET_MessageHeader header;
281 * Type of the element to add or remove.
283 uint16_t element_type GNUNET_PACKED;
286 * For alignment, always zero.
288 uint16_t reserved GNUNET_PACKED;
290 /* rest: the actual element */
295 * Sent to the service by the client
296 * in order to cancel a set operation.
298 struct GNUNET_SET_CancelMessage {
300 * Type: #GNUNET_MESSAGE_TYPE_SET_CANCEL
302 struct GNUNET_MessageHeader header;
305 * ID of the request we want to cancel.
307 uint32_t request_id GNUNET_PACKED;
312 * Set element transmitted by service to client in response to a set
315 struct GNUNET_SET_IterResponseMessage {
317 * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT
319 struct GNUNET_MessageHeader header;
322 * To which set iteration does this reponse belong to? First
323 * iteration (per client) has counter zero. Wraps around.
325 uint16_t iteration_id GNUNET_PACKED;
328 * Type of the element attachted to the message,
331 uint16_t element_type GNUNET_PACKED;
338 * Client acknowledges receiving element in iteration.
340 struct GNUNET_SET_IterAckMessage {
342 * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ACK
344 struct GNUNET_MessageHeader header;
347 * Non-zero if the service should continue sending elements.
354 * Server responds to a lazy copy request.
356 struct GNUNET_SET_CopyLazyResponseMessage {
358 * Type: #GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE
360 struct GNUNET_MessageHeader header;
363 * Temporary name for the copied set.
370 * Client connects to a lazily copied set.
372 struct GNUNET_SET_CopyLazyConnectMessage {
374 * Type: #GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT
376 struct GNUNET_MessageHeader header;
379 * Temporary name for the copied set.
385 GNUNET_NETWORK_STRUCT_END