2 This file is part of GNUnet.
3 (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
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.
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.
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.
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_fs_service.h"
34 * Size of the individual blocks used for file-sharing.
36 #define DBLOCK_SIZE (32*1024)
39 * Maximum legal size for a kblock.
41 #define MAX_KBLOCK_SIZE (60 * 1024)
44 * Maximum legal size for an sblock.
46 #define MAX_SBLOCK_SIZE (60 * 1024)
49 * Maximum legal size for an nblock.
51 #define MAX_NBLOCK_SIZE (60 * 1024)
54 * Pick a multiple of 2 here to achive 8-byte alignment!
55 * We also probably want DBlocks to have (roughly) the
56 * same size as IBlocks. With SHA-512, the optimal
57 * value is 32768 byte / 128 byte = 256
58 * (128 byte = 2 * 512 bits). DO NOT CHANGE!
60 #define CHK_PER_INODE 256
64 * Maximum size for a file to be considered for
65 * inlining in a directory.
67 #define MAX_INLINE_SIZE 65536
71 * Blocksize to use when hashing files
72 * for indexing (blocksize for IO, not for
73 * the DBlocks). Larger blocksizes can
74 * be more efficient but will be more disruptive
75 * as far as the scheduler is concerned.
77 #define HASHING_BLOCKSIZE (1024 * 1024)
80 * Number of bits we set per entry in the bloomfilter.
83 #define BLOOMFILTER_K 16
86 * By how much (in ms) do we decrement the TTL
89 #define TTL_DECREMENT 5000
92 * Length of the P2P success tracker. Note that
93 * having a very long list can also hurt performance.
95 #define P2P_SUCCESS_LIST_SIZE 8
99 * Length of the CS-2-P success tracker. Note that
100 * having a very long list can also hurt performance.
102 #define CS2P_SUCCESS_LIST_SIZE 8
105 * How long are we willing to wait for the datastore to be ready to
106 * process a request for a query without priority?
108 #define BASIC_DATASTORE_REQUEST_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
112 * How long are we willing to wait for the core to be ready to
113 * transmit a reply to the target peer (if we can not transmit
114 * until then, we will discard the reply).
116 #define ACCEPTABLE_REPLY_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
120 * Bandwidth value of an (effectively) 0-priority query.
122 #define QUERY_BANDWIDTH_VALUE 0.001
125 * Bandwidth value of a 0-priority content (must be
126 * fairly high compared to query since content is
127 * typically significantly larger -- and more valueable
128 * since it can take many queries to get one piece of
131 #define CONTENT_BANDWIDTH_VALUE 0.8
134 * By which amount do we decrement the TTL for simple forwarding /
135 * indirection of the query; in milli-seconds. Set somewhat in
136 * accordance to your network latency (above the time it'll take you
137 * to send a packet and get a reply).
139 #define TTL_DECREMENT 5000
142 * Until which load do we consider the peer idle and do not
143 * charge at all? (should be larger than GNUNET_IDLE_LOAD_THRESHOLD used
144 * by the rest of the code)!
146 #define IDLE_LOAD_THRESHOLD ((100 + GNUNET_CONSTANTS_IDLE_LOAD_THRESHOLD) / 2)
151 * @brief content hash key
153 struct ContentHashKey
156 GNUNET_HashCode query;
161 * @brief complete information needed
162 * to download a file.
164 struct FileIdentifier
168 * Total size of the file in bytes. (network byte order (!))
170 uint64_t file_length;
173 * Query and key of the top GNUNET_EC_IBlock.
175 struct ContentHashKey chk;
181 * Information about a file and its location
182 * (peer claiming to share the file).
187 * Information about the shared file.
189 struct FileIdentifier fi;
192 * Identity of the peer sharing the file.
194 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer;
197 * Time when this location URI expires.
199 struct GNUNET_TIME_Absolute expirationTime;
202 * RSA signature over the GNUNET_EC_FileIdentifier,
203 * GNUNET_hash of the peer and expiration time.
205 struct GNUNET_CRYPTO_RsaSignature contentSignature;
210 { chk, sks, ksk, loc };
213 * A Universal Resource Identifier (URI), opaque.
223 * Keywords start with a '+' if they are
224 * mandatory (in which case the '+' is NOT
225 * part of the keyword) and with a
226 * simple space if they are optional
227 * (in which case the space is ALSO not
228 * part of the actual keyword).
230 * Double-quotes to protect spaces and
231 * %-encoding are NOT used internally
232 * (only in URI-strings).
237 * Size of the keywords array.
239 unsigned int keywordCount;
245 * Hash of the public key for the namespace.
247 GNUNET_HashCode namespace;
250 * Human-readable identifier chosen for this
251 * entry in the namespace.
257 * Information needed to retrieve a file (content-hash-key
260 struct FileIdentifier chk;
263 * Information needed to retrieve a file including signed
264 * location (identity of a peer) of the content.
273 * Information for a file or directory that is
274 * about to be published.
276 struct GNUNET_FS_FileInformation
280 * Files in a directory are kept as a linked list.
282 struct GNUNET_FS_FileInformation *next;
285 * If this is a file in a directory, "dir" refers to
286 * the directory; otherwise NULL.
288 struct GNUNET_FS_FileInformation *dir;
291 * Pointer kept for the client.
296 * Metadata to use for the file.
298 struct GNUNET_CONTAINER_MetaData *meta;
301 * Keywords to use for KBlocks.
303 struct GNUNET_FS_Uri *keywords;
306 * CHK for this file or directory. NULL if
307 * we have not yet computed it.
309 struct GNUNET_FS_Uri *chk_uri;
312 * At what time should the content expire?
314 struct GNUNET_TIME_Absolute expirationTime;
317 * At what time did we start this upload?
319 struct GNUNET_TIME_Absolute start_time;
322 * Under what filename is this struct serialized
323 * (for operational persistence).
328 * Encoder being used to publish this file.
330 struct GNUNET_FS_TreeEncoder *te;
333 * Error message (non-NULL if this operation
339 * Data describing either the file or the directory.
350 * Function that can be used to read the data for the file.
352 GNUNET_FS_DataReader reader;
355 * Closure for reader.
360 * Name of the file (must be an absolute path).
361 * Only required for indexing. FIXME: not yet
367 * If this file is being indexed, this value
368 * is set to the hash over the entire file
369 * (when the indexing process is started).
370 * Otherwise this field is not used.
372 GNUNET_HashCode file_id;
375 * Size of the file (in bytes).
380 * Should the file be indexed or inserted?
385 * Is "file_id" already valid? Set to GNUNET_YES
386 * once the hash has been calculated.
391 * Has the service confirmed our INDEX_START request?
392 * GNUNET_YES if this step has been completed.
394 int index_start_confirmed;
399 * Data for a directory.
404 * Name of the directory.
409 * Linked list of entries in the directory.
411 struct GNUNET_FS_FileInformation *entries;
414 * Size of the directory itself (in bytes); 0 if the
415 * size has not yet been calculated.
420 * Pointer to the data for the directory (or NULL if not
430 * Is this struct for a file or directory?
435 * Desired anonymity level.
440 * Desired priority (for keeping the content in the DB).
448 * Master context for most FS operations.
450 struct GNUNET_FS_Handle
455 struct GNUNET_SCHEDULER_Handle *sched;
458 * Configuration to use.
460 const struct GNUNET_CONFIGURATION_Handle *cfg;
463 * Name of our client.
468 * Function to call with updates on our progress.
470 GNUNET_FS_ProgressCallback upcb;
478 * Connection to the FS service.
480 struct GNUNET_CLIENT_Connection *client;
483 * How many downloads probing availability
484 * of search results do we have running
487 unsigned int active_probes;
492 enum GNUNET_FS_Flags flags;
498 * Handle for controlling an upload.
500 struct GNUNET_FS_PublishContext
503 * Handle to the global fs context.
505 struct GNUNET_FS_Handle *h;
508 * File-structure that is being shared.
510 struct GNUNET_FS_FileInformation *fi;
513 * Namespace that we are publishing in, NULL if we have no namespace.
515 struct GNUNET_FS_Namespace *namespace;
518 * ID of the content in the namespace, NULL if we have no namespace.
523 * ID for future updates, NULL if we have no namespace or no updates.
528 * Our own client handle for the FS service;
529 * only briefly used when we start to index a
530 * file, otherwise NULL.
532 struct GNUNET_CLIENT_Connection *client;
535 * Current position in the file-tree for the
538 struct GNUNET_FS_FileInformation *fi_pos;
541 * Connection to the datastore service.
543 struct GNUNET_DATASTORE_Handle *dsh;
546 * ID of the task performing the upload. NO_TASK
547 * if the upload has completed.
549 GNUNET_SCHEDULER_TaskIdentifier upload_task;
552 * Typically GNUNET_NO. Set to GNUNET_YES if
553 * "upload_task" is GNUNET_SCHEDULER_NO_TASK
554 * and we're waiting for a response from the
555 * datastore service (in which case this
556 * struct must not be freed until we have that
557 * response). If someone tries to stop the
558 * download for good during this period,
559 * "in_network_wait" is set to GNUNET_SYSERR
560 * which will cause the struct to be destroyed
561 * right after we have the reply (or timeout)
562 * from the datastore service.
567 * Options for publishing.
569 enum GNUNET_FS_PublishOptions options;
572 * Space reservation ID with datastore service
578 * Set to GNUNET_YES if all processing has completed.
585 * Phases of unindex processing (state machine).
590 * We're currently hashing the file.
592 UNINDEX_STATE_HASHING = 0,
595 * We're notifying the FS service about
598 UNINDEX_STATE_FS_NOTIFY = 1,
601 * We're telling the datastore to delete
602 * the respective entries.
604 UNINDEX_STATE_DS_REMOVE = 2,
609 UNINDEX_STATE_COMPLETE = 3,
612 * We've encountered a fatal error.
614 UNINDEX_STATE_ERROR = 4,
617 * We've been aborted. The next callback should clean up the
620 UNINDEX_STATE_ABORTED = 5
625 * Handle for controlling an unindexing operation.
627 struct GNUNET_FS_UnindexContext
633 struct GNUNET_FS_Handle *h;
636 * Name of the file that we are unindexing.
641 * Connection to the FS service,
642 * only valid during the UNINDEX_STATE_FS_NOTIFY
645 struct GNUNET_CLIENT_Connection *client;
648 * Connection to the datastore service,
649 * only valid during the UNINDEX_STATE_DS_NOTIFY
652 struct GNUNET_DATASTORE_Handle *dsh;
655 * Pointer kept for the client.
660 * Merkle-ish tree encoder context.
662 struct GNUNET_FS_TreeEncoder *tc;
665 * Handle used to read the file.
667 struct GNUNET_DISK_FileHandle *fh;
670 * Overall size of the file.
677 struct GNUNET_TIME_Absolute start_time;
680 * Hash of the file's contents (once
683 GNUNET_HashCode file_id;
686 * Current operatinonal phase.
688 enum UnindexState state;
694 * Information we store for each search result.
700 * URI to which this search result
703 struct GNUNET_FS_Uri *uri;
706 * Metadata for the search result.
708 struct GNUNET_CONTAINER_MetaData *meta;
711 * Client info for this search result.
716 * ID of a job that is currently probing
717 * this results' availability (NULL if we
718 * are not currently probing).
720 struct GNUNET_FS_DownloadContext *probe_ctx;
723 * ID of the task that will clean up the probe_ctx
724 * should it not complete on time (and that will
725 * need to be cancelled if we clean up the search
726 * result before then).
728 GNUNET_SCHEDULER_TaskIdentifier probe_cancel_task;
731 * Number of mandatory keywords for which
732 * we have NOT yet found the search result;
733 * when this value hits zero, the search
734 * result is given to the callback.
736 uint32_t mandatory_missing;
739 * Number of optional keywords under which
740 * this result was also found.
742 uint32_t optional_support;
745 * Number of availability tests that
746 * have succeeded for this result.
748 uint32_t availability_success;
751 * Number of availability trials that we
752 * have performed for this search result.
754 uint32_t availability_trials;
760 * Information we keep for each keyword in
763 struct SearchRequestEntry
766 * Hash of the original keyword, also known as the
767 * key (for decrypting the KBlock).
772 * Hash of the public key, also known as the query.
774 GNUNET_HashCode query;
777 * Map that contains a "struct SearchResult" for each result that
778 * was found under this keyword. Note that the entries will point
779 * to the same locations as those in the master result map (in
780 * "struct GNUNET_FS_SearchContext"), so they should not be freed.
781 * The key for each entry is the XOR of the key and query in the CHK
782 * URI (as a unique identifier for the search result).
784 struct GNUNET_CONTAINER_MultiHashMap *results;
787 * Is this keyword a mandatory keyword
788 * (started with '+')?
796 * Handle for controlling a search.
798 struct GNUNET_FS_SearchContext
801 * Handle to the global FS context.
803 struct GNUNET_FS_Handle *h;
806 * List of keywords that we're looking for.
808 struct GNUNET_FS_Uri *uri;
811 * For update-searches, link to the
812 * base-SKS search that triggered the
813 * update search; otherwise NULL.
815 struct GNUNET_FS_SearchContext *parent;
818 * For update-searches, link to the
819 * first child search that triggered the
820 * update search; otherwise NULL.
822 struct GNUNET_FS_SearchContext *child_head;
825 * For update-searches, link to the
826 * last child search that triggered the
827 * update search; otherwise NULL.
829 struct GNUNET_FS_SearchContext *child_tail;
832 * For update-searches, link to the
833 * next child belonging to the same parent.
835 struct GNUNET_FS_SearchContext *next;
838 * For update-searches, link to the
839 * previous child belonging to the same
842 struct GNUNET_FS_SearchContext *prev;
845 * Connection to the FS service.
847 struct GNUNET_CLIENT_Connection *client;
850 * Pointer we keep for the client.
855 * Map that contains a "struct SearchResult" for each result that
856 * was found in the search. The key for each entry is the XOR of
857 * the key and query in the CHK URI (as a unique identifier for the
860 struct GNUNET_CONTAINER_MultiHashMap *master_result_map;
863 * Per-keyword information for a keyword search.
864 * This array will have exactly as many entries
865 * as there were keywords.
867 struct SearchRequestEntry *requests;
872 struct GNUNET_TIME_Absolute start_time;
875 * ID of a task that is using this struct
876 * and that must be cancelled when the search
877 * is being stopped (if not GNUNET_SCHEDULER_NO_TASK).
878 * Used for the task that adds some artificial
879 * delay when trying to reconnect to the FS
882 GNUNET_SCHEDULER_TaskIdentifier task;
885 * Anonymity level for the search.
890 * Number of mandatory keywords in this query.
892 uint32_t mandatory_count;
897 * Information about an active download request.
899 struct DownloadRequest
902 * While pending, we keep all download requests
905 struct DownloadRequest *next;
908 * CHK for the request.
910 struct ContentHashKey chk;
913 * Offset of the corresponding block.
918 * Depth of the corresponding block in the tree.
923 * Set if this request is currently in the linked list of pending
924 * requests. Needed in case we get a response for a request that we
925 * have not yet send (due to FS bug or two blocks with identical
926 * content); in this case, we would need to remove the block from
927 * the pending list (and need a fast way to check if the block is on
936 * Context for controlling a download.
938 struct GNUNET_FS_DownloadContext
944 struct GNUNET_FS_Handle *h;
947 * Connection to the FS service.
949 struct GNUNET_CLIENT_Connection *client;
952 * Parent download (used when downloading files
955 struct GNUNET_FS_DownloadContext *parent;
958 * Head of list of child downloads.
960 struct GNUNET_FS_DownloadContext *child_head;
963 * Tail of list of child downloads.
965 struct GNUNET_FS_DownloadContext *child_tail;
968 * Previous download belonging to the same parent.
970 struct GNUNET_FS_DownloadContext *prev;
973 * Next download belonging to the same parent.
975 struct GNUNET_FS_DownloadContext *next;
978 * Context kept for the client.
983 * URI that identifies the file that
984 * we are downloading.
986 struct GNUNET_FS_Uri *uri;
989 * Known meta-data for the file (can be NULL).
991 struct GNUNET_CONTAINER_MetaData *meta;
994 * Error message, NULL if we're doing OK.
999 * Where are we writing the data (name of the
1000 * file, can be NULL!).
1005 * Where are we writing the data temporarily (name of the
1006 * file, can be NULL!); used if we do not have a permanent
1007 * name and we are a directory and we do a recursive download.
1009 char *temp_filename;
1012 * Map of active requests (those waiting
1013 * for a response). The key is the hash
1014 * of the encryped block (aka query).
1016 struct GNUNET_CONTAINER_MultiHashMap *active;
1019 * Linked list of pending requests.
1021 struct DownloadRequest *pending;
1024 * The file handle, NULL if we don't create
1027 struct GNUNET_DISK_FileHandle *handle;
1030 * Non-NULL if we are currently having a request for
1031 * transmission pending with the client handle.
1033 struct GNUNET_CLIENT_TransmitHandle *th;
1036 * Identity of the peer having the content, or all-zeros
1037 * if we don't know of such a peer.
1039 struct GNUNET_PeerIdentity target;
1042 * ID of a task that is using this struct
1043 * and that must be cancelled when the download
1044 * is being stopped (if not GNUNET_SCHEDULER_NO_TASK).
1045 * Used for the task that adds some artificial
1046 * delay when trying to reconnect to the FS
1049 GNUNET_SCHEDULER_TaskIdentifier task;
1052 * What was the size of the file on disk that we're downloading
1053 * before we started? Used to detect if there is a point in
1054 * checking an existing block on disk for matching the desired
1055 * content. 0 if the file did not exist already.
1057 uint64_t old_file_size;
1060 * What is the first offset that we're interested
1066 * How many bytes starting from offset are desired?
1067 * This is NOT the overall length of the file!
1072 * How many bytes have we already received within
1073 * the specified range (DBlocks only).
1078 * Time download was started.
1080 struct GNUNET_TIME_Absolute start_time;
1083 * Desired level of anonymity.
1088 * The depth of the file-tree.
1090 unsigned int treedepth;
1093 * Options for the download.
1095 enum GNUNET_FS_DownloadOptions options;
1098 * Flag set upon transitive completion (includes child downloads).
1099 * This flag is only set to GNUNET_YES for directories where all
1100 * child-downloads have also completed (and signalled completion).
1106 struct GNUNET_FS_Namespace
1110 * Private key for the namespace.
1112 struct GNUNET_CRYPTO_RsaPrivateKey *key;
1115 * Name of the file with the private key.
1120 * Reference counter.
1127 * @brief index block (indexing a DBlock that
1128 * can be obtained directly from reading
1129 * the plaintext file)
1131 struct OnDemandBlock
1134 * Hash code of the entire content of the
1135 * file that was indexed (used to uniquely
1136 * identify the plaintext file).
1138 GNUNET_HashCode file_id;
1141 * At which offset should we be able to find
1142 * this on-demand encoded block? (in NBO)
1144 uint64_t offset GNUNET_PACKED;
1150 * @brief keyword block (advertising data under a keyword)
1156 * GNUNET_RSA_Signature using RSA-key generated from search keyword.
1158 struct GNUNET_CRYPTO_RsaSignature signature;
1161 * What is being signed and why?
1163 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
1166 * Key generated (!) from the H(keyword) as the seed!
1168 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
1170 /* 0-terminated URI here */
1172 /* variable-size Meta-Data follows here */
1177 * @brief namespace content block (advertising data under an identifier in a namespace)
1183 * GNUNET_RSA_Signature using RSA-key of the namespace
1185 struct GNUNET_CRYPTO_RsaSignature signature;
1188 * What is being signed and why?
1190 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
1193 * Hash of the hash of the human-readable identifier used for
1194 * this entry (the hash of the human-readable identifier is
1195 * used as the key for decryption; the xor of this identifier
1196 * and the hash of the "keyspace" is the datastore-query hash).
1198 GNUNET_HashCode identifier;
1201 * Public key of the namespace.
1203 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
1205 /* 0-terminated update-identifier here */
1207 /* 0-terminated URI here (except for NBlocks) */
1209 /* variable-size Meta-Data follows here */
1215 * @brief namespace advertisement block (advertising root of a namespace)
1221 * GNUNET_RSA_Signature using RSA-key generated from search keyword.
1223 struct GNUNET_CRYPTO_RsaSignature ksk_signature;
1226 * What is being signed and why?
1228 struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose;
1231 * Key generated (!) from the H(keyword) as the seed!
1233 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
1236 * GNUNET_RSA_Signature using RSA-key of the namespace
1238 struct GNUNET_CRYPTO_RsaSignature ns_signature;
1241 * What is being signed and why?
1243 struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose;
1246 * Public key of the namespace.
1248 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
1250 /* from here on, data is encrypted with H(keyword) */
1252 /* 0-terminated root identifier here */
1254 /* variable-size Meta-Data follows here */
1260 * Message sent from a GNUnet (fs) publishing activity to the
1261 * gnunet-fs-service to initiate indexing of a file. The service is
1262 * supposed to check if the specified file is available and has the
1263 * same cryptographic hash. It should then respond with either a
1264 * confirmation or a denial.
1266 * On OSes where this works, it is considered acceptable if the
1267 * service only checks that the path, device and inode match (it can
1268 * then be assumed that the hash will also match without actually
1269 * computing it; this is an optimization that should be safe given
1270 * that the client is not our adversary).
1272 struct IndexStartMessage
1276 * Message type will be GNUNET_MESSAGE_TYPE_FS_INDEX_START.
1278 struct GNUNET_MessageHeader header;
1281 * ID of device containing the file, as seen by the client. This
1282 * device ID is obtained using a call like "statvfs" (and converting
1283 * the "f_fsid" field to a 32-bit big-endian number). Use 0 if the
1284 * OS does not support this, in which case the service must do a
1285 * full hash recomputation.
1287 uint32_t device GNUNET_PACKED;
1290 * Inode of the file on the given device, as seen by the client
1291 * ("st_ino" field from "struct stat"). Use 0 if the OS does not
1292 * support this, in which case the service must do a full hash
1295 uint64_t inode GNUNET_PACKED;
1298 * Hash of the file that we would like to index.
1300 GNUNET_HashCode file_id;
1302 /* this is followed by a 0-terminated
1303 filename of a file with the hash
1304 "file_id" as seen by the client */
1310 * Message send by FS service in response to a request
1311 * asking for a list of all indexed files.
1313 struct IndexInfoMessage
1316 * Message type will be
1317 * GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
1319 struct GNUNET_MessageHeader header;
1324 uint32_t reserved GNUNET_PACKED;
1327 * Hash of the indexed file.
1329 GNUNET_HashCode file_id;
1331 /* this is followed by a 0-terminated
1332 filename of a file with the hash
1333 "file_id" as seen by the client */
1339 * Message sent from a GNUnet (fs) unindexing activity to the
1340 * gnunet-service-fs to indicate that a file will be unindexed. The
1341 * service is supposed to remove the file from the list of indexed
1342 * files and response with a confirmation message (even if the file
1343 * was already not on the list).
1345 struct UnindexMessage
1349 * Message type will be
1350 * GNUNET_MESSAGE_TYPE_FS_UNINDEX.
1352 struct GNUNET_MessageHeader header;
1357 uint32_t reserved GNUNET_PACKED;
1360 * Hash of the file that we will unindex.
1362 GNUNET_HashCode file_id;
1368 * Message sent from a GNUnet (fs) search activity to the
1369 * gnunet-service-fs to start a search.
1371 struct SearchMessage
1375 * Message type will be
1376 * GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
1378 struct GNUNET_MessageHeader header;
1383 int32_t reserved GNUNET_PACKED;
1386 * Type of the content that we're looking for.
1388 uint32_t type GNUNET_PACKED;
1391 * Desired anonymity level, big-endian.
1393 uint32_t anonymity_level GNUNET_PACKED;
1396 * If the request is for a DBLOCK or IBLOCK, this is the identity of
1397 * the peer that is known to have a response. Set to all-zeros if
1398 * such a target is not known (note that even if OUR anonymity
1399 * level is >0 we may happen to know the responder's identity;
1400 * nevertheless, we should probably not use it for a DHT-lookup
1401 * or similar blunt actions in order to avoid exposing ourselves).
1403 * If the request is for an SBLOCK, this is the identity of the
1404 * pseudonym to which the SBLOCK belongs.
1406 * If the request is for a KBLOCK, "target" must be all zeros.
1408 GNUNET_HashCode target;
1411 * Hash of the keyword (aka query) for KBLOCKs; Hash of
1412 * the CHK-encoded block for DBLOCKS and IBLOCKS (aka query)
1413 * and hash of the identifier XORed with the target for
1414 * SBLOCKS (aka query).
1416 GNUNET_HashCode query;
1418 /* this is followed by the hash codes of already-known
1419 results (which should hence be excluded from what
1420 the service returns); naturally, this only applies
1421 to queries that can have multiple results, such as
1422 those for KBLOCKS (KSK) and SBLOCKS (SKS) */
1427 * Only the (mandatory) query is included.
1429 #define GET_MESSAGE_BIT_QUERY_ONLY 0
1432 * The peer identity of a peer waiting for the
1433 * reply is included (used if the response
1434 * should be transmitted to someone other than
1435 * the sender of the GET).
1437 #define GET_MESSAGE_BIT_RETURN_TO 1
1440 * The hash of the public key of the target
1441 * namespace is included (for SKS queries).
1443 #define GET_MESSAGE_BIT_SKS_NAMESPACE 2
1446 * The peer identity of a peer that had claimed to have the content
1447 * previously is included (can be used if responder-anonymity is not
1448 * desired; note that the precursor presumably lacked a direct
1449 * connection to the specified peer; still, the receiver is in no way
1450 * required to limit forwarding only to the specified peer, it should
1451 * only prefer it somewhat if possible).
1453 #define GET_MESSAGE_BIT_TRANSMIT_TO 4
1457 * Message sent between peers asking for FS-content.
1463 * Message type will be GNUNET_MESSAGE_TYPE_FS_GET.
1465 struct GNUNET_MessageHeader header;
1468 * Type of the query (block type).
1470 uint32_t type GNUNET_PACKED;
1473 * How important is this request (network byte order)
1475 uint32_t priority GNUNET_PACKED;
1478 * Relative time to live in GNUNET_CRON_MILLISECONDS (network byte order)
1480 int32_t ttl GNUNET_PACKED;
1483 * The content hash should be mutated using this value
1484 * before checking against the bloomfilter (used to
1485 * get many different filters for the same hash codes).
1486 * The number should be in big-endian format when used
1489 int32_t filter_mutator GNUNET_PACKED;
1492 * Which of the optional hash codes are present at the end of the
1493 * message? See GET_MESSAGE_BIT_xx constants. For each bit that is
1494 * set, an additional GNUNET_HashCode with the respective content
1495 * (in order of the bits) will be appended to the end of the GET
1498 uint32_t hash_bitmap GNUNET_PACKED;
1501 * Hashcodes of the file(s) we're looking for.
1502 * Details depend on the query type.
1504 GNUNET_HashCode query GNUNET_PACKED;
1506 /* this is followed by hash codes
1507 as specified in the "hash_bitmap";
1508 after that, an optional bloomfilter
1509 (with bits set for replies that should
1510 be suppressed) can be present */
1515 * Response from FS service with a result for a previous FS search.
1516 * Note that queries for DBLOCKS and IBLOCKS that have received a
1517 * single response are considered done. This message is transmitted
1518 * between peers as well as between the service and a client.
1524 * Message type will be GNUNET_MESSAGE_TYPE_FS_PUT.
1526 struct GNUNET_MessageHeader header;
1529 * Type of the block (in big endian). Should never be zero.
1531 uint32_t type GNUNET_PACKED;
1534 * When does this result expire?
1536 struct GNUNET_TIME_AbsoluteNBO expiration;
1538 /* this is followed by the actual encrypted content */