![]() |
GNUnet
0.11.x
|
Distributed Hash Table. More...
Macros | |
#define | GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY |
Default republication frequency for stored data in the DHT. More... | |
Typedefs | |
typedef void(* | GNUNET_DHT_GetIterator) (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data) |
Iterator called on each result obtained for a DHT operation that expects a reply. More... | |
typedef void(* | GNUNET_DHT_MonitorGetCB) (void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, const struct GNUNET_HashCode *key) |
Callback called on each GET request going through the DHT. More... | |
typedef void(* | GNUNET_DHT_MonitorGetRespCB) (void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size) |
Callback called on each GET reply going through the DHT. More... | |
typedef void(* | GNUNET_DHT_MonitorPutCB) (void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size) |
Callback called on each PUT request going through the DHT. More... | |
Enumerations | |
enum | GNUNET_DHT_RouteOption { GNUNET_DHT_RO_NONE = 0, GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1, GNUNET_DHT_RO_RECORD_ROUTE = 2, GNUNET_DHT_RO_FIND_PEER = 4, GNUNET_DHT_RO_BART = 8, GNUNET_DHT_RO_LAST_HOP = 16 } |
Options for routing. More... | |
Functions | |
struct GNUNET_DHT_Handle * | GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len) |
Initialize the connection with the DHT service. More... | |
void | GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) |
Shutdown connection with the DHT service. More... | |
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. More... | |
void | GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph) |
Cancels a DHT PUT operation. More... | |
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. More... | |
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. More... | |
void | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle) |
Stop async DHT-get. More... | |
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. More... | |
void | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle) |
Stop monitoring. More... | |
Distributed Hash Table.
#define GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY |
Default republication frequency for stored data in the DHT.
Definition at line 54 of file gnunet_dht_service.h.
Referenced by run(), and schedule_next_put().
typedef void(* GNUNET_DHT_GetIterator) (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data) |
Iterator called on each result obtained for a DHT operation that expects a reply.
cls | closure |
exp | when will this value expire |
key | key of the result |
get_path | peers on reply path (or NULL if not recorded) [0] = datastore's first neighbor, [length - 1] = local peer |
get_path_length | number of entries in get_path |
put_path | peers on the PUT path (or NULL if not recorded) [0] = origin, [length - 1] = datastore |
put_path_length | number of entries in put_path |
type | type of the result |
size | number of bytes in data |
data | pointer to the result data |
Definition at line 208 of file gnunet_dht_service.h.
typedef void(* GNUNET_DHT_MonitorGetCB) (void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, const struct GNUNET_HashCode *key) |
Callback called on each GET request going through the DHT.
cls | Closure. |
options | Options, for instance RecordRoute, DemultiplexEverywhere. |
type | The type of data in the request. |
hop_count | Hop count so far. |
path_length | number of entries in path (or 0 if not recorded). |
path | peers on the GET path (or NULL if not recorded). |
desired_replication_level | Desired replication level. |
key | Key of the requested data. |
Definition at line 292 of file gnunet_dht_service.h.
typedef void(* GNUNET_DHT_MonitorGetRespCB) (void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size) |
Callback called on each GET reply going through the DHT.
cls | Closure. |
type | The type of data in the result. |
get_path | Peers on GET path (or NULL if not recorded). |
get_path_length | number of entries in get_path. |
put_path | peers on the PUT path (or NULL if not recorded). |
put_path_length | number of entries in get_path. |
exp | Expiration time of the data. |
key | Key of the data. |
data | Pointer to the result data. |
size | Number of bytes in data. |
Definition at line 317 of file gnunet_dht_service.h.
typedef void(* GNUNET_DHT_MonitorPutCB) (void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size) |
Callback called on each PUT request going through the DHT.
cls | Closure. |
options | Options, for instance RecordRoute, DemultiplexEverywhere. |
type | The type of data in the request. |
hop_count | Hop count so far. |
path_length | number of entries in path (or 0 if not recorded). |
path | peers on the PUT path (or NULL if not recorded). |
desired_replication_level | Desired replication level. |
exp | Expiration time of the data. |
key | Key under which data is to be stored. |
data | Pointer to the data carried. |
size | Number of bytes in data. |
Definition at line 345 of file gnunet_dht_service.h.
Options for routing.
Definition at line 77 of file gnunet_dht_service.h.
struct GNUNET_DHT_Handle* GNUNET_DHT_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
unsigned int | ht_len | ||
) |
Initialize the connection with the DHT service.
cfg | configuration to use |
ht_len | size of the internal hash table to use for processing multiple GET/FIND requests in parallel |
cfg | configuration to use |
ht_len | size of the internal hash table to use for processing multiple GET/FIND requests in parallel |
Definition at line 890 of file dht_api.c.
References GNUNET_DHT_Handle::active_requests, cfg, GNUNET_DHT_Handle::cfg, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_DHT_disconnect(), GNUNET_new, GNUNET_NO, GNUNET_YES, handle, try_connect(), and GNUNET_DHT_Handle::uid_gen.
Referenced by advertise_dns_exit(), dht_ca(), dht_connect(), dht_connect_adapter(), GCD_init(), and run().
void GNUNET_DHT_disconnect | ( | struct GNUNET_DHT_Handle * | handle | ) |
Shutdown connection with the DHT service.
handle | connection to shut down |
handle | handle of the DHT connection to stop |
Definition at line 918 of file dht_api.c.
References GNUNET_DHT_Handle::active_requests, GNUNET_DHT_PutHandle::cont, GNUNET_DHT_PutHandle::cont_cls, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_DHT_put_cancel(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_DHT_Handle::mq, ph, GNUNET_DHT_Handle::put_head, and GNUNET_DHT_Handle::reconnect_task.
Referenced by cleanup(), cleanup_task(), dht_da(), dht_disconnect(), dht_disconnect_adapter(), GCD_shutdown(), GNUNET_DHT_connect(), and shutdown_task().
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.
handle | handle to DHT service |
key | the key to store under |
desired_replication_level | estimate of how many nearest peers this request should reach |
options | routing options for this message |
type | type of the value |
size | number of bytes in data; must be less than 64k |
data | the data to store |
exp | desired expiration time for the value |
cont | continuation to call when done (transmitting request to service) You must not call GNUNET_DHT_disconnect in this continuation |
cont_cls | closure for cont |
FIXME: we should change the protocol to get a confirmation for the PUT from the DHT and call 'cont' only after getting the confirmation; otherwise, the client has no good way of telling if the 'PUT' message actually got to the DHT service!
handle | handle to DHT service |
key | the key to store under |
desired_replication_level | estimate of how many nearest peers this request should reach |
options | routing options for this message |
type | type of the value |
size | number of bytes in data; must be less than 64k |
data | the data to store |
exp | desired expiration time for the value |
cont | continuation to call when done (transmitting request to service) You must not call GNUNET_DHT_disconnect in this continuation |
cont_cls | closure for cont |
Definition at line 966 of file dht_api.c.
References GNUNET_DHT_PutHandle::cont, GNUNET_DHT_PutHandle::cont_cls, GNUNET_DHT_ClientPutMessage::desired_replication_level, GNUNET_DHT_PutHandle::dht_handle, GNUNET_DHT_PutHandle::env, GNUNET_DHT_ClientPutMessage::expiration, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_new, GNUNET_TIME_absolute_hton(), handle, handle_put_cont(), key, GNUNET_DHT_ClientPutMessage::key, LOG, GNUNET_DHT_Handle::mq, GNUNET_DHT_ClientPutMessage::options, ph, GNUNET_DHT_Handle::put_head, GNUNET_DHT_Handle::put_tail, and GNUNET_DHT_ClientPutMessage::type.
Referenced by announce_id(), delayed_put(), do_dht_put(), message_sent_cont(), perform_dht_put(), process_dht_put_content(), regex_iterator(), and run().
void GNUNET_DHT_put_cancel | ( | struct GNUNET_DHT_PutHandle * | ph | ) |
Cancels a DHT PUT operation.
Note that the PUT request may still go out over the network (we can't stop that); However, if the PUT has not yet been sent to the service, cancelling the PUT will stop this from happening (but there is no way for the user of this API to tell if that is the case). The only use for this API is to prevent a later call to 'cont' from GNUNET_DHT_put (i.e. because the system is shutting down).
ph | put operation to cancel ('cont' will no longer be called) |
Definition at line 1035 of file dht_api.c.
References GNUNET_DHT_PutHandle::dht_handle, GNUNET_DHT_PutHandle::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_notify_sent(), handle, GNUNET_DHT_Handle::put_head, and GNUNET_DHT_Handle::put_tail.
Referenced by cleanup(), do_dht_put(), do_disconnect(), do_shutdown(), GNUNET_DHT_disconnect(), GSF_put_done_(), handle_monitor_event(), handle_put_cont(), put_gns_record(), and shutdown_task().
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.
See also GNUNET_BLOCK_evaluate.
handle | handle to the DHT service |
type | expected type of the response object |
key | the key to look up |
desired_replication_level | estimate of how many nearest peers this request should reach |
options | routing options for this message |
xquery | extended query data (can be NULL, depending on type) |
xquery_size | number of bytes in xquery |
iter | function to call on each result |
iter_cls | closure for iter |
Definition at line 1067 of file dht_api.c.
References GNUNET_DHT_Handle::active_requests, GNUNET_DHT_ClientGetMessage::desired_replication_level, GNUNET_DHT_GetHandle::desired_replication_level, GNUNET_DHT_GetHandle::dht_handle, gh, GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_malloc, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, handle, GNUNET_DHT_GetHandle::iter, GNUNET_DHT_GetHandle::iter_cls, key, GNUNET_DHT_GetHandle::key, LOG, GNUNET_DHT_Handle::mq, options, GNUNET_DHT_GetHandle::options, send_get(), GNUNET_DHT_GetHandle::type, type, GNUNET_DHT_Handle::uid_gen, GNUNET_DHT_GetHandle::unique_id, and GNUNET_DHT_GetHandle::xquery_size.
Referenced by delayed_get(), GCD_search(), get_result_iterator(), GSF_dht_lookup_(), regex_find_path(), REGEX_INTERNAL_search(), regex_next_edge(), run(), and start_dht_request().
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.
get_handle | get operation for which results should be filtered |
num_results | number of results to be blocked that are provided in this call (size of the results array) |
results | array of hash codes over the data of the results to be blocked |
get_handle | get operation for which results should be filtered |
num_results | number of results to be blocked that are provided in this call (size of the results array) |
results | array of hash codes over the 'data' of the results to be blocked |
Definition at line 1126 of file dht_api.c.
References GNUNET_DHT_GetHandle::dht_handle, GNUNET_array_grow, GNUNET_memcpy, GNUNET_DHT_Handle::mq, GNUNET_DHT_GetHandle::seen_results, GNUNET_DHT_GetHandle::seen_results_end, GNUNET_DHT_GetHandle::seen_results_size, and send_get_known_results().
Referenced by GSF_dht_lookup_(), and GSF_pending_request_update_().
void GNUNET_DHT_get_stop | ( | struct GNUNET_DHT_GetHandle * | get_handle | ) |
Stop async DHT-get.
Frees associated resources.
get_handle | GET operation to stop. |
get_handle | handle to the GET operation to stop |
Definition at line 1155 of file dht_api.c.
References GNUNET_DHT_Handle::active_requests, GNUNET_DHT_GetHandle::dht_handle, GNUNET_DHT_PutHandle::env, GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, handle, GNUNET_DHT_ClientGetStopMessage::key, GNUNET_DHT_GetHandle::key, LOG, GNUNET_DHT_Handle::mq, GNUNET_DHT_ClientGetStopMessage::reserved, GNUNET_DHT_GetHandle::seen_results, GNUNET_DHT_GetHandle::seen_results_end, GNUNET_DHT_ClientGetStopMessage::unique_id, and GNUNET_DHT_GetHandle::unique_id.
Referenced by cancel_get(), clean_request(), cleanup(), cleanup_task(), do_shutdown(), GCD_search_stop(), get_iter(), get_result_iterator(), GNS_resolver_lookup_cancel(), GSF_dht_lookup_(), GSF_pending_request_cancel_(), handle_dht_response(), and regex_cancel_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.
handle | Handle to the DHT service. |
type | Type of blocks that are of interest. |
key | Key of data of interest, NULL for all. |
get_cb | Callback to process monitored get messages. |
get_resp_cb | Callback to process monitored get response messages. |
put_cb | Callback to process monitored put messages. |
cb_cls | Closure for callbacks |
handle | Handle to the DHT service. |
type | Type of blocks that are of interest. |
key | Key of data of interest, NULL for all. |
get_cb | Callback to process monitored get messages. |
get_resp_cb | Callback to process monitored get response messages. |
put_cb | Callback to process monitored put messages. |
cb_cls | Closure for callbacks. |
Definition at line 1200 of file dht_api.c.
References GNUNET_DHT_MonitorHandle::cb_cls, GNUNET_DHT_MonitorHandle::dht_handle, GNUNET_DHT_MonitorHandle::get_cb, get_cb(), GNUNET_DHT_MonitorHandle::get_resp_cb, GNUNET_CONTAINER_DLL_insert, GNUNET_new, handle, key, GNUNET_DHT_MonitorHandle::key, mh, GNUNET_DHT_Handle::monitor_head, GNUNET_DHT_Handle::monitor_tail, GNUNET_DHT_Handle::mq, put_cb(), GNUNET_DHT_MonitorHandle::put_cb, send_monitor_start(), type, and GNUNET_DHT_MonitorHandle::type.
Referenced by run().
void GNUNET_DHT_monitor_stop | ( | struct GNUNET_DHT_MonitorHandle * | mh | ) |
Stop monitoring.
On return handle will no longer be valid, caller must not use it anymore.
handle | The handle to the monitor request returned by GNUNET_DHT_monitor_start(). |
mh | The handle to the monitor request returned by monitor_start. |
On return get_handle will no longer be valid, caller must not use again!!!
Definition at line 1239 of file dht_api.c.
References GNUNET_DHT_MonitorHandle::dht_handle, GNUNET_DHT_PutHandle::env, GNUNET_DHT_MonitorStartStopMessage::filter_key, GNUNET_DHT_MonitorStartStopMessage::get, GNUNET_DHT_MonitorHandle::get_cb, GNUNET_DHT_MonitorStartStopMessage::get_resp, GNUNET_DHT_MonitorHandle::get_resp_cb, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), handle, GNUNET_DHT_MonitorHandle::key, GNUNET_DHT_MonitorStartStopMessage::key, m, GNUNET_DHT_Handle::monitor_head, GNUNET_DHT_Handle::monitor_tail, GNUNET_DHT_Handle::mq, GNUNET_DHT_MonitorStartStopMessage::put, GNUNET_DHT_MonitorHandle::put_cb, GNUNET_DHT_MonitorHandle::type, and GNUNET_DHT_MonitorStartStopMessage::type.
Referenced by cleanup_task().