2 This file is part of GNUnet.
3 Copyright (C) 2003--2012 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
23 * @brief definitions for the entire fs module
24 * @author Igor Wronsky, Christian Grothoff
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"
38 * Size of the individual blocks used for file-sharing.
40 #define DBLOCK_SIZE (32 * 1024)
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.
47 #define HASHING_BLOCKSIZE (1024 * 128)
51 * @brief content hash key
53 struct ContentHashKey {
55 * Hash of the original content, used for encryption.
57 struct GNUNET_HashCode key;
60 * Hash of the encrypted content, used for querying.
62 struct GNUNET_HashCode query;
66 GNUNET_NETWORK_STRUCT_BEGIN
70 * Message sent from a GNUnet (fs) publishing activity to sign
73 struct RequestLocSignatureMessage {
75 * Message type will be #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN.
77 struct GNUNET_MessageHeader header;
80 * Requested signature purpose. For now, always
81 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
83 uint32_t purpose GNUNET_PACKED;
86 * Requested expiration time.
88 struct GNUNET_TIME_AbsoluteNBO expiration_time;
91 * Information about the shared file (to be signed).
93 struct ContentHashKey chk;
96 * Size of the shared file (to be signed).
103 * Message sent from the service with the signed LOC URI.
105 struct ResponseLocSignatureMessage {
107 * Message type will be
108 * #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE.
110 struct GNUNET_MessageHeader header;
113 * Purpose of the generated signature. For now, always
114 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
116 uint32_t purpose GNUNET_PACKED;
119 * Expiration time that was actually used (rounded!).
121 struct GNUNET_TIME_AbsoluteNBO expiration_time;
124 * The requested signature.
126 struct GNUNET_CRYPTO_EddsaSignature signature;
129 * Identity of the peer sharing the file.
131 struct GNUNET_PeerIdentity peer;
136 * Message sent from a GNUnet (fs) publishing activity to the
137 * gnunet-fs-service to initiate indexing of a file. The service is
138 * supposed to check if the specified file is available and has the
139 * same cryptographic hash. It should then respond with either a
140 * confirmation or a denial.
142 * On OSes where this works, it is considered acceptable if the
143 * service only checks that the path, device and inode match (it can
144 * then be assumed that the hash will also match without actually
145 * computing it; this is an optimization that should be safe given
146 * that the client is not our adversary).
148 struct IndexStartMessage {
150 * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START.
152 struct GNUNET_MessageHeader header;
157 uint32_t reserved GNUNET_PACKED;
160 * ID of device containing the file, as seen by the client. This
161 * device ID is obtained using a call like "statvfs" (and converting
162 * the "f_fsid" field to a 32-bit big-endian number). Use 0 if the
163 * OS does not support this, in which case the service must do a
164 * full hash recomputation.
166 uint64_t device GNUNET_PACKED;
169 * Inode of the file on the given device, as seen by the client
170 * ("st_ino" field from "struct stat"). Use 0 if the OS does not
171 * support this, in which case the service must do a full hash
174 uint64_t inode GNUNET_PACKED;
177 * Hash of the file that we would like to index.
179 struct GNUNET_HashCode file_id;
181 /* this is followed by a 0-terminated
182 * filename of a file with the hash
183 * "file_id" as seen by the client */
188 * Message send by FS service in response to a request
189 * asking for a list of all indexed files.
191 struct IndexInfoMessage {
193 * Message type will be
194 * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
196 struct GNUNET_MessageHeader header;
201 uint32_t reserved GNUNET_PACKED;
204 * Hash of the indexed file.
206 struct GNUNET_HashCode file_id;
208 /* this is followed by a 0-terminated
209 * filename of a file with the hash
210 * "file_id" as seen by the client */
215 * Message sent from a GNUnet (fs) unindexing activity to the
216 * gnunet-service-fs to indicate that a file will be unindexed. The
217 * service is supposed to remove the file from the list of indexed
218 * files and response with a confirmation message (even if the file
219 * was already not on the list).
221 struct UnindexMessage {
223 * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX.
225 struct GNUNET_MessageHeader header;
230 uint32_t reserved GNUNET_PACKED;
233 * Hash of the file that we will unindex.
235 struct GNUNET_HashCode file_id;
242 #define SEARCH_MESSAGE_OPTION_NONE 0
245 * Only search the local datastore (no network)
247 #define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
250 * Request is too large to fit in 64k format. The list of
251 * already-known search results will be continued in another message
252 * for the same type/query/target and additional already-known results
253 * following this one).
255 #define SEARCH_MESSAGE_OPTION_CONTINUED 2
259 * Message sent from a GNUnet (fs) search activity to the
260 * gnunet-service-fs to start a search.
262 struct SearchMessage {
264 * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
266 struct GNUNET_MessageHeader header;
269 * Bitmask with options. Zero for no options, one for
270 * loopback-only, two for 'to be continued' (with a second search
271 * message for the same type/query/target and additional
272 * already-known results following this one). See
273 * SEARCH_MESSAGE_OPTION_ defines.
275 * Other bits are currently not defined.
277 uint32_t options GNUNET_PACKED;
280 * Type of the content that we're looking for.
282 uint32_t type GNUNET_PACKED;
285 * Desired anonymity level, big-endian.
287 uint32_t anonymity_level GNUNET_PACKED;
290 * If the request is for a DBLOCK or IBLOCK, this is the identity of
291 * the peer that is known to have a response. Set to all-zeros if
292 * such a target is not known (note that even if OUR anonymity
293 * level is >0 we may happen to know the responder's identity;
294 * nevertheless, we should probably not use it for a DHT-lookup
295 * or similar blunt actions in order to avoid exposing ourselves).
297 * Otherwise, "target" must be all zeros.
299 struct GNUNET_PeerIdentity target;
302 * Hash of the public key for UBLOCKs; Hash of
303 * the CHK-encoded block for DBLOCKS and IBLOCKS.
305 struct GNUNET_HashCode query;
307 /* this is followed by the hash codes of already-known
308 * results (which should hence be excluded from what
309 * the service returns); naturally, this only applies
310 * to queries that can have multiple results (UBLOCKS).
316 * Response from FS service with a result for a previous FS search.
317 * Note that queries for DBLOCKS and IBLOCKS that have received a
318 * single response are considered done. This message is transmitted
323 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
325 struct GNUNET_MessageHeader header;
328 * Type of the block (in big endian). Should never be zero.
330 uint32_t type GNUNET_PACKED;
333 * When does this result expire?
335 struct GNUNET_TIME_AbsoluteNBO expiration;
337 /* this is followed by the actual encrypted content */
341 * Response from FS service with a result for a previous FS search.
342 * Note that queries for DBLOCKS and IBLOCKS that have received a
343 * single response are considered done. This message is transmitted
344 * between the service and a client.
346 struct ClientPutMessage {
348 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
350 struct GNUNET_MessageHeader header;
353 * Type of the block (in big endian). Should never be zero.
355 uint32_t type GNUNET_PACKED;
358 * When does this result expire?
360 struct GNUNET_TIME_AbsoluteNBO expiration;
363 * When was the last time we've tried to download this block?
364 * (FOREVER if unknown/not relevant)
366 struct GNUNET_TIME_AbsoluteNBO last_transmission;
369 * How often did we transmit this query before getting an
372 uint32_t num_transmissions;
375 * How much respect did we offer (in total) before getting an
378 uint32_t respect_offered;
380 /* this is followed by the actual encrypted content */
382 GNUNET_NETWORK_STRUCT_END