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