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