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