aboutsummaryrefslogtreecommitdiff
path: root/src/service/dht/dht.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/dht/dht.h')
-rw-r--r--src/service/dht/dht.h427
1 files changed, 427 insertions, 0 deletions
diff --git a/src/service/dht/dht.h b/src/service/dht/dht.h
new file mode 100644
index 000000000..6a137defe
--- /dev/null
+++ b/src/service/dht/dht.h
@@ -0,0 +1,427 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2003, 2004, 2009, 2011, 2021 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/**
22 * @author Christian Grothoff
23 * @author Nathan Evans
24 * @file dht/dht.h
25 */
26
27#ifndef DHT_H
28#define DHT_H
29
30
31/**
32 * Size of the bloom filter the DHT uses to filter peers.
33 */
34#define DHT_BLOOM_SIZE 128
35
36
37GNUNET_NETWORK_STRUCT_BEGIN
38
39/**
40 * Message which indicates the DHT should cancel outstanding
41 * requests and discard any state.
42 */
43struct GNUNET_DHT_ClientGetStopMessage
44{
45 /**
46 * Type: #GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP
47 */
48 struct GNUNET_MessageHeader header;
49
50 /**
51 * Always zero.
52 */
53 uint32_t reserved GNUNET_PACKED;
54
55 /**
56 * Unique ID identifying this request
57 */
58 uint64_t unique_id GNUNET_PACKED;
59
60 /**
61 * Key of this request
62 */
63 struct GNUNET_HashCode key;
64};
65
66
67/**
68 * DHT GET message sent from clients to service. Indicates that a GET
69 * request should be issued.
70 */
71struct GNUNET_DHT_ClientGetMessage
72{
73 /**
74 * Type: #GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET
75 */
76 struct GNUNET_MessageHeader header;
77
78 /**
79 * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
80 */
81 uint32_t options GNUNET_PACKED;
82
83 /**
84 * Replication level for this message
85 */
86 uint32_t desired_replication_level GNUNET_PACKED;
87
88 /**
89 * The type for the data for the GET request; actually an 'enum
90 * GNUNET_BLOCK_Type'.
91 */
92 uint32_t type GNUNET_PACKED;
93
94 /**
95 * The key to search for
96 */
97 struct GNUNET_HashCode key GNUNET_PACKED;
98
99 /**
100 * Unique ID identifying this request, if 0 then
101 * the client will not expect a response
102 */
103 uint64_t unique_id GNUNET_PACKED;
104
105 /* Possibly followed by xquery, copied to end of this dealy do */
106};
107
108
109/**
110 * DHT GET RESULTS KNOWN message sent from clients to service. Indicates that a GET
111 * request should exclude certain results which are already known.
112 */
113struct GNUNET_DHT_ClientGetResultSeenMessage
114{
115 /**
116 * Type: #GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN
117 */
118 struct GNUNET_MessageHeader header;
119
120 /**
121 * Reserved, always 0.
122 */
123 uint32_t reserved GNUNET_PACKED;
124
125 /**
126 * The key we are searching for (to make it easy to find the corresponding
127 * GET inside the service).
128 */
129 struct GNUNET_HashCode key GNUNET_PACKED;
130
131 /**
132 * Unique ID identifying this request.
133 */
134 uint64_t unique_id GNUNET_PACKED;
135
136 /* Followed by an array of the hash codes of known results */
137};
138
139
140/**
141 * Reply to a GET send from the service to a client.
142 */
143struct GNUNET_DHT_ClientResultMessage
144{
145 /**
146 * Type: #GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT
147 */
148 struct GNUNET_MessageHeader header;
149
150 /**
151 * The type for the data.
152 */
153 uint32_t type GNUNET_PACKED;
154
155 /**
156 * Reserved, always 0.
157 */
158 uint32_t reserved GNUNET_PACKED;
159
160 /**
161 * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
162 */
163 uint32_t options GNUNET_PACKED;
164
165 /**
166 * Number of peers recorded in the outgoing path from source to the
167 * storgage location of this message.
168 */
169 uint32_t put_path_length GNUNET_PACKED;
170
171 /**
172 * The number of peer identities recorded from the storage location
173 * to this peer.
174 */
175 uint32_t get_path_length GNUNET_PACKED;
176
177 /**
178 * Unique ID of the matching GET request.
179 */
180 uint64_t unique_id GNUNET_PACKED;
181
182 /**
183 * When does this entry expire?
184 */
185 struct GNUNET_TIME_AbsoluteNBO expiration;
186
187 /**
188 * The key that was searched for
189 */
190 struct GNUNET_HashCode key GNUNET_PACKED;
191
192 /* trunc_peer, put path, get path and actual data are copied to end of this dealy do */
193};
194
195
196/**
197 * Message to insert data into the DHT, sent from clients to DHT service.
198 */
199struct GNUNET_DHT_ClientPutMessage
200{
201 /**
202 * Type: #GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT
203 */
204 struct GNUNET_MessageHeader header;
205
206 /**
207 * The type of data to insert.
208 */
209 uint32_t type GNUNET_PACKED;
210
211 /**
212 * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
213 */
214 uint32_t options GNUNET_PACKED;
215
216 /**
217 * Replication level for this message
218 */
219 uint32_t desired_replication_level GNUNET_PACKED;
220
221 /**
222 * How long should this data persist?
223 */
224 struct GNUNET_TIME_AbsoluteNBO expiration;
225
226 /**
227 * The key to store the value under.
228 */
229 struct GNUNET_HashCode key GNUNET_PACKED;
230
231 /* DATA copied to end of this message */
232};
233
234
235/**
236 * Message to monitor put requests going through peer, DHT service -> clients.
237 */
238struct GNUNET_DHT_MonitorPutMessage
239{
240 /**
241 * Type: #GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT
242 */
243 struct GNUNET_MessageHeader header;
244
245 /**
246 * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
247 */
248 uint32_t options GNUNET_PACKED;
249
250 /**
251 * The type of data in the request.
252 */
253 uint32_t type GNUNET_PACKED;
254
255 /**
256 * Hop count so far.
257 */
258 uint32_t hop_count GNUNET_PACKED;
259
260 /**
261 * Replication level for this message
262 */
263 uint32_t desired_replication_level GNUNET_PACKED;
264
265 /**
266 * Number of peers recorded in the outgoing path from source to the
267 * storage location of this message.
268 */
269 uint32_t put_path_length GNUNET_PACKED;
270
271 /**
272 * How long should this data persist?
273 */
274 struct GNUNET_TIME_AbsoluteNBO expiration_time;
275
276 /**
277 * The key to store the value under.
278 */
279 struct GNUNET_HashCode key GNUNET_PACKED;
280
281 /* put path (if tracked) */
282
283 /* Payload */
284};
285
286
287/**
288 * Message to request monitoring messages, clients -> DHT service.
289 */
290struct GNUNET_DHT_MonitorStartStopMessage
291{
292 /**
293 * Type: #GNUNET_MESSAGE_TYPE_DHT_MONITOR_START or
294 * #GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP
295 */
296 struct GNUNET_MessageHeader header;
297
298 /**
299 * The type of data desired, GNUNET_BLOCK_TYPE_ANY for all.
300 */
301 uint32_t type GNUNET_PACKED;
302
303 /**
304 * Flag whether to notify about GET messages.
305 */
306 int16_t get GNUNET_PACKED;
307
308 /**
309 * Flag whether to notify about GET_REPONSE messages.
310 */
311 int16_t get_resp GNUNET_PACKED;
312
313 /**
314 * Flag whether to notify about PUT messages.
315 */
316 int16_t put GNUNET_PACKED;
317
318 /**
319 * Flag whether to use the provided key to filter messages.
320 */
321 int16_t filter_key GNUNET_PACKED;
322
323 /**
324 * The key to filter messages by.
325 */
326 struct GNUNET_HashCode key GNUNET_PACKED;
327};
328
329
330/**
331 * Message to monitor get requests going through peer, DHT service -> clients.
332 */
333struct GNUNET_DHT_MonitorGetMessage
334{
335 /**
336 * Type: #GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET
337 */
338 struct GNUNET_MessageHeader header;
339
340 /**
341 * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
342 */
343 uint32_t options GNUNET_PACKED;
344
345 /**
346 * The type of data in the request.
347 */
348 uint32_t type GNUNET_PACKED;
349
350 /**
351 * Hop count
352 */
353 uint32_t hop_count GNUNET_PACKED;
354
355 /**
356 * Replication level for this message
357 */
358 uint32_t desired_replication_level GNUNET_PACKED;
359
360 /**
361 * Always zero.
362 */
363 uint32_t reserved GNUNET_PACKED;
364
365 /**
366 * The key to store the value under.
367 */
368 struct GNUNET_HashCode key GNUNET_PACKED;
369
370 /* get path (if tracked) */
371};
372
373/**
374 * Message to monitor get results going through peer, DHT service -> clients.
375 */
376struct GNUNET_DHT_MonitorGetRespMessage
377{
378 /**
379 * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT
380 */
381 struct GNUNET_MessageHeader header;
382
383 /**
384 * Content type.
385 */
386 uint32_t type GNUNET_PACKED;
387
388 /**
389 * Reserved, always 0.
390 */
391 uint32_t reserved GNUNET_PACKED;
392
393 /**
394 * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
395 */
396 uint32_t options GNUNET_PACKED;
397
398 /**
399 * Length of the PUT path that follows (if tracked).
400 */
401 uint32_t put_path_length GNUNET_PACKED;
402
403 /**
404 * Length of the GET path that follows (if tracked).
405 */
406 uint32_t get_path_length GNUNET_PACKED;
407
408 /**
409 * When does the content expire?
410 */
411 struct GNUNET_TIME_AbsoluteNBO expiration_time;
412
413 /**
414 * The key of the corresponding GET request.
415 */
416 struct GNUNET_HashCode key GNUNET_PACKED;
417
418 /* put path (if tracked) */
419
420 /* get path (if tracked) */
421
422 /* Payload */
423};
424
425GNUNET_NETWORK_STRUCT_END
426
427#endif