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