10e607982a9f341d613f7dbb99f9e6a8333dd108
[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   /* rest: inner message */
139 };
140
141
142 struct ResultMessage
143 {
144   /**
145    * Type: GNUNET_MESSAGE_TYPE_SET_RESULT
146    */
147   struct GNUNET_MessageHeader header;
148
149   /**
150    * id the result belongs to
151    */
152   uint32_t request_id GNUNET_PACKED;
153
154   /**
155    * Was the evaluation successful?
156    */
157   uint16_t result_status GNUNET_PACKED;
158
159   /**
160    * Type of the element attachted to the message,
161    * if any.
162    */
163   uint16_t element_type GNUNET_PACKED;
164
165   /* rest: the actual element */
166 };
167
168
169 struct ElementMessage
170 {
171   /**
172    * Type: GNUNET_MESSAGE_TYPE_SET_ADD or
173    *       GNUNET_MESSAGE_TYPE_SET_REMOVE
174    */
175   struct GNUNET_MessageHeader header;
176
177   uint16_t element_type GNUNET_PACKED;
178
179   /* rest: the actual element */
180 };
181
182
183 struct CancelMessage
184 {
185   /**
186    * Type: GNUNET_MESSAGE_TYPE_SET_CANCEL
187    */
188   struct GNUNET_MessageHeader header;
189
190   /**
191    * id we want to cancel result belongs to
192    */
193   uint32_t request_id GNUNET_PACKED;
194 };
195
196
197 GNUNET_NETWORK_STRUCT_END
198
199 #endif