- another fix to generation handling and lazy copying
[oweals/gnunet.git] / src / set / set.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2012-2014 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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20 /**
21  * @file set/set.h
22  * @brief messages used for the set api
23  * @author Florian Dold
24  * @author Christian Grothoff
25  */
26 #ifndef SET_H
27 #define SET_H
28
29 #include "platform.h"
30 #include "gnunet_common.h"
31
32 GNUNET_NETWORK_STRUCT_BEGIN
33
34 /**
35  * Message sent by the client to the service to ask starting
36  * a new set to perform operations with.  Includes the desired
37  * set operation type.
38  */
39 struct GNUNET_SET_CreateMessage
40 {
41   /**
42    * Type: #GNUNET_MESSAGE_TYPE_SET_CREATE
43    */
44   struct GNUNET_MessageHeader header;
45
46   /**
47    * Operation type, values of `enum GNUNET_SET_OperationType`
48    */
49   uint32_t operation GNUNET_PACKED;
50 };
51
52
53 /**
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.
57  */
58 struct GNUNET_SET_ListenMessage
59 {
60   /**
61    * Type: #GNUNET_MESSAGE_TYPE_SET_LISTEN
62    */
63   struct GNUNET_MessageHeader header;
64
65   /**
66    * Operation type, values of `enum GNUNET_SET_OperationType`
67    */
68   uint32_t operation GNUNET_PACKED;
69
70   /**
71    * application id
72    */
73   struct GNUNET_HashCode app_id;
74
75 };
76
77
78 /**
79  * Message sent by a listening client to the service to accept
80  * performing the operation with the other peer.
81  */
82 struct GNUNET_SET_AcceptMessage
83 {
84   /**
85    * Type: #GNUNET_MESSAGE_TYPE_SET_ACCEPT
86    */
87   struct GNUNET_MessageHeader header;
88
89   /**
90    * ID of the incoming request we want to accept.
91    */
92   uint32_t accept_reject_id GNUNET_PACKED;
93
94   /**
95    * Request ID to identify responses.
96    */
97   uint32_t request_id GNUNET_PACKED;
98
99   /**
100    * How should results be sent to us?
101    * See `enum GNUNET_SET_ResultMode`.
102    */
103   uint32_t result_mode GNUNET_PACKED;
104 };
105
106
107 /**
108  * Message sent by a listening client to the service to reject
109  * performing the operation with the other peer.
110  */
111 struct GNUNET_SET_RejectMessage
112 {
113   /**
114    * Type: #GNUNET_MESSAGE_TYPE_SET_REJECT
115    */
116   struct GNUNET_MessageHeader header;
117
118   /**
119    * ID of the incoming request we want to reject.
120    */
121   uint32_t accept_reject_id GNUNET_PACKED;
122
123 };
124
125
126 /**
127  * A request for an operation with another client.
128  */
129 struct GNUNET_SET_RequestMessage
130 {
131   /**
132    * Type: #GNUNET_MESSAGE_TYPE_SET_REQUEST.
133    */
134   struct GNUNET_MessageHeader header;
135
136   /**
137    * ID of the to identify the request when accepting or
138    * rejecting it.
139    */
140   uint32_t accept_id GNUNET_PACKED;
141
142   /**
143    * Identity of the requesting peer.
144    */
145   struct GNUNET_PeerIdentity peer_id;
146
147   /* rest: context message, that is, application-specific
148      message to convince listener to pick up */
149 };
150
151
152 /**
153  * Message sent by client to service to initiate a set operation as a
154  * client (not as listener).  A set (which determines the operation
155  * type) must already exist in association with this client.
156  */
157 struct GNUNET_SET_EvaluateMessage
158 {
159   /**
160    * Type: #GNUNET_MESSAGE_TYPE_SET_EVALUATE
161    */
162   struct GNUNET_MessageHeader header;
163
164   /**
165    * How should results be sent to us?
166    * See `enum GNUNET_SET_ResultMode`.
167    */
168   uint32_t result_mode GNUNET_PACKED;
169
170   /**
171    * Peer to evaluate the operation with
172    */
173   struct GNUNET_PeerIdentity target_peer;
174
175   /**
176    * Application id
177    */
178   struct GNUNET_HashCode app_id;
179
180   /**
181    * Id of our set to evaluate, chosen implicitly by the client when it
182    * calls #GNUNET_SET_commit().
183    */
184   uint32_t request_id GNUNET_PACKED;
185
186   /* rest: context message, that is, application-specific
187      message to convince listener to pick up */
188 };
189
190
191 /**
192  * Message sent by the service to the client to indicate an
193  * element that is removed (set intersection) or added
194  * (set union) or part of the final result, depending on
195  * options specified for the operation.
196  */
197 struct GNUNET_SET_ResultMessage
198 {
199   /**
200    * Type: #GNUNET_MESSAGE_TYPE_SET_RESULT
201    */
202   struct GNUNET_MessageHeader header;
203
204   /**
205    * id the result belongs to
206    */
207   uint32_t request_id GNUNET_PACKED;
208
209   /**
210    * Was the evaluation successful? Contains
211    * an `enum GNUNET_SET_Status` in NBO.
212    */
213   uint16_t result_status GNUNET_PACKED;
214
215   /**
216    * Type of the element attachted to the message, if any.
217    */
218   uint16_t element_type GNUNET_PACKED;
219
220   /* rest: the actual element */
221 };
222
223
224 /**
225  * Message sent by client to the service to add or remove
226  * an element to/from the set.
227  */
228 struct GNUNET_SET_ElementMessage
229 {
230   /**
231    * Type: #GNUNET_MESSAGE_TYPE_SET_ADD or
232    *       #GNUNET_MESSAGE_TYPE_SET_REMOVE
233    */
234   struct GNUNET_MessageHeader header;
235
236   /**
237    * Type of the element to add or remove.
238    */
239   uint16_t element_type GNUNET_PACKED;
240
241   /**
242    * For alignment, always zero.
243    */
244   uint16_t reserved GNUNET_PACKED;
245
246   /* rest: the actual element */
247 };
248
249
250 /**
251  * Sent to the service by the client
252  * in order to cancel a set operation.
253  */
254 struct GNUNET_SET_CancelMessage
255 {
256   /**
257    * Type: #GNUNET_MESSAGE_TYPE_SET_CANCEL
258    */
259   struct GNUNET_MessageHeader header;
260
261   /**
262    * ID of the request we want to cancel.
263    */
264   uint32_t request_id GNUNET_PACKED;
265 };
266
267
268 /**
269  * Set element transmitted by service to client in response to a set
270  * iteration request.
271  */
272 struct GNUNET_SET_IterResponseMessage
273 {
274   /**
275    * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT
276    */
277   struct GNUNET_MessageHeader header;
278
279   /**
280    * To which set iteration does this reponse belong to?  First
281    * iteration (per client) has counter zero. Wraps around.
282    */
283   uint16_t iteration_id GNUNET_PACKED;
284
285   /**
286    * Type of the element attachted to the message,
287    * if any.
288    */
289   uint16_t element_type GNUNET_PACKED;
290
291   /* rest: element */
292 };
293
294
295 /**
296  * Client acknowledges receiving element in iteration.
297  */
298 struct GNUNET_SET_IterAckMessage
299 {
300   /**
301    * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ACK
302    */
303   struct GNUNET_MessageHeader header;
304
305   /**
306    * Non-zero if the service should continue sending elements.
307    */
308   uint32_t send_more;
309 };
310
311
312 /**
313  * Server responds to a lazy copy request.
314  */
315 struct GNUNET_SET_CopyLazyResponseMessage
316 {
317   /**
318    * Type: #GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE
319    */
320   struct GNUNET_MessageHeader header;
321
322   /**
323    * Temporary name for the copied set.
324    */
325   uint32_t cookie;
326 };
327
328
329 /**
330  * Client connects to a lazily copied set.
331  */
332 struct GNUNET_SET_CopyLazyConnectMessage
333 {
334   /**
335    * Type: #GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT
336    */
337   struct GNUNET_MessageHeader header;
338
339   /**
340    * Temporary name for the copied set.
341    */
342   uint32_t cookie;
343 };
344
345
346 GNUNET_NETWORK_STRUCT_END
347
348 #endif