diff options
Diffstat (limited to 'src/setu/setu.h')
-rw-r--r-- | src/setu/setu.h | 315 |
1 files changed, 315 insertions, 0 deletions
diff --git a/src/setu/setu.h b/src/setu/setu.h new file mode 100644 index 000000000..e9a0def95 --- /dev/null +++ b/src/setu/setu.h | |||
@@ -0,0 +1,315 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2012-2014, 2020 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file set/set.h | ||
22 | * @brief messages used for the set union api | ||
23 | * @author Florian Dold | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef SET_H | ||
27 | #define SET_H | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_common.h" | ||
31 | #include "gnunet_set_service.h" | ||
32 | |||
33 | GNUNET_NETWORK_STRUCT_BEGIN | ||
34 | |||
35 | /** | ||
36 | * Message sent by the client to the service to ask starting | ||
37 | * a new set to perform operations with. Includes the desired | ||
38 | * set operation type. | ||
39 | */ | ||
40 | struct GNUNET_SETU_CreateMessage | ||
41 | { | ||
42 | /** | ||
43 | * Type: #GNUNET_MESSAGE_TYPE_SETU_CREATE | ||
44 | */ | ||
45 | struct GNUNET_MessageHeader header; | ||
46 | |||
47 | }; | ||
48 | |||
49 | |||
50 | /** | ||
51 | * Message sent by the client to the service to start listening for | ||
52 | * incoming requests to perform a certain type of set operation for a | ||
53 | * certain type of application. | ||
54 | */ | ||
55 | struct GNUNET_SETU_ListenMessage | ||
56 | { | ||
57 | /** | ||
58 | * Type: #GNUNET_MESSAGE_TYPE_SETU_LISTEN | ||
59 | */ | ||
60 | struct GNUNET_MessageHeader header; | ||
61 | |||
62 | /** | ||
63 | * Always zero. | ||
64 | */ | ||
65 | uint32_t reserved GNUNET_PACKED; | ||
66 | |||
67 | /** | ||
68 | * application id | ||
69 | */ | ||
70 | struct GNUNET_HashCode app_id; | ||
71 | }; | ||
72 | |||
73 | |||
74 | /** | ||
75 | * Message sent by a listening client to the service to accept | ||
76 | * performing the operation with the other peer. | ||
77 | */ | ||
78 | struct GNUNET_SETU_AcceptMessage | ||
79 | { | ||
80 | /** | ||
81 | * Type: #GNUNET_MESSAGE_TYPE_SETU_ACCEPT | ||
82 | */ | ||
83 | struct GNUNET_MessageHeader header; | ||
84 | |||
85 | /** | ||
86 | * ID of the incoming request we want to accept. | ||
87 | */ | ||
88 | uint32_t accept_reject_id GNUNET_PACKED; | ||
89 | |||
90 | /** | ||
91 | * Request ID to identify responses. | ||
92 | */ | ||
93 | uint32_t request_id GNUNET_PACKED; | ||
94 | |||
95 | /** | ||
96 | * Always use delta operation instead of sending full sets, | ||
97 | * even it it's less efficient. | ||
98 | */ | ||
99 | uint8_t force_delta; | ||
100 | |||
101 | /** | ||
102 | * Always send full sets, even if delta operations would | ||
103 | * be more efficient. | ||
104 | */ | ||
105 | uint8_t force_full; | ||
106 | |||
107 | /** | ||
108 | * #GNUNET_YES to fail operations where Byzantine faults | ||
109 | * are suspected | ||
110 | */ | ||
111 | uint8_t byzantine; | ||
112 | |||
113 | /** | ||
114 | * #GNUNET_YES to also send back set elements we are sending to | ||
115 | * the remote peer. | ||
116 | */ | ||
117 | uint8_t symmetric; | ||
118 | |||
119 | /** | ||
120 | * Lower bound for the set size, used only when | ||
121 | * byzantine mode is enabled. | ||
122 | */ | ||
123 | uint32_t byzantine_lower_bound; | ||
124 | }; | ||
125 | |||
126 | |||
127 | /** | ||
128 | * Message sent by a listening client to the service to reject | ||
129 | * performing the operation with the other peer. | ||
130 | */ | ||
131 | struct GNUNET_SETU_RejectMessage | ||
132 | { | ||
133 | /** | ||
134 | * Type: #GNUNET_MESSAGE_TYPE_SETU_REJECT | ||
135 | */ | ||
136 | struct GNUNET_MessageHeader header; | ||
137 | |||
138 | /** | ||
139 | * ID of the incoming request we want to reject. | ||
140 | */ | ||
141 | uint32_t accept_reject_id GNUNET_PACKED; | ||
142 | }; | ||
143 | |||
144 | |||
145 | /** | ||
146 | * A request for an operation with another client. | ||
147 | */ | ||
148 | struct GNUNET_SETU_RequestMessage | ||
149 | { | ||
150 | /** | ||
151 | * Type: #GNUNET_MESSAGE_TYPE_SETU_REQUEST. | ||
152 | */ | ||
153 | struct GNUNET_MessageHeader header; | ||
154 | |||
155 | /** | ||
156 | * ID of the to identify the request when accepting or | ||
157 | * rejecting it. | ||
158 | */ | ||
159 | uint32_t accept_id GNUNET_PACKED; | ||
160 | |||
161 | /** | ||
162 | * Identity of the requesting peer. | ||
163 | */ | ||
164 | struct GNUNET_PeerIdentity peer_id; | ||
165 | |||
166 | /* rest: context message, that is, application-specific | ||
167 | message to convince listener to pick up */ | ||
168 | }; | ||
169 | |||
170 | |||
171 | /** | ||
172 | * Message sent by client to service to initiate a set operation as a | ||
173 | * client (not as listener). A set (which determines the operation | ||
174 | * type) must already exist in association with this client. | ||
175 | */ | ||
176 | struct GNUNET_SETU_EvaluateMessage | ||
177 | { | ||
178 | /** | ||
179 | * Type: #GNUNET_MESSAGE_TYPE_SETU_EVALUATE | ||
180 | */ | ||
181 | struct GNUNET_MessageHeader header; | ||
182 | |||
183 | /** | ||
184 | * Id of our set to evaluate, chosen implicitly by the client when it | ||
185 | * calls #GNUNET_SETU_commit(). | ||
186 | */ | ||
187 | uint32_t request_id GNUNET_PACKED; | ||
188 | |||
189 | /** | ||
190 | * Peer to evaluate the operation with | ||
191 | */ | ||
192 | struct GNUNET_PeerIdentity target_peer; | ||
193 | |||
194 | /** | ||
195 | * Application id | ||
196 | */ | ||
197 | struct GNUNET_HashCode app_id; | ||
198 | |||
199 | /** | ||
200 | * Always use delta operation instead of sending full sets, | ||
201 | * even it it's less efficient. | ||
202 | */ | ||
203 | uint8_t force_delta; | ||
204 | |||
205 | /** | ||
206 | * Always send full sets, even if delta operations would | ||
207 | * be more efficient. | ||
208 | */ | ||
209 | uint8_t force_full; | ||
210 | |||
211 | /** | ||
212 | * #GNUNET_YES to fail operations where Byzantine faults | ||
213 | * are suspected | ||
214 | */ | ||
215 | uint8_t byzantine; | ||
216 | |||
217 | /** | ||
218 | * Also return set elements we are sending to the remote peer. | ||
219 | */ | ||
220 | uint8_t symmetric; | ||
221 | |||
222 | /** | ||
223 | * Lower bound for the set size, used only when | ||
224 | * byzantine mode is enabled. | ||
225 | */ | ||
226 | uint32_t byzantine_lower_bound; | ||
227 | |||
228 | /* rest: context message, that is, application-specific | ||
229 | message to convince listener to pick up */ | ||
230 | }; | ||
231 | |||
232 | |||
233 | /** | ||
234 | * Message sent by the service to the client to indicate an | ||
235 | * element that is removed (set intersection) or added | ||
236 | * (set union) or part of the final result, depending on | ||
237 | * options specified for the operation. | ||
238 | */ | ||
239 | struct GNUNET_SETU_ResultMessage | ||
240 | { | ||
241 | /** | ||
242 | * Type: #GNUNET_MESSAGE_TYPE_SETU_RESULT | ||
243 | */ | ||
244 | struct GNUNET_MessageHeader header; | ||
245 | |||
246 | /** | ||
247 | * Current set size. | ||
248 | */ | ||
249 | uint64_t current_size; | ||
250 | |||
251 | /** | ||
252 | * id the result belongs to | ||
253 | */ | ||
254 | uint32_t request_id GNUNET_PACKED; | ||
255 | |||
256 | /** | ||
257 | * Was the evaluation successful? Contains | ||
258 | * an `enum GNUNET_SETU_Status` in NBO. | ||
259 | */ | ||
260 | uint16_t result_status GNUNET_PACKED; | ||
261 | |||
262 | /** | ||
263 | * Type of the element attachted to the message, if any. | ||
264 | */ | ||
265 | uint16_t element_type GNUNET_PACKED; | ||
266 | |||
267 | /* rest: the actual element */ | ||
268 | }; | ||
269 | |||
270 | |||
271 | /** | ||
272 | * Message sent by client to the service to add | ||
273 | * an element to the set. | ||
274 | */ | ||
275 | struct GNUNET_SETU_ElementMessage | ||
276 | { | ||
277 | /** | ||
278 | * Type: #GNUNET_MESSAGE_TYPE_SETU_ADD | ||
279 | */ | ||
280 | struct GNUNET_MessageHeader header; | ||
281 | |||
282 | /** | ||
283 | * Type of the element to add or remove. | ||
284 | */ | ||
285 | uint16_t element_type GNUNET_PACKED; | ||
286 | |||
287 | /** | ||
288 | * For alignment, always zero. | ||
289 | */ | ||
290 | uint16_t reserved GNUNET_PACKED; | ||
291 | |||
292 | /* rest: the actual element */ | ||
293 | }; | ||
294 | |||
295 | |||
296 | /** | ||
297 | * Sent to the service by the client in order to cancel a set operation. | ||
298 | */ | ||
299 | struct GNUNET_SETU_CancelMessage | ||
300 | { | ||
301 | /** | ||
302 | * Type: #GNUNET_MESSAGE_TYPE_SETU_CANCEL | ||
303 | */ | ||
304 | struct GNUNET_MessageHeader header; | ||
305 | |||
306 | /** | ||
307 | * ID of the request we want to cancel. | ||
308 | */ | ||
309 | uint32_t request_id GNUNET_PACKED; | ||
310 | }; | ||
311 | |||
312 | |||
313 | GNUNET_NETWORK_STRUCT_END | ||
314 | |||
315 | #endif | ||