0bf1f2d055e65ae35cdc4efe8020ba3c1173ae2f
[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 of the request we want to accept
84    */
85   uint32_t request_id GNUNET_PACKED;
86
87   /**
88    * Zero if the client has rejected the request,
89    * non-zero if it has accepted it
90    */
91   uint32_t accepted GNUNET_PACKED;
92 };
93
94
95 struct RequestMessage
96 {
97   /**
98    * Type: GNUNET_MESSAGE_TYPE_SET_Request
99    */
100   struct GNUNET_MessageHeader header;
101
102   /**
103    * requesting peer
104    */
105   struct GNUNET_PeerIdentity peer_id;
106
107   /**
108    * request id of the request we want to accept
109    */
110   uint32_t request_id GNUNET_PACKED;
111
112   /* rest: inner message */
113 };
114
115
116 struct EvaluateMessage
117 {
118   /**
119    * Type: GNUNET_MESSAGE_TYPE_SET_EVALUATE
120    */
121   struct GNUNET_MessageHeader header;
122
123   /**
124    * Peer to evaluate the operation with
125    */
126   struct GNUNET_PeerIdentity peer;
127
128   /**
129    * Application id
130    */
131   struct GNUNET_HashCode app_id;
132
133   /**
134    * id of our evaluate
135    */
136   uint32_t request_id GNUNET_PACKED;
137
138   uint16_t salt;
139
140   uint16_t reserved;
141
142   /* rest: inner message */
143 };
144
145
146 struct ResultMessage
147 {
148   /**
149    * Type: GNUNET_MESSAGE_TYPE_SET_RESULT
150    */
151   struct GNUNET_MessageHeader header;
152
153   /**
154    * id the result belongs to
155    */
156   uint32_t request_id GNUNET_PACKED;
157
158   /**
159    * Was the evaluation successful?
160    */
161   uint16_t result_status GNUNET_PACKED;
162
163   /**
164    * Type of the element attachted to the message,
165    * if any.
166    */
167   uint16_t element_type GNUNET_PACKED;
168
169   /* rest: the actual element */
170 };
171
172
173 struct ElementMessage
174 {
175   /**
176    * Type: GNUNET_MESSAGE_TYPE_SET_ADD or
177    *       GNUNET_MESSAGE_TYPE_SET_REMOVE
178    */
179   struct GNUNET_MessageHeader header;
180
181   uint16_t element_type GNUNET_PACKED;
182
183   /* rest: the actual element */
184 };
185
186
187 struct CancelMessage
188 {
189   /**
190    * Type: GNUNET_MESSAGE_TYPE_SET_CANCEL
191    */
192   struct GNUNET_MessageHeader header;
193
194   /**
195    * id we want to cancel result belongs to
196    */
197   uint32_t request_id GNUNET_PACKED;
198 };
199
200
201 GNUNET_NETWORK_STRUCT_END
202
203 #endif