print stat
[oweals/gnunet.git] / src / dht / dht.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2009, 2011 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
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 /**
38  * Message which indicates the DHT should cancel outstanding
39  * requests and discard any state.
40  */
41 struct GNUNET_DHT_ClientGetStopMessage
42 {
43   /**
44    * Type: GNUNET_MESSAGE_TYPE_DHT_GET_STOP
45    */
46   struct GNUNET_MessageHeader header;
47
48   /**
49    * Always zero.
50    */
51   uint32_t reserved GNUNET_PACKED;
52
53   /**
54    * Unique ID identifying this request
55    */
56   uint64_t unique_id GNUNET_PACKED;
57
58   /**
59    * Key of this request
60    */
61   GNUNET_HashCode key;
62
63 };
64
65
66 /**
67  * DHT GET message sent from clients to service. Indicates that a GET
68  * request should be issued.
69  */
70 struct GNUNET_DHT_ClientGetMessage
71 {
72   /**
73    * Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET
74    */
75   struct GNUNET_MessageHeader header;
76
77   /**
78    * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
79    */
80   uint32_t options GNUNET_PACKED;
81
82   /**
83    * Replication level for this message
84    */
85   uint32_t desired_replication_level GNUNET_PACKED;
86
87   /**
88    * The type for the data for the GET request; actually an 'enum
89    * GNUNET_BLOCK_Type'.
90    */
91   uint32_t type;
92
93   /**
94    * The key to search for
95    */
96   GNUNET_HashCode key;
97
98   /**
99    * Unique ID identifying this request, if 0 then
100    * the client will not expect a response
101    */
102   uint64_t unique_id GNUNET_PACKED;
103
104   /* Possibly followed by xquery, copied to end of this dealy do */
105
106 };
107
108
109 /**
110  * Reply to a GET send from the service to a client.
111  */
112 struct GNUNET_DHT_ClientResultMessage
113 {
114   /**
115    * Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT
116    */
117   struct GNUNET_MessageHeader header;
118
119   /**
120    * The type for the data.
121    */
122   uint32_t type;
123
124   /**
125    * Number of peers recorded in the outgoing path from source to the
126    * storgage location of this message.
127    */
128   uint32_t put_path_length GNUNET_PACKED;
129
130   /**
131    * The number of peer identities recorded from the storage location
132    * to this peer.
133    */
134   uint32_t get_path_length GNUNET_PACKED;
135
136   /**
137    * Unique ID of the matching GET request.
138    */
139   uint64_t unique_id GNUNET_PACKED;
140
141   /**
142    * When does this entry expire?
143    */
144   struct GNUNET_TIME_AbsoluteNBO expiration;
145
146   /**
147    * The key that was searched for
148    */
149   GNUNET_HashCode key;
150
151   /* put path, get path and actual data are copied to end of this dealy do */
152
153 };
154
155
156 /**
157  * Message to insert data into the DHT, sent from clients to DHT service.
158  */
159 struct GNUNET_DHT_ClientPutMessage
160 {
161   /**
162    * Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT
163    */
164   struct GNUNET_MessageHeader header;
165
166   /**
167    * The type of data to insert.
168    */
169   uint32_t type GNUNET_PACKED;
170
171   /**
172    * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
173    */
174   uint32_t options GNUNET_PACKED;
175
176   /**
177    * Replication level for this message
178    */
179   uint32_t desired_replication_level GNUNET_PACKED;
180
181   /**
182    * How long should this data persist?
183    */
184   struct GNUNET_TIME_AbsoluteNBO expiration;
185
186   /**
187    * The key to store the value under.
188    */
189   GNUNET_HashCode key;
190
191   /* DATA copied to end of this message */
192
193 };
194
195
196 #endif