Helper functions for searching. More...
#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_fs_service.h"
#include "gnunet_protocols.h"
#include "fs_api.h"
#include "fs_publish_ublock.h"
Go to the source code of this file.
Data Structures | |
struct | GetResultContext |
Context for "get_result_present". More... | |
struct | MessageBuilderContext |
Closure for build_result_set(). More... | |
Macros | |
#define | AVAILABILITY_TRIALS_MAX 8 |
Number of availability trials we perform per search result. More... | |
Functions | |
void * | GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc) |
Fill in all of the generic fields for a search event and call the callback. More... | |
static int | test_result_present (void *cls, const struct GNUNET_HashCode *key, void *value) |
Check if the given result is identical to the given URI. More... | |
static void | notify_client_chk_result (struct GNUNET_FS_SearchContext *sc, struct GNUNET_FS_SearchResult *sr) |
We've found a new CHK result. More... | |
static void | notify_client_chk_update (struct GNUNET_FS_SearchContext *sc, struct GNUNET_FS_SearchResult *sr) |
We've found new information about an existing CHK result. More... | |
static int | get_result_present (void *cls, const struct GNUNET_HashCode *key, void *value) |
Check if the given result is identical to the given URI and if so return it. More... | |
static void | signal_probe_result (struct GNUNET_FS_SearchResult *sr) |
Signal result of last probe to client and then schedule next probe. More... | |
static void | probe_failure_handler (void *cls) |
Handle the case where we have failed to receive a response for our probe. More... | |
static void | probe_success_handler (void *cls) |
Handle the case where we have gotten a response for our probe. More... | |
void * | GNUNET_FS_search_probe_progress_ (void *cls, const struct GNUNET_FS_ProgressInfo *info) |
Notification of FS that a search probe has made progress. More... | |
static void | probe_ping_task_cb (void *cls) |
Task run periodically to remind clients that a probe is active. More... | |
static void | start_probe_ping_task (struct GNUNET_FS_SearchResult *sr) |
Start the ping task for this search result. More... | |
void | GNUNET_FS_stop_probe_ping_task_ (struct GNUNET_FS_SearchResult *sr) |
Stop the ping task for this search result. More... | |
void | GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr) |
Start download probes for the given search result. More... | |
struct GNUNET_FS_SearchResult * | GNUNET_FS_probe (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, void *client_info, uint32_t anonymity) |
Start download probes for the given search result. More... | |
static void | GNUNET_FS_search_stop_probe_ (struct GNUNET_FS_SearchResult *sr) |
Stop probing activity associated with a search result. More... | |
void * | GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr) |
Stop probe activity. More... | |
static void | process_ksk_result (struct GNUNET_FS_SearchContext *sc, struct SearchRequestEntry *ent, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta) |
We have received a KSK result. More... | |
static struct GNUNET_FS_SearchContext * | search_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx, struct GNUNET_FS_SearchResult *psearch) |
Start search for content, internal API. More... | |
static void | process_sks_result (struct GNUNET_FS_SearchContext *sc, const char *id_update, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta) |
We have received an SKS result. More... | |
static int | decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc, const struct GNUNET_CRYPTO_EcdsaPublicKey *dpub, const void *edata, size_t edata_size, char *data) |
Decrypt a ublock using a 'keyword' as the passphrase. More... | |
static void | process_kblock (struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub, size_t size) |
Process a keyword search result. More... | |
static void | process_sblock (struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub, size_t size) |
Process a namespace-search result. More... | |
static void | try_reconnect (struct GNUNET_FS_SearchContext *sc) |
Shutdown any existing connection to the FS service and try to establish a fresh one (and then re-transmit our search request). More... | |
static int | check_result (void *cls, const struct ClientPutMessage *cm) |
We check a result message from the service. More... | |
static void | handle_result (void *cls, const struct ClientPutMessage *cm) |
We process a search result from the service. More... | |
static void | schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) |
Schedule the transmission of the (next) search request to the service. More... | |
static int | build_result_set (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterating over the known results, pick those matching the given result range and store their keys at 'xoff'. More... | |
static int | find_result_set (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterating over the known results, count those matching the given result range and increment put count for each. More... | |
static void | search_mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More... | |
static void | do_reconnect (void *cls) |
Reconnect to the FS service and transmit our queries NOW. More... | |
static int | update_sre_result_maps (void *cls, const struct GNUNET_HashCode *key, void *value) |
Update the 'results' map for the individual keywords with the results from the 'global' result set. More... | |
int | GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc) |
Build the request and actually initiate the search using the GNUnet FS service. More... | |
static int | search_result_freeze_probes (void *cls, const struct GNUNET_HashCode *key, void *value) |
Freeze probes for the given search result. More... | |
static int | search_result_resume_probes (void *cls, const struct GNUNET_HashCode *key, void *value) |
Resume probes for the given search result. More... | |
static int | search_result_suspend (void *cls, const struct GNUNET_HashCode *key, void *value) |
Signal suspend and free the given search result. More... | |
void | GNUNET_FS_search_signal_suspend_ (void *cls) |
Create SUSPEND event for the given search operation and then clean up our state (without stop signal). More... | |
struct GNUNET_FS_SearchContext * | GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx) |
Start search for content. More... | |
void | GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc) |
Pause search. More... | |
void | GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc) |
Continue paused search. More... | |
static int | search_result_stop (void *cls, const struct GNUNET_HashCode *key, void *value) |
Signal stop for the given search result. More... | |
static int | search_result_free (void *cls, const struct GNUNET_HashCode *key, void *value) |
Free the given search result. More... | |
void | GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) |
Stop search for content. More... | |
Helper functions for searching.
Definition in file fs_search.c.
#define AVAILABILITY_TRIALS_MAX 8 |
Number of availability trials we perform per search result.
Definition at line 37 of file fs_search.c.
void * GNUNET_FS_search_make_status_ | ( | struct GNUNET_FS_ProgressInfo * | pi, |
struct GNUNET_FS_Handle * | h, | ||
struct GNUNET_FS_SearchContext * | sc | ||
) |
Fill in all of the generic fields for a search event and call the callback.
pi | structure to fill in |
h | file-sharing handle |
sc | overall search context |
Definition at line 49 of file fs_search.c.
References GNUNET_FS_SearchContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchContext::client_info, GNUNET_FS_ProgressInfo::fsh, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_ZERO, h, GNUNET_FS_SearchContext::psearch_result, ret, sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_SearchContext::start_time, GNUNET_FS_SearchContext::uri, and GNUNET_FS_ProgressInfo::value.
Referenced by GNUNET_FS_search_continue(), GNUNET_FS_search_pause(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop(), notify_client_chk_result(), notify_client_chk_update(), search_result_stop(), search_result_suspend(), search_start(), signal_probe_result(), signal_result_resume(), and signal_search_resume().
|
static |
Check if the given result is identical to the given URI.
cls | points to the URI we check against |
key | not used |
value | a struct GNUNET_FS_SearchResult who's URI we should compare with |
Definition at line 84 of file fs_search.c.
References GNUNET_FS_uri_test_equal(), GNUNET_OK, GNUNET_SYSERR, uri, GNUNET_FS_SearchResult::uri, and value.
Referenced by process_ksk_result(), and process_sks_result().
|
static |
We've found a new CHK result.
Let the client know about it.
sc | the search context |
sr | the specific result |
Definition at line 105 of file fs_search.c.
References GNUNET_FS_SearchResult::client_info, GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_RESULT, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::uri, and GNUNET_FS_ProgressInfo::value.
Referenced by process_ksk_result(), and process_sks_result().
|
static |
We've found new information about an existing CHK result.
Let the client know about it.
sc | the search context |
sr | the specific result |
Definition at line 127 of file fs_search.c.
References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, GNUNET_FS_SearchResult::client_info, GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_UPDATE, GNUNET_TIME_absolute_get_duration(), GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, GNUNET_FS_SearchResult::probe_active_time, sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::uri, and GNUNET_FS_ProgressInfo::value.
Referenced by process_ksk_result().
|
static |
Check if the given result is identical to the given URI and if so return it.
cls | a struct GetResultContext |
key | not used |
value | a struct GNUNET_FS_SearchResult who's URI we should compare with |
Definition at line 176 of file fs_search.c.
References GNUNET_FS_uri_test_equal(), GNUNET_OK, GetResultContext::sr, GNUNET_FS_SearchResult::uri, GetResultContext::uri, and value.
Referenced by process_ksk_result().
|
static |
Signal result of last probe to client and then schedule next probe.
sr | search result to signal for |
Definition at line 196 of file fs_search.c.
References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, GNUNET_FS_SearchResult::client_info, GNUNET_FS_search_make_status_(), GNUNET_FS_search_start_probe_(), GNUNET_FS_STATUS_SEARCH_UPDATE, GNUNET_TIME_absolute_get_duration(), GNUNET_FS_SearchResult::h, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, GNUNET_FS_SearchResult::probe_active_time, GNUNET_FS_SearchResult::sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::uri, and GNUNET_FS_ProgressInfo::value.
Referenced by probe_failure_handler(), probe_ping_task_cb(), and probe_success_handler().
|
static |
Handle the case where we have failed to receive a response for our probe.
cls | our struct GNUNET_FS_SearchResult * |
Definition at line 222 of file fs_search.c.
References GNUNET_FS_SearchResult::availability_trials, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_download_stop(), GNUNET_FS_search_result_sync_(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_log, GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, and signal_probe_result().
Referenced by GNUNET_FS_search_probe_progress_().
|
static |
Handle the case where we have gotten a response for our probe.
cls | our struct GNUNET_FS_SearchResult * |
Definition at line 246 of file fs_search.c.
References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_download_stop(), GNUNET_FS_search_result_sync_(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_log, GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, and signal_probe_result().
Referenced by GNUNET_FS_search_probe_progress_().
void * GNUNET_FS_search_probe_progress_ | ( | void * | cls, |
const struct GNUNET_FS_ProgressInfo * | info | ||
) |
Notification of FS that a search probe has made progress.
This function is used INSTEAD of the client's event handler for downloads where the GNUNET_FS_DOWNLOAD_IS_PROBE flag is set.
cls | closure, always NULL (!), actual closure is in the client-context of the info struct |
info | details about the event, specifying the event type and various bits about the event |
struct GNUNET_FS_ProgressInfo
. Definition at line 281 of file fs_search.c.
References GNUNET_assert, GNUNET_break, GNUNET_FS_search_result_sync_(), GNUNET_FS_STATUS_DOWNLOAD_ACTIVE, GNUNET_FS_STATUS_DOWNLOAD_COMPLETED, GNUNET_FS_STATUS_DOWNLOAD_ERROR, GNUNET_FS_STATUS_DOWNLOAD_INACTIVE, GNUNET_FS_STATUS_DOWNLOAD_PROGRESS, GNUNET_FS_STATUS_DOWNLOAD_RESUME, GNUNET_FS_STATUS_DOWNLOAD_START, GNUNET_FS_STATUS_DOWNLOAD_STOPPED, GNUNET_FS_STATUS_DOWNLOAD_SUSPEND, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_subtract(), info, GNUNET_FS_SearchResult::probe_active_time, GNUNET_FS_SearchResult::probe_cancel_task, probe_failure_handler(), probe_success_handler(), GNUNET_TIME_Relative::rel_value_us, and GNUNET_FS_SearchResult::remaining_probe_time.
Referenced by GNUNET_FS_download_make_status_().
|
static |
Task run periodically to remind clients that a probe is active.
cls | the struct GNUNET_FS_SearchResult that we are probing for |
Definition at line 368 of file fs_search.c.
References GNUNET_FS_PROBE_UPDATE_FREQUENCY, GNUNET_SCHEDULER_add_delayed(), h, probe_ping_task_cb(), and signal_probe_result().
Referenced by probe_ping_task_cb(), and start_probe_ping_task().
|
static |
Start the ping task for this search result.
sr | result to start pinging for. |
Definition at line 390 of file fs_search.c.
References GNUNET_CONTAINER_DLL_insert, GNUNET_SCHEDULER_add_now(), h, GNUNET_FS_SearchResult::h, and probe_ping_task_cb().
Referenced by GNUNET_FS_search_start_probe_().
void GNUNET_FS_stop_probe_ping_task_ | ( | struct GNUNET_FS_SearchResult * | sr | ) |
Stop the ping task for this search result.
sr | result to start pinging for. |
Definition at line 410 of file fs_search.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_SCHEDULER_cancel(), h, and GNUNET_FS_SearchResult::h.
Referenced by GNUNET_FS_download_start_from_search(), GNUNET_FS_search_stop_probe_(), probe_failure_handler(), probe_success_handler(), and search_result_freeze_probes().
void GNUNET_FS_search_start_probe_ | ( | struct GNUNET_FS_SearchResult * | sr | ) |
Start download probes for the given search result.
sr | the search result |
Definition at line 431 of file fs_search.c.
References GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, AVAILABILITY_TRIALS_MAX, GNUNET_FS_Handle::avg_block_latency, DBLOCK_SIZE, GNUNET_FS_SearchResult::download, GNUNET_FS_Handle::flags, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_DOWNLOAD_NO_TEMPORARIES, GNUNET_FS_download_start(), GNUNET_FS_FLAGS_DO_PROBES, GNUNET_FS_URI_CHK, GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_URI_LOC, GNUNET_log, GNUNET_TIME_relative_saturating_multiply(), GNUNET_FS_SearchResult::h, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_SearchResult::remaining_probe_time, start_probe_ping_task(), GNUNET_FS_Uri::type, and GNUNET_FS_SearchResult::uri.
Referenced by GNUNET_FS_probe(), process_ksk_result(), process_sks_result(), search_result_resume_probes(), signal_probe_result(), and signal_result_resume().
|
static |
Stop probing activity associated with a search result.
sr | search result |
Definition at line 516 of file fs_search.c.
References GNUNET_FS_download_stop(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, and GNUNET_FS_SearchResult::probe_ctx.
Referenced by GNUNET_FS_probe_stop(), search_result_stop(), and search_result_suspend().
|
static |
We have received a KSK result.
Check how it fits in with the overall query and notify the client accordingly.
sc | context for the overall query |
ent | entry for the specific keyword |
uri | the URI that was found |
meta | metadata associated with the URI under the ent keyword |
Definition at line 565 of file fs_search.c.
References GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_Uri::data, get_result_present(), GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_FS_meta_data_duplicate(), GNUNET_FS_meta_data_merge(), GNUNET_FS_search_result_sync_(), GNUNET_FS_search_start_probe_(), GNUNET_FS_uri_dup(), GNUNET_FS_uri_to_key(), GNUNET_malloc, GNUNET_new, GNUNET_OK, GNUNET_SYSERR, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchContext::h, key, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, SearchRequestEntry::mandatory, GNUNET_FS_SearchContext::mandatory_count, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchContext::master_result_map, meta, GNUNET_FS_SearchResult::meta, notify_client_chk_result(), notify_client_chk_update(), GNUNET_FS_SearchResult::optional_support, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, GNUNET_FS_SearchResult::sc, GetResultContext::sr, test_result_present(), uri, GNUNET_FS_SearchResult::uri, GNUNET_FS_SearchContext::uri, and GetResultContext::uri.
Referenced by process_kblock().
|
static |
Start search for content, internal API.
h | handle to the file sharing subsystem |
uri | specifies the search parameters; can be a KSK URI or an SKS URI. |
anonymity | desired level of anonymity |
options | options for the search |
cctx | client context |
psearch | parent search result (for namespace update searches) |
h | handle to the file sharing subsystem |
uri | specifies the search parameters; can be a KSK URI or an SKS URI. |
anonymity | desired level of anonymity |
options | options for the search |
cctx | initial value for the client context |
psearch | parent search result (for namespace update searches) |
Definition at line 1334 of file fs_search.c.
References anonymity, GNUNET_FS_SearchContext::anonymity, GNUNET_FS_ProgressInfo::cctx, GNUNET_FS_SearchContext::client_info, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_free, GNUNET_FS_search_make_status_(), GNUNET_FS_search_start_searching_(), GNUNET_FS_search_sync_(), GNUNET_FS_STATUS_SEARCH_START, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_dup(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_get(), h, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchContext::master_result_map, options, GNUNET_FS_SearchContext::options, GNUNET_FS_SearchContext::psearch_result, sc, GNUNET_FS_SearchContext::start_time, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::update_search, uri, and GNUNET_FS_SearchContext::uri.
Referenced by GNUNET_FS_search_start(), and process_sks_result().
|
static |
We have received an SKS result.
Start searching for updates and notify the client if it is a new result.
sc | context for the overall query |
id_update | identifier for updates, NULL for none |
uri | the URI that was found |
meta | metadata associated with the URI |
Definition at line 686 of file fs_search.c.
References GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchContext::anonymity, FileIdentifier::chk, GNUNET_FS_Uri::chk, GNUNET_FS_SearchResult::client_info, GNUNET_FS_Uri::data, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash_xor(), GNUNET_free, GNUNET_FS_meta_data_duplicate(), GNUNET_FS_search_result_sync_(), GNUNET_FS_search_start_probe_(), GNUNET_FS_uri_dup(), GNUNET_FS_URI_SKS, GNUNET_FS_uri_to_key(), GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchContext::h, GNUNET_FS_Uri::identifier, key, ContentHashKey::key, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchContext::master_result_map, meta, GNUNET_FS_SearchResult::meta, notify_client_chk_result(), GNUNET_FS_Uri::ns, GNUNET_FS_SearchContext::options, ContentHashKey::query, sc, GNUNET_FS_SearchResult::sc, search_start(), GNUNET_FS_Uri::sks, test_result_present(), GNUNET_FS_Uri::type, uri, GNUNET_FS_SearchResult::uri, and GNUNET_FS_SearchContext::uri.
Referenced by process_sblock().
|
static |
Decrypt a ublock using a 'keyword' as the passphrase.
Given the KSK public key derived from the keyword, this function looks up the original keyword in the search context and decrypts the given ciphertext block.
sc | search context with the keywords |
dpub | derived public key used for the search |
edata | encrypted data |
edata_size | number of bytes in edata (and data) |
data | where to store the plaintext |
Definition at line 754 of file fs_search.c.
References data, GNUNET_FS_Uri::data, SearchRequestEntry::dpub, GNUNET_break, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_FS_ublock_decrypt_(), GNUNET_SYSERR, SearchRequestEntry::keyword, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::requests, sc, and GNUNET_FS_SearchContext::uri.
Referenced by process_kblock().
|
static |
Process a keyword search result.
The actual type of block is a UBlock; we know it is a keyword search result because that's what we were searching for.
sc | our search context |
ub | the ublock with the keyword search result |
size | size of ub |
Definition at line 797 of file fs_search.c.
References _, decrypt_block_with_keyword(), GNUNET_break_op, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_deserialize(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_parse(), GNUNET_FS_VERSION, GNUNET_log, meta, process_ksk_result(), GNUNET_FS_SearchContext::requests, sc, size, uri, and UBlock::verification_key.
Referenced by handle_result().
|
static |
Process a namespace-search result.
The actual type of block is a UBlock; we know it is a namespace search result because that's what we were searching for.
sc | our search context |
ub | the ublock with a namespace result |
size | size of ub |
Definition at line 869 of file fs_search.c.
References _, GNUNET_FS_Uri::data, GNUNET_break_op, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_meta_data_deserialize(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_ublock_decrypt_(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_parse(), GNUNET_log, GNUNET_STRINGS_buffer_tokenize(), id, GNUNET_FS_Uri::identifier, meta, GNUNET_FS_Uri::ns, process_sks_result(), sc, size, GNUNET_FS_Uri::sks, uri, and GNUNET_FS_SearchContext::uri.
Referenced by handle_result().
|
static |
Shutdown any existing connection to the FS service and try to establish a fresh one (and then re-transmit our search request).
sc | the search to reconnec |
Definition at line 1306 of file fs_search.c.
References do_reconnect(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::reconnect_backoff, sc, and GNUNET_FS_SearchContext::task.
Referenced by do_reconnect(), and search_mq_error_handler().
|
static |
We check a result message from the service.
cls | closure |
cm | result message received |
Definition at line 934 of file fs_search.c.
References GNUNET_OK.
|
static |
We process a search result from the service.
cls | closure |
cm | result message received |
Definition at line 949 of file fs_search.c.
References _, ClientPutMessage::expiration, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_BLOCK_TYPE_FS_IBLOCK, GNUNET_BLOCK_TYPE_FS_ONDEMAND, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_FS_URI_SKS, GNUNET_log, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_ntoh(), ClientPutMessage::header, process_kblock(), process_sblock(), GNUNET_TIME_Relative::rel_value_us, sc, GNUNET_MessageHeader::size, type, ClientPutMessage::type, GNUNET_FS_Uri::type, and GNUNET_FS_SearchContext::uri.
|
static |
Schedule the transmission of the (next) search request to the service.
sc | context for the search |
Definition at line 1114 of file fs_search.c.
References GNUNET_FS_SearchContext::anonymity, SearchMessage::anonymity_level, build_result_set(), GNUNET_FS_Uri::data, env, find_result_set(), GNUNET_assert, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY, GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_sks(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_MESSAGE_TYPE_FS_START_SEARCH, GNUNET_MIN, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_YES, GNUNET_FS_Uri::identifier, MessageBuilderContext::keyword_offset, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, GNUNET_FS_Uri::ns, options, SearchMessage::options, GNUNET_FS_SearchContext::options, MessageBuilderContext::put_cnt, SearchMessage::query, GNUNET_FS_SearchContext::requests, sc, MessageBuilderContext::sc, SEARCH_MESSAGE_OPTION_CONTINUED, SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY, SEARCH_MESSAGE_OPTION_NONE, MessageBuilderContext::skip_cnt, GNUNET_FS_Uri::sks, SearchMessage::target, SearchMessage::type, SearchRequestEntry::uquery, GNUNET_FS_SearchContext::uri, and MessageBuilderContext::xoff.
Referenced by do_reconnect().
|
static |
Iterating over the known results, pick those matching the given result range and store their keys at 'xoff'.
cls | the struct MessageBuilderContext |
key | key for a result |
value | the search result |
Definition at line 1053 of file fs_search.c.
References GNUNET_OK, GNUNET_SYSERR, key, GNUNET_FS_SearchResult::keyword_bitmap, MessageBuilderContext::keyword_offset, MessageBuilderContext::put_cnt, MessageBuilderContext::skip_cnt, value, and MessageBuilderContext::xoff.
Referenced by schedule_transmit_search_request().
|
static |
Iterating over the known results, count those matching the given result range and increment put count for each.
cls | the struct MessageBuilderContext |
key | key for a result |
value | the search result |
Definition at line 1089 of file fs_search.c.
References GNUNET_OK, GNUNET_FS_SearchResult::keyword_bitmap, MessageBuilderContext::keyword_offset, MessageBuilderContext::put_cnt, and value.
Referenced by schedule_transmit_search_request().
|
static |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.
Not every message queue implementation supports an error handler.
cls | closure with the struct GNUNET_FS_SearchContext * |
error | error code |
Definition at line 1251 of file fs_search.c.
References GNUNET_MQ_destroy(), GNUNET_FS_SearchContext::mq, sc, and try_reconnect().
Referenced by do_reconnect().
|
static |
Reconnect to the FS service and transmit our queries NOW.
cls | our search context |
Definition at line 1272 of file fs_search.c.
References GNUNET_FS_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_FS_PUT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_FS_SearchContext::h, handlers, GNUNET_FS_SearchContext::mq, result, sc, schedule_transmit_search_request(), search_mq_error_handler(), GNUNET_FS_SearchContext::task, and try_reconnect().
Referenced by GNUNET_FS_search_continue(), GNUNET_FS_search_start_searching_(), and try_reconnect().
|
static |
Update the 'results' map for the individual keywords with the results from the 'global' result set.
cls | closure, the struct GNUNET_FS_SearchContext * |
key | current key code |
value | value in the hash map, the struct GNUNET_FS_SearchResult * |
Definition at line 1381 of file fs_search.c.
References GNUNET_FS_Uri::data, GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_OK, GNUNET_YES, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, GNUNET_FS_SearchContext::uri, and value.
Referenced by GNUNET_FS_search_start_searching_().
int GNUNET_FS_search_start_searching_ | ( | struct GNUNET_FS_SearchContext * | sc | ) |
Build the request and actually initiate the search using the GNUnet FS service.
sc | search context |
Definition at line 1402 of file fs_search.c.
References GNUNET_FS_Uri::data, do_reconnect(), SearchRequestEntry::dpub, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_FS_uri_test_ksk(), GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_strdup, GNUNET_SYSERR, SearchRequestEntry::keyword, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, SearchRequestEntry::mandatory, GNUNET_FS_SearchContext::mandatory_count, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, GNUNET_FS_SearchContext::task, update_sre_result_maps(), SearchRequestEntry::uquery, and GNUNET_FS_SearchContext::uri.
Referenced by deserialize_search(), and search_start().
|
static |
Freeze probes for the given search result.
cls | the global FS handle |
key | the key for the search result (unused) |
value | the search result to free |
Definition at line 1462 of file fs_search.c.
References GNUNET_FS_download_stop(), GNUNET_FS_search_pause(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_SearchResult::update_search, and value.
Referenced by GNUNET_FS_search_pause().
|
static |
Resume probes for the given search result.
cls | the global FS handle |
key | the key for the search result (unused) |
value | the search result to free |
Definition at line 1494 of file fs_search.c.
References GNUNET_FS_search_continue(), GNUNET_FS_search_start_probe_(), GNUNET_OK, GNUNET_FS_SearchResult::update_search, and value.
Referenced by GNUNET_FS_search_continue().
|
static |
Signal suspend and free the given search result.
cls | the global FS handle |
key | the key for the search result (unused) |
value | the search result to free |
Definition at line 1516 of file fs_search.c.
References GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchResult::download, GNUNET_break, GNUNET_free, GNUNET_FS_download_signal_suspend_(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop_probe_(), GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND, GNUNET_FS_uri_destroy(), GNUNET_OK, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchResult::meta, sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_SearchResult::serialization, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::update_search, GNUNET_FS_SearchResult::uri, value, and GNUNET_FS_ProgressInfo::value.
Referenced by GNUNET_FS_search_signal_suspend_().
void GNUNET_FS_search_signal_suspend_ | ( | void * | cls | ) |
Create SUSPEND event for the given search operation and then clean up our state (without stop signal).
cls | the 'struct GNUNET_FS_SearchContext' to signal for |
Definition at line 1555 of file fs_search.c.
References GNUNET_FS_SearchContext::client_info, GNUNET_FS_Uri::data, GNUNET_FS_SearchContext::emsg, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_FS_end_top(), GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_SUSPEND, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_test_ksk(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_FS_SearchContext::h, SearchRequestEntry::keyword, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, search_result_suspend(), GNUNET_FS_SearchContext::serialization, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchContext::task, GNUNET_FS_SearchContext::top, and GNUNET_FS_SearchContext::uri.
Referenced by deserialize_search_file(), GNUNET_FS_search_start(), and search_result_suspend().
|
static |
Signal stop for the given search result.
cls | the global FS handle |
key | the key for the search result (unused) |
value | the search result to free |
Definition at line 1682 of file fs_search.c.
References GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchResult::download, GNUNET_break, GNUNET_free, GNUNET_FS_download_make_status_(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_sync_(), GNUNET_FS_make_top(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_stop_probe_(), GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT, GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, GNUNET_OK, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchContext::h, GNUNET_FS_DownloadContext::h, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchResult::meta, sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::serialization, GNUNET_FS_ProgressInfo::status, GNUNET_FS_DownloadContext::top, GNUNET_FS_SearchResult::uri, value, and GNUNET_FS_ProgressInfo::value.
Referenced by GNUNET_FS_search_stop().
|
static |
Free the given search result.
cls | the global FS handle |
key | the key for the search result (unused) |
value | the search result to free |
Definition at line 1737 of file fs_search.c.
References GNUNET_FS_SearchResult::client_info, GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_search_stop(), GNUNET_FS_uri_destroy(), GNUNET_OK, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_SearchResult::serialization, GNUNET_FS_SearchResult::update_search, GNUNET_FS_SearchResult::uri, and value.
Referenced by GNUNET_FS_search_stop().