bugfixes
[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.hc
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    * Always zero.
47    */
48   uint32_t reserved GNUNET_PACKED;
49
50   /**
51    * Number of bytes to reserve.
52    */
53   uint64_t amount GNUNET_PACKED;
54
55   /**
56    * Number of items to reserve.
57    */
58   uint64_t entries GNUNET_PACKED;
59 };
60
61
62 /**
63  * Message from datastore service informing client about
64  * the success or failure of a requested operation.
65  * This header is optionally followed by a variable-size,
66  * 0-terminated error message.
67  */
68 struct StatusMessage
69 {
70   /**
71    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_STATUS.
72    */
73   struct GNUNET_MessageHeader header;
74
75   /**
76    * Status code, -1 for errors.
77    */
78   int32_t status GNUNET_PACKED;
79
80 };
81
82
83 /**
84  * Message from datastore client informing service that
85  * the remainder of the reserved bytes can now be released
86  * for other requests.
87  */
88 struct ReleaseReserveMessage
89 {
90   /**
91    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE.
92    */
93   struct GNUNET_MessageHeader header;
94
95   /**
96    * Reservation id.
97    */
98   int32_t rid GNUNET_PACKED;
99
100 };
101
102
103 /**
104  * Message to the datastore service asking about specific
105  * content.
106  */
107 struct GetMessage
108 {
109   /**
110    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET.  Size
111    * can either be "sizeof(struct GetMessage)" or 
112    * "sizeof(struct GetMessage) - sizeof(GNUNET_HashCode)"!
113    */
114   struct GNUNET_MessageHeader header;
115
116   /**
117    * Desired content type.
118    */
119   uint32_t type GNUNET_PACKED;
120
121   /**
122    * Desired key (optional).  Check the "size" of the
123    * header to see if the key is actually present.
124    */
125   GNUNET_HashCode key GNUNET_PACKED;
126
127 };
128
129
130 /**
131  * Message to the datastore service requesting an update
132  * to the priority or expiration for some content.
133  */
134 struct UpdateMessage
135 {
136   /**
137    * Type is GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE.
138    */
139   struct GNUNET_MessageHeader header;
140
141   /**
142    * Desired priority increase.
143    */
144   int32_t priority GNUNET_PACKED;
145
146   /**
147    * Desired new expiration time.
148    */
149   struct GNUNET_TIME_AbsoluteNBO expiration;
150
151   /**
152    * Unique ID for the content.
153    */
154   uint64_t uid;
155
156 };
157
158
159 /**
160  * Message transmitting content from or to the datastore
161  * service.
162  */
163 struct DataMessage
164 {
165   /**
166    * Type is either GNUNET_MESSAGE_TYPE_DATASTORE_PUT,
167    * GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE or
168    * GNUNET_MESSAGE_TYPE_DATASTORE_DATA.  Depending on the message
169    * type, some fields may simply have values of zero.
170    */
171   struct GNUNET_MessageHeader header;
172
173   /**
174    * Reservation ID to use; use zero for none.
175    */
176   uint32_t rid GNUNET_PACKED;
177
178   /**
179    * Number of bytes in the item (NBO).
180    */
181   uint32_t size GNUNET_PACKED;
182
183   /**
184    * Type of the item (NBO), zero for remove.
185    */
186   uint32_t type GNUNET_PACKED;
187
188   /**
189    * Priority of the item (NBO), zero for remove.
190    */
191   uint32_t priority GNUNET_PACKED;
192   
193   /**
194    * Desired anonymity level (NBO), zero for remove.
195    */
196   uint32_t anonymity GNUNET_PACKED;
197
198   /**
199    * Unique ID for the content (can be used for UPDATE);
200    * can be zero for remove (which indicates that
201    * the datastore should use whatever UID matches
202    * the key and content).
203    */
204   uint64_t uid;
205   
206   /**
207    * Expiration time (NBO); zero for remove.
208    */
209   struct GNUNET_TIME_AbsoluteNBO expiration;
210
211   /**
212    * Key under which the item can be found.
213    */
214   GNUNET_HashCode key GNUNET_PACKED;
215
216 };
217
218
219
220
221 #endif