diff options
Diffstat (limited to 'src/fs/fs.h')
-rw-r--r-- | src/fs/fs.h | 396 |
1 files changed, 0 insertions, 396 deletions
diff --git a/src/fs/fs.h b/src/fs/fs.h deleted file mode 100644 index 4c433e774..000000000 --- a/src/fs/fs.h +++ /dev/null | |||
@@ -1,396 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2003--2012 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 fs/fs.h | ||
23 | * @brief definitions for the entire fs module | ||
24 | * @author Igor Wronsky, Christian Grothoff | ||
25 | */ | ||
26 | #ifndef FS_H | ||
27 | #define FS_H | ||
28 | |||
29 | #include "gnunet_constants.h" | ||
30 | #include "gnunet_datastore_service.h" | ||
31 | #include "gnunet_dht_service.h" | ||
32 | #include "gnunet_fs_service.h" | ||
33 | #include "gnunet_block_lib.h" | ||
34 | #include "block_fs.h" | ||
35 | |||
36 | |||
37 | /** | ||
38 | * Size of the individual blocks used for file-sharing. | ||
39 | */ | ||
40 | #define DBLOCK_SIZE (32 * 1024) | ||
41 | |||
42 | /** | ||
43 | * Blocksize to use when hashing files for indexing (blocksize for IO, | ||
44 | * not for the DBlocks). Larger blocksizes can be more efficient but | ||
45 | * will be more disruptive as far as the scheduler is concerned. | ||
46 | */ | ||
47 | #define HASHING_BLOCKSIZE (1024 * 128) | ||
48 | |||
49 | |||
50 | /** | ||
51 | * @brief content hash key | ||
52 | */ | ||
53 | struct ContentHashKey | ||
54 | { | ||
55 | /** | ||
56 | * Hash of the original content, used for encryption. | ||
57 | */ | ||
58 | struct GNUNET_HashCode key; | ||
59 | |||
60 | /** | ||
61 | * Hash of the encrypted content, used for querying. | ||
62 | */ | ||
63 | struct GNUNET_HashCode query; | ||
64 | }; | ||
65 | |||
66 | |||
67 | GNUNET_NETWORK_STRUCT_BEGIN | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Message sent from a GNUnet (fs) publishing activity to sign | ||
72 | * a LOC URI. | ||
73 | */ | ||
74 | struct RequestLocSignatureMessage | ||
75 | { | ||
76 | /** | ||
77 | * Message type will be #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN. | ||
78 | */ | ||
79 | struct GNUNET_MessageHeader header; | ||
80 | |||
81 | /** | ||
82 | * Requested signature purpose. For now, always | ||
83 | * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT. | ||
84 | */ | ||
85 | uint32_t purpose GNUNET_PACKED; | ||
86 | |||
87 | /** | ||
88 | * Requested expiration time. | ||
89 | */ | ||
90 | struct GNUNET_TIME_AbsoluteNBO expiration_time; | ||
91 | |||
92 | /** | ||
93 | * Information about the shared file (to be signed). | ||
94 | */ | ||
95 | struct ContentHashKey chk; | ||
96 | |||
97 | /** | ||
98 | * Size of the shared file (to be signed). | ||
99 | */ | ||
100 | uint64_t file_length; | ||
101 | }; | ||
102 | |||
103 | |||
104 | /** | ||
105 | * Message sent from the service with the signed LOC URI. | ||
106 | */ | ||
107 | struct ResponseLocSignatureMessage | ||
108 | { | ||
109 | /** | ||
110 | * Message type will be | ||
111 | * #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE. | ||
112 | */ | ||
113 | struct GNUNET_MessageHeader header; | ||
114 | |||
115 | /** | ||
116 | * Purpose of the generated signature. For now, always | ||
117 | * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT. | ||
118 | */ | ||
119 | uint32_t purpose GNUNET_PACKED; | ||
120 | |||
121 | /** | ||
122 | * Expiration time that was actually used (rounded!). | ||
123 | */ | ||
124 | struct GNUNET_TIME_AbsoluteNBO expiration_time; | ||
125 | |||
126 | /** | ||
127 | * The requested signature. | ||
128 | */ | ||
129 | struct GNUNET_CRYPTO_EddsaSignature signature; | ||
130 | |||
131 | /** | ||
132 | * Identity of the peer sharing the file. | ||
133 | */ | ||
134 | struct GNUNET_PeerIdentity peer; | ||
135 | }; | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Message sent from a GNUnet (fs) publishing activity to the | ||
140 | * gnunet-fs-service to initiate indexing of a file. The service is | ||
141 | * supposed to check if the specified file is available and has the | ||
142 | * same cryptographic hash. It should then respond with either a | ||
143 | * confirmation or a denial. | ||
144 | * | ||
145 | * On OSes where this works, it is considered acceptable if the | ||
146 | * service only checks that the path, device and inode match (it can | ||
147 | * then be assumed that the hash will also match without actually | ||
148 | * computing it; this is an optimization that should be safe given | ||
149 | * that the client is not our adversary). | ||
150 | */ | ||
151 | struct IndexStartMessage | ||
152 | { | ||
153 | /** | ||
154 | * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START. | ||
155 | */ | ||
156 | struct GNUNET_MessageHeader header; | ||
157 | |||
158 | /** | ||
159 | * For alignment. | ||
160 | */ | ||
161 | uint32_t reserved GNUNET_PACKED; | ||
162 | |||
163 | /** | ||
164 | * ID of device containing the file, as seen by the client. This | ||
165 | * device ID is obtained using a call like "statvfs" (and converting | ||
166 | * the "f_fsid" field to a 32-bit big-endian number). Use 0 if the | ||
167 | * OS does not support this, in which case the service must do a | ||
168 | * full hash recomputation. | ||
169 | */ | ||
170 | uint64_t device GNUNET_PACKED; | ||
171 | |||
172 | /** | ||
173 | * Inode of the file on the given device, as seen by the client | ||
174 | * ("st_ino" field from "struct stat"). Use 0 if the OS does not | ||
175 | * support this, in which case the service must do a full hash | ||
176 | * recomputation. | ||
177 | */ | ||
178 | uint64_t inode GNUNET_PACKED; | ||
179 | |||
180 | /** | ||
181 | * Hash of the file that we would like to index. | ||
182 | */ | ||
183 | struct GNUNET_HashCode file_id; | ||
184 | |||
185 | /* this is followed by a 0-terminated | ||
186 | * filename of a file with the hash | ||
187 | * "file_id" as seen by the client */ | ||
188 | }; | ||
189 | |||
190 | |||
191 | /** | ||
192 | * Message send by FS service in response to a request | ||
193 | * asking for a list of all indexed files. | ||
194 | */ | ||
195 | struct IndexInfoMessage | ||
196 | { | ||
197 | /** | ||
198 | * Message type will be | ||
199 | * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY. | ||
200 | */ | ||
201 | struct GNUNET_MessageHeader header; | ||
202 | |||
203 | /** | ||
204 | * Always zero. | ||
205 | */ | ||
206 | uint32_t reserved GNUNET_PACKED; | ||
207 | |||
208 | /** | ||
209 | * Hash of the indexed file. | ||
210 | */ | ||
211 | struct GNUNET_HashCode file_id; | ||
212 | |||
213 | /* this is followed by a 0-terminated | ||
214 | * filename of a file with the hash | ||
215 | * "file_id" as seen by the client */ | ||
216 | }; | ||
217 | |||
218 | |||
219 | /** | ||
220 | * Message sent from a GNUnet (fs) unindexing activity to the | ||
221 | * gnunet-service-fs to indicate that a file will be unindexed. The | ||
222 | * service is supposed to remove the file from the list of indexed | ||
223 | * files and response with a confirmation message (even if the file | ||
224 | * was already not on the list). | ||
225 | */ | ||
226 | struct UnindexMessage | ||
227 | { | ||
228 | /** | ||
229 | * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX. | ||
230 | */ | ||
231 | struct GNUNET_MessageHeader header; | ||
232 | |||
233 | /** | ||
234 | * Always zero. | ||
235 | */ | ||
236 | uint32_t reserved GNUNET_PACKED; | ||
237 | |||
238 | /** | ||
239 | * Hash of the file that we will unindex. | ||
240 | */ | ||
241 | struct GNUNET_HashCode file_id; | ||
242 | }; | ||
243 | |||
244 | |||
245 | /** | ||
246 | * No options. | ||
247 | */ | ||
248 | #define SEARCH_MESSAGE_OPTION_NONE 0 | ||
249 | |||
250 | /** | ||
251 | * Only search the local datastore (no network) | ||
252 | */ | ||
253 | #define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1 | ||
254 | |||
255 | /** | ||
256 | * Request is too large to fit in 64k format. The list of | ||
257 | * already-known search results will be continued in another message | ||
258 | * for the same type/query/target and additional already-known results | ||
259 | * following this one). | ||
260 | */ | ||
261 | #define SEARCH_MESSAGE_OPTION_CONTINUED 2 | ||
262 | |||
263 | |||
264 | /** | ||
265 | * Message sent from a GNUnet (fs) search activity to the | ||
266 | * gnunet-service-fs to start a search. | ||
267 | */ | ||
268 | struct SearchMessage | ||
269 | { | ||
270 | /** | ||
271 | * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH. | ||
272 | */ | ||
273 | struct GNUNET_MessageHeader header; | ||
274 | |||
275 | /** | ||
276 | * Bitmask with options. Zero for no options, one for | ||
277 | * loopback-only, two for 'to be continued' (with a second search | ||
278 | * message for the same type/query/target and additional | ||
279 | * already-known results following this one). See | ||
280 | * SEARCH_MESSAGE_OPTION_ defines. | ||
281 | * | ||
282 | * Other bits are currently not defined. | ||
283 | */ | ||
284 | uint32_t options GNUNET_PACKED; | ||
285 | |||
286 | /** | ||
287 | * Type of the content that we're looking for. | ||
288 | */ | ||
289 | uint32_t type GNUNET_PACKED; | ||
290 | |||
291 | /** | ||
292 | * Desired anonymity level, big-endian. | ||
293 | */ | ||
294 | uint32_t anonymity_level GNUNET_PACKED; | ||
295 | |||
296 | /** | ||
297 | * If the request is for a DBLOCK or IBLOCK, this is the identity of | ||
298 | * the peer that is known to have a response. Set to all-zeros if | ||
299 | * such a target is not known (note that even if OUR anonymity | ||
300 | * level is >0 we may happen to know the responder's identity; | ||
301 | * nevertheless, we should probably not use it for a DHT-lookup | ||
302 | * or similar blunt actions in order to avoid exposing ourselves). | ||
303 | * <p> | ||
304 | * Otherwise, "target" must be all zeros. | ||
305 | */ | ||
306 | struct GNUNET_PeerIdentity target; | ||
307 | |||
308 | /** | ||
309 | * Hash of the public key for UBLOCKs; Hash of | ||
310 | * the CHK-encoded block for DBLOCKS and IBLOCKS. | ||
311 | */ | ||
312 | struct GNUNET_HashCode query; | ||
313 | |||
314 | /* this is followed by the hash codes of already-known | ||
315 | * results (which should hence be excluded from what | ||
316 | * the service returns); naturally, this only applies | ||
317 | * to queries that can have multiple results (UBLOCKS). | ||
318 | */ | ||
319 | }; | ||
320 | |||
321 | |||
322 | /** | ||
323 | * Response from FS service with a result for a previous FS search. | ||
324 | * Note that queries for DBLOCKS and IBLOCKS that have received a | ||
325 | * single response are considered done. This message is transmitted | ||
326 | * between peers. | ||
327 | */ | ||
328 | struct PutMessage | ||
329 | { | ||
330 | /** | ||
331 | * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT. | ||
332 | */ | ||
333 | struct GNUNET_MessageHeader header; | ||
334 | |||
335 | /** | ||
336 | * Type of the block (in big endian). Should never be zero. | ||
337 | */ | ||
338 | uint32_t type GNUNET_PACKED; | ||
339 | |||
340 | /** | ||
341 | * When does this result expire? | ||
342 | */ | ||
343 | struct GNUNET_TIME_AbsoluteNBO expiration; | ||
344 | |||
345 | /* this is followed by the actual encrypted content */ | ||
346 | }; | ||
347 | |||
348 | /** | ||
349 | * Response from FS service with a result for a previous FS search. | ||
350 | * Note that queries for DBLOCKS and IBLOCKS that have received a | ||
351 | * single response are considered done. This message is transmitted | ||
352 | * between the service and a client. | ||
353 | */ | ||
354 | struct ClientPutMessage | ||
355 | { | ||
356 | /** | ||
357 | * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT. | ||
358 | */ | ||
359 | struct GNUNET_MessageHeader header; | ||
360 | |||
361 | /** | ||
362 | * Type of the block (in big endian). Should never be zero. | ||
363 | */ | ||
364 | uint32_t type GNUNET_PACKED; | ||
365 | |||
366 | /** | ||
367 | * When does this result expire? | ||
368 | */ | ||
369 | struct GNUNET_TIME_AbsoluteNBO expiration; | ||
370 | |||
371 | /** | ||
372 | * When was the last time we've tried to download this block? | ||
373 | * (FOREVER if unknown/not relevant) | ||
374 | */ | ||
375 | struct GNUNET_TIME_AbsoluteNBO last_transmission; | ||
376 | |||
377 | /** | ||
378 | * How often did we transmit this query before getting an | ||
379 | * answer (estimate). | ||
380 | */ | ||
381 | uint32_t num_transmissions; | ||
382 | |||
383 | /** | ||
384 | * How much respect did we offer (in total) before getting an | ||
385 | * answer (estimate). | ||
386 | */ | ||
387 | uint32_t respect_offered; | ||
388 | |||
389 | /* this is followed by the actual encrypted content */ | ||
390 | }; | ||
391 | GNUNET_NETWORK_STRUCT_END | ||
392 | |||
393 | |||
394 | #endif | ||
395 | |||
396 | /* end of fs.h */ | ||