program that provides indexing functions of the file-sharing service More...
#include "platform.h"#include <float.h>#include "gnunet_core_service.h"#include "gnunet_datastore_service.h"#include "gnunet_protocols.h"#include "gnunet_signatures.h"#include "gnunet_util_lib.h"#include "gnunet-service-fs.h"#include "gnunet-service-fs_indexing.h"#include "fs.h"Go to the source code of this file.
| Data Structures | |
| struct | IndexInfo | 
| In-memory information about indexed files (also available on-disk).  More... | |
| Functions | |
| static void | write_index_list () | 
| Write the current index information list to disk. | |
| static void | read_index_list () | 
| Read index information from disk. | |
| static void | remove_cont (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) | 
| Continuation called from datastore's remove function. | |
| int | GNUNET_FS_handle_on_demand_block (const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid, GNUNET_DATASTORE_DatumProcessor cont, void *cont_cls) | 
| We've received an on-demand encoded block from the datastore. | |
| void | GNUNET_FS_indexing_send_list (struct GNUNET_MQ_Handle *mq) | 
| Transmit information about indexed files to mq. | |
| int | GNUNET_FS_indexing_do_unindex (const struct GNUNET_HashCode *fid) | 
| Remove a file from the index. | |
| void | GNUNET_FS_add_to_index (const char *filename, const struct GNUNET_HashCode *file_id) | 
| Add the given file to the list of indexed files. | |
| void | GNUNET_FS_indexing_done () | 
| Shutdown the module. | |
| int | GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_DATASTORE_Handle *d) | 
| Initialize the indexing submodule. | |
| Variables | |
| static struct IndexInfo * | indexed_files_head | 
| Head of linked list of indexed files. | |
| static struct IndexInfo * | indexed_files_tail | 
| Tail of linked list of indexed files. | |
| static struct GNUNET_CONTAINER_MultiHashMap * | ifm | 
| Maps hash over content of indexed files to the respective 'struct IndexInfo'. | |
| static const struct GNUNET_CONFIGURATION_Handle * | cfg | 
| Our configuration. | |
| static struct GNUNET_DATASTORE_Handle * | dsh | 
| Datastore handle. | |
program that provides indexing functions of the file-sharing service
Definition in file gnunet-service-fs_indexing.c.
| 
 | static | 
Write the current index information list to disk.
Definition at line 111 of file gnunet-service-fs_indexing.c.
References _, cfg, IndexInfo::file_id, IndexInfo::filename, GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_open_file(), GNUNET_BIO_write_string(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_OK, indexed_files_head, and IndexInfo::next.
Referenced by GNUNET_FS_add_to_index(), and GNUNET_FS_indexing_do_unindex().
| 
 | static | 
Read index information from disk.
Definition at line 159 of file gnunet-service-fs_indexing.c.
References _, cfg, IndexInfo::file_id, IndexInfo::filename, GNUNET_BIO_read(), GNUNET_BIO_read_close(), GNUNET_BIO_read_open_file(), GNUNET_BIO_read_string(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, ifm, indexed_files_head, and indexed_files_tail.
Referenced by GNUNET_FS_indexing_init().
| 
 | static | 
Continuation called from datastore's remove function.
| cls | unused | 
| success | did the deletion work? | 
| min_expiration | minimum expiration time required for content to be stored | 
| msg | error message | 
Definition at line 236 of file gnunet-service-fs_indexing.c.
References _, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, and msg.
Referenced by GNUNET_FS_handle_on_demand_block().
| int GNUNET_FS_handle_on_demand_block | ( | const struct GNUNET_HashCode * | key, | 
| uint32_t | size, | ||
| const void * | data, | ||
| enum GNUNET_BLOCK_Type | type, | ||
| uint32_t | priority, | ||
| uint32_t | anonymity, | ||
| uint32_t | replication, | ||
| struct GNUNET_TIME_Absolute | expiration, | ||
| uint64_t | uid, | ||
| GNUNET_DATASTORE_DatumProcessor | cont, | ||
| void * | cont_cls | ||
| ) | 
We've received an on-demand encoded block from the datastore.
Attempt to do on-demand encoding and (if successful), call the continuation with the resulting block. On error, clean up and ask the datastore for more results.
| key | key for the content | 
| size | number of bytes in data | 
| data | content stored | 
| type | type of the content | 
| priority | priority of the content | 
| anonymity | anonymity-level for the content | 
| replication | replication-level for the content | 
| expiration | expiration time for the content | 
| uid | unique identifier for the datum; maybe 0 if no unique identifier is available | 
| cont | function to call with the actual block (at most once, on success) | 
| cont_cls | closure for cont | 
Definition at line 249 of file gnunet-service-fs_indexing.c.
References _, anonymity, data, DBLOCK_SIZE, dsh, expiration, OnDemandBlock::file_id, IndexInfo::filename, gettext_noop, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_to_aes_key(), GNUNET_CRYPTO_symmetric_encrypt(), GNUNET_DATASTORE_remove(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_ntohll(), GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, GSF_stats, ifm, key, OnDemandBlock::offset, remove_cont(), replication, and size.
Referenced by handle_datastore_reply(), process_local_reply(), and process_migration_content().
| void GNUNET_FS_indexing_send_list | ( | struct GNUNET_MQ_Handle * | mq | ) | 
Transmit information about indexed files to mq.
| mq | message queue to send information to | 
Definition at line 357 of file gnunet-service-fs_indexing.c.
References env, IndexInfoMessage::file_id, IndexInfo::file_id, IndexInfo::filename, GNUNET_break, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY, GNUNET_MQ_msg, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), indexed_files_head, mq, IndexInfo::next, and IndexInfoMessage::reserved.
Referenced by handle_client_index_list_get().
| int GNUNET_FS_indexing_do_unindex | ( | const struct GNUNET_HashCode * | fid | ) | 
Remove a file from the index.
| fid | identifier of the file to remove | 
Definition at line 394 of file gnunet-service-fs_indexing.c.
References IndexInfo::file_id, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_YES, ifm, indexed_files_head, indexed_files_tail, IndexInfo::next, and write_index_list().
Referenced by handle_client_unindex().
| void GNUNET_FS_add_to_index | ( | const char * | filename, | 
| const struct GNUNET_HashCode * | file_id | ||
| ) | 
Add the given file to the list of indexed files.
| filename | name of the file | 
| file_id | hash identifier for filename | 
Definition at line 422 of file gnunet-service-fs_indexing.c.
References _, IndexInfo::file_id, filename, IndexInfo::filename, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, ifm, indexed_files_head, indexed_files_tail, and write_index_list().
Referenced by signal_index_ok().
| void GNUNET_FS_indexing_done | ( | void | ) | 
Shutdown the module.
Definition at line 463 of file gnunet-service-fs_indexing.c.
References cfg, IndexInfo::fhc, IndexInfo::file_id, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash_file_cancel(), GNUNET_free, GNUNET_OK, ifm, indexed_files_head, and indexed_files_tail.
Referenced by shutdown_task().
| int GNUNET_FS_indexing_init | ( | const struct GNUNET_CONFIGURATION_Handle * | c, | 
| struct GNUNET_DATASTORE_Handle * | d | ||
| ) | 
Initialize the indexing submodule.
| c | configuration to use | 
| d | datastore to use | 
Definition at line 484 of file gnunet-service-fs_indexing.c.
References cfg, d, dsh, GNUNET_CONTAINER_multihashmap_create(), GNUNET_OK, GNUNET_YES, ifm, and read_index_list().
Referenced by run().
| 
 | static | 
Head of linked list of indexed files.
FIXME: we don't need both a DLL and a hashmap here!
Definition at line 81 of file gnunet-service-fs_indexing.c.
Referenced by GNUNET_FS_add_to_index(), GNUNET_FS_indexing_do_unindex(), GNUNET_FS_indexing_done(), GNUNET_FS_indexing_send_list(), read_index_list(), and write_index_list().
| 
 | static | 
Tail of linked list of indexed files.
Definition at line 86 of file gnunet-service-fs_indexing.c.
Referenced by GNUNET_FS_add_to_index(), GNUNET_FS_indexing_do_unindex(), GNUNET_FS_indexing_done(), and read_index_list().
| 
 | static | 
Maps hash over content of indexed files to the respective 'struct IndexInfo'.
The filenames are pointers into the indexed_files linked list and do not need to be freed.
Definition at line 93 of file gnunet-service-fs_indexing.c.
Referenced by GNUNET_FS_add_to_index(), GNUNET_FS_handle_on_demand_block(), GNUNET_FS_indexing_do_unindex(), GNUNET_FS_indexing_done(), GNUNET_FS_indexing_init(), and read_index_list().
| 
 | static | 
Our configuration.
Definition at line 98 of file gnunet-service-fs_indexing.c.
Referenced by GNUNET_FS_indexing_done(), GNUNET_FS_indexing_init(), read_index_list(), and write_index_list().
| 
 | static | 
Datastore handle.
Created and destroyed by code in gnunet-service-fs (this is an alias).
Definition at line 104 of file gnunet-service-fs_indexing.c.
Referenced by GNUNET_FS_handle_on_demand_block(), GNUNET_FS_indexing_init(), GNUNET_FS_publish_start(), and GNUNET_FS_publish_ublock_().