-cleanup and some remarks
[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 2, 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
33 /**
34  * The service sends up to GNUNET_SET_ACK_WINDOW messages per client handle,
35  * the client should send an ack every GNUNET_SET_ACK_WINDOW/2 messages.
36  */
37 #define GNUNET_SET_ACK_WINDOW 8
38
39
40 GNUNET_NETWORK_STRUCT_BEGIN
41
42 struct SetCreateMessage
43 {
44   /**
45    * Type: GNUNET_MESSAGE_TYPE_SET_CREATE
46    */
47   struct GNUNET_MessageHeader header;
48
49   /**
50    * Operation type, values of enum GNUNET_SET_OperationType
51    */
52   // FIXME: use 32_t for 'enum'.
53   uint16_t operation GNUNET_PACKED;
54 };
55
56
57 struct ListenMessage
58 {
59   /**
60    * Type: GNUNET_MESSAGE_TYPE_SET_LISTEN
61    */
62   struct GNUNET_MessageHeader header;
63
64   /**
65    * Operation type, values of enum GNUNET_SET_OperationType
66    */
67   uint16_t operation GNUNET_PACKED;
68
69   /**
70    * application id
71    */
72   struct GNUNET_HashCode app_id;
73
74 };
75
76
77 struct AcceptMessage
78 {
79   /**
80    * Type: GNUNET_MESSAGE_TYPE_SET_ACCEPT
81    */
82   struct GNUNET_MessageHeader header;
83
84   /**
85    * Request id that will be sent along with
86    * results for the accepted operation.
87    * Chosen by the client.
88    * Must be 0 if the request has been rejected.
89    */
90   uint32_t request_id GNUNET_PACKED;
91
92   /**
93    * ID of the incoming request we want to accept / reject.
94    */
95   uint32_t accept_id GNUNET_PACKED;
96 };
97
98
99 /**
100  * A request for an operation with another client.
101  */
102 struct RequestMessage
103 {
104   /**
105    * Type: GNUNET_MESSAGE_TYPE_SET_Request.
106    */
107   struct GNUNET_MessageHeader header;
108
109   /**
110    * ID of the request we want to accept,
111    * chosen by the service.
112    */
113   uint32_t accept_id GNUNET_PACKED;
114
115   /**
116    * Identity of the requesting peer.
117    */
118   struct GNUNET_PeerIdentity peer_id;
119
120   /* rest: nested context message */
121 };
122
123
124 struct EvaluateMessage
125 {
126   /**
127    * Type: GNUNET_MESSAGE_TYPE_SET_EVALUATE
128    */
129   struct GNUNET_MessageHeader header;
130
131   /**
132    * id of our evaluate, chosen by the client
133    */
134   uint32_t request_id GNUNET_PACKED;
135
136   /**
137    * Peer to evaluate the operation with
138    */
139   struct GNUNET_PeerIdentity peer;
140
141   /**
142    * Application id
143    */
144   struct GNUNET_HashCode app_id;
145
146   /**
147    * Salt to use for the operation
148    */
149   uint16_t salt GNUNET_PACKED;
150
151   /**
152    * Padding
153    */
154   uint16_t reserved GNUNET_PACKED;
155
156   /* rest: inner message */
157 };
158
159
160 struct ResultMessage
161 {
162   /**
163    * Type: GNUNET_MESSAGE_TYPE_SET_RESULT
164    */
165   struct GNUNET_MessageHeader header;
166
167   /**
168    * id the result belongs to
169    */
170   uint32_t request_id GNUNET_PACKED;
171
172   /**
173    * Was the evaluation successful?
174    */
175   uint16_t result_status GNUNET_PACKED;
176
177   /**
178    * Type of the element attachted to the message,
179    * if any.
180    */
181   uint16_t element_type GNUNET_PACKED;
182
183   /* rest: the actual element */
184 };
185
186
187 struct ElementMessage
188 {
189   /**
190    * Type: GNUNET_MESSAGE_TYPE_SET_ADD or
191    *       GNUNET_MESSAGE_TYPE_SET_REMOVE
192    */
193   struct GNUNET_MessageHeader header;
194
195   uint16_t element_type GNUNET_PACKED;
196
197   uint16_t reserved GNUNET_PACKED;
198
199   /* rest: the actual element */
200 };
201
202
203 struct CancelMessage
204 {
205   /**
206    * Type: GNUNET_MESSAGE_TYPE_SET_CANCEL
207    */
208   struct GNUNET_MessageHeader header;
209
210   /**
211    * id we want to cancel result belongs to
212    */
213   uint32_t request_id GNUNET_PACKED;
214 };
215
216
217 GNUNET_NETWORK_STRUCT_END
218
219 #endif