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