adding min_expiration argument to GNUNET_DATASTORE_ContinuationWithStatus callback...
[oweals/gnunet.git] / src / datastore / datastore.h
1 /*
2      This file is part of GNUnet
3      (C) 2004, 2005, 2006, 2007, 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  * @file datastore/datastore.h
23  * @brief structs for communication between datastore service and API
24  * @author Christian Grothoff
25  */
26
27 #ifndef DATASTORE_H
28 #define DATASTORE_H
29
30 #define DEBUG_DATASTORE GNUNET_EXTRA_LOGGING
31
32 #include "gnunet_util_lib.h"
33
34 /**
35  * Message from datastore service informing client about
36  * the current size of the datastore.
37  */
38 struct ReserveMessage
39 {
40   /**
41    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE.
42    */
43   struct GNUNET_MessageHeader header;
44
45   /**
46    * Number of items to reserve.
47    */
48   uint32_t entries GNUNET_PACKED;
49
50   /**
51    * Number of bytes to reserve.
52    */
53   uint64_t amount GNUNET_PACKED;
54 };
55
56
57 /**
58  * Message from datastore service informing client about
59  * the success or failure of a requested operation.
60  * This header is optionally followed by a variable-size,
61  * 0-terminated error message.
62  */
63 struct StatusMessage
64 {
65   /**
66    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_STATUS.
67    */
68   struct GNUNET_MessageHeader header;
69
70   /**
71    * Status code, -1 for errors.
72    */
73   int32_t status GNUNET_PACKED;
74
75   /**
76    * Minimum expiration time required for content to be stored
77    * by the datacache at this time, zero for unknown or no limit.
78    */
79   struct GNUNET_TIME_AbsoluteNBO min_expiration;
80
81 };
82
83
84 /**
85  * Message from datastore client informing service that
86  * the remainder of the reserved bytes can now be released
87  * for other requests.
88  */
89 struct ReleaseReserveMessage
90 {
91   /**
92    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE.
93    */
94   struct GNUNET_MessageHeader header;
95
96   /**
97    * Reservation id.
98    */
99   int32_t rid GNUNET_PACKED;
100
101 };
102
103
104 /**
105  * Message to the datastore service asking about specific
106  * content.
107  */
108 struct GetMessage
109 {
110   /**
111    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET.  Size
112    * can either be "sizeof(struct GetMessage)" or
113    * "sizeof(struct GetMessage) - sizeof(GNUNET_HashCode)"!
114    */
115   struct GNUNET_MessageHeader header;
116
117   /**
118    * Desired content type.  (actually an enum GNUNET_BLOCK_Type)
119    */
120   uint32_t type GNUNET_PACKED;
121
122   /**
123    * Offset of the result.
124    */
125   uint64_t offset GNUNET_PACKED;
126
127   /**
128    * Desired key (optional).  Check the "size" of the
129    * header to see if the key is actually present.
130    */
131   GNUNET_HashCode key GNUNET_PACKED;
132
133 };
134
135
136 /**
137  * Message to the datastore service asking about zero
138  * anonymity content.
139  */
140 struct GetZeroAnonymityMessage
141 {
142   /**
143    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY.
144    */
145   struct GNUNET_MessageHeader header;
146
147   /**
148    * Desired content type (actually an enum GNUNET_BLOCK_Type)
149    */
150   uint32_t type GNUNET_PACKED;
151
152   /**
153    * Offset of the result.
154    */
155   uint64_t offset GNUNET_PACKED;
156
157 };
158
159
160 /**
161  * Message to the datastore service requesting an update
162  * to the priority or expiration for some content.
163  */
164 struct UpdateMessage
165 {
166   /**
167    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE.
168    */
169   struct GNUNET_MessageHeader header;
170
171   /**
172    * Desired priority increase.
173    */
174   int32_t priority GNUNET_PACKED;
175
176   /**
177    * Desired new expiration time.
178    */
179   struct GNUNET_TIME_AbsoluteNBO expiration;
180
181   /**
182    * Unique ID for the content.
183    */
184   uint64_t uid;
185
186 };
187
188
189 /**
190  * Message transmitting content from or to the datastore
191  * service.
192  */
193 struct DataMessage
194 {
195   /**
196    * Type is either GNUNET_MESSAGE_TYPE_DATASTORE_PUT,
197    * GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE or
198    * GNUNET_MESSAGE_TYPE_DATASTORE_DATA.  Depending on the message
199    * type, some fields may simply have values of zero.
200    */
201   struct GNUNET_MessageHeader header;
202
203   /**
204    * Reservation ID to use; use zero for none.
205    */
206   uint32_t rid GNUNET_PACKED;
207
208   /**
209    * Number of bytes in the item (NBO).
210    */
211   uint32_t size GNUNET_PACKED;
212
213   /**
214    * Type of the item (NBO), zero for remove,  (actually an enum GNUNET_BLOCK_Type)
215    */
216   uint32_t type GNUNET_PACKED;
217
218   /**
219    * Priority of the item (NBO), zero for remove.
220    */
221   uint32_t priority GNUNET_PACKED;
222
223   /**
224    * Desired anonymity level (NBO), zero for remove.
225    */
226   uint32_t anonymity GNUNET_PACKED;
227
228   /**
229    * Desired replication level. 0 from service to API.
230    */
231   uint32_t replication GNUNET_PACKED;
232
233   /**
234    * For alignment.
235    */
236   uint32_t reserved GNUNET_PACKED;
237
238   /**
239    * Unique ID for the content (can be used for UPDATE);
240    * can be zero for remove (which indicates that
241    * the datastore should use whatever UID matches
242    * the key and content).
243    */
244   uint64_t uid;
245
246   /**
247    * Expiration time (NBO); zero for remove.
248    */
249   struct GNUNET_TIME_AbsoluteNBO expiration;
250
251   /**
252    * Key under which the item can be found.
253    */
254   GNUNET_HashCode key GNUNET_PACKED;
255
256 };
257
258
259
260
261 #endif