38503cfe2106a01a473c8b61e1be0e48272e73ab
[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                                                    const struct GNUNET_MessageHeader
34                                                    * msg);
35
36 /**
37  * FIXME.
38  */
39 struct GNUNET_DHT_StopMessage
40 {
41   /**
42    * Type: GNUNET_MESSAGE_TYPE_DHT_MESSAGE
43    */
44   struct GNUNET_MessageHeader header;
45
46   /**
47    * Always zero.
48    */
49   uint32_t reserved GNUNET_PACKED;
50
51   /**
52    * Unique ID identifying this request
53    */
54   uint64_t unique_id GNUNET_PACKED;
55
56 };
57
58
59 /**
60  * Generic DHT message, wrapper for other message types
61  */
62 struct GNUNET_DHT_Message
63 {
64   /**
65    * Type: GNUNET_MESSAGE_TYPE_DHT_MESSAGE
66    */
67   struct GNUNET_MessageHeader header;
68
69   /**
70    * Message options
71    */
72   uint32_t options GNUNET_PACKED;
73
74   /**
75    * The key to search for
76    */
77   GNUNET_HashCode key;
78
79   /**
80    * Unique ID identifying this request
81    */
82   uint64_t unique_id GNUNET_PACKED;
83
84   /**
85    * Replication level for this message
86    */
87   uint32_t desired_replication_level GNUNET_PACKED;
88
89   /**
90    * Is this message uniquely identified?  If so it will
91    * be fire and forget, if not we will wait for a receipt
92    * from the service.
93    */
94   uint32_t unique GNUNET_PACKED;
95
96   /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
97
98 };
99
100 /**
101  * Message to insert data into the DHT
102  */
103 struct GNUNET_DHT_PutMessage
104 {
105   /**
106    * Type: GNUNET_MESSAGE_TYPE_DHT_PUT
107    */
108   struct GNUNET_MessageHeader header;
109
110   /**
111    * The type of data to insert.
112    */
113   size_t type GNUNET_PACKED;
114
115   /**
116    * How long should this data persist?
117    */
118   struct GNUNET_TIME_AbsoluteNBO expiration;
119
120   /**
121    * The size of the data, appended to the end of this message.
122    */
123   size_t data_size GNUNET_PACKED;
124
125 };
126
127
128 /**
129  * Message to request data from the DHT
130  */
131 struct GNUNET_DHT_GetMessage
132 {
133   /**
134    * Type: GNUNET_MESSAGE_TYPE_DHT_GET
135    */
136   struct GNUNET_MessageHeader header;
137
138   /**
139    * The type for the data for the GET request
140    */
141   uint32_t type;
142
143 };
144
145 /**
146  * Message to return data from the DHT
147  */
148 struct GNUNET_DHT_GetResultMessage
149 {
150   /**
151    * Type: GNUNET_MESSAGE_TYPE_DHT_GET_RESULT
152    */
153   struct GNUNET_MessageHeader header;
154
155   /**
156    * The type for the data for the GET request
157    */
158   uint32_t type;
159
160   /**
161    * The key to search for
162    */
163   GNUNET_HashCode key;
164
165   /**
166    * When does this entry expire?
167    */
168   struct GNUNET_TIME_Absolute expiration;
169
170 };
171
172
173 #endif /* DHT_H_ */