GNUnet DHT service's client management code. More...
#include "gnunet-service-dht_clients.h"Go to the source code of this file.
Data Structures | |
| struct | ClientQueryRecord |
| Entry in the local forwarding map for a client's GET request. More... | |
| struct | ClientMonitorRecord |
| Struct containing parameters of monitoring requests. More... | |
| struct | ClientHandle |
| Struct containing information about a client, handle to connect to it, and any pending messages that need to be sent to it. More... | |
| struct | FindByUniqueIdContext |
| Closure for find_by_unique_id(). More... | |
| struct | RemoveByUniqueIdContext |
| Closure for remove_by_unique_id(). More... | |
| struct | ForwardReplyContext |
| Closure for forward_reply() More... | |
| struct | GetActionContext |
| Closure for get_action();. More... | |
| struct | ResponseActionContext |
| Closure for response_action(). More... | |
| struct | PutActionContext |
| Closure for put_action(). More... | |
Macros | |
| #define | SANITY_CHECKS 0 |
| Enable slow sanity checks to debug issues. | |
| #define | LOG_TRAFFIC(kind, ...) |
| Should routing details be logged to stderr (for debugging)? | |
| #define | LOG(kind, ...) GNUNET_log_from (kind, "dht-clients", __VA_ARGS__) |
| #define | GDS_DHT_SERVICE_INIT(name, run) |
| Define "main" method using service macro. | |
Typedefs | |
| typedef void(* | MonitorAction) (void *cls, struct ClientMonitorRecord *m) |
| Function to call by for_matching_monitors(). | |
Functions | |
| static void | remove_client_query_record (struct ClientQueryRecord *record) |
| Free data structures associated with the given query. | |
| static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) |
| Functions with this signature are called whenever a local client is connects to us. | |
| static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx) |
| Functions with this signature are called whenever a client is disconnected on the network level. | |
| static void | transmit_request (struct ClientQueryRecord *cqr) |
| Route the given request via the DHT. | |
| static void | transmit_next_request_task (void *cls) |
| Task that looks at the retry_heap and transmits all of the requests on the heap that are ready for transmission. | |
| static enum GNUNET_GenericReturnValue | check_dht_local_put (void *cls, const struct GNUNET_DHT_ClientPutMessage *dht_msg) |
| Check DHT PUT messages from the client. | |
| static void | handle_dht_local_put (void *cls, const struct GNUNET_DHT_ClientPutMessage *dht_msg) |
| Handler for PUT messages. | |
| static void | handle_local_result (void *cls, const struct GNUNET_DATACACHE_Block *bd) |
| Handle a result from local datacache for a GET operation. | |
| static enum GNUNET_GenericReturnValue | check_dht_local_get (void *cls, const struct GNUNET_DHT_ClientGetMessage *get) |
| Check DHT GET messages from the client. | |
| static void | handle_dht_local_get (void *cls, const struct GNUNET_DHT_ClientGetMessage *get) |
| Handler for DHT GET messages from the client. | |
| static enum GNUNET_GenericReturnValue | find_by_unique_id (void *cls, const struct GNUNET_HashCode *key, void *value) |
| Function called for each existing DHT record for the given query. | |
| static enum GNUNET_GenericReturnValue | check_dht_local_get_result_seen (void *cls, const struct GNUNET_DHT_ClientGetResultSeenMessage *seen) |
| Check "GET result seen" messages from the client. | |
| static void | handle_dht_local_get_result_seen (void *cls, const struct GNUNET_DHT_ClientGetResultSeenMessage *seen) |
| Handler for "GET result seen" messages from the client. | |
| static enum GNUNET_GenericReturnValue | remove_by_unique_id (void *cls, const struct GNUNET_HashCode *key, void *value) |
| Iterator over hash map entries that frees all entries that match the given client and unique ID. | |
| static void | handle_dht_local_get_stop (void *cls, const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg) |
| Handler for any generic DHT stop messages, calls the appropriate handler depending on message type (if processed locally) | |
| static enum GNUNET_GenericReturnValue | forward_reply (void *cls, const struct GNUNET_HashCode *query_hash, void *value) |
| Iterator over hash map entries that send a given reply to each of the matching clients. | |
| bool | GDS_CLIENTS_handle_reply (const struct GNUNET_DATACACHE_Block *bd, const struct GNUNET_HashCode *query_hash, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *get_path) |
| Handle a reply we've received from another peer. | |
| static void | handle_dht_local_hello_get (void *cls, const struct GNUNET_MessageHeader *msg) |
| Handler for HELLO GET message. | |
| static enum GNUNET_GenericReturnValue | check_dht_local_hello_offer (void *cls, const struct GNUNET_MessageHeader *hdr) |
| Process a client HELLO message received from the service. | |
| static void | handle_dht_local_hello_offer (void *cls, const struct GNUNET_MessageHeader *msg) |
| Handler for HELLO OFFER message. | |
| static void | handle_dht_local_monitor (void *cls, const struct GNUNET_DHT_MonitorStartStopMessage *msg) |
| Handler for monitor start messages. | |
| static void | handle_dht_local_monitor_stop (void *cls, const struct GNUNET_DHT_MonitorStartStopMessage *msg) |
| Handler for monitor stop messages. | |
| static void | for_matching_monitors (enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, MonitorAction cb, void *cb_cls) |
| Call cb on all monitors that watch for blocks of type and key key. | |
| static void | get_action (void *cls, struct ClientMonitorRecord *m) |
| Function called on monitors that match a GET. | |
| void | GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, const struct GNUNET_HashCode *key) |
| Check if some client is monitoring GET messages and notify them in that case. | |
| static void | response_action (void *cls, struct ClientMonitorRecord *m) |
| Function called on monitors that match a response. | |
| void | GDS_CLIENTS_process_get_resp (const struct GNUNET_DATACACHE_Block *bd, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length) |
| Check if some client is monitoring GET RESP messages and notify them in that case. | |
| static void | put_action (void *cls, struct ClientMonitorRecord *m) |
| Function called on monitors that match a PUT. | |
| void | GDS_CLIENTS_process_put (const struct GNUNET_DATACACHE_Block *bd, uint32_t hop_count, uint32_t desired_replication_level) |
| Check if some client is monitoring PUT messages and notify them in that case. | |
| void | GDS_CLIENTS_init (void) |
| Initialize client subsystem. | |
| void | GDS_CLIENTS_stop (void) |
| Shutdown client subsystem. | |
| void | GDS_CLIENTS_done (void) |
| void | __attribute__ ((destructor)) |
| MINIMIZE heap size (way below 128k) since this process doesn't need much. | |
Variables | |
| struct GNUNET_BLOCK_Context * | GDS_block_context |
| Our handle to the BLOCK library. | |
| struct GNUNET_STATISTICS_Handle * | GDS_stats |
| Handle for the statistics service. | |
| struct GNUNET_PILS_Handle * | GDS_pils |
| Handle for the pils service. | |
| struct GNUNET_SERVICE_Handle * | GDS_service |
| Handle for the service. | |
| const struct GNUNET_CONFIGURATION_Handle * | GDS_cfg |
| The configuration the DHT service is running with. | |
| static struct ClientMonitorRecord * | monitor_head |
| List of active monitoring requests. | |
| static struct ClientMonitorRecord * | monitor_tail |
| List of active monitoring requests. | |
| static struct GNUNET_CONTAINER_MultiHashMap * | forward_map |
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries. | |
| static struct GNUNET_CONTAINER_Heap * | retry_heap |
| Heap with all of our client's request, sorted by retry time (earliest on top). | |
| static struct GNUNET_SCHEDULER_Task * | retry_task |
| Task that re-transmits requests (using retry_heap). | |
GNUnet DHT service's client management code.
Definition in file gnunet-service-dht_clients.c.
| #define SANITY_CHECKS 0 |
Enable slow sanity checks to debug issues.
0: do not check 1: check all external inputs 2: check internal computations as well
Definition at line 35 of file gnunet-service-dht_clients.c.
| #define LOG_TRAFFIC | ( | kind, | |
| ... | |||
| ) |
Should routing details be logged to stderr (for debugging)?
Definition at line 40 of file gnunet-service-dht_clients.c.
| #define LOG | ( | kind, | |
| ... | |||
| ) | GNUNET_log_from (kind, "dht-clients", __VA_ARGS__) |
Definition at line 43 of file gnunet-service-dht_clients.c.
Define "main" method using service macro.
| name | name of the service, like "dht" or "xdht" |
| run | name of the initialization method for the service |
Definition at line 1643 of file gnunet-service-dht_clients.c.
| typedef void(* MonitorAction) (void *cls, struct ClientMonitorRecord *m) |
Function to call by for_matching_monitors().
| cls | closure |
| m | a matching monitor |
Definition at line 1309 of file gnunet-service-dht_clients.c.
|
static |
Free data structures associated with the given query.
| record | record to remove |
Definition at line 271 of file gnunet-service-dht_clients.c.
References ch, forward_map, GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, and record().
Referenced by client_disconnect_cb(), forward_reply(), and remove_by_unique_id().
|
static |
Functions with this signature are called whenever a local client is connects to us.
| cls | closure (NULL for dht) |
| client | identification of the client |
| mq | message queue for talking to client |
struct ClientHandle for client Definition at line 301 of file gnunet-service-dht_clients.c.
References ch, ClientHandle::client, GNUNET_new, mq, and GNUNET_CADET_Channel::mq.
|
static |
Functions with this signature are called whenever a client is disconnected on the network level.
| cls | closure (NULL for dht) |
| client | identification of the client |
| app_ctx | our struct ClientHandle for client |
Definition at line 324 of file gnunet-service-dht_clients.c.
References ch, ClientHandle::client, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, monitor, monitor_head, monitor_tail, ClientMonitorRecord::next, and remove_client_query_record().
|
static |
Route the given request via the DHT.
This includes updating the bloom filter and retransmission times, building the P2P message and initiating the routing operation.
| cqr | request to transmit |
Definition at line 370 of file gnunet-service-dht_clients.c.
References DHT_BLOOM_SIZE, GDS_block_context, GDS_NEIGHBOURS_handle_get(), GDS_stats, GNUNET_BLOCK_group_create(), GNUNET_BLOCK_group_destroy(), GNUNET_BLOCK_group_set_seen(), GNUNET_CONSTANTS_BLOOMFILTER_K, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, ClientQueryRecord::key, LOG, ClientQueryRecord::msg_options, ClientQueryRecord::replication, ClientQueryRecord::retry_frequency, ClientQueryRecord::retry_time, ClientQueryRecord::seen_replies, ClientQueryRecord::seen_replies_count, ClientQueryRecord::type, ClientQueryRecord::xquery, and ClientQueryRecord::xquery_size.
Referenced by transmit_next_request_task().
|
static |
Task that looks at the retry_heap and transmits all of the requests on the heap that are ready for transmission.
Then re-schedules itself (unless the heap is empty).
| cls | unused |
Definition at line 425 of file gnunet-service-dht_clients.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_SCHEDULER_add_at(), GNUNET_TIME_absolute_is_past(), ClientQueryRecord::hnode, retry_heap, retry_task, ClientQueryRecord::retry_time, transmit_next_request_task(), and transmit_request().
Referenced by handle_dht_local_get(), and transmit_next_request_task().
|
static |
Check DHT PUT messages from the client.
| cls | the client we received this message from |
| dht_msg | the actual message received |
Definition at line 463 of file gnunet-service-dht_clients.c.
References GNUNET_DHT_ClientPutMessage::desired_replication_level, GNUNET_break_op, GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL, GNUNET_OK, GNUNET_SYSERR, and replication_level.
|
static |
Handler for PUT messages.
| cls | the client we received this message from |
| dht_msg | the actual message received |
Definition at line 485 of file gnunet-service-dht_clients.c.
References ch, GNUNET_DATACACHE_Block::data, GNUNET_DATACACHE_Block::data_size, GNUNET_DHT_ClientPutMessage::desired_replication_level, DHT_BLOOM_SIZE, GNUNET_DHT_ClientPutMessage::expiration, GDS_am_closest_peer(), GDS_block_context, GDS_CLIENTS_handle_reply(), GDS_CLIENTS_process_put(), GDS_DATACACHE_handle_put(), GDS_NEIGHBOURS_handle_put(), GDS_stats, GNUNET_BLOCK_check_block(), GNUNET_break, GNUNET_CONSTANTS_BLOOMFILTER_K, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_ntoh(), GNUNET_DHT_ClientPutMessage::header, GNUNET_DATACACHE_Block::key, GNUNET_DHT_ClientPutMessage::key, LOG, LOG_TRAFFIC, GNUNET_DHT_ClientPutMessage::options, replication_level, GNUNET_DATACACHE_Block::ro, GNUNET_MessageHeader::size, size, GNUNET_DATACACHE_Block::type, and GNUNET_DHT_ClientPutMessage::type.
|
static |
Handle a result from local datacache for a GET operation.
| cls | the struct ClientHandle of the client doing the query |
| bd | details about the block that was found |
Definition at line 570 of file gnunet-service-dht_clients.c.
References GDS_CLIENTS_handle_reply(), GNUNET_break, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, and GNUNET_DATACACHE_Block::key.
Referenced by handle_dht_local_get().
|
static |
Check DHT GET messages from the client.
| cls | the client we received this message from |
| get | the actual message received |
Definition at line 590 of file gnunet-service-dht_clients.c.
|
static |
Handler for DHT GET messages from the client.
| cls | the client we received this message from |
| get | the actual message received |
Definition at line 607 of file gnunet-service-dht_clients.c.
References ch, ClientQueryRecord::ch, forward_map, GDS_CLIENTS_process_get(), GDS_DATACACHE_handle_get(), GDS_stats, get, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_SECONDS, handle_local_result(), ClientQueryRecord::hnode, ClientQueryRecord::key, LOG, LOG_TRAFFIC, ClientQueryRecord::msg_options, ClientQueryRecord::replication, ClientQueryRecord::retry_frequency, retry_heap, retry_task, ClientQueryRecord::retry_time, size, transmit_next_request_task(), ClientQueryRecord::type, ClientQueryRecord::unique_id, ClientQueryRecord::xquery, and ClientQueryRecord::xquery_size.
|
static |
Function called for each existing DHT record for the given query.
Checks if it matches the UID given in the closure and if so returns the entry as a result.
| cls | the search context |
| key | query for the lookup (not used) |
| value | the struct ClientQueryRecord |
Definition at line 704 of file gnunet-service-dht_clients.c.
References FindByUniqueIdContext::cqr, GNUNET_NO, GNUNET_YES, ClientQueryRecord::unique_id, FindByUniqueIdContext::unique_id, and value.
Referenced by handle_dht_local_get_result_seen().
|
static |
Check "GET result seen" messages from the client.
| cls | the client we received this message from |
| seen | the actual message received |
Definition at line 726 of file gnunet-service-dht_clients.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_DHT_ClientGetResultSeenMessage::header, GNUNET_MessageHeader::size, and size.
|
static |
Handler for "GET result seen" messages from the client.
| cls | the client we received this message from |
| seen | the actual message received |
Definition at line 751 of file gnunet-service-dht_clients.c.
References ch, FindByUniqueIdContext::cqr, find_by_unique_id(), forward_map, GNUNET_array_grow, GNUNET_break, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_memcpy, GNUNET_SERVICE_client_drop(), GNUNET_DHT_ClientGetResultSeenMessage::header, GNUNET_DHT_ClientGetResultSeenMessage::key, ClientQueryRecord::seen_replies, ClientQueryRecord::seen_replies_count, GNUNET_MessageHeader::size, size, GNUNET_DHT_ClientGetResultSeenMessage::unique_id, and FindByUniqueIdContext::unique_id.
|
static |
Iterator over hash map entries that frees all entries that match the given client and unique ID.
| cls | unique ID and client to search for in source routes |
| key | current key code |
| value | value in the hash map, a ClientQueryRecord |
Definition at line 814 of file gnunet-service-dht_clients.c.
References ctx, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_YES, key, remove_client_query_record(), ClientQueryRecord::unique_id, and value.
Referenced by handle_dht_local_get_stop().
|
static |
Handler for any generic DHT stop messages, calls the appropriate handler depending on message type (if processed locally)
| cls | client we received this message from |
| dht_stop_msg | the actual message received |
Definition at line 841 of file gnunet-service-dht_clients.c.
References ch, ctx, forward_map, GDS_stats, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_DHT_ClientGetStopMessage::key, LOG, remove_by_unique_id(), and GNUNET_DHT_ClientGetStopMessage::unique_id.
|
static |
Iterator over hash map entries that send a given reply to each of the matching clients.
With some tricky recycling of the buffer.
| cls | the struct ForwardReplyContext |
| query_hash | hash of the query for which this may be a reply |
| value | value in the hash map, a ClientQueryRecord |
Definition at line 901 of file gnunet-service-dht_clients.c.
References ForwardReplyContext::bd, ch, GNUNET_DATACACHE_Block::data, GNUNET_DATACACHE_Block::data_size, env, GNUNET_DHT_ClientResultMessage::expiration, GNUNET_DATACACHE_Block::expiration_time, GDS_block_context, GDS_my_identity, GDS_stats, ForwardReplyContext::get_path, GNUNET_DHT_ClientResultMessage::get_path_length, ForwardReplyContext::get_path_length, GNUNET_array_append, GNUNET_BLOCK_check_reply(), GNUNET_BLOCK_REPLY_IRRELEVANT, GNUNET_BLOCK_REPLY_OK_DUPLICATE, GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_REPLY_OK_MORE, GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_CRYPTO_hash(), GNUNET_DHT_RO_FIND_APPROXIMATE, GNUNET_DHT_RO_TRUNCATED, GNUNET_DHT_verify_path(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_memcmp, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_hton(), GNUNET_YES, GNUNET_DATACACHE_Block::key, GNUNET_DHT_ClientResultMessage::key, LOG, LOG_TRAFFIC, GNUNET_DHT_ClientResultMessage::options, GNUNET_DATACACHE_Block::put_path, GNUNET_DATACACHE_Block::put_path_length, GNUNET_DHT_ClientResultMessage::put_path_length, record(), remove_client_query_record(), GNUNET_DATACACHE_Block::ro, GNUNET_DATACACHE_Block::trunc_peer, GNUNET_DATACACHE_Block::type, GNUNET_DHT_ClientResultMessage::type, GNUNET_DHT_ClientResultMessage::unique_id, and value.
Referenced by GDS_CLIENTS_handle_reply().
| bool GDS_CLIENTS_handle_reply | ( | const struct GNUNET_DATACACHE_Block * | bd, |
| const struct GNUNET_HashCode * | query_hash, | ||
| unsigned int | get_path_length, | ||
| const struct GNUNET_DHT_PathElement * | get_path | ||
| ) |
Handle a reply we've received from another peer.
If the reply matches any of our pending queries, forward it to the respective client(s).
| bd | block details |
| query_hash | hash of the original query, might not match key in bd |
| get_path_length | number of entries in get_path |
| get_path | path the reply has taken |
Definition at line 1066 of file gnunet-service-dht_clients.c.
References ForwardReplyContext::bd, GNUNET_DATACACHE_Block::data, data_size, GNUNET_DATACACHE_Block::data_size, GNUNET_DATACACHE_Block::expiration_time, forward_map, forward_reply(), GDS_my_identity, GDS_stats, ForwardReplyContext::get_path, GNUNET_DHT_ClientResultMessage::get_path_length, ForwardReplyContext::get_path_length, GNUNET_break, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_DHT_RO_TRUNCATED, GNUNET_DHT_verify_path(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, GNUNET_DATACACHE_Block::put_path, GNUNET_DATACACHE_Block::put_path_length, GNUNET_DHT_ClientResultMessage::put_path_length, GNUNET_DATACACHE_Block::ro, and GNUNET_DATACACHE_Block::trunc_peer.
Referenced by handle_dht_local_put(), handle_dht_p2p_put(), handle_local_result(), and process_reply_with_path().
|
static |
Handler for HELLO GET message.
Reply to client with a URL of our HELLO.
| cls | the client we received this message from |
| msg | the actual message received |
Definition at line 1141 of file gnunet-service-dht_clients.c.
References ch, env, GDS_my_hello, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_msg(), GNUNET_HELLO_parser_to_url(), GNUNET_log, GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_CADET_Channel::mq, and p.
|
static |
Process a client HELLO message received from the service.
| cls | the client we received this message from |
| hdr | HELLO URL message from the service. |
Definition at line 1179 of file gnunet-service-dht_clients.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MessageHeader::size.
|
static |
Handler for HELLO OFFER message.
Try to use the HELLO to connect to another peer.
| cls | the client we received this message from |
| msg | the actual message received |
Definition at line 1203 of file gnunet-service-dht_clients.c.
References ch, GDS_try_connect(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_url(), GNUNET_HELLO_parser_iterate(), GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), and msg.
|
static |
Handler for monitor start messages.
| cls | the client we received this message from |
| msg | the actual message received |
Definition at line 1239 of file gnunet-service-dht_clients.c.
References ch, ClientMonitorRecord::ch, ClientMonitorRecord::get, ClientMonitorRecord::get_resp, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_SERVICE_client_continue(), ClientMonitorRecord::key, monitor_head, monitor_tail, msg, ClientMonitorRecord::put, GNUNET_MessageHeader::type, and ClientMonitorRecord::type.
|
static |
Handler for monitor stop messages.
| cls | the client we received this message from |
| msg | the actual message received |
Definition at line 1267 of file gnunet-service-dht_clients.c.
References ch, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_is_zero, GNUNET_memcmp, GNUNET_SERVICE_client_continue(), monitor_head, monitor_tail, msg, ClientMonitorRecord::next, and GNUNET_MessageHeader::type.
|
static |
Call cb on all monitors that watch for blocks of type and key key.
| type | the type to match |
| key | the key to match |
| cb | function to call |
| cb_cls | closure for cb |
Definition at line 1324 of file gnunet-service-dht_clients.c.
References GNUNET_array_append, GNUNET_BLOCK_TYPE_ANY, GNUNET_free, GNUNET_is_zero, GNUNET_memcmp, key, m, monitor_head, and type.
Referenced by GDS_CLIENTS_process_get(), GDS_CLIENTS_process_get_resp(), and GDS_CLIENTS_process_put().
|
static |
Function called on monitors that match a GET.
Sends the GET notification to the monitor.
| cls | a struct GetActionContext |
| m | a matching monitor |
Definition at line 1387 of file gnunet-service-dht_clients.c.
References GNUNET_DHT_MonitorGetMessage::desired_replication_level, GetActionContext::desired_replication_level, env, GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_DHT_MonitorGetMessage::hop_count, GetActionContext::hop_count, GNUNET_DHT_MonitorGetMessage::key, GetActionContext::key, m, GNUNET_ARM_MonitorHandle::mq, GNUNET_DHT_MonitorGetMessage::options, GetActionContext::options, GNUNET_DHT_MonitorGetMessage::type, and GetActionContext::type.
Referenced by GDS_CLIENTS_process_get().
| void GDS_CLIENTS_process_get | ( | enum GNUNET_DHT_RouteOption | options, |
| enum GNUNET_BLOCK_Type | type, | ||
| uint32_t | hop_count, | ||
| uint32_t | desired_replication_level, | ||
| const struct GNUNET_HashCode * | key | ||
| ) |
Check if some client is monitoring GET messages and notify them in that case.
If tracked, path should include the local peer.
| options | Options, for instance RecordRoute, DemultiplexEverywhere. |
| type | The type of data in the request. |
| hop_count | Hop count so far. |
| desired_replication_level | Desired replication level. |
| key | Key of the requested data. |
Definition at line 1407 of file gnunet-service-dht_clients.c.
References GetActionContext::desired_replication_level, for_matching_monitors(), get_action(), GetActionContext::hop_count, key, options, GetActionContext::options, and type.
Referenced by handle_dht_local_get(), and handle_dht_p2p_get().
|
static |
Function called on monitors that match a response.
Sends the response notification to the monitor.
| cls | a struct ResponseActionContext |
| m | a matching monitor |
Definition at line 1447 of file gnunet-service-dht_clients.c.
References ResponseActionContext::bd, GNUNET_DATACACHE_Block::data, GNUNET_DATACACHE_Block::data_size, env, GNUNET_DATACACHE_Block::expiration_time, GNUNET_DHT_MonitorGetRespMessage::expiration_time, ResponseActionContext::get_path, GNUNET_DHT_MonitorGetRespMessage::get_path_length, ResponseActionContext::get_path_length, GNUNET_DHT_RO_TRUNCATED, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), GNUNET_DATACACHE_Block::key, GNUNET_DHT_MonitorGetRespMessage::key, m, GNUNET_ARM_MonitorHandle::mq, GNUNET_DATACACHE_Block::put_path, GNUNET_DATACACHE_Block::put_path_length, GNUNET_DHT_MonitorGetRespMessage::put_path_length, GNUNET_DATACACHE_Block::ro, GNUNET_DATACACHE_Block::trunc_peer, GNUNET_DATACACHE_Block::type, and GNUNET_DHT_MonitorGetRespMessage::type.
Referenced by GDS_CLIENTS_process_get_resp().
| void GDS_CLIENTS_process_get_resp | ( | const struct GNUNET_DATACACHE_Block * | bd, |
| const struct GNUNET_DHT_PathElement * | get_path, | ||
| unsigned int | get_path_length | ||
| ) |
Check if some client is monitoring GET RESP messages and notify them in that case.
| bd | block details |
| get_path | Peers on GET path (or NULL if not recorded). |
| get_path_length | number of entries in get_path. |
Definition at line 1501 of file gnunet-service-dht_clients.c.
References ResponseActionContext::bd, for_matching_monitors(), ResponseActionContext::get_path, ResponseActionContext::get_path_length, GNUNET_DATACACHE_Block::key, response_action(), and GNUNET_DATACACHE_Block::type.
Referenced by process_reply_with_path().
|
static |
Function called on monitors that match a PUT.
Sends the PUT notification to the monitor.
| cls | a struct PutActionContext |
| m | a matching monitor |
Definition at line 1537 of file gnunet-service-dht_clients.c.
References PutActionContext::bd, GNUNET_DATACACHE_Block::data, GNUNET_DATACACHE_Block::data_size, GNUNET_DHT_MonitorPutMessage::desired_replication_level, PutActionContext::desired_replication_level, env, GNUNET_DATACACHE_Block::expiration_time, GNUNET_DHT_MonitorPutMessage::expiration_time, GNUNET_DHT_RO_TRUNCATED, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), GNUNET_DHT_MonitorPutMessage::hop_count, PutActionContext::hop_count, GNUNET_DATACACHE_Block::key, GNUNET_DHT_MonitorPutMessage::key, m, GNUNET_ARM_MonitorHandle::mq, GNUNET_DHT_MonitorPutMessage::options, GNUNET_DATACACHE_Block::put_path, GNUNET_DATACACHE_Block::put_path_length, GNUNET_DHT_MonitorPutMessage::put_path_length, GNUNET_DATACACHE_Block::ro, GNUNET_DATACACHE_Block::trunc_peer, GNUNET_DATACACHE_Block::type, and GNUNET_DHT_MonitorPutMessage::type.
Referenced by GDS_CLIENTS_process_put().
| void GDS_CLIENTS_process_put | ( | const struct GNUNET_DATACACHE_Block * | bd, |
| uint32_t | hop_count, | ||
| uint32_t | desired_replication_level | ||
| ) |
Check if some client is monitoring PUT messages and notify them in that case.
The path should include our own peer ID (if recorded).
| bd | details about the block |
| hop_count | Hop count so far. |
| desired_replication_level | Desired replication level. |
Definition at line 1589 of file gnunet-service-dht_clients.c.
References PutActionContext::bd, PutActionContext::desired_replication_level, for_matching_monitors(), PutActionContext::hop_count, GNUNET_DATACACHE_Block::key, put_action(), and GNUNET_DATACACHE_Block::type.
Referenced by handle_dht_local_put(), and handle_dht_p2p_put().
| void GDS_CLIENTS_init | ( | void | ) |
Initialize client subsystem.
Definition at line 1613 of file gnunet-service-dht_clients.c.
References forward_map, GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_YES, and retry_heap.
Referenced by run().
| void GDS_CLIENTS_stop | ( | void | ) |
Shutdown client subsystem.
Definition at line 1627 of file gnunet-service-dht_clients.c.
References GNUNET_SCHEDULER_cancel(), and retry_task.
Referenced by shutdown_task().
| void GDS_CLIENTS_done | ( | void | ) |
| void __attribute__ | ( | (destructor) | ) |
MINIMIZE heap size (way below 128k) since this process doesn't need much.
Definition at line 1691 of file gnunet-service-dht_clients.c.
References forward_map, GNUNET_assert, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_size(), and retry_heap.
| struct GNUNET_BLOCK_Context* GDS_block_context |
Our handle to the BLOCK library.
Definition at line 217 of file gnunet-service-dht_clients.c.
Referenced by datacache_get_iterator(), forward_reply(), handle_dht_local_put(), handle_dht_p2p_get(), handle_dht_p2p_put(), handle_dht_p2p_result(), handle_find_local_hello(), handle_find_my_hello(), process(), run(), send_find_peer_message(), shutdown_task(), and transmit_request().
| struct GNUNET_STATISTICS_Handle* GDS_stats |
Handle for the statistics service.
Definition at line 222 of file gnunet-service-dht_clients.c.
Referenced by datacache_get_iterator(), do_send(), expire_oldest_entry(), forward_reply(), GDS_CLIENTS_handle_reply(), GDS_DATACACHE_get_closest(), GDS_DATACACHE_handle_get(), GDS_DATACACHE_handle_put(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), GDS_ROUTING_add(), GDS_u_connect(), GDS_u_disconnect(), get_forward_count(), handle_dht_local_get(), handle_dht_local_get_stop(), handle_dht_local_put(), handle_dht_p2p_get(), handle_dht_p2p_put(), handle_dht_p2p_result(), handle_find_my_hello(), process(), run(), select_peer(), send_find_peer_message(), shutdown_task(), transmit_request(), and update_network_size_estimate().
| struct GNUNET_PILS_Handle* GDS_pils |
Handle for the pils service.
Definition at line 227 of file gnunet-service-dht_clients.c.
Referenced by run(), and shutdown_task().
| struct GNUNET_SERVICE_Handle* GDS_service |
Handle for the service.
Definition at line 232 of file gnunet-service-dht_clients.c.
Referenced by run().
| const struct GNUNET_CONFIGURATION_Handle* GDS_cfg |
The configuration the DHT service is running with.
Configuration we use.
Definition at line 237 of file gnunet-service-dht_clients.c.
Referenced by GDS_DATACACHE_init(), GDS_NEIGHBOURS_init(), load_underlay(), and run().
|
static |
List of active monitoring requests.
Definition at line 242 of file gnunet-service-dht_clients.c.
Referenced by client_disconnect_cb(), for_matching_monitors(), handle_dht_local_monitor(), and handle_dht_local_monitor_stop().
|
static |
List of active monitoring requests.
Definition at line 247 of file gnunet-service-dht_clients.c.
Referenced by client_disconnect_cb(), handle_dht_local_monitor(), and handle_dht_local_monitor_stop().
|
static |
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries.
Definition at line 252 of file gnunet-service-dht_clients.c.
Referenced by __attribute__(), GDS_CLIENTS_handle_reply(), GDS_CLIENTS_init(), handle_dht_local_get(), handle_dht_local_get_result_seen(), handle_dht_local_get_stop(), and remove_client_query_record().
|
static |
Heap with all of our client's request, sorted by retry time (earliest on top).
Definition at line 257 of file gnunet-service-dht_clients.c.
Referenced by __attribute__(), GDS_CLIENTS_init(), handle_dht_local_get(), and transmit_next_request_task().
|
static |
Task that re-transmits requests (using retry_heap).
Definition at line 262 of file gnunet-service-dht_clients.c.
Referenced by GDS_CLIENTS_stop(), handle_dht_local_get(), and transmit_next_request_task().