f3aedff4f87e2e635a7292e278b2729ea11c1d43
[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: nested context message */
154 };
155
156
157 /**
158  * Message sent by client to service to initiate a set operation as a
159  * client (not as listener).  A set (which determines the operation
160  * type) must already exist in association with this client.
161  */
162 struct GNUNET_SET_EvaluateMessage
163 {
164   /**
165    * Type: #GNUNET_MESSAGE_TYPE_SET_EVALUATE
166    */
167   struct GNUNET_MessageHeader header;
168
169   /**
170    * How should results be sent to us?
171    * See `enum GNUNET_SET_ResultMode`.
172    */
173   uint32_t result_mode GNUNET_PACKED;
174
175   /**
176    * Peer to evaluate the operation with
177    */
178   struct GNUNET_PeerIdentity target_peer;
179
180   /**
181    * Application id
182    */
183   struct GNUNET_HashCode app_id;
184
185   /**
186    * Id of our set to evaluate, chosen implicitly by the client when it
187    * calls #GNUNE_SET_commit().
188    */
189   uint32_t request_id GNUNET_PACKED;
190
191   /* rest: context message, that is, application-specific
192      message to convince listener to pick up */
193 };
194
195
196 struct GNUNET_SET_ResultMessage
197 {
198   /**
199    * Type: #GNUNET_MESSAGE_TYPE_SET_RESULT
200    */
201   struct GNUNET_MessageHeader header;
202
203   /**
204    * id the result belongs to
205    */
206   uint32_t request_id GNUNET_PACKED;
207
208   /**
209    * Was the evaluation successful?
210    */
211   uint16_t result_status GNUNET_PACKED;
212
213   /**
214    * Type of the element attachted to the message,
215    * if any.
216    */
217   uint16_t element_type GNUNET_PACKED;
218
219   /* rest: the actual element */
220 };
221
222
223 /**
224  * Message sent by client to the service to add or remove
225  * an element to/from the set.
226  */
227 struct GNUNET_SET_ElementMessage
228 {
229   /**
230    * Type: #GNUNET_MESSAGE_TYPE_SET_ADD or
231    *       #GNUNET_MESSAGE_TYPE_SET_REMOVE
232    */
233   struct GNUNET_MessageHeader header;
234
235   /**
236    * Type of the element to add or remove.
237    */
238   uint16_t element_type GNUNET_PACKED;
239
240   /**
241    * For alignment, always zero.
242    */
243   uint16_t reserved GNUNET_PACKED;
244
245   /* rest: the actual element */
246 };
247
248
249 /**
250  * Sent to the service by the client
251  * in order to cancel a set operation.
252  */
253 struct GNUNET_SET_CancelMessage
254 {
255   /**
256    * Type: #GNUNET_MESSAGE_TYPE_SET_CANCEL
257    */
258   struct GNUNET_MessageHeader header;
259
260   /**
261    * ID of the request we want to cancel.
262    */
263   uint32_t request_id GNUNET_PACKED;
264 };
265
266
267 struct GNUNET_SET_IterResponseMessage
268 {
269   /**
270    * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_RESPONSE
271    */
272   struct GNUNET_MessageHeader header;
273
274   /**
275    * Type of the element attachted to the message,
276    * if any.
277    */
278   uint16_t element_type GNUNET_PACKED;
279
280   /* rest: element */
281 };
282
283 struct GNUNET_SET_IterAckMessage
284 {
285   /**
286    * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ACK
287    */
288   struct GNUNET_MessageHeader header;
289
290   /**
291    * Non-zero if the service should continue sending elements.
292    */
293   uint32_t send_more;
294 };
295
296 GNUNET_NETWORK_STRUCT_END
297
298 #endif