use and respect send_more field in IterAckMessage
[oweals/gnunet.git] / src / set / set.h
1 /*
2      This file is part of GNUnet.
3      (C) 2012, 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  * @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 /**
33  * FIXME
34  */
35 #define GNUNET_SET_ACK_WINDOW 10
36
37
38 GNUNET_NETWORK_STRUCT_BEGIN
39
40 /**
41  * Message sent by the client to the service to ask starting
42  * a new set to perform operations with.  Includes the desired
43  * set operation type.
44  */
45 struct GNUNET_SET_CreateMessage
46 {
47   /**
48    * Type: #GNUNET_MESSAGE_TYPE_SET_CREATE
49    */
50   struct GNUNET_MessageHeader header;
51
52   /**
53    * Operation type, values of `enum GNUNET_SET_OperationType`
54    */
55   uint32_t operation GNUNET_PACKED;
56 };
57
58
59 /**
60  * Message sent by the client to the service to start listening for
61  * incoming requests to perform a certain type of set operation for a
62  * certain type of application.
63  */
64 struct GNUNET_SET_ListenMessage
65 {
66   /**
67    * Type: #GNUNET_MESSAGE_TYPE_SET_LISTEN
68    */
69   struct GNUNET_MessageHeader header;
70
71   /**
72    * Operation type, values of `enum GNUNET_SET_OperationType`
73    */
74   uint32_t operation GNUNET_PACKED;
75
76   /**
77    * application id
78    */
79   struct GNUNET_HashCode app_id;
80
81 };
82
83
84 /**
85  * Message sent by a listening client to the service to accept
86  * performing the operation with the other peer.
87  */
88 struct GNUNET_SET_AcceptMessage
89 {
90   /**
91    * Type: #GNUNET_MESSAGE_TYPE_SET_ACCEPT
92    */
93   struct GNUNET_MessageHeader header;
94
95   /**
96    * ID of the incoming request we want to accept.
97    */
98   uint32_t accept_reject_id GNUNET_PACKED;
99
100   /**
101    * Request ID to identify responses.
102    */
103   uint32_t request_id GNUNET_PACKED;
104
105   /**
106    * How should results be sent to us?
107    * See `enum GNUNET_SET_ResultMode`.
108    */
109   uint32_t result_mode GNUNET_PACKED;
110 };
111
112
113 /**
114  * Message sent by a listening client to the service to reject
115  * performing the operation with the other peer.
116  */
117 struct GNUNET_SET_RejectMessage
118 {
119   /**
120    * Type: #GNUNET_MESSAGE_TYPE_SET_REJECT
121    */
122   struct GNUNET_MessageHeader header;
123
124   /**
125    * ID of the incoming request we want to reject.
126    */
127   uint32_t accept_reject_id GNUNET_PACKED;
128
129 };
130
131
132 /**
133  * A request for an operation with another client.
134  */
135 struct GNUNET_SET_RequestMessage
136 {
137   /**
138    * Type: #GNUNET_MESSAGE_TYPE_SET_REQUEST.
139    */
140   struct GNUNET_MessageHeader header;
141
142   /**
143    * ID of the to identify the request when accepting or
144    * rejecting it.
145    */
146   uint32_t accept_id GNUNET_PACKED;
147
148   /**
149    * Identity of the requesting peer.
150    */
151   struct GNUNET_PeerIdentity peer_id;
152
153   /* rest: context message, that is, application-specific
154      message to convince listener to pick up */
155 };
156
157
158 /**
159  * Message sent by client to service to initiate a set operation as a
160  * client (not as listener).  A set (which determines the operation
161  * type) must already exist in association with this client.
162  */
163 struct GNUNET_SET_EvaluateMessage
164 {
165   /**
166    * Type: #GNUNET_MESSAGE_TYPE_SET_EVALUATE
167    */
168   struct GNUNET_MessageHeader header;
169
170   /**
171    * How should results be sent to us?
172    * See `enum GNUNET_SET_ResultMode`.
173    */
174   uint32_t result_mode GNUNET_PACKED;
175
176   /**
177    * Peer to evaluate the operation with
178    */
179   struct GNUNET_PeerIdentity target_peer;
180
181   /**
182    * Application id
183    */
184   struct GNUNET_HashCode app_id;
185
186   /**
187    * Id of our set to evaluate, chosen implicitly by the client when it
188    * calls #GNUNE_SET_commit().
189    */
190   uint32_t request_id GNUNET_PACKED;
191
192   /* rest: context message, that is, application-specific
193      message to convince listener to pick up */
194 };
195
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,
217    * if any.
218    */
219   uint16_t element_type GNUNET_PACKED;
220
221   /* rest: the actual element */
222 };
223
224
225 /**
226  * Message sent by client to the service to add or remove
227  * an element to/from the set.
228  */
229 struct GNUNET_SET_ElementMessage
230 {
231   /**
232    * Type: #GNUNET_MESSAGE_TYPE_SET_ADD or
233    *       #GNUNET_MESSAGE_TYPE_SET_REMOVE
234    */
235   struct GNUNET_MessageHeader header;
236
237   /**
238    * Type of the element to add or remove.
239    */
240   uint16_t element_type GNUNET_PACKED;
241
242   /**
243    * For alignment, always zero.
244    */
245   uint16_t reserved GNUNET_PACKED;
246
247   /* rest: the actual element */
248 };
249
250
251 /**
252  * Sent to the service by the client
253  * in order to cancel a set operation.
254  */
255 struct GNUNET_SET_CancelMessage
256 {
257   /**
258    * Type: #GNUNET_MESSAGE_TYPE_SET_CANCEL
259    */
260   struct GNUNET_MessageHeader header;
261
262   /**
263    * ID of the request we want to cancel.
264    */
265   uint32_t request_id GNUNET_PACKED;
266 };
267
268
269 struct GNUNET_SET_IterResponseMessage
270 {
271   /**
272    * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_RESPONSE
273    */
274   struct GNUNET_MessageHeader header;
275
276   /**
277    * Type of the element attachted to the message,
278    * if any.
279    */
280   uint16_t element_type GNUNET_PACKED;
281
282   /* rest: element */
283 };
284
285 struct GNUNET_SET_IterAckMessage
286 {
287   /**
288    * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ACK
289    */
290   struct GNUNET_MessageHeader header;
291
292   /**
293    * Non-zero if the service should continue sending elements.
294    */
295   uint32_t send_more;
296 };
297
298 GNUNET_NETWORK_STRUCT_END
299
300 #endif