src: for every AGPL3.0 file, add SPDX identifier.
[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 Affero 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      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
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 GetKeyMessage
110 {
111   /**
112    * Type is #GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY.
113    */
114   struct GNUNET_MessageHeader header;
115
116   /**
117    * Desired content type.  (actually an enum GNUNET_BLOCK_Type)
118    */
119   uint32_t type GNUNET_PACKED;
120
121   /**
122    * UID at which to start the search
123    */
124   uint64_t next_uid GNUNET_PACKED;
125
126   /**
127    * If true return a random result
128    */
129   uint32_t random GNUNET_PACKED;
130
131   /**
132    * Desired key.
133    */
134   struct GNUNET_HashCode key;
135
136 };
137
138
139 /**
140  * Message to the datastore service asking about specific
141  * content.
142  */
143 struct GetMessage
144 {
145   /**
146    * Type is #GNUNET_MESSAGE_TYPE_DATASTORE_GET.
147    */
148   struct GNUNET_MessageHeader header;
149
150   /**
151    * Desired content type.  (actually an enum GNUNET_BLOCK_Type)
152    */
153   uint32_t type GNUNET_PACKED;
154
155   /**
156    * UID at which to start the search
157    */
158   uint64_t next_uid GNUNET_PACKED;
159
160   /**
161    * If true return a random result
162    */
163   uint32_t random GNUNET_PACKED;
164
165 };
166
167
168 /**
169  * Message to the datastore service asking about zero
170  * anonymity content.
171  */
172 struct GetZeroAnonymityMessage
173 {
174   /**
175    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY.
176    */
177   struct GNUNET_MessageHeader header;
178
179   /**
180    * Desired content type (actually an enum GNUNET_BLOCK_Type)
181    */
182   uint32_t type GNUNET_PACKED;
183
184   /**
185    * UID at which to start the search
186    */
187   uint64_t next_uid GNUNET_PACKED;
188
189 };
190
191
192 /**
193  * Message transmitting content from or to the datastore
194  * service.
195  */
196 struct DataMessage
197 {
198   /**
199    * Type is either GNUNET_MESSAGE_TYPE_DATASTORE_PUT,
200    * GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE or
201    * GNUNET_MESSAGE_TYPE_DATASTORE_DATA.  Depending on the message
202    * type, some fields may simply have values of zero.
203    */
204   struct GNUNET_MessageHeader header;
205
206   /**
207    * Reservation ID to use; use zero for none.
208    */
209   uint32_t rid GNUNET_PACKED;
210
211   /**
212    * Number of bytes in the item (NBO).
213    */
214   uint32_t size GNUNET_PACKED;
215
216   /**
217    * Type of the item (NBO), zero for remove,  (actually an enum GNUNET_BLOCK_Type)
218    */
219   uint32_t type GNUNET_PACKED;
220
221   /**
222    * Priority of the item (NBO), zero for remove.
223    */
224   uint32_t priority GNUNET_PACKED;
225
226   /**
227    * Desired anonymity level (NBO), zero for remove.
228    */
229   uint32_t anonymity GNUNET_PACKED;
230
231   /**
232    * Desired replication level.
233    */
234   uint32_t replication GNUNET_PACKED;
235
236   /**
237    * For alignment.
238    */
239   uint32_t reserved GNUNET_PACKED;
240
241   /**
242    * Unique ID for the content (can be used for UPDATE);
243    * can be zero for remove (which indicates that
244    * the datastore should use whatever UID matches
245    * the key and content).
246    */
247   uint64_t uid;
248
249   /**
250    * Expiration time (NBO); zero for remove.
251    */
252   struct GNUNET_TIME_AbsoluteNBO expiration;
253
254   /**
255    * Key under which the item can be found.
256    */
257   struct GNUNET_HashCode key;
258
259 };
260 GNUNET_NETWORK_STRUCT_END
261
262
263
264 #endif