-indentation, code cleanup
[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 /**
22  * @author Florian Dold
23  * @file set/set.h
24  * @brief messages used for the set api
25  */
26 #ifndef SET_H
27 #define SET_H
28
29 #include "platform.h"
30 #include "gnunet_common.h"
31
32 #define GNUNET_SET_ACK_WINDOW 10
33
34
35 GNUNET_NETWORK_STRUCT_BEGIN
36
37 struct GNUNET_SET_CreateMessage
38 {
39   /**
40    * Type: GNUNET_MESSAGE_TYPE_SET_CREATE
41    */
42   struct GNUNET_MessageHeader header;
43
44   /**
45    * Operation type, values of enum GNUNET_SET_OperationType
46    */
47   // FIXME: use 32_t for 'enum'.
48   uint16_t operation GNUNET_PACKED;
49 };
50
51
52 struct GNUNET_SET_ListenMessage
53 {
54   /**
55    * Type: GNUNET_MESSAGE_TYPE_SET_LISTEN
56    */
57   struct GNUNET_MessageHeader header;
58
59   /**
60    * Operation type, values of enum GNUNET_SET_OperationType
61    */
62   uint32_t operation GNUNET_PACKED;
63
64   /**
65    * application id
66    */
67   struct GNUNET_HashCode app_id;
68
69 };
70
71
72 struct GNUNET_SET_AcceptRejectMessage
73 {
74   /**
75    * Type: GNUNET_MESSAGE_TYPE_SET_ACCEPT or
76    *       GNUNET_MESSAGE_TYPE_SET_REJECT
77    */
78   struct GNUNET_MessageHeader header;
79
80   /**
81    * ID of the incoming request we want to accept / reject.
82    */
83   uint32_t accept_reject_id GNUNET_PACKED;
84
85   /**
86    * Request ID to identify responses,
87    * must be 0 if we don't accept the request.
88    */
89   uint32_t request_id GNUNET_PACKED;
90 };
91
92
93 /**
94  * A request for an operation with another client.
95  */
96 struct GNUNET_SET_RequestMessage
97 {
98   /**
99    * Type: GNUNET_MESSAGE_TYPE_SET_Request.
100    */
101   struct GNUNET_MessageHeader header;
102
103   /**
104    * Identity of the requesting peer.
105    */
106   struct GNUNET_PeerIdentity peer_id;
107
108   /**
109    * ID of the to identify the request when accepting or
110    * rejecting it.
111    */
112   uint32_t accept_id GNUNET_PACKED;
113
114   /* rest: nested context message */
115 };
116
117
118 struct GNUNET_SET_EvaluateMessage
119 {
120   /**
121    * Type: GNUNET_MESSAGE_TYPE_SET_EVALUATE
122    */
123   struct GNUNET_MessageHeader header;
124
125   /**
126    * id of our evaluate, chosen by the client
127    */
128   uint32_t request_id GNUNET_PACKED;
129
130   /**
131    * Peer to evaluate the operation with
132    */
133   struct GNUNET_PeerIdentity target_peer;
134
135   /**
136    * Application id
137    */
138   struct GNUNET_HashCode app_id;
139
140   /**
141    * Salt to use for the operation
142    */
143   uint16_t salt GNUNET_PACKED;
144
145   /**
146    * Padding
147    */
148   uint16_t reserved GNUNET_PACKED;
149
150   /* rest: inner message */
151 };
152
153
154 struct GNUNET_SET_ResultMessage
155 {
156   /**
157    * Type: GNUNET_MESSAGE_TYPE_SET_RESULT
158    */
159   struct GNUNET_MessageHeader header;
160
161   /**
162    * id the result belongs to
163    */
164   uint32_t request_id GNUNET_PACKED;
165
166   /**
167    * Was the evaluation successful?
168    */
169   uint16_t result_status GNUNET_PACKED;
170
171   /**
172    * Type of the element attachted to the message,
173    * if any.
174    */
175   uint16_t element_type GNUNET_PACKED;
176
177   /* rest: the actual element */
178 };
179
180
181 struct GNUNET_SET_ElementMessage
182 {
183   /**
184    * Type: GNUNET_MESSAGE_TYPE_SET_ADD or
185    *       GNUNET_MESSAGE_TYPE_SET_REMOVE
186    */
187   struct GNUNET_MessageHeader header;
188
189   uint16_t element_type GNUNET_PACKED;
190
191   uint16_t reserved GNUNET_PACKED;
192
193   /* rest: the actual element */
194 };
195
196
197 /**
198  * Sent to the service by the client
199  * in order to cancel a set operation.
200  */
201 struct GNUNET_SET_CancelMessage
202 {
203   /**
204    * Type: GNUNET_MESSAGE_TYPE_SET_CANCEL
205    */
206   struct GNUNET_MessageHeader header;
207
208   /**
209    * ID of the request we want to cancel.
210    */
211   uint32_t request_id GNUNET_PACKED;
212 };
213
214 struct GNUNET_SET_IterResponseMessage
215 {
216   /**
217    * Type: GNUNET_MESSAGE_TYPE_SET_ITER_RESPONSE
218    */
219   struct GNUNET_MessageHeader header;
220
221   /**
222    * Type of the element attachted to the message,
223    * if any.
224    */
225   uint16_t element_type GNUNET_PACKED;
226
227   /* rest: element */
228 };
229
230 struct GNUNET_SET_IterAckMessage
231 {
232   /**
233    * Type: GNUNET_MESSAGE_TYPE_SET_ITER_ACK
234    */
235   struct GNUNET_MessageHeader header;
236
237   /**
238    * Non-zero if the service should continue sending elements.
239    */
240   uint32_t send_more;
241 };
242
243 GNUNET_NETWORK_STRUCT_END
244
245 #endif