diff options
Diffstat (limited to 'src/seti/seti.h')
-rw-r--r-- | src/seti/seti.h | 267 |
1 files changed, 267 insertions, 0 deletions
diff --git a/src/seti/seti.h b/src/seti/seti.h new file mode 100644 index 000000000..aa7014034 --- /dev/null +++ b/src/seti/seti.h | |||
@@ -0,0 +1,267 @@ | |||
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/seti.h | ||
22 | * @brief messages used for the set intersection api | ||
23 | * @author Florian Dold | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef SETI_H | ||
27 | #define SETI_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. | ||
38 | */ | ||
39 | struct GNUNET_SETI_CreateMessage | ||
40 | { | ||
41 | /** | ||
42 | * Type: #GNUNET_MESSAGE_TYPE_SETI_CREATE | ||
43 | */ | ||
44 | struct GNUNET_MessageHeader header; | ||
45 | }; | ||
46 | |||
47 | |||
48 | /** | ||
49 | * Message sent by the client to the service to start listening for | ||
50 | * incoming requests to perform a certain type of set operation for a | ||
51 | * certain type of application. | ||
52 | */ | ||
53 | struct GNUNET_SETI_ListenMessage | ||
54 | { | ||
55 | /** | ||
56 | * Type: #GNUNET_MESSAGE_TYPE_SETI_LISTEN | ||
57 | */ | ||
58 | struct GNUNET_MessageHeader header; | ||
59 | |||
60 | /** | ||
61 | * Operation type, values of `enum GNUNET_SETI_OperationType` | ||
62 | */ | ||
63 | uint32_t operation GNUNET_PACKED; | ||
64 | |||
65 | /** | ||
66 | * application id | ||
67 | */ | ||
68 | struct GNUNET_HashCode app_id; | ||
69 | }; | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Message sent by a listening client to the service to accept | ||
74 | * performing the operation with the other peer. | ||
75 | */ | ||
76 | struct GNUNET_SETI_AcceptMessage | ||
77 | { | ||
78 | /** | ||
79 | * Type: #GNUNET_MESSAGE_TYPE_SETI_ACCEPT | ||
80 | */ | ||
81 | struct GNUNET_MessageHeader header; | ||
82 | |||
83 | /** | ||
84 | * ID of the incoming request we want to accept. | ||
85 | */ | ||
86 | uint32_t accept_reject_id GNUNET_PACKED; | ||
87 | |||
88 | /** | ||
89 | * Request ID to identify responses. | ||
90 | */ | ||
91 | uint32_t request_id GNUNET_PACKED; | ||
92 | |||
93 | /** | ||
94 | * Return the intersection (1), instead of the elements to | ||
95 | * remove / the delta (0), in NBO. | ||
96 | */ | ||
97 | uint32_t return_intersection; | ||
98 | |||
99 | }; | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Message sent by a listening client to the service to reject | ||
104 | * performing the operation with the other peer. | ||
105 | */ | ||
106 | struct GNUNET_SETI_RejectMessage | ||
107 | { | ||
108 | /** | ||
109 | * Type: #GNUNET_MESSAGE_TYPE_SETI_REJECT | ||
110 | */ | ||
111 | struct GNUNET_MessageHeader header; | ||
112 | |||
113 | /** | ||
114 | * ID of the incoming request we want to reject. | ||
115 | */ | ||
116 | uint32_t accept_reject_id GNUNET_PACKED; | ||
117 | }; | ||
118 | |||
119 | |||
120 | /** | ||
121 | * A request for an operation with another client. | ||
122 | */ | ||
123 | struct GNUNET_SETI_RequestMessage | ||
124 | { | ||
125 | /** | ||
126 | * Type: #GNUNET_MESSAGE_TYPE_SETI_REQUEST. | ||
127 | */ | ||
128 | struct GNUNET_MessageHeader header; | ||
129 | |||
130 | /** | ||
131 | * ID of the to identify the request when accepting or | ||
132 | * rejecting it. | ||
133 | */ | ||
134 | uint32_t accept_id GNUNET_PACKED; | ||
135 | |||
136 | /** | ||
137 | * Identity of the requesting peer. | ||
138 | */ | ||
139 | struct GNUNET_PeerIdentity peer_id; | ||
140 | |||
141 | /* rest: context message, that is, application-specific | ||
142 | message to convince listener to pick up */ | ||
143 | }; | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Message sent by client to service to initiate a set operation as a | ||
148 | * client (not as listener). A set (which determines the operation | ||
149 | * type) must already exist in association with this client. | ||
150 | */ | ||
151 | struct GNUNET_SETI_EvaluateMessage | ||
152 | { | ||
153 | /** | ||
154 | * Type: #GNUNET_MESSAGE_TYPE_SETI_EVALUATE | ||
155 | */ | ||
156 | struct GNUNET_MessageHeader header; | ||
157 | |||
158 | /** | ||
159 | * Id of our set to evaluate, chosen implicitly by the client when it | ||
160 | * calls #GNUNET_SETI_commit(). | ||
161 | */ | ||
162 | uint32_t request_id GNUNET_PACKED; | ||
163 | |||
164 | /** | ||
165 | * Peer to evaluate the operation with | ||
166 | */ | ||
167 | struct GNUNET_PeerIdentity target_peer; | ||
168 | |||
169 | /** | ||
170 | * Application id | ||
171 | */ | ||
172 | struct GNUNET_HashCode app_id; | ||
173 | |||
174 | /** | ||
175 | * Return the intersection (1), instead of the elements to | ||
176 | * remove / the delta (0), in NBO. | ||
177 | */ | ||
178 | uint32_t return_intersection; | ||
179 | |||
180 | /* rest: context message, that is, application-specific | ||
181 | message to convince listener to pick up */ | ||
182 | }; | ||
183 | |||
184 | |||
185 | /** | ||
186 | * Message sent by the service to the client to indicate an | ||
187 | * element that is removed (set intersection) or added | ||
188 | * (set union) or part of the final result, depending on | ||
189 | * options specified for the operation. | ||
190 | */ | ||
191 | struct GNUNET_SETI_ResultMessage | ||
192 | { | ||
193 | /** | ||
194 | * Type: #GNUNET_MESSAGE_TYPE_SETI_RESULT | ||
195 | */ | ||
196 | struct GNUNET_MessageHeader header; | ||
197 | |||
198 | /** | ||
199 | * Current set size. | ||
200 | */ | ||
201 | uint64_t current_size; | ||
202 | |||
203 | /** | ||
204 | * id the result belongs to | ||
205 | */ | ||
206 | uint32_t request_id GNUNET_PACKED; | ||
207 | |||
208 | /** | ||
209 | * Was the evaluation successful? Contains | ||
210 | * an `enum GNUNET_SETI_Status` in NBO. | ||
211 | */ | ||
212 | uint16_t result_status GNUNET_PACKED; | ||
213 | |||
214 | /** | ||
215 | * Type of the element attachted to the message, if any. | ||
216 | */ | ||
217 | uint16_t element_type GNUNET_PACKED; | ||
218 | |||
219 | /* rest: the actual element */ | ||
220 | }; | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Message sent by client to the service to add an element to the set. | ||
225 | */ | ||
226 | struct GNUNET_SETI_ElementMessage | ||
227 | { | ||
228 | /** | ||
229 | * Type: #GNUNET_MESSAGE_TYPE_SETI_ADD. | ||
230 | */ | ||
231 | struct GNUNET_MessageHeader header; | ||
232 | |||
233 | /** | ||
234 | * Type of the element to add or remove. | ||
235 | */ | ||
236 | uint16_t element_type GNUNET_PACKED; | ||
237 | |||
238 | /** | ||
239 | * For alignment, always zero. | ||
240 | */ | ||
241 | uint16_t reserved GNUNET_PACKED; | ||
242 | |||
243 | /* rest: the actual element */ | ||
244 | }; | ||
245 | |||
246 | |||
247 | /** | ||
248 | * Sent to the service by the client | ||
249 | * in order to cancel a set operation. | ||
250 | */ | ||
251 | struct GNUNET_SETI_CancelMessage | ||
252 | { | ||
253 | /** | ||
254 | * Type: #GNUNET_MESSAGE_TYPE_SETI_CANCEL | ||
255 | */ | ||
256 | struct GNUNET_MessageHeader header; | ||
257 | |||
258 | /** | ||
259 | * ID of the request we want to cancel. | ||
260 | */ | ||
261 | uint32_t request_id GNUNET_PACKED; | ||
262 | }; | ||
263 | |||
264 | |||
265 | GNUNET_NETWORK_STRUCT_END | ||
266 | |||
267 | #endif | ||