fixes
[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_YES
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
77
78 /**
79  * Message from datastore client informing service that
80  * the remainder of the reserved bytes can now be released
81  * for other requests.
82  */
83 struct ReleaseReserveMessage
84 {
85   /**
86    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE.
87    */
88   struct GNUNET_MessageHeader header;
89
90   /**
91    * Reservation id.
92    */
93   int32_t rid GNUNET_PACKED;
94
95 };
96
97
98 /**
99  * Message to the datastore service asking about specific
100  * content.
101  */
102 struct GetMessage
103 {
104   /**
105    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET.  Size
106    * can either be "sizeof(struct GetMessage)" or 
107    * "sizeof(struct GetMessage) - sizeof(GNUNET_HashCode)"!
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    * Desired key (optional).  Check the "size" of the
118    * header to see if the key is actually present.
119    */
120   GNUNET_HashCode key GNUNET_PACKED;
121
122 };
123
124
125 /**
126  * Message to the datastore service asking about zero
127  * anonymity content.
128  */
129 struct GetZeroAnonymityMessage
130 {
131   /**
132    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY.
133    */
134   struct GNUNET_MessageHeader header;
135
136   /**
137    * Desired content type (actually an enum GNUNET_BLOCK_Type)
138    */
139   uint32_t type GNUNET_PACKED;
140
141 };
142
143
144 /**
145  * Message to the datastore service requesting an update
146  * to the priority or expiration for some content.
147  */
148 struct UpdateMessage
149 {
150   /**
151    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE.
152    */
153   struct GNUNET_MessageHeader header;
154
155   /**
156    * Desired priority increase.
157    */
158   int32_t priority GNUNET_PACKED;
159
160   /**
161    * Desired new expiration time.
162    */
163   struct GNUNET_TIME_AbsoluteNBO expiration;
164
165   /**
166    * Unique ID for the content.
167    */
168   uint64_t uid;
169
170 };
171
172
173 /**
174  * Message transmitting content from or to the datastore
175  * service.
176  */
177 struct DataMessage
178 {
179   /**
180    * Type is either GNUNET_MESSAGE_TYPE_DATASTORE_PUT,
181    * GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE or
182    * GNUNET_MESSAGE_TYPE_DATASTORE_DATA.  Depending on the message
183    * type, some fields may simply have values of zero.
184    */
185   struct GNUNET_MessageHeader header;
186
187   /**
188    * Reservation ID to use; use zero for none.
189    */
190   uint32_t rid GNUNET_PACKED;
191
192   /**
193    * Number of bytes in the item (NBO).
194    */
195   uint32_t size GNUNET_PACKED;
196
197   /**
198    * Type of the item (NBO), zero for remove,  (actually an enum GNUNET_BLOCK_Type)
199    */
200   uint32_t type GNUNET_PACKED;
201
202   /**
203    * Priority of the item (NBO), zero for remove.
204    */
205   uint32_t priority GNUNET_PACKED;
206   
207   /**
208    * Desired anonymity level (NBO), zero for remove.
209    */
210   uint32_t anonymity GNUNET_PACKED;
211
212   /**
213    * Unique ID for the content (can be used for UPDATE);
214    * can be zero for remove (which indicates that
215    * the datastore should use whatever UID matches
216    * the key and content).
217    */
218   uint64_t uid;
219   
220   /**
221    * Expiration time (NBO); zero for remove.
222    */
223   struct GNUNET_TIME_AbsoluteNBO expiration;
224
225   /**
226    * Key under which the item can be found.
227    */
228   GNUNET_HashCode key GNUNET_PACKED;
229
230 };
231
232
233
234
235 #endif