API to handle pending requests. More...
#include "gnunet-service-fs.h"
Go to the source code of this file.
Data Structures | |
struct | GSF_PendingRequestData |
Public data (in the sense of not encapsulated within 'gnunet-service-fs_pr', not in the sense of network-wide known) associated with each pending request. More... | |
Typedefs | |
typedef void(* | GSF_PendingRequestReplyHandler) (void *cls, enum GNUNET_BLOCK_ReplyEvaluationResult eval, struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, struct GNUNET_TIME_Absolute expiration, struct GNUNET_TIME_Absolute last_transmission, enum GNUNET_BLOCK_Type type, const void *data, size_t data_len) |
Handle a reply to a pending request. More... | |
typedef int(* | GSF_PendingRequestIterator) (void *cls, const struct GNUNET_HashCode *key, struct GSF_PendingRequest *pr) |
Signature of function called on each request. More... | |
typedef void(* | GSF_LocalLookupContinuation) (void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_ReplyEvaluationResult result) |
Function to be called after we're done processing replies from the local lookup. More... | |
Enumerations | |
enum | GSF_PendingRequestOptions { GSF_PRO_DEFAULTS = 0 , GSF_PRO_LOCAL_ONLY = 1 , GSF_PRO_FORWARD_ONLY = 2 , GSF_PRO_REQUEST_NEVER_EXPIRES = 4 , GSF_PRO_BLOOMFILTER_FULL_REFRESH = 8 , GSF_PRO_PRIORITY_UNLIMITED = 16 , GSF_PRO_LOCAL_REQUEST } |
Options for pending requests (bits to be ORed). More... | |
Functions | |
struct GSF_PendingRequest * | GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const struct GNUNET_PeerIdentity *target, const char *bf_data, size_t bf_size, uint32_t anonymity_level, uint32_t priority, int32_t ttl, GNUNET_PEER_Id sender_pid, GNUNET_PEER_Id origin_pid, const struct GNUNET_HashCode *replies_seen, unsigned int replies_seen_count, GSF_PendingRequestReplyHandler rh, void *rh_cls) |
Create a new pending request. More... | |
void | GSF_pending_request_update_ (struct GSF_PendingRequest *pr, const struct GNUNET_HashCode *replies_seen, unsigned int replies_seen_count) |
Update a given pending request with additional replies that have been seen. More... | |
struct GSF_PendingRequestData * | GSF_pending_request_get_data_ (struct GSF_PendingRequest *pr) |
Obtain the public data associated with a pending request. More... | |
int | GSF_pending_request_test_active_ (struct GSF_PendingRequest *pr) |
Check if the given request is still active. More... | |
int | GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra, struct GSF_PendingRequest *prb) |
Test if two pending requests are compatible (would generate the same query modulo filters and should thus be processed jointly). More... | |
struct GNUNET_MQ_Envelope * | GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr) |
Generate the message corresponding to the given pending request for transmission to other peers. More... | |
void | GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup) |
Explicitly cancel a pending request. More... | |
void | GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, void *cls) |
Iterate over all pending requests. More... | |
void | handle_p2p_put (void *cls, const struct PutMessage *put) |
Handle P2P "CONTENT" message. More... | |
void | GSF_dht_lookup_ (struct GSF_PendingRequest *pr) |
Consider looking up the data in the DHT (anonymity-level permitting). More... | |
void | GSF_cadet_lookup_ (struct GSF_PendingRequest *pr) |
Consider downloading via cadet (if possible) More... | |
void | GSF_local_lookup_ (struct GSF_PendingRequest *pr, GSF_LocalLookupContinuation cont, void *cont_cls) |
Look up the request in the local datastore. More... | |
int | GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, const struct GNUNET_PeerIdentity *target) |
Is the given target a legitimate peer for forwarding the given request? More... | |
void | GSF_pending_request_init_ (void) |
Setup the subsystem. More... | |
void | GSF_pending_request_done_ (void) |
Shutdown the subsystem. More... | |
API to handle pending requests.
Definition in file gnunet-service-fs_pr.h.
typedef void(* GSF_PendingRequestReplyHandler) (void *cls, enum GNUNET_BLOCK_ReplyEvaluationResult eval, struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, struct GNUNET_TIME_Absolute expiration, struct GNUNET_TIME_Absolute last_transmission, enum GNUNET_BLOCK_Type type, const void *data, size_t data_len) |
Handle a reply to a pending request.
Also called if a request expires (then with data == NULL). The handler may be called many times (depending on the request type), but will not be called during or after a call to GSF_pending_request_cancel and will also not be called anymore after a call signalling expiration.
cls | user-specified closure |
eval | evaluation of the result |
pr | handle to the original pending request |
reply_anonymity_level | anonymity level for the reply, UINT32_MAX for "unknown" |
expiration | when does data expire? |
last_transmission | the last time we've tried to get this block (FOREVER if unknown) |
type | type of the block |
data | response data, NULL on request expiration |
data_len | number of bytes in data |
Definition at line 186 of file gnunet-service-fs_pr.h.
typedef int(* GSF_PendingRequestIterator) (void *cls, const struct GNUNET_HashCode *key, struct GSF_PendingRequest *pr) |
Signature of function called on each request.
(Note: 'subtype' of GNUNET_CONTAINER_HashMapIterator).
cls | closure |
key | query for the request |
pr | handle to the pending request |
Definition at line 318 of file gnunet-service-fs_pr.h.
typedef void(* GSF_LocalLookupContinuation) (void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_ReplyEvaluationResult result) |
Function to be called after we're done processing replies from the local lookup.
cls | closure |
pr | the pending request we were processing |
result | final datastore lookup result |
Definition at line 375 of file gnunet-service-fs_pr.h.
Options for pending requests (bits to be ORed).
Enumerator | |
---|---|
GSF_PRO_DEFAULTS | No special options (P2P-default). |
GSF_PRO_LOCAL_ONLY | Request must only be processed locally. |
GSF_PRO_FORWARD_ONLY | Request must only be forwarded (no routing) |
GSF_PRO_REQUEST_NEVER_EXPIRES | Request persists indefinitely (no expiration). |
GSF_PRO_BLOOMFILTER_FULL_REFRESH | Request is allowed to refresh bloomfilter and change mingle value. |
GSF_PRO_PRIORITY_UNLIMITED | Request priority is allowed to be exceeded. |
GSF_PRO_LOCAL_REQUEST | Option mask for typical local requests. |
Definition at line 35 of file gnunet-service-fs_pr.h.
struct GSF_PendingRequest * GSF_pending_request_create_ | ( | enum GSF_PendingRequestOptions | options, |
enum GNUNET_BLOCK_Type | type, | ||
const struct GNUNET_HashCode * | query, | ||
const struct GNUNET_PeerIdentity * | target, | ||
const char * | bf_data, | ||
size_t | bf_size, | ||
uint32_t | anonymity_level, | ||
uint32_t | priority, | ||
int32_t | ttl, | ||
GNUNET_PEER_Id | sender_pid, | ||
GNUNET_PEER_Id | origin_pid, | ||
const struct GNUNET_HashCode * | replies_seen, | ||
unsigned int | replies_seen_count, | ||
GSF_PendingRequestReplyHandler | rh, | ||
void * | rh_cls | ||
) |
Create a new pending request.
options | request options |
type | type of the block that is being requested |
query | key for the lookup |
target | preferred target for the request, NULL for none |
bf_data | raw data for bloom filter for known replies, can be NULL |
bf_size | number of bytes in bf_data |
anonymity_level | desired anonymity level |
priority | maximum outgoing cumulative request priority to use |
ttl | current time-to-live for the request |
sender_pid | peer ID to use for the sender when forwarding, 0 for none; reference counter is taken over by this function |
origin_pid | peer ID of origin of query (do not loop back) |
replies_seen | hash codes of known local replies |
replies_seen_count | size of the 'replies_seen' array |
rh | handle to call when we get a reply |
rh_cls | closure for rh |
Definition at line 278 of file gnunet-service-fs_pr.c.
References GNUNET_TIME_Absolute::abs_value_us, anonymity_level, GSF_PendingRequestData::anonymity_level, GSF_PendingRequest::bg, gettext_noop, GNUNET_assert, GNUNET_BLOCK_group_create(), GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_peek(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_new_array, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_subtract(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, GSF_block_ctx, GSF_pending_request_cancel_(), GSF_PRO_BLOOMFILTER_FULL_REFRESH, GSF_PRO_FORWARD_ONLY, GSF_PRO_REQUEST_NEVER_EXPIRES, GSF_stats, GSF_PendingRequest::hnode, max_pending_requests, options, GSF_PendingRequestData::options, GSF_PendingRequest::origin_pid, GSF_PendingRequestData::original_priority, pr_map, GSF_PendingRequestData::priority, GSF_PendingRequest::public_data, GSF_PendingRequestData::query, refresh_bloomfilter(), GSF_PendingRequest::replies_seen, GSF_PendingRequest::replies_seen_count, GSF_PendingRequest::replies_seen_size, requests_by_expiration_heap, GSF_PendingRequest::rh, GSF_PendingRequest::rh_cls, GSF_PendingRequest::sender_pid, GSF_PendingRequestData::start_time, GSF_PendingRequestData::target, ttl, GSF_PendingRequestData::ttl, type, and GSF_PendingRequestData::type.
Referenced by handle_client_start_search(), and handle_p2p_get().
void GSF_pending_request_update_ | ( | struct GSF_PendingRequest * | pr, |
const struct GNUNET_HashCode * | replies_seen, | ||
unsigned int | replies_seen_count | ||
) |
Update a given pending request with additional replies that have been seen.
pr | request to update |
replies_seen | hash codes of replies that we've seen |
replies_seen_count | size of the replies_seen array |
Definition at line 439 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::bg, GSF_PendingRequest::gh, GNUNET_array_grow, GNUNET_BLOCK_group_set_seen(), GNUNET_break, GNUNET_DHT_get_filter_known_results(), GNUNET_memcpy, GNUNET_OK, GSF_PRO_BLOOMFILTER_FULL_REFRESH, GSF_PendingRequestData::options, GSF_PendingRequest::public_data, refresh_bloomfilter(), GSF_PendingRequest::replies_seen, GSF_PendingRequest::replies_seen_count, GSF_PendingRequest::replies_seen_size, and GSF_PendingRequestData::type.
Referenced by handle_client_start_search(), and process_reply().
struct GSF_PendingRequestData * GSF_pending_request_get_data_ | ( | struct GSF_PendingRequest * | pr | ) |
Obtain the public data associated with a pending request.
pr | pending request |
Definition at line 410 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::public_data.
Referenced by client_response_handler(), free_pending_request(), get_latest(), get_rp_key(), GSF_plan_add_(), GSF_plan_notify_peer_disconnect_(), GSF_plan_notify_request_done_(), handle_client_start_search(), handle_p2p_get(), handle_p2p_reply(), merge_pr(), peer_request_destroy(), plan(), start_p2p_processing(), and test_exist_cb().
int GSF_pending_request_test_active_ | ( | struct GSF_PendingRequest * | pr | ) |
Check if the given request is still active.
pr | pending request |
Definition at line 1840 of file gnunet-service-fs_pr.c.
References GNUNET_NO, GNUNET_YES, and GSF_PendingRequest::rh.
Referenced by consider_peer_for_forwarding(), get_latest(), GSF_consider_forwarding(), GSF_plan_add_(), and merge_pr().
int GSF_pending_request_is_compatible_ | ( | struct GSF_PendingRequest * | pra, |
struct GSF_PendingRequest * | prb | ||
) |
Test if two pending requests are compatible (would generate the same query modulo filters and should thus be processed jointly).
pra | a pending request |
prb | another pending request |
Definition at line 426 of file gnunet-service-fs_pr.c.
References GNUNET_NO, GNUNET_OK, GSF_PendingRequest::public_data, GSF_PendingRequestData::query, and GSF_PendingRequestData::type.
Referenced by merge_pr().
struct GNUNET_MQ_Envelope * GSF_pending_request_get_message_ | ( | struct GSF_PendingRequest * | pr | ) |
Generate the message corresponding to the given pending request for transmission to other peers.
pr | request to generate the message for |
Definition at line 489 of file gnunet-service-fs_pr.c.
References GNUNET_TIME_Absolute::abs_value_us, GSF_PendingRequest::bg, env, GET_MESSAGE_BIT_RETURN_TO, GET_MESSAGE_BIT_TRANSMIT_TO, GNUNET_BLOCK_group_serialize(), GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_GET, GNUNET_MQ_msg_extra, GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_TIME_absolute_get(), GNUNET_YES, GSF_PRO_FORWARD_ONLY, GetMessage::hash_bitmap, GSF_PendingRequestData::num_transmissions, GSF_PendingRequestData::options, GetMessage::priority, GSF_PendingRequestData::priority, GSF_PendingRequest::public_data, GetMessage::query, GSF_PendingRequestData::query, GetMessage::reserved, GSF_PendingRequestData::respect_offered, GSF_PendingRequest::sender_pid, GSF_PendingRequestData::target, ttl, GetMessage::ttl, GSF_PendingRequestData::ttl, GetMessage::type, and GSF_PendingRequestData::type.
Referenced by schedule_peer_transmission().
void GSF_pending_request_cancel_ | ( | struct GSF_PendingRequest * | pr, |
int | full_cleanup | ||
) |
Explicitly cancel a pending request.
pr | request to cancel |
full_cleanup | fully purge the request |
Definition at line 641 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::cadet_request, GSF_PendingRequest::cadet_retry_count, CADET_RETRY_MAX, clean_request(), GSF_PendingRequest::gh, GNUNET_assert, GNUNET_DATASTORE_cancel(), GNUNET_DHT_get_stop(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GSF_cadet_query_cancel(), GSF_plan_notify_request_done_(), GSF_PendingRequest::llc_cont, GSF_PendingRequest::llc_cont_cls, GSF_PendingRequest::local_result, pr_map, GSF_PendingRequest::public_data, GSF_PendingRequest::qe, GSF_PendingRequestData::query, GSF_PendingRequest::rh, and GSF_PendingRequest::warn_task.
Referenced by cancel_pending_request(), client_request_destroy(), GSF_pending_request_create_(), and test_exist_cb().
void GSF_iterate_pending_requests_ | ( | GSF_PendingRequestIterator | it, |
void * | cls | ||
) |
Iterate over all pending requests.
it | function to call for each request |
cls | closure for it |
Definition at line 690 of file gnunet-service-fs_pr.c.
References GNUNET_CONTAINER_multihashmap_iterate(), and pr_map.
Referenced by GSF_peer_connect_handler().
void handle_p2p_put | ( | void * | cls, |
const struct PutMessage * | put | ||
) |
Handle P2P "CONTENT" message.
Checks that the message is well-formed and then checks if there are any pending requests for this content and possibly passes it on (to local clients or other peers). Does NOT perform migration (content caching at this peer).
cls | the other peer involved (sender) |
put | the actual message |
Checks that the message is well-formed and then checks if there are any pending requests for this content and possibly passes it on (to local clients or other peers). Does NOT perform migration (content caching at this peer).
cls | the other peer involved |
put | the actual message |
Definition at line 1698 of file gnunet-service-fs_pr.c.
References active_to_migration, ProcessReplyClosure::anonymity_level, CONTENT_BANDWIDTH_VALUE, ProcessReplyClosure::data, datastore_put_load, expiration, PutMessage::expiration, ProcessReplyClosure::expiration, gettext_noop, GNUNET_assert, GNUNET_BLOCK_check_block(), GNUNET_BLOCK_get_key(), GNUNET_break_op, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_DATASTORE_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_LOAD_get_load(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_min(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_TIME_UNIT_YEARS, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, GSF_block_ctx, GSF_block_peer_migration_(), GSF_connected_peer_change_preference_(), GSF_cover_content_count, GSF_dsh, GSF_get_peer_performance_data_(), GSF_stats, PutMessage::header, MAX_DATASTORE_QUEUE, PutMigrationContext::origin, pid, pr_map, ProcessReplyClosure::priority, process_reply(), put_migration_continuation(), ProcessReplyClosure::request_found, PutMigrationContext::requested, GSF_PeerPerformanceData::respect, ProcessReplyClosure::sender, GNUNET_MessageHeader::size, ProcessReplyClosure::size, PutMigrationContext::start, test_put_load_too_high(), type, PutMessage::type, and ProcessReplyClosure::type.
void GSF_dht_lookup_ | ( | struct GSF_PendingRequest * | pr | ) |
Consider looking up the data in the DHT (anonymity-level permitting).
pr | the pending request to process |
Definition at line 1128 of file gnunet-service-fs_pr.c.
References GSF_PendingRequestData::anonymity_level, DHT_GET_REPLICATION, GSF_PendingRequest::gh, GNUNET_ALIGN, GNUNET_assert, GNUNET_DHT_get_filter_known_results(), GNUNET_DHT_get_start(), GNUNET_DHT_get_stop(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_memcpy, GNUNET_PEER_resolve(), GSF_dht, GSF_PRO_FORWARD_ONLY, handle_dht_reply(), GSF_PendingRequestData::options, GSF_PendingRequest::public_data, GSF_PendingRequestData::query, GSF_PendingRequest::replies_seen, GSF_PendingRequest::replies_seen_count, GSF_PendingRequest::sender_pid, and GSF_PendingRequestData::type.
Referenced by process_reply(), and start_p2p_processing().
void GSF_cadet_lookup_ | ( | struct GSF_PendingRequest * | pr | ) |
Consider downloading via cadet (if possible)
pr | the pending request to process |
Definition at line 1252 of file gnunet-service-fs_pr.c.
References GSF_PendingRequestData::anonymity_level, cadet_reply_proc(), GSF_PendingRequest::cadet_request, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GSF_cadet_query(), GSF_PendingRequest::public_data, GSF_PendingRequestData::query, GSF_PendingRequestData::target, and GSF_PendingRequestData::type.
Referenced by start_p2p_processing().
void GSF_local_lookup_ | ( | struct GSF_PendingRequest * | pr, |
GSF_LocalLookupContinuation | cont, | ||
void * | cont_cls | ||
) |
Look up the request in the local datastore.
pr | the pending request to process |
cont | function to call at the end |
cont_cls | closure for cont |
Definition at line 1669 of file gnunet-service-fs_pr.c.
References GSF_PendingRequest::cadet_request, gettext_noop, GSF_PendingRequest::gh, GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), GSF_stats, GSF_PendingRequest::llc_cont, GSF_PendingRequest::llc_cont_cls, and start_local_query().
Referenced by handle_client_start_search(), and handle_p2p_get().
int GSF_pending_request_test_target_ | ( | struct GSF_PendingRequest * | pr, |
const struct GNUNET_PeerIdentity * | target | ||
) |
Is the given target a legitimate peer for forwarding the given request?
pr | request |
target |
Definition at line 1647 of file gnunet-service-fs_pr.c.
References GNUNET_NO, GNUNET_PEER_resolve(), GNUNET_YES, and GSF_PendingRequest::origin_pid.
Referenced by consider_peer_for_forwarding(), and consider_request_for_forwarding().
void GSF_pending_request_init_ | ( | void | ) |
Setup the subsystem.
Definition at line 1850 of file gnunet-service-fs_pr.c.
References active_to_migration, DATASTORE_LOAD_AUTODECLINE, datastore_put_load, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_INFO, GNUNET_LOAD_value_init(), GNUNET_log_config_missing(), GNUNET_OK, GNUNET_YES, GSF_cfg, max_pending_requests, pr_map, and requests_by_expiration_heap.
Referenced by run().
void GSF_pending_request_done_ | ( | void | ) |
Shutdown the subsystem.
Definition at line 1875 of file gnunet-service-fs_pr.c.
References clean_request(), datastore_put_load, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_LOAD_value_free, pr_map, and requests_by_expiration_heap.
Referenced by shutdown_task().