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