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