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