make test case a bit more robust using timeouts and retries
[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 2, 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                                                    struct GNUNET_MessageHeader
34                                                    * msg);
35
36 /**
37  * Generic DHT message, wrapper for other message types
38  */
39 struct GNUNET_DHT_StopMessage
40 {
41   /**
42    * Type: GNUNET_MESSAGE_TYPE_DHT_MESSAGE
43    */
44   struct GNUNET_MessageHeader header;
45
46   /**
47    * Unique ID identifying this request
48    */
49   uint64_t unique_id;
50
51 };
52
53
54 /**
55  * Generic DHT message, wrapper for other message types
56  */
57 struct GNUNET_DHT_Message
58 {
59   /**
60    * Type: GNUNET_MESSAGE_TYPE_DHT_MESSAGE
61    */
62   struct GNUNET_MessageHeader header;
63
64   /**
65    * The key to search for
66    */
67   GNUNET_HashCode key;
68
69   /**
70    * Replication level for this message
71    */
72   uint16_t desired_replication_level;
73
74   /**
75    * Message options
76    */
77   uint16_t options;
78
79   /**
80    * Is this message uniquely identified?  If so it will
81    * be fire and forget, if not we will wait for a receipt
82    * from the service.
83    */
84   uint16_t unique;
85
86
87   /**
88    * Unique ID identifying this request
89    */
90   uint64_t unique_id;
91
92   /* */
93   /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
94
95 };
96
97 /**
98  * Message to insert data into the DHT
99  */
100 struct GNUNET_DHT_PutMessage
101 {
102   /**
103    * Type: GNUNET_MESSAGE_TYPE_DHT_PUT
104    */
105   struct GNUNET_MessageHeader header;
106
107   /**
108    * The type of data to insert.
109    */
110   size_t type;
111
112   /**
113    * The size of the data, appended to the end of this message.
114    */
115   size_t data_size;
116
117   /**
118    * How long should this data persist?
119    */
120   struct GNUNET_TIME_Absolute expiration;
121
122 };
123
124
125 /**
126  * Message to request data from the DHT
127  */
128 struct GNUNET_DHT_GetMessage
129 {
130   /**
131    * Type: GNUNET_MESSAGE_TYPE_DHT_GET
132    */
133   struct GNUNET_MessageHeader header;
134
135   /**
136    * The type for the data for the GET request
137    */
138   size_t type;
139
140 };
141
142 /**
143  * Message to return data from the DHT
144  */
145 struct GNUNET_DHT_GetResultMessage
146 {
147   /**
148    * Type: GNUNET_MESSAGE_TYPE_DHT_GET_RESULT
149    */
150   struct GNUNET_MessageHeader header;
151
152   /**
153    * The type for the data for the GET request
154    */
155   size_t type;
156
157   /**
158    * The key to search for
159    */
160   GNUNET_HashCode key;
161
162   /**
163    * When does this entry expire?
164    */
165   struct GNUNET_TIME_Absolute expiration;
166
167   /**
168    * The size of the data, appended to the end of this message.
169    */
170   size_t data_size;
171
172 };
173
174 /**
175  * Message to issue find peer request to the DHT
176  */
177 struct GNUNET_DHT_FindPeerMessage
178 {
179   /**
180    * Type: GNUNET_MESSAGE_TYPE_DHT_FIND_PEER
181    */
182   struct GNUNET_MessageHeader header;
183
184   /**
185    * Size of inject message (may be zero)
186    */
187   size_t msg_len;
188
189   /* Followed by message to inject at found peers */
190
191 };
192
193 /**
194  * Message to return data from the DHT
195  */
196 struct GNUNET_DHT_FindPeerResultMessage
197 {
198   /**
199    * Type: GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT
200    */
201   struct GNUNET_MessageHeader header;
202
203   /**
204    * The peer that was found
205    */
206   struct GNUNET_PeerIdentity peer;
207
208   /**
209    * The size of the return message from the peer
210    * (defaults to HELLO for the peer),
211    * appended to the end of this message, 0 if
212    * no message.
213    */
214   size_t data_size;
215
216 };
217
218 #endif /* DHT_H_ */