library to access the DHT service More...
#include "platform.h"#include "gnunet_constants.h"#include "gnunet_signatures.h"#include "gnunet_arm_service.h"#include "gnunet_protocols.h"#include "gnunet_dht_service.h"#include "dht.h"Go to the source code of this file.
Data Structures | |
| struct | GNUNET_DHT_PutHandle |
| Handle to a PUT request. More... | |
| struct | GNUNET_DHT_GetHandle |
| Handle to a GET request. More... | |
| struct | GNUNET_DHT_MonitorHandle |
| Handle to a monitoring request. More... | |
| struct | GNUNET_DHT_HelloGetHandle |
| Handle to get a HELLO URL from the DHT for manual bootstrapping. More... | |
| struct | GNUNET_DHT_Handle |
| Connection to the DHT service. More... | |
Macros | |
| #define | LOG(kind, ...) GNUNET_log_from (kind, "dht-api", __VA_ARGS__) |
Functions | |
| static enum GNUNET_GenericReturnValue | try_connect (struct GNUNET_DHT_Handle *h) |
| Try to (re)connect to the DHT service. | |
| static void | send_get (struct GNUNET_DHT_GetHandle *gh) |
| Send GET message for a get_handle to DHT. | |
| static void | send_get_known_results (struct GNUNET_DHT_GetHandle *gh, unsigned int transmission_offset_start) |
| Send GET message(s) for indicating which results are already known for a get_handle to DHT. | |
| static enum GNUNET_GenericReturnValue | add_get_request_to_pending (void *cls, const struct GNUNET_HashCode *key, void *value) |
| Add the GET request corresponding to the given route handle to the pending queue (if it is not already in there). | |
| static void | send_monitor_start (struct GNUNET_DHT_MonitorHandle *mh) |
| Send GNUNET_MESSAGE_TYPE_DHT_MONITOR_START message. | |
| static void | try_reconnect (void *cls) |
| Try reconnecting to the dht service. | |
| static void | do_disconnect (struct GNUNET_DHT_Handle *h) |
| Try reconnecting to the DHT service. | |
| static void | 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. | |
| static void | handle_monitor_get (void *cls, const struct GNUNET_DHT_MonitorGetMessage *msg) |
| Process a get monitor message from the service. | |
| static enum GNUNET_GenericReturnValue | check_monitor_get_resp (void *cls, const struct GNUNET_DHT_MonitorGetRespMessage *msg) |
| Validate a get response monitor message from the service. | |
| static void | handle_monitor_get_resp (void *cls, const struct GNUNET_DHT_MonitorGetRespMessage *msg) |
| Process a get response monitor message from the service. | |
| static enum GNUNET_GenericReturnValue | check_monitor_put (void *cls, const struct GNUNET_DHT_MonitorPutMessage *msg) |
| Check validity of a put monitor message from the service. | |
| static void | handle_monitor_put (void *cls, const struct GNUNET_DHT_MonitorPutMessage *msg) |
| Process a put monitor message from the service. | |
| static enum GNUNET_GenericReturnValue | check_client_result (void *cls, const struct GNUNET_DHT_ClientResultMessage *msg) |
| Verify that client result message received from the service is well-formed. | |
| static enum GNUNET_GenericReturnValue | process_client_result (void *cls, const struct GNUNET_HashCode *key, void *value) |
| Process a given reply that might match the given request. | |
| static void | handle_client_result (void *cls, const struct GNUNET_DHT_ClientResultMessage *msg) |
| Process a client result message received from the service. | |
| static enum GNUNET_GenericReturnValue | check_client_hello (void *cls, const struct GNUNET_MessageHeader *hdr) |
| Process a client HELLO message received from the service. | |
| static void | handle_client_hello (void *cls, const struct GNUNET_MessageHeader *hdr) |
| Process a client HELLO message received from the service. | |
| static void | handle_put_cont (void *cls) |
| Process a MQ PUT transmission notification. | |
| struct GNUNET_DHT_Handle * | GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len) |
| Initialize the connection with the DHT service. | |
| void | GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) |
| Shutdown connection with the DHT service. | |
| struct GNUNET_DHT_PutHandle * | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls) |
| Perform a PUT operation storing data in the DHT. | |
| void | GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph) |
| Cancels a DHT PUT operation. | |
| struct GNUNET_DHT_GetHandle * | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls) |
| Perform an asynchronous GET operation on the DHT identified. | |
| void | GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handle, unsigned int num_results, const struct GNUNET_HashCode *results) |
| Tell the DHT not to return any of the following known results to this client. | |
| void | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle) |
| Stop async DHT-get. | |
| struct GNUNET_DHT_MonitorHandle * | GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, GNUNET_DHT_MonitorGetCB get_cb, GNUNET_DHT_MonitorGetRespCB get_resp_cb, GNUNET_DHT_MonitorPutCB put_cb, void *cb_cls) |
| Start monitoring the local DHT service. | |
| void | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *mh) |
| Stop monitoring. | |
| char * | GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path, unsigned int path_len) |
| Convert a peer path to a human-readable string. | |
| unsigned int | GNUNET_DHT_verify_path (const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, const struct GNUNET_PeerIdentity *bpid, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_len, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_len, const struct GNUNET_PeerIdentity *me) |
| Verify signatures on a path consisting of put_path and get_path in reverse order (starting at the last element of the get_path). | |
| struct GNUNET_DHT_HelloGetHandle * | GNUNET_DHT_hello_get (struct GNUNET_DHT_Handle *dht_handle, GNUNET_DHT_HelloGetCallback cb, void *cb_cls) |
| Obtain HELLO URL of the DHT identified by dht_handle. | |
| void | GNUNET_DHT_hello_get_cancel (struct GNUNET_DHT_HelloGetHandle *hgh) |
| Cancel hello get operation. | |
| void | GNUNET_DHT_hello_offer (struct GNUNET_DHT_Handle *dht_handle, const char *url, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls) |
| Offer HELLO URL of the DHT identified by dht_handle. | |
library to access the DHT service
Definition in file dht_api.c.
| #define LOG | ( | kind, | |
| ... | |||
| ) | GNUNET_log_from (kind, "dht-api", __VA_ARGS__) |
|
static |
Try to (re)connect to the DHT service.
| h | DHT handle to reconnect |
Definition at line 986 of file dht_api.c.
References GNUNET_ARM_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL, GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT, GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET, GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP, GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_OK, GNUNET_YES, h, handlers, LOG, GNUNET_ARM_Handle::mq, and mq_error_handler().
Referenced by GNUNET_DHT_connect(), and try_reconnect().
|
static |
Send GET message for a get_handle to DHT.
| gh | GET to generate messages for. |
Definition at line 316 of file dht_api.c.
References GNUNET_DHT_ClientGetMessage::desired_replication_level, GNUNET_DHT_GetHandle::desired_replication_level, GNUNET_DHT_GetHandle::dht_handle, env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), h, GNUNET_DHT_ClientGetMessage::key, GNUNET_DHT_GetHandle::key, GNUNET_ARM_Handle::mq, GNUNET_DHT_ClientGetMessage::options, GNUNET_DHT_GetHandle::options, GNUNET_DHT_ClientGetMessage::type, GNUNET_DHT_GetHandle::type, GNUNET_DHT_ClientGetMessage::unique_id, GNUNET_DHT_GetHandle::unique_id, and GNUNET_DHT_GetHandle::xquery_size.
Referenced by add_get_request_to_pending(), and GNUNET_DHT_get_start().
|
static |
Send GET message(s) for indicating which results are already known for a get_handle to DHT.
Complex as we need to send the list of known results, which means we may need multiple messages to block known results from the result set.
| gh | GET to generate messages for |
| transmission_offset_start | at which offset should we start? |
Definition at line 348 of file dht_api.c.
References delta, GNUNET_DHT_GetHandle::dht_handle, env, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), h, GNUNET_DHT_GetHandle::key, max, GNUNET_ARM_Handle::mq, msg, GNUNET_DHT_GetHandle::seen_results, GNUNET_DHT_GetHandle::seen_results_end, and GNUNET_DHT_GetHandle::unique_id.
Referenced by add_get_request_to_pending(), and GNUNET_DHT_get_filter_known_results().
|
static |
Add the GET request corresponding to the given route handle to the pending queue (if it is not already in there).
| cls | the struct GNUNET_DHT_Handle * |
| key | key for the request (not used) |
| value | the struct GNUNET_DHT_GetHandle * |
Definition at line 391 of file dht_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_YES, handle, key, LOG, send_get(), send_get_known_results(), and value.
Referenced by try_reconnect().
|
static |
Send GNUNET_MESSAGE_TYPE_DHT_MONITOR_START message.
| mh | monitor handle to generate start message for |
Definition at line 414 of file dht_api.c.
References env, GNUNET_MESSAGE_TYPE_DHT_MONITOR_START, GNUNET_MQ_msg, GNUNET_MQ_send(), h, m, mh, and GNUNET_ARM_Handle::mq.
Referenced by GNUNET_DHT_monitor_start(), and try_reconnect().
|
static |
Try reconnecting to the dht service.
| cls | a struct GNUNET_DHT_Handle |
Definition at line 442 of file dht_api.c.
References add_get_request_to_pending(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, h, LOG, mh, GNUNET_ARM_Handle::reconnect_task, send_monitor_start(), try_connect(), and try_reconnect().
Referenced by do_disconnect(), and try_reconnect().
|
static |
Try reconnecting to the DHT service.
| h | handle to dht to (possibly) disconnect and reconnect |
Definition at line 476 of file dht_api.c.
References GNUNET_DHT_PutHandle::cont, GNUNET_DHT_PutHandle::cont_cls, GNUNET_DHT_PutHandle::env, GNUNET_assert, GNUNET_DHT_put_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, h, GNUNET_ARM_Handle::mq, GNUNET_ARM_Handle::reconnect_task, and try_reconnect().
|
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_DHT_Handle * |
| error | error code |
Definition at line 517 of file dht_api.c.
References do_disconnect, and h.
Referenced by try_connect().
|
static |
Process a get monitor message from the service.
| cls | The DHT handle. |
| msg | Monitor get message from the service. |
Definition at line 533 of file dht_api.c.
References GNUNET_BLOCK_TYPE_ANY, GNUNET_memcmp, handle, mh, msg, and GNUNET_MessageHeader::type.
|
static |
Validate a get response monitor message from the service.
| cls | The DHT handle. |
| msg | monitor get response message from the service |
Definition at line 571 of file dht_api.c.
References GNUNET_break, GNUNET_DHT_RO_TRUNCATED, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.
|
static |
Process a get response monitor message from the service.
| cls | The DHT handle. |
| msg | monitor get response message from the service |
Definition at line 606 of file dht_api.c.
References GNUNET_BLOCK_TYPE_ANY, GNUNET_DHT_RO_TRUNCATED, GNUNET_memcmp, GNUNET_TIME_absolute_ntoh(), handle, mh, msg, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
|
static |
Check validity of a put monitor message from the service.
| cls | The DHT handle. |
| msg | Monitor put message from the service. |
Definition at line 664 of file dht_api.c.
References GNUNET_break, GNUNET_DHT_RO_TRUNCATED, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.
|
static |
Process a put monitor message from the service.
| cls | The DHT handle. |
| msg | Monitor put message from the service. |
Definition at line 697 of file dht_api.c.
References GNUNET_BLOCK_TYPE_ANY, GNUNET_DHT_RO_TRUNCATED, GNUNET_memcmp, GNUNET_TIME_absolute_ntoh(), handle, mh, msg, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
|
static |
Verify that client result message received from the service is well-formed.
| cls | The DHT handle. |
| msg | Monitor put message from the service. |
Definition at line 755 of file dht_api.c.
References GNUNET_break, GNUNET_DHT_RO_TRUNCATED, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.
|
static |
Process a given reply that might match the given request.
| cls | the struct GNUNET_DHT_ClientResultMessage |
| key | query of the request |
| value | the struct GNUNET_DHT_GetHandle of a request matching the same key |
Definition at line 796 of file dht_api.c.
References data, GNUNET_DHT_ClientResultMessage::expiration, get_handle, GNUNET_DHT_ClientResultMessage::get_path_length, GNUNET_array_grow, GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_CRYPTO_hash(), GNUNET_DHT_pp2s(), GNUNET_DHT_RO_TRUNCATED, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, GNUNET_DHT_ClientResultMessage::header, GNUNET_DHT_GetHandle::iter, GNUNET_DHT_GetHandle::iter_cls, key, LOG, GNUNET_DHT_ClientResultMessage::options, GNUNET_DHT_ClientResultMessage::put_path_length, GNUNET_DHT_GetHandle::seen_results, GNUNET_DHT_GetHandle::seen_results_end, GNUNET_DHT_GetHandle::seen_results_size, GNUNET_MessageHeader::size, type, GNUNET_DHT_ClientResultMessage::type, GNUNET_DHT_GetHandle::type, GNUNET_DHT_ClientResultMessage::unique_id, GNUNET_DHT_GetHandle::unique_id, and value.
Referenced by handle_client_result().
|
static |
Process a client result message received from the service.
| cls | The DHT handle. |
| msg | Monitor put message from the service. |
Definition at line 899 of file dht_api.c.
References GNUNET_CONTAINER_multihashmap_get_multiple(), handle, msg, and process_client_result().
|
static |
Process a client HELLO message received from the service.
| cls | The DHT handle. |
| hdr | HELLO URL message from the service. |
Definition at line 919 of file dht_api.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MessageHeader::size.
|
static |
Process a client HELLO message received from the service.
| cls | The DHT handle. |
| hdr | HELLO URL message from the service. |
Definition at line 942 of file dht_api.c.
References GNUNET_DHT_HelloGetHandle::cb, GNUNET_DHT_HelloGetHandle::cb_cls, GNUNET_DHT_hello_get_cancel(), and handle.
|
static |
Process a MQ PUT transmission notification.
| cls | The DHT handle. |
Definition at line 964 of file dht_api.c.
References GNUNET_DHT_PutHandle::cont, GNUNET_DHT_PutHandle::cont_cls, GNUNET_DHT_PutHandle::env, and GNUNET_DHT_put_cancel().
Referenced by GNUNET_DHT_put().