dead
[oweals/gnunet.git] / src / dht / dht.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2009 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 #define DEBUG_DHT GNUNET_NO
31
32 typedef void (*GNUNET_DHT_MessageReceivedHandler) (void *cls,
33                                                    const struct GNUNET_MessageHeader
34                                                    * msg);
35
36 /**
37  * Message which indicates the DHT should cancel outstanding
38  * requests and discard any state.
39  */
40 struct GNUNET_DHT_StopMessage
41 {
42   /**
43    * Type: GNUNET_MESSAGE_TYPE_DHT_STOP
44    */
45   struct GNUNET_MessageHeader header;
46
47   /**
48    * Always zero.
49    */
50   uint32_t reserved GNUNET_PACKED;
51
52   /**
53    * Unique ID identifying this request
54    */
55   uint64_t unique_id GNUNET_PACKED;
56
57 };
58
59
60 /**
61  * Generic DHT message, indicates that a route request
62  * should be issued.
63  */
64 struct GNUNET_DHT_RouteMessage
65 {
66   /**
67    * Type: GNUNET_MESSAGE_TYPE_DHT_ROUTE
68    */
69   struct GNUNET_MessageHeader header;
70
71   /**
72    * Message options
73    */
74   uint32_t options GNUNET_PACKED;
75
76   /**
77    * The key to search for
78    */
79   GNUNET_HashCode key;
80
81   /**
82    * Unique ID identifying this request, if 0 then
83    * the client will not expect a response
84    */
85   uint64_t unique_id GNUNET_PACKED;
86
87   /**
88    * Replication level for this message
89    */
90   uint32_t desired_replication_level GNUNET_PACKED;
91
92
93   /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
94
95 };
96
97 struct GNUNET_DHT_RouteResultMessage
98 {
99   /**
100    * Type: GNUNET_MESSAGE_TYPE_DHT_ROUTE_RESULT
101    */
102   struct GNUNET_MessageHeader header;
103
104   /**
105    * Message options
106    */
107   uint32_t options GNUNET_PACKED;
108
109   /**
110    * The key that was searched for
111    */
112   GNUNET_HashCode key;
113
114   /**
115    * Unique ID identifying this request
116    */
117   uint64_t unique_id GNUNET_PACKED;
118
119   /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
120 };
121
122 /**
123  * Message to insert data into the DHT
124  */
125 struct GNUNET_DHT_PutMessage
126 {
127   /**
128    * Type: GNUNET_MESSAGE_TYPE_DHT_PUT
129    */
130   struct GNUNET_MessageHeader header;
131
132   /**
133    * The type of data to insert.
134    */
135   size_t type GNUNET_PACKED;
136
137   /**
138    * How long should this data persist?
139    */
140   struct GNUNET_TIME_AbsoluteNBO expiration;
141
142   /**
143    * The size of the data, appended to the end of this message.
144    */
145   size_t data_size GNUNET_PACKED;
146
147 };
148
149
150 /**
151  * Message to request data from the DHT
152  */
153 struct GNUNET_DHT_GetMessage
154 {
155   /**
156    * Type: GNUNET_MESSAGE_TYPE_DHT_GET
157    */
158   struct GNUNET_MessageHeader header;
159
160   /**
161    * The type for the data for the GET request
162    */
163   uint32_t type;
164
165 };
166
167 /**
168  * Message to return data from the DHT
169  */
170 struct GNUNET_DHT_GetResultMessage
171 {
172   /**
173    * Type: GNUNET_MESSAGE_TYPE_DHT_GET_RESULT
174    */
175   struct GNUNET_MessageHeader header;
176
177   /**
178    * The type for the data for the GET request
179    */
180   uint32_t type;
181
182   /**
183    * The key to search for
184    */
185   GNUNET_HashCode key;
186
187   /**
188    * When does this entry expire?
189    */
190   struct GNUNET_TIME_Absolute expiration;
191
192 };
193
194
195 #endif /* DHT_H_ */